diff --git a/client.c b/client.c index fa0fdfa8..8b2b4d8b 100644 --- a/client.c +++ b/client.c @@ -683,8 +683,7 @@ client_resize(client_t *c, area_t geometry, bool hints) area_t area; /* offscreen appearance fixes */ - area = display_area_get(c->phys_screen, NULL, - &c->screen->padding); + area = display_area_get(c->phys_screen, NULL); if(geometry.x > area.width) geometry.x = area.width - geometry.width; @@ -815,7 +814,7 @@ client_setfullscreen(client_t *c, bool s) client_setabove(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->border_fs = c->border; client_setborder(c, 0); @@ -851,7 +850,6 @@ client_setmaxhoriz(client_t *c, bool s) geometry = screen_area_get(c->screen, &c->screen->wiboxes, - &c->screen->padding, true); geometry.y = c->geometry.y; geometry.height = c->geometry.height; @@ -891,7 +889,6 @@ client_setmaxvert(client_t *c, bool s) geometry = screen_area_get(c->screen, &c->screen->wiboxes, - &c->screen->padding, true); geometry.x = c->geometry.x; geometry.width = c->geometry.width; @@ -1439,7 +1436,7 @@ luaA_client_struts(lua_State *L) if(lua_gettop(L) == 2) { 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.right = luaA_getopt_number(L, 2, "right", c->strut.right); diff --git a/ewmh.c b/ewmh.c index 2d6ce176..950f764e 100644 --- a/ewmh.c +++ b/ewmh.c @@ -46,7 +46,6 @@ static void ewmh_update_desktop_geometry(int phys_screen) { area_t geom = screen_area_get(&globalconf.screens.tab[phys_screen], - NULL, NULL, false); 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); area_t geom = screen_area_get(&globalconf.screens.tab[phys_screen], &globalconf.screens.tab[phys_screen].wiboxes, - &globalconf.screens.tab[phys_screen].padding, true); diff --git a/lib/awful/layout/init.lua.in b/lib/awful/layout/init.lua.in index f7300326..3bff6014 100644 --- a/lib/awful/layout/init.lua.in +++ b/lib/awful/layout/init.lua.in @@ -11,6 +11,7 @@ local tag = require("awful.tag") local util = require("awful.util") local suit = require("awful.layout.suit") local client = require("awful.client") +local ascreen = require("awful.screen") local capi = { hooks = hooks, @@ -64,6 +65,14 @@ local function on_arrange (screen) local t = tag.selected(screen) local p = {} 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.clients = client.tiled(screen) p.ncol = tag.getncol(t) @@ -89,4 +98,6 @@ hooks.property.register(function (c, prop) 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 diff --git a/lib/awful/screen.lua.in b/lib/awful/screen.lua.in index 95f8a9b7..e6ef1c83 100644 --- a/lib/awful/screen.lua.in +++ b/lib/awful/screen.lua.in @@ -13,10 +13,17 @@ local capi = } local util = require("awful.util") local client = require("awful.client") +local hooks = require("awful.hooks") --- Screen module for awful 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. -- @param i Relative screen number. function focus(i) @@ -27,4 +34,16 @@ function focus(i) capi.mouse.screen = s 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 diff --git a/screen.c b/screen.c index 9fd2c065..62c9ef57 100644 --- a/screen.c +++ b/screen.c @@ -143,26 +143,15 @@ screen_getbycoord(screen_t *screen, int x, int y) /** Get screens info. * \param screen Screen. * \param wiboxes Wiboxes list to remove. - * \param padding Padding. * \param strut Honor windows strut. * \return The screen area. */ area_t -screen_area_get(screen_t *screen, wibox_array_t *wiboxes, - padding_t *padding, bool strut) +screen_area_get(screen_t *screen, wibox_array_t *wiboxes, bool strut) { area_t area = screen->geometry; 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) foreach(_c, globalconf.clients) { @@ -236,11 +225,10 @@ screen_area_get(screen_t *screen, wibox_array_t *wiboxes, /** Get display info. * \param phys_screen Physical screen number. * \param wiboxes The wiboxes. - * \param padding Padding. * \return The display area. */ 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); 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; } - /* 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; } @@ -327,8 +307,8 @@ screen_client_moveto(client_t *c, screen_t *new_screen, bool dotag, bool doresiz if(!doresize) return; - from = screen_area_get(old_screen, NULL, NULL, false); - to = screen_area_get(c->screen, NULL, NULL, false); + from = screen_area_get(old_screen, NULL, false); + to = screen_area_get(c->screen, NULL, false); area_t new_geometry = c->geometry; @@ -465,7 +445,7 @@ luaA_screen_index(lua_State *L) luaA_pusharea(L, s->geometry); break; 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; default: return 0; @@ -474,37 +454,6 @@ luaA_screen_index(lua_State *L) 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. * \param L The Lua VM state. * \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[] = { { "tags", luaA_screen_tags }, - { "padding", luaA_screen_padding }, { "__index", luaA_screen_index }, { NULL, NULL } }; diff --git a/screen.h b/screen.h index 7a68fd9e..507213ec 100644 --- a/screen.h +++ b/screen.h @@ -34,8 +34,6 @@ struct a_screen tag_array_t tags; /** Wiboxes */ wibox_array_t wiboxes; - /** Padding */ - padding_t padding; /** Window that contains the systray */ struct { @@ -54,8 +52,8 @@ ARRAY_FUNCS(screen_t, screen, DO_NOTHING) void screen_scan(void); screen_t *screen_getbycoord(screen_t *, int, int); -area_t screen_area_get(screen_t *, wibox_array_t *, padding_t *, bool); -area_t display_area_get(int, wibox_array_t *, padding_t *); +area_t screen_area_get(screen_t *, wibox_array_t *, bool); +area_t display_area_get(int, wibox_array_t *); int screen_virttophys(int); void screen_client_moveto(client_t *, screen_t *, bool, bool);