Merge pull request #2669 from psychon/more_idle

Move more stuff from awesome_refresh to g_idle_add
This commit is contained in:
Daniel Hahler 2019-02-21 04:59:27 +01:00 committed by GitHub
commit 4c2d0fd4dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 43 additions and 21 deletions

View File

@ -459,7 +459,7 @@ event_handle_configurenotify(xcb_configure_notify_event_t *ev)
xcb_screen_t *screen = globalconf.screen; xcb_screen_t *screen = globalconf.screen;
if(ev->window == screen->root) if(ev->window == screen->root)
globalconf.screen_need_refresh = true; screen_schedule_refresh();
/* Copy what XRRUpdateConfiguration() would do: Update the configuration */ /* Copy what XRRUpdateConfiguration() would do: Update the configuration */
if(ev->window == screen->root) { if(ev->window == screen->root) {
@ -881,7 +881,7 @@ event_handle_randr_screen_change_notify(xcb_randr_screen_change_notify_event_t *
globalconf.screen->height_in_millimeters = ev->mheight;; globalconf.screen->height_in_millimeters = ev->mheight;;
} }
globalconf.screen_need_refresh = true; screen_schedule_refresh();
} }
/** XRandR event handler for RRNotify subtype XRROutputChangeNotifyEvent /** XRandR event handler for RRNotify subtype XRROutputChangeNotifyEvent

View File

@ -39,17 +39,9 @@ void client_refresh(void);
void client_focus_refresh(void); void client_focus_refresh(void);
void client_destroy_later(void); void client_destroy_later(void);
/* objects/screen.c */
void screen_refresh(void);
/* xkb.c */
void xkb_refresh(void);
static inline int static inline int
awesome_refresh(void) awesome_refresh(void)
{ {
xkb_refresh();
screen_refresh();
luaA_emit_refresh(); luaA_emit_refresh();
drawin_refresh(); drawin_refresh();
client_refresh(); client_refresh();

View File

@ -101,7 +101,7 @@ typedef struct
/** Do we have RandR 1.5 or newer? */ /** Do we have RandR 1.5 or newer? */
bool have_randr_15; bool have_randr_15;
/** Do we have a RandR screen update pending? */ /** Do we have a RandR screen update pending? */
bool screen_need_refresh; bool screen_refresh_pending;
/** Check for XTest extension */ /** Check for XTest extension */
bool have_xtest; bool have_xtest;
/** Check for SHAPE extension */ /** Check for SHAPE extension */
@ -189,6 +189,8 @@ typedef struct
struct xkb_context *xkb_ctx; struct xkb_context *xkb_ctx;
/* xkb state of dead keys on keyboard */ /* xkb state of dead keys on keyboard */
struct xkb_state *xkb_state; struct xkb_state *xkb_state;
/* Do we have a pending xkb update call? */
bool xkb_update_pending;
/* Do we have a pending reload? */ /* Do we have a pending reload? */
bool xkb_reload_keymap; bool xkb_reload_keymap;
/* Do we have a pending map change? */ /* Do we have a pending map change? */

View File

@ -661,12 +661,10 @@ screen_modified(screen_t *existing_screen, screen_t *other_screen)
} }
} }
void static gboolean
screen_refresh(void) screen_refresh(gpointer unused)
{ {
if(!globalconf.screen_need_refresh || !globalconf.have_randr_13) globalconf.screen_refresh_pending = false;
return;
globalconf.screen_need_refresh = false;
screen_array_t new_screens; screen_array_t new_screens;
screen_array_t removed_screens; screen_array_t removed_screens;
@ -740,6 +738,18 @@ screen_refresh(void)
if (list_changed) if (list_changed)
luaA_class_emit_signal(L, &screen_class, "list", 0); luaA_class_emit_signal(L, &screen_class, "list", 0);
return G_SOURCE_REMOVE;
}
void
screen_schedule_refresh(void)
{
if(globalconf.screen_refresh_pending || !globalconf.have_randr_13)
return;
globalconf.screen_refresh_pending = true;
g_idle_add_full(G_PRIORITY_LOW, screen_refresh, NULL, NULL);
} }
/** Return the squared distance of the given screen to the coordinates. /** Return the squared distance of the given screen to the coordinates.

View File

@ -56,6 +56,7 @@ void screen_client_moveto(client_t *, screen_t *, bool);
void screen_update_primary(void); void screen_update_primary(void);
void screen_update_workarea(screen_t *); void screen_update_workarea(screen_t *);
screen_t *screen_get_primary(void); screen_t *screen_get_primary(void);
void screen_schedule_refresh(void);
screen_t *luaA_checkscreen(lua_State *, int); screen_t *luaA_checkscreen(lua_State *, int);

26
xkb.c
View File

@ -297,21 +297,33 @@ xkb_reload_keymap(void)
} }
} }
void static gboolean
xkb_refresh(void) xkb_refresh(gpointer unused)
{ {
lua_State *L = globalconf_get_lua_State(); lua_State *L = globalconf_get_lua_State();
globalconf.xkb_update_pending = false;
if (globalconf.xkb_reload_keymap) if (globalconf.xkb_reload_keymap)
xkb_reload_keymap(); xkb_reload_keymap();
if (globalconf.xkb_map_changed) if (globalconf.xkb_map_changed)
signal_object_emit(L, &global_signals, "xkb::map_changed", 0); signal_object_emit(L, &global_signals, "xkb::map_changed", 0);
if (globalconf.xkb_group_changed) if (globalconf.xkb_group_changed)
signal_object_emit(L, &global_signals, "xkb::group_changed", 0); signal_object_emit(L, &global_signals, "xkb::group_changed", 0);
globalconf.xkb_reload_keymap = false; globalconf.xkb_reload_keymap = false;
globalconf.xkb_map_changed = false; globalconf.xkb_map_changed = false;
globalconf.xkb_group_changed = false; globalconf.xkb_group_changed = false;
return G_SOURCE_REMOVE;
}
static void
xkb_schedule_refresh(void)
{
if (globalconf.xkb_update_pending)
return;
globalconf.xkb_update_pending = true;
g_idle_add_full(G_PRIORITY_LOW, xkb_refresh, NULL, NULL);
} }
/** The xkb notify event handler. /** The xkb notify event handler.
@ -335,12 +347,14 @@ event_handle_xkb_notify(xcb_generic_event_t* event)
if (new_keyboard_event->changed & XCB_XKB_NKN_DETAIL_KEYCODES) if (new_keyboard_event->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
globalconf.xkb_map_changed = true; globalconf.xkb_map_changed = true;
xkb_schedule_refresh();
break; break;
} }
case XCB_XKB_MAP_NOTIFY: case XCB_XKB_MAP_NOTIFY:
{ {
globalconf.xkb_reload_keymap = true; globalconf.xkb_reload_keymap = true;
globalconf.xkb_map_changed = true; globalconf.xkb_map_changed = true;
xkb_schedule_refresh();
break; break;
} }
case XCB_XKB_STATE_NOTIFY: case XCB_XKB_STATE_NOTIFY:
@ -356,7 +370,10 @@ event_handle_xkb_notify(xcb_generic_event_t* event)
state_notify_event->lockedGroup); state_notify_event->lockedGroup);
if (state_notify_event->changed & XCB_XKB_STATE_PART_GROUP_STATE) if (state_notify_event->changed & XCB_XKB_STATE_PART_GROUP_STATE)
{
globalconf.xkb_group_changed = true; globalconf.xkb_group_changed = true;
xkb_schedule_refresh();
}
break; break;
} }
@ -369,6 +386,7 @@ event_handle_xkb_notify(xcb_generic_event_t* event)
void void
xkb_init(void) xkb_init(void)
{ {
globalconf.xkb_update_pending = false;
globalconf.xkb_reload_keymap = false; globalconf.xkb_reload_keymap = false;
globalconf.xkb_map_changed = false; globalconf.xkb_map_changed = false;
globalconf.xkb_group_changed = false; globalconf.xkb_group_changed = false;

1
xkb.h
View File

@ -26,7 +26,6 @@
#include <lua.h> #include <lua.h>
void event_handle_xkb_notify(xcb_generic_event_t* event); void event_handle_xkb_notify(xcb_generic_event_t* event);
void xkb_refresh(void);
void xkb_init(void); void xkb_init(void);
void xkb_free(void); void xkb_free(void);