[gnome-builder/wip/gtk4-port] libide/sourceview: fix menu positioning



commit 2bb4a03cf6309a5e7fa146938c3cd2d6cf2b5d27
Author: Christian Hergert <chergert redhat com>
Date:   Sun May 8 16:33:01 2022 -0700

    libide/sourceview: fix menu positioning

 src/libide/sourceview/ide-source-view-private.h |  4 ++++
 src/libide/sourceview/ide-source-view.c         | 10 +++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)
---
diff --git a/src/libide/sourceview/ide-source-view-private.h b/src/libide/sourceview/ide-source-view-private.h
index affcf07b7..07cffe69b 100644
--- a/src/libide/sourceview/ide-source-view-private.h
+++ b/src/libide/sourceview/ide-source-view-private.h
@@ -62,6 +62,10 @@ struct _IdeSourceView
   IdeExtensionSetAdapter *completion_providers;
   IdeExtensionSetAdapter *hover_providers;
 
+  /* Mouse click position */
+  double click_x;
+  double click_y;
+
   /* Bitfield values go here */
   guint highlight_current_line : 1;
 };
diff --git a/src/libide/sourceview/ide-source-view.c b/src/libide/sourceview/ide-source-view.c
index 29b5e12b9..9c865d383 100644
--- a/src/libide/sourceview/ide-source-view.c
+++ b/src/libide/sourceview/ide-source-view.c
@@ -191,6 +191,9 @@ ide_source_view_click_pressed_cb (IdeSourceView   *self,
   g_assert (IDE_IS_SOURCE_VIEW (self));
   g_assert (GTK_IS_GESTURE_CLICK (click));
 
+  self->click_x = x;
+  self->click_y = y;
+
   buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self));
   sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (click));
   event = gtk_gesture_get_last_event (GTK_GESTURE (click), sequence);
@@ -403,7 +406,7 @@ ide_source_view_menu_popup_action (GtkWidget  *widget,
       model = G_MENU_MODEL (self->joined_menu);
       self->popup_menu = GTK_POPOVER (gtk_popover_menu_new_from_model (model));
       gtk_widget_set_parent (GTK_WIDGET (self->popup_menu), widget);
-      gtk_popover_set_position (self->popup_menu, GTK_POS_BOTTOM);
+      gtk_popover_set_position (self->popup_menu, GTK_POS_RIGHT);
       gtk_popover_set_has_arrow (self->popup_menu, FALSE);
       gtk_widget_set_halign (GTK_WIDGET (self->popup_menu), GTK_ALIGN_START);
     }
@@ -430,6 +433,11 @@ ide_source_view_menu_popup_action (GtkWidget  *widget,
 
       gtk_popover_set_pointing_to (self->popup_menu, &iter_location);
     }
+  else
+    {
+      gtk_popover_set_pointing_to (self->popup_menu,
+                                   &(GdkRectangle) { self->click_x, self->click_y, 1, 1 });
+    }
 
   gtk_popover_popup (self->popup_menu);
 


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