diff options
author | Quentin Glidic <sardemff7+git@sardemff7.net> | 2017-06-01 15:08:20 +0200 |
---|---|---|
committer | Quentin Glidic <sardemff7+git@sardemff7.net> | 2017-06-01 15:08:20 +0200 |
commit | e576bc441cccd1958166b9bc121363cbfe2f5e1b (patch) | |
tree | b030ac5deaddf0d8adc7b34b2e0702f3ab4c5a41 | |
parent | 48a80e3f82dc69e291060d1b1b338d60c6e4f3a6 (diff) |
xcb: Hide WM discover function
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
-rw-r--r-- | include/xcb.h | 4 | ||||
-rw-r--r-- | source/xcb.c | 54 |
2 files changed, 27 insertions, 31 deletions
diff --git a/include/xcb.h b/include/xcb.h index 87f144e3..1223b440 100644 --- a/include/xcb.h +++ b/include/xcb.h @@ -185,8 +185,4 @@ typedef enum */ extern WindowManager current_window_manager; -/** - * discover the window manager. - */ -void x11_helper_discover_window_manager ( void ); #endif diff --git a/source/xcb.c b/source/xcb.c index f2f41e3c..13dbdd6a 100644 --- a/source/xcb.c +++ b/source/xcb.c @@ -799,6 +799,33 @@ static void x11_create_frequently_used_atoms ( void ) } } +static void x11_helper_discover_window_manager ( void ) +{ + xcb_window_t wm_win = 0; + xcb_get_property_cookie_t cc = xcb_ewmh_get_supporting_wm_check_unchecked ( &xcb->ewmh, + xcb_stuff_get_root_window () ); + + if ( xcb_ewmh_get_supporting_wm_check_reply ( &xcb->ewmh, cc, &wm_win, NULL ) ) { + xcb_ewmh_get_utf8_strings_reply_t wtitle; + xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_name_unchecked ( &( xcb->ewmh ), wm_win ); + if ( xcb_ewmh_get_wm_name_reply ( &( xcb->ewmh ), cookie, &wtitle, (void *) 0 ) ) { + if ( wtitle.strings_len > 0 ) { + g_debug ( "Found window manager: %s", wtitle.strings ); + if ( g_strcmp0 ( wtitle.strings, "i3" ) == 0 ) { + current_window_manager = WM_I3; + } + else if ( g_strcmp0 ( wtitle.strings, "awesome" ) == 0 ) { + current_window_manager = WM_AWESOME; + } + else if ( g_strcmp0 ( wtitle.strings, "Openbox" ) == 0 ) { + current_window_manager = WM_OPENBOX; + } + } + xcb_ewmh_get_utf8_strings_reply_wipe ( &wtitle ); + } + } +} + gboolean display_setup ( GMainLoop *main_loop, NkBindings *bindings ) { // Get DISPLAY, first env, then argument. @@ -1089,30 +1116,3 @@ void x11_disable_decoration ( xcb_window_t window ) xcb_atom_t ha = netatoms[_MOTIF_WM_HINTS]; xcb_change_property ( xcb->connection, XCB_PROP_MODE_REPLACE, window, ha, ha, 32, 5, &hints ); } - -void x11_helper_discover_window_manager ( void ) -{ - xcb_window_t wm_win = 0; - xcb_get_property_cookie_t cc = xcb_ewmh_get_supporting_wm_check_unchecked ( &xcb->ewmh, - xcb_stuff_get_root_window () ); - - if ( xcb_ewmh_get_supporting_wm_check_reply ( &xcb->ewmh, cc, &wm_win, NULL ) ) { - xcb_ewmh_get_utf8_strings_reply_t wtitle; - xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_name_unchecked ( &( xcb->ewmh ), wm_win ); - if ( xcb_ewmh_get_wm_name_reply ( &( xcb->ewmh ), cookie, &wtitle, (void *) 0 ) ) { - if ( wtitle.strings_len > 0 ) { - g_debug ( "Found window manager: %s", wtitle.strings ); - if ( g_strcmp0 ( wtitle.strings, "i3" ) == 0 ) { - current_window_manager = WM_I3; - } - else if ( g_strcmp0 ( wtitle.strings, "awesome" ) == 0 ) { - current_window_manager = WM_AWESOME; - } - else if ( g_strcmp0 ( wtitle.strings, "Openbox" ) == 0 ) { - current_window_manager = WM_OPENBOX; - } - } - xcb_ewmh_get_utf8_strings_reply_wipe ( &wtitle ); - } - } -} |