diff --git a/lib/awful/client.lua b/lib/awful/client.lua index 2fb11844..5ea63adf 100644 --- a/lib/awful/client.lua +++ b/lib/awful/client.lua @@ -667,18 +667,39 @@ function client.object.get_floating(c) if value ~= nil then return value end - if c.type ~= "normal" + return client.property.get(c, "_implicitly_floating") or false + end +end + +-- When a client is not explicitly assigned a floating state, it might +-- implicitly end up being floating. The following makes sure that +-- property::floating is still emitted if this implicit floating state changes. + +local function update_implicitly_floating(c) + local explicit = client.property.get(c, "floating") + if explicit ~= nil then + return + end + local cur = client.property.get(c, "_implicitly_floating") + local new = c.type ~= "normal" or c.fullscreen or c.maximized_vertical or c.maximized_horizontal or c.maximized - or client.object.is_fixed(c) then - return true - end - return false + or client.object.is_fixed(c) + if cur ~= new then + client.property.set(c, "_implicitly_floating", new) + c:emit_signal("property::floating") end end +capi.client.connect_signal("property::type", update_implicitly_floating) +capi.client.connect_signal("property::fullscreen", update_implicitly_floating) +capi.client.connect_signal("property::maximized_vertical", update_implicitly_floating) +capi.client.connect_signal("property::maximized_horizontal", update_implicitly_floating) +capi.client.connect_signal("property::maximized", update_implicitly_floating) +capi.client.connect_signal("property::size_hints", update_implicitly_floating) + --- Toggle the floating state of a client between 'auto' and 'true'. -- Use `c.floating = not c.floating` -- @deprecated awful.client.floating.toggle diff --git a/tests/test-awful-client.lua b/tests/test-awful-client.lua index b75dd7ff..3dc19a58 100644 --- a/tests/test-awful-client.lua +++ b/tests/test-awful-client.lua @@ -74,7 +74,41 @@ local steps = { return true end - end + end, + + -- Test implicitly floating state: Even though a client way not explicitly + -- made floating, it could still end up being floating + function() + local c = client.get()[1] + assert(c ~= nil) + + awful.client.property.set(c, "floating", nil) + assert(not c.floating) + assert(not c.maximized) + + local signal_count = 0 + c:connect_signal("property::floating", function() + signal_count = signal_count + 1 + end) + + c.maximized = true + assert(c.floating) + assert(signal_count == 1) + + c.fullscreen = true + assert(c.floating) + assert(signal_count == 1) + + c.maximized = false + assert(c.floating) + assert(signal_count == 1) + + c.fullscreen = false + assert(c.floating == false) + assert(signal_count == 2) + + return true + end, } local original_count, c1, c2 = 0