window: add strut support

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-10-01 16:36:46 +02:00
parent 220d072164
commit 92717a0849
7 changed files with 49 additions and 70 deletions

35
ewmh.c
View File

@ -453,24 +453,27 @@ ewmh_client_update_desktop(client_t *c)
void void
ewmh_update_strut(xcb_window_t window, strut_t *strut) ewmh_update_strut(xcb_window_t window, strut_t *strut)
{ {
const uint32_t state[] = if(window)
{ {
strut->left, const uint32_t state[] =
strut->right, {
strut->top, strut->left,
strut->bottom, strut->right,
strut->left_start_y, strut->top,
strut->left_end_y, strut->bottom,
strut->right_start_y, strut->left_start_y,
strut->right_end_y, strut->left_end_y,
strut->top_start_x, strut->right_start_y,
strut->top_end_x, strut->right_end_y,
strut->bottom_start_x, strut->top_start_x,
strut->bottom_end_x strut->top_end_x,
}; strut->bottom_start_x,
strut->bottom_end_x
};
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
window, _NET_WM_STRUT_PARTIAL, CARDINAL, 32, countof(state), state); window, _NET_WM_STRUT_PARTIAL, CARDINAL, 32, countof(state), state);
}
} }
void void

View File

@ -1506,29 +1506,6 @@ luaA_client_geometry(lua_State *L)
return luaA_pusharea(L, c->geometry); 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 static int
luaA_client_set_screen(lua_State *L, client_t *c) luaA_client_set_screen(lua_State *L, client_t *c)
{ {
@ -2048,7 +2025,6 @@ client_class_setup(lua_State *L)
{ "keys", luaA_client_keys }, { "keys", luaA_client_keys },
{ "isvisible", luaA_client_isvisible }, { "isvisible", luaA_client_isvisible },
{ "geometry", luaA_client_geometry }, { "geometry", luaA_client_geometry },
{ "struts", luaA_client_struts },
{ "tags", luaA_client_tags }, { "tags", luaA_client_tags },
{ "kill", luaA_client_kill }, { "kill", luaA_client_kill },
{ "swap", luaA_client_swap }, { "swap", luaA_client_swap },

View File

@ -24,7 +24,6 @@
#include "mouse.h" #include "mouse.h"
#include "stack.h" #include "stack.h"
#include "strut.h"
#include "draw.h" #include "draw.h"
#include "banning.h" #include "banning.h"
#include "objects/window.h" #include "objects/window.h"
@ -80,8 +79,6 @@ struct client_t
/** Internal geometry (matching X11 protocol) */ /** Internal geometry (matching X11 protocol) */
area_t internal; area_t internal;
} geometries; } geometries;
/** Strut */
strut_t strut;
/** Border width and pre-fullscreen border width */ /** Border width and pre-fullscreen border width */
int border_width, border_width_fs; int border_width, border_width_fs;
xcolor_t border_color; xcolor_t border_color;
@ -123,8 +120,6 @@ struct client_t
xcb_window_t leader_window; xcb_window_t leader_window;
/** Client's WM_PROTOCOLS property */ /** Client's WM_PROTOCOLS property */
xcb_get_wm_protocols_reply_t protocols; xcb_get_wm_protocols_reply_t protocols;
/** Client logical screen */
screen_t *screen;
/** Client physical screen */ /** Client physical screen */
int phys_screen; int phys_screen;
/** Button bindings */ /** Button bindings */

View File

@ -884,24 +884,6 @@ luaA_wibox_geometry(lua_State *L)
return luaA_pusharea(L, wibox->geometry); 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, ontop, lua_pushboolean)
LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, cursor, lua_pushstring) LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, cursor, lua_pushstring)
LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, visible, lua_pushboolean) 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_OBJECT_META(wibox)
LUA_CLASS_META LUA_CLASS_META
{ "struts", luaA_wibox_struts },
{ "buttons", luaA_wibox_buttons }, { "buttons", luaA_wibox_buttons },
{ "geometry", luaA_wibox_geometry }, { "geometry", luaA_wibox_geometry },
{ "__gc", luaA_wibox_gc }, { "__gc", luaA_wibox_gc },

View File

@ -23,7 +23,6 @@
#define AWESOME_WIBOX_H #define AWESOME_WIBOX_H
#include "objects/widget.h" #include "objects/widget.h"
#include "strut.h"
#include "objects/window.h" #include "objects/window.h"
#include "common/luaobject.h" #include "common/luaobject.h"
@ -35,8 +34,6 @@ struct wibox_t
bool ontop; bool ontop;
/** Visible */ /** Visible */
bool visible; bool visible;
/** Screen */
screen_t *screen;
/** Widget list */ /** Widget list */
widget_node_array_t widgets; widget_node_array_t widgets;
void *widgets_table; void *widgets_table;
@ -66,8 +63,6 @@ struct wibox_t
draw_context_t ctx; draw_context_t ctx;
/** Orientation */ /** Orientation */
orientation_t orientation; orientation_t orientation;
/** Strut */
strut_t strut;
/** The window's shape */ /** The window's shape */
struct struct
{ {

View File

@ -21,11 +21,34 @@
#include "luaa.h" #include "luaa.h"
#include "xwindow.h" #include "xwindow.h"
#include "ewmh.h"
#include "screen.h"
#include "objects/window.h" #include "objects/window.h"
#include "common/luaobject.h" #include "common/luaobject.h"
LUA_CLASS_FUNCS(window, window_class) 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. /** Set a window opacity.
* \param L The Lua VM state. * \param L The Lua VM state.
* \param idx The index of the window on the stack. * \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[] = static const struct luaL_reg window_meta[] =
{ {
{ "struts", luaA_window_struts },
{ NULL, NULL } { NULL, NULL }
}; };

View File

@ -22,6 +22,7 @@
#ifndef AWESOME_OBJECTS_WINDOW_H #ifndef AWESOME_OBJECTS_WINDOW_H
#define AWESOME_OBJECTS_WINDOW_H #define AWESOME_OBJECTS_WINDOW_H
#include "strut.h"
#include "common/luaclass.h" #include "common/luaclass.h"
#define WINDOW_OBJECT_HEADER \ #define WINDOW_OBJECT_HEADER \
@ -29,7 +30,11 @@
/** The X window number */ \ /** The X window number */ \
xcb_window_t window; \ xcb_window_t window; \
/** Opacity */ \ /** Opacity */ \
double opacity; double opacity; \
/** Strut */ \
strut_t strut; \
/** Client logical screen */ \
screen_t *screen;
/** Window structure */ /** Window structure */
typedef struct typedef struct