summaryrefslogtreecommitdiffstats
path: root/source/dialogs
diff options
context:
space:
mode:
authorDimitar Yordanov <domidimi@gmail.com>2016-04-28 22:45:01 +0200
committerDimitar Yordanov <domidimi@gmail.com>2016-04-28 22:45:01 +0200
commit74d1b234d909846ce36fbf387944ca910ad940f0 (patch)
tree787e489d79ce341e5f9498a6c0cc5a3ff27de47f /source/dialogs
parent7861b7369095ea14739a6819711f403a2cca62b5 (diff)
When switching windows also switch the desktop
If the window we switch to is not on the same desktop, first switch to the desktop.
Diffstat (limited to 'source/dialogs')
-rw-r--r--source/dialogs/window.c42
1 files changed, 40 insertions, 2 deletions
diff --git a/source/dialogs/window.c b/source/dialogs/window.c
index d1cedb3d..13a43dee 100644
--- a/source/dialogs/window.c
+++ b/source/dialogs/window.c
@@ -37,6 +37,7 @@
#include <xcb/xcb.h>
#include <xcb/xcb_ewmh.h>
#include <xcb/xcb_icccm.h>
+#include <xcb/xcb_atom.h>
#include <glib.h>
@@ -543,8 +544,45 @@ static ModeMode window_mode_result ( Mode *sw, int mretv, G_GNUC_UNUSED char **i
if ( rmpd->config_i3_mode ) {
// Hack for i3.
i3_support_focus_window ( rmpd->ids->array[selected_line] );
- }
- else{
+ } else {
+ // Get the current desktop.
+ unsigned int current_desktop = 0;
+ xcb_get_property_cookie_t c = xcb_ewmh_get_current_desktop ( &xcb->ewmh, xcb->screen_nbr );
+ if ( !xcb_ewmh_get_current_desktop_reply ( &xcb->ewmh, c, &current_desktop, NULL ) ) {
+ current_desktop = 0;
+ }
+
+ // Get the desktop of the client to switch to
+ uint32_t wmdesktop = 0;
+ xcb_get_property_cookie_t cookie;
+ xcb_get_property_reply_t *r;
+
+ cookie = xcb_get_property (xcb->connection,
+ 0,
+ rmpd->ids->array[selected_line],
+ xcb->ewmh._NET_WM_DESKTOP,
+ XCB_ATOM_CARDINAL,
+ 0,
+ 1);
+ r = xcb_get_property_reply ( xcb->connection, cookie, NULL );
+ if ( r && r->type == XCB_ATOM_CARDINAL ) {
+ wmdesktop = *( (uint32_t *) xcb_get_property_value ( r ) );
+ }
+ if ( r && r->type != XCB_ATOM_CARDINAL) {
+ // Assume the client is on all desktops.
+ wmdesktop = current_desktop;
+ }
+ free ( r );
+
+ // If we have to switch the desktop, do
+ if ( wmdesktop != current_desktop ) {
+ xcb_ewmh_request_change_current_desktop(&xcb->ewmh,
+ xcb->screen_nbr,
+ wmdesktop,
+ XCB_CURRENT_TIME);
+ }
+
+ // Activate the window
xcb_ewmh_request_change_active_window ( &xcb->ewmh, xcb->screen_nbr, rmpd->ids->array[selected_line],
XCB_EWMH_CLIENT_SOURCE_TYPE_OTHER,
XCB_CURRENT_TIME, XCB_WINDOW_NONE );