summaryrefslogtreecommitdiffstats
path: root/client/x11/red_window.cpp
diff options
context:
space:
mode:
authorArnon Gilboa <agilboa@redhat.com>2009-12-30 13:41:58 +0200
committerYaniv Kamay <ykamay@redhat.com>2009-12-30 22:15:02 +0200
commitea9af22e62fdae7fc0bd707ef60bcf82ec3c4551 (patch)
tree2de4eb88b9b71c49515b0deb8b2be82bfb992546 /client/x11/red_window.cpp
parent02a07b2c067e629749cbe8a9f9cfbfb487a512d7 (diff)
downloadspice-ea9af22e62fdae7fc0bd707ef60bcf82ec3c4551.tar.gz
spice-ea9af22e62fdae7fc0bd707ef60bcf82ec3c4551.tar.xz
spice-ea9af22e62fdae7fc0bd707ef60bcf82ec3c4551.zip
spice: position mouse in primary monitor center after full screen toggle
-move _focused & _pointer_in_window from RedWindow to RedWindow_p's -move shadow focus & cursor handling to sync() -add reset_cursor_pos() to Platform -Monitor set_mode()/restore() use virtual do_set_mode()/do_restore()
Diffstat (limited to 'client/x11/red_window.cpp')
-rw-r--r--client/x11/red_window.cpp73
1 files changed, 29 insertions, 44 deletions
diff --git a/client/x11/red_window.cpp b/client/x11/red_window.cpp
index ee43b5a5..795a7bbd 100644
--- a/client/x11/red_window.cpp
+++ b/client/x11/red_window.cpp
@@ -889,7 +889,7 @@ void RedWindow_p::win_proc(XEvent& event)
if (!red_window->_ignore_pointer) {
Point origin = red_window->get_origin();
red_window->on_pointer_enter(event.xcrossing.x - origin.x, event.xcrossing.y - origin.y,
- to_red_buttons_state(event.xmotion.state));
+ to_red_buttons_state(event.xcrossing.state));
} else {
red_window->_shadow_pointer_state = true;
memcpy(&red_window->_shadow_pointer_event, &event, sizeof(XEvent));
@@ -906,13 +906,35 @@ void RedWindow_p::win_proc(XEvent& event)
}
}
-void RedWindow_p::sync()
+void RedWindow_p::sync(bool shadowed)
{
+ if (shadowed) {
+ _ignore_foucs = true;
+ _ignore_pointer = true;
+ _shadow_foucs_state = _focused;
+ _shadow_pointer_state = _pointer_in_window;
+ _shadow_focus_event.xany.serial = 0;
+ }
XSync(x_display, False);
XEvent event;
while (XCheckWindowEvent(x_display, _win, ~long(0), &event)) {
win_proc(event);
}
+ if (!shadowed) {
+ return;
+ }
+ _ignore_foucs = false;
+ _ignore_pointer = false;
+ if (_shadow_foucs_state != _focused) {
+ DBG(0, "put back shadowed focus event");
+ XPutBackEvent(x_display, &_shadow_focus_event);
+ } else if (_shadow_focus_event.xany.serial > 0) {
+ focus_serial = _shadow_focus_event.xany.serial;
+ }
+ if (_shadow_pointer_state != _pointer_in_window) {
+ DBG(0, "put back shadowed pointer event");
+ XPutBackEvent(x_display, &_shadow_pointer_event);
+ }
}
void RedWindow_p::wait_for_reparent()
@@ -1023,7 +1045,9 @@ RedWindow_p::RedWindow_p()
: _win (None)
, _glcont_copy (NULL)
, _icon (NULL)
+ , _focused (false)
, _ignore_foucs (false)
+ , _pointer_in_window (false)
, _ignore_pointer (false)
{
}
@@ -1193,8 +1217,6 @@ RedWindow::RedWindow(RedWindow::Listener& listener, int screen)
, _type (TYPE_NORMAL)
, _local_cursor (NULL)
, _cursor_visible (true)
- , _focused (false)
- , _pointer_in_window (false)
, _trace_key_interception (false)
, _key_interception_on (false)
, _menu (NULL)
@@ -1600,55 +1622,18 @@ void RedWindow::do_start_key_interception()
// LeaveNotify and EnterNotify.
ASSERT(_focused);
- _ignore_foucs = true;
- _ignore_pointer = true;
- _shadow_foucs_state = true;
- _shadow_pointer_state = true;
- _shadow_focus_event.xany.serial = 0;
XGrabKeyboard(x_display, _win, True, GrabModeAsync, GrabModeAsync, CurrentTime);
- sync();
+ sync(true);
_listener.on_start_key_interception();
- _ignore_foucs = false;
- _ignore_pointer = false;
_key_interception_on = true;
- if (!_shadow_foucs_state) {
- DBG(0, "put back shadowed focus out");
- XPutBackEvent(x_display, &_shadow_focus_event);
- } else if (_shadow_focus_event.xany.serial > 0) {
- ASSERT(focus_window == this);
- focus_serial = _shadow_focus_event.xany.serial;
- }
-
- if (!_shadow_pointer_state) {
- DBG(0, "put back shadowed pointer leave");
- XPutBackEvent(x_display, &_shadow_pointer_event);
- }
}
void RedWindow::do_stop_key_interception()
{
- _ignore_foucs = true;
- _ignore_pointer = true;
- _shadow_foucs_state = _focused;
- _shadow_pointer_state = _pointer_in_window;
- _shadow_focus_event.xany.serial = 0;
XUngrabKeyboard(x_display, CurrentTime);
- sync();
+ sync(true);
_key_interception_on = false;
_listener.on_stop_key_interception();
- _ignore_foucs = false;
- _ignore_pointer = false;
- if (_shadow_foucs_state != _focused) {
- DBG(0, "put back shadowed focus event");
- XPutBackEvent(x_display, &_shadow_focus_event);
- } else if (_shadow_focus_event.xany.serial > 0) {
- focus_serial = _shadow_focus_event.xany.serial;
- }
-
- if (_shadow_pointer_state != _pointer_in_window) {
- DBG(0, "put back shadowed pointer event");
- XPutBackEvent(x_display, &_shadow_pointer_event);
- }
}
void RedWindow::start_key_interception()
@@ -1705,7 +1690,7 @@ void RedWindow::hide_cursor()
void RedWindow::release_mouse()
{
XUngrabPointer(x_display, CurrentTime);
- sync();
+ sync(true);
}
void RedWindow::cupture_mouse()