diff options
author | Dave Davenport <qball@gmpclient.org> | 2016-03-01 18:33:26 +0100 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2016-03-01 18:33:26 +0100 |
commit | 8c950a984cabd812c674f3eafd403cb4e0bdc406 (patch) | |
tree | af952c8c1b619c99ec278236d57616b6361ff60c /source | |
parent | 167e9d30ceb50242b0781fb5400ebb4aaf50c81d (diff) |
Small cleanup
Diffstat (limited to 'source')
-rw-r--r-- | source/rofi.c | 22 | ||||
-rw-r--r-- | source/view.c | 1 | ||||
-rw-r--r-- | source/x11-helper.c | 28 |
3 files changed, 29 insertions, 22 deletions
diff --git a/source/rofi.c b/source/rofi.c index 439df164..b641b292 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -65,14 +65,6 @@ // Pidfile. char *pidfile = NULL; const char *cache_dir = NULL; -struct _xcb_stuff xcb_int = { - .connection = NULL, - .screen = NULL, - .screen_nbr = -1, - .sndisplay = NULL, - .sncontext = NULL, -}; -xcb_stuff *xcb = &xcb_int; struct xkb_stuff xkb = { NULL }; char *config_path = NULL; // Array of modi. @@ -315,19 +307,7 @@ static void cleanup () main_loop = NULL; } // Cleanup - if ( xcb->connection != NULL ) { - if ( xcb->sncontext != NULL ) { - sn_launchee_context_unref ( xcb->sncontext ); - xcb->sncontext = NULL; - } - if ( xcb->sndisplay != NULL ) { - sn_display_unref ( xcb->sndisplay ); - xcb->sndisplay = NULL; - } - xcb_disconnect ( xcb->connection ); - xcb->connection = NULL; - } - + xcb_stuff_wipe ( xcb ); // Cleaning up memory allocated by the Xresources file. config_xresource_free (); for ( unsigned int i = 0; i < num_modi; i++ ) { diff --git a/source/view.c b/source/view.c index 35ca5b95..85ff6f18 100644 --- a/source/view.c +++ b/source/view.c @@ -1822,4 +1822,3 @@ Mode * rofi_view_get_mode ( RofiViewState *state ) return state->sw; } - diff --git a/source/x11-helper.c b/source/x11-helper.c index 0de0b845..c2d7b9e5 100644 --- a/source/x11-helper.c +++ b/source/x11-helper.c @@ -51,6 +51,16 @@ #include "x11-helper.h" #include "xkb-internal.h" + +struct _xcb_stuff xcb_int = { + .connection = NULL, + .screen = NULL, + .screen_nbr = -1, + .sndisplay = NULL, + .sncontext = NULL, +}; +xcb_stuff *xcb = &xcb_int; + enum { X11MOD_SHIFT, @@ -672,3 +682,21 @@ xcb_window_t xcb_stuff_get_root_window ( xcb_stuff *xcb ) { return xcb->screen->root; } + +void xcb_stuff_wipe ( xcb_stuff *xcb ) +{ + if ( xcb->connection != NULL ) { + if ( xcb->sncontext != NULL ) { + sn_launchee_context_unref ( xcb->sncontext ); + xcb->sncontext = NULL; + } + if ( xcb->sndisplay != NULL ) { + sn_display_unref ( xcb->sndisplay ); + xcb->sndisplay = NULL; + } + xcb_disconnect ( xcb->connection ); + xcb->connection = NULL; + xcb->screen = NULL; + xcb->screen_nbr = 0; + } +} |