broadway: Track popups

This is more or less a 1:1 copy of the X11 code.
This commit is contained in:
Matthias Clasen 2019-04-22 20:27:08 +00:00
parent 6f1c32b3eb
commit 2dd15346a7
4 changed files with 50 additions and 5 deletions

View File

@ -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;

View File

@ -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,

View File

@ -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)));
@ -225,13 +233,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);
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;
}
@ -394,6 +406,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,
@ -797,6 +815,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

View File

@ -60,6 +60,11 @@ struct _GdkBroadwaySurface
GArray *node_data;
GPtrArray *node_data_textures;
int offset_x;
int offset_y;
GList *popups;
};
struct _GdkBroadwaySurfaceClass