On Di  8.Dez'09 at  9:42:49 +0800, Paul Harris wrote:
> 
> my setup: wheel mouse on background changes the desktop
> 
> procedure:
> - minimise a window
> - move mouse over the icon, then twirl the mouse wheel down
> 
> if you do it right, the window will restore, but the workspace will change
> (from A to B), and the window is restored on the new desktop.
> if you press F11 (or middle-mouse, or whatever) to bring up the Window List,
> you'll see that the restored window is listed as still living on Workspace A
> when its clearly visible on Workspace B.
> 
> if you switch back to the original workspace (A), the restored window
> "follows" you there.
> if you return to the workspace B, the restore window is not there (which is
> how it should have been from the start).
> 
> so,  you can make a window restore onto the incorrect workspace.

The patch below fixes the issue for me and I've just pushed it to 'next'.
Paul, can you test it too?

I am not sure if there are already some flags in Window Maker saying
"don't do that while I am doing this", so I had to create a global
variable to take care of this issue.

---8<------
>From a2133e8e2fa868e6284f78ec2ecb06294b2ee95d Mon Sep 17 00:00:00 2001
From: Carlos R. Mafra <[email protected]>
Date: Sat, 26 Dec 2009 21:09:10 +0100
Subject: [PATCH] Do not change workspace during deiconify animation

Paul Harris reported that using the mouse wheel over a miniwindow
would deiconify it to a different workspace than the original one
where it was iconified.

This happens because after the window begins to be deiconified the
"residual" mouse wheel scrolling hits the workspace background, and
Window Maker changes workspace with wWorkspaceRelativeChange().

But if it all happens fast enough (so the deiconification animation
did not finish yet) the workspace will have changed before the
window reaches its final deiconified destination, leading to
the situation that Paul described in the link below.

So to avoid this, let's set a 'ignore_wks_change' variable
from wDeiconifyWindow() and make wWorkspaceRelativeChange() respect it.

Original report: http://lists.windowmaker.info/dev/msg00821.html
---
 src/actions.c   |    7 +++++++
 src/workspace.c |    8 ++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/src/actions.c b/src/actions.c
index c308ed0..891c4f2 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -49,6 +49,8 @@
 #include "xinerama.h"
 
 /****** Global Variables ******/
+
+int ignore_wks_change = 0;
 extern Time LastTimestamp;
 extern Time LastFocusChange;
 
@@ -1109,6 +1111,9 @@ void wIconifyWindow(WWindow * wwin)
 
 void wDeiconifyWindow(WWindow * wwin)
 {
+       /* Let's avoid changing workspace while deiconifying */
+       ignore_wks_change = 1;
+
        /* we're hiding for show_desktop */
        int netwm_hidden = wwin->flags.net_show_desktop &&
            wwin->frame->workspace != wwin->screen_ptr->current_workspace;
@@ -1230,6 +1235,8 @@ void wDeiconifyWindow(WWindow * wwin)
        /* In case we were shaded and iconified, also unshade */
        if (!netwm_hidden)
                wUnshadeWindow(wwin);
+
+       ignore_wks_change = 0;
 }
 
 static void hideWindow(WIcon * icon, int icon_x, int icon_y, WWindow * wwin, 
int animate)
diff --git a/src/workspace.c b/src/workspace.c
index 1178070..7374633 100644
--- a/src/workspace.c
+++ b/src/workspace.c
@@ -54,6 +54,7 @@
 #define MAX_SHORTCUT_LENGTH 32
 #define WORKSPACE_NAME_DISPLAY_PADDING 32
 
+extern int ignore_wks_change;
 extern WPreferences wPreferences;
 extern XContext wWinContext;
 extern XContext wVEdgeContext;
@@ -441,6 +442,13 @@ void wWorkspaceRelativeChange(WScreen * scr, int amount)
 {
        int w;
 
+       /* While the deiconify animation is going on the window is
+        * still "flying" to its final position and we don't want to
+        * change workspace before the animation finishes, otherwise
+        * the window will land in the new workspace */
+       if (ignore_wks_change)
+               return;
+
        w = scr->current_workspace + amount;
 
        if (amount < 0) {
-- 
1.6.6


-- 
To unsubscribe, send mail to [email protected].

Reply via email to