From 55dc7b400feef0c35fda3e8d3515dada2ced29c4 Mon Sep 17 00:00:00 2001 From: Simon Steinbeiss 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 #include #include +#include #include #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