[gtk+/gdk-backend] gdk: Allow display subclasses to override the type used for windows
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gdk-backend] gdk: Allow display subclasses to override the type used for windows
- Date: Tue, 21 Dec 2010 02:59:42 +0000 (UTC)
commit 89868cb819ef33530834b4a73e770631d56c67b2
Author: Benjamin Otte <otte redhat com>
Date: Tue Dec 21 03:13:55 2010 +0100
gdk: Allow display subclasses to override the type used for windows
We want to have different window types for different displays, so we can
write code like this:
#if GDK_WINDOWING_X11
if (GDK_IS_X11_WINDOW (window))
{
/* do x11 stuff */
}
else
#endif
#if GDK_WINDOWING_WAYLAND
if (GDK_IS_WAYLAND_WINDOW (window))
{
/* do wayland stuff */
}
else
#endif
{
/* do stuff for unsupported system */
}
This requires different GdkWindow types and we currently don't have
that, as only the GdkWindowImpl differs. With this method, every backend
defines a custom type that's just a simple subclass of GdkWindow. This
way GdkWindow behaves like all the other types (visuals, screens,
displays) and we can write code like the above.
gdk/gdkdisplay.c | 3 ++-
gdk/gdkdisplayprivate.h | 2 ++
2 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c
index b833eac..c58270a 100644
--- a/gdk/gdkdisplay.c
+++ b/gdk/gdkdisplay.c
@@ -186,6 +186,7 @@ gdk_display_class_init (GdkDisplayClass *class)
object_class->dispose = gdk_display_dispose;
class->get_app_launch_context = gdk_display_real_get_app_launch_context;
+ class->window_type = GDK_TYPE_WINDOW;
/**
* GdkDisplay::opened:
@@ -2499,7 +2500,7 @@ _gdk_display_create_window_impl (GdkDisplay *display,
GdkWindow *
_gdk_display_create_window (GdkDisplay *display)
{
- return g_object_new (GDK_TYPE_WINDOW, NULL);
+ return g_object_new (GDK_DISPLAY_GET_CLASS (display)->window_type, NULL);
}
/**
diff --git a/gdk/gdkdisplayprivate.h b/gdk/gdkdisplayprivate.h
index 608e7b1..29ab846 100644
--- a/gdk/gdkdisplayprivate.h
+++ b/gdk/gdkdisplayprivate.h
@@ -115,6 +115,8 @@ struct _GdkDisplayClass
{
GObjectClass parent_class;
+ GType window_type; /* type for native windows for this display, set in class_init */
+
G_CONST_RETURN gchar * (*get_name) (GdkDisplay *display);
gint (*get_n_screens) (GdkDisplay *display);
GdkScreen * (*get_screen) (GdkDisplay *display,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]