entrycompletion: Mark popup window as subsurface on wayland

This will make the completion window use GDK_WINDOW_SUBSURFACE and be
shown relative to the parent window without involving compositor grabs.

https://bugzilla.gnome.org/show_bug.cgi?id=695504
This commit is contained in:
Carlos Garnacho 2014-08-21 17:36:45 +02:00
parent c38651cac4
commit d04d29f26c

View File

@ -85,6 +85,7 @@
#include "gtkmarshalers.h" #include "gtkmarshalers.h"
#include "gtkprivate.h" #include "gtkprivate.h"
#include "gtkwindowprivate.h"
#include <string.h> #include <string.h>
@ -609,9 +610,11 @@ gtk_entry_completion_constructed (GObject *object)
/* pack it all */ /* pack it all */
priv->popup_window = gtk_window_new (GTK_WINDOW_POPUP); 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_resizable (GTK_WINDOW (priv->popup_window), FALSE);
gtk_window_set_type_hint (GTK_WINDOW(priv->popup_window), gtk_window_set_type_hint (GTK_WINDOW(priv->popup_window),
GDK_WINDOW_TYPE_HINT_COMBO); GDK_WINDOW_TYPE_HINT_COMBO);
g_signal_connect (priv->popup_window, "key-press-event", g_signal_connect (priv->popup_window, "key-press-event",
G_CALLBACK (gtk_entry_completion_popup_key_event), G_CALLBACK (gtk_entry_completion_popup_key_event),
completion); completion);
@ -2708,6 +2711,8 @@ _gtk_entry_completion_disconnect (GtkEntryCompletion *completion)
gtk_window_set_attached_to (GTK_WINDOW (completion->priv->popup_window), gtk_window_set_attached_to (GTK_WINDOW (completion->priv->popup_window),
NULL); NULL);
gtk_window_set_transient_for (GTK_WINDOW (completion->priv->popup_window), NULL);
completion->priv->entry = NULL; completion->priv->entry = NULL;
} }
@ -2715,6 +2720,9 @@ void
_gtk_entry_completion_connect (GtkEntryCompletion *completion, _gtk_entry_completion_connect (GtkEntryCompletion *completion,
GtkEntry *entry) GtkEntry *entry)
{ {
GtkEntryCompletionPrivate *priv = completion->priv;
GtkWidget *toplevel;
completion->priv->entry = GTK_WIDGET (entry); completion->priv->entry = GTK_WIDGET (entry);
set_accessible_relation (completion->priv->popup_window, set_accessible_relation (completion->priv->popup_window,
@ -2723,4 +2731,10 @@ _gtk_entry_completion_connect (GtkEntryCompletion *completion,
completion->priv->entry); completion->priv->entry);
connect_completion_signals (completion); connect_completion_signals (completion);
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (entry));
if (gtk_widget_is_toplevel (toplevel))
gtk_window_set_transient_for (GTK_WINDOW (priv->popup_window),
GTK_WINDOW (toplevel));
} }