[balsa/gtk4: 57/311] libbalsa: In popup-widget, special case GtkToolbar




commit 90ad75842f597d68910c18ee58ddf2b7d46ec971
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Sun Jun 21 15:04:02 2020 -0400

    libbalsa: In popup-widget, special case GtkToolbar
    
    When the user right-clicks on a toolbar button, the GdkEvent coordinates
    are relative to the button. The root x-coordinate is relative to the
    toolbar, so we use that to position the popup, instead of the event x.
    
    The event y-coordinate is a few pixels off from y relative to the
    toolbar, and making the pointed-to rectangle 5x5 instead of 0x0 mostly
    fixes it. The root y-coordinate is way off, and it seems better to use
    the event y.

 libbalsa/libbalsa.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/libbalsa/libbalsa.c b/libbalsa/libbalsa.c
index 4ff8d43dc..3d883e90f 100644
--- a/libbalsa/libbalsa.c
+++ b/libbalsa/libbalsa.c
@@ -814,25 +814,36 @@ libbalsa_popup_widget_popup(GtkWidget      *popup_widget,
         if (event != NULL &&
             gdk_event_triggers_context_menu(event) &&
             gdk_event_get_coords(event, &x, &y)) {
-            /* Pop up to the right of the pointer */
             if (GTK_IS_TREE_VIEW(widget)) {
                 gtk_tree_view_convert_bin_window_to_widget_coords(GTK_TREE_VIEW(widget),
                                                                   (gint) x,
                                                                   (gint) y,
                                                                   &rectangle.x,
                                                                   &rectangle.y);
+                rectangle.width = 0;
+                rectangle.height = 0;
+            } else if (GTK_IS_TOOLBAR(widget)) {
+                gdouble x_root;
+
+                gdk_event_get_root_coords(event, &x_root, NULL);
+                rectangle.x = (gint) x_root;
+                rectangle.y = (gint) y;
+                rectangle.width = 5;
+                rectangle.height = 5;
             } else {
                 rectangle.x = (gint) x;
                 rectangle.y = (gint) y;
+                rectangle.width = 0;
+                rectangle.height = 0;
             }
         } else {
             /* Pop up centered on widget */
             gtk_widget_get_allocation(widget, (GtkAllocation *) &rectangle);
             rectangle.x += rectangle.width / 2;
             rectangle.y += rectangle.height / 2;
+            rectangle.width = 0;
+            rectangle.height = 0;
         }
-        rectangle.width = 0;
-        rectangle.height = 0;
 
         gtk_popover_set_pointing_to(popover, &rectangle);
         gtk_popover_popup(popover);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]