Stacking update: Use a GLib idle source

Ever since the switch from libev to GLib, we have a hack in place. We
use g_main_context_set_poll_func() to replace g_poll() (which is just a
wrapper around poll()) with our own function that does lots of house
keeping. This commit is part of getting rid of this hack: It moves one
step that is done in this poll-replacement into a GLib idle source.

Namely, this commit makes us use an idle source instead of a boolean to
track whether we have to update the stacking order.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2019-07-25 17:56:34 +02:00
parent 862598857f
commit ebd95098a5
4 changed files with 14 additions and 15 deletions

View file

@ -41,7 +41,6 @@ awesome_refresh(void)
{
luaA_emit_refresh();
client_refresh();
stack_refresh();
client_destroy_later();
return xcb_flush(globalconf.connection);
}

View file

@ -190,6 +190,8 @@ typedef struct
xcb_colormap_t default_cmap;
/** Do we have to reban clients? */
guint banning_update_id;
/** Do we have to update the stacking order? */
guint stacking_update_id;
/** Tag list */
tag_array_t tags;
/** List of registered xproperties */

25
stack.c
View file

@ -61,14 +61,6 @@ stack_client_append(client_t *c)
stack_windows();
}
static bool need_stack_refresh = false;
void
stack_windows(void)
{
need_stack_refresh = true;
}
/** Stack a window above another window, without causing errors.
* \param w The window.
* \param previous The window which should be below this window.
@ -159,11 +151,11 @@ client_layer_translator(client_t *c)
* \todo It might be worth stopping to restack everyone and only stack `c'
* relatively to the first matching in the list.
*/
void
stack_refresh()
static gboolean
stack_refresh(gpointer unused)
{
if(!need_stack_refresh)
return;
assert(globalconf.stacking_update_id != 0);
globalconf.stacking_update_id = 0;
xcb_window_t next = XCB_NONE;
@ -195,7 +187,14 @@ stack_refresh()
next = (*drawin)->window;
}
need_stack_refresh = false;
return G_SOURCE_REMOVE;
}
void
stack_windows(void)
{
if (globalconf.stacking_update_id == 0)
globalconf.stacking_update_id = g_idle_add(stack_refresh, NULL);
}

View file

@ -28,7 +28,6 @@ void stack_client_remove(client_t *);
void stack_client_push(client_t *);
void stack_client_append(client_t *);
void stack_windows(void);
void stack_refresh(void);
#endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80