diff --git a/ewmh.c b/ewmh.c index dbe7580e..1172a400 100644 --- a/ewmh.c +++ b/ewmh.c @@ -453,24 +453,27 @@ ewmh_client_update_desktop(client_t *c) void ewmh_update_strut(xcb_window_t window, strut_t *strut) { - const uint32_t state[] = + if(window) { - strut->left, - strut->right, - strut->top, - strut->bottom, - strut->left_start_y, - strut->left_end_y, - strut->right_start_y, - strut->right_end_y, - strut->top_start_x, - strut->top_end_x, - strut->bottom_start_x, - strut->bottom_end_x - }; + const uint32_t state[] = + { + strut->left, + strut->right, + strut->top, + strut->bottom, + strut->left_start_y, + strut->left_end_y, + strut->right_start_y, + strut->right_end_y, + strut->top_start_x, + strut->top_end_x, + strut->bottom_start_x, + strut->bottom_end_x + }; - xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, - window, _NET_WM_STRUT_PARTIAL, CARDINAL, 32, countof(state), state); + xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, + window, _NET_WM_STRUT_PARTIAL, CARDINAL, 32, countof(state), state); + } } void diff --git a/objects/client.c b/objects/client.c index 87ce9262..a37b489f 100644 --- a/objects/client.c +++ b/objects/client.c @@ -1506,29 +1506,6 @@ luaA_client_geometry(lua_State *L) return luaA_pusharea(L, c->geometry); } -/** Return client struts (reserved space at the edge of the screen). - * \param L The Lua VM state. - * \return The number of elements pushed on stack. - * \luastack - * \lparam A table with new strut values, or none. - * \lreturn A table with strut values. - */ -static int -luaA_client_struts(lua_State *L) -{ - client_t *c = luaA_checkudata(L, 1, &client_class); - - if(lua_gettop(L) == 2) - { - luaA_tostrut(L, 2, &c->strut); - ewmh_update_strut(c->window, &c->strut); - luaA_object_emit_signal(L, 1, "property::struts", 0); - screen_emit_signal(L, c->screen, "property::workarea", 0); - } - - return luaA_pushstrut(L, c->strut); -} - static int luaA_client_set_screen(lua_State *L, client_t *c) { @@ -2048,7 +2025,6 @@ client_class_setup(lua_State *L) { "keys", luaA_client_keys }, { "isvisible", luaA_client_isvisible }, { "geometry", luaA_client_geometry }, - { "struts", luaA_client_struts }, { "tags", luaA_client_tags }, { "kill", luaA_client_kill }, { "swap", luaA_client_swap }, diff --git a/objects/client.h b/objects/client.h index b534d7f0..90f8f57a 100644 --- a/objects/client.h +++ b/objects/client.h @@ -24,7 +24,6 @@ #include "mouse.h" #include "stack.h" -#include "strut.h" #include "draw.h" #include "banning.h" #include "objects/window.h" @@ -80,8 +79,6 @@ struct client_t /** Internal geometry (matching X11 protocol) */ area_t internal; } geometries; - /** Strut */ - strut_t strut; /** Border width and pre-fullscreen border width */ int border_width, border_width_fs; xcolor_t border_color; @@ -123,8 +120,6 @@ struct client_t xcb_window_t leader_window; /** Client's WM_PROTOCOLS property */ xcb_get_wm_protocols_reply_t protocols; - /** Client logical screen */ - screen_t *screen; /** Client physical screen */ int phys_screen; /** Button bindings */ diff --git a/objects/wibox.c b/objects/wibox.c index 2f4c653f..05c90960 100644 --- a/objects/wibox.c +++ b/objects/wibox.c @@ -884,24 +884,6 @@ luaA_wibox_geometry(lua_State *L) return luaA_pusharea(L, wibox->geometry); } -static int -luaA_wibox_struts(lua_State *L) -{ - wibox_t *w = luaA_checkudata(L, 1, &wibox_class); - - if(lua_gettop(L) == 2) - { - luaA_tostrut(L, 2, &w->strut); - if(w->window) - ewmh_update_strut(w->window, &w->strut); - luaA_object_emit_signal(L, 1, "property::struts", 0); - if(w->screen) - screen_emit_signal(L, w->screen, "property::workarea", 0); - } - - return luaA_pushstrut(L, w->strut); -} - LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, ontop, lua_pushboolean) LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, cursor, lua_pushstring) LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, visible, lua_pushboolean) @@ -1334,7 +1316,6 @@ wibox_class_setup(lua_State *L) { LUA_OBJECT_META(wibox) LUA_CLASS_META - { "struts", luaA_wibox_struts }, { "buttons", luaA_wibox_buttons }, { "geometry", luaA_wibox_geometry }, { "__gc", luaA_wibox_gc }, diff --git a/objects/wibox.h b/objects/wibox.h index db8689a9..c176566f 100644 --- a/objects/wibox.h +++ b/objects/wibox.h @@ -23,7 +23,6 @@ #define AWESOME_WIBOX_H #include "objects/widget.h" -#include "strut.h" #include "objects/window.h" #include "common/luaobject.h" @@ -35,8 +34,6 @@ struct wibox_t bool ontop; /** Visible */ bool visible; - /** Screen */ - screen_t *screen; /** Widget list */ widget_node_array_t widgets; void *widgets_table; @@ -66,8 +63,6 @@ struct wibox_t draw_context_t ctx; /** Orientation */ orientation_t orientation; - /** Strut */ - strut_t strut; /** The window's shape */ struct { diff --git a/objects/window.c b/objects/window.c index 2079449d..cb33e791 100644 --- a/objects/window.c +++ b/objects/window.c @@ -21,11 +21,34 @@ #include "luaa.h" #include "xwindow.h" +#include "ewmh.h" +#include "screen.h" #include "objects/window.h" #include "common/luaobject.h" LUA_CLASS_FUNCS(window, window_class) +/** Return window struts (reserved space at the edge of the screen). + * \param L The Lua VM state. + * \return The number of elements pushed on stack. + */ +static int +luaA_window_struts(lua_State *L) +{ + window_t *window = luaA_checkudata(L, 1, &window_class); + + if(lua_gettop(L) == 2) + { + luaA_tostrut(L, 2, &window->strut); + ewmh_update_strut(window->window, &window->strut); + luaA_object_emit_signal(L, 1, "property::struts", 0); + if(window->screen) + screen_emit_signal(L, window->screen, "property::workarea", 0); + } + + return luaA_pushstrut(L, window->strut); +} + /** Set a window opacity. * \param L The Lua VM state. * \param idx The index of the window on the stack. @@ -91,6 +114,7 @@ window_class_setup(lua_State *L) static const struct luaL_reg window_meta[] = { + { "struts", luaA_window_struts }, { NULL, NULL } }; diff --git a/objects/window.h b/objects/window.h index 2722615e..2dc17ae4 100644 --- a/objects/window.h +++ b/objects/window.h @@ -22,6 +22,7 @@ #ifndef AWESOME_OBJECTS_WINDOW_H #define AWESOME_OBJECTS_WINDOW_H +#include "strut.h" #include "common/luaclass.h" #define WINDOW_OBJECT_HEADER \ @@ -29,7 +30,11 @@ /** The X window number */ \ xcb_window_t window; \ /** Opacity */ \ - double opacity; + double opacity; \ + /** Strut */ \ + strut_t strut; \ + /** Client logical screen */ \ + screen_t *screen; /** Window structure */ typedef struct