[gtk/wip/matthiasc/popup5: 5/145] window: Implement GtkNative
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/popup5: 5/145] window: Implement GtkNative
- Date: Sun, 26 May 2019 19:02:09 +0000 (UTC)
commit 346aff71dab8fb980e252098b4026dba71ecfca7
Author: Matthias Clasen <mclasen redhat com>
Date: Sun May 26 17:43:46 2019 +0000
window: Implement GtkNative
Adapt GtkWindow to implement both GtkRoot and GtkNative.
gtk/gtkwindow.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 52 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 44b6b8f7ec..6c974394aa 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 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 GskRenderer *
+gtk_window_root_get_renderer (GtkRoot *root)
+{
+ return gtk_window_native_get_renderer (GTK_NATIVE (root));
+}
+
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;
@@ -2382,6 +2402,20 @@ gtk_window_root_get_surface_transform (GtkRoot *root,
*y = margin.top + border.top + padding.top;
}
+static void
+gtk_window_root_get_surface_transform (GtkRoot *root,
+ int *x,
+ int *y)
+{
+ gtk_window_native_get_surface_transform (GTK_NATIVE (root), x, y);
+}
+
+static void
+gtk_window_native_check_resize (GtkNative *native)
+{
+ gtk_window_check_resize (GTK_WINDOW (native));
+}
+
static void
gtk_window_root_interface_init (GtkRootInterface *iface)
{
@@ -2390,6 +2424,15 @@ gtk_window_root_interface_init (GtkRootInterface *iface)
iface->get_surface_transform = gtk_window_root_get_surface_transform;
}
+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;
+}
+
/**
* gtk_window_new:
* @type: type of window
@@ -5660,6 +5703,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]