- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我从来都不喜欢 Awesome 中默认的窗口切换可能性,所以我想我应该实现考虑到历史的 Alt-Tab 行为(并且做花哨的不透明效果)。
当按下 Alt-Tab 时,整个历史记录在一个表中,并附加到该历史记录的是最小化的窗口(在同一标签内)。生成此表后,我实例化一个捕获 Tab 键事件(切换到表中的下一个客户端)和 Alt 键释放事件(完全中止)的键盘抓取器。
一个标记会跟踪用户是否在按 Alt-tabbing 的过程中,以防止表格被一遍又一遍地生成。
代码(很多,你可能不需要看,但我的经验告诉我,当我不发布所有代码时,人们最终会要求它):
altTabbing = false
altTabIndex = 1
altTabHistory = {}
clientOpacities = {}
function altTabSetOpacities(restore)
for i,c in pairs(altTabHistory) do
if not restore and i ~= altTabIndex then
c.opacity = 0.5
else
c.opacity = clientOpacities[i]
end
end
end
function myAltTab()
-- First check if the user is already alttabbing, in which case the history
-- should NOT be updated. If the user has just pressed alt-tab, generate a new
-- history-table
if not altTabbing then -- generate history-table
-- Clear Tables
for i in pairs(altTabHistory) do altTabHistory[i] = nil end
for i in pairs(clientOpacities) do clientOpacities[i] = nil end
-- Get focus history for current tag
local s = mouse.screen;
local idx = 0
local c = awful.client.focus.history.get(s, idx)
while c do
table.insert(altTabHistory, c)
table.insert(clientOpacities, c.opacity)
idx = idx + 1
c = awful.client.focus.history.get(s, idx)
end
-- Minimized clients will not appear in the focus history
-- Find them by cycling through all clients, and adding them to the list
-- if not already there.
-- This will preserve the history AND enable you to focus on minimized clients
local t = awful.tag.selected(s)
local all = client.get(s)
for i = 1, #all do
local c = all[i]
local ctags = c:tags();
-- check if the client is on the current tag
local isCurrentTag = false
for j = 1, #ctags do
if t == ctags[j] then
isCurrentTag = true
break
end
end
if isCurrentTag then
-- check if client is already in the history
-- if not, add it
local addToHistory = true
for k = 1, #altTabHistory do
if altTabHistory[k] == c then
addToHistory = false
break
end
end
if addToHistory then
table.insert(altTabHistory, c)
table.insert(clientOpacities, c.opacity)
end
end
end
-- reset current index and flag
altTabIndex = 1
altTabbing = true
-- Now that we have collected all windows, we should run a keygrabber
-- as long as the user is alt-tabbing:
keygrabber.run(
function (mod, key, event)
-- Stop alt-tabbing when the alt-key is released
if key == "Alt_L" and event == "release" then
altTabbing = false
altTabSetOpacities(true)
c = altTabHistory[altTabIndex]
client.focus = c
c:raise()
return false -- stop keygrabber
end
-- Move to next client on each Tab-press
if key == "Tab" and event == "press" then
myAltTab()
return true -- keep going
end
return true -- keep going
end
)
end -- if not altTabbing
-- at this point, the user is alt-tabbing, so we should raise
-- the next client in the history-table
if #altTabHistory < 2 then return end
-- Switch to next client
altTabIndex = altTabIndex + 1
if altTabIndex > #altTabHistory then
altTabIndex = 1 -- wrap around
end
-- focus on current client
local c = altTabHistory[altTabIndex]
c.minimized = false
c:raise()
-- make current client stand out
altTabSetOpacities(false)
end
我知道有很多代码,但最主要的是 keygrabber。由于仍然未知的原因,当我使用这种方法使用 Alt-Tabbing 时,Awesome 有时会崩溃。我想通过将信号连接到 Alt 和 Tab 键来替换 keygrabber,并在用户完成后立即断开它们。但是,出于某种原因,我无法执行此操作。
我像这样实例化一个新的键对象:
local altkey = awful.key({}, "Alt_L")[1]
我通过反复试验发现 awful.key()
实际上返回了一个表,我可以在其中查询第一个元素的 key
,keysym
等,因此 [1]
。但是,当我尝试将信号连接到该对象时,LUA 解释器会提示并告诉我它是一个 nil 对象。所以我的问题是:我在这里做的事情对吗?是否有可能按照我打算的方式更换 keygrabber?
最佳答案
要在 Awesome 中使用 Alt_L 键,您应该在 rc.lua 文件中引用“Mod1”,为了使其更具可读性,我在配置的开头添加了以下行,以便可以使用 Alt_L。
Alt_L = "Mod1"
关于lua - Awesome WM (v3.5.5) keygrabber 替代品,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24756997/
我不完全确定我理解 substitute 的作用,尽管我以前在它的代码中使用过。今天在shiny::exprToFunction中遇到了如下几行代码: function (expr, env = pa
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,因为
我最近发现了 crockford 的 Javascript supplant 函数。函数是这样的—— if (!String.prototype.supplant) { String.prot
在我工作的一些项目中,添加了一些具有这种语法的 block : var [code, name] = input.split("/"); console.log(code); console.log(
我对 JavaBeans 模式的憎恨就像一千个太阳的火焰一样燃烧。为什么? 冗长。现在是 2009 年。我不应该为一个属性写 7 LOC。如果他们有事件监听器,请捕获你的帽子。 没有类型安全的引用。没
是否有比 PHP 执行速度更快且具有相同功能集(例如对常见 RDBMS、Curl、Regex 等的支持)的替代品? 用 C 编写网站代码怎么样?效果如何?该平台是否独立并在每台服务器上运行? 最佳答案
我正在开始新项目。客户端界面基于 GWT(和 GXT),我没有说它是预先确定的。但是,我可以选择服务器端,这样我就可以玩得开心,并希望在这个过程中学到一些新东西。一些要求是: 与服务器的交换将通过使用
我目前使用 CentOS 5.6(Ghostscript 8 - ImageMagick-6.2.8) 我正在尝试将 pdf 的第一张图像转换为 jpg 文件。 我知道我当前的设置无法转换压缩的 pd
2021 年更新: 只使用 MathJax;您不应该再支持旧版本的 IE。 我想使用 MathJax 来显示 MathML 方程,但它在 IE 中的性能慢得令人无法接受(是的,我读过使用 Emulat
BinaryFormatter 序列化的 128³ 数组加倍,占用 50 MB 空间。序列化具有两个双字段的 128³ 结构数组需要 150 MB 和超过 20 秒的处理时间。 是否有快速简单的替代方
我发现 $.each 非常慢,如果包含大量各种 jQuery 效果,会给网页带来问题。 我想知道 $.each 是否有一个好的替代方案,例如: $('ul li').each(function() {
我正在编写一个Mac应用程序,它提供类似“测试”的功能。此应用程序(通过与服务器的连接)。基本上,该应用程序将为学生提供一个故事供阅读,然后是一系列问题(也来自服务器),用户可以(尝试)选择正确的答案
我喜欢 WPF,但我讨厌 XAML。 XAML 过于冗长,在 Microsoft 尝试对其进行扩展时出现语法问题(请参阅 StringFormat on Bindings),并且难以导航。 XAML
已结束。此问题正在寻求书籍、工具、软件库等的推荐。它不满足 Stack Overflow guidelines 。目前不接受答案。 我们不允许提出寻求书籍、工具、软件库等推荐的问题。您可以编辑问题,以
有没有类似 SoftwareFx 的 PowerGadgets 的产品?我正在查看支持自动刷新的 powershell 的仪表控件。 最佳答案 检查 ShowUI 模块。 http://showui.
我正在开发一个项目,其中页面需要能够根据服务器的状态保持更新。 我喜欢 websocket,因为它们为我提供了一种从服务器推送消息的方法,但可用性是一个问题。 我需要通用方法在网络服务器和浏览器客户端
我最近一直在使用 openX 自托管广告管理软件,但它太慢了。 目标:我需要能够展示一个广告,获得 10 次点击,然后停用该广告,并且每天都这样做。 问题:当我将 openX 设置为每天 10 次点击
就目前情况而言,这个问题不太适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、民意调查或扩展讨论。如果您觉得这个问题可以改进并可能重新开放,visit
我正在尝试实现一个简单的类,该类允许用户裁剪用于其个人资料图片的图像。这是一个 Java Web 应用程序。 我做了一些搜索,发现 java.awt 有一个 BufferedImage 类,这看起来(
只是一个关于 JQuery 的简单问题,我一直在使用phonegap 并使用 JQuery 制作了一些应用程序。其中一个运行速度非常慢,所以我一直在努力尽可能地精简它。 我一直在考虑的一个更改是用更小
我是一名优秀的程序员,十分优秀!