drawin: Added support for the desktop layer.

This commit is contained in:
Aproxia-dev 2022-12-10 22:17:40 +01:00
parent 1239cdf4bc
commit 89db74f4f7
4 changed files with 53 additions and 5 deletions

View File

@ -265,6 +265,7 @@ local function setup_signals(w)
clone_signal("property::cursor") clone_signal("property::cursor")
clone_signal("property::height") clone_signal("property::height")
clone_signal("property::ontop") clone_signal("property::ontop")
clone_signal("property::desktop")
clone_signal("property::opacity") clone_signal("property::opacity")
clone_signal("property::struts") clone_signal("property::struts")
clone_signal("property::visible") clone_signal("property::visible")

View File

@ -504,6 +504,7 @@ luaA_drawin_geometry(lua_State *L)
LUA_OBJECT_EXPORT_PROPERTY(drawin, drawin_t, ontop, lua_pushboolean) LUA_OBJECT_EXPORT_PROPERTY(drawin, drawin_t, ontop, lua_pushboolean)
LUA_OBJECT_EXPORT_PROPERTY(drawin, drawin_t, desktop, lua_pushboolean)
LUA_OBJECT_EXPORT_PROPERTY(drawin, drawin_t, cursor, lua_pushstring) LUA_OBJECT_EXPORT_PROPERTY(drawin, drawin_t, cursor, lua_pushstring)
LUA_OBJECT_EXPORT_PROPERTY(drawin, drawin_t, visible, lua_pushboolean) LUA_OBJECT_EXPORT_PROPERTY(drawin, drawin_t, visible, lua_pushboolean)
@ -584,16 +585,48 @@ luaA_drawin_get_height(lua_State *L, drawin_t *drawin)
* \param drawin The drawin object. * \param drawin The drawin object.
* \return The number of elements pushed on stack. * \return The number of elements pushed on stack.
*/ */
static int void
luaA_drawin_set_ontop(lua_State *L, drawin_t *drawin) drawin_set_ontop(lua_State *L, drawin_t *drawin, bool b)
{ {
bool b = luaA_checkboolean(L, -1);
if(b != drawin->ontop) if(b != drawin->ontop)
{ {
if(b)
drawin_set_desktop(L, drawin, false);
drawin->ontop = b; drawin->ontop = b;
stack_windows(); stack_windows();
luaA_object_emit_signal(L, -3, "property::ontop", 0); luaA_object_emit_signal(L, -3, "property::ontop", 0);
} }
}
/** Set the drawin on desktop status.
* \param L The Lua VM state.
* \param drawin The drawin object.
* \return The number of elements pushed on stack.
*/
void
drawin_set_desktop(lua_State *L, drawin_t *drawin, bool b)
{
if(b != drawin->desktop)
{
if(b)
drawin_set_ontop(L, drawin, false);
drawin->desktop = b;
stack_windows();
luaA_object_emit_signal(L, -3, "property::desktop", 0);
}
}
static int
luaA_drawin_set_ontop(lua_State *L, drawin_t *drawin)
{
drawin_set_ontop(L, drawin, luaA_checkboolean(L, -1));
return 0;
}
static int
luaA_drawin_set_desktop(lua_State *L, drawin_t *drawin)
{
drawin_set_desktop(L, drawin, luaA_checkboolean(L, -1));
return 0; return 0;
} }
@ -797,6 +830,10 @@ drawin_class_setup(lua_State *L)
(lua_class_propfunc_t) luaA_drawin_set_ontop, (lua_class_propfunc_t) luaA_drawin_set_ontop,
(lua_class_propfunc_t) luaA_drawin_get_ontop, (lua_class_propfunc_t) luaA_drawin_get_ontop,
(lua_class_propfunc_t) luaA_drawin_set_ontop); (lua_class_propfunc_t) luaA_drawin_set_ontop);
luaA_class_add_property(&drawin_class, "desktop",
(lua_class_propfunc_t) luaA_drawin_set_desktop,
(lua_class_propfunc_t) luaA_drawin_get_desktop,
(lua_class_propfunc_t) luaA_drawin_set_desktop);
luaA_class_add_property(&drawin_class, "cursor", luaA_class_add_property(&drawin_class, "cursor",
(lua_class_propfunc_t) luaA_drawin_set_cursor, (lua_class_propfunc_t) luaA_drawin_set_cursor,
(lua_class_propfunc_t) luaA_drawin_get_cursor, (lua_class_propfunc_t) luaA_drawin_get_cursor,

View File

@ -32,6 +32,8 @@ struct drawin_t
WINDOW_OBJECT_HEADER WINDOW_OBJECT_HEADER
/** Ontop */ /** Ontop */
bool ontop; bool ontop;
/** Desktop */
bool desktop;
/** Visible */ /** Visible */
bool visible; bool visible;
/** Cursor */ /** Cursor */
@ -49,7 +51,8 @@ ARRAY_FUNCS(drawin_t *, drawin, DO_NOTHING)
drawin_t * drawin_getbywin(xcb_window_t); drawin_t * drawin_getbywin(xcb_window_t);
void drawin_refresh_pixmap_partial(drawin_t *, int16_t, int16_t, uint16_t, uint16_t); void drawin_refresh_pixmap_partial(drawin_t *, int16_t, int16_t, uint16_t, uint16_t);
void luaA_drawin_systray_kickout(lua_State *); void luaA_drawin_systray_kickout(lua_State *);
void drawin_set_ontop(lua_State *, drawin_t *, bool);
void drawin_set_desktop(lua_State *, drawin_t *, bool);
void drawin_class_setup(lua_State *); void drawin_class_setup(lua_State *);
extern lua_class_t drawin_class; extern lua_class_t drawin_class;

View File

@ -167,6 +167,13 @@ stack_refresh()
xcb_window_t next = XCB_NONE; xcb_window_t next = XCB_NONE;
foreach(drawin, globalconf.drawins)
if ((*drawin)->desktop)
{
stack_window_above((*drawin)->window, next);
next = (*drawin)->window;
}
/* stack desktop windows */ /* stack desktop windows */
for(window_layer_t layer = WINDOW_LAYER_DESKTOP; layer < WINDOW_LAYER_BELOW; layer++) for(window_layer_t layer = WINDOW_LAYER_DESKTOP; layer < WINDOW_LAYER_BELOW; layer++)
foreach(node, globalconf.stack) foreach(node, globalconf.stack)
@ -175,7 +182,7 @@ stack_refresh()
/* first stack not ontop drawin window */ /* first stack not ontop drawin window */
foreach(drawin, globalconf.drawins) foreach(drawin, globalconf.drawins)
if(!(*drawin)->ontop) if(!(*drawin)->ontop && !(*drawin)->desktop)
{ {
stack_window_above((*drawin)->window, next); stack_window_above((*drawin)->window, next);
next = (*drawin)->window; next = (*drawin)->window;