From 2b9f0b48174cb29ccd445a40e80c01fb1bb04782 Mon Sep 17 00:00:00 2001 From: Jan Arne Petersen Date: Sat, 19 Jan 2013 23:43:27 +0100 Subject: [PATCH] wayland: Make GdkWaylandDisplay public Allows to access Wayland specific display information like wl_display etc. Add gdk_wayland_display_get_wl_display for getting the Wayland wl_display. --- gdk/wayland/Makefile.am | 4 ++ gdk/wayland/gdkdisplay-wayland.c | 70 +++++++++++++++++++++++++++++--- gdk/wayland/gdkdisplay-wayland.h | 12 ------ gdk/wayland/gdkprivate-wayland.h | 1 + gdk/wayland/gdkwayland.h | 4 ++ gdk/wayland/gdkwaylanddisplay.h | 53 ++++++++++++++++++++++++ 6 files changed, 127 insertions(+), 17 deletions(-) create mode 100644 gdk/wayland/gdkwaylanddisplay.h diff --git a/gdk/wayland/Makefile.am b/gdk/wayland/Makefile.am index 01695938f..5033397b1 100644 --- a/gdk/wayland/Makefile.am +++ b/gdk/wayland/Makefile.am @@ -2,6 +2,7 @@ include $(top_srcdir)/Makefile.decl libgdkincludedir = $(includedir)/gtk-3.0/gdk +libgdkwaylandincludedir = $(includedir)/gtk-3.0/gdk/wayland AM_CPPFLAGS = \ -DG_LOG_DOMAIN=\"Gdk\" \ @@ -36,4 +37,7 @@ libgdk_wayland_la_SOURCES = \ libgdkinclude_HEADERS = \ gdkwayland.h +libgdkwaylandinclude_HEADERS = \ + gdkwaylanddisplay.h + -include $(top_srcdir)/git.mk diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c index 45e5d5af3..dceb8e83b 100644 --- a/gdk/wayland/gdkdisplay-wayland.c +++ b/gdk/wayland/gdkdisplay-wayland.c @@ -36,7 +36,7 @@ static void _gdk_wayland_display_load_cursor_theme (GdkWaylandDisplay *wayland_display); -G_DEFINE_TYPE (GdkWaylandDisplay, _gdk_wayland_display, GDK_TYPE_DISPLAY) +G_DEFINE_TYPE (GdkWaylandDisplay, gdk_wayland_display, GDK_TYPE_DISPLAY) static void gdk_input_init (GdkDisplay *display) @@ -212,7 +212,7 @@ gdk_wayland_display_dispose (GObject *object) display_wayland->event_source = NULL; } - G_OBJECT_CLASS (_gdk_wayland_display_parent_class)->dispose (object); + G_OBJECT_CLASS (gdk_wayland_display_parent_class)->dispose (object); } static void @@ -231,7 +231,7 @@ gdk_wayland_display_finalize (GObject *object) g_free (display_wayland->startup_notification_id); - G_OBJECT_CLASS (_gdk_wayland_display_parent_class)->finalize (object); + G_OBJECT_CLASS (gdk_wayland_display_parent_class)->finalize (object); } static const gchar * @@ -519,7 +519,7 @@ gdk_wayland_display_pop_error_trap (GdkDisplay *display, } static void -_gdk_wayland_display_class_init (GdkWaylandDisplayClass * class) +gdk_wayland_display_class_init (GdkWaylandDisplayClass * class) { GObjectClass *object_class = G_OBJECT_CLASS (class); GdkDisplayClass *display_class = GDK_DISPLAY_CLASS (class); @@ -574,7 +574,7 @@ _gdk_wayland_display_class_init (GdkWaylandDisplayClass * class) } static void -_gdk_wayland_display_init (GdkWaylandDisplay *display) +gdk_wayland_display_init (GdkWaylandDisplay *display) { _gdk_wayland_display_manager_add_display (gdk_display_manager_get (), GDK_DISPLAY (display)); @@ -612,3 +612,63 @@ _gdk_wayland_display_update_serial (GdkWaylandDisplay *wayland_display, if (serial > wayland_display->serial) wayland_display->serial = serial; } + +/** + * gdk_wayland_display_get_wl_display + * @display: (type GdkWaylandDisplay): a #GdkDisplay + * + * Returns the Wayland wl_display of a #GdkDisplay + * + * Returns: (transfer none): a Wayland wl_display + * + * Since: 3.8 + */ +struct wl_display * +gdk_wayland_display_get_wl_display(GdkDisplay *display) +{ + GdkWaylandDisplay *wayland_display = GDK_WAYLAND_DISPLAY(display); + + g_return_val_if_fail (GDK_IS_WAYLAND_DISPLAY(display), NULL); + + return wayland_display->wl_display; +} + +/** + * gdk_wayland_display_get_wl_compositor + * @display: (type GdkWaylandDisplay): a #GdkDisplay + * + * Returns the Wayland global singleton compositor of a #GdkDisplay + * + * Returns: (transfer none): a Wayland wl_compositor + * + * Since: 3.8 + */ +struct wl_compositor * +gdk_wayland_display_get_wl_compositor (GdkDisplay *display) +{ + GdkWaylandDisplay *wayland_display = GDK_WAYLAND_DISPLAY(display); + + g_return_val_if_fail (GDK_IS_WAYLAND_DISPLAY(display), NULL); + + return wayland_display->compositor; +} + +/** + * gdk_wayland_display_get_wl_shell + * @display: (type GdkWaylandDisplay): a #GdkDisplay + * + * Returns the Wayland global singleton shell of a #GdkDisplay + * + * Returns: (transfer none): a Wayland wl_shell + * + * Since: 3.8 + */ +struct wl_shell * +gdk_wayland_display_get_wl_shell (GdkDisplay *display) +{ + GdkWaylandDisplay *wayland_display = GDK_WAYLAND_DISPLAY(display); + + g_return_val_if_fail (GDK_IS_WAYLAND_DISPLAY(display), NULL); + + return wayland_display->shell; +} diff --git a/gdk/wayland/gdkdisplay-wayland.h b/gdk/wayland/gdkdisplay-wayland.h index ae95a17e7..fc9042904 100644 --- a/gdk/wayland/gdkdisplay-wayland.h +++ b/gdk/wayland/gdkdisplay-wayland.h @@ -37,16 +37,6 @@ G_BEGIN_DECLS -typedef struct _GdkWaylandDisplay GdkWaylandDisplay; -typedef struct _GdkWaylandDisplayClass GdkWaylandDisplayClass; - -#define GDK_TYPE_WAYLAND_DISPLAY (_gdk_wayland_display_get_type()) -#define GDK_WAYLAND_DISPLAY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_DISPLAY, GdkWaylandDisplay)) -#define GDK_WAYLAND_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WAYLAND_DISPLAY, GdkWaylandDisplayClass)) -#define GDK_IS_WAYLAND_DISPLAY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_DISPLAY)) -#define GDK_IS_WAYLAND_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WAYLAND_DISPLAY)) -#define GDK_WAYLAND_DISPLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WAYLAND_DISPLAY, GdkWaylandDisplayClass)) - struct _GdkWaylandDisplay { GdkDisplay parent_instance; @@ -87,8 +77,6 @@ struct _GdkWaylandDisplayClass GdkDisplayClass parent_class; }; -GType _gdk_wayland_display_get_type (void); - G_END_DECLS #endif /* __GDK_WAYLAND_DISPLAY__ */ diff --git a/gdk/wayland/gdkprivate-wayland.h b/gdk/wayland/gdkprivate-wayland.h index 8a3161b2b..73810cacd 100644 --- a/gdk/wayland/gdkprivate-wayland.h +++ b/gdk/wayland/gdkprivate-wayland.h @@ -31,6 +31,7 @@ #include #include +#include #include #include diff --git a/gdk/wayland/gdkwayland.h b/gdk/wayland/gdkwayland.h index 8464a5f72..2b4b7b247 100644 --- a/gdk/wayland/gdkwayland.h +++ b/gdk/wayland/gdkwayland.h @@ -27,6 +27,10 @@ #include +#define __GDKWAYLAND_H_INSIDE__ + +#include + G_BEGIN_DECLS typedef struct _GdkWaylandDisplayManager GdkWaylandDisplayManager; diff --git a/gdk/wayland/gdkwaylanddisplay.h b/gdk/wayland/gdkwaylanddisplay.h new file mode 100644 index 000000000..336fff370 --- /dev/null +++ b/gdk/wayland/gdkwaylanddisplay.h @@ -0,0 +1,53 @@ +/* GDK - The GIMP Drawing Kit + * Copyright (C) 2013 Jan Arne Petersen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + */ + +#ifndef __GDK_WAYLAND_DISPLAY_H__ +#define __GDK_WAYLAND_DISPLAY_H__ + +#if !defined (__GDKWAYLAND_H_INSIDE__) && !defined (GDK_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +#include + +G_BEGIN_DECLS + +#ifdef GDK_COMPILATION +typedef struct _GdkWaylandDisplay GdkWaylandDisplay; +#else +typedef GdkDisplay GdkWaylandDisplay; +#endif +typedef struct _GdkWaylandDisplayClass GdkWaylandDisplayClass; + +#define GDK_TYPE_WAYLAND_DISPLAY (gdk_wayland_display_get_type()) +#define GDK_WAYLAND_DISPLAY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_DISPLAY, GdkWaylandDisplay)) +#define GDK_WAYLAND_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WAYLAND_DISPLAY, GdkWaylandDisplayClass)) +#define GDK_IS_WAYLAND_DISPLAY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_DISPLAY)) +#define GDK_IS_WAYLAND_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WAYLAND_DISPLAY)) +#define GDK_WAYLAND_DISPLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WAYLAND_DISPLAY, GdkWaylandDisplayClass)) + +GType gdk_wayland_display_get_type (void); + +struct wl_display *gdk_wayland_display_get_wl_display (GdkDisplay *display); +struct wl_compositor *gdk_wayland_display_get_wl_compositor (GdkDisplay *display); +struct wl_shell *gdk_wayland_display_get_wl_shell (GdkDisplay *display); + +G_END_DECLS + +#endif /* __GDK_WAYLAND_DISPLAY_H__ */ -- 2.43.2