[gtk+/wip/attachment: 5/5] x11: allow setting initial window position on map



commit 6bc3457a1960715c1669c52d1ea495c94deedca1
Author: William Hua <william hua canonical com>
Date:   Wed Sep 16 13:55:30 2015 -0400

    x11: allow setting initial window position on map

 gdk/x11/gdkdisplay-x11.c |   19 +++++++++++++++++--
 gdk/x11/gdkwindow-x11.c  |   13 ++++++++++++-
 gdk/x11/gdkwindow-x11.h  |    4 ++++
 3 files changed, 33 insertions(+), 3 deletions(-)
---
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index 0030c6c..6b02edf 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -705,7 +705,11 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
             }
 
          if (toplevel)
-            gdk_window_freeze_toplevel_updates (window);
+            {
+              toplevel->is_mapped = FALSE;
+
+              gdk_window_freeze_toplevel_updates (window);
+            }
 
           _gdk_x11_window_grab_check_unmap (window, xevent->xany.serial);
         }
@@ -729,7 +733,18 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
                                         0);
 
          if (toplevel)
-           gdk_window_thaw_toplevel_updates (window);
+            {
+              toplevel->is_mapped = TRUE;
+
+              if (toplevel->move_on_map)
+                {
+                  toplevel->move_on_map = FALSE;
+
+                  gdk_window_move (window, toplevel->initial_position.x, toplevel->initial_position.y);
+                }
+
+              gdk_window_thaw_toplevel_updates (window);
+            }
        }
 
       break;
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index 1d1d378..69d52de 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -5797,6 +5797,7 @@ gdk_x11_window_set_attachment_parameters (GdkWindow                     *window,
   gint secondary_axis;
   gint value;
   GdkPoint offset = { 0 };
+  GdkToplevelX11 *toplevel = NULL;
 
   if (!parameters)
     return;
@@ -5981,7 +5982,17 @@ gdk_x11_window_set_attachment_parameters (GdkWindow                     *window,
       y = bounds.y;
     }
 
-  gdk_window_move (window, x, y);
+  if (GDK_IS_WINDOW_IMPL_X11 (window->impl))
+    toplevel = GDK_WINDOW_IMPL_X11 (window->impl)->toplevel;
+
+  if (toplevel && !toplevel->is_mapped)
+    {
+      toplevel->move_on_map = TRUE;
+      toplevel->initial_position.x = x;
+      toplevel->initial_position.y = y;
+    }
+  else
+    gdk_window_move (window, x, y);
 }
 
 static void
diff --git a/gdk/x11/gdkwindow-x11.h b/gdk/x11/gdkwindow-x11.h
index 2bc2417..64a7f75 100644
--- a/gdk/x11/gdkwindow-x11.h
+++ b/gdk/x11/gdkwindow-x11.h
@@ -147,6 +147,10 @@ struct _GdkToplevelX11
   guint pending_counter_value_is_extended : 1;
   guint configure_counter_value_is_extended : 1;
 
+  guint is_mapped : 1;
+  guint move_on_map : 1;
+  GdkPoint initial_position;
+
   gulong map_serial;   /* Serial of last transition from unmapped */
   
   cairo_surface_t *icon_pixmap;


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