mirror of
https://github.com/davatorium/rofi.git
synced 2025-04-14 17:43:01 -04:00
Merge pull request #393 from domidimi/master
When switching windows also switch the desktop
This commit is contained in:
commit
91e68f4ded
1 changed files with 40 additions and 2 deletions
|
@ -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, ¤t_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 );
|
||||
|
|
Loading…
Add table
Reference in a new issue