diff options
author | Dave Davenport <qball@gmpclient.org> | 2017-02-11 19:51:02 +0100 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2017-02-11 19:51:02 +0100 |
commit | 97be4e9c7298a86a747115b7288cceb3c0f6a9e7 (patch) | |
tree | ebfb33ae6420c404cd2d0dba8c7945acfcedb115 | |
parent | a579c86c1fbb9428f31199a04fc4ced8e554ab3f (diff) |
Use xcb_ewmh_get_supporting_wm to get window to get wm name on
-rw-r--r-- | source/x11-helper.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/source/x11-helper.c b/source/x11-helper.c index fff0e23d..be06aca0 100644 --- a/source/x11-helper.c +++ b/source/x11-helper.c @@ -926,17 +926,24 @@ void x11_disable_decoration ( xcb_window_t window ) void x11_helper_discover_window_manager ( void ) { - xcb_ewmh_get_utf8_strings_reply_t wtitle; - xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_name_unchecked(&(xcb->ewmh), xcb_stuff_get_root_window ( xcb ) ); - if ( xcb_ewmh_get_wm_name_reply(&(xcb->ewmh), cookie, &wtitle, (void *)0)) - { - if ( wtitle.strings_len > 0 ){ - 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; + 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 ( xcb ) ); + + 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_log ( LOG_DOMAIN, G_LOG_LEVEL_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; + } } + xcb_ewmh_get_utf8_strings_reply_wipe(&wtitle); } - xcb_ewmh_get_utf8_strings_reply_wipe(&wtitle); } } |