window: Implement GtkNative
Adapt GtkWindow to implement both GtkRoot and GtkNative.
This commit is contained in:
@@ -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 GskRenderer *
|
||||
gtk_window_root_get_renderer (GtkRoot *root)
|
||||
static GdkSurface *
|
||||
gtk_window_native_get_surface (GtkNative *native)
|
||||
{
|
||||
GtkWindow *self = GTK_WINDOW (root);
|
||||
GtkWindow *self = GTK_WINDOW (native);
|
||||
GtkWindowPrivate *priv = gtk_window_get_instance_private (self);
|
||||
|
||||
return priv->surface;
|
||||
}
|
||||
|
||||
static GskRenderer *
|
||||
gtk_window_native_get_renderer (GtkNative *native)
|
||||
{
|
||||
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)
|
||||
static GskRenderer *
|
||||
gtk_window_root_get_renderer (GtkRoot *root)
|
||||
{
|
||||
GtkWindow *self = GTK_WINDOW (root);
|
||||
return gtk_window_native_get_renderer (GTK_NATIVE (root));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_window_native_get_surface_transform (GtkNative *native,
|
||||
int *x,
|
||||
int *y)
|
||||
{
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user