From a03c10fa14e4d9e33e487566ec6858192394621c Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 3 Feb 2005 18:09:41 +0000 Subject: [PATCH] Don't do one roundtrip per motion event. (#166173, pointed out by Chris MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2005-02-03 Matthias Clasen * gtk/gtkmenu.c (gtk_menu_handle_scrolling): Don't do one roundtrip per motion event. (#166173, pointed out by Chris Lee, patch by Søren Sandmann) --- ChangeLog | 4 ++++ ChangeLog.pre-2-10 | 4 ++++ ChangeLog.pre-2-8 | 4 ++++ gtk/gtkmenu.c | 32 +++++++++++++++++++++----------- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index a02f78353c..3cb44a3d2a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2005-02-03 Matthias Clasen + * gtk/gtkmenu.c (gtk_menu_handle_scrolling): Don't do + one roundtrip per motion event. (#166173, pointed out + by Chris Lee, patch by Søren Sandmann) + * gtk/gtk.symbols: * gtk/gtkstock.h: * gtk/gtkstock.c (gtk_stock_set_translate_func): diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index a02f78353c..3cb44a3d2a 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,5 +1,9 @@ 2005-02-03 Matthias Clasen + * gtk/gtkmenu.c (gtk_menu_handle_scrolling): Don't do + one roundtrip per motion event. (#166173, pointed out + by Chris Lee, patch by Søren Sandmann) + * gtk/gtk.symbols: * gtk/gtkstock.h: * gtk/gtkstock.c (gtk_stock_set_translate_func): diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index a02f78353c..3cb44a3d2a 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,5 +1,9 @@ 2005-02-03 Matthias Clasen + * gtk/gtkmenu.c (gtk_menu_handle_scrolling): Don't do + one roundtrip per motion event. (#166173, pointed out + by Chris Lee, patch by Søren Sandmann) + * gtk/gtk.symbols: * gtk/gtkstock.h: * gtk/gtkstock.c (gtk_stock_set_translate_func): diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c index 7266bb7569..0595301d59 100644 --- a/gtk/gtkmenu.c +++ b/gtk/gtkmenu.c @@ -189,7 +189,9 @@ static void gtk_menu_real_insert (GtkMenuShell *menu_shell, static void gtk_menu_scrollbar_changed (GtkAdjustment *adjustment, GtkMenu *menu); static void gtk_menu_handle_scrolling (GtkMenu *menu, - gboolean enter); + gint event_x, + gint event_y, + gboolean enter); static void gtk_menu_set_tearoff_hints (GtkMenu *menu, gint width); static void gtk_menu_style_set (GtkWidget *widget, @@ -2763,7 +2765,7 @@ gtk_menu_motion_notify (GtkWidget *widget, gboolean need_enter; if (GTK_IS_MENU (widget)) - gtk_menu_handle_scrolling (GTK_MENU (widget), TRUE); + gtk_menu_handle_scrolling (GTK_MENU (widget), event->x_root, event->y_root, TRUE); /* We received the event for one of two reasons: * @@ -2917,20 +2919,23 @@ gtk_menu_scroll (GtkWidget *widget, } static void -gtk_menu_handle_scrolling (GtkMenu *menu, gboolean enter) +gtk_menu_handle_scrolling (GtkMenu *menu, + gint x, + gint y, + gboolean enter) { GtkMenuShell *menu_shell; gint width, height; - gint x, y; gint border; GdkRectangle rect; gboolean in_arrow; gboolean scroll_fast = FALSE; guint vertical_padding; + gint top_x, top_y; + gint win_x, win_y; menu_shell = GTK_MENU_SHELL (menu); - gdk_window_get_pointer (GTK_WIDGET (menu)->window, &x, &y, NULL); gdk_drawable_get_size (GTK_WIDGET (menu)->window, &width, &height); gtk_widget_style_get (GTK_WIDGET (menu), @@ -2940,10 +2945,15 @@ gtk_menu_handle_scrolling (GtkMenu *menu, gboolean enter) border = GTK_CONTAINER (menu)->border_width + GTK_WIDGET (menu)->style->ythickness + vertical_padding; + gdk_window_get_position (menu->toplevel->window, &top_x, &top_y); + gdk_window_get_position (GTK_WIDGET (menu)->window, &win_x, &win_y); + win_x += top_x; + win_y += top_y; + if (menu->upper_arrow_visible && !menu->tearoff_active) { - rect.x = 0; - rect.y = 0; + rect.x = win_x; + rect.y = win_y; rect.width = width; rect.height = MENU_SCROLL_ARROW_HEIGHT + border; @@ -2981,8 +2991,8 @@ gtk_menu_handle_scrolling (GtkMenu *menu, gboolean enter) if (menu->lower_arrow_visible && !menu->tearoff_active) { - rect.x = 0; - rect.y = height - border - MENU_SCROLL_ARROW_HEIGHT; + rect.x = win_x; + rect.y = win_y + height - border - MENU_SCROLL_ARROW_HEIGHT; rect.width = width; rect.height = MENU_SCROLL_ARROW_HEIGHT + border; @@ -3031,7 +3041,7 @@ gtk_menu_enter_notify (GtkWidget *widget, GtkMenuShell *menu_shell = GTK_MENU_SHELL (widget); if (!menu_shell->ignore_enter) - gtk_menu_handle_scrolling (GTK_MENU (widget), TRUE); + gtk_menu_handle_scrolling (GTK_MENU (widget), event->x_root, event->y_root, TRUE); } if (menu_item && GTK_IS_MENU_ITEM (menu_item)) @@ -3096,7 +3106,7 @@ gtk_menu_leave_notify (GtkWidget *widget, if (gtk_menu_navigating_submenu (menu, event->x_root, event->y_root)) return TRUE; - gtk_menu_handle_scrolling (menu, FALSE); + gtk_menu_handle_scrolling (menu, event->x_root, event->y_root, FALSE); event_widget = gtk_get_event_widget ((GdkEvent*) event);