From 60c8a3593d681ebcc9c07cd160afabacfe6bcff5 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 27 May 2008 16:07:17 +0200 Subject: [PATCH] [lua] Split screen.* out of awesome.* Signed-off-by: Julien Danjou --- awesomerc.lua.in | 8 ++++---- awful.lua | 7 ++++--- lua.c | 12 +++++++++--- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/awesomerc.lua.in b/awesomerc.lua.in index 1dc3beae..2864d0c4 100644 --- a/awesomerc.lua.in +++ b/awesomerc.lua.in @@ -24,7 +24,7 @@ layouts = { "tile", "tileleft", "tilebottom", "tiletop", "max", "spiral", "dwind -- {{{ Tags -- Define tags table tags = {} -for s = 1, awesome.screen_count() do +for s = 1, screen.count() do -- Each screen has its own tag table tags[s] = {} -- Create 9 tags per screen @@ -71,13 +71,13 @@ myiconbox:set("image", "@iconsdir@/awesome16.png") -- Create an iconbox widget which will contains an icon indicating which layout we're using. -- We need one layoutbox per screen. mylayoutbox = {} -for s = 1, awesome.screen_count() do +for s = 1, screen.count() do mylayoutbox[s] = widget.new({ type = "iconbox", name = "myiconbox", align = "right" }) mylayoutbox[s]:set("image", "@iconsdir@/layouts/tilew.png") end -- Create a statusbar for each screen and add it -for s = 1, awesome.screen_count() do +for s = 1, screen.count() do mystatusbar = statusbar.new({ position = "top", name = "mystatusbar" .. s, fg = "lightblue", bg = "black" }) -- Add widgets to the statusbar - order matters @@ -118,7 +118,7 @@ client.mouse({ modkey }, 3, function (c) c:mouse_resize() end) -- Bind keyboard digits -- Compute the maximum number of digit we need, limited to 9 keynumber = 0 -for s = 1, awesome.screen_count() do +for s = 1, screen.count() do keynumber = math.min(9, math.max(#tags[s], keynumber)); end diff --git a/awful.lua b/awful.lua index 5d66c3a3..ced149dc 100644 --- a/awful.lua +++ b/awful.lua @@ -17,6 +17,7 @@ end -- Grab environment we need local ipairs = ipairs local awesome = awesome +local screen = screen local client = client local tag = tag local mouse = mouse @@ -77,16 +78,16 @@ function screen_focus(i) else s = mouse.screen_get() end - local count = awesome.screen_count() + local count = screen.count() s = s + i if s < 1 then s = count elseif s > count then s = 1 end - awesome.screen_focus(s) + screen.focus(s) -- Move the mouse on the screen - local screen_coords = awesome.screen_coords_get(s) + local screen_coords = screen.coords_get(s) mouse.coords_set(screen_coords['x'], screen_coords['y']) end diff --git a/lua.c b/lua.c index 681a70a5..3e8894a9 100644 --- a/lua.c +++ b/lua.c @@ -430,9 +430,6 @@ luaA_parserc(const char *rcfile) { "restart", luaA_restart }, { "floating_placement_set", luaA_floating_placement_set }, { "padding_set", luaA_padding_set }, - { "screen_coords_get", luaA_screen_coords_get }, - { "screen_count", luaA_screen_count }, - { "screen_focus", luaA_screen_focus }, { "key", luaA_key }, { "mouse", luaA_mouse }, { "resizehints_set", luaA_resizehints_set }, @@ -440,6 +437,12 @@ luaA_parserc(const char *rcfile) { "colors_set", luaA_colors_set }, { NULL, NULL } }; + static const struct luaL_reg awesome_screen_lib[] = + { + { "coords_get", luaA_screen_coords_get }, + { "count", luaA_screen_count }, + { "focus", luaA_screen_focus }, + }; static const struct luaL_reg awesome_hooks_lib[] = { { "focus", luaA_hooks_focus }, @@ -459,6 +462,9 @@ luaA_parserc(const char *rcfile) /* Export awesome lib */ luaL_register(L, "awesome", awesome_lib); + /* Export screen lib */ + luaL_register(L, "screen", awesome_screen_lib); + /* Export hooks lib */ luaL_register(L, "hooks", awesome_hooks_lib);