1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
diff -Naur xfce4-panel-4.20.0-orig/plugins/pager/pager.c xfce4-panel-4.20.0/plugins/pager/pager.c
--- xfce4-panel-4.20.0-orig/plugins/pager/pager.c 2024-10-23 18:27:20.000000000 +0200
+++ xfce4-panel-4.20.0/plugins/pager/pager.c 2024-12-29 20:53:43.800000000 +0100
@@ -446,31 +446,96 @@
active_ws = xfw_workspace_group_get_active_workspace (plugin->workspace_group);
active_n = xfw_workspace_get_number (active_ws);
- if (scrolling_direction == GDK_SCROLL_UP
- || scrolling_direction == GDK_SCROLL_LEFT)
- active_n--;
- else
- active_n++;
-
n_workspaces = xfw_workspace_group_get_workspace_count (plugin->workspace_group) - 1;
- if (plugin->wrap_workspaces)
+ /* Having one workspace is a special case: could be viewport mode (compiz) */
+ if (n_workspaces == 0)
{
- /* wrap around */
- if (active_n < 0)
- active_n = n_workspaces;
- else if (active_n > n_workspaces)
- active_n = 0;
+ /* Do we really have only one workspace or are we in viewport mode */
+ if (xfw_workspace_get_state (active_ws) & XFW_WORKSPACE_STATE_VIRTUAL)
+ {
+ /* Viewport mode (compiz) */
+ guint scale_factor;
+ GdkRectangle *rect;
+ GdkScreen *screen = gdk_screen_get_default ();
+ int viewport_x;
+ int viewport_y;
+ int screen_width;
+ int workspace_width;
+ int scroll_direction;
+
+ scale_factor = gdk_window_get_scale_factor (gtk_widget_get_window (GTK_WIDGET (plugin)));
+ rect = xfw_workspace_get_geometry (active_ws);
+
+ /* Total workspacesize, e.g. 5120x1024 (5120=4x1280) */
+ /* Only width is needed, virtual workspaces are stacked */
+ /* horizontally. */
+ workspace_width = rect->width;
+ /* Current screensize, e.g. 1280x1024 */
+ screen_width = panel_screen_get_width (screen) * scale_factor;
+ /* Current viewportcoordinates, e.g. 0,0 or 1280,0 */
+ viewport_x = rect->x;
+ viewport_y = rect->y;
+
+ if (scrolling_direction == GDK_SCROLL_UP
+ || scrolling_direction == GDK_SCROLL_LEFT)
+ scroll_direction = -1;
+ else
+ scroll_direction = 1;
+
+ /* Viewportscroll is only in x-direction */
+ viewport_x = viewport_x + (scroll_direction * screen_width);
+
+ if (plugin->wrap_workspaces)
+ {
+ /* Wrap if needed */
+ if (viewport_x > workspace_width)
+ viewport_x = 0;
+ if (viewport_x < 0)
+ viewport_x = workspace_width - screen_width;
+ }
+ else if (viewport_x < 0 || viewport_x >= workspace_width)
+ {
+ /* Wrap disabled, no need to do anything */
+ return TRUE;
+ }
+
+ xfw_workspace_group_move_viewport (plugin->workspace_group,
+ viewport_x, viewport_y, NULL);
+ }
+ else
+ {
+ /* Only one workspace, no need to do anything */
+ return TRUE;
+ }
}
- else if (active_n < 0 || active_n > n_workspaces)
+ else
{
- /* we do not need to do anything */
- return TRUE;
- }
+ /* Real workspaces */
+ if (scrolling_direction == GDK_SCROLL_UP
+ || scrolling_direction == GDK_SCROLL_LEFT)
+ active_n--;
+ else
+ active_n++;
+
+ if (plugin->wrap_workspaces)
+ {
+ /* Wrap around */
+ if (active_n < 0)
+ active_n = n_workspaces;
+ else if (active_n > n_workspaces)
+ active_n = 0;
+ }
+ else if (active_n < 0 || active_n > n_workspaces )
+ {
+ /* We do not need to do anything */
+ return TRUE;
+ }
- new_ws = g_list_nth_data (xfw_workspace_group_list_workspaces (plugin->workspace_group), active_n);
- if (new_ws != NULL && active_ws != new_ws)
- xfw_workspace_activate (new_ws, NULL);
+ new_ws = g_list_nth_data (xfw_workspace_group_list_workspaces (plugin->workspace_group), active_n);
+ if (new_ws != NULL && active_ws != new_ws)
+ xfw_workspace_activate (new_ws, NULL);
+ }
return TRUE;
}
|