[gtk+] window: Add a GdkWindow:display property
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] window: Add a GdkWindow:display property
- Date: Fri, 28 Oct 2016 03:55:05 +0000 (UTC)
commit cd67c0d7ccedb4a09d0a10293b576a324f0a179b
Author: Benjamin Otte <otte redhat com>
Date: Thu Oct 27 15:38:41 2016 +0200
window: Add a GdkWindow:display property
... and make it an explicit property of the window struct instead of
looking it up in the visual.
gdk/gdkdisplay.c | 4 +++-
gdk/gdkinternals.h | 2 ++
gdk/gdkwindow.c | 34 +++++++++++++++++++++++++++++++---
3 files changed, 36 insertions(+), 4 deletions(-)
---
diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c
index 5609181..bef6be0 100644
--- a/gdk/gdkdisplay.c
+++ b/gdk/gdkdisplay.c
@@ -1877,7 +1877,9 @@ _gdk_display_create_window_impl (GdkDisplay *display,
GdkWindow *
_gdk_display_create_window (GdkDisplay *display)
{
- return g_object_new (GDK_DISPLAY_GET_CLASS (display)->window_type, NULL);
+ return g_object_new (GDK_DISPLAY_GET_CLASS (display)->window_type,
+ "display", display,
+ NULL);
}
/**
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index 81b1e93..4a63967 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -151,6 +151,8 @@ struct _GdkWindow
{
GObject parent_instance;
+ GdkDisplay *display;
+
GdkWindowImpl *impl; /* window-system-specific delegate object */
GdkWindow *parent;
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 30647c7..2b32b71 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -119,6 +119,7 @@ enum {
enum {
PROP_0,
PROP_CURSOR,
+ PROP_DISPLAY,
LAST_PROP
};
@@ -289,6 +290,22 @@ gdk_window_class_init (GdkWindowClass *klass)
P_("Cursor"),
GDK_TYPE_CURSOR,
G_PARAM_READWRITE);
+
+ /**
+ * GdkWindow:display:
+ *
+ * The #GdkDisplay connection of the window. See gdk_window_get_display()
+ * for details.
+ *
+ * Since: 3.90
+ */
+ properties[PROP_DISPLAY] =
+ g_param_spec_object ("display",
+ P_("Display"),
+ P_("Display"),
+ GDK_TYPE_DISPLAY,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+
g_object_class_install_properties (object_class, LAST_PROP, properties);
/**
@@ -401,6 +418,8 @@ gdk_window_finalize (GObject *object)
if (window->devices_inside)
g_list_free (window->devices_inside);
+ g_clear_object (&window->display);
+
G_OBJECT_CLASS (gdk_window_parent_class)->finalize (object);
}
@@ -410,7 +429,7 @@ gdk_window_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- GdkWindow *window = (GdkWindow *)object;
+ GdkWindow *window = GDK_WINDOW (object);
switch (prop_id)
{
@@ -418,6 +437,11 @@ gdk_window_set_property (GObject *object,
gdk_window_set_cursor (window, g_value_get_object (value));
break;
+ case PROP_DISPLAY:
+ window->display = g_value_dup_object (value);
+ g_assert (window->display != NULL);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -430,7 +454,7 @@ gdk_window_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- GdkWindow *window = (GdkWindow *) object;
+ GdkWindow *window = GDK_WINDOW (object);
switch (prop_id)
{
@@ -438,6 +462,10 @@ gdk_window_get_property (GObject *object,
g_value_set_object (value, gdk_window_get_cursor (window));
break;
+ case PROP_DISPLAY:
+ g_value_set_object (value, window->display);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -2095,7 +2123,7 @@ gdk_window_get_display (GdkWindow *window)
{
g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
- return gdk_screen_get_display (gdk_visual_get_screen (window->visual));
+ return window->display;
}
/**
* gdk_window_is_destroyed:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]