window: import border_width property
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
4f6667b56f
commit
c94f7b6767
2
event.c
2
event.c
|
@ -276,7 +276,7 @@ event_handle_configurerequest(void *data __attribute__ ((unused)),
|
||||||
if(ev->value_mask & XCB_CONFIG_WINDOW_BORDER_WIDTH)
|
if(ev->value_mask & XCB_CONFIG_WINDOW_BORDER_WIDTH)
|
||||||
{
|
{
|
||||||
luaA_object_push(globalconf.L, c);
|
luaA_object_push(globalconf.L, c);
|
||||||
client_set_border_width(globalconf.L, -1, ev->border_width);
|
window_set_border_width(globalconf.L, -1, ev->border_width);
|
||||||
lua_pop(globalconf.L, 1);
|
lua_pop(globalconf.L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -462,8 +462,8 @@ HANDLE_GEOM(height)
|
||||||
|
|
||||||
luaA_object_emit_signal(globalconf.L, -1, "property::geometry", 0);
|
luaA_object_emit_signal(globalconf.L, -1, "property::geometry", 0);
|
||||||
|
|
||||||
/* Push client */
|
/* Set border width */
|
||||||
client_set_border_width(globalconf.L, -1, wgeom->border_width);
|
window_set_border_width(globalconf.L, -1, wgeom->border_width);
|
||||||
|
|
||||||
/* we honor size hints by default */
|
/* we honor size hints by default */
|
||||||
c->size_hints_honor = true;
|
c->size_hints_honor = true;
|
||||||
|
@ -792,14 +792,14 @@ client_set_fullscreen(lua_State *L, int cidx, bool s)
|
||||||
geometry = screen_area_get(c->screen, false);
|
geometry = screen_area_get(c->screen, false);
|
||||||
c->geometries.fullscreen = c->geometry;
|
c->geometries.fullscreen = c->geometry;
|
||||||
c->border_width_fs = c->border_width;
|
c->border_width_fs = c->border_width;
|
||||||
client_set_border_width(L, cidx, 0);
|
window_set_border_width(L, cidx, 0);
|
||||||
c->fullscreen = true;
|
c->fullscreen = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
geometry = c->geometries.fullscreen;
|
geometry = c->geometries.fullscreen;
|
||||||
c->fullscreen = false;
|
c->fullscreen = false;
|
||||||
client_set_border_width(L, cidx, c->border_width_fs);
|
window_set_border_width(L, cidx, c->border_width_fs);
|
||||||
}
|
}
|
||||||
client_resize(c, geometry, false);
|
client_resize(c, geometry, false);
|
||||||
stack_windows();
|
stack_windows();
|
||||||
|
@ -1144,44 +1144,6 @@ luaA_client_isvisible(lua_State *L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set client border width.
|
|
||||||
* \param L The Lua VM state.
|
|
||||||
* \param cidx The client index.
|
|
||||||
* \param width The border width.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
client_set_border_width(lua_State *L, int cidx, int width)
|
|
||||||
{
|
|
||||||
client_t *c = luaA_checkudata(L, cidx, &client_class);
|
|
||||||
uint32_t w = width;
|
|
||||||
|
|
||||||
if(width > 0 && (c->type == WINDOW_TYPE_DOCK
|
|
||||||
|| c->type == WINDOW_TYPE_SPLASH
|
|
||||||
|| c->type == WINDOW_TYPE_DESKTOP
|
|
||||||
|| c->fullscreen))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(width == c->border_width || width < 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* disallow change of border width if the client is fullscreen */
|
|
||||||
if(c->fullscreen)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* Update geometry with the new border. */
|
|
||||||
c->geometry.width -= 2 * c->border_width;
|
|
||||||
c->geometry.height -= 2 * c->border_width;
|
|
||||||
|
|
||||||
c->border_width = width;
|
|
||||||
xcb_configure_window(globalconf.connection, c->window,
|
|
||||||
XCB_CONFIG_WINDOW_BORDER_WIDTH, &w);
|
|
||||||
|
|
||||||
c->geometry.width += 2 * c->border_width;
|
|
||||||
c->geometry.height += 2 * c->border_width;
|
|
||||||
|
|
||||||
luaA_object_emit_signal(L, cidx, "property::border_width", 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Set a client icon.
|
/** Set a client icon.
|
||||||
* \param L The Lua VM state.
|
* \param L The Lua VM state.
|
||||||
* \param cidx The client index on the stack.
|
* \param cidx The client index on the stack.
|
||||||
|
@ -1451,13 +1413,6 @@ luaA_client_set_size_hints_honor(lua_State *L, client_t *c)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
luaA_client_set_border_width(lua_State *L, client_t *c)
|
|
||||||
{
|
|
||||||
client_set_border_width(L, -3, luaL_checknumber(L, -1));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
luaA_client_set_ontop(lua_State *L, client_t *c)
|
luaA_client_set_ontop(lua_State *L, client_t *c)
|
||||||
{
|
{
|
||||||
|
@ -1528,7 +1483,6 @@ LUA_OBJECT_EXPORT_PROPERTY(client, client_t, sticky, lua_pushboolean)
|
||||||
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, size_hints_honor, lua_pushboolean)
|
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, size_hints_honor, lua_pushboolean)
|
||||||
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, maximized_horizontal, lua_pushboolean)
|
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, maximized_horizontal, lua_pushboolean)
|
||||||
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, maximized_vertical, lua_pushboolean)
|
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, maximized_vertical, lua_pushboolean)
|
||||||
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, border_width, lua_pushnumber)
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
luaA_client_get_content(lua_State *L, client_t *c)
|
luaA_client_get_content(lua_State *L, client_t *c)
|
||||||
|
@ -1964,10 +1918,6 @@ client_class_setup(lua_State *L)
|
||||||
(lua_class_propfunc_t) luaA_client_set_size_hints_honor,
|
(lua_class_propfunc_t) luaA_client_set_size_hints_honor,
|
||||||
(lua_class_propfunc_t) luaA_client_get_size_hints_honor,
|
(lua_class_propfunc_t) luaA_client_get_size_hints_honor,
|
||||||
(lua_class_propfunc_t) luaA_client_set_size_hints_honor);
|
(lua_class_propfunc_t) luaA_client_set_size_hints_honor);
|
||||||
luaA_class_add_property(&client_class, A_TK_BORDER_WIDTH,
|
|
||||||
(lua_class_propfunc_t) luaA_client_set_border_width,
|
|
||||||
(lua_class_propfunc_t) luaA_client_get_border_width,
|
|
||||||
(lua_class_propfunc_t) luaA_client_set_border_width);
|
|
||||||
luaA_class_add_property(&client_class, A_TK_URGENT,
|
luaA_class_add_property(&client_class, A_TK_URGENT,
|
||||||
(lua_class_propfunc_t) luaA_client_set_urgent,
|
(lua_class_propfunc_t) luaA_client_set_urgent,
|
||||||
(lua_class_propfunc_t) luaA_client_get_urgent,
|
(lua_class_propfunc_t) luaA_client_get_urgent,
|
||||||
|
|
|
@ -79,8 +79,8 @@ struct client_t
|
||||||
/** Internal geometry (matching X11 protocol) */
|
/** Internal geometry (matching X11 protocol) */
|
||||||
area_t internal;
|
area_t internal;
|
||||||
} geometries;
|
} geometries;
|
||||||
/** Border width and pre-fullscreen border width */
|
/** Pre-fullscreen border width */
|
||||||
int border_width, border_width_fs;
|
int border_width_fs;
|
||||||
/** True if the client is sticky */
|
/** True if the client is sticky */
|
||||||
bool sticky;
|
bool sticky;
|
||||||
/** Has urgency hint */
|
/** Has urgency hint */
|
||||||
|
@ -164,7 +164,6 @@ void client_set_fullscreen(lua_State *, int, bool);
|
||||||
void client_set_maximized_horizontal(lua_State *, int, bool);
|
void client_set_maximized_horizontal(lua_State *, int, bool);
|
||||||
void client_set_maximized_vertical(lua_State *, int, bool);
|
void client_set_maximized_vertical(lua_State *, int, bool);
|
||||||
void client_set_minimized(lua_State *, int, bool);
|
void client_set_minimized(lua_State *, int, bool);
|
||||||
void client_set_border_width(lua_State *, int, int);
|
|
||||||
void client_set_urgent(lua_State *, int, bool);
|
void client_set_urgent(lua_State *, int, bool);
|
||||||
void client_set_pid(lua_State *, int, uint32_t);
|
void client_set_pid(lua_State *, int, uint32_t);
|
||||||
void client_set_role(lua_State *, int, char *);
|
void client_set_role(lua_State *, int, char *);
|
||||||
|
|
|
@ -751,6 +751,13 @@ wibox_attach(lua_State *L, int udx, screen_t *s)
|
||||||
screen_emit_signal(L, wibox->screen, "property::workarea", 0);
|
screen_emit_signal(L, wibox->screen, "property::workarea", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
luaA_wibox_need_update(lua_State *L)
|
||||||
|
{
|
||||||
|
wibox_need_update(luaA_checkudata(L, 1, &wibox_class));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/** Create a new wibox.
|
/** Create a new wibox.
|
||||||
* \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.
|
||||||
|
@ -782,6 +789,9 @@ luaA_wibox_new(lua_State *L)
|
||||||
if(!w->geometry.height)
|
if(!w->geometry.height)
|
||||||
w->geometry.height = 1;
|
w->geometry.height = 1;
|
||||||
|
|
||||||
|
lua_pushcfunction(L, luaA_wibox_need_update);
|
||||||
|
luaA_object_add_signal(L, -2, "property::border_width", -1);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -856,7 +866,6 @@ luaA_wibox_geometry(lua_State *L)
|
||||||
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)
|
||||||
LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, border_width, lua_pushnumber)
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
luaA_wibox_set_x(lua_State *L, wibox_t *wibox)
|
luaA_wibox_set_x(lua_State *L, wibox_t *wibox)
|
||||||
|
@ -1175,29 +1184,6 @@ luaA_wibox_get_widgets(lua_State *L, wibox_t *wibox)
|
||||||
return luaA_object_push_item(L, 1, wibox->widgets_table);
|
return luaA_object_push_item(L, 1, wibox->widgets_table);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set the wibox border width.
|
|
||||||
* \param L The Lua VM state.
|
|
||||||
* \param wibox The wibox object.
|
|
||||||
* \return The number of elements pushed on stack.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
luaA_wibox_set_border_width(lua_State *L, wibox_t *wibox)
|
|
||||||
{
|
|
||||||
wibox_t *w = luaA_checkudata(L, -3, &wibox_class);
|
|
||||||
int32_t border_width = luaL_checknumber(L, -1);
|
|
||||||
if(border_width != w->border_width && border_width >= 0)
|
|
||||||
{
|
|
||||||
if (w->window != XCB_NONE)
|
|
||||||
xcb_configure_window(globalconf.connection, w->window, XCB_CONFIG_WINDOW_BORDER_WIDTH,
|
|
||||||
(uint32_t[]) { border_width });
|
|
||||||
w->border_width = border_width;
|
|
||||||
/* Need update if transparent background */
|
|
||||||
wibox_need_update(w);
|
|
||||||
luaA_object_emit_signal(L, -3, "property::border_width", 0);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
luaA_wibox_set_shape_bounding(lua_State *L, wibox_t *wibox)
|
luaA_wibox_set_shape_bounding(lua_State *L, wibox_t *wibox)
|
||||||
{
|
{
|
||||||
|
@ -1264,10 +1250,6 @@ wibox_class_setup(lua_State *L)
|
||||||
(lua_class_propfunc_t) luaA_wibox_set_visible,
|
(lua_class_propfunc_t) luaA_wibox_set_visible,
|
||||||
(lua_class_propfunc_t) luaA_wibox_get_visible,
|
(lua_class_propfunc_t) luaA_wibox_get_visible,
|
||||||
(lua_class_propfunc_t) luaA_wibox_set_visible);
|
(lua_class_propfunc_t) luaA_wibox_set_visible);
|
||||||
luaA_class_add_property(&wibox_class, A_TK_BORDER_WIDTH,
|
|
||||||
(lua_class_propfunc_t) luaA_wibox_set_border_width,
|
|
||||||
(lua_class_propfunc_t) luaA_wibox_get_border_width,
|
|
||||||
(lua_class_propfunc_t) luaA_wibox_set_border_width);
|
|
||||||
luaA_class_add_property(&wibox_class, A_TK_ORIENTATION,
|
luaA_class_add_property(&wibox_class, A_TK_ORIENTATION,
|
||||||
(lua_class_propfunc_t) luaA_wibox_set_orientation,
|
(lua_class_propfunc_t) luaA_wibox_set_orientation,
|
||||||
(lua_class_propfunc_t) luaA_wibox_get_orientation,
|
(lua_class_propfunc_t) luaA_wibox_get_orientation,
|
||||||
|
|
|
@ -53,8 +53,6 @@ struct wibox_t
|
||||||
xcb_gcontext_t gc;
|
xcb_gcontext_t gc;
|
||||||
/** The window geometry. */
|
/** The window geometry. */
|
||||||
area_t geometry;
|
area_t geometry;
|
||||||
/** The window border width */
|
|
||||||
uint16_t border_width;
|
|
||||||
/** Draw context */
|
/** Draw context */
|
||||||
draw_context_t ctx;
|
draw_context_t ctx;
|
||||||
/** Orientation */
|
/** Orientation */
|
||||||
|
|
|
@ -148,8 +148,39 @@ luaA_window_set_border_color(lua_State *L, window_t *window)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Set a window border width.
|
||||||
|
* \param L The Lua VM state.
|
||||||
|
* \param idx The window index.
|
||||||
|
* \param width The border width.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
window_set_border_width(lua_State *L, int idx, int width)
|
||||||
|
{
|
||||||
|
window_t *window = luaA_checkudata(L, idx, &window_class);
|
||||||
|
|
||||||
|
if(width == window->border_width || width < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(window->window)
|
||||||
|
xcb_configure_window(globalconf.connection, window->window,
|
||||||
|
XCB_CONFIG_WINDOW_BORDER_WIDTH,
|
||||||
|
(uint32_t[]) { width });
|
||||||
|
|
||||||
|
window->border_width = width;
|
||||||
|
|
||||||
|
luaA_object_emit_signal(L, idx, "property::border_width", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
luaA_window_set_border_width(lua_State *L, window_t *c)
|
||||||
|
{
|
||||||
|
window_set_border_width(L, -3, luaL_checknumber(L, -1));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
LUA_OBJECT_EXPORT_PROPERTY(window, window_t, window, lua_pushnumber)
|
LUA_OBJECT_EXPORT_PROPERTY(window, window_t, window, lua_pushnumber)
|
||||||
LUA_OBJECT_EXPORT_PROPERTY(window, window_t, border_color, luaA_pushxcolor)
|
LUA_OBJECT_EXPORT_PROPERTY(window, window_t, border_color, luaA_pushxcolor)
|
||||||
|
LUA_OBJECT_EXPORT_PROPERTY(window, window_t, border_width, lua_pushnumber)
|
||||||
|
|
||||||
void
|
void
|
||||||
window_class_setup(lua_State *L)
|
window_class_setup(lua_State *L)
|
||||||
|
@ -183,6 +214,10 @@ window_class_setup(lua_State *L)
|
||||||
(lua_class_propfunc_t) luaA_window_set_border_color,
|
(lua_class_propfunc_t) luaA_window_set_border_color,
|
||||||
(lua_class_propfunc_t) luaA_window_get_border_color,
|
(lua_class_propfunc_t) luaA_window_get_border_color,
|
||||||
(lua_class_propfunc_t) luaA_window_set_border_color);
|
(lua_class_propfunc_t) luaA_window_set_border_color);
|
||||||
|
luaA_class_add_property(&window_class, A_TK_BORDER_WIDTH,
|
||||||
|
(lua_class_propfunc_t) luaA_window_set_border_width,
|
||||||
|
(lua_class_propfunc_t) luaA_window_get_border_width,
|
||||||
|
(lua_class_propfunc_t) luaA_window_set_border_width);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
|
|
|
@ -39,7 +39,9 @@
|
||||||
/** Button bindings */ \
|
/** Button bindings */ \
|
||||||
button_array_t buttons; \
|
button_array_t buttons; \
|
||||||
/** Border color */ \
|
/** Border color */ \
|
||||||
xcolor_t border_color;
|
xcolor_t border_color; \
|
||||||
|
/** Border width */ \
|
||||||
|
uint16_t border_width;
|
||||||
|
|
||||||
/** Window structure */
|
/** Window structure */
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -52,6 +54,7 @@ lua_class_t window_class;
|
||||||
void window_class_setup(lua_State *);
|
void window_class_setup(lua_State *);
|
||||||
|
|
||||||
void window_set_opacity(lua_State *, int, double);
|
void window_set_opacity(lua_State *, int, double);
|
||||||
|
void window_set_border_width(lua_State *, int, int);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// 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
|
||||||
|
|
Loading…
Reference in New Issue