[gtk/wip/matthiasc/popup4: 38/94] window: Stop using gtk_widget_register_surface
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/popup4: 38/94] window: Stop using gtk_widget_register_surface
- Date: Sat, 27 Apr 2019 04:44:36 +0000 (UTC)
commit c10e270bd994910e267518c0779c19aaf26ffd5a
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Apr 19 20:14:09 2019 +0000
window: Stop using gtk_widget_register_surface
The GtkRoot implementations are expected to handle
the necessary surface setup themselves, going forward.
gtk/gtkwindow.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 51 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index dd33c78fb5..9b8a1b071e 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -417,7 +417,18 @@ static void gtk_window_size_allocate (GtkWidget *widget,
static gboolean gtk_window_close_request (GtkWindow *window);
static void gtk_window_focus_in (GtkWidget *widget);
static void gtk_window_focus_out (GtkWidget *widget);
-static void surface_state_changed (GtkWidget *widget);
+
+static void surface_state_changed (GtkWidget *widget);
+static void surface_size_changed (GtkWidget *widget,
+ int width,
+ int height);
+static gboolean surface_render (GdkSurface *surface,
+ cairo_region_t *region,
+ GtkWidget *widget);
+static gboolean surface_event (GdkSurface *surface,
+ GdkEvent *event,
+ GtkWidget *widget);
+
static void gtk_window_remove (GtkContainer *container,
GtkWidget *widget);
static void gtk_window_forall (GtkContainer *container,
@@ -5761,9 +5772,12 @@ gtk_window_realize (GtkWidget *widget)
}
gtk_widget_set_surface (widget, surface);
+ gdk_surface_set_widget (surface, widget);
+
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);
- gtk_widget_register_surface (widget, surface);
+ g_signal_connect_swapped (surface, "size-changed", G_CALLBACK (surface_size_changed), widget);
+ g_signal_connect (surface, "render", G_CALLBACK (surface_render), widget);
+ g_signal_connect (surface, "event", G_CALLBACK (surface_event), widget);
GTK_WIDGET_CLASS (gtk_window_parent_class)->realize (widget);
@@ -5852,6 +5866,7 @@ gtk_window_unrealize (GtkWidget *widget)
GtkWindow *window = GTK_WINDOW (widget);
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
GtkWindowGeometryInfo *info;
+ GdkSurface *surface;
/* On unrealize, we reset the size of the window such
* that we will re-apply the default sizing stuff
@@ -5889,12 +5904,13 @@ gtk_window_unrealize (GtkWidget *widget)
gsk_renderer_unrealize (priv->renderer);
g_clear_object (&priv->renderer);
- g_signal_handlers_disconnect_by_func (_gtk_widget_get_surface (widget),
- G_CALLBACK (surface_state_changed),
- widget);
- g_signal_handlers_disconnect_by_func (_gtk_widget_get_surface (widget),
- G_CALLBACK (gtk_window_configure),
- widget);
+ surface = _gtk_widget_get_surface (widget);
+
+ g_signal_handlers_disconnect_by_func (surface, surface_state_changed, widget);
+ g_signal_handlers_disconnect_by_func (surface, surface_size_changed, widget);
+ g_signal_handlers_disconnect_by_func (surface, surface_render, widget);
+ g_signal_handlers_disconnect_by_func (surface, surface_event, widget);
+ gdk_surface_set_widget (surface, NULL);
GTK_WIDGET_CLASS (gtk_window_parent_class)->unrealize (widget);
@@ -6210,6 +6226,32 @@ surface_state_changed (GtkWidget *widget)
}
}
+static void
+surface_size_changed (GtkWidget *widget,
+ int width,
+ int height)
+{
+ gtk_window_configure (GTK_WINDOW (widget), width, height);
+}
+
+static gboolean
+surface_render (GdkSurface *surface,
+ cairo_region_t *region,
+ GtkWidget *widget)
+{
+ gtk_widget_render (widget, surface, region);
+ return TRUE;
+}
+
+static gboolean
+surface_event (GdkSurface *surface,
+ GdkEvent *event,
+ GtkWidget *widget)
+{
+ gtk_main_do_event (event);
+ return TRUE;
+}
+
/* the accel_key and accel_mods fields of the key have to be setup
* upon calling this function. it’ll then return whether that key
* is at all used as accelerator, and if so will OR in the
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]