From 97be4e9c7298a86a747115b7288cceb3c0f6a9e7 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sat, 11 Feb 2017 19:51:02 +0100 Subject: [PATCH] Use xcb_ewmh_get_supporting_wm to get window to get wm name on --- source/x11-helper.c | 27 +++++++++++++++++---------- 1 file 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); } }