diff options
author | Jan-Michael Brummer <jan.brummer@tabos.org> | 2019-09-06 17:00:55 +0200 |
---|---|---|
committer | Jan-Michael Brummer <jan.brummer@tabos.org> | 2019-09-06 22:41:37 +0200 |
commit | fd2be449c6f78511b981e9b05e18090051c38846 (patch) | |
tree | 9492dcb45f07e98d47b43285d9f732d07f364779 | |
parent | 5ca7bbfd0e66a8524ad8f97240228eb21816879c (diff) | |
download | gtk+-gtk-entry-completion-fix.tar.gz |
gtkentrycompletion: Implement positioning using gdk_window_move_to_rect()gtk-entry-completion-fix
Fixes: https://gitlab.gnome.org/GNOME/gtk/issues/699
-rw-r--r-- | gtk/gtkentrycompletion.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/gtk/gtkentrycompletion.c b/gtk/gtkentrycompletion.c index ea159fe1c8..d04d283560 100644 --- a/gtk/gtkentrycompletion.c +++ b/gtk/gtkentrycompletion.c @@ -87,6 +87,10 @@ #include "gtkprivate.h" #include "gtkwindowprivate.h" +#ifdef GDK_WINDOWING_WAYLAND +#include <gdk/wayland/gdkwayland.h> +#endif + #include <string.h> #define PAGE_STEP 14 @@ -605,10 +609,8 @@ gtk_entry_completion_constructed (GObject *object) /* pack it all */ priv->popup_window = gtk_window_new (GTK_WINDOW_POPUP); - gtk_window_set_use_subsurface (GTK_WINDOW (priv->popup_window), TRUE); gtk_window_set_resizable (GTK_WINDOW (priv->popup_window), FALSE); - gtk_window_set_type_hint (GTK_WINDOW(priv->popup_window), - GDK_WINDOW_TYPE_HINT_COMBO); + gtk_window_set_type_hint (GTK_WINDOW(priv->popup_window), GDK_WINDOW_TYPE_HINT_COMBO); g_signal_connect (priv->popup_window, "key-press-event", G_CALLBACK (gtk_entry_completion_popup_key_event), @@ -1663,6 +1665,17 @@ _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion) else items = MIN (matches, (((area.height - y) - (actions * action_height)) / height) - 1); +#ifdef GDK_WINDOWING_WAYLAND + if (GDK_IS_WAYLAND_DISPLAY (display)) + { + /* Long lists might not fit into the work area and we do not have absolute coordinates + * to calculate the space above / below the entry. + * Therefore limit the number of maximal items to 10 + */ + items = MIN (items, 10); + } +#endif + if (items <= 0) gtk_widget_hide (completion->priv->scrolled_window); else @@ -1711,7 +1724,16 @@ _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion) gtk_tree_path_free (path); } - gtk_window_move (GTK_WINDOW (completion->priv->popup_window), x, y); + if (gtk_window_get_transient_for (GTK_WINDOW (completion->priv->popup_window))) + { + gdk_window_move_to_rect (gtk_widget_get_window (completion->priv->popup_window), + &allocation, + GDK_GRAVITY_SOUTH, + GDK_GRAVITY_NORTH, + GDK_ANCHOR_FLIP_Y | GDK_ANCHOR_SLIDE_X, + 0, 0); + gtk_widget_show (completion->priv->popup_window); + } } static gboolean |