[gtk+] Derive GdkDisplayManager for quartz
- From: Kristian Rietveld <kristian src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Derive GdkDisplayManager for quartz
- Date: Wed, 22 Dec 2010 16:51:18 +0000 (UTC)
commit 733c8fc8e79af89ac33bc5579a8add345ceb01f6
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Dec 17 11:38:02 2010 -0500
Derive GdkDisplayManager for quartz
gdk/quartz/Makefile.am | 1 +
gdk/quartz/gdkdisplay-quartz.c | 25 ++++---
gdk/quartz/gdkdisplaymanager-quartz.c | 132 +++++++++++++++++++++++++++++++++
gdk/quartz/gdkevents-quartz.c | 2 +-
gdk/quartz/gdkinput.c | 27 +-------
gdk/quartz/gdkinputprivate.h | 3 +-
gdk/quartz/gdkprivate-quartz.h | 6 +-
7 files changed, 155 insertions(+), 41 deletions(-)
---
diff --git a/gdk/quartz/Makefile.am b/gdk/quartz/Makefile.am
index a1d5664..7774dbc 100644
--- a/gdk/quartz/Makefile.am
+++ b/gdk/quartz/Makefile.am
@@ -25,6 +25,7 @@ libgdk_quartz_la_SOURCES = \
gdkdevice-core.c \
gdkdevicemanager-core.c \
gdkdisplay-quartz.c \
+ gdkdisplaymanager-quartz.c \
gdkdnd-quartz.c \
gdkevents-quartz.c \
gdkeventloop-quartz.c \
diff --git a/gdk/quartz/gdkdisplay-quartz.c b/gdk/quartz/gdkdisplay-quartz.c
index 2883136..162569c 100644
--- a/gdk/quartz/gdkdisplay-quartz.c
+++ b/gdk/quartz/gdkdisplay-quartz.c
@@ -37,12 +37,6 @@ gdk_quartz_display_get_default_group (GdkDisplay *display)
return NULL;
}
-void
-_gdk_windowing_set_default_display (GdkDisplay *display)
-{
- g_assert (display == NULL || _gdk_display == display);
-}
-
GdkDeviceManager *
_gdk_device_manager_new (GdkDisplay *display)
{
@@ -52,7 +46,7 @@ _gdk_device_manager_new (GdkDisplay *display)
}
GdkDisplay *
-gdk_display_open (const gchar *display_name)
+_gdk_quartz_display_open (const gchar *display_name)
{
if (_gdk_display != NULL)
return NULL;
@@ -60,7 +54,7 @@ gdk_display_open (const gchar *display_name)
/* Initialize application */
[NSApplication sharedApplication];
- _gdk_display = g_object_new (GDK_TYPE_DISPLAY, NULL);
+ _gdk_display = g_object_new (_gdk_quartz_display_get_type (), NULL);
_gdk_display->device_manager = _gdk_device_manager_new (_gdk_display);
_gdk_screen = _gdk_screen_quartz_new ();
@@ -69,9 +63,9 @@ gdk_display_open (const gchar *display_name)
_gdk_windowing_window_init ();
- _gdk_events_init ();
+ _gdk_quartz_events_init ();
- _gdk_input_init ();
+ _gdk_quartz_input_init ();
#if 0
/* FIXME: Remove the #if 0 when we have these functions */
@@ -199,6 +193,17 @@ G_DEFINE_TYPE (GdkDisplayQuartz, _gdk_display_quartz, GDK_TYPE_DISPLAY)
static void
_gdk_display_quartz_init (GdkDisplayQuartz *display)
{
+ gdk_x11_display_manager_add_display (gdk_display_nmanager_get (),
+ GDK_DISPLAY_OBJECT (display));
+}
+
+static void
+_gdk_display_quartz_dispose (GObject *object)
+{
+ _gdk_quartz_display_manager_remove_display (gdk_display_manager_get (),
+ GDK_DISPLAY_OBJECT (object));
+
+ G_OBJECT_CLASS (_gdk_display_quartz_parent_class)->dispose (object);
}
static void
diff --git a/gdk/quartz/gdkdisplaymanager-quartz.c b/gdk/quartz/gdkdisplaymanager-quartz.c
new file mode 100644
index 0000000..2df3c7c
--- /dev/null
+++ b/gdk/quartz/gdkdisplaymanager-quartz.c
@@ -0,0 +1,132 @@
+/* GDK - The GIMP Drawing Kit
+ * gdkdisplaymanager-quartz.c
+ *
+ * Copyright 2010 Red Hat, Inc.
+ *
+ * Author: Matthias clasen
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include "gdkdisplay-quartz.h"
+#include "gdkprivate-quartz.h"
+
+#include "gdkdisplaymanagerprivate.h"
+#include "gdkinternals.h"
+
+#define GDK_TYPE_DISPLAY_MANAGER_QUARTZ (gdk_display_manager_quartz_get_type ())
+#define GDK_DISPLAY_MANAGER_QUARTZ(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DISPLAY_MANAGER_QUARTZ, GdkDisplayManagerQuartz))
+
+typedef struct _GdkDisplayManagerQuartz GdkDisplayManagerQuartz;
+typedef struct _GdkDisplayManagerClass GdkDisplayManagerQuartzClass;
+
+struct _GdkDisplayManagerQuartz
+{
+ GdkDisplayManager parent;
+
+ GdkDisplay *default_display;
+ GSList *displays;
+};
+
+G_DEFINE_TYPE (GdkDisplayManagerQuartz, gdk_display_manager_quartz, GDK_TYPE_DISPLAY_MANAGER)
+
+static GdkDisplay *
+gdk_display_manager_quartz_open_display (GdkDisplayManager *manager,
+ const gchar *name)
+{
+ return _gdk_quartz_display_open (name);
+}
+
+static GSList *
+gdk_display_manager_quartz_list_displays (GdkDisplayManager *manager)
+{
+ GdkDisplayManagerQuartz *manager_quartz = GDK_DISPLAY_MANAGER_QUARTZ (manager);
+
+ return g_slist_copy (manager_quartz->displays);
+}
+
+static GdkDisplay *
+gdk_display_manager_quartz_get_default_display (GdkDisplayManager *manager)
+{
+ return GDK_DISPLAY_MANAGER_QUARTZ (manager)->default_display;
+}
+
+static void
+gdk_display_manager_quartz_set_default_display (GdkDisplayManager *manager,
+ GdkDisplay *display)
+{
+ GdkDisplayManagerQuartz *manager_quartz = GDK_DISPLAY_MANAGER_QUARTZ (manager);
+
+ manager_quartz->default_display = display;
+}
+
+static void
+gdk_display_manager_quartz_init (GdkDisplayManagerQuartz *manager)
+{
+ _gdk_quartz_windowing_init ();
+}
+
+static void
+gdk_display_manager_quartz_finalize (GObject *object)
+{
+ g_error ("A GdkDisplayManagerQuartz object was finalized. This should not happen");
+ G_OBJECT_CLASS (gdk_display_manager_quartz_parent_class)->finalize (object);
+}
+
+static void
+gdk_display_manager_quartz_class_init (GdkDisplayManagerQuartzClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+ GdkDisplayManagerClass *manager_class = GDK_DISPLAY_MANAGER_CLASS (class);
+
+ object_class->finalize = gdk_display_manager_quartz_finalize;
+
+ manager_class->open_display = gdk_display_manager_quartz_open_display;
+ manager_class->list_displays = gdk_display_manager_quartz_list_displays;
+ manager_class->set_default_display = gdk_display_manager_quartz_set_default_display;
+ manager_class->get_default_display = gdk_display_manager_quartz_get_default_display;
+}
+
+void
+_gdk_quartz_display_manager_add_display (GdkDisplayManager *manager,
+ GdkDisplay *display)
+{
+ GdkDisplayManagerQuartz *manager_quartz = GDK_DISPLAY_MANAGER_QUARTZ (manager);
+
+ if (manager_quartz->displays == NULL)
+ gdk_display_manager_set_default_display (manager, display);
+
+ manager_quartz->displays = g_slist_prepend (manager_quartz->displays, display);
+}
+
+void
+_gdk_quartz_display_manager_remove_display (GdkDisplayManager *manager,
+ GdkDisplay *display)
+{
+ GdkDisplayManagerQuartz *manager_quartz = GDK_DISPLAY_MANAGER_QUARTZ (manager);
+
+ manager_quartz->displays = g_slist_remove (manager_quartz->displays, display);
+
+ if (manager_quartz->default_display == display)
+ {
+ if (manager_quartz->displays)
+ gdk_display_manager_set_default_display (manager, manager_quartz->displays->data);
+ else
+ gdk_display_manager_set_default_display (manager, NULL);
+ }
+}
diff --git a/gdk/quartz/gdkevents-quartz.c b/gdk/quartz/gdkevents-quartz.c
index 83f6b7a..75ead8b 100644
--- a/gdk/quartz/gdkevents-quartz.c
+++ b/gdk/quartz/gdkevents-quartz.c
@@ -60,7 +60,7 @@ gdk_quartz_event_get_nsevent (GdkEvent *event)
}
void
-_gdk_events_init (void)
+_gdk_quartz_events_init (void)
{
_gdk_quartz_event_loop_init ();
diff --git a/gdk/quartz/gdkinput.c b/gdk/quartz/gdkinput.c
index fc7d73f..8d96076 100644
--- a/gdk/quartz/gdkinput.c
+++ b/gdk/quartz/gdkinput.c
@@ -204,7 +204,7 @@ _gdk_quartz_device_check_extension_events (GdkDevice *device)
}
void
-_gdk_input_init (void)
+_gdk_quartz_input_init (void)
{
GdkDeviceManager *device_manager;
GList *list, *l;
@@ -252,28 +252,3 @@ _gdk_input_init (void)
_gdk_input_ignore_core = FALSE;
}
-
-void
-_gdk_input_exit (void)
-{
- GList *tmp_list;
- GdkDevicePrivate *gdkdev;
-
- for (tmp_list = _gdk_input_devices; tmp_list; tmp_list = tmp_list->next)
- {
- gdkdev = (GdkDevicePrivate *)(tmp_list->data);
- if (gdkdev != (GdkDevicePrivate *)_gdk_core_pointer)
- {
- gdk_device_set_mode ((GdkDevice *)gdkdev, GDK_MODE_DISABLED);
- g_object_unref(gdkdev);
- }
- }
-
- g_list_free (_gdk_input_devices);
-
- for (tmp_list = _gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
- {
- g_free (tmp_list->data);
- }
- g_list_free (_gdk_input_windows);
-}
diff --git a/gdk/quartz/gdkinputprivate.h b/gdk/quartz/gdkinputprivate.h
index 7ba4293..a72aa10 100644
--- a/gdk/quartz/gdkinputprivate.h
+++ b/gdk/quartz/gdkinputprivate.h
@@ -133,8 +133,7 @@ extern gint _gdk_input_ignore_core;
GdkInputWindow * _gdk_input_window_find (GdkWindow *window);
void _gdk_input_window_destroy (GdkWindow *window);
-void _gdk_input_init (void);
-void _gdk_input_exit (void);
+void _gdk_quartz_input_init (void);
gint _gdk_input_enable_window (GdkWindow *window,
GdkDevicePrivate *gdkdev);
gint _gdk_input_disable_window (GdkWindow *window,
diff --git a/gdk/quartz/gdkprivate-quartz.h b/gdk/quartz/gdkprivate-quartz.h
index 890e10c..bebf02c 100644
--- a/gdk/quartz/gdkprivate-quartz.h
+++ b/gdk/quartz/gdkprivate-quartz.h
@@ -67,9 +67,9 @@ extern GdkDragContext *_gdk_quartz_drag_source_context;
/* Initialization */
void _gdk_windowing_update_window_sizes (GdkScreen *screen);
void _gdk_windowing_window_init (void);
-void _gdk_events_init (void);
+void _gdk_quartz_events_init (void);
void _gdk_quartz_visual_init (GdkScreen *screen);
-void _gdk_input_init (void);
+void _gdk_quartz_input_init (void);
void _gdk_quartz_event_loop_init (void);
/* GC */
@@ -153,6 +153,8 @@ void _gdk_quartz_display_sync (GdkDisplay *display);
void _gdk_quartz_display_flush (GdkDisplay *display);
GList * _gdk_quartz_display_list_devices (GdkDisplay *dpy);
+GdkDisplay * _gdk_quartz_display_open (const gchar *name);
+
GdkNativeWinodw _gdk_quartz_display_get_drag_get_protocol (GdkDisplay *display,
GdkNativeWindow *xid,
GdkDragProtocol *protocol,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]