1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 * Copyright (C) 1998-1999 Tor Lillqvist
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.
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.
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.
22 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
23 * file for a list of people on the GTK+ Team.
27 * GTK+ DirectFB backend
28 * Copyright (C) 2001-2002 convergence integrated media GmbH
29 * Copyright (C) 2002-2004 convergence GmbH
30 * Written by Denis Oliver Kropp <dok@convergence.de> and
31 * Sven Neumann <sven@convergence.de>
35 Main entry point for 2.6 seems to be open_display so
36 most stuff in main is moved over to gdkdisplay-directfb.c
37 I'll move stub functions here that make no sense for directfb
47 #include "gdkdisplay.h"
48 #include "gdkdirectfb.h"
49 #include "gdkprivate-directfb.h"
51 #include "gdkinternals.h"
53 #include "gdkinput-directfb.h"
60 _gdk_windowing_init (void)
63 Not that usable called before parse_args
68 gdk_set_use_xshm (gboolean use_xshm)
73 gdk_get_use_xshm (void)
79 _gdk_windowing_display_set_sm_client_id (GdkDisplay *display,const gchar *sm_client_id)
81 g_message ("gdk_set_sm_client_id() is unimplemented.");
86 _gdk_windowing_exit (void)
89 if (_gdk_display->buffer)
90 _gdk_display->buffer->Release (_gdk_display->buffer);
92 _gdk_directfb_keyboard_exit ();
94 if (_gdk_display->keyboard)
95 _gdk_display->keyboard->Release (_gdk_display->keyboard);
97 _gdk_display->layer->Release (_gdk_display->layer);
99 _gdk_display->directfb->Release (_gdk_display->directfb);
101 g_free (_gdk_display);
106 gdk_get_display (void)
108 return g_strdup (gdk_display_get_name (gdk_display_get_default ()));
113 static const guint type_masks[] =
115 GDK_STRUCTURE_MASK, /* GDK_DELETE = 0, */
116 GDK_STRUCTURE_MASK, /* GDK_DESTROY = 1, */
117 GDK_EXPOSURE_MASK, /* GDK_EXPOSE = 2, */
118 GDK_POINTER_MOTION_MASK, /* GDK_MOTION_NOTIFY = 3, */
119 GDK_BUTTON_PRESS_MASK, /* GDK_BUTTON_PRESS = 4, */
120 GDK_BUTTON_PRESS_MASK, /* GDK_2BUTTON_PRESS = 5, */
121 GDK_BUTTON_PRESS_MASK, /* GDK_3BUTTON_PRESS = 6, */
122 GDK_BUTTON_RELEASE_MASK, /* GDK_BUTTON_RELEASE = 7, */
123 GDK_KEY_PRESS_MASK, /* GDK_KEY_PRESS = 8, */
124 GDK_KEY_RELEASE_MASK, /* GDK_KEY_RELEASE = 9, */
125 GDK_ENTER_NOTIFY_MASK, /* GDK_ENTER_NOTIFY = 10, */
126 GDK_LEAVE_NOTIFY_MASK, /* GDK_LEAVE_NOTIFY = 11, */
127 GDK_FOCUS_CHANGE_MASK, /* GDK_FOCUS_CHANGE = 12, */
128 GDK_STRUCTURE_MASK, /* GDK_CONFIGURE = 13, */
129 GDK_VISIBILITY_NOTIFY_MASK,/* GDK_MAP = 14, */
130 GDK_VISIBILITY_NOTIFY_MASK,/* GDK_UNMAP = 15, */
131 GDK_PROPERTY_CHANGE_MASK, /* GDK_PROPERTY_NOTIFY = 16, */
132 GDK_PROPERTY_CHANGE_MASK, /* GDK_SELECTION_CLEAR = 17, */
133 GDK_PROPERTY_CHANGE_MASK, /* GDK_SELECTION_REQUEST = 18, */
134 GDK_PROPERTY_CHANGE_MASK, /* GDK_SELECTION_NOTIFY = 19, */
135 GDK_PROXIMITY_IN_MASK, /* GDK_PROXIMITY_IN = 20, */
136 GDK_PROXIMITY_OUT_MASK, /* GDK_PROXIMITY_OUT = 21, */
137 GDK_ALL_EVENTS_MASK, /* GDK_DRAG_ENTER = 22, */
138 GDK_ALL_EVENTS_MASK, /* GDK_DRAG_LEAVE = 23, */
139 GDK_ALL_EVENTS_MASK, /* GDK_DRAG_MOTION = 24, */
140 GDK_ALL_EVENTS_MASK, /* GDK_DRAG_STATUS = 25, */
141 GDK_ALL_EVENTS_MASK, /* GDK_DROP_START = 26, */
142 GDK_ALL_EVENTS_MASK, /* GDK_DROP_FINISHED = 27, */
143 GDK_ALL_EVENTS_MASK, /* GDK_CLIENT_EVENT = 28, */
144 GDK_VISIBILITY_NOTIFY_MASK,/* GDK_VISIBILITY_NOTIFY = 29, */
145 GDK_EXPOSURE_MASK, /* GDK_NO_EXPOSE = 30, */
146 GDK_SCROLL_MASK /* GDK_SCROLL = 31 */
150 gdk_directfb_other_event_window (GdkWindow *window,
157 while (w != _gdk_parent_root)
159 /* Huge hack, so that we don't propagate events to GtkWindow->frame */
161 (GDK_WINDOW_OBJECT (w)->window_type != GDK_WINDOW_CHILD) &&
162 (g_object_get_data (G_OBJECT (w), "gdk-window-child-handler")))
165 evmask = GDK_WINDOW_OBJECT (w)->event_mask;
167 if (evmask & type_masks[type])
170 w = gdk_window_get_parent (w);
177 gdk_directfb_pointer_event_window (GdkWindow *window,
181 GdkModifierType mask;
184 gdk_directfb_mouse_get_info (NULL, NULL, &mask);
186 if (_gdk_directfb_pointer_grab_window && !_gdk_directfb_pointer_grab_owner_events )
188 evmask = _gdk_directfb_pointer_grab_events;
190 if (evmask & (GDK_BUTTON1_MOTION_MASK |
191 GDK_BUTTON2_MOTION_MASK |
192 GDK_BUTTON3_MOTION_MASK))
194 if (((mask & GDK_BUTTON1_MASK) &&
195 (evmask & GDK_BUTTON1_MOTION_MASK)) ||
196 ((mask & GDK_BUTTON2_MASK) &&
197 (evmask & GDK_BUTTON2_MOTION_MASK)) ||
198 ((mask & GDK_BUTTON3_MASK) &&
199 (evmask & GDK_BUTTON3_MOTION_MASK)))
200 evmask |= GDK_POINTER_MOTION_MASK;
203 if (evmask & type_masks[type]) {
205 if( _gdk_directfb_pointer_grab_owner_events ) {
206 return _gdk_directfb_pointer_grab_window;
208 GdkWindowObject *obj= GDK_WINDOW_OBJECT(window);
209 while (obj != NULL &&
210 obj != GDK_WINDOW_OBJECT(_gdk_directfb_pointer_grab_window)) {
211 obj = (GdkWindowObject *)obj->parent;
213 if( obj ==GDK_WINDOW_OBJECT(_gdk_directfb_pointer_grab_window) ) {
216 //was not child of the grab window so return the grab window
217 return _gdk_directfb_pointer_grab_window;
224 while (w != _gdk_parent_root)
226 /* Huge hack, so that we don't propagate events to GtkWindow->frame */
228 (GDK_WINDOW_OBJECT (w)->window_type != GDK_WINDOW_CHILD) &&
229 (g_object_get_data (G_OBJECT (w), "gdk-window-child-handler")))
232 evmask = GDK_WINDOW_OBJECT (w)->event_mask;
234 if (evmask & (GDK_BUTTON1_MOTION_MASK |
235 GDK_BUTTON2_MOTION_MASK |
236 GDK_BUTTON3_MOTION_MASK))
238 if (((mask & GDK_BUTTON1_MASK) &&
239 (evmask & GDK_BUTTON1_MOTION_MASK)) ||
240 ((mask & GDK_BUTTON2_MASK) &&
241 (evmask & GDK_BUTTON2_MOTION_MASK)) ||
242 ((mask & GDK_BUTTON3_MASK) &&
243 (evmask & GDK_BUTTON3_MOTION_MASK)))
244 evmask |= GDK_POINTER_MOTION_MASK;
247 if (evmask & type_masks[type])
250 w = gdk_window_get_parent (w);
257 gdk_directfb_keyboard_event_window (GdkWindow *window,
263 if (_gdk_directfb_keyboard_grab_window &&
264 !_gdk_directfb_keyboard_grab_owner_events)
266 return _gdk_directfb_keyboard_grab_window;
270 while (w != _gdk_parent_root)
272 /* Huge hack, so that we don't propagate events to GtkWindow->frame */
274 (GDK_WINDOW_OBJECT (w)->window_type != GDK_WINDOW_CHILD) &&
275 (g_object_get_data (G_OBJECT (w), "gdk-window-child-handler")))
278 evmask = GDK_WINDOW_OBJECT (w)->event_mask;
280 if (evmask & type_masks[type])
283 w = gdk_window_get_parent (w);
290 gdk_directfb_event_make (GdkWindow *window,
293 GdkEvent *event = gdk_event_new (GDK_NOTHING);
294 guint32 the_time = gdk_directfb_get_time ();
295 event->any.type = type;
296 event->any.window = g_object_ref (window);
297 event->any.send_event = FALSE;
301 case GDK_MOTION_NOTIFY:
302 event->motion.time = the_time;
303 event->motion.axes = NULL;
305 case GDK_BUTTON_PRESS:
306 case GDK_2BUTTON_PRESS:
307 case GDK_3BUTTON_PRESS:
308 case GDK_BUTTON_RELEASE:
309 event->button.time = the_time;
310 event->button.axes = NULL;
313 case GDK_KEY_RELEASE:
314 event->key.time = the_time;
316 case GDK_ENTER_NOTIFY:
317 case GDK_LEAVE_NOTIFY:
318 event->crossing.time = the_time;
320 case GDK_PROPERTY_NOTIFY:
321 event->property.time = the_time;
323 case GDK_SELECTION_CLEAR:
324 case GDK_SELECTION_REQUEST:
325 case GDK_SELECTION_NOTIFY:
326 event->selection.time = the_time;
328 case GDK_PROXIMITY_IN:
329 case GDK_PROXIMITY_OUT:
330 event->proximity.time = the_time;
334 case GDK_DRAG_MOTION:
335 case GDK_DRAG_STATUS:
337 case GDK_DROP_FINISHED:
338 event->dnd.time = the_time;
341 event->scroll.time = the_time;
343 case GDK_FOCUS_CHANGE:
347 case GDK_CLIENT_EVENT:
348 case GDK_VISIBILITY_NOTIFY:
357 _gdk_event_queue_append (gdk_display_get_default (), event);
363 gdk_error_trap_push (void)
368 gdk_error_trap_pop (void)
375 * gdk_pointer_grab_info_libgtk_only:
376 * @grab_window: location to store current grab window
377 * @owner_events: location to store boolean indicating whether
378 * the @owner_events flag to gdk_pointer_grab() was %TRUE.
380 * Determines information about the current pointer grab.
381 * This is not public API and must not be used by applications.
383 * Return value: %TRUE if this application currently has the
387 gdk_pointer_grab_info_libgtk_only (GdkDisplay *display,GdkWindow **grab_window,
388 gboolean *owner_events)
390 if (_gdk_directfb_pointer_grab_window)
393 *grab_window = (GdkWindow *)_gdk_directfb_pointer_grab_window;
395 *owner_events = _gdk_directfb_pointer_grab_owner_events;
404 * gdk_keyboard_grab_info_libgtk_only:
405 * @grab_window: location to store current grab window
406 * @owner_events: location to store boolean indicating whether
407 * the @owner_events flag to gdk_keyboard_grab() was %TRUE.
409 * Determines information about the current keyboard grab.
410 * This is not public API and must not be used by applications.
412 * Return value: %TRUE if this application currently has the
416 gdk_keyboard_grab_info_libgtk_only (GdkDisplay *display,GdkWindow **grab_window,
417 gboolean *owner_events)
419 if (_gdk_directfb_keyboard_grab_window)
422 *grab_window = (GdkWindow *) _gdk_directfb_keyboard_grab_window;
424 *owner_events = _gdk_directfb_keyboard_grab_owner_events;
434 gdk_keyboard_grab (GdkWindow *window,
438 return gdk_directfb_keyboard_grab(gdk_display_get_default(),
446 *--------------------------------------------------------------
449 * Grabs the pointer to a specific window
452 * "window" is the window which will receive the grab
453 * "owner_events" specifies whether events will be reported as is,
454 * or relative to "window"
455 * "event_mask" masks only interesting events
456 * "confine_to" limits the cursor movement to the specified window
457 * "cursor" changes the cursor for the duration of the grab
458 * "time" specifies the time
463 * requires a corresponding call to gdk_pointer_ungrab
465 *--------------------------------------------------------------
470 gdk_display_pointer_grab (GdkDisplay *display,GdkWindow *window,
472 GdkEventMask event_mask,
473 GdkWindow *confine_to,
477 g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
478 g_return_val_if_fail (confine_to == NULL || GDK_IS_WINDOW (confine_to), 0);
480 return gdk_directfb_pointer_grab (window,
490 gdk_pointer_grab (GdkWindow * window,
492 GdkEventMask event_mask,
493 GdkWindow * confine_to,
497 return gdk_directfb_pointer_grab(window, owner_events,event_mask,
498 confine_to,cursor,time,FALSE);
501 #define __GDK_MAIN_X11_C__
502 #include "gdkaliasdef.c"