From 5b59146f8d060754b14eba415dcc9066d8bc7b02 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Tue, 7 May 2013 22:29:50 -0700 Subject: [PATCH] psppire-cell-renderer-button: Translate coords before propagating event. When propagating a right-click upward, the x and y coordinates in the event are those for the button, not for the parent window, but the parent window's signal handlers will expect that they are relative to the parent window. This commit makes that so. Without this commit, the following scenario occurs: 1. Open a dataset with at least two cases. 2. Switch to the Data View 3. Place the pointer over (say) the tenth row header button. 4. Click the left mouse button. 5. Click the right mouse button. 6. The popup menu appears (as it should), but row 1 gets selected instead of row 10. With this commit, in step 6 the correct row is selected. Bug #38922. Reported by John Darrington. --- src/ui/gui/psppire-cell-renderer-button.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ui/gui/psppire-cell-renderer-button.c b/src/ui/gui/psppire-cell-renderer-button.c index 8b9e9076dc..f312a01900 100644 --- a/src/ui/gui/psppire-cell-renderer-button.c +++ b/src/ui/gui/psppire-cell-renderer-button.c @@ -340,7 +340,16 @@ psppire_cell_renderer_button_press_event (GtkButton *button, /* Allow right-click events to propagate upward in the widget hierarchy. Otherwise right-click menus, that trigger on a button-press-event on the containing PsppSheetView, will pop up if the button is rendered as - a facade but not if the button widget exists. */ + a facade but not if the button widget exists. + + We have to translate the event's data by hand to be relative to the + parent window, because the normal GObject signal propagation mechanism + won't do it for us. (This might be a hint that we're doing this + wrong.) */ + gdk_window_coords_to_parent (event->window, + event->x, event->y, + &event->x, &event->y); + event->window = gdk_window_get_parent (event->window); g_signal_stop_emission_by_name (button, "button-press-event"); return FALSE; } -- 2.30.2