[evolution-data-server/wip/mcrha/gtk4] Fix coords recalc from an event in the EBufferTagger



commit 08cc5c2e8bf93ca3430561de48e0f6a99e35bf78
Author: Milan Crha <mcrha redhat com>
Date:   Tue Oct 19 17:53:33 2021 +0200

    Fix coords recalc from an event in the EBufferTagger

 src/libedataserverui/e-buffer-tagger.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/src/libedataserverui/e-buffer-tagger.c b/src/libedataserverui/e-buffer-tagger.c
index 292cd8b67..6a2a9870a 100644
--- a/src/libedataserverui/e-buffer-tagger.c
+++ b/src/libedataserverui/e-buffer-tagger.c
@@ -248,6 +248,10 @@ get_pointer_position (GtkTextView *text_view,
        if (!event || !gdk_event_get_position (event, &tmp_x, &tmp_y)) {
                tmp_x = -1;
                tmp_y = -1;
+       } else {
+               GtkWidget *window = gtk_widget_get_ancestor (GTK_WIDGET (text_view), GTK_TYPE_WINDOW);
+               if (window)
+                       gtk_widget_translate_coordinates (window, GTK_WIDGET (text_view), tmp_x, tmp_y, 
&tmp_x, &tmp_y);
        }
        if (out_x)
                *out_x = tmp_x;
@@ -845,7 +849,11 @@ textview_event_after (GtkTextView *textview,
 
 #if GTK_CHECK_VERSION(4, 0, 0)
        event_button = gdk_button_event_get_button (event);
-       gdk_event_get_position (event, &event_x_win, &event_y_win);
+       if (gdk_event_get_position (event, &event_x_win, &event_y_win)) {
+               GtkWidget *window = gtk_widget_get_ancestor (GTK_WIDGET (textview), GTK_TYPE_WINDOW);
+               if (window)
+                       gtk_widget_translate_coordinates (window, GTK_WIDGET (textview), event_y_win, 
event_y_win, &event_x_win, &event_y_win);
+       }
 #else
        gdk_event_get_button (event, &event_button);
        gdk_event_get_coords (event, &event_x_win, &event_y_win);


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