diff -Naur xfce4-panel-4.8.3/plugins/pager/pager.c xfce4-panel-4.8.3-changed//plugins/pager/pager.c --- xfce4-panel-4.8.3/plugins/pager/pager.c 2011-04-06 19:14:40.000000000 +0200 +++ xfce4-panel-4.8.3-changed//plugins/pager/pager.c 2011-05-11 13:34:05.000000000 +0200 @@ -240,34 +240,97 @@ WnckWorkspace *new_ws; gint active_n; gint n_workspaces; - + GList *workspaces; + gint rows, cols; + gint new_x, new_y; + gint workspace_width = 0, workspace_height = 0; + gint screen_width = 0, screen_height = 0; + WnckWorkspace *workspace = NULL; + panel_return_val_if_fail (WNCK_IS_SCREEN (plugin->wnck_screen), FALSE); - /* leave when scrolling is not enabled */ - if (plugin->scrolling == FALSE) - return TRUE; + workspaces = wnck_screen_get_workspaces (plugin->wnck_screen); + n_workspaces = g_list_length (workspaces); - active_ws = wnck_screen_get_active_workspace (plugin->wnck_screen); - active_n = wnck_workspace_get_number (active_ws); + if (G_UNLIKELY (n_workspaces == 1 + && wnck_workspace_is_virtual (WNCK_WORKSPACE (workspaces->data)))) + { + workspace = wnck_screen_get_active_workspace (plugin->wnck_screen); + + workspace_width = wnck_workspace_get_width (workspace); + workspace_height = wnck_workspace_get_height (workspace); + screen_width = wnck_screen_get_width (plugin->wnck_screen); + screen_height = wnck_screen_get_height (plugin->wnck_screen); + + panel_return_val_if_fail (WNCK_IS_SCREEN (plugin->wnck_screen), FALSE); + + if (plugin->scrolling == FALSE) + return TRUE; + + cols = workspace_width / screen_width; + rows = workspace_height / screen_height; + + new_x = wnck_workspace_get_viewport_x (workspace); + new_y = wnck_workspace_get_viewport_y (workspace); + + new_x /= screen_width; + new_y /= screen_height; + + if(event->direction == GDK_SCROLL_UP || event->direction == GDK_SCROLL_LEFT) { + new_x -= 1; + } else { + new_x += 1; + } + + if(new_x < 0) { + if(new_y > 0) { + new_y -= 1; + new_x = cols - 1; + } else { + new_x = 0; + } + } + + if(new_x >= cols) { + if(new_y < rows - 1) { + new_y += 1; + new_x = 0; + } else { + new_x = cols - 1; + } + } + + new_x *= screen_width; + new_y *= screen_height; + + wnck_screen_move_viewport(plugin->wnck_screen, + new_x, new_y); + } else { + /* leave when scrolling is not enabled */ + if (plugin->scrolling == FALSE) + return TRUE; - 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); + active_ws = wnck_screen_get_active_workspace (plugin->wnck_screen); + active_n = wnck_workspace_get_number (active_ws); - return TRUE; + 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; }