From 09ab44bf92218f818b4541b14d3cebf4221cbf3c Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Tue, 10 Nov 2015 23:52:52 +0100 Subject: [PATCH] Fix #264 fall back to age ordered list if stacked list does not work --- include/x11-helper.h | 1 + source/dialogs/drun.c | 4 ++-- source/dialogs/window.c | 15 ++++++++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/include/x11-helper.h b/include/x11-helper.h index 3c36328c..61b69532 100644 --- a/include/x11-helper.h +++ b/include/x11-helper.h @@ -34,6 +34,7 @@ int window_get_cardinal_prop ( Display *display, Window w, Atom atom, unsigned l X ( _NET_NUMBER_OF_DESKTOPS ), \ X ( _NET_CURRENT_DESKTOP ), \ X ( _NET_ACTIVE_WINDOW ), \ + X ( _NET_CLIENT_LIST ), \ X ( _NET_WM_NAME ), \ X ( _NET_WM_STATE ), \ X ( _NET_WM_STATE_SKIP_TASKBAR ), \ diff --git a/source/dialogs/drun.c b/source/dialogs/drun.c index 8530ccd9..95f073b4 100644 --- a/source/dialogs/drun.c +++ b/source/dialogs/drun.c @@ -161,8 +161,8 @@ static void get_apps_dir ( DRunModePrivateData *pd, const char *bp ) } else { ( pd->cmd_list )[( pd->cmd_list_length )] = g_markup_printf_escaped ( - "%s (%s)", - n, gn ? gn : "" ); + "%s (%s)", + n, gn ? gn : "" ); } g_free ( n ); g_free ( gn ); } diff --git a/source/dialogs/window.c b/source/dialogs/window.c index 6483552c..1a30bf11 100644 --- a/source/dialogs/window.c +++ b/source/dialogs/window.c @@ -379,7 +379,7 @@ static char ** _window_mode_get_data ( unsigned int *length, Switcher *sw, unsig Window root = RootWindow ( display, XScreenNumberOfScreen ( screen ) ); // find window list Atom type; - int nwins; + int nwins = 0; Window wins[100]; int count = 0; Window curr_win_id = 0; @@ -401,8 +401,17 @@ static char ** _window_mode_get_data ( unsigned int *length, Switcher *sw, unsig current_desktop = 0; } - if ( window_get_prop ( display, root, netatoms[_NET_CLIENT_LIST_STACKING], &type, &nwins, wins, 100 * sizeof ( Window ) ) - && type == XA_WINDOW ) { + unsigned int nw = 100 * sizeof ( Window ); + // First try Stacking order.. If this fails. + if ( !( window_get_prop ( display, root, netatoms[_NET_CLIENT_LIST_STACKING], &type, &nwins, wins, nw ) + && type == XA_WINDOW ) ) { + // Try to get order by age. + if ( !( window_get_prop ( display, root, netatoms[_NET_CLIENT_LIST], &type, &nwins, wins, nw ) + && type == XA_WINDOW ) ) { + nwins = 0; + } + } + if ( nwins > 0 ) { char pattern[50]; int i; unsigned int classfield = 0;