textview: Avoid misplacing the Emoji chooser
authorMatthias Clasen <mclasen@redhat.com>
Wed, 1 Dec 2021 00:44:26 +0000 (19:44 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 1 Dec 2021 00:44:26 +0000 (19:44 -0500)
When the iter is at the end of the buffer,
gtk_text_view_get_iter_location returns a
rectangle with width 0, which in turn makes
gdk_rectangle_intersect return FALSE.

Avoid that by always giving the rectangle
non-empty dimensions.

Fixes: #4503
gtk/gtktextview.c

index f576aaf748304c12bce276d99d33fd6dd940c3da..c1b83eb9b38e24c767c78c67c0e9279791a5e651 100644 (file)
@@ -10012,6 +10012,10 @@ gtk_text_view_insert_emoji (GtkTextView *text_view)
                                     gtk_text_buffer_get_insert (buffer));
 
   gtk_text_view_get_iter_location (text_view, &iter, (GdkRectangle *) &rect);
+
+  rect.width = MAX (rect.width, 1);
+  rect.height = MAX (rect.height, 1);
+
   gtk_text_view_buffer_to_window_coords (text_view, GTK_TEXT_WINDOW_TEXT,
                                          rect.x, rect.y, &rect.x, &rect.y);
   _text_window_to_widget_coords (text_view, &rect.x, &rect.y);