spicec-x11: Fix window management under KDE

There were 2 issues with window management under KDE
1) When an app does its own focus management like we do, kwin expects
   an explicit raise for the app to get to the top, so we did have focus,
   but would have other windows (partially) covering the client window
   -> do a raise after setting focus to ourselves
2) When switching from fullscreen <-> window, we unmap and remap our
   window, then set focus to ourselves. kwin thinks this means we're trying
   to steal the focus without the user asking for it. This patch makes us
   set the _NET_WM_USER_TIME property on our window, this helps kwin's
   focus stealing code to see that we are really not stealing the focus,
   just responding to a user event.
This commit is contained in:
Hans de Goede 2010-10-17 14:55:15 +02:00
parent 421ddb7422
commit d08b8120d6
2 changed files with 13 additions and 0 deletions

View File

@ -801,6 +801,10 @@ void RedWindow_p::win_proc(XEvent& event)
}
case KeyPress:
red_window->handle_key_press_event(*red_window, &event.xkey);
red_window->last_event_time = event.xkey.time;
XChangeProperty(x_display, red_window->_win, wm_user_time,
XA_CARDINAL, 32, PropModeReplace,
(unsigned char *)&event.xkey.time, 1);
break;
case KeyRelease: {
RedKey key = to_red_key_code(event.xkey.keycode);
@ -829,6 +833,10 @@ void RedWindow_p::win_proc(XEvent& event)
break;
}
red_window->get_listener().on_mouse_button_press(button, state);
red_window->last_event_time = event.xkey.time;
XChangeProperty(x_display, red_window->_win, wm_user_time,
XA_CARDINAL, 32, PropModeReplace,
(unsigned char *)&event.xbutton.time, 1);
break;
}
case ButtonRelease: {
@ -1526,6 +1534,8 @@ void RedWindow::show(int screen_id)
XDeleteProperty(x_display, _win, wm_state);
wait_parent = true;
}
XChangeProperty(x_display, _win, wm_user_time, XA_CARDINAL, 32,
PropModeReplace, (unsigned char *)&last_event_time, 1);
XMapWindow(x_display, _win);
move_to_current_desktop();
_expect_parent = wait_parent;
@ -1664,6 +1674,8 @@ void RedWindow::activate()
{
//todo: use _NET_ACTIVE_WINDOW
XSetInputFocus(x_display, _win, RevertToParent, CurrentTime);
/* kwin won't raise on focus */
XRaiseWindow(x_display, _win);
}
void RedWindow::minimize()

View File

@ -82,6 +82,7 @@ protected:
RedWindow *_red_window;
int _width;
int _height;
Time last_event_time;
};
#endif