From ed9f218669879a8b8578a9981384aa22e0e11cbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abd=C3=B3=20Roig-Maranges?= Date: Fri, 28 Sep 2012 23:53:58 +0200 Subject: [PATCH] Fixes module namespace issues in screen.lua and client.lua The wrong module names were introduced in commits: 0e2960ebf372507017d6dba4e573c28dbd028478 and d799ac76aa9d182abc4d80810e4c552e6e4d7e17. 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 --- lib/awful/client.lua.in | 27 +++++++++++++++++---------- lib/awful/screen.lua.in | 5 ++++- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/lib/awful/client.lua.in b/lib/awful/client.lua.in index defa4bff..bc46e341 100644 --- a/lib/awful/client.lua.in +++ b/lib/awful/client.lua.in @@ -20,10 +20,14 @@ local capi = screen = screen, } +-- we use require("awful.screen") inside functions to prevent circular dependencies. +local screen + --- Useful client manipulation functions. -- awful.client local client = {} + -- Private data client.data = {} client.data.focus = {} @@ -277,6 +281,7 @@ end -- @param dir The direction, can be either "up", "down", "left" or "right". -- @param c Optional client. function client.focus.global_bydirection(dir, c) + screen = screen or require("awful.screen") local sel = c or capi.client.focus local scr = capi.mouse.screen if sel then @@ -288,7 +293,7 @@ function client.focus.global_bydirection(dir, c) -- if focus not changed, we must change screen if sel == capi.client.focus then - awful.screen.focus_bydirection(dir, scr) + screen.focus_bydirection(dir, scr) if scr ~= capi.mouse.screen then local cltbl = client.visible(capi.mouse.screen) local geomtbl = {} @@ -338,10 +343,11 @@ end -- @param dir The direction, can be either "up", "down", "left" or "right". -- @param c Optional client. function client.swap.global_bydirection(dir, c) + screen = screen or require("awful.screen") local sel = c or capi.client.focus - local screen = capi.mouse.screen + local scr = capi.mouse.screen if sel then - screen = sel.screen + scr = sel.screen end if sel then @@ -355,15 +361,15 @@ function client.swap.global_bydirection(dir, c) -- swapping to an empty screen 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 elseif sel.screen ~= c.screen and sel ~= c then - awful.client.movetoscreen(sel, c.screen) - awful.client.movetoscreen(c, screen) + client.movetoscreen(sel, c.screen) + client.movetoscreen(c, scr) end - awful.screen.focus(sel.screen) + screen.focus(sel.screen) capi.client.focus = sel end end @@ -484,6 +490,7 @@ end -- @param c The client to move. -- @param s The screen number, default to current + 1. function client.movetoscreen(c, s) + screen = screen or require("awful.screen") local sel = c or capi.client.focus if sel then local sc = capi.screen.count() @@ -492,7 +499,7 @@ function client.movetoscreen(c, s) end if s > sc then s = 1 elseif s < 1 then s = sc end sel.screen = s - awful.screen.focus(s) + screen.focus(s) end end @@ -577,11 +584,11 @@ function client.floating.set(c, s) local c = c or capi.client.focus if c and client.property.get(c, "floating") ~= s then client.property.set(c, "floating", s) - local screen = c.screen + local scr = c.screen if s == true then c:geometry(client.property.get(c, "floating_geometry")) end - c.screen = screen + c.screen = scr end end diff --git a/lib/awful/screen.lua.in b/lib/awful/screen.lua.in index 00fd16a8..e6bc1e27 100644 --- a/lib/awful/screen.lua.in +++ b/lib/awful/screen.lua.in @@ -12,7 +12,9 @@ local capi = client = client } 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 -- 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. -- @param screen Screen number. function screen.focus(_screen) + client = client or require("awful.client") if _screen > capi.screen.count() then _screen = capi.mouse.screen end -- screen and pos for current screen