summarylogtreecommitdiffstats
path: root/fix-scrolling.patch
blob: 72f14bc0f45e6a19ff1ab45657d81da376e15437 (plain)
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
120
121
122
123
124
125
From 55dc7b400feef0c35fda3e8d3515dada2ced29c4 Mon Sep 17 00:00:00 2001
From: Simon Steinbeiss <simon.steinbeiss@elfenbeinturm.at>
Date: Thu, 15 Aug 2019 23:27:25 +0200
Subject: pager: Fix scrolling in pager-buttons (Bug #15614)

Unfortunately this doesn't affect the miniature view (aka WnckPager),
where scrolling is handled natively and in a different - broken - order.
---
 common/panel-debug.c          |  3 ++-
 common/panel-debug.h          |  3 ++-
 plugins/pager/pager-buttons.c |  2 ++
 plugins/pager/pager.c         | 32 +++++++++++++++++++++++++-------
 4 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/common/panel-debug.c b/common/panel-debug.c
index b554a98f..38af2854 100644
--- a/common/panel-debug.c
+++ b/common/panel-debug.c
@@ -54,7 +54,8 @@ static const GDebugKey panel_debug_keys[] =
   { "positioning", PANEL_DEBUG_POSITIONING },
   { "struts", PANEL_DEBUG_STRUTS },
   { "systray", PANEL_DEBUG_SYSTRAY },
-  { "tasklist", PANEL_DEBUG_TASKLIST }
+  { "tasklist", PANEL_DEBUG_TASKLIST },
+  { "pager", PANEL_DEBUG_PAGER }
 };
 
 
diff --git a/common/panel-debug.h b/common/panel-debug.h
index 9d882da9..56175658 100644
--- a/common/panel-debug.h
+++ b/common/panel-debug.h
@@ -42,7 +42,8 @@ typedef enum
   PANEL_DEBUG_POSITIONING      = 1 << 12,
   PANEL_DEBUG_STRUTS           = 1 << 13,
   PANEL_DEBUG_SYSTRAY          = 1 << 14,
-  PANEL_DEBUG_TASKLIST         = 1 << 15
+  PANEL_DEBUG_TASKLIST         = 1 << 15,
+  PANEL_DEBUG_PAGER            = 1 << 16
 }
 PanelDebugFlag;
 
diff --git a/plugins/pager/pager-buttons.c b/plugins/pager/pager-buttons.c
index fbac26fe..6c635be6 100644
--- a/plugins/pager/pager-buttons.c
+++ b/plugins/pager/pager-buttons.c
@@ -368,6 +368,7 @@ pager_buttons_rebuild_idle (gpointer user_data)
           vp_info[VIEWPORT_Y] = (n / (workspace_height / screen_height)) * screen_height;
 
           button = xfce_panel_create_toggle_button ();
+          gtk_widget_add_events (GTK_WIDGET (button), GDK_SCROLL_MASK | GDK_SMOOTH_SCROLL_MASK);
           if (viewport_x >= vp_info[VIEWPORT_X] && viewport_x < vp_info[VIEWPORT_X] + screen_width
               && viewport_y >= vp_info[VIEWPORT_Y] && viewport_y < vp_info[VIEWPORT_Y] + screen_height)
             gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
@@ -410,6 +411,7 @@ pager_buttons_rebuild_idle (gpointer user_data)
           workspace = WNCK_WORKSPACE (li->data);
 
           button = xfce_panel_create_toggle_button ();
+          gtk_widget_add_events (GTK_WIDGET (button), GDK_SCROLL_MASK | GDK_SMOOTH_SCROLL_MASK);
           if (workspace == active_ws)
             gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
           g_signal_connect (G_OBJECT (button), "toggled",
diff --git a/plugins/pager/pager.c b/plugins/pager/pager.c
index 40cc7fab..5637bea6 100644
--- a/plugins/pager/pager.c
+++ b/plugins/pager/pager.c
@@ -32,6 +32,7 @@
 #include <common/panel-xfconf.h>
 #include <common/panel-utils.h>
 #include <common/panel-private.h>
+#include <common/panel-debug.h>
 #include <libwnck/libwnck.h>
 
 #include "pager.h"
@@ -320,11 +321,12 @@ static gboolean
 pager_plugin_scroll_event (GtkWidget      *widget,
                            GdkEventScroll *event)
 {
-  PagerPlugin   *plugin = XFCE_PAGER_PLUGIN (widget);
-  WnckWorkspace *active_ws;
-  WnckWorkspace *new_ws;
-  gint           active_n;
-  gint           n_workspaces;
+  PagerPlugin        *plugin = XFCE_PAGER_PLUGIN (widget);
+  WnckWorkspace      *active_ws;
+  WnckWorkspace      *new_ws;
+  gint                active_n;
+  gint                n_workspaces;
+  GdkScrollDirection  scrolling_direction;
 
   panel_return_val_if_fail (WNCK_IS_SCREEN (plugin->wnck_screen), FALSE);
 
@@ -332,11 +334,27 @@ pager_plugin_scroll_event (GtkWidget      *widget,
   if (plugin->scrolling == FALSE)
     return TRUE;
 
+  if (event->direction != GDK_SCROLL_SMOOTH)
+    scrolling_direction = event->direction;
+  else if (event->delta_y < 0)
+    scrolling_direction = GDK_SCROLL_UP;
+  else if (event->delta_y > 0)
+    scrolling_direction = GDK_SCROLL_DOWN;
+  else if (event->delta_x < 0)
+    scrolling_direction = GDK_SCROLL_LEFT;
+  else if (event->delta_x > 0)
+    scrolling_direction = GDK_SCROLL_RIGHT;
+  else
+    {
+      panel_debug_filtered (PANEL_DEBUG_PAGER, "Scrolling event with no delta happened.");
+      return TRUE;
+    }
+
   active_ws = wnck_screen_get_active_workspace (plugin->wnck_screen);
   active_n = wnck_workspace_get_number (active_ws);
 
-  if (event->direction == GDK_SCROLL_UP
-      || event->direction == GDK_SCROLL_LEFT)
+  if (scrolling_direction == GDK_SCROLL_UP
+      || scrolling_direction == GDK_SCROLL_LEFT)
     active_n--;
   else
     active_n++;
-- 
cgit v1.2.1