[gtk/wip/matthiasc/popup5: 52/187] window: Implement GtkNative
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/popup5: 52/187] window: Implement GtkNative
- Date: Thu, 23 May 2019 10:57:55 +0000 (UTC)
commit d23bec4cc068a330d1fc0d49edcf3328bb32dc5c
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Apr 29 05:44:57 2019 +0000
window: Implement GtkNative
Adapt GtkWindow to implement both GtkRoot and GtkNative.
gtk/gtkwindow.c | 51 ++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 40 insertions(+), 11 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 44b6b8f7ec..8f0da3efbd 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -62,6 +62,7 @@
#include "gtkpopoverprivate.h"
#include "gtkprivate.h"
#include "gtkroot.h"
+#include "gtknative.h"
#include "gtkseparatormenuitem.h"
#include "gtksettings.h"
#include "gtksnapshot.h"
@@ -279,6 +280,7 @@ typedef struct
GtkCssNode *decoration_node;
+ GdkSurface *surface;
GskRenderer *renderer;
GList *foci;
@@ -552,7 +554,8 @@ static void gtk_window_buildable_custom_finished (GtkBuildable *buildable,
gpointer user_data);
/* GtkRoot */
-static void gtk_window_root_interface_init (GtkRootInterface *iface);
+static void gtk_window_root_interface_init (GtkRootInterface *iface);
+static void gtk_window_native_interface_init (GtkNativeInterface *iface);
static void ensure_state_flag_backdrop (GtkWidget *widget);
static void unset_titlebar (GtkWindow *window);
@@ -569,6 +572,8 @@ G_DEFINE_TYPE_WITH_CODE (GtkWindow, gtk_window, GTK_TYPE_BIN,
G_ADD_PRIVATE (GtkWindow)
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
gtk_window_buildable_interface_init)
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_NATIVE,
+ gtk_window_native_interface_init)
G_IMPLEMENT_INTERFACE (GTK_TYPE_ROOT,
gtk_window_root_interface_init))
@@ -2355,21 +2360,36 @@ gtk_window_root_get_display (GtkRoot *root)
return priv->display;
}
+static void
+gtk_window_root_interface_init (GtkRootInterface *iface)
+{
+ iface->get_display = gtk_window_root_get_display;
+}
+
+static GdkSurface *
+gtk_window_native_get_surface (GtkNative *native)
+{
+ GtkWindow *self = GTK_WINDOW (native);
+ GtkWindowPrivate *priv = gtk_window_get_instance_private (self);
+
+ return priv->surface;
+}
+
static GskRenderer *
-gtk_window_root_get_renderer (GtkRoot *root)
+gtk_window_native_get_renderer (GtkNative *native)
{
- GtkWindow *self = GTK_WINDOW (root);
+ GtkWindow *self = GTK_WINDOW (native);
GtkWindowPrivate *priv = gtk_window_get_instance_private (self);
return priv->renderer;
}
static void
-gtk_window_root_get_surface_transform (GtkRoot *root,
- int *x,
- int *y)
+gtk_window_native_get_surface_transform (GtkNative *native,
+ int *x,
+ int *y)
{
- GtkWindow *self = GTK_WINDOW (root);
+ GtkWindow *self = GTK_WINDOW (native);
GtkStyleContext *context;
GtkBorder margin, border, padding;
@@ -2383,11 +2403,18 @@ gtk_window_root_get_surface_transform (GtkRoot *root,
}
static void
-gtk_window_root_interface_init (GtkRootInterface *iface)
+gtk_window_native_check_resize (GtkNative *native)
{
- iface->get_display = gtk_window_root_get_display;
- iface->get_renderer = gtk_window_root_get_renderer;
- iface->get_surface_transform = gtk_window_root_get_surface_transform;
+ gtk_window_check_resize (GTK_WINDOW (native));
+}
+
+static void
+gtk_window_native_interface_init (GtkNativeInterface *iface)
+{
+ iface->get_surface = gtk_window_native_get_surface;
+ iface->get_renderer = gtk_window_native_get_renderer;
+ iface->get_surface_transform = gtk_window_native_get_surface_transform;
+ iface->check_resize = gtk_window_native_check_resize;
}
/**
@@ -5660,6 +5687,8 @@ gtk_window_realize (GtkWidget *widget)
}
}
+ priv->surface = surface;
+
gtk_widget_set_surface (widget, surface);
g_signal_connect_swapped (surface, "notify::state", G_CALLBACK (surface_state_changed), widget);
g_signal_connect_swapped (surface, "size-changed", G_CALLBACK (gtk_window_configure), widget);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]