在AwesomeWM上始终位于最上方的窗口并保持关注 [英] Always-on-top window and keeping focus, on AwesomeWM

查看:124
本文介绍了在AwesomeWM上始终位于最上方的窗口并保持关注的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个脚本,该脚本创建并关闭多个窗口,因此,我在rc.lua中添加了一种使窗口始终保持在顶部的方式:

I am running a script which creates and closes several windows, hence, I added to my rc.lua a way to keep the window where I am working always on top:

awful.key({ modkey, "Control" }, "space",
function(c)
  awful.client.floating.toggle()
  c.ontop = not c.ontop
end),

问题是:创建新窗口时,我失去了焦点,该焦点传递给了新窗口.

The problem is:when the new window is created, I lose the focus, which passes to the new window.

是否有办法使上一个切换不仅使窗口保持在顶部,而且还使焦点一直保持到我再次切换它?

Is there a way to make that the previous toggle not only keep the window on top, but also with the focus until I toggle it again?

推荐答案

假定

Assuming the awful.rules.rules assignment from lines 357-375 of this awesomerc.lua file are in your user's awesomerc.lua file and the awful.client.focus.filter used in that assignment is the one from this file then you should be able to do something like this.

在rc文件中的某个位置定义自定义焦点过滤器功能.

Define a custom focus filter function somewhere in your rc file.

function custom_focus_filter(c)
    if global_focus_disable then
        return nil
    end
    return awful.client.focus.filter(c)
end

然后在规则分配中使用该自定义过滤器功能代替原始过滤器功能.

Then use that custom filter function in the rules assignment in place of the original filter function.

awful.rules.rules = {
    -- All clients will match this rule.
    { rule = { },
      properties = { ....
                     focus = custom_focus_filter,
                     .... } },

然后您的切换功能只需要适当地设置和取消设置全局.

And then your toggle function just needs to set and unset the global as appropriate.

awful.key({ modkey, "Shift" }, "f", function ()
    global_focus_disable = not global_focus_disable
end)

这篇关于在AwesomeWM上始终位于最上方的窗口并保持关注的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆