Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of fullscreen clients #27

Merged
merged 2 commits into from
Dec 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 46 additions & 12 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -411,16 +411,9 @@ local raise_client = function(c)
end


-- Keep track of the client where "ontop" needs to be restored, and forget
-- about it in "unmanage", to avoid an "invalid object" error.
-- Ref: https://github.com/awesomeWM/awesome/issues/110
local restore_ontop_c
local restore_callback_show_client
local show_client_restore_client_props = {}
client.connect_signal("unmanage", function (c)
if restore_ontop_c and c == restore_ontop_c[1] then
restore_ontop_c = nil
end
if c == restore_callback_show_client then
restore_callback_show_client = nil
end
Expand Down Expand Up @@ -566,6 +559,12 @@ cyclefocus.callback_show_client = function (c, restore)
callback_show_client_lock = false
end

-- Handle temporarily setting "ontop" for shown clients.
-- This is a function that keeps track and handles the related "below",
-- "above", and "fullscreen" properties.
-- Ref: https://github.com/awesomeWM/awesome/issues/667
local restore_ontop_c

-- Helper function to restore state of the temporarily selected client.
cyclefocus.show_client = function (c)
showing_client = c
Expand All @@ -576,12 +575,46 @@ cyclefocus.show_client = function (c)
end
restore_callback_show_client = c

-- (Re)store ontop property.
-- Restore ontop (and related) properties.
if restore_ontop_c then
restore_ontop_c[1].ontop = restore_ontop_c[2]
restore_ontop_c()
restore_ontop_c = nil
end
-- Handle setting ontop for the current client.
-- This involves managing other properties, since setting "ontop"
-- resets "fullscreen", "below", and "above".
if not c.ontop then
if c.fullscreen then
-- Keep fullscreen clients as is.
-- This requires to temporarily unset ontop for others.
-- NOTE: the client might not be visible with other ontop clients
-- after selecting it. This could be handled by setting
-- ontop in the end (unsetting its fullscreen then though).
local ontop_restore_clients = {}
for _,_c in pairs(awful.client.visible(client.screen)) do
if _c.ontop then
table.insert(ontop_restore_clients, _c)
_c.ontop = false
end
end
if #ontop_restore_clients then
function restore_ontop_c()
for _,_c in pairs(ontop_restore_clients) do
_c.ontop = true
end
end
end
else
local ontop_orig_props = {c.ontop, c.below, c.above, c.fullscreen}
function restore_ontop_c()
c.ontop = ontop_orig_props[1]
c.below = ontop_orig_props[2]
c.above = ontop_orig_props[3]
c.fullscreen = ontop_orig_props[4]
end
c.ontop = true
end
end
restore_ontop_c = {c, c.ontop}
c.ontop = true

-- Make the clients tag visible, if it currently is not.
local sel_tags = c.screen.selected_tags
Expand Down Expand Up @@ -610,7 +643,8 @@ cyclefocus.show_client = function (c)

else -- No client provided, restore only.
if restore_ontop_c then
restore_ontop_c[1].ontop = restore_ontop_c[2]
restore_ontop_c()
restore_ontop_c = nil
end
cyclefocus.callback_show_client(restore_callback_show_client, true)
showing_client = nil
Expand Down