[Xfce4-commits] <xfce4-panel:master> Restore old workspace scroll behaviour (bug #6271).
Nick Schermer
noreply at xfce.org
Sun Mar 14 17:38:01 CET 2010
Updating branch refs/heads/master
to 3de49f5f5d99e7b590cd96fc86b25b3e01606079 (commit)
from 7bf7d77f53c45629a57f0466ae470d7314eaa643 (commit)
commit 3de49f5f5d99e7b590cd96fc86b25b3e01606079
Author: Nick Schermer <nick at xfce.org>
Date: Sun Mar 14 17:34:56 2010 +0100
Restore old workspace scroll behaviour (bug #6271).
We use the neighbor functiononality in wnck for scrolling,
but this does not work for most people and is not the
way xfwm4 handles root scroll event.
Restore old behaviour like in the 4.6 panel.
plugins/pager/pager.c | 54 +++++++++++++++++++++---------------------------
1 files changed, 24 insertions(+), 30 deletions(-)
diff --git a/plugins/pager/pager.c b/plugins/pager/pager.c
index b2b8163..7519abd 100644
--- a/plugins/pager/pager.c
+++ b/plugins/pager/pager.c
@@ -226,9 +226,11 @@ static gboolean
pager_plugin_scroll_event (GtkWidget *widget,
GdkEventScroll *event)
{
- PagerPlugin *plugin = XFCE_PAGER_PLUGIN (widget);
- WnckWorkspace *active, *neighbor;
- WnckMotionDirection direction;
+ PagerPlugin *plugin = XFCE_PAGER_PLUGIN (widget);
+ WnckWorkspace *active_ws;
+ WnckWorkspace *new_ws;
+ gint active_n;
+ gint n_workspaces;
panel_return_val_if_fail (WNCK_IS_SCREEN (plugin->wnck_screen), FALSE);
@@ -236,33 +238,25 @@ pager_plugin_scroll_event (GtkWidget *widget,
if (plugin->scrolling == FALSE)
return TRUE;
- /* translate the gdk scroll direction into a wnck motion direction */
- switch (event->direction)
- {
- case GDK_SCROLL_UP:
- direction = WNCK_MOTION_UP;
- break;
-
- case GDK_SCROLL_DOWN:
- direction = WNCK_MOTION_DOWN;
- break;
-
- case GDK_SCROLL_LEFT:
- direction = WNCK_MOTION_LEFT;
- break;
+ active_ws = wnck_screen_get_active_workspace (plugin->wnck_screen);
+ active_n = wnck_workspace_get_number (active_ws);
- default:
- direction = WNCK_MOTION_RIGHT;
- break;
- }
-
- /* get the active workspace's neighbor */
- active = wnck_screen_get_active_workspace (plugin->wnck_screen);
- neighbor = wnck_workspace_get_neighbor (active, direction);
-
- /* if there is a neighbor, move to it */
- if (neighbor != NULL)
- wnck_workspace_activate (neighbor, event->time);
+ if (event->direction == GDK_SCROLL_UP
+ || event->direction == GDK_SCROLL_LEFT)
+ active_n--;
+ else
+ active_n++;
+
+ /* wrap around */
+ n_workspaces = wnck_screen_get_workspace_count (plugin->wnck_screen) - 1;
+ if (active_n < 0)
+ active_n = n_workspaces;
+ else if (active_n > n_workspaces)
+ active_n = 0;
+
+ new_ws = wnck_screen_get_workspace (plugin->wnck_screen, active_n);
+ if (new_ws != NULL && active_ws != new_ws)
+ wnck_workspace_activate (new_ws, event->time);
return TRUE;
}
More information about the Xfce4-commits
mailing list