From d2bb60239be166dfe674e641ec1a8bf8e2748045 Mon Sep 17 00:00:00 2001 From: markt Date: Sun, 7 Jan 2007 18:44:46 +0000 Subject: remove race condition from workspace warping code --- ChangeLog | 2 ++ src/Window.cc | 33 +++++++++++++++++++-------------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index cb16560..5621322 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ (Format: Year/Month/Day) Changes for 1.0rc3: *07/01/07: + * Fixed workspace warping going crazy, bug #1467124 (Mark) + Window.cc * Fix little bug with iconbar rendering, bug #1549209 (Mark) IconbarTool.cc * Fix RefCount crash and Slit deconstruction ordering (Simon) diff --git a/src/Window.cc b/src/Window.cc index ca42c96..fe4cf4a 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -2849,12 +2849,6 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { if (! isMoving()) { startMoving(me.x_root, me.y_root); } else { - int dx = me.x_root - m_button_grab_x, - dy = me.y_root - m_button_grab_y; - - dx -= frame().window().borderWidth(); - dy -= frame().window().borderWidth(); - // Warp to next or previous workspace?, must have moved sideways some int moved_x = me.x_root - m_last_resize_x; // save last event point @@ -2871,25 +2865,36 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { moved_x > 0) { //warp right new_id = (cur_id + 1) % screen().numberOfWorkspaces(); - dx = - me.x_root; // move mouse back to x=0 + m_last_resize_x = 0; // move mouse back to x=0 } else if (me.x_root <= warpPad && moved_x < 0) { //warp left new_id = (cur_id + screen().numberOfWorkspaces() - 1) % screen().numberOfWorkspaces(); - dx = screen().width() - me.x_root-1; // move mouse to screen width - 1 + m_last_resize_x = screen().width() - 1; // move mouse to screen width - 1 } if (new_id != cur_id) { - XWarpPointer(display, None, None, 0, 0, 0, 0, dx, 0); - screen().changeWorkspaceID(new_id); + // remove motion events from queue to avoid repeated warps + XEvent e; + while (XCheckTypedEvent(display, MotionNotify, &e)) { + // might as well update the y-coordinate + m_last_resize_y = e.xmotion.y_root; + } - m_last_resize_x = me.x_root + dx; + // move the pointer to (m_last_resize_x,m_last_resize_y) + XWarpPointer(display, None, me.root, 0, 0, 0, 0, + m_last_resize_x, m_last_resize_y); - // dx is the difference, so our new x is what it would have been - // without the warp, plus the difference. - dx += me.x_root - m_button_grab_x; + screen().changeWorkspaceID(new_id); } } + + int dx = m_last_resize_x - m_button_grab_x, + dy = m_last_resize_y - m_button_grab_y; + + dx -= frame().window().borderWidth(); + dy -= frame().window().borderWidth(); + // dx = current left side, dy = current top doSnapping(dx, dy); -- cgit v0.11.2