[gtk/wip/matthiasc/popup4: 105/115] broadway: Track popups



commit 000ca4f8c32f67f69fadb45f28fe431b92aa77a9
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Apr 22 20:27:08 2019 +0000

    broadway: Track popups
    
    This is more or less a 1:1 copy of the X11 code.

 gdk/broadway/gdkeventsource.c      |  2 ++
 gdk/broadway/gdkprivate-broadway.h |  1 +
 gdk/broadway/gdksurface-broadway.c | 47 ++++++++++++++++++++++++++++++++++----
 gdk/broadway/gdksurface-broadway.h |  5 ++++
 4 files changed, 50 insertions(+), 5 deletions(-)
---
diff --git a/gdk/broadway/gdkeventsource.c b/gdk/broadway/gdkeventsource.c
index 506740fa16..7f791ad545 100644
--- a/gdk/broadway/gdkeventsource.c
+++ b/gdk/broadway/gdkeventsource.c
@@ -288,6 +288,8 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
         surface->x = message->configure_notify.x;
         surface->y = message->configure_notify.y;
 
+        gdk_broadway_surface_update_popups (surface);
+
         event = gdk_event_new (GDK_CONFIGURE);
         event->any.surface = g_object_ref (surface);
         event->configure.x = message->configure_notify.x;
diff --git a/gdk/broadway/gdkprivate-broadway.h b/gdk/broadway/gdkprivate-broadway.h
index 784947c00f..9fd41bcc53 100644
--- a/gdk/broadway/gdkprivate-broadway.h
+++ b/gdk/broadway/gdkprivate-broadway.h
@@ -68,6 +68,7 @@ void     _gdk_broadway_roundtrip_notify           (GdkSurface  *surface,
 void     _gdk_broadway_surface_grab_check_destroy (GdkSurface *surface);
 void     _gdk_broadway_surface_grab_check_unmap   (GdkSurface *surface,
                                                    gulong     serial);
+void     gdk_broadway_surface_update_popups       (GdkSurface *surface);
 
 void _gdk_keymap_keys_changed     (GdkDisplay      *display);
 gint _gdk_broadway_get_group_for_state (GdkDisplay      *display,
diff --git a/gdk/broadway/gdksurface-broadway.c b/gdk/broadway/gdksurface-broadway.c
index c4740d3fa6..e26aecdf3a 100644
--- a/gdk/broadway/gdksurface-broadway.c
+++ b/gdk/broadway/gdksurface-broadway.c
@@ -66,13 +66,21 @@ gdk_broadway_surface_init (GdkBroadwaySurface *impl)
 static void
 gdk_broadway_surface_finalize (GObject *object)
 {
+  GdkSurface *surface;
   GdkBroadwaySurface *impl;
   GdkBroadwayDisplay *broadway_display;
 
   g_return_if_fail (GDK_IS_BROADWAY_SURFACE (object));
 
+  surface = GDK_SURFACE (object);
   impl = GDK_BROADWAY_SURFACE (object);
 
+  if (surface->parent)
+    {
+      GdkBroadwaySurface *parent_impl = GDK_BROADWAY_SURFACE (surface->parent);
+      parent_impl->popups = g_list_remove (parent_impl->popups, surface);
+    }
+
   _gdk_broadway_surface_grab_check_destroy (GDK_SURFACE (impl));
 
   broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (GDK_SURFACE (impl)));
@@ -222,13 +230,17 @@ _gdk_broadway_display_create_surface (GdkDisplay     *display,
                                                surface->surface_type == GDK_SURFACE_TEMP);
   g_hash_table_insert (broadway_display->id_ht, GINT_TO_POINTER(impl->id), surface);
 
-  g_assert (surface->surface_type == GDK_SURFACE_TOPLEVEL ||
-            surface->surface_type == GDK_SURFACE_TEMP);
-
-  broadway_display->toplevels = g_list_prepend (broadway_display->toplevels, impl);
+  if (!surface->parent)
+    broadway_display->toplevels = g_list_prepend (broadway_display->toplevels, impl);
 
   connect_frame_clock (surface);
 
+  if (parent)
+    {
+      GdkBroadwaySurface *parent_impl = GDK_BROADWAY_SURFACE (parent);
+      parent_impl->popups = g_list_prepend (parent_impl->popups, surface);
+    }
+
   return surface;
 }
 
@@ -391,6 +403,12 @@ gdk_broadway_surface_move_resize (GdkSurface *surface,
         }
     }
 
+  if (surface->parent)
+    {
+      impl->offset_x = x - surface->parent->x;
+      impl->offset_y = y - surface->parent->y;
+    }
+
   _gdk_broadway_server_surface_move_resize (broadway_display->server,
                                             impl->id,
                                             with_move,
@@ -794,6 +812,25 @@ gdk_broadway_surface_set_functions (GdkSurface    *surface,
     return;
 }
 
+void
+gdk_broadway_surface_update_popups (GdkSurface *parent)
+{
+  GdkBroadwaySurface *impl = GDK_BROADWAY_SURFACE (parent);
+  GList *l;
+
+  for (l = impl->popups; l; l = l->next)
+    {
+      GdkBroadwaySurface *popup_impl = l->data;
+      GdkSurface *popup = GDK_SURFACE (popup_impl);
+      int new_x = parent->x + popup_impl->offset_x;
+      int new_y = parent->y + popup_impl->offset_y;
+
+      if (new_x != popup->x || new_y != popup->y)
+        gdk_broadway_surface_move_resize (popup, TRUE, new_x, new_y, popup->width, popup->height);
+      gdk_broadway_surface_restack_toplevel (popup, parent, TRUE);
+    }
+}
+
 typedef struct _MoveResizeData MoveResizeData;
 
 struct _MoveResizeData
@@ -1186,7 +1223,7 @@ gdk_broadway_surface_begin_resize_drag (GdkSurface     *surface,
   mv_resize->is_resize = TRUE;
   mv_resize->moveresize_button = button;
   mv_resize->resize_edge = edge;
-  mv_resize->moveresize_x = x  + surface->x;
+  mv_resize->moveresize_x = x + surface->x;
   mv_resize->moveresize_y = y + surface->y;
   mv_resize->moveresize_surface = g_object_ref (surface);
 
diff --git a/gdk/broadway/gdksurface-broadway.h b/gdk/broadway/gdksurface-broadway.h
index a2c0b96cf7..4c47a887a6 100644
--- a/gdk/broadway/gdksurface-broadway.h
+++ b/gdk/broadway/gdksurface-broadway.h
@@ -60,6 +60,11 @@ struct _GdkBroadwaySurface
 
   GArray *node_data;
   GPtrArray *node_data_textures;
+
+  int offset_x;
+  int offset_y;
+
+  GList *popups;
 };
 
 struct _GdkBroadwaySurfaceClass


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