From a2133e8e2fa868e6284f78ec2ecb06294b2ee95d Mon Sep 17 00:00:00 2001 From: "Carlos R. Mafra" 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(+) diff --git a/src/actions.c b/src/actions.c index c308ed04..891c4f29 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 11780705..7374633a 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) {