screen: move padding in Lua
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
0c564079b5
commit
e15aab73bf
9
client.c
9
client.c
|
@ -683,8 +683,7 @@ client_resize(client_t *c, area_t geometry, bool hints)
|
||||||
area_t area;
|
area_t area;
|
||||||
|
|
||||||
/* offscreen appearance fixes */
|
/* offscreen appearance fixes */
|
||||||
area = display_area_get(c->phys_screen, NULL,
|
area = display_area_get(c->phys_screen, NULL);
|
||||||
&c->screen->padding);
|
|
||||||
|
|
||||||
if(geometry.x > area.width)
|
if(geometry.x > area.width)
|
||||||
geometry.x = area.width - geometry.width;
|
geometry.x = area.width - geometry.width;
|
||||||
|
@ -815,7 +814,7 @@ client_setfullscreen(client_t *c, bool s)
|
||||||
client_setabove(c, false);
|
client_setabove(c, false);
|
||||||
client_setontop(c, false);
|
client_setontop(c, false);
|
||||||
|
|
||||||
geometry = screen_area_get(c->screen, NULL, NULL, false);
|
geometry = screen_area_get(c->screen, NULL, false);
|
||||||
c->geometries.fullscreen = c->geometry;
|
c->geometries.fullscreen = c->geometry;
|
||||||
c->border_fs = c->border;
|
c->border_fs = c->border;
|
||||||
client_setborder(c, 0);
|
client_setborder(c, 0);
|
||||||
|
@ -851,7 +850,6 @@ client_setmaxhoriz(client_t *c, bool s)
|
||||||
|
|
||||||
geometry = screen_area_get(c->screen,
|
geometry = screen_area_get(c->screen,
|
||||||
&c->screen->wiboxes,
|
&c->screen->wiboxes,
|
||||||
&c->screen->padding,
|
|
||||||
true);
|
true);
|
||||||
geometry.y = c->geometry.y;
|
geometry.y = c->geometry.y;
|
||||||
geometry.height = c->geometry.height;
|
geometry.height = c->geometry.height;
|
||||||
|
@ -891,7 +889,6 @@ client_setmaxvert(client_t *c, bool s)
|
||||||
|
|
||||||
geometry = screen_area_get(c->screen,
|
geometry = screen_area_get(c->screen,
|
||||||
&c->screen->wiboxes,
|
&c->screen->wiboxes,
|
||||||
&c->screen->padding,
|
|
||||||
true);
|
true);
|
||||||
geometry.x = c->geometry.x;
|
geometry.x = c->geometry.x;
|
||||||
geometry.width = c->geometry.width;
|
geometry.width = c->geometry.width;
|
||||||
|
@ -1439,7 +1436,7 @@ luaA_client_struts(lua_State *L)
|
||||||
if(lua_gettop(L) == 2)
|
if(lua_gettop(L) == 2)
|
||||||
{
|
{
|
||||||
strut_t struts;
|
strut_t struts;
|
||||||
area_t screen_area = display_area_get(c->phys_screen, NULL, NULL);
|
area_t screen_area = display_area_get(c->phys_screen, NULL);
|
||||||
|
|
||||||
struts.left = luaA_getopt_number(L, 2, "left", c->strut.left);
|
struts.left = luaA_getopt_number(L, 2, "left", c->strut.left);
|
||||||
struts.right = luaA_getopt_number(L, 2, "right", c->strut.right);
|
struts.right = luaA_getopt_number(L, 2, "right", c->strut.right);
|
||||||
|
|
2
ewmh.c
2
ewmh.c
|
@ -46,7 +46,6 @@ static void
|
||||||
ewmh_update_desktop_geometry(int phys_screen)
|
ewmh_update_desktop_geometry(int phys_screen)
|
||||||
{
|
{
|
||||||
area_t geom = screen_area_get(&globalconf.screens.tab[phys_screen],
|
area_t geom = screen_area_get(&globalconf.screens.tab[phys_screen],
|
||||||
NULL,
|
|
||||||
NULL,
|
NULL,
|
||||||
false);
|
false);
|
||||||
uint32_t sizes[] = { geom.width, geom.height };
|
uint32_t sizes[] = { geom.width, geom.height };
|
||||||
|
@ -234,7 +233,6 @@ ewmh_update_workarea(int phys_screen)
|
||||||
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(&globalconf.screens.tab[phys_screen],
|
area_t geom = screen_area_get(&globalconf.screens.tab[phys_screen],
|
||||||
&globalconf.screens.tab[phys_screen].wiboxes,
|
&globalconf.screens.tab[phys_screen].wiboxes,
|
||||||
&globalconf.screens.tab[phys_screen].padding,
|
|
||||||
true);
|
true);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ local tag = require("awful.tag")
|
||||||
local util = require("awful.util")
|
local util = require("awful.util")
|
||||||
local suit = require("awful.layout.suit")
|
local suit = require("awful.layout.suit")
|
||||||
local client = require("awful.client")
|
local client = require("awful.client")
|
||||||
|
local ascreen = require("awful.screen")
|
||||||
local capi =
|
local capi =
|
||||||
{
|
{
|
||||||
hooks = hooks,
|
hooks = hooks,
|
||||||
|
@ -64,6 +65,14 @@ local function on_arrange (screen)
|
||||||
local t = tag.selected(screen)
|
local t = tag.selected(screen)
|
||||||
local p = {}
|
local p = {}
|
||||||
p.workarea = capi.screen[screen].workarea
|
p.workarea = capi.screen[screen].workarea
|
||||||
|
-- Handle padding
|
||||||
|
local padding = ascreen.padding(screen)
|
||||||
|
if padding then
|
||||||
|
p.workarea.x = p.workarea.x + (padding.left or 0)
|
||||||
|
p.workarea.y = p.workarea.y + (padding.top or 0)
|
||||||
|
p.workarea.width = p.workarea.width - ((padding.left or 0 ) + (padding.right or 0))
|
||||||
|
p.workarea.height = p.workarea.height - ((padding.top or 0) + (padding.bottom or 0))
|
||||||
|
end
|
||||||
p.geometry = capi.screen[screen].geometry
|
p.geometry = capi.screen[screen].geometry
|
||||||
p.clients = client.tiled(screen)
|
p.clients = client.tiled(screen)
|
||||||
p.ncol = tag.getncol(t)
|
p.ncol = tag.getncol(t)
|
||||||
|
@ -89,4 +98,6 @@ hooks.property.register(function (c, prop)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
hooks.padding.register(function(screen) on_arrange(screen) end)
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||||
|
|
|
@ -13,10 +13,17 @@ local capi =
|
||||||
}
|
}
|
||||||
local util = require("awful.util")
|
local util = require("awful.util")
|
||||||
local client = require("awful.client")
|
local client = require("awful.client")
|
||||||
|
local hooks = require("awful.hooks")
|
||||||
|
|
||||||
--- Screen module for awful
|
--- Screen module for awful
|
||||||
module("awful.screen")
|
module("awful.screen")
|
||||||
|
|
||||||
|
local data = {}
|
||||||
|
data.padding = {}
|
||||||
|
|
||||||
|
-- Create a hook for padding event
|
||||||
|
hooks.user.create("padding")
|
||||||
|
|
||||||
--- Give the focus to a screen, and move pointer.
|
--- Give the focus to a screen, and move pointer.
|
||||||
-- @param i Relative screen number.
|
-- @param i Relative screen number.
|
||||||
function focus(i)
|
function focus(i)
|
||||||
|
@ -27,4 +34,16 @@ function focus(i)
|
||||||
capi.mouse.screen = s
|
capi.mouse.screen = s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get or set the screen padding.
|
||||||
|
-- @param i The screen number.
|
||||||
|
-- @param padding The padding, an table with 'top', 'left', 'right' and/or
|
||||||
|
-- 'bottom'. Can be nil if you only want to retrieve padding
|
||||||
|
function padding(i, padding)
|
||||||
|
if padding then
|
||||||
|
data.padding[i] = padding
|
||||||
|
hooks.user.call("padding", i)
|
||||||
|
end
|
||||||
|
return data.padding[i]
|
||||||
|
end
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||||
|
|
62
screen.c
62
screen.c
|
@ -143,26 +143,15 @@ screen_getbycoord(screen_t *screen, int x, int y)
|
||||||
/** Get screens info.
|
/** Get screens info.
|
||||||
* \param screen Screen.
|
* \param screen Screen.
|
||||||
* \param wiboxes Wiboxes list to remove.
|
* \param wiboxes Wiboxes list to remove.
|
||||||
* \param padding Padding.
|
|
||||||
* \param strut Honor windows strut.
|
* \param strut Honor windows strut.
|
||||||
* \return The screen area.
|
* \return The screen area.
|
||||||
*/
|
*/
|
||||||
area_t
|
area_t
|
||||||
screen_area_get(screen_t *screen, wibox_array_t *wiboxes,
|
screen_area_get(screen_t *screen, wibox_array_t *wiboxes, bool strut)
|
||||||
padding_t *padding, bool strut)
|
|
||||||
{
|
{
|
||||||
area_t area = screen->geometry;
|
area_t area = screen->geometry;
|
||||||
uint16_t top = 0, bottom = 0, left = 0, right = 0;
|
uint16_t top = 0, bottom = 0, left = 0, right = 0;
|
||||||
|
|
||||||
/* make padding corrections */
|
|
||||||
if(padding)
|
|
||||||
{
|
|
||||||
area.x += padding->left;
|
|
||||||
area.y += padding->top;
|
|
||||||
area.width -= padding->left + padding->right;
|
|
||||||
area.height -= padding->top + padding->bottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(strut)
|
if(strut)
|
||||||
foreach(_c, globalconf.clients)
|
foreach(_c, globalconf.clients)
|
||||||
{
|
{
|
||||||
|
@ -236,11 +225,10 @@ screen_area_get(screen_t *screen, wibox_array_t *wiboxes,
|
||||||
/** Get display info.
|
/** Get display info.
|
||||||
* \param phys_screen Physical screen number.
|
* \param phys_screen Physical screen number.
|
||||||
* \param wiboxes The wiboxes.
|
* \param wiboxes The wiboxes.
|
||||||
* \param padding Padding.
|
|
||||||
* \return The display area.
|
* \return The display area.
|
||||||
*/
|
*/
|
||||||
area_t
|
area_t
|
||||||
display_area_get(int phys_screen, wibox_array_t *wiboxes, padding_t *padding)
|
display_area_get(int phys_screen, wibox_array_t *wiboxes)
|
||||||
{
|
{
|
||||||
xcb_screen_t *s = xutil_screen_get(globalconf.connection, phys_screen);
|
xcb_screen_t *s = xutil_screen_get(globalconf.connection, phys_screen);
|
||||||
area_t area = { .x = 0,
|
area_t area = { .x = 0,
|
||||||
|
@ -256,14 +244,6 @@ display_area_get(int phys_screen, wibox_array_t *wiboxes, padding_t *padding)
|
||||||
area.height -= (w->position == Top || w->position == Bottom) ? w->sw.geometry.height : 0;
|
area.height -= (w->position == Top || w->position == Bottom) ? w->sw.geometry.height : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make padding corrections */
|
|
||||||
if(padding)
|
|
||||||
{
|
|
||||||
area.x += padding->left;
|
|
||||||
area.y += padding->top;
|
|
||||||
area.width -= padding->left + padding->right;
|
|
||||||
area.height -= padding->top + padding->bottom;
|
|
||||||
}
|
|
||||||
return area;
|
return area;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,8 +307,8 @@ screen_client_moveto(client_t *c, screen_t *new_screen, bool dotag, bool doresiz
|
||||||
if(!doresize)
|
if(!doresize)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
from = screen_area_get(old_screen, NULL, NULL, false);
|
from = screen_area_get(old_screen, NULL, false);
|
||||||
to = screen_area_get(c->screen, NULL, NULL, false);
|
to = screen_area_get(c->screen, NULL, false);
|
||||||
|
|
||||||
area_t new_geometry = c->geometry;
|
area_t new_geometry = c->geometry;
|
||||||
|
|
||||||
|
@ -465,7 +445,7 @@ luaA_screen_index(lua_State *L)
|
||||||
luaA_pusharea(L, s->geometry);
|
luaA_pusharea(L, s->geometry);
|
||||||
break;
|
break;
|
||||||
case A_TK_WORKAREA:
|
case A_TK_WORKAREA:
|
||||||
luaA_pusharea(L, screen_area_get(s, &s->wiboxes, &s->padding, true));
|
luaA_pusharea(L, screen_area_get(s, &s->wiboxes, true));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -474,37 +454,6 @@ luaA_screen_index(lua_State *L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set or get the screen padding.
|
|
||||||
* \param L The Lua VM state.
|
|
||||||
* \return The number of elements pushed on stack.
|
|
||||||
* \luastack
|
|
||||||
* \lparam None or a table with new padding values.
|
|
||||||
* \lreturn The screen padding. A table with top, right, left and bottom
|
|
||||||
* keys and values in pixel.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
luaA_screen_padding(lua_State *L)
|
|
||||||
{
|
|
||||||
screen_t *s = lua_touserdata(L, 1);
|
|
||||||
|
|
||||||
if(!s)
|
|
||||||
luaL_typerror(L, 1, "screen");
|
|
||||||
|
|
||||||
if(lua_gettop(L) == 2)
|
|
||||||
{
|
|
||||||
s->padding = luaA_getopt_padding(L, 2, &s->padding);
|
|
||||||
|
|
||||||
s->need_arrange = true;
|
|
||||||
|
|
||||||
/* All the wiboxes repositioned */
|
|
||||||
foreach(w, s->wiboxes)
|
|
||||||
wibox_position_update(*w);
|
|
||||||
|
|
||||||
ewmh_update_workarea(screen_virttophys(screen_array_indexof(&globalconf.screens, s)));
|
|
||||||
}
|
|
||||||
return luaA_pushpadding(L, &s->padding);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get the screen count.
|
/** Get the screen count.
|
||||||
* \param L The Lua VM state.
|
* \param L The Lua VM state.
|
||||||
* \return The number of elements pushed on stack.
|
* \return The number of elements pushed on stack.
|
||||||
|
@ -529,7 +478,6 @@ const struct luaL_reg awesome_screen_methods[] =
|
||||||
const struct luaL_reg awesome_screen_meta[] =
|
const struct luaL_reg awesome_screen_meta[] =
|
||||||
{
|
{
|
||||||
{ "tags", luaA_screen_tags },
|
{ "tags", luaA_screen_tags },
|
||||||
{ "padding", luaA_screen_padding },
|
|
||||||
{ "__index", luaA_screen_index },
|
{ "__index", luaA_screen_index },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
6
screen.h
6
screen.h
|
@ -34,8 +34,6 @@ struct a_screen
|
||||||
tag_array_t tags;
|
tag_array_t tags;
|
||||||
/** Wiboxes */
|
/** Wiboxes */
|
||||||
wibox_array_t wiboxes;
|
wibox_array_t wiboxes;
|
||||||
/** Padding */
|
|
||||||
padding_t padding;
|
|
||||||
/** Window that contains the systray */
|
/** Window that contains the systray */
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
@ -54,8 +52,8 @@ ARRAY_FUNCS(screen_t, screen, DO_NOTHING)
|
||||||
|
|
||||||
void screen_scan(void);
|
void screen_scan(void);
|
||||||
screen_t *screen_getbycoord(screen_t *, int, int);
|
screen_t *screen_getbycoord(screen_t *, int, int);
|
||||||
area_t screen_area_get(screen_t *, wibox_array_t *, padding_t *, bool);
|
area_t screen_area_get(screen_t *, wibox_array_t *, bool);
|
||||||
area_t display_area_get(int, wibox_array_t *, padding_t *);
|
area_t display_area_get(int, wibox_array_t *);
|
||||||
int screen_virttophys(int);
|
int screen_virttophys(int);
|
||||||
void screen_client_moveto(client_t *, screen_t *, bool, bool);
|
void screen_client_moveto(client_t *, screen_t *, bool, bool);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue