[lua] Split screen.* out of awesome.*
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
c3d16391f5
commit
60c8a3593d
|
@ -24,7 +24,7 @@ layouts = { "tile", "tileleft", "tilebottom", "tiletop", "max", "spiral", "dwind
|
||||||
-- {{{ Tags
|
-- {{{ Tags
|
||||||
-- Define tags table
|
-- Define tags table
|
||||||
tags = {}
|
tags = {}
|
||||||
for s = 1, awesome.screen_count() do
|
for s = 1, screen.count() do
|
||||||
-- Each screen has its own tag table
|
-- Each screen has its own tag table
|
||||||
tags[s] = {}
|
tags[s] = {}
|
||||||
-- Create 9 tags per screen
|
-- 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.
|
-- Create an iconbox widget which will contains an icon indicating which layout we're using.
|
||||||
-- We need one layoutbox per screen.
|
-- We need one layoutbox per screen.
|
||||||
mylayoutbox = {}
|
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] = widget.new({ type = "iconbox", name = "myiconbox", align = "right" })
|
||||||
mylayoutbox[s]:set("image", "@iconsdir@/layouts/tilew.png")
|
mylayoutbox[s]:set("image", "@iconsdir@/layouts/tilew.png")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Create a statusbar for each screen and add it
|
-- 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,
|
mystatusbar = statusbar.new({ position = "top", name = "mystatusbar" .. s,
|
||||||
fg = "lightblue", bg = "black" })
|
fg = "lightblue", bg = "black" })
|
||||||
-- Add widgets to the statusbar - order matters
|
-- Add widgets to the statusbar - order matters
|
||||||
|
@ -118,7 +118,7 @@ client.mouse({ modkey }, 3, function (c) c:mouse_resize() end)
|
||||||
-- Bind keyboard digits
|
-- Bind keyboard digits
|
||||||
-- Compute the maximum number of digit we need, limited to 9
|
-- Compute the maximum number of digit we need, limited to 9
|
||||||
keynumber = 0
|
keynumber = 0
|
||||||
for s = 1, awesome.screen_count() do
|
for s = 1, screen.count() do
|
||||||
keynumber = math.min(9, math.max(#tags[s], keynumber));
|
keynumber = math.min(9, math.max(#tags[s], keynumber));
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ end
|
||||||
-- Grab environment we need
|
-- Grab environment we need
|
||||||
local ipairs = ipairs
|
local ipairs = ipairs
|
||||||
local awesome = awesome
|
local awesome = awesome
|
||||||
|
local screen = screen
|
||||||
local client = client
|
local client = client
|
||||||
local tag = tag
|
local tag = tag
|
||||||
local mouse = mouse
|
local mouse = mouse
|
||||||
|
@ -77,16 +78,16 @@ function screen_focus(i)
|
||||||
else
|
else
|
||||||
s = mouse.screen_get()
|
s = mouse.screen_get()
|
||||||
end
|
end
|
||||||
local count = awesome.screen_count()
|
local count = screen.count()
|
||||||
s = s + i
|
s = s + i
|
||||||
if s < 1 then
|
if s < 1 then
|
||||||
s = count
|
s = count
|
||||||
elseif s > count then
|
elseif s > count then
|
||||||
s = 1
|
s = 1
|
||||||
end
|
end
|
||||||
awesome.screen_focus(s)
|
screen.focus(s)
|
||||||
-- Move the mouse on the screen
|
-- 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'])
|
mouse.coords_set(screen_coords['x'], screen_coords['y'])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
12
lua.c
12
lua.c
|
@ -430,9 +430,6 @@ luaA_parserc(const char *rcfile)
|
||||||
{ "restart", luaA_restart },
|
{ "restart", luaA_restart },
|
||||||
{ "floating_placement_set", luaA_floating_placement_set },
|
{ "floating_placement_set", luaA_floating_placement_set },
|
||||||
{ "padding_set", luaA_padding_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 },
|
{ "key", luaA_key },
|
||||||
{ "mouse", luaA_mouse },
|
{ "mouse", luaA_mouse },
|
||||||
{ "resizehints_set", luaA_resizehints_set },
|
{ "resizehints_set", luaA_resizehints_set },
|
||||||
|
@ -440,6 +437,12 @@ luaA_parserc(const char *rcfile)
|
||||||
{ "colors_set", luaA_colors_set },
|
{ "colors_set", luaA_colors_set },
|
||||||
{ NULL, NULL }
|
{ 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[] =
|
static const struct luaL_reg awesome_hooks_lib[] =
|
||||||
{
|
{
|
||||||
{ "focus", luaA_hooks_focus },
|
{ "focus", luaA_hooks_focus },
|
||||||
|
@ -459,6 +462,9 @@ luaA_parserc(const char *rcfile)
|
||||||
/* Export awesome lib */
|
/* Export awesome lib */
|
||||||
luaL_register(L, "awesome", awesome_lib);
|
luaL_register(L, "awesome", awesome_lib);
|
||||||
|
|
||||||
|
/* Export screen lib */
|
||||||
|
luaL_register(L, "screen", awesome_screen_lib);
|
||||||
|
|
||||||
/* Export hooks lib */
|
/* Export hooks lib */
|
||||||
luaL_register(L, "hooks", awesome_hooks_lib);
|
luaL_register(L, "hooks", awesome_hooks_lib);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue