| 1 |
/* GDK - The GIMP Drawing Kit |
| 2 |
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald |
| 3 |
* |
| 4 |
* This library is free software; you can redistribute it and/or |
| 5 |
* modify it under the terms of the GNU Lesser General Public |
| 6 |
* License as published by the Free Software Foundation; either |
| 7 |
* version 2 of the License, or (at your option) any later version. |
| 8 |
* |
| 9 |
* This library is distributed in the hope that it will be useful, |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 |
* Lesser General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU Lesser General Public |
| 15 |
* License along with this library; if not, write to the |
| 16 |
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 17 |
* Boston, MA 02111-1307, USA. |
| 18 |
*/ |
| 19 |
|
| 20 |
/* |
| 21 |
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS |
| 22 |
* file for a list of people on the GTK+ Team. See the ChangeLog |
| 23 |
* files for a list of changes. These files are distributed with |
| 24 |
* GTK+ at ftp://ftp.gtk.org/pub/gtk/. |
| 25 |
*/ |
| 26 |
|
| 27 |
#include "config.h" |
| 28 |
|
| 29 |
#include <glib.h> |
| 30 |
#include "gdk.h" |
| 31 |
#include "gdkdirectfb.h" |
| 32 |
#include "gdkprivate-directfb.h" |
| 33 |
#include "gdkscreen.h" |
| 34 |
#include "gdkdisplaymanager.h" |
| 35 |
#include "gdkalias.h" |
| 36 |
|
| 37 |
|
| 38 |
extern void _gdk_visual_init (void); |
| 39 |
extern void _gdk_events_init (void); |
| 40 |
extern void _gdk_input_init (void); |
| 41 |
extern void _gdk_dnd_init (void); |
| 42 |
extern void _gdk_windowing_window_init (GdkScreen *screen); |
| 43 |
extern void _gdk_windowing_image_init (void); |
| 44 |
extern void _gdk_directfb_keyboard_init (void); |
| 45 |
|
| 46 |
static gboolean gdk_directfb_argb_font = FALSE; |
| 47 |
static gint gdk_directfb_glyph_surface_cache = 8; |
| 48 |
|
| 49 |
|
| 50 |
const GOptionEntry _gdk_windowing_args[] = |
| 51 |
{ |
| 52 |
{ "disable-aa-fonts",0,0,G_OPTION_ARG_INT,&gdk_directfb_monochrome_fonts,NULL,NULL }, |
| 53 |
{ "argb-font",0,0, G_OPTION_ARG_INT, &gdk_directfb_argb_font,NULL,NULL}, |
| 54 |
{ "transparent-unfocused",0,0, G_OPTION_ARG_INT, &gdk_directfb_apply_focus_opacity,NULL,NULL }, |
| 55 |
{ "glyph-surface-cache",0,0,G_OPTION_ARG_INT,&gdk_directfb_glyph_surface_cache,NULL,NULL }, |
| 56 |
{ "enable-color-keying",0,0,G_OPTION_ARG_INT,&gdk_directfb_enable_color_keying,NULL,NULL }, |
| 57 |
{ NULL } |
| 58 |
}; |
| 59 |
|
| 60 |
/* Main entry point for gdk in 2.6 args are parsed |
| 61 |
*/ |
| 62 |
GdkDisplay * |
| 63 |
gdk_display_open (const gchar *display_name) |
| 64 |
{ |
| 65 |
IDirectFB *directfb; |
| 66 |
IDirectFBDisplayLayer *layer; |
| 67 |
IDirectFBInputDevice *keyboard; |
| 68 |
DFBResult ret; |
| 69 |
|
| 70 |
if (_gdk_display) |
| 71 |
{ |
| 72 |
return GDK_DISPLAY_OBJECT (_gdk_display); /* single display only */ |
| 73 |
} |
| 74 |
|
| 75 |
ret = DirectFBInit (NULL, NULL); |
| 76 |
if (ret != DFB_OK) |
| 77 |
{ |
| 78 |
DirectFBError ("gdk_display_open: DirectFBInit", ret); |
| 79 |
return NULL; |
| 80 |
} |
| 81 |
|
| 82 |
ret = DirectFBCreate (&directfb); |
| 83 |
if (ret != DFB_OK) |
| 84 |
{ |
| 85 |
DirectFBError ("gdk_display_open: DirectFBCreate", ret); |
| 86 |
return NULL; |
| 87 |
} |
| 88 |
|
| 89 |
_gdk_display = g_object_new (GDK_TYPE_DISPLAY_DFB, NULL); |
| 90 |
_gdk_display->directfb = directfb; |
| 91 |
|
| 92 |
ret = directfb->GetDisplayLayer (directfb, DLID_PRIMARY, &layer); |
| 93 |
if (ret != DFB_OK) |
| 94 |
{ |
| 95 |
DirectFBError ("gdk_display_open: GetDisplayLayer", ret); |
| 96 |
directfb->Release (directfb); |
| 97 |
_gdk_display->directfb = NULL; |
| 98 |
return NULL; |
| 99 |
} |
| 100 |
|
| 101 |
|
| 102 |
ret = directfb->GetInputDevice (directfb, DIDID_KEYBOARD, &keyboard); |
| 103 |
if (ret != DFB_OK) |
| 104 |
{ |
| 105 |
DirectFBError ("gdk_display_open: GetInputDevice", ret); |
| 106 |
directfb->Release (directfb); |
| 107 |
_gdk_display->directfb = NULL; |
| 108 |
return NULL; |
| 109 |
} |
| 110 |
|
| 111 |
_gdk_display->layer = layer; |
| 112 |
_gdk_display->keyboard = keyboard; |
| 113 |
|
| 114 |
_gdk_directfb_keyboard_init (); |
| 115 |
|
| 116 |
_gdk_screen = g_object_new (GDK_TYPE_SCREEN, NULL); |
| 117 |
|
| 118 |
_gdk_visual_init (); |
| 119 |
_gdk_windowing_window_init (_gdk_screen); |
| 120 |
|
| 121 |
gdk_screen_set_default_colormap (_gdk_screen, |
| 122 |
gdk_screen_get_system_colormap (_gdk_screen)); |
| 123 |
_gdk_windowing_image_init (); |
| 124 |
|
| 125 |
_gdk_events_init (); |
| 126 |
_gdk_input_init (); |
| 127 |
_gdk_dnd_init (); |
| 128 |
|
| 129 |
layer->EnableCursor (layer, 1); |
| 130 |
|
| 131 |
g_signal_emit_by_name (gdk_display_manager_get (), |
| 132 |
"display_opened", _gdk_display); |
| 133 |
|
| 134 |
return GDK_DISPLAY_OBJECT (_gdk_display); |
| 135 |
} |
| 136 |
|
| 137 |
GType |
| 138 |
gdk_display_dfb_get_type (void) |
| 139 |
{ |
| 140 |
static GType object_type = 0; |
| 141 |
|
| 142 |
if (!object_type) |
| 143 |
{ |
| 144 |
const GTypeInfo object_info = |
| 145 |
{ |
| 146 |
sizeof (GdkDisplayDFBClass), |
| 147 |
(GBaseInitFunc) NULL, |
| 148 |
(GBaseFinalizeFunc) NULL, |
| 149 |
(GClassInitFunc) NULL, |
| 150 |
NULL, /* class_finalize */ |
| 151 |
NULL, /* class_data */ |
| 152 |
sizeof (GdkDisplayDFB), |
| 153 |
0, /* n_preallocs */ |
| 154 |
(GInstanceInitFunc) NULL, |
| 155 |
}; |
| 156 |
|
| 157 |
object_type = g_type_register_static (GDK_TYPE_DISPLAY, |
| 158 |
"GdkDisplayDFB", |
| 159 |
&object_info, 0); |
| 160 |
} |
| 161 |
|
| 162 |
return object_type; |
| 163 |
} |
| 164 |
|
| 165 |
IDirectFBSurface * |
| 166 |
gdk_display_dfb_create_surface (GdkDisplayDFB *display, int format, int width, int height) |
| 167 |
{ |
| 168 |
DFBResult ret; |
| 169 |
IDirectFBSurface *temp; |
| 170 |
DFBSurfaceDescription dsc; |
| 171 |
dsc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT; |
| 172 |
dsc.width = width; |
| 173 |
dsc.height = height; |
| 174 |
dsc.pixelformat = format; |
| 175 |
ret = display->directfb->CreateSurface (display->directfb, &dsc, &temp); |
| 176 |
if (ret) |
| 177 |
{ |
| 178 |
DirectFBError ("gdk_display_dfb_create_surface ", ret); |
| 179 |
return NULL; |
| 180 |
} |
| 181 |
return temp; |
| 182 |
|
| 183 |
} |
| 184 |
|
| 185 |
|
| 186 |
/************************************************************************************************* |
| 187 |
* Displays and Screens |
| 188 |
*/ |
| 189 |
|
| 190 |
void |
| 191 |
_gdk_windowing_set_default_display (GdkDisplay *display) |
| 192 |
{ |
| 193 |
_gdk_display = GDK_DISPLAY_DFB (display); |
| 194 |
} |
| 195 |
|
| 196 |
const gchar * |
| 197 |
gdk_display_get_name (GdkDisplay *display) |
| 198 |
{ |
| 199 |
return gdk_get_display_arg_name (); |
| 200 |
} |
| 201 |
|
| 202 |
int |
| 203 |
gdk_display_get_n_screens (GdkDisplay *display) |
| 204 |
{ |
| 205 |
return 1; |
| 206 |
} |
| 207 |
|
| 208 |
GdkScreen * |
| 209 |
gdk_display_get_screen (GdkDisplay *display, |
| 210 |
gint screen_num) |
| 211 |
{ |
| 212 |
return _gdk_screen; |
| 213 |
} |
| 214 |
|
| 215 |
GdkScreen * |
| 216 |
gdk_display_get_default_screen (GdkDisplay *display) |
| 217 |
{ |
| 218 |
return _gdk_screen; |
| 219 |
} |
| 220 |
|
| 221 |
gboolean |
| 222 |
gdk_display_supports_shapes (GdkDisplay *display) |
| 223 |
{ |
| 224 |
return FALSE; |
| 225 |
} |
| 226 |
|
| 227 |
gboolean |
| 228 |
gdk_display_supports_input_shapes (GdkDisplay *display) |
| 229 |
{ |
| 230 |
return FALSE; |
| 231 |
} |
| 232 |
|
| 233 |
|
| 234 |
GdkWindow *gdk_display_get_default_group (GdkDisplay *display) |
| 235 |
{ |
| 236 |
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL); |
| 237 |
return _gdk_parent_root; |
| 238 |
} |
| 239 |
|
| 240 |
|
| 241 |
/************************************************************************************************* |
| 242 |
* Selection and Clipboard |
| 243 |
*/ |
| 244 |
|
| 245 |
gboolean |
| 246 |
gdk_display_supports_selection_notification (GdkDisplay *display) |
| 247 |
{ |
| 248 |
return FALSE; |
| 249 |
} |
| 250 |
|
| 251 |
gboolean gdk_display_request_selection_notification (GdkDisplay *display, |
| 252 |
GdkAtom selection) |
| 253 |
|
| 254 |
{ |
| 255 |
g_warning("gdk_display_request_selection_notification Unimplemented function \n"); |
| 256 |
return FALSE; |
| 257 |
} |
| 258 |
|
| 259 |
gboolean |
| 260 |
gdk_display_supports_clipboard_persistence (GdkDisplay *display) |
| 261 |
{ |
| 262 |
g_warning("gdk_display_supports_clipboard_persistence Unimplemented function \n"); |
| 263 |
return FALSE; |
| 264 |
} |
| 265 |
|
| 266 |
void |
| 267 |
gdk_display_store_clipboard (GdkDisplay *display, |
| 268 |
GdkWindow *clipboard_window, |
| 269 |
guint32 time_, |
| 270 |
const GdkAtom *targets, |
| 271 |
gint n_targets) |
| 272 |
{ |
| 273 |
|
| 274 |
g_warning("gdk_display_store_clipboard Unimplemented function \n"); |
| 275 |
|
| 276 |
} |
| 277 |
|
| 278 |
|
| 279 |
/************************************************************************************************* |
| 280 |
* Pointer |
| 281 |
*/ |
| 282 |
|
| 283 |
static gboolean _gdk_directfb_pointer_implicit_grab = FALSE; |
| 284 |
|
| 285 |
GdkGrabStatus |
| 286 |
gdk_directfb_pointer_grab (GdkWindow *window, |
| 287 |
gint owner_events, |
| 288 |
GdkEventMask event_mask, |
| 289 |
GdkWindow *confine_to, |
| 290 |
GdkCursor *cursor, |
| 291 |
guint32 time, |
| 292 |
gboolean implicit_grab) |
| 293 |
{ |
| 294 |
GdkWindow *toplevel; |
| 295 |
GdkWindowImplDirectFB *impl; |
| 296 |
|
| 297 |
if (_gdk_directfb_pointer_grab_window) |
| 298 |
{ |
| 299 |
if (implicit_grab && !_gdk_directfb_pointer_implicit_grab) |
| 300 |
return GDK_GRAB_ALREADY_GRABBED; |
| 301 |
|
| 302 |
gdk_pointer_ungrab (time); |
| 303 |
} |
| 304 |
|
| 305 |
toplevel = gdk_directfb_window_find_toplevel (window); |
| 306 |
impl = GDK_WINDOW_IMPL_DIRECTFB (GDK_WINDOW_OBJECT (toplevel)->impl); |
| 307 |
|
| 308 |
if (impl->window) |
| 309 |
{ |
| 310 |
if (impl->window->GrabPointer (impl->window) == DFB_LOCKED) |
| 311 |
return GDK_GRAB_ALREADY_GRABBED; |
| 312 |
} |
| 313 |
|
| 314 |
if (event_mask & GDK_BUTTON_MOTION_MASK) |
| 315 |
event_mask |= (GDK_BUTTON1_MOTION_MASK | |
| 316 |
GDK_BUTTON2_MOTION_MASK | |
| 317 |
GDK_BUTTON3_MOTION_MASK); |
| 318 |
|
| 319 |
_gdk_directfb_pointer_implicit_grab = implicit_grab; |
| 320 |
_gdk_directfb_pointer_grab_window = g_object_ref (window); |
| 321 |
_gdk_directfb_pointer_grab_owner_events = owner_events; |
| 322 |
|
| 323 |
_gdk_directfb_pointer_grab_confine = (confine_to ? |
| 324 |
g_object_ref (confine_to) : NULL); |
| 325 |
_gdk_directfb_pointer_grab_events = event_mask; |
| 326 |
_gdk_directfb_pointer_grab_cursor = (cursor ? |
| 327 |
gdk_cursor_ref (cursor) : NULL); |
| 328 |
|
| 329 |
|
| 330 |
gdk_directfb_window_send_crossing_events (NULL, |
| 331 |
window, |
| 332 |
GDK_CROSSING_GRAB); |
| 333 |
|
| 334 |
return GDK_GRAB_SUCCESS; |
| 335 |
} |
| 336 |
|
| 337 |
void |
| 338 |
gdk_directfb_pointer_ungrab (guint32 time, |
| 339 |
gboolean implicit_grab) |
| 340 |
{ |
| 341 |
GdkWindow *toplevel; |
| 342 |
GdkWindow *mousewin; |
| 343 |
GdkWindow *old_grab_window; |
| 344 |
GdkWindowImplDirectFB *impl; |
| 345 |
|
| 346 |
if (implicit_grab && !_gdk_directfb_pointer_implicit_grab) |
| 347 |
return; |
| 348 |
|
| 349 |
if (!_gdk_directfb_pointer_grab_window) |
| 350 |
return; |
| 351 |
|
| 352 |
toplevel = |
| 353 |
gdk_directfb_window_find_toplevel (_gdk_directfb_pointer_grab_window); |
| 354 |
impl = GDK_WINDOW_IMPL_DIRECTFB (GDK_WINDOW_OBJECT (toplevel)->impl); |
| 355 |
|
| 356 |
if (impl->window) |
| 357 |
impl->window->UngrabPointer (impl->window); |
| 358 |
|
| 359 |
if (_gdk_directfb_pointer_grab_confine) |
| 360 |
{ |
| 361 |
g_object_unref (_gdk_directfb_pointer_grab_confine); |
| 362 |
_gdk_directfb_pointer_grab_confine = NULL; |
| 363 |
} |
| 364 |
|
| 365 |
if (_gdk_directfb_pointer_grab_cursor) |
| 366 |
{ |
| 367 |
gdk_cursor_unref (_gdk_directfb_pointer_grab_cursor); |
| 368 |
_gdk_directfb_pointer_grab_cursor = NULL; |
| 369 |
} |
| 370 |
|
| 371 |
old_grab_window = _gdk_directfb_pointer_grab_window; |
| 372 |
|
| 373 |
_gdk_directfb_pointer_grab_window = NULL; |
| 374 |
_gdk_directfb_pointer_implicit_grab = FALSE; |
| 375 |
|
| 376 |
mousewin = gdk_window_at_pointer (NULL, NULL); |
| 377 |
gdk_directfb_window_send_crossing_events (old_grab_window, |
| 378 |
mousewin, |
| 379 |
GDK_CROSSING_UNGRAB); |
| 380 |
g_object_unref (old_grab_window); |
| 381 |
} |
| 382 |
|
| 383 |
void |
| 384 |
gdk_display_pointer_ungrab (GdkDisplay *display, |
| 385 |
guint32 time) |
| 386 |
{ |
| 387 |
GdkPointerGrabInfo *grab = _gdk_display_get_last_pointer_grab (display); |
| 388 |
|
| 389 |
if (grab) |
| 390 |
{ |
| 391 |
grab->serial_end = 0; |
| 392 |
} |
| 393 |
|
| 394 |
_gdk_display_pointer_grab_update (display, 0); |
| 395 |
} |
| 396 |
|
| 397 |
|
| 398 |
/************************************************************************************************* |
| 399 |
* Keyboard |
| 400 |
*/ |
| 401 |
|
| 402 |
GdkGrabStatus |
| 403 |
gdk_directfb_keyboard_grab (GdkDisplay *display, |
| 404 |
GdkWindow *window, |
| 405 |
gint owner_events, |
| 406 |
guint32 time) |
| 407 |
{ |
| 408 |
GdkWindow *toplevel; |
| 409 |
GdkWindowImplDirectFB *impl; |
| 410 |
|
| 411 |
g_return_val_if_fail (GDK_IS_WINDOW (window), 0); |
| 412 |
|
| 413 |
if (_gdk_directfb_keyboard_grab_window) |
| 414 |
gdk_keyboard_ungrab (time); |
| 415 |
|
| 416 |
toplevel = gdk_directfb_window_find_toplevel (window); |
| 417 |
impl = GDK_WINDOW_IMPL_DIRECTFB (GDK_WINDOW_OBJECT (toplevel)->impl); |
| 418 |
|
| 419 |
if (impl->window) |
| 420 |
{ |
| 421 |
if (impl->window->GrabKeyboard (impl->window) == DFB_LOCKED) |
| 422 |
return GDK_GRAB_ALREADY_GRABBED; |
| 423 |
} |
| 424 |
|
| 425 |
_gdk_directfb_keyboard_grab_window = g_object_ref (window); |
| 426 |
_gdk_directfb_keyboard_grab_owner_events = owner_events; |
| 427 |
return GDK_GRAB_SUCCESS; |
| 428 |
} |
| 429 |
|
| 430 |
void |
| 431 |
gdk_directfb_keyboard_ungrab (GdkDisplay *display, |
| 432 |
guint32 time) |
| 433 |
{ |
| 434 |
GdkWindow *toplevel; |
| 435 |
GdkWindowImplDirectFB *impl; |
| 436 |
|
| 437 |
if (!_gdk_directfb_keyboard_grab_window) |
| 438 |
return; |
| 439 |
|
| 440 |
toplevel = gdk_directfb_window_find_toplevel (_gdk_directfb_keyboard_grab_window); |
| 441 |
impl = GDK_WINDOW_IMPL_DIRECTFB (GDK_WINDOW_OBJECT (toplevel)->impl); |
| 442 |
|
| 443 |
if (impl->window) |
| 444 |
impl->window->UngrabKeyboard (impl->window); |
| 445 |
|
| 446 |
g_object_unref (_gdk_directfb_keyboard_grab_window); |
| 447 |
_gdk_directfb_keyboard_grab_window = NULL; |
| 448 |
} |
| 449 |
|
| 450 |
/* |
| 451 |
*-------------------------------------------------------------- |
| 452 |
* gdk_keyboard_grab |
| 453 |
* |
| 454 |
* Grabs the keyboard to a specific window |
| 455 |
* |
| 456 |
* Arguments: |
| 457 |
* "window" is the window which will receive the grab |
| 458 |
* "owner_events" specifies whether events will be reported as is, |
| 459 |
* or relative to "window" |
| 460 |
* "time" specifies the time |
| 461 |
* |
| 462 |
* Results: |
| 463 |
* |
| 464 |
* Side effects: |
| 465 |
* requires a corresponding call to gdk_keyboard_ungrab |
| 466 |
* |
| 467 |
*-------------------------------------------------------------- |
| 468 |
*/ |
| 469 |
|
| 470 |
GdkGrabStatus |
| 471 |
gdk_display_keyboard_grab (GdkDisplay *display, |
| 472 |
GdkWindow *window, |
| 473 |
gint owner_events, |
| 474 |
guint32 time) |
| 475 |
{ |
| 476 |
return gdk_directfb_keyboard_grab (display, window, owner_events, time); |
| 477 |
} |
| 478 |
|
| 479 |
void |
| 480 |
gdk_display_keyboard_ungrab (GdkDisplay *display, |
| 481 |
guint32 time) |
| 482 |
{ |
| 483 |
return gdk_directfb_keyboard_ungrab (display, time); |
| 484 |
} |
| 485 |
|
| 486 |
|
| 487 |
/************************************************************************************************* |
| 488 |
* Misc Stuff |
| 489 |
*/ |
| 490 |
|
| 491 |
void |
| 492 |
gdk_display_beep (GdkDisplay *display) |
| 493 |
{ |
| 494 |
} |
| 495 |
|
| 496 |
void |
| 497 |
gdk_display_sync (GdkDisplay *display) |
| 498 |
{ |
| 499 |
} |
| 500 |
|
| 501 |
void |
| 502 |
gdk_display_flush (GdkDisplay *display) |
| 503 |
{ |
| 504 |
} |
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
/************************************************************************************************* |
| 509 |
* Notifications |
| 510 |
*/ |
| 511 |
|
| 512 |
void |
| 513 |
gdk_notify_startup_complete (void) |
| 514 |
{ |
| 515 |
} |
| 516 |
|
| 517 |
/** |
| 518 |
* gdk_notify_startup_complete_with_id: |
| 519 |
* @startup_id: a startup-notification identifier, for which notification |
| 520 |
* process should be completed |
| 521 |
* |
| 522 |
* Indicates to the GUI environment that the application has finished |
| 523 |
* loading, using a given identifier. |
| 524 |
* |
| 525 |
* GTK+ will call this function automatically for #GtkWindow with custom |
| 526 |
* startup-notification identifier unless |
| 527 |
* gtk_window_set_auto_startup_notification() is called to disable |
| 528 |
* that feature. |
| 529 |
* |
| 530 |
* Since: 2.12 |
| 531 |
**/ |
| 532 |
void |
| 533 |
gdk_notify_startup_complete_with_id (const gchar* startup_id) |
| 534 |
{ |
| 535 |
} |
| 536 |
|
| 537 |
|
| 538 |
/************************************************************************************************* |
| 539 |
* Compositing |
| 540 |
*/ |
| 541 |
|
| 542 |
gboolean |
| 543 |
gdk_display_supports_composite (GdkDisplay *display) |
| 544 |
{ |
| 545 |
return FALSE; |
| 546 |
} |
| 547 |
|
| 548 |
|
| 549 |
#define __GDK_DISPLAY_X11_C__ |
| 550 |
#include "gdkaliasdef.c" |
| 551 |
|