From 4792a16593374bc3036ea2bccaf9143cc90af44f Mon Sep 17 00:00:00 2001 From: Quentin Glidic Date: Thu, 1 Jun 2017 12:47:52 +0200 Subject: [PATCH] xcb: Hide release details Signed-off-by: Quentin Glidic --- include/xcb.h | 31 ++----------------------------- source/rofi.c | 4 +--- source/view.c | 4 +--- source/xcb.c | 16 ++++++++++++---- 4 files changed, 16 insertions(+), 39 deletions(-) diff --git a/include/xcb.h b/include/xcb.h index 26163ca6..aaa6981a 100644 --- a/include/xcb.h +++ b/include/xcb.h @@ -156,35 +156,6 @@ typedef struct _workarea */ int monitor_active ( workarea *mon ); -/** - * Release keyboard grab on root window. - */ -void release_keyboard ( void ); -/** - * Release pointer grab on root window. - */ -void release_pointer ( void ); - -/** - * @param w xcb_window_t we want to grab keyboard on. - * @param iters Number of retries. - * - * Grab keyboard. - * - * @return 1 when keyboard is grabbed, 0 not. - */ -int take_keyboard ( xcb_window_t w, int iters ); - -/** - * @param w xcb_window_t we want to grab mouse on. - * @param iters Number of retries. - * - * Grab mouse. - * - * @return 1 when mouse is grabbed, 0 not. - */ -int take_pointer ( xcb_window_t w, int iters ); - /** * @param main_loop The GMainLoop * @@ -212,6 +183,8 @@ extern xcb_colormap_t map; gboolean x11_late_setup ( void ); +void x11_early_cleanup ( void ); + /** * Gets a surface containing the background image of the desktop. * diff --git a/source/rofi.c b/source/rofi.c index 44fb955a..3390a44b 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -146,9 +146,7 @@ static void teardown ( int pfd ) // Cleanup font setup. textbox_cleanup ( ); - // Release the window. - release_keyboard ( ); - release_pointer ( ); + x11_early_cleanup (); // Cleanup view rofi_view_cleanup (); diff --git a/source/view.c b/source/view.c index dd536639..923cd714 100644 --- a/source/view.c +++ b/source/view.c @@ -1722,9 +1722,7 @@ void rofi_view_hide ( void ) { if ( CacheState.main_window != XCB_WINDOW_NONE ) { xcb_unmap_window ( xcb->connection, CacheState.main_window ); - release_keyboard ( ); - release_pointer ( ); - xcb_flush ( xcb->connection ); + x11_early_cleanup (); } } diff --git a/source/xcb.c b/source/xcb.c index fd5e202e..14ccfe42 100644 --- a/source/xcb.c +++ b/source/xcb.c @@ -628,7 +628,7 @@ static gboolean main_loop_x11_event_handler ( xcb_generic_event_t *ev, G_GNUC_UN return G_SOURCE_CONTINUE; } -int take_pointer ( xcb_window_t w, int iters ) +static int take_pointer ( xcb_window_t w, int iters ) { int i = 0; while ( TRUE ) { @@ -653,7 +653,8 @@ int take_pointer ( xcb_window_t w, int iters ) } return 0; } -int take_keyboard ( xcb_window_t w, int iters ) + +static int take_keyboard ( xcb_window_t w, int iters ) { int i = 0; while ( TRUE ) { @@ -680,11 +681,11 @@ int take_keyboard ( xcb_window_t w, int iters ) return 0; } -void release_keyboard ( void ) +static void release_keyboard ( void ) { xcb_ungrab_keyboard ( xcb->connection, XCB_CURRENT_TIME ); } -void release_pointer ( void ) +static void release_pointer ( void ) { xcb_ungrab_pointer ( xcb->connection, XCB_CURRENT_TIME ); } @@ -960,6 +961,13 @@ xcb_window_t xcb_stuff_get_root_window ( void ) return xcb->screen->root; } +void x11_early_cleanup ( void ) +{ + release_keyboard ( ); + release_pointer ( ); + xcb_flush ( xcb->connection ); +} + void xcb_stuff_wipe ( void ) { if ( xcb->connection == NULL ) {