[gtk/matthiasc/surface-state-rework: 27/80] wayland: Layout drag icon from GdkSurface::layout
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/surface-state-rework: 27/80] wayland: Layout drag icon from GdkSurface::layout
- Date: Sat, 5 Dec 2020 17:42:38 +0000 (UTC)
commit a67b4187b31690c5d4b43c8adf0e0e7254599f80
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Wed Nov 25 15:06:09 2020 +0100
wayland: Layout drag icon from GdkSurface::layout
gdk/wayland/gdksurface-wayland.c | 25 ++++++++++++++++++++++++-
gtk/gtkdragicon.c | 20 ++++++++++++--------
2 files changed, 36 insertions(+), 9 deletions(-)
---
diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c
index 04a7643b46..8b16669213 100644
--- a/gdk/wayland/gdksurface-wayland.c
+++ b/gdk/wayland/gdksurface-wayland.c
@@ -283,6 +283,11 @@ static void gdk_wayland_surface_maybe_resize (GdkSurface *surface,
int height,
int scale);
+static void gdk_wayland_surface_resize (GdkSurface *surface,
+ int width,
+ int height,
+ int scale);
+
static void gdk_wayland_surface_configure (GdkSurface *surface);
static void maybe_set_gtk_surface_dbus_properties (GdkWaylandSurface *impl);
@@ -622,6 +627,17 @@ configure_popup_geometry (GdkSurface *surface)
impl->next_layout.configured_height);
}
+static void
+configure_drag_surface_geometry (GdkSurface *surface)
+{
+ GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
+
+ gdk_wayland_surface_resize (surface,
+ impl->next_layout.configured_width,
+ impl->next_layout.configured_height,
+ impl->scale);
+}
+
static void
gdk_wayland_surface_compute_size (GdkSurface *surface)
{
@@ -633,6 +649,8 @@ gdk_wayland_surface_compute_size (GdkSurface *surface)
configure_toplevel_geometry (surface);
else if (GDK_IS_POPUP (impl))
configure_popup_geometry (surface);
+ else if (GDK_IS_DRAG_SURFACE (impl))
+ configure_drag_surface_geometry (surface);
impl->next_layout.surface_geometry_dirty = FALSE;
}
@@ -5041,8 +5059,13 @@ gdk_wayland_drag_surface_present (GdkDragSurface *drag_surface,
GdkSurface *surface = GDK_SURFACE (drag_surface);
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
- gdk_wayland_surface_resize (surface, width, height, impl->scale);
gdk_wayland_surface_show (surface, FALSE);
+
+ impl->next_layout.configured_width = width;
+ impl->next_layout.configured_height = height;
+ impl->next_layout.surface_geometry_dirty = TRUE;
+ gdk_surface_request_layout (surface);
+
maybe_notify_mapped (surface);
return TRUE;
diff --git a/gtk/gtkdragicon.c b/gtk/gtkdragicon.c
index e239090011..dfcb029cc9 100644
--- a/gtk/gtkdragicon.c
+++ b/gtk/gtkdragicon.c
@@ -155,14 +155,7 @@ gtk_drag_icon_native_check_resize (GtkNative *native)
if (!_gtk_widget_get_alloc_needed (widget))
gtk_widget_ensure_allocate (widget);
else if (gtk_widget_get_visible (widget))
- {
- gtk_drag_icon_move_resize (icon);
- if (icon->surface)
- gtk_widget_allocate (widget,
- gdk_surface_get_width (icon->surface),
- gdk_surface_get_height (icon->surface),
- -1, NULL);
- }
+ gtk_drag_icon_move_resize (icon);
}
static void
@@ -174,6 +167,15 @@ gtk_drag_icon_native_init (GtkNativeInterface *iface)
iface->check_resize = gtk_drag_icon_native_check_resize;
}
+static void
+surface_layout (GdkSurface *surface,
+ int width,
+ int height,
+ GtkWidget *widget)
+{
+ gtk_widget_allocate (widget, width, height, -1, NULL);
+}
+
static gboolean
surface_render (GdkSurface *surface,
cairo_region_t *region,
@@ -192,6 +194,7 @@ gtk_drag_icon_realize (GtkWidget *widget)
gdk_surface_set_widget (icon->surface, widget);
+ g_signal_connect (icon->surface, "layout", G_CALLBACK (surface_layout), widget);
g_signal_connect (icon->surface, "render", G_CALLBACK (surface_render), widget);
GTK_WIDGET_CLASS (gtk_drag_icon_parent_class)->realize (widget);
@@ -211,6 +214,7 @@ gtk_drag_icon_unrealize (GtkWidget *widget)
if (icon->surface)
{
+ g_signal_handlers_disconnect_by_func (icon->surface, surface_layout, widget);
g_signal_handlers_disconnect_by_func (icon->surface, surface_render, widget);
gdk_surface_set_widget (icon->surface, NULL);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]