]> Pileus Git - ~andy/gtk/blob - gdk/quartz/gdkdisplay-quartz.c
Implement dnd vtables for quartz
[~andy/gtk] / gdk / quartz / gdkdisplay-quartz.c
1 /* gdkdisplay-quartz.c
2  *
3  * Copyright (C) 2005 Imendio AB
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 #include "config.h"
22
23 #include "gdk.h"
24 #include "gdkdisplay-quartz.h"
25 #include "gdkprivate-quartz.h"
26 #include "gdkscreen-quartz.h"
27 #include "gdkdevicemanager-core.h"
28
29
30 static GdkWindow *
31 gdk_quartz_display_get_default_group (GdkDisplay *display)
32 {
33   g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
34
35   /* FIXME: Implement */
36
37   return NULL;
38 }
39
40 void
41 _gdk_windowing_set_default_display (GdkDisplay *display)
42 {
43   g_assert (display == NULL || _gdk_display == display);
44 }
45
46 GdkDeviceManager *
47 _gdk_device_manager_new (GdkDisplay *display)
48 {
49   return g_object_new (GDK_TYPE_DEVICE_MANAGER_CORE,
50                        "display", display,
51                        NULL);
52 }
53
54 GdkDisplay *
55 gdk_display_open (const gchar *display_name)
56 {
57   if (_gdk_display != NULL)
58     return NULL;
59
60   /* Initialize application */
61   [NSApplication sharedApplication];
62
63   _gdk_display = g_object_new (GDK_TYPE_DISPLAY, NULL);
64   _gdk_display->device_manager = _gdk_device_manager_new (_gdk_display);
65
66   _gdk_visual_init ();
67
68   _gdk_screen = _gdk_screen_quartz_new ();
69
70   _gdk_windowing_window_init ();
71
72   _gdk_events_init ();
73
74   _gdk_input_init ();
75
76 #if 0
77   /* FIXME: Remove the #if 0 when we have these functions */
78   _gdk_dnd_init ();
79 #endif
80
81   g_signal_emit_by_name (gdk_display_manager_get (),
82                          "display_opened", _gdk_display);
83
84   return _gdk_display;
85 }
86
87 static const gchar *
88 gdk_quartz_display_get_name (GdkDisplay *display)
89 {
90   static gchar *display_name = NULL;
91
92   if (!display_name)
93     {
94       GDK_QUARTZ_ALLOC_POOL;
95       display_name = g_strdup ([[[NSHost currentHost] name] UTF8String]);
96       GDK_QUARTZ_RELEASE_POOL;
97     }
98
99   return display_name;
100 }
101
102 static gint
103 gdk_quartz_display_get_n_screens (GdkDisplay *display)
104 {
105   g_return_val_if_fail (GDK_IS_DISPLAY (display), 0);
106
107   return 1;
108 }
109
110 static GdkScreen *
111 gdk_quartz_display_get_screen (GdkDisplay *display,
112                                gint        screen_num)
113 {
114   g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
115   g_return_val_if_fail (screen_num == 0, NULL);
116
117   return _gdk_screen;
118 }
119
120 static GdkScreen *
121 gdk_quartz_display_get_default_screen (GdkDisplay *display)
122 {
123   return _gdk_screen;
124 }
125
126 static void
127 gdk_quartz_display_beep (GdkDisplay *display)
128 {
129   g_return_if_fail (GDK_IS_DISPLAY (display));
130
131   NSBeep();
132 }
133
134 static gboolean
135 gdk_quartz_display_supports_selection_notification (GdkDisplay *display)
136 {
137   g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
138
139   /* FIXME: Implement */
140   return FALSE;
141 }
142
143 static gboolean
144 gdk_quartz_display_request_selection_notification (GdkDisplay *display,
145                                                    GdkAtom     selection)
146
147 {
148   /* FIXME: Implement */
149   return FALSE;
150 }
151
152 static gboolean
153 gdk_quartz_display_supports_clipboard_persistence (GdkDisplay *display)
154 {
155   /* FIXME: Implement */
156   return FALSE;
157 }
158
159 static gboolean
160 gdk_quartz_display_supports_shapes (GdkDisplay *display)
161 {
162   /* FIXME: Implement */
163   return FALSE;
164 }
165
166 static gboolean
167 gdk_quartz_display_supports_input_shapes (GdkDisplay *display)
168 {
169   /* FIXME: Implement */
170   return FALSE;
171 }
172
173 static void
174 gdk_quartz_display_store_clipboard (GdkDisplay    *display,
175                                     GdkWindow     *clipboard_window,
176                                     guint32        time_,
177                                     const GdkAtom *targets,
178                                     gint           n_targets)
179 {
180   /* FIXME: Implement */
181 }
182
183
184 static gboolean
185 gdk_quartz_display_supports_composite (GdkDisplay *display)
186 {
187   /* FIXME: Implement */
188   return FALSE;
189 }
190
191 gulong
192 _gdk_windowing_window_get_next_serial (GdkDisplay *display)
193 {
194   return 0;
195 }
196
197 G_DEFINE_TYPE (GdkDisplayQuartz, _gdk_display_quartz, GDK_TYPE_DISPLAY)
198
199 static void
200 _gdk_display_quartz_init (GdkDisplayQuartz *display)
201 {
202 }
203
204 static void
205 _gdk_display_quartz_finalize (GObject *object)
206 {
207   G_OBJECT_CLASS (_gdk_display_quartz_parent_class)->finalize (object);
208 }
209
210 static void
211 _gdk_display_quartz_class_init (GdkDisplayQuartz *class)
212 {
213   GObjectClass *object_class = G_OBJECT_CLASS (class);
214   GdkDisplayClass *display_class = GDK_DISPLAY_CLASS (class);
215
216   object_class->finalize = _gdk_display_quartz_finalize;
217
218   display_class->get_name = gdk_quartz_display_get_name;
219   display_class->get_n_screens = gdk_quartz_display_get_n_screens;
220   display_class->get_screen = gdk_quartz_display_get_screen;
221   display_class->get_default_screen = gdk_quartz_display_get_default_screen;
222   display_class->beep = gdk_quartz_display_beep;
223   display_class->sync = _gdk_quartz_display_sync;
224   display_class->flush = _gdk_quartz_display_flush;
225   display_class->get_default_group = gdk_quartz_display_get_default_group;
226   display_class->supports_selection_notification = gdk_quartz_display_supports_selection_notification;
227   display_class->request_selection_notification = gdk_quartz_display_request_selection_notification;
228   display_class->supports_clipboard_persistence = gdk_quartz_display_supports_clipboard_persistence;
229   display_class->store_clipboard = gdk_quartz_display_store_clipboard;
230   display_class->supports_shapes = gdk_quartz_display_supports_shapes;
231   display_class->supports_input_shapes = gdk_quartz_display_supports_input_shapes;
232   display_class->supports_composite = gdk_quartz_display_supports_composite;
233   display_class->list_devices = _gdk_quartz_display_list_devices;
234   display_class->send_client_message = _gdk_quartz_display_send_client_message;
235   display_class->add_client_message_filter = _gdk_quartz_display_add_client_message_filter;
236   display_class->get_drag_protocol = _gdk_quartz_display_get_drag_protocol;
237 }