Merge pull request #2329 from Elv13/fix_minimize_activate

Fix 3rd party toolbar unminimization and the default rc.lua focusable issue
This commit is contained in:
Emmanuel Lepage Vallée 2018-08-03 18:07:50 -04:00 committed by GitHub
commit aab582c0a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 27 deletions

View File

@ -155,16 +155,11 @@ local tasklist_buttons = gears.table.join(
if c == client.focus then if c == client.focus then
c.minimized = true c.minimized = true
else else
-- Without this, the following c:emit_signal(
-- :isvisible() makes no sense "request::activate",
c.minimized = false "tasklist",
if not c:isvisible() and c.first_tag then {raise = true}
c.first_tag:view_only() )
end
-- This will also un-minimize
-- the client, if needed
client.focus = c
c:raise()
end end
end), end),
awful.button({ }, 3, client_menu_toggle_fn()), awful.button({ }, 3, client_menu_toggle_fn()),
@ -335,8 +330,9 @@ globalkeys = gears.table.join(
local c = awful.client.restore() local c = awful.client.restore()
-- Focus restored client -- Focus restored client
if c then if c then
client.focus = c c:emit_signal(
c:raise() "request::activate", "key.unminimize", {raise = true}
)
end end
end, end,
{description = "restore minimized", group = "client"}), {description = "restore minimized", group = "client"}),
@ -459,17 +455,14 @@ end
-- @DOC_CLIENT_BUTTONS@ -- @DOC_CLIENT_BUTTONS@
clientbuttons = gears.table.join( clientbuttons = gears.table.join(
awful.button({ }, 1, function (c) awful.button({ }, 1, function (c)
client.focus = c; c:emit_signal("request::activate", "mouse_click", {raise = true})
c:raise()
end), end),
awful.button({ modkey }, 1, function (c) awful.button({ modkey }, 1, function (c)
client.focus = c c:emit_signal("request::activate", "mouse_click", {raise = true})
c:raise()
awful.mouse.client.move(c) awful.mouse.client.move(c)
end), end),
awful.button({ modkey }, 3, function (c) awful.button({ modkey }, 3, function (c)
client.focus = c c:emit_signal("request::activate", "mouse_click", {raise = true})
c:raise()
awful.mouse.client.resize(c) awful.mouse.client.resize(c)
end) end)
) )
@ -559,13 +552,11 @@ client.connect_signal("request::titlebars", function(c)
-- buttons for the titlebar -- buttons for the titlebar
local buttons = gears.table.join( local buttons = gears.table.join(
awful.button({ }, 1, function() awful.button({ }, 1, function()
client.focus = c c:emit_signal("request::activate", "titlebar", {raise = true})
c:raise()
awful.mouse.client.move(c) awful.mouse.client.move(c)
end), end),
awful.button({ }, 3, function() awful.button({ }, 3, function()
client.focus = c c:emit_signal("request::activate", "titlebar", {raise = true})
c:raise()
awful.mouse.client.resize(c) awful.mouse.client.resize(c)
end) end)
) )
@ -598,10 +589,7 @@ end)
-- Enable sloppy focus, so that focus follows mouse. -- Enable sloppy focus, so that focus follows mouse.
client.connect_signal("mouse::enter", function(c) client.connect_signal("mouse::enter", function(c)
if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier c:emit_signal("request::activate", "mouse_enter", {raise = true})
and awful.client.focus.filter(c) then
client.focus = c
end
end) end)
-- @DOC_BORDER@ -- @DOC_BORDER@

View File

@ -15,6 +15,7 @@ local aclient = require("awful.client")
local aplace = require("awful.placement") local aplace = require("awful.placement")
local asuit = require("awful.layout.suit") local asuit = require("awful.layout.suit")
local beautiful = require("beautiful") local beautiful = require("beautiful")
local alayout = require("awful.layout")
local ewmh = { local ewmh = {
generic_activate_filters = {}, generic_activate_filters = {},
@ -85,7 +86,13 @@ end
function ewmh.activate(c, context, hints) -- luacheck: no unused args function ewmh.activate(c, context, hints) -- luacheck: no unused args
hints = hints or {} hints = hints or {}
if c.focusable == false and not hints.force then return end if c.focusable == false and not hints.force then
if hints.raise then
c:raise()
end
return
end
local found, ret = false local found, ret = false
@ -102,6 +109,12 @@ function ewmh.activate(c, context, hints) -- luacheck: no unused args
if found then break end if found then break end
end end
-- Minimized clients can be requested to have focus by, for example, 3rd
-- party toolbars and they might not try to unminimize it first.
if ret ~= false and hints.raise then
c.minimized = false
end
if ret ~= false and c:isvisible() then if ret ~= false and c:isvisible() then
client.focus = c client.focus = c
elseif ret == false and not hints.force then elseif ret == false and not hints.force then
@ -393,6 +406,15 @@ function ewmh.client_geometry_requests(c, context, hints)
end end
end end
-- The magnifier layout doesn't work with focus follow mouse.
ewmh.add_activate_filter(function(c)
if alayout.get(c.screen) ~= alayout.suit.magnifier
and aclient.focus.filter(c) then
return nil
else
return false
end
end, "mouse_enter")
client.connect_signal("request::activate", ewmh.activate) client.connect_signal("request::activate", ewmh.activate)
client.connect_signal("request::tag", ewmh.tag) client.connect_signal("request::tag", ewmh.tag)