[libdazzle] suggestion: fix popover placement on X11



commit cf122b20143df156edb080bf7967f238a62f5474
Author: Christian Hergert <chergert redhat com>
Date:   Thu Jul 20 13:59:26 2017 -0700

    suggestion: fix popover placement on X11
    
    On wayland, our positions are relative to the parent window. But
    on X11, they are not. The position on Wayland is (0,0) so we can
    just always add the window position in both cases.

 src/suggestions/dzl-suggestion-entry.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/src/suggestions/dzl-suggestion-entry.c b/src/suggestions/dzl-suggestion-entry.c
index 54dd71c..05d48a2 100644
--- a/src/suggestions/dzl-suggestion-entry.c
+++ b/src/suggestions/dzl-suggestion-entry.c
@@ -786,8 +786,11 @@ _dzl_suggestion_entry_reposition (DzlSuggestionEntry   *self,
 {
   DzlSuggestionEntryPrivate *priv = dzl_suggestion_entry_get_instance_private (self);
   GtkWidget *toplevel;
+  GdkWindow *window;
   GtkAllocation alloc;
   gboolean is_absolute = FALSE;
+  gint x;
+  gint y;
 
   g_return_if_fail (DZL_IS_SUGGESTION_ENTRY (self));
   g_return_if_fail (DZL_IS_SUGGESTION_POPOVER (popover));
@@ -797,6 +800,7 @@ _dzl_suggestion_entry_reposition (DzlSuggestionEntry   *self,
     return;
 
   toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
+  window = gtk_widget_get_window (toplevel);
 
   gtk_widget_get_allocation (GTK_WIDGET (self), &alloc);
 
@@ -809,14 +813,15 @@ _dzl_suggestion_entry_reposition (DzlSuggestionEntry   *self,
 
   if (!is_absolute)
     {
-      gint x;
-      gint y;
-
       gtk_widget_translate_coordinates (GTK_WIDGET (self), toplevel, 0, 0, &x, &y);
       alloc.x += x;
       alloc.y += y;
     }
 
+  gdk_window_get_position (window, &x, &y);
+  alloc.x += x;
+  alloc.y += y;
+
   _dzl_suggestion_popover_adjust_margin (popover, &alloc);
 
   gtk_widget_set_size_request (GTK_WIDGET (popover), alloc.width, -1);


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