Fixes module namespace issues in screen.lua and client.lua

The wrong module names were introduced in commits:
0e2960ebf3 and
d799ac76aa.

Once fixed, client.lua and screen.lua mutually require each other, so we must
use a trick, and load the modules inside the functions that need them.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Abdó Roig-Maranges 2012-09-28 23:53:58 +02:00 committed by Uli Schlachter
parent 34c1c7d416
commit ed9f218669
2 changed files with 21 additions and 11 deletions

View File

@ -20,10 +20,14 @@ local capi =
screen = screen, screen = screen,
} }
-- we use require("awful.screen") inside functions to prevent circular dependencies.
local screen
--- Useful client manipulation functions. --- Useful client manipulation functions.
-- awful.client -- awful.client
local client = {} local client = {}
-- Private data -- Private data
client.data = {} client.data = {}
client.data.focus = {} client.data.focus = {}
@ -277,6 +281,7 @@ end
-- @param dir The direction, can be either "up", "down", "left" or "right". -- @param dir The direction, can be either "up", "down", "left" or "right".
-- @param c Optional client. -- @param c Optional client.
function client.focus.global_bydirection(dir, c) function client.focus.global_bydirection(dir, c)
screen = screen or require("awful.screen")
local sel = c or capi.client.focus local sel = c or capi.client.focus
local scr = capi.mouse.screen local scr = capi.mouse.screen
if sel then if sel then
@ -288,7 +293,7 @@ function client.focus.global_bydirection(dir, c)
-- if focus not changed, we must change screen -- if focus not changed, we must change screen
if sel == capi.client.focus then if sel == capi.client.focus then
awful.screen.focus_bydirection(dir, scr) screen.focus_bydirection(dir, scr)
if scr ~= capi.mouse.screen then if scr ~= capi.mouse.screen then
local cltbl = client.visible(capi.mouse.screen) local cltbl = client.visible(capi.mouse.screen)
local geomtbl = {} local geomtbl = {}
@ -338,10 +343,11 @@ end
-- @param dir The direction, can be either "up", "down", "left" or "right". -- @param dir The direction, can be either "up", "down", "left" or "right".
-- @param c Optional client. -- @param c Optional client.
function client.swap.global_bydirection(dir, c) function client.swap.global_bydirection(dir, c)
screen = screen or require("awful.screen")
local sel = c or capi.client.focus local sel = c or capi.client.focus
local screen = capi.mouse.screen local scr = capi.mouse.screen
if sel then if sel then
screen = sel.screen scr = sel.screen
end end
if sel then if sel then
@ -355,15 +361,15 @@ function client.swap.global_bydirection(dir, c)
-- swapping to an empty screen -- swapping to an empty screen
elseif sel.screen ~= c.screen and sel == c then elseif sel.screen ~= c.screen and sel == c then
awful.client.movetoscreen(sel, capi.mouse.screen) client.movetoscreen(sel, capi.mouse.screen)
--swapping to a nonempty screen --swapping to a nonempty screen
elseif sel.screen ~= c.screen and sel ~= c then elseif sel.screen ~= c.screen and sel ~= c then
awful.client.movetoscreen(sel, c.screen) client.movetoscreen(sel, c.screen)
awful.client.movetoscreen(c, screen) client.movetoscreen(c, scr)
end end
awful.screen.focus(sel.screen) screen.focus(sel.screen)
capi.client.focus = sel capi.client.focus = sel
end end
end end
@ -484,6 +490,7 @@ end
-- @param c The client to move. -- @param c The client to move.
-- @param s The screen number, default to current + 1. -- @param s The screen number, default to current + 1.
function client.movetoscreen(c, s) function client.movetoscreen(c, s)
screen = screen or require("awful.screen")
local sel = c or capi.client.focus local sel = c or capi.client.focus
if sel then if sel then
local sc = capi.screen.count() local sc = capi.screen.count()
@ -492,7 +499,7 @@ function client.movetoscreen(c, s)
end end
if s > sc then s = 1 elseif s < 1 then s = sc end if s > sc then s = 1 elseif s < 1 then s = sc end
sel.screen = s sel.screen = s
awful.screen.focus(s) screen.focus(s)
end end
end end
@ -577,11 +584,11 @@ function client.floating.set(c, s)
local c = c or capi.client.focus local c = c or capi.client.focus
if c and client.property.get(c, "floating") ~= s then if c and client.property.get(c, "floating") ~= s then
client.property.set(c, "floating", s) client.property.set(c, "floating", s)
local screen = c.screen local scr = c.screen
if s == true then if s == true then
c:geometry(client.property.get(c, "floating_geometry")) c:geometry(client.property.get(c, "floating_geometry"))
end end
c.screen = screen c.screen = scr
end end
end end

View File

@ -12,7 +12,9 @@ local capi =
client = client client = client
} }
local util = require("awful.util") local util = require("awful.util")
local client = require("awful.client")
-- we use require("awful.client") inside functions to prevent circular dependencies.
local client
--- Screen module for awful --- Screen module for awful
-- awful.screen -- awful.screen
@ -40,6 +42,7 @@ end
--- Give the focus to a screen, and move pointer. Keeps relative position of the pointer on the screen. --- Give the focus to a screen, and move pointer. Keeps relative position of the pointer on the screen.
-- @param screen Screen number. -- @param screen Screen number.
function screen.focus(_screen) function screen.focus(_screen)
client = client or require("awful.client")
if _screen > capi.screen.count() then _screen = capi.mouse.screen end if _screen > capi.screen.count() then _screen = capi.mouse.screen end
-- screen and pos for current screen -- screen and pos for current screen