[Xfce4-commits] [xfce/xfce4-panel] 01/01: pager: Fix scrolling in pager-buttons (Bug #15614)

noreply at xfce.org noreply at xfce.org
Mon Aug 19 02:13:11 CEST 2019


This is an automated email from the git hooks/post-receive script.

o   c   h   o   s   i       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/xfce4-panel.

commit 55dc7b400feef0c35fda3e8d3515dada2ced29c4
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Thu Aug 15 23:27:25 2019 +0200

    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 b554a98..38af285 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 9d882da..5617565 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 fbac26f..6c635be 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 40cc7fa..5637bea 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++;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list