screen: Fix multiple little issues
This commit is contained in:
parent
79407729d0
commit
3536951a7a
34
screen.lua
34
screen.lua
|
@ -182,30 +182,35 @@ end
|
||||||
local function select_screen(scr_index,move,old_screen)
|
local function select_screen(scr_index,move,old_screen)
|
||||||
if capi.screen[scr_index] ~= capi.screen[old_screen or 1] then
|
if capi.screen[scr_index] ~= capi.screen[old_screen or 1] then
|
||||||
local c = last_clients[capi.screen[scr_index]]
|
local c = last_clients[capi.screen[scr_index]]
|
||||||
if pcall(c) then
|
|
||||||
|
-- If the client is leaked elsewhere, prevent an error message
|
||||||
|
if c and not pcall(function() return c.valid end) and not c.valid then
|
||||||
last_clients[capi.screen[scr_index]] = nil
|
last_clients[capi.screen[scr_index]] = nil
|
||||||
c = nil
|
c = nil
|
||||||
end
|
end
|
||||||
if c and c:isvisible() then
|
|
||||||
|
if c and c.valid and c:isvisible() then
|
||||||
local geom = c:geometry()
|
local geom = c:geometry()
|
||||||
if last_clients_coords[scr_index] and last_clients_coords[scr_index].client == c then
|
if last_clients_coords[scr_index] and last_clients_coords[scr_index].client == c then
|
||||||
capi.mouse.coords(last_clients_coords[scr_index])
|
capi.mouse.coords(last_clients_coords[scr_index])
|
||||||
else
|
else
|
||||||
capi.mouse.coords({x=geom.x+geom.width/2,y=geom.y+geom.height/2+55})
|
capi.mouse.coords({x=geom.x+geom.width/2,y=geom.y+geom.height/2+55})
|
||||||
end
|
end
|
||||||
mouse.highlight()
|
|
||||||
else
|
else
|
||||||
local geom = capi.screen[scr_index].geometry
|
local geom = capi.screen[scr_index].geometry
|
||||||
capi.mouse.coords({x=geom.x+geom.width/2,y=geom.y+geom.height/2+55})
|
capi.mouse.coords({x=geom.x+geom.width/2,y=geom.y+geom.height/2+55})
|
||||||
end
|
end
|
||||||
|
mouse.highlight()
|
||||||
end
|
end
|
||||||
|
|
||||||
if move then
|
if move then
|
||||||
local t = capi.screen[old_screen].selected_tag
|
local t = capi.screen[scr_index].selected_tag
|
||||||
t.screen = scr_index
|
if t then
|
||||||
awful.tag.viewonly(t)
|
t.screen = old_screen
|
||||||
|
awful.tag.viewonly(t)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
local c = awful.mouse.client_under_pointer()
|
local c = capi.mouse.current_client
|
||||||
if c then
|
if c then
|
||||||
capi.client.focus = c
|
capi.client.focus = c
|
||||||
end
|
end
|
||||||
|
@ -246,7 +251,6 @@ local function next_screen(ss,dir,move)
|
||||||
if type(scr_index) == "screen" then
|
if type(scr_index) == "screen" then
|
||||||
scr_index = scr_index.index
|
scr_index = scr_index.index
|
||||||
end
|
end
|
||||||
|
|
||||||
if dir == "left" then
|
if dir == "left" then
|
||||||
scr_index = scr_index == 1 and #screens or scr_index - 1
|
scr_index = scr_index == 1 and #screens or scr_index - 1
|
||||||
elseif dir == "right" then
|
elseif dir == "right" then
|
||||||
|
@ -268,6 +272,7 @@ function module.display(_,dir,move)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function highlight_screen(ss)
|
local function highlight_screen(ss)
|
||||||
|
ss = capi.screen[ss]
|
||||||
if pss ~= ss then
|
if pss ~= ss then
|
||||||
|
|
||||||
local bg = beautiful.collision_screen_bg or beautiful.bg_alternate or "#ff0000"
|
local bg = beautiful.collision_screen_bg or beautiful.bg_alternate or "#ff0000"
|
||||||
|
@ -275,8 +280,10 @@ local function highlight_screen(ss)
|
||||||
local bg_focus = beautiful.collision_screen_bg_focus or beautiful.bg_urgent or "#ff0000"
|
local bg_focus = beautiful.collision_screen_bg_focus or beautiful.bg_urgent or "#ff0000"
|
||||||
local fg_focus = beautiful.collision_screen_fg_focus or beautiful.fg_urgent or "#ff0000"
|
local fg_focus = beautiful.collision_screen_fg_focus or beautiful.fg_urgent or "#ff0000"
|
||||||
|
|
||||||
bgs[pss].bg = bg
|
if pss then
|
||||||
bgs[pss].fg = fg
|
bgs[pss].bg = bg
|
||||||
|
bgs[pss].fg = fg
|
||||||
|
end
|
||||||
|
|
||||||
pss = ss
|
pss = ss
|
||||||
|
|
||||||
|
@ -335,6 +342,13 @@ function module.select_screen(idx)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Make sure this keeps working when a new screen is added
|
||||||
|
awful.screen.connect_for_each_screen(function(s)
|
||||||
|
if next(wiboxes) then
|
||||||
|
create_wibox(s)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
capi.client.connect_signal("focus",function(c)
|
capi.client.connect_signal("focus",function(c)
|
||||||
last_clients[c.screen] = c
|
last_clients[c.screen] = c
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Reference in New Issue