[gtk/present-toplevel-2: 66/71] surface: Implement GdkDragSurface



commit b37354cc86de46c0d0a6dd65d4fe2e53b1202ca1
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Mar 3 15:57:54 2020 -0800

    surface: Implement GdkDragSurface

 gdk/gdksurface.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)
---
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index 67561b66a0..48101db289 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -40,6 +40,7 @@
 #include "gdkglcontextprivate.h"
 #include "gdkpopupprivate.h"
 #include "gdktoplevelprivate.h"
+#include "gdkdragsurfaceprivate.h"
 #include "gdk-private.h"
 
 #include <math.h>
@@ -113,12 +114,15 @@ static GParamSpec *properties[LAST_PROP] = { NULL, };
 
 static void gdk_surface_popup_init (GdkPopupInterface *iface);
 static void gdk_surface_toplevel_init (GdkToplevelInterface *iface);
+static void gdk_surface_drag_surface_init (GdkDragSurfaceInterface *iface);
 
 G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GdkSurface, gdk_surface, G_TYPE_OBJECT,
                                   G_IMPLEMENT_INTERFACE (GDK_TYPE_POPUP,
                                                          gdk_surface_popup_init)
                                   G_IMPLEMENT_INTERFACE (GDK_TYPE_TOPLEVEL,
-                                                         gdk_surface_toplevel_init))
+                                                         gdk_surface_toplevel_init)
+                                  G_IMPLEMENT_INTERFACE (GDK_TYPE_DRAG_SURFACE,
+                                                         gdk_surface_drag_surface_init))
 
 static gboolean
 gdk_surface_real_beep (GdkSurface *surface)
@@ -2147,6 +2151,27 @@ gdk_surface_toplevel_init (GdkToplevelInterface *iface)
   iface->show_window_menu = gdk_toplevel_surface_show_window_menu;
 }
 
+static gboolean
+gdk_drag_surface_real_present (GdkDragSurface *drag_surface,
+                               int             width,
+                               int             height)
+{
+  GdkSurface *surface = GDK_SURFACE (drag_surface);
+
+  g_return_val_if_fail (surface->surface_type == GDK_SURFACE_TEMP, FALSE);
+
+  GDK_SURFACE_GET_CLASS (surface)->toplevel_resize (surface, width, height);
+  gdk_surface_show_internal (surface, TRUE);
+
+  return TRUE;
+}
+
+static void
+gdk_surface_drag_surface_init (GdkDragSurfaceInterface *iface)
+{
+  iface->present = gdk_drag_surface_real_present;
+}
+
 static void
 gdk_surface_set_cursor_internal (GdkSurface *surface,
                                  GdkDevice *device,


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