screen: introduce screen objects
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
0903e21a1a
commit
be2bfdcfc5
|
@ -399,6 +399,12 @@ main(int argc, char **argv)
|
||||||
/* init screens struct */
|
/* init screens struct */
|
||||||
globalconf.screens_info = screensinfo_new(globalconf.connection);
|
globalconf.screens_info = screensinfo_new(globalconf.connection);
|
||||||
globalconf.screen_focus = globalconf.screens = p_new(screen_t, globalconf.screens_info->nscreen);
|
globalconf.screen_focus = globalconf.screens = p_new(screen_t, globalconf.screens_info->nscreen);
|
||||||
|
/* \todo stop duplicating this */
|
||||||
|
for(screen_nbr = 0; screen_nbr < globalconf.screens_info->nscreen; screen_nbr++)
|
||||||
|
{
|
||||||
|
globalconf.screens[screen_nbr].index = screen_nbr;
|
||||||
|
globalconf.screens[screen_nbr].geometry = globalconf.screens_info->geometry[screen_nbr];
|
||||||
|
}
|
||||||
|
|
||||||
/* init default font and colors */
|
/* init default font and colors */
|
||||||
globalconf.font = draw_font_new(globalconf.connection, globalconf.default_screen, "sans 8");
|
globalconf.font = draw_font_new(globalconf.connection, globalconf.default_screen, "sans 8");
|
||||||
|
|
|
@ -47,7 +47,7 @@ floatapps =
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Applications to be moved to a pre-defined tag by class or instance.
|
-- Applications to be moved to a pre-defined tag by class or instance.
|
||||||
-- Use the screen and workspace indices.
|
-- Use the screen and tags indices.
|
||||||
apptags =
|
apptags =
|
||||||
{
|
{
|
||||||
-- ["Firefox"] = { screen = 1, tag = 2 },
|
-- ["Firefox"] = { screen = 1, tag = 2 },
|
||||||
|
|
|
@ -42,6 +42,7 @@ nmaster
|
||||||
name
|
name
|
||||||
on
|
on
|
||||||
opacity
|
opacity
|
||||||
|
padding
|
||||||
pid
|
pid
|
||||||
plot_data_add
|
plot_data_add
|
||||||
plot_properties_set
|
plot_properties_set
|
||||||
|
@ -71,4 +72,5 @@ visible
|
||||||
vertical
|
vertical
|
||||||
widgets
|
widgets
|
||||||
width
|
width
|
||||||
|
workarea
|
||||||
yes
|
yes
|
||||||
|
|
6
ewmh.c
6
ewmh.c
|
@ -213,7 +213,7 @@ ewmh_update_workarea(int phys_screen)
|
||||||
{
|
{
|
||||||
tag_array_t *tags = &globalconf.screens[phys_screen].tags;
|
tag_array_t *tags = &globalconf.screens[phys_screen].tags;
|
||||||
uint32_t *area = p_alloca(uint32_t, tags->len * 4);
|
uint32_t *area = p_alloca(uint32_t, tags->len * 4);
|
||||||
area_t geom = screen_area_get(phys_screen,
|
area_t geom = screen_area_get(&globalconf.screens[phys_screen].geometry,
|
||||||
globalconf.screens[phys_screen].statusbar,
|
globalconf.screens[phys_screen].statusbar,
|
||||||
&globalconf.screens[phys_screen].padding);
|
&globalconf.screens[phys_screen].padding);
|
||||||
|
|
||||||
|
@ -287,7 +287,9 @@ ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set)
|
||||||
}
|
}
|
||||||
else if(set == _NET_WM_STATE_ADD)
|
else if(set == _NET_WM_STATE_ADD)
|
||||||
{
|
{
|
||||||
geometry = screen_area_get(c->screen, NULL, &globalconf.screens[c->screen].padding);
|
geometry = screen_area_get(&globalconf.screens[c->screen].geometry,
|
||||||
|
NULL,
|
||||||
|
&globalconf.screens[c->screen].padding);
|
||||||
/* save geometry */
|
/* save geometry */
|
||||||
c->m_geometry = c->geometry;
|
c->m_geometry = c->geometry;
|
||||||
c->wasfloating = c->isfloating;
|
c->wasfloating = c->isfloating;
|
||||||
|
|
|
@ -32,7 +32,7 @@ layout_fibonacci(int screen, int shape)
|
||||||
int n = 0, i = 0;
|
int n = 0, i = 0;
|
||||||
client_t *c;
|
client_t *c;
|
||||||
area_t geometry, area;
|
area_t geometry, area;
|
||||||
geometry = area = screen_area_get(screen,
|
geometry = area = screen_area_get(&globalconf.screens[screen].geometry,
|
||||||
globalconf.screens[screen].statusbar,
|
globalconf.screens[screen].statusbar,
|
||||||
&globalconf.screens[screen].padding);
|
&globalconf.screens[screen].padding);
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ layout_magnifier(int screen)
|
||||||
int n = 0;
|
int n = 0;
|
||||||
client_t *c, *focus;
|
client_t *c, *focus;
|
||||||
tag_t **curtags = tags_get_current(screen);
|
tag_t **curtags = tags_get_current(screen);
|
||||||
area_t geometry, area = screen_area_get(screen,
|
area_t geometry, area = screen_area_get(&globalconf.screens[screen].geometry,
|
||||||
globalconf.screens[screen].statusbar,
|
globalconf.screens[screen].statusbar,
|
||||||
&globalconf.screens[screen].padding);
|
&globalconf.screens[screen].padding);
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,9 @@ void
|
||||||
layout_max(int screen)
|
layout_max(int screen)
|
||||||
{
|
{
|
||||||
client_t *c;
|
client_t *c;
|
||||||
area_t area = screen_area_get(screen,
|
area_t area = screen_area_get(&globalconf.screens[screen].geometry,
|
||||||
globalconf.screens[screen].statusbar,
|
globalconf.screens[screen].statusbar,
|
||||||
&globalconf.screens[screen].padding);
|
&globalconf.screens[screen].padding);
|
||||||
|
|
||||||
for(c = globalconf.clients; c; c = c->next)
|
for(c = globalconf.clients; c; c = c->next)
|
||||||
if(IS_TILED(c, screen))
|
if(IS_TILED(c, screen))
|
||||||
|
|
|
@ -42,7 +42,7 @@ _tile(int screen, const position_t position)
|
||||||
client_t *c;
|
client_t *c;
|
||||||
tag_t **curtags = tags_get_current(screen);
|
tag_t **curtags = tags_get_current(screen);
|
||||||
|
|
||||||
area = screen_area_get(screen,
|
area = screen_area_get(&globalconf.screens[screen].geometry,
|
||||||
globalconf.screens[screen].statusbar,
|
globalconf.screens[screen].statusbar,
|
||||||
&globalconf.screens[screen].padding);
|
&globalconf.screens[screen].padding);
|
||||||
|
|
||||||
|
|
|
@ -278,13 +278,13 @@ function client.moveresize(x, y, w, h, c)
|
||||||
sel.coords = coords
|
sel.coords = coords
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Maximize a client to use the full workspace area.
|
--- Maximize a client to use the full workarea.
|
||||||
-- @param c A client, or the focused one if nil.
|
-- @param c A client, or the focused one if nil.
|
||||||
function client.maximize(c)
|
function client.maximize(c)
|
||||||
local sel = c or capi.client.focus_get()
|
local sel = c or capi.client.focus_get()
|
||||||
if sel then
|
if sel then
|
||||||
sel.floating = true
|
sel.floating = true
|
||||||
local ws = capi.screen.workspace_get(sel.screen)
|
local ws = capi.screen[sel.screen].workarea
|
||||||
ws.width = ws.width - 2 * sel.border_width
|
ws.width = ws.width - 2 * sel.border_width
|
||||||
ws.height = ws.height - 2 * sel.border_width
|
ws.height = ws.height - 2 * sel.border_width
|
||||||
sel.coords = ws
|
sel.coords = ws
|
||||||
|
@ -305,7 +305,7 @@ function screen.focus(i)
|
||||||
local c = client.focus.history.get(s, 0)
|
local c = client.focus.history.get(s, 0)
|
||||||
if c then c:focus_set() end
|
if c then c:focus_set() end
|
||||||
-- Move the mouse on the screen
|
-- Move the mouse on the screen
|
||||||
capi.mouse.coords = capi.screen.coords_get(s)
|
capi.mouse.coords = capi.screen[s].coords
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Compare 2 tables of tags.
|
--- Compare 2 tables of tags.
|
||||||
|
@ -532,7 +532,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
|
||||||
capi.mouse.coords = capi.screen.coords_get(s)
|
capi.mouse.coords = capi.screen[s].coords
|
||||||
sel:focus_set()
|
sel:focus_set()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
111
lua.c
111
lua.c
|
@ -51,6 +51,8 @@ extern awesome_t globalconf;
|
||||||
extern const struct luaL_reg awesome_keygrabber_lib[];
|
extern const struct luaL_reg awesome_keygrabber_lib[];
|
||||||
extern const struct luaL_reg awesome_mouse_methods[];
|
extern const struct luaL_reg awesome_mouse_methods[];
|
||||||
extern const struct luaL_reg awesome_mouse_meta[];
|
extern const struct luaL_reg awesome_mouse_meta[];
|
||||||
|
extern const struct luaL_reg awesome_screen_methods[];
|
||||||
|
extern const struct luaL_reg awesome_screen_meta[];
|
||||||
extern const struct luaL_reg awesome_client_methods[];
|
extern const struct luaL_reg awesome_client_methods[];
|
||||||
extern const struct luaL_reg awesome_client_meta[];
|
extern const struct luaL_reg awesome_client_meta[];
|
||||||
extern const struct luaL_reg awesome_titlebar_methods[];
|
extern const struct luaL_reg awesome_titlebar_methods[];
|
||||||
|
@ -126,101 +128,6 @@ luaA_restart(lua_State *L __attribute__ ((unused)))
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set the screen padding. This can be used to define margin around the
|
|
||||||
* screen. awesome will not use this area.
|
|
||||||
* \param L The Lua VM state.
|
|
||||||
* \return The number of elements pushed on stack.
|
|
||||||
*
|
|
||||||
* \luastack
|
|
||||||
* \lparam A screen number.
|
|
||||||
* \lparam A table with a list of margin for `right', `left', `top' and
|
|
||||||
* `bottom'.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
luaA_screen_padding_set(lua_State *L)
|
|
||||||
{
|
|
||||||
int screen = luaL_checknumber(L, 1) - 1;
|
|
||||||
|
|
||||||
luaA_checkscreen(screen);
|
|
||||||
|
|
||||||
luaA_checktable(L, 2);
|
|
||||||
|
|
||||||
globalconf.screens[screen].padding.right = luaA_getopt_number(L, 2, "right", 0);
|
|
||||||
globalconf.screens[screen].padding.left = luaA_getopt_number(L, 2, "left", 0);
|
|
||||||
globalconf.screens[screen].padding.top = luaA_getopt_number(L, 2, "top", 0);
|
|
||||||
globalconf.screens[screen].padding.bottom = luaA_getopt_number(L, 2, "bottom", 0);
|
|
||||||
|
|
||||||
ewmh_update_workarea(screen_virttophys(screen));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get the screen count.
|
|
||||||
* \param L The Lua VM state.
|
|
||||||
* \return The number of elements pushed on stack.
|
|
||||||
*
|
|
||||||
* \luastack
|
|
||||||
* \lreturn The screen count, at least 1.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
luaA_screen_count(lua_State *L)
|
|
||||||
{
|
|
||||||
lua_pushnumber(L, globalconf.screens_info->nscreen);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Return screen coordinates.
|
|
||||||
* \param L The Lua VM state.
|
|
||||||
* \return The number of elements pushed on stack.
|
|
||||||
* \luastack
|
|
||||||
* \lparam A screen number.
|
|
||||||
* \lreturn A table with the screen geometry: x, y, width and height.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
luaA_screen_coords_get(lua_State *L)
|
|
||||||
{
|
|
||||||
int screen = luaL_checknumber(L, 1) - 1;
|
|
||||||
luaA_checkscreen(screen);
|
|
||||||
lua_newtable(L);
|
|
||||||
lua_pushnumber(L, globalconf.screens_info->geometry[screen].x);
|
|
||||||
lua_setfield(L, -2, "x");
|
|
||||||
lua_pushnumber(L, globalconf.screens_info->geometry[screen].y);
|
|
||||||
lua_setfield(L, -2, "y");
|
|
||||||
lua_pushnumber(L, globalconf.screens_info->geometry[screen].width);
|
|
||||||
lua_setfield(L, -2, "width");
|
|
||||||
lua_pushnumber(L, globalconf.screens_info->geometry[screen].height);
|
|
||||||
lua_setfield(L, -2, "height");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Return the geometry of the workspace, i.e. where applications live.
|
|
||||||
* \param L The Lua VM state.
|
|
||||||
* \return The number of elements pushed on stack.
|
|
||||||
* \luastack
|
|
||||||
* \lparam A screen number.
|
|
||||||
* \lreturn A table with the workspace geometry.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
luaA_screen_workspace_get(lua_State *L)
|
|
||||||
{
|
|
||||||
area_t g;
|
|
||||||
int screen = luaL_checknumber(L, 1) - 1;
|
|
||||||
luaA_checkscreen(screen);
|
|
||||||
g = screen_area_get(screen,
|
|
||||||
globalconf.screens[screen].statusbar,
|
|
||||||
&globalconf.screens[screen].padding);
|
|
||||||
lua_newtable(L);
|
|
||||||
lua_pushnumber(L, g.x);
|
|
||||||
lua_setfield(L, -2, "x");
|
|
||||||
lua_pushnumber(L, g.y);
|
|
||||||
lua_setfield(L, -2, "y");
|
|
||||||
lua_pushnumber(L, g.width);
|
|
||||||
lua_setfield(L, -2, "width");
|
|
||||||
lua_pushnumber(L, g.height);
|
|
||||||
lua_setfield(L, -2, "height");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Set the function called each time a client gets focus. This function is
|
/** Set the function called each time a client gets focus. This function is
|
||||||
* called with the client object as argument.
|
* called with the client object as argument.
|
||||||
* \param L The Lua VM state.
|
* \param L The Lua VM state.
|
||||||
|
@ -531,14 +438,6 @@ luaA_init(void)
|
||||||
{ "colors_set", luaA_colors_set },
|
{ "colors_set", luaA_colors_set },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
static const struct luaL_reg awesome_screen_lib[] =
|
|
||||||
{
|
|
||||||
{ "padding_set", luaA_screen_padding_set },
|
|
||||||
{ "coords_get", luaA_screen_coords_get },
|
|
||||||
{ "workspace_get", luaA_screen_workspace_get },
|
|
||||||
{ "count", luaA_screen_count },
|
|
||||||
{ NULL, NULL }
|
|
||||||
};
|
|
||||||
static const struct luaL_reg awesome_hooks_lib[] =
|
static const struct luaL_reg awesome_hooks_lib[] =
|
||||||
{
|
{
|
||||||
{ "focus", luaA_hooks_focus },
|
{ "focus", luaA_hooks_focus },
|
||||||
|
@ -562,9 +461,6 @@ luaA_init(void)
|
||||||
/* 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);
|
||||||
|
|
||||||
|
@ -574,6 +470,9 @@ luaA_init(void)
|
||||||
/* Export otable lib */
|
/* Export otable lib */
|
||||||
luaA_openlib(L, "otable", otable_methods, otable_meta);
|
luaA_openlib(L, "otable", otable_methods, otable_meta);
|
||||||
|
|
||||||
|
/* Export screen */
|
||||||
|
luaA_openlib(L, "screen", awesome_screen_methods, awesome_screen_meta);
|
||||||
|
|
||||||
/* Export mouse */
|
/* Export mouse */
|
||||||
luaA_openlib(L, "mouse", awesome_mouse_methods, awesome_mouse_meta);
|
luaA_openlib(L, "mouse", awesome_mouse_methods, awesome_mouse_meta);
|
||||||
|
|
||||||
|
|
6
mouse.c
6
mouse.c
|
@ -130,7 +130,7 @@ mouse_snapclient(client_t *c, area_t geometry, int snap)
|
||||||
client_t *snapper;
|
client_t *snapper;
|
||||||
area_t snapper_geometry;
|
area_t snapper_geometry;
|
||||||
area_t screen_geometry =
|
area_t screen_geometry =
|
||||||
screen_area_get(c->screen,
|
screen_area_get(&globalconf.screens[c->screen].geometry,
|
||||||
globalconf.screens[c->screen].statusbar,
|
globalconf.screens[c->screen].statusbar,
|
||||||
&globalconf.screens[c->screen].padding);
|
&globalconf.screens[c->screen].padding);
|
||||||
|
|
||||||
|
@ -720,7 +720,7 @@ mouse_client_resize_tiled(client_t *c)
|
||||||
tag = tags_get_current(c->screen)[0];
|
tag = tags_get_current(c->screen)[0];
|
||||||
layout = tag->layout;
|
layout = tag->layout;
|
||||||
|
|
||||||
area = screen_area_get(tag->screen,
|
area = screen_area_get(&globalconf.screens[tag->screen].geometry,
|
||||||
globalconf.screens[tag->screen].statusbar,
|
globalconf.screens[tag->screen].statusbar,
|
||||||
&globalconf.screens[tag->screen].padding);
|
&globalconf.screens[tag->screen].padding);
|
||||||
|
|
||||||
|
@ -823,7 +823,7 @@ mouse_client_resize_magnified(client_t *c, bool infobox)
|
||||||
|
|
||||||
root = xutil_screen_get(globalconf.connection, c->phys_screen)->root;
|
root = xutil_screen_get(globalconf.connection, c->phys_screen)->root;
|
||||||
|
|
||||||
area = screen_area_get(tag->screen,
|
area = screen_area_get(&globalconf.screens[tag->screen].geometry,
|
||||||
globalconf.screens[tag->screen].statusbar,
|
globalconf.screens[tag->screen].statusbar,
|
||||||
&globalconf.screens[tag->screen].padding);
|
&globalconf.screens[tag->screen].padding);
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ placement_fix_offscreen(area_t geometry, int screen, int border)
|
||||||
{
|
{
|
||||||
area_t screen_geometry;
|
area_t screen_geometry;
|
||||||
|
|
||||||
screen_geometry = screen_area_get(screen,
|
screen_geometry = screen_area_get(&globalconf.screens[screen].geometry,
|
||||||
globalconf.screens[screen].statusbar,
|
globalconf.screens[screen].statusbar,
|
||||||
&globalconf.screens[screen].padding);
|
&globalconf.screens[screen].padding);
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ placement_smart(client_t *c)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
area_array_init(&areas);
|
area_array_init(&areas);
|
||||||
screen_geometry = screen_area_get(c->screen,
|
screen_geometry = screen_area_get(&globalconf.screens[c->screen].geometry,
|
||||||
globalconf.screens[c->screen].statusbar,
|
globalconf.screens[c->screen].statusbar,
|
||||||
&globalconf.screens[c->screen].padding);
|
&globalconf.screens[c->screen].padding);
|
||||||
|
|
||||||
|
|
147
screen.c
147
screen.c
|
@ -25,9 +25,9 @@
|
||||||
#include <xcb/xcb_aux.h>
|
#include <xcb/xcb_aux.h>
|
||||||
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
#include "ewmh.h"
|
||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "layouts/floating.h"
|
|
||||||
|
|
||||||
extern awesome_t globalconf;
|
extern awesome_t globalconf;
|
||||||
|
|
||||||
|
@ -38,9 +38,9 @@ extern awesome_t globalconf;
|
||||||
* \return The screen area.
|
* \return The screen area.
|
||||||
*/
|
*/
|
||||||
area_t
|
area_t
|
||||||
screen_area_get(int screen, statusbar_t *statusbar, padding_t *padding)
|
screen_area_get(area_t *geometry, statusbar_t *statusbar, padding_t *padding)
|
||||||
{
|
{
|
||||||
area_t area = globalconf.screens_info->geometry[screen];
|
area_t area = *geometry;
|
||||||
statusbar_t *sb;
|
statusbar_t *sb;
|
||||||
|
|
||||||
/* make padding corrections */
|
/* make padding corrections */
|
||||||
|
@ -149,8 +149,10 @@ screen_client_moveto(client_t *c, int new_screen, bool doresize)
|
||||||
area_t new_geometry, new_f_geometry;
|
area_t new_geometry, new_f_geometry;
|
||||||
new_f_geometry = c->f_geometry;
|
new_f_geometry = c->f_geometry;
|
||||||
|
|
||||||
to = screen_area_get(c->screen, NULL, NULL);
|
to = screen_area_get(&globalconf.screens[c->screen].geometry,
|
||||||
from = screen_area_get(old_screen, NULL, NULL);
|
NULL, NULL);
|
||||||
|
from = screen_area_get(&globalconf.screens[old_screen].geometry,
|
||||||
|
NULL, NULL);
|
||||||
|
|
||||||
/* compute new coords in new screen */
|
/* compute new coords in new screen */
|
||||||
new_f_geometry.x = (c->f_geometry.x - from.x) + to.x;
|
new_f_geometry.x = (c->f_geometry.x - from.x) + to.x;
|
||||||
|
@ -213,4 +215,139 @@ screen_client_moveto(client_t *c, int new_screen, bool doresize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Screen module.
|
||||||
|
* \param L The Lua VM state.
|
||||||
|
* \return The number of elements pushed on stack.
|
||||||
|
* \luastack
|
||||||
|
* \lfield coords The screen coordinates.
|
||||||
|
* \lfield padding The screen padding.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
luaA_screen_module_index(lua_State *L)
|
||||||
|
{
|
||||||
|
int screen = luaL_checknumber(L, 2) - 1;
|
||||||
|
|
||||||
|
luaA_checkscreen(screen);
|
||||||
|
lua_pushlightuserdata(L, &globalconf.screens[screen]);
|
||||||
|
return luaA_settype(L, "screen");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A screen.
|
||||||
|
* \param L The Lua VM state.
|
||||||
|
* \luastack
|
||||||
|
* \lfield padding The screen padding. A table with top, right, left and bottom
|
||||||
|
* keys and values in pixel.
|
||||||
|
* \lfield coords The screen coordinates. Immutable.
|
||||||
|
* \lfield workarea The screen workarea, i.e. without statusbar.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
luaA_screen_index(lua_State *L)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
const char *buf = luaL_checklstring(L, 2, &len);
|
||||||
|
screen_t *s;
|
||||||
|
area_t g;
|
||||||
|
|
||||||
|
s = lua_touserdata(L, 1);
|
||||||
|
|
||||||
|
switch(a_tokenize(buf, len))
|
||||||
|
{
|
||||||
|
case A_TK_PADDING:
|
||||||
|
lua_newtable(L);
|
||||||
|
lua_pushnumber(L, s->padding.right);
|
||||||
|
lua_setfield(L, -2, "right");
|
||||||
|
lua_pushnumber(L, s->padding.left);
|
||||||
|
lua_setfield(L, -2, "left");
|
||||||
|
lua_pushnumber(L, s->padding.top);
|
||||||
|
lua_setfield(L, -2, "top");
|
||||||
|
lua_pushnumber(L, s->padding.bottom);
|
||||||
|
lua_setfield(L, -2, "bottom");
|
||||||
|
break;
|
||||||
|
case A_TK_COORDS:
|
||||||
|
/* \todo lua_pushgeometry() ? */
|
||||||
|
lua_newtable(L);
|
||||||
|
lua_pushnumber(L, s->geometry.x);
|
||||||
|
lua_setfield(L, -2, "x");
|
||||||
|
lua_pushnumber(L, s->geometry.y);
|
||||||
|
lua_setfield(L, -2, "y");
|
||||||
|
lua_pushnumber(L, s->geometry.width);
|
||||||
|
lua_setfield(L, -2, "width");
|
||||||
|
lua_pushnumber(L, s->geometry.height);
|
||||||
|
lua_setfield(L, -2, "height");
|
||||||
|
break;
|
||||||
|
case A_TK_WORKAREA:
|
||||||
|
g = screen_area_get(&s->geometry, s->statusbar, &s->padding);
|
||||||
|
lua_newtable(L);
|
||||||
|
lua_pushnumber(L, g.x);
|
||||||
|
lua_setfield(L, -2, "x");
|
||||||
|
lua_pushnumber(L, g.y);
|
||||||
|
lua_setfield(L, -2, "y");
|
||||||
|
lua_pushnumber(L, g.width);
|
||||||
|
lua_setfield(L, -2, "width");
|
||||||
|
lua_pushnumber(L, g.height);
|
||||||
|
lua_setfield(L, -2, "height");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
luaA_screen_newindex(lua_State *L)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
const char *buf = luaL_checklstring(L, 2, &len);
|
||||||
|
screen_t *s;
|
||||||
|
|
||||||
|
s = lua_touserdata(L, 1);
|
||||||
|
|
||||||
|
switch(a_tokenize(buf, len))
|
||||||
|
{
|
||||||
|
case A_TK_PADDING:
|
||||||
|
luaA_checktable(L, 3);
|
||||||
|
s->padding.right = luaA_getopt_number(L, 2, "right", 0);
|
||||||
|
s->padding.left = luaA_getopt_number(L, 2, "left", 0);
|
||||||
|
s->padding.top = luaA_getopt_number(L, 2, "top", 0);
|
||||||
|
s->padding.bottom = luaA_getopt_number(L, 2, "bottom", 0);
|
||||||
|
|
||||||
|
ewmh_update_workarea(screen_virttophys(s->index));
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get the screen count.
|
||||||
|
* \param L The Lua VM state.
|
||||||
|
* \return The number of elements pushed on stack.
|
||||||
|
*
|
||||||
|
* \luastack
|
||||||
|
* \lreturn The screen count, at least 1.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
luaA_screen_count(lua_State *L)
|
||||||
|
{
|
||||||
|
lua_pushnumber(L, globalconf.screens_info->nscreen);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const struct luaL_reg awesome_screen_methods[] =
|
||||||
|
{
|
||||||
|
{ "count", luaA_screen_count },
|
||||||
|
{ "__index", luaA_screen_module_index },
|
||||||
|
{ NULL, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct luaL_reg awesome_screen_meta[] =
|
||||||
|
{
|
||||||
|
{ "__index", luaA_screen_index },
|
||||||
|
{ "__newindex", luaA_screen_newindex },
|
||||||
|
{ NULL, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||||
|
|
2
screen.h
2
screen.h
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
#define SCREEN_UNDEF (-1)
|
#define SCREEN_UNDEF (-1)
|
||||||
|
|
||||||
area_t screen_area_get(int, statusbar_t *, padding_t *);
|
area_t screen_area_get(area_t *, statusbar_t *, padding_t *);
|
||||||
area_t display_area_get(int, statusbar_t *, padding_t *);
|
area_t display_area_get(int, statusbar_t *, padding_t *);
|
||||||
int screen_virttophys(int);
|
int screen_virttophys(int);
|
||||||
void screen_client_moveto(client_t *, int, bool);
|
void screen_client_moveto(client_t *, int, bool);
|
||||||
|
|
|
@ -223,7 +223,7 @@ statusbar_position_update(statusbar_t *statusbar)
|
||||||
if(statusbar->position == Off)
|
if(statusbar->position == Off)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
area = screen_area_get(statusbar->screen,
|
area = screen_area_get(&globalconf.screens[statusbar->screen].geometry,
|
||||||
NULL,
|
NULL,
|
||||||
&globalconf.screens[statusbar->screen].padding);
|
&globalconf.screens[statusbar->screen].padding);
|
||||||
|
|
||||||
|
|
|
@ -358,6 +358,10 @@ typedef struct
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
/** Screen index */
|
||||||
|
int index;
|
||||||
|
/** Screen geometry */
|
||||||
|
area_t geometry;
|
||||||
/** true if we need to arrange() */
|
/** true if we need to arrange() */
|
||||||
bool need_arrange;
|
bool need_arrange;
|
||||||
/** Tag list */
|
/** Tag list */
|
||||||
|
|
Loading…
Reference in New Issue