| 1 |
/* gdkwindow-quartz.c |
| 2 |
* |
| 3 |
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald |
| 4 |
* Copyright (C) 2005-2007 Imendio AB |
| 5 |
* |
| 6 |
* This library is free software; you can redistribute it and/or |
| 7 |
* modify it under the terms of the GNU Lesser General Public |
| 8 |
* License as published by the Free Software Foundation; either |
| 9 |
* version 2 of the License, or (at your option) any later version. |
| 10 |
* |
| 11 |
* This library is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 |
* Lesser General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU Lesser General Public |
| 17 |
* License along with this library; if not, write to the |
| 18 |
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 19 |
* Boston, MA 02111-1307, USA. |
| 20 |
*/ |
| 21 |
|
| 22 |
#include "config.h" |
| 23 |
#include <Carbon/Carbon.h> |
| 24 |
|
| 25 |
#include "gdk.h" |
| 26 |
#include "gdkwindowimpl.h" |
| 27 |
#include "gdkprivate-quartz.h" |
| 28 |
#include "gdkscreen-quartz.h" |
| 29 |
#include "gdkinputprivate.h" |
| 30 |
|
| 31 |
static gpointer parent_class; |
| 32 |
|
| 33 |
static GSList *update_nswindows; |
| 34 |
static gboolean in_process_all_updates = FALSE; |
| 35 |
|
| 36 |
static GSList *main_window_stack; |
| 37 |
|
| 38 |
#define FULLSCREEN_DATA "fullscreen-data" |
| 39 |
|
| 40 |
typedef struct |
| 41 |
{ |
| 42 |
gint x, y; |
| 43 |
gint width, height; |
| 44 |
GdkWMDecoration decor; |
| 45 |
} FullscreenSavedGeometry; |
| 46 |
|
| 47 |
|
| 48 |
static void update_toplevel_order (void); |
| 49 |
static void clear_toplevel_order (void); |
| 50 |
|
| 51 |
static FullscreenSavedGeometry *get_fullscreen_geometry (GdkWindow *window); |
| 52 |
|
| 53 |
#define WINDOW_IS_TOPLEVEL(window) \ |
| 54 |
(GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \ |
| 55 |
GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN && \ |
| 56 |
GDK_WINDOW_TYPE (window) != GDK_WINDOW_OFFSCREEN) |
| 57 |
|
| 58 |
static void gdk_window_impl_iface_init (GdkWindowImplIface *iface); |
| 59 |
|
| 60 |
gboolean |
| 61 |
gdk_quartz_window_is_quartz (GdkWindow *window) |
| 62 |
{ |
| 63 |
return GDK_WINDOW_IS_QUARTZ (window); |
| 64 |
} |
| 65 |
|
| 66 |
NSView * |
| 67 |
gdk_quartz_window_get_nsview (GdkWindow *window) |
| 68 |
{ |
| 69 |
GdkWindowObject *private = (GdkWindowObject *)window; |
| 70 |
|
| 71 |
g_return_val_if_fail (GDK_WINDOW_IS_QUARTZ (window), NULL); |
| 72 |
|
| 73 |
if (GDK_WINDOW_DESTROYED (window)) |
| 74 |
return NULL; |
| 75 |
|
| 76 |
return ((GdkWindowImplQuartz *)private->impl)->view; |
| 77 |
} |
| 78 |
|
| 79 |
NSWindow * |
| 80 |
gdk_quartz_window_get_nswindow (GdkWindow *window) |
| 81 |
{ |
| 82 |
GdkWindowObject *private = (GdkWindowObject *)window; |
| 83 |
|
| 84 |
if (GDK_WINDOW_DESTROYED (window)) |
| 85 |
return NULL; |
| 86 |
|
| 87 |
return ((GdkWindowImplQuartz *)private->impl)->toplevel; |
| 88 |
} |
| 89 |
|
| 90 |
static CGContextRef |
| 91 |
gdk_window_impl_quartz_get_context (GdkDrawable *drawable, |
| 92 |
gboolean antialias) |
| 93 |
{ |
| 94 |
GdkDrawableImplQuartz *drawable_impl = GDK_DRAWABLE_IMPL_QUARTZ (drawable); |
| 95 |
GdkWindowImplQuartz *window_impl = GDK_WINDOW_IMPL_QUARTZ (drawable); |
| 96 |
CGContextRef cg_context; |
| 97 |
|
| 98 |
if (GDK_WINDOW_DESTROYED (drawable_impl->wrapper)) |
| 99 |
return NULL; |
| 100 |
|
| 101 |
/* Lock focus when not called as part of a drawRect call. This |
| 102 |
* is needed when called from outside "real" expose events, for |
| 103 |
* example for synthesized expose events when realizing windows |
| 104 |
* and for widgets that send fake expose events like the arrow |
| 105 |
* buttons in spinbuttons or the position marker in rulers. |
| 106 |
*/ |
| 107 |
if (window_impl->in_paint_rect_count == 0) |
| 108 |
{ |
| 109 |
if (![window_impl->view lockFocusIfCanDraw]) |
| 110 |
return NULL; |
| 111 |
} |
| 112 |
if (gdk_quartz_osx_version () < GDK_OSX_YOSEMITE) |
| 113 |
cg_context = [[NSGraphicsContext currentContext] graphicsPort]; |
| 114 |
else |
| 115 |
cg_context = [[NSGraphicsContext currentContext] CGContext]; |
| 116 |
|
| 117 |
if (!cg_context) |
| 118 |
return NULL; |
| 119 |
|
| 120 |
CGContextSaveGState (cg_context); |
| 121 |
CGContextSetAllowsAntialiasing (cg_context, antialias); |
| 122 |
|
| 123 |
/* We'll emulate the clipping caused by double buffering here */ |
| 124 |
if (window_impl->begin_paint_count != 0) |
| 125 |
{ |
| 126 |
CGRect rect; |
| 127 |
CGRect *cg_rects; |
| 128 |
GdkRectangle *rects; |
| 129 |
gint n_rects, i; |
| 130 |
|
| 131 |
gdk_region_get_rectangles (window_impl->paint_clip_region, |
| 132 |
&rects, &n_rects); |
| 133 |
|
| 134 |
if (n_rects == 1) |
| 135 |
cg_rects = ▭ |
| 136 |
else |
| 137 |
cg_rects = g_new (CGRect, n_rects); |
| 138 |
|
| 139 |
for (i = 0; i < n_rects; i++) |
| 140 |
{ |
| 141 |
cg_rects[i].origin.x = rects[i].x; |
| 142 |
cg_rects[i].origin.y = rects[i].y; |
| 143 |
cg_rects[i].size.width = rects[i].width; |
| 144 |
cg_rects[i].size.height = rects[i].height; |
| 145 |
} |
| 146 |
|
| 147 |
CGContextClipToRects (cg_context, cg_rects, n_rects); |
| 148 |
|
| 149 |
g_free (rects); |
| 150 |
if (cg_rects != &rect) |
| 151 |
g_free (cg_rects); |
| 152 |
} |
| 153 |
|
| 154 |
return cg_context; |
| 155 |
} |
| 156 |
|
| 157 |
static void |
| 158 |
check_grab_unmap (GdkWindow *window) |
| 159 |
{ |
| 160 |
GdkDisplay *display = gdk_drawable_get_display (window); |
| 161 |
|
| 162 |
_gdk_display_end_pointer_grab (display, 0, window, TRUE); |
| 163 |
|
| 164 |
if (display->keyboard_grab.window) |
| 165 |
{ |
| 166 |
GdkWindowObject *private = GDK_WINDOW_OBJECT (window); |
| 167 |
GdkWindowObject *tmp = GDK_WINDOW_OBJECT (display->keyboard_grab.window); |
| 168 |
|
| 169 |
while (tmp && tmp != private) |
| 170 |
tmp = tmp->parent; |
| 171 |
|
| 172 |
if (tmp) |
| 173 |
_gdk_display_unset_has_keyboard_grab (display, TRUE); |
| 174 |
} |
| 175 |
} |
| 176 |
|
| 177 |
static void |
| 178 |
check_grab_destroy (GdkWindow *window) |
| 179 |
{ |
| 180 |
GdkDisplay *display = gdk_drawable_get_display (window); |
| 181 |
GdkPointerGrabInfo *grab; |
| 182 |
|
| 183 |
/* Make sure there is no lasting grab in this native window */ |
| 184 |
grab = _gdk_display_get_last_pointer_grab (display); |
| 185 |
if (grab && grab->native_window == window) |
| 186 |
{ |
| 187 |
/* Serials are always 0 in quartz, but for clarity: */ |
| 188 |
grab->serial_end = grab->serial_start; |
| 189 |
grab->implicit_ungrab = TRUE; |
| 190 |
} |
| 191 |
|
| 192 |
if (window == display->keyboard_grab.native_window && |
| 193 |
display->keyboard_grab.window != NULL) |
| 194 |
_gdk_display_unset_has_keyboard_grab (display, TRUE); |
| 195 |
} |
| 196 |
|
| 197 |
static void |
| 198 |
gdk_window_impl_quartz_finalize (GObject *object) |
| 199 |
{ |
| 200 |
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (object); |
| 201 |
|
| 202 |
check_grab_destroy (GDK_DRAWABLE_IMPL_QUARTZ (object)->wrapper); |
| 203 |
|
| 204 |
if (impl->paint_clip_region) |
| 205 |
gdk_region_destroy (impl->paint_clip_region); |
| 206 |
|
| 207 |
if (impl->transient_for) |
| 208 |
g_object_unref (impl->transient_for); |
| 209 |
|
| 210 |
G_OBJECT_CLASS (parent_class)->finalize (object); |
| 211 |
} |
| 212 |
|
| 213 |
static void |
| 214 |
gdk_window_impl_quartz_class_init (GdkWindowImplQuartzClass *klass) |
| 215 |
{ |
| 216 |
GObjectClass *object_class = G_OBJECT_CLASS (klass); |
| 217 |
GdkDrawableImplQuartzClass *drawable_quartz_class = GDK_DRAWABLE_IMPL_QUARTZ_CLASS (klass); |
| 218 |
|
| 219 |
parent_class = g_type_class_peek_parent (klass); |
| 220 |
|
| 221 |
object_class->finalize = gdk_window_impl_quartz_finalize; |
| 222 |
|
| 223 |
drawable_quartz_class->get_context = gdk_window_impl_quartz_get_context; |
| 224 |
} |
| 225 |
|
| 226 |
static void |
| 227 |
gdk_window_impl_quartz_init (GdkWindowImplQuartz *impl) |
| 228 |
{ |
| 229 |
impl->type_hint = GDK_WINDOW_TYPE_HINT_NORMAL; |
| 230 |
} |
| 231 |
|
| 232 |
static void |
| 233 |
gdk_window_impl_quartz_begin_paint_region (GdkPaintable *paintable, |
| 234 |
GdkWindow *window, |
| 235 |
const GdkRegion *region) |
| 236 |
{ |
| 237 |
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (paintable); |
| 238 |
GdkWindowObject *private = (GdkWindowObject*)window; |
| 239 |
int n_rects; |
| 240 |
GdkRectangle *rects = NULL; |
| 241 |
GdkPixmap *bg_pixmap; |
| 242 |
GdkRegion *clipped_and_offset_region; |
| 243 |
gboolean free_clipped_and_offset_region = TRUE; |
| 244 |
|
| 245 |
bg_pixmap = private->bg_pixmap; |
| 246 |
|
| 247 |
clipped_and_offset_region = gdk_region_copy (region); |
| 248 |
|
| 249 |
gdk_region_intersect (clipped_and_offset_region, |
| 250 |
private->clip_region_with_children); |
| 251 |
gdk_region_offset (clipped_and_offset_region, |
| 252 |
private->abs_x, private->abs_y); |
| 253 |
|
| 254 |
if (impl->begin_paint_count == 0) |
| 255 |
{ |
| 256 |
impl->paint_clip_region = clipped_and_offset_region; |
| 257 |
free_clipped_and_offset_region = FALSE; |
| 258 |
} |
| 259 |
else |
| 260 |
gdk_region_union (impl->paint_clip_region, clipped_and_offset_region); |
| 261 |
|
| 262 |
impl->begin_paint_count++; |
| 263 |
|
| 264 |
if (bg_pixmap == GDK_NO_BG) |
| 265 |
goto done; |
| 266 |
|
| 267 |
gdk_region_get_rectangles (clipped_and_offset_region, &rects, &n_rects); |
| 268 |
|
| 269 |
if (n_rects == 0) |
| 270 |
goto done; |
| 271 |
|
| 272 |
if (bg_pixmap == NULL) |
| 273 |
{ |
| 274 |
CGContextRef cg_context; |
| 275 |
CGColorRef color; |
| 276 |
gint i; |
| 277 |
|
| 278 |
cg_context = gdk_quartz_drawable_get_context (GDK_DRAWABLE (impl), FALSE); |
| 279 |
|
| 280 |
if (!cg_context) |
| 281 |
goto done; |
| 282 |
|
| 283 |
color = _gdk_quartz_colormap_get_cgcolor_from_pixel (window, |
| 284 |
private->bg_color.pixel); |
| 285 |
CGContextSetFillColorWithColor (cg_context, color); |
| 286 |
CGColorRelease (color); |
| 287 |
|
| 288 |
for (i = 0; i < n_rects; i++) |
| 289 |
{ |
| 290 |
CGContextFillRect (cg_context, |
| 291 |
CGRectMake (rects[i].x, rects[i].y, |
| 292 |
rects[i].width, rects[i].height)); |
| 293 |
} |
| 294 |
|
| 295 |
gdk_quartz_drawable_release_context (GDK_DRAWABLE (impl), cg_context); |
| 296 |
} |
| 297 |
else |
| 298 |
{ |
| 299 |
int x, y; |
| 300 |
int x_offset, y_offset; |
| 301 |
int width, height; |
| 302 |
GdkGC *gc; |
| 303 |
|
| 304 |
x_offset = y_offset = 0; |
| 305 |
|
| 306 |
while (window && bg_pixmap == GDK_PARENT_RELATIVE_BG) |
| 307 |
{ |
| 308 |
/* If this window should have the same background as the parent, |
| 309 |
* fetch the parent. (And if the same goes for the parent, fetch |
| 310 |
* the grandparent, etc.) |
| 311 |
*/ |
| 312 |
x_offset += ((GdkWindowObject *) window)->x; |
| 313 |
y_offset += ((GdkWindowObject *) window)->y; |
| 314 |
window = GDK_WINDOW (((GdkWindowObject *) window)->parent); |
| 315 |
bg_pixmap = ((GdkWindowObject *) window)->bg_pixmap; |
| 316 |
} |
| 317 |
|
| 318 |
if (bg_pixmap == NULL || bg_pixmap == GDK_NO_BG || bg_pixmap == GDK_PARENT_RELATIVE_BG) |
| 319 |
{ |
| 320 |
/* Parent relative background but the parent doesn't have a |
| 321 |
* pixmap. |
| 322 |
*/ |
| 323 |
goto done; |
| 324 |
} |
| 325 |
|
| 326 |
/* Note: There should be a CG API to draw tiled images, we might |
| 327 |
* want to look into that for this. |
| 328 |
*/ |
| 329 |
gc = gdk_gc_new (GDK_DRAWABLE (impl)); |
| 330 |
|
| 331 |
gdk_drawable_get_size (GDK_DRAWABLE (bg_pixmap), &width, &height); |
| 332 |
|
| 333 |
x = -x_offset; |
| 334 |
while (x < (rects[0].x + rects[0].width)) |
| 335 |
{ |
| 336 |
if (x + width >= rects[0].x) |
| 337 |
{ |
| 338 |
y = -y_offset; |
| 339 |
while (y < (rects[0].y + rects[0].height)) |
| 340 |
{ |
| 341 |
if (y + height >= rects[0].y) |
| 342 |
gdk_draw_drawable (GDK_DRAWABLE (impl), gc, bg_pixmap, 0, 0, x, y, width, height); |
| 343 |
|
| 344 |
y += height; |
| 345 |
} |
| 346 |
} |
| 347 |
x += width; |
| 348 |
} |
| 349 |
|
| 350 |
g_object_unref (gc); |
| 351 |
} |
| 352 |
|
| 353 |
done: |
| 354 |
if (free_clipped_and_offset_region) |
| 355 |
gdk_region_destroy (clipped_and_offset_region); |
| 356 |
g_free (rects); |
| 357 |
} |
| 358 |
|
| 359 |
static void |
| 360 |
gdk_window_impl_quartz_end_paint (GdkPaintable *paintable) |
| 361 |
{ |
| 362 |
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (paintable); |
| 363 |
|
| 364 |
impl->begin_paint_count--; |
| 365 |
|
| 366 |
if (impl->begin_paint_count == 0) |
| 367 |
{ |
| 368 |
gdk_region_destroy (impl->paint_clip_region); |
| 369 |
impl->paint_clip_region = NULL; |
| 370 |
} |
| 371 |
} |
| 372 |
|
| 373 |
void |
| 374 |
_gdk_quartz_window_set_needs_display_in_rect (GdkWindow *window, |
| 375 |
GdkRectangle *rect) |
| 376 |
{ |
| 377 |
GdkWindowObject *private; |
| 378 |
GdkWindowImplQuartz *impl; |
| 379 |
|
| 380 |
private = GDK_WINDOW_OBJECT (window); |
| 381 |
impl = GDK_WINDOW_IMPL_QUARTZ (private->impl); |
| 382 |
|
| 383 |
if (!impl->needs_display_region) |
| 384 |
impl->needs_display_region = gdk_region_new (); |
| 385 |
|
| 386 |
gdk_region_union_with_rect (impl->needs_display_region, rect); |
| 387 |
|
| 388 |
[impl->view setNeedsDisplayInRect:NSMakeRect (rect->x, rect->y, |
| 389 |
rect->width, rect->height)]; |
| 390 |
|
| 391 |
} |
| 392 |
|
| 393 |
void |
| 394 |
_gdk_quartz_window_set_needs_display_in_region (GdkWindow *window, |
| 395 |
GdkRegion *region) |
| 396 |
{ |
| 397 |
GdkWindowObject *private; |
| 398 |
GdkWindowImplQuartz *impl; |
| 399 |
int i, n_rects; |
| 400 |
GdkRectangle *rects; |
| 401 |
|
| 402 |
private = GDK_WINDOW_OBJECT (window); |
| 403 |
impl = GDK_WINDOW_IMPL_QUARTZ (private->impl); |
| 404 |
|
| 405 |
if (!impl->needs_display_region) |
| 406 |
impl->needs_display_region = gdk_region_new (); |
| 407 |
|
| 408 |
gdk_region_union (impl->needs_display_region, region); |
| 409 |
|
| 410 |
gdk_region_get_rectangles (region, &rects, &n_rects); |
| 411 |
|
| 412 |
for (i = 0; i < n_rects; i++) |
| 413 |
[impl->view setNeedsDisplayInRect:NSMakeRect (rects[i].x, rects[i].y, |
| 414 |
rects[i].width, |
| 415 |
rects[i].height)]; |
| 416 |
|
| 417 |
g_free (rects); |
| 418 |
|
| 419 |
} |
| 420 |
|
| 421 |
void |
| 422 |
_gdk_windowing_window_process_updates_recurse (GdkWindow *window, |
| 423 |
GdkRegion *region) |
| 424 |
{ |
| 425 |
/* Make sure to only flush each toplevel at most once if we're called |
| 426 |
* from process_all_updates. |
| 427 |
*/ |
| 428 |
if (in_process_all_updates) |
| 429 |
{ |
| 430 |
GdkWindow *toplevel; |
| 431 |
|
| 432 |
toplevel = gdk_window_get_effective_toplevel (window); |
| 433 |
if (toplevel && WINDOW_IS_TOPLEVEL (toplevel)) |
| 434 |
{ |
| 435 |
GdkWindowObject *toplevel_private; |
| 436 |
GdkWindowImplQuartz *toplevel_impl; |
| 437 |
NSWindow *nswindow; |
| 438 |
|
| 439 |
toplevel_private = (GdkWindowObject *)toplevel; |
| 440 |
toplevel_impl = (GdkWindowImplQuartz *)toplevel_private->impl; |
| 441 |
nswindow = toplevel_impl->toplevel; |
| 442 |
|
| 443 |
/* In theory, we could skip the flush disabling, since we only |
| 444 |
* have one NSView. |
| 445 |
*/ |
| 446 |
if (nswindow && ![nswindow isFlushWindowDisabled]) |
| 447 |
{ |
| 448 |
[nswindow retain]; |
| 449 |
[nswindow disableFlushWindow]; |
| 450 |
update_nswindows = g_slist_prepend (update_nswindows, nswindow); |
| 451 |
} |
| 452 |
} |
| 453 |
} |
| 454 |
|
| 455 |
if (WINDOW_IS_TOPLEVEL (window)) |
| 456 |
_gdk_quartz_window_set_needs_display_in_region (window, region); |
| 457 |
else |
| 458 |
_gdk_window_process_updates_recurse (window, region); |
| 459 |
|
| 460 |
/* NOTE: I'm not sure if we should displayIfNeeded here. It slows down a |
| 461 |
* lot (since it triggers the beam syncing) and things seem to work |
| 462 |
* without it. |
| 463 |
*/ |
| 464 |
} |
| 465 |
|
| 466 |
void |
| 467 |
_gdk_windowing_before_process_all_updates (void) |
| 468 |
{ |
| 469 |
in_process_all_updates = TRUE; |
| 470 |
|
| 471 |
NSDisableScreenUpdates (); |
| 472 |
} |
| 473 |
|
| 474 |
void |
| 475 |
_gdk_windowing_after_process_all_updates (void) |
| 476 |
{ |
| 477 |
GSList *old_update_nswindows = update_nswindows; |
| 478 |
GSList *tmp_list = update_nswindows; |
| 479 |
|
| 480 |
update_nswindows = NULL; |
| 481 |
|
| 482 |
while (tmp_list) |
| 483 |
{ |
| 484 |
NSWindow *nswindow = tmp_list->data; |
| 485 |
|
| 486 |
[[nswindow contentView] displayIfNeeded]; |
| 487 |
|
| 488 |
_gdk_quartz_drawable_flush (NULL); |
| 489 |
|
| 490 |
/* 10.14 needs to be told that the view needs to be redrawn, see |
| 491 |
* https://gitlab.gnome.org/GNOME/gtk/issues/1479 */ |
| 492 |
if (gdk_quartz_osx_version() >= GDK_OSX_MOJAVE) |
| 493 |
[[nswindow contentView] setNeedsDisplay:YES]; |
| 494 |
[nswindow enableFlushWindow]; |
| 495 |
[nswindow flushWindow]; |
| 496 |
[nswindow release]; |
| 497 |
|
| 498 |
tmp_list = tmp_list->next; |
| 499 |
} |
| 500 |
|
| 501 |
g_slist_free (old_update_nswindows); |
| 502 |
|
| 503 |
in_process_all_updates = FALSE; |
| 504 |
|
| 505 |
NSEnableScreenUpdates (); |
| 506 |
} |
| 507 |
|
| 508 |
static void |
| 509 |
gdk_window_impl_quartz_paintable_init (GdkPaintableIface *iface) |
| 510 |
{ |
| 511 |
iface->begin_paint_region = gdk_window_impl_quartz_begin_paint_region; |
| 512 |
iface->end_paint = gdk_window_impl_quartz_end_paint; |
| 513 |
} |
| 514 |
|
| 515 |
GType |
| 516 |
_gdk_window_impl_quartz_get_type (void) |
| 517 |
{ |
| 518 |
static GType object_type = 0; |
| 519 |
|
| 520 |
if (!object_type) |
| 521 |
{ |
| 522 |
const GTypeInfo object_info = |
| 523 |
{ |
| 524 |
sizeof (GdkWindowImplQuartzClass), |
| 525 |
(GBaseInitFunc) NULL, |
| 526 |
(GBaseFinalizeFunc) NULL, |
| 527 |
(GClassInitFunc) gdk_window_impl_quartz_class_init, |
| 528 |
NULL, /* class_finalize */ |
| 529 |
NULL, /* class_data */ |
| 530 |
sizeof (GdkWindowImplQuartz), |
| 531 |
0, /* n_preallocs */ |
| 532 |
(GInstanceInitFunc) gdk_window_impl_quartz_init, |
| 533 |
}; |
| 534 |
|
| 535 |
const GInterfaceInfo paintable_info = |
| 536 |
{ |
| 537 |
(GInterfaceInitFunc) gdk_window_impl_quartz_paintable_init, |
| 538 |
NULL, |
| 539 |
NULL |
| 540 |
}; |
| 541 |
|
| 542 |
const GInterfaceInfo window_impl_info = |
| 543 |
{ |
| 544 |
(GInterfaceInitFunc) gdk_window_impl_iface_init, |
| 545 |
NULL, |
| 546 |
NULL |
| 547 |
}; |
| 548 |
|
| 549 |
object_type = g_type_register_static (GDK_TYPE_DRAWABLE_IMPL_QUARTZ, |
| 550 |
"GdkWindowImplQuartz", |
| 551 |
&object_info, 0); |
| 552 |
g_type_add_interface_static (object_type, |
| 553 |
GDK_TYPE_PAINTABLE, |
| 554 |
&paintable_info); |
| 555 |
g_type_add_interface_static (object_type, |
| 556 |
GDK_TYPE_WINDOW_IMPL, |
| 557 |
&window_impl_info); |
| 558 |
} |
| 559 |
|
| 560 |
return object_type; |
| 561 |
} |
| 562 |
|
| 563 |
GType |
| 564 |
_gdk_window_impl_get_type (void) |
| 565 |
{ |
| 566 |
return _gdk_window_impl_quartz_get_type (); |
| 567 |
} |
| 568 |
|
| 569 |
static const gchar * |
| 570 |
get_default_title (void) |
| 571 |
{ |
| 572 |
const char *title; |
| 573 |
|
| 574 |
title = g_get_application_name (); |
| 575 |
if (!title) |
| 576 |
title = g_get_prgname (); |
| 577 |
|
| 578 |
return title; |
| 579 |
} |
| 580 |
|
| 581 |
static void |
| 582 |
get_ancestor_coordinates_from_child (GdkWindow *child_window, |
| 583 |
gint child_x, |
| 584 |
gint child_y, |
| 585 |
GdkWindow *ancestor_window, |
| 586 |
gint *ancestor_x, |
| 587 |
gint *ancestor_y) |
| 588 |
{ |
| 589 |
GdkWindowObject *child_private = GDK_WINDOW_OBJECT (child_window); |
| 590 |
GdkWindowObject *ancestor_private = GDK_WINDOW_OBJECT (ancestor_window); |
| 591 |
|
| 592 |
while (child_private != ancestor_private) |
| 593 |
{ |
| 594 |
child_x += child_private->x; |
| 595 |
child_y += child_private->y; |
| 596 |
|
| 597 |
child_private = child_private->parent; |
| 598 |
} |
| 599 |
|
| 600 |
*ancestor_x = child_x; |
| 601 |
*ancestor_y = child_y; |
| 602 |
} |
| 603 |
|
| 604 |
void |
| 605 |
_gdk_quartz_window_debug_highlight (GdkWindow *window, gint number) |
| 606 |
{ |
| 607 |
GdkWindowObject *private = GDK_WINDOW_OBJECT (window); |
| 608 |
gint x, y; |
| 609 |
gint gx, gy; |
| 610 |
GdkWindow *toplevel; |
| 611 |
gint tx, ty; |
| 612 |
static NSWindow *debug_window[10]; |
| 613 |
static NSRect old_rect[10]; |
| 614 |
NSRect rect; |
| 615 |
NSColor *color; |
| 616 |
|
| 617 |
g_return_if_fail (number >= 0 && number <= 9); |
| 618 |
|
| 619 |
if (window == _gdk_root) |
| 620 |
return; |
| 621 |
|
| 622 |
if (window == NULL) |
| 623 |
{ |
| 624 |
if (debug_window[number]) |
| 625 |
[debug_window[number] close]; |
| 626 |
debug_window[number] = NULL; |
| 627 |
|
| 628 |
return; |
| 629 |
} |
| 630 |
|
| 631 |
toplevel = gdk_window_get_effective_toplevel (window); |
| 632 |
get_ancestor_coordinates_from_child (window, 0, 0, toplevel, &x, &y); |
| 633 |
|
| 634 |
gdk_window_get_origin (toplevel, &tx, &ty); |
| 635 |
x += tx; |
| 636 |
y += ty; |
| 637 |
|
| 638 |
_gdk_quartz_window_gdk_xy_to_xy (x, y + private->height, |
| 639 |
&gx, &gy); |
| 640 |
|
| 641 |
rect = NSMakeRect (gx, gy, private->width, private->height); |
| 642 |
|
| 643 |
if (debug_window[number] && NSEqualRects (rect, old_rect[number])) |
| 644 |
return; |
| 645 |
|
| 646 |
old_rect[number] = rect; |
| 647 |
|
| 648 |
if (debug_window[number]) |
| 649 |
[debug_window[number] close]; |
| 650 |
|
| 651 |
debug_window[number] = [[NSWindow alloc] initWithContentRect:rect |
| 652 |
styleMask:NSBorderlessWindowMask |
| 653 |
backing:NSBackingStoreBuffered |
| 654 |
defer:NO]; |
| 655 |
|
| 656 |
switch (number) |
| 657 |
{ |
| 658 |
case 0: |
| 659 |
color = [NSColor redColor]; |
| 660 |
break; |
| 661 |
case 1: |
| 662 |
color = [NSColor blueColor]; |
| 663 |
break; |
| 664 |
case 2: |
| 665 |
color = [NSColor greenColor]; |
| 666 |
break; |
| 667 |
case 3: |
| 668 |
color = [NSColor yellowColor]; |
| 669 |
break; |
| 670 |
case 4: |
| 671 |
color = [NSColor brownColor]; |
| 672 |
break; |
| 673 |
case 5: |
| 674 |
color = [NSColor purpleColor]; |
| 675 |
break; |
| 676 |
default: |
| 677 |
color = [NSColor blackColor]; |
| 678 |
break; |
| 679 |
} |
| 680 |
|
| 681 |
[debug_window[number] setBackgroundColor:color]; |
| 682 |
[debug_window[number] setAlphaValue:0.4]; |
| 683 |
[debug_window[number] setOpaque:NO]; |
| 684 |
[debug_window[number] setReleasedWhenClosed:YES]; |
| 685 |
[debug_window[number] setIgnoresMouseEvents:YES]; |
| 686 |
[debug_window[number] setLevel:NSFloatingWindowLevel]; |
| 687 |
|
| 688 |
[debug_window[number] orderFront:nil]; |
| 689 |
} |
| 690 |
|
| 691 |
gboolean |
| 692 |
_gdk_quartz_window_is_ancestor (GdkWindow *ancestor, |
| 693 |
GdkWindow *window) |
| 694 |
{ |
| 695 |
if (ancestor == NULL || window == NULL) |
| 696 |
return FALSE; |
| 697 |
|
| 698 |
return (gdk_window_get_parent (window) == ancestor || |
| 699 |
_gdk_quartz_window_is_ancestor (ancestor, |
| 700 |
gdk_window_get_parent (window))); |
| 701 |
} |
| 702 |
|
| 703 |
|
| 704 |
/* See notes on top of gdkscreen-quartz.c */ |
| 705 |
void |
| 706 |
_gdk_quartz_window_gdk_xy_to_xy (gint gdk_x, |
| 707 |
gint gdk_y, |
| 708 |
gint *ns_x, |
| 709 |
gint *ns_y) |
| 710 |
{ |
| 711 |
GdkScreenQuartz *screen_quartz = GDK_SCREEN_QUARTZ (_gdk_screen); |
| 712 |
|
| 713 |
if (ns_y) |
| 714 |
*ns_y = screen_quartz->height - gdk_y + screen_quartz->min_y; |
| 715 |
|
| 716 |
if (ns_x) |
| 717 |
*ns_x = gdk_x + screen_quartz->min_x; |
| 718 |
} |
| 719 |
|
| 720 |
void |
| 721 |
_gdk_quartz_window_xy_to_gdk_xy (gint ns_x, |
| 722 |
gint ns_y, |
| 723 |
gint *gdk_x, |
| 724 |
gint *gdk_y) |
| 725 |
{ |
| 726 |
GdkScreenQuartz *screen_quartz = GDK_SCREEN_QUARTZ (_gdk_screen); |
| 727 |
|
| 728 |
if (gdk_y) |
| 729 |
*gdk_y = screen_quartz->height - ns_y + screen_quartz->min_y; |
| 730 |
|
| 731 |
if (gdk_x) |
| 732 |
*gdk_x = ns_x - screen_quartz->min_x; |
| 733 |
} |
| 734 |
|
| 735 |
void |
| 736 |
_gdk_quartz_window_nspoint_to_gdk_xy (NSPoint point, |
| 737 |
gint *x, |
| 738 |
gint *y) |
| 739 |
{ |
| 740 |
_gdk_quartz_window_xy_to_gdk_xy (point.x, point.y, |
| 741 |
x, y); |
| 742 |
} |
| 743 |
|
| 744 |
static GdkWindow * |
| 745 |
find_child_window_helper (GdkWindow *window, |
| 746 |
gint x, |
| 747 |
gint y, |
| 748 |
gint x_offset, |
| 749 |
gint y_offset) |
| 750 |
{ |
| 751 |
GdkWindowImplQuartz *impl; |
| 752 |
GList *l; |
| 753 |
|
| 754 |
impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl); |
| 755 |
|
| 756 |
if (window == _gdk_root) |
| 757 |
update_toplevel_order (); |
| 758 |
|
| 759 |
for (l = impl->sorted_children; l; l = l->next) |
| 760 |
{ |
| 761 |
GdkWindowObject *child_private = l->data; |
| 762 |
GdkWindowImplQuartz *child_impl = GDK_WINDOW_IMPL_QUARTZ (child_private->impl); |
| 763 |
int temp_x, temp_y; |
| 764 |
|
| 765 |
if (!GDK_WINDOW_IS_MAPPED (child_private)) |
| 766 |
continue; |
| 767 |
|
| 768 |
temp_x = x_offset + child_private->x; |
| 769 |
temp_y = y_offset + child_private->y; |
| 770 |
|
| 771 |
/* Special-case the root window. We have to include the title |
| 772 |
* bar in the checks, otherwise the window below the title bar |
| 773 |
* will be found i.e. events punch through. (If we can find a |
| 774 |
* better way to deal with the events in gdkevents-quartz, this |
| 775 |
* might not be needed.) |
| 776 |
*/ |
| 777 |
if (window == _gdk_root) |
| 778 |
{ |
| 779 |
NSRect frame = NSMakeRect (0, 0, 100, 100); |
| 780 |
NSRect content; |
| 781 |
NSUInteger mask; |
| 782 |
int titlebar_height; |
| 783 |
|
| 784 |
mask = [child_impl->toplevel styleMask]; |
| 785 |
|
| 786 |
/* Get the title bar height. */ |
| 787 |
content = [NSWindow contentRectForFrameRect:frame |
| 788 |
styleMask:mask]; |
| 789 |
titlebar_height = frame.size.height - content.size.height; |
| 790 |
|
| 791 |
if (titlebar_height > 0 && |
| 792 |
x >= temp_x && y >= temp_y - titlebar_height && |
| 793 |
x < temp_x + child_private->width && y < temp_y) |
| 794 |
{ |
| 795 |
/* The root means "unknown" i.e. a window not managed by |
| 796 |
* GDK. |
| 797 |
*/ |
| 798 |
return (GdkWindow *)_gdk_root; |
| 799 |
} |
| 800 |
} |
| 801 |
|
| 802 |
if (x >= temp_x && y >= temp_y && |
| 803 |
x < temp_x + child_private->width && y < temp_y + child_private->height) |
| 804 |
{ |
| 805 |
/* Look for child windows. */ |
| 806 |
return find_child_window_helper (l->data, |
| 807 |
x, y, |
| 808 |
temp_x, temp_y); |
| 809 |
} |
| 810 |
} |
| 811 |
|
| 812 |
return window; |
| 813 |
} |
| 814 |
|
| 815 |
/* Given a GdkWindow and coordinates relative to it, returns the |
| 816 |
* innermost subwindow that contains the point. If the coordinates are |
| 817 |
* outside the passed in window, NULL is returned. |
| 818 |
*/ |
| 819 |
GdkWindow * |
| 820 |
_gdk_quartz_window_find_child (GdkWindow *window, |
| 821 |
gint x, |
| 822 |
gint y) |
| 823 |
{ |
| 824 |
GdkWindowObject *private = GDK_WINDOW_OBJECT (window); |
| 825 |
|
| 826 |
if (x >= 0 && y >= 0 && x < private->width && y < private->height) |
| 827 |
return find_child_window_helper (window, x, y, 0, 0); |
| 828 |
|
| 829 |
return NULL; |
| 830 |
} |
| 831 |
|
| 832 |
|
| 833 |
void |
| 834 |
_gdk_quartz_window_did_become_main (GdkWindow *window) |
| 835 |
{ |
| 836 |
main_window_stack = g_slist_remove (main_window_stack, window); |
| 837 |
|
| 838 |
if (GDK_WINDOW_OBJECT (window)->window_type != GDK_WINDOW_TEMP) |
| 839 |
main_window_stack = g_slist_prepend (main_window_stack, window); |
| 840 |
|
| 841 |
clear_toplevel_order (); |
| 842 |
} |
| 843 |
|
| 844 |
void |
| 845 |
_gdk_quartz_window_did_resign_main (GdkWindow *window) |
| 846 |
{ |
| 847 |
GdkWindow *new_window = NULL; |
| 848 |
|
| 849 |
if (main_window_stack) |
| 850 |
new_window = main_window_stack->data; |
| 851 |
else |
| 852 |
{ |
| 853 |
GList *toplevels; |
| 854 |
|
| 855 |
toplevels = gdk_window_get_toplevels (); |
| 856 |
if (toplevels) |
| 857 |
new_window = toplevels->data; |
| 858 |
g_list_free (toplevels); |
| 859 |
} |
| 860 |
|
| 861 |
if (new_window && |
| 862 |
new_window != window && |
| 863 |
GDK_WINDOW_IS_MAPPED (new_window) && |
| 864 |
WINDOW_IS_TOPLEVEL (new_window)) |
| 865 |
{ |
| 866 |
GdkWindowObject *private = (GdkWindowObject *) new_window; |
| 867 |
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl); |
| 868 |
|
| 869 |
[impl->toplevel makeKeyAndOrderFront:impl->toplevel]; |
| 870 |
} |
| 871 |
|
| 872 |
clear_toplevel_order (); |
| 873 |
} |
| 874 |
|
| 875 |
static NSScreen * |
| 876 |
get_nsscreen_for_point (gint x, gint y) |
| 877 |
{ |
| 878 |
int i; |
| 879 |
NSArray *screens; |
| 880 |
NSScreen *screen = NULL; |
| 881 |
|
| 882 |
GDK_QUARTZ_ALLOC_POOL; |
| 883 |
|
| 884 |
screens = [NSScreen screens]; |
| 885 |
|
| 886 |
for (i = 0; i < [screens count]; i++) |
| 887 |
{ |
| 888 |
NSRect rect = [[screens objectAtIndex:i] frame]; |
| 889 |
|
| 890 |
if (x >= rect.origin.x && x <= rect.origin.x + rect.size.width && |
| 891 |
y >= rect.origin.y && y <= rect.origin.y + rect.size.height) |
| 892 |
{ |
| 893 |
screen = [screens objectAtIndex:i]; |
| 894 |
break; |
| 895 |
} |
| 896 |
} |
| 897 |
|
| 898 |
GDK_QUARTZ_RELEASE_POOL; |
| 899 |
|
| 900 |
return screen; |
| 901 |
} |
| 902 |
|
| 903 |
void |
| 904 |
_gdk_window_impl_new (GdkWindow *window, |
| 905 |
GdkWindow *real_parent, |
| 906 |
GdkScreen *screen, |
| 907 |
GdkVisual *visual, |
| 908 |
GdkEventMask event_mask, |
| 909 |
GdkWindowAttr *attributes, |
| 910 |
gint attributes_mask) |
| 911 |
{ |
| 912 |
GdkWindowObject *private; |
| 913 |
GdkWindowImplQuartz *impl; |
| 914 |
GdkDrawableImplQuartz *draw_impl; |
| 915 |
GdkWindowImplQuartz *parent_impl; |
| 916 |
|
| 917 |
GDK_QUARTZ_ALLOC_POOL; |
| 918 |
|
| 919 |
private = (GdkWindowObject *)window; |
| 920 |
|
| 921 |
impl = g_object_new (_gdk_window_impl_get_type (), NULL); |
| 922 |
private->impl = (GdkDrawable *)impl; |
| 923 |
draw_impl = GDK_DRAWABLE_IMPL_QUARTZ (impl); |
| 924 |
draw_impl->wrapper = GDK_DRAWABLE (window); |
| 925 |
|
| 926 |
parent_impl = GDK_WINDOW_IMPL_QUARTZ (private->parent->impl); |
| 927 |
|
| 928 |
switch (private->window_type) |
| 929 |
{ |
| 930 |
case GDK_WINDOW_TOPLEVEL: |
| 931 |
case GDK_WINDOW_DIALOG: |
| 932 |
case GDK_WINDOW_TEMP: |
| 933 |
if (GDK_WINDOW_TYPE (private->parent) != GDK_WINDOW_ROOT) |
| 934 |
{ |
| 935 |
/* The common code warns for this case */ |
| 936 |
parent_impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (_gdk_root)->impl); |
| 937 |
} |
| 938 |
} |
| 939 |
|
| 940 |
if (!private->input_only) |
| 941 |
{ |
| 942 |
if (attributes_mask & GDK_WA_COLORMAP) |
| 943 |
{ |
| 944 |
draw_impl->colormap = attributes->colormap; |
| 945 |
g_object_ref (attributes->colormap); |
| 946 |
} |
| 947 |
else |
| 948 |
{ |
| 949 |
if (visual == gdk_screen_get_system_visual (_gdk_screen)) |
| 950 |
{ |
| 951 |
draw_impl->colormap = gdk_screen_get_system_colormap (_gdk_screen); |
| 952 |
g_object_ref (draw_impl->colormap); |
| 953 |
} |
| 954 |
else if (visual == gdk_screen_get_rgba_visual (_gdk_screen)) |
| 955 |
{ |
| 956 |
draw_impl->colormap = gdk_screen_get_rgba_colormap (_gdk_screen); |
| 957 |
g_object_ref (draw_impl->colormap); |
| 958 |
} |
| 959 |
else |
| 960 |
{ |
| 961 |
draw_impl->colormap = gdk_colormap_new (visual, FALSE); |
| 962 |
} |
| 963 |
} |
| 964 |
} |
| 965 |
else |
| 966 |
{ |
| 967 |
draw_impl->colormap = gdk_screen_get_system_colormap (_gdk_screen); |
| 968 |
g_object_ref (draw_impl->colormap); |
| 969 |
} |
| 970 |
|
| 971 |
/* Maintain the z-ordered list of children. */ |
| 972 |
if (private->parent != (GdkWindowObject *)_gdk_root) |
| 973 |
parent_impl->sorted_children = g_list_prepend (parent_impl->sorted_children, window); |
| 974 |
else |
| 975 |
clear_toplevel_order (); |
| 976 |
|
| 977 |
gdk_window_set_cursor (window, ((attributes_mask & GDK_WA_CURSOR) ? |
| 978 |
(attributes->cursor) : |
| 979 |
NULL)); |
| 980 |
|
| 981 |
switch (attributes->window_type) |
| 982 |
{ |
| 983 |
case GDK_WINDOW_TOPLEVEL: |
| 984 |
case GDK_WINDOW_DIALOG: |
| 985 |
case GDK_WINDOW_TEMP: |
| 986 |
{ |
| 987 |
NSScreen *screen; |
| 988 |
NSRect screen_rect; |
| 989 |
NSRect content_rect; |
| 990 |
NSUInteger style_mask; |
| 991 |
int nx, ny; |
| 992 |
const char *title; |
| 993 |
|
| 994 |
/* initWithContentRect will place on the mainScreen by default. |
| 995 |
* We want to select the screen to place on ourselves. We need |
| 996 |
* to find the screen the window will be on and correct the |
| 997 |
* content_rect coordinates to be relative to that screen. |
| 998 |
*/ |
| 999 |
_gdk_quartz_window_gdk_xy_to_xy (private->x, private->y, &nx, &ny); |
| 1000 |
|
| 1001 |
screen = get_nsscreen_for_point (nx, ny); |
| 1002 |
screen_rect = [screen frame]; |
| 1003 |
nx -= screen_rect.origin.x; |
| 1004 |
ny -= screen_rect.origin.y; |
| 1005 |
|
| 1006 |
content_rect = NSMakeRect (nx, ny - private->height, |
| 1007 |
private->width, |
| 1008 |
private->height); |
| 1009 |
|
| 1010 |
if (attributes->window_type == GDK_WINDOW_TEMP || |
| 1011 |
attributes->type_hint == GDK_WINDOW_TYPE_HINT_SPLASHSCREEN) |
| 1012 |
{ |
| 1013 |
style_mask = NSBorderlessWindowMask; |
| 1014 |
} |
| 1015 |
else |
| 1016 |
{ |
| 1017 |
style_mask = (NSTitledWindowMask | |
| 1018 |
NSClosableWindowMask | |
| 1019 |
NSMiniaturizableWindowMask | |
| 1020 |
NSResizableWindowMask); |
| 1021 |
} |
| 1022 |
|
| 1023 |
impl->toplevel = [[GdkQuartzWindow alloc] initWithContentRect:content_rect |
| 1024 |
styleMask:style_mask |
| 1025 |
backing:NSBackingStoreBuffered |
| 1026 |
defer:NO |
| 1027 |
screen:screen]; |
| 1028 |
|
| 1029 |
if (attributes_mask & GDK_WA_TITLE) |
| 1030 |
title = attributes->title; |
| 1031 |
else |
| 1032 |
title = get_default_title (); |
| 1033 |
|
| 1034 |
gdk_window_set_title (window, title); |
| 1035 |
|
| 1036 |
if (draw_impl->colormap == gdk_screen_get_rgba_colormap (_gdk_screen)) |
| 1037 |
{ |
| 1038 |
[impl->toplevel setOpaque:NO]; |
| 1039 |
[impl->toplevel setBackgroundColor:[NSColor clearColor]]; |
| 1040 |
} |
| 1041 |
|
| 1042 |
content_rect.origin.x = 0; |
| 1043 |
content_rect.origin.y = 0; |
| 1044 |
|
| 1045 |
impl->view = [[GdkQuartzView alloc] initWithFrame:content_rect]; |
| 1046 |
[impl->view setGdkWindow:window]; |
| 1047 |
[impl->toplevel setContentView:impl->view]; |
| 1048 |
[impl->view release]; |
| 1049 |
} |
| 1050 |
break; |
| 1051 |
|
| 1052 |
case GDK_WINDOW_CHILD: |
| 1053 |
{ |
| 1054 |
GdkWindowImplQuartz *parent_impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (private->parent)->impl); |
| 1055 |
|
| 1056 |
if (!private->input_only) |
| 1057 |
{ |
| 1058 |
NSRect frame_rect = NSMakeRect (private->x + private->parent->abs_x, |
| 1059 |
private->y + private->parent->abs_y, |
| 1060 |
private->width, |
| 1061 |
private->height); |
| 1062 |
|
| 1063 |
impl->view = [[GdkQuartzView alloc] initWithFrame:frame_rect]; |
| 1064 |
|
| 1065 |
[impl->view setGdkWindow:window]; |
| 1066 |
|
| 1067 |
/* GdkWindows should be hidden by default */ |
| 1068 |
[impl->view setHidden:YES]; |
| 1069 |
[parent_impl->view addSubview:impl->view]; |
| 1070 |
[impl->view release]; |
| 1071 |
} |
| 1072 |
} |
| 1073 |
break; |
| 1074 |
|
| 1075 |
default: |
| 1076 |
g_assert_not_reached (); |
| 1077 |
} |
| 1078 |
|
| 1079 |
GDK_QUARTZ_RELEASE_POOL; |
| 1080 |
|
| 1081 |
if (attributes_mask & GDK_WA_TYPE_HINT) |
| 1082 |
gdk_window_set_type_hint (window, attributes->type_hint); |
| 1083 |
} |
| 1084 |
|
| 1085 |
void |
| 1086 |
_gdk_quartz_window_update_position (GdkWindow *window) |
| 1087 |
{ |
| 1088 |
NSRect frame_rect; |
| 1089 |
NSRect content_rect; |
| 1090 |
GdkWindowObject *private = (GdkWindowObject *)window; |
| 1091 |
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl); |
| 1092 |
|
| 1093 |
GDK_QUARTZ_ALLOC_POOL; |
| 1094 |
|
| 1095 |
frame_rect = [impl->toplevel frame]; |
| 1096 |
content_rect = [impl->toplevel contentRectForFrameRect:frame_rect]; |
| 1097 |
|
| 1098 |
_gdk_quartz_window_xy_to_gdk_xy (content_rect.origin.x, |
| 1099 |
content_rect.origin.y + content_rect.size.height, |
| 1100 |
&private->x, &private->y); |
| 1101 |
|
| 1102 |
|
| 1103 |
GDK_QUARTZ_RELEASE_POOL; |
| 1104 |
} |
| 1105 |
|
| 1106 |
void |
| 1107 |
_gdk_windowing_update_window_sizes (GdkScreen *screen) |
| 1108 |
{ |
| 1109 |
GList *windows, *list; |
| 1110 |
GdkWindowObject *private = (GdkWindowObject *)_gdk_root; |
| 1111 |
|
| 1112 |
/* The size of the root window is so that it can contain all |
| 1113 |
* monitors attached to this machine. The monitors are laid out |
| 1114 |
* within this root window. We calculate the size of the root window |
| 1115 |
* and the positions of the different monitors in gdkscreen-quartz.c. |
| 1116 |
* |
| 1117 |
* This data is updated when the monitor configuration is changed. |
| 1118 |
*/ |
| 1119 |
private->x = 0; |
| 1120 |
private->y = 0; |
| 1121 |
private->abs_x = 0; |
| 1122 |
private->abs_y = 0; |
| 1123 |
private->width = gdk_screen_get_width (screen); |
| 1124 |
private->height = gdk_screen_get_height (screen); |
| 1125 |
|
| 1126 |
windows = gdk_screen_get_toplevel_windows (screen); |
| 1127 |
|
| 1128 |
for (list = windows; list; list = list->next) |
| 1129 |
_gdk_quartz_window_update_position (list->data); |
| 1130 |
|
| 1131 |
g_list_free (windows); |
| 1132 |
} |
| 1133 |
|
| 1134 |
void |
| 1135 |
_gdk_windowing_window_init (void) |
| 1136 |
{ |
| 1137 |
GdkWindowObject *private; |
| 1138 |
GdkWindowImplQuartz *impl; |
| 1139 |
GdkDrawableImplQuartz *drawable_impl; |
| 1140 |
|
| 1141 |
g_assert (_gdk_root == NULL); |
| 1142 |
|
| 1143 |
_gdk_root = g_object_new (GDK_TYPE_WINDOW, NULL); |
| 1144 |
|
| 1145 |
private = (GdkWindowObject *)_gdk_root; |
| 1146 |
private->impl = g_object_new (_gdk_window_impl_get_type (), NULL); |
| 1147 |
private->impl_window = private; |
| 1148 |
|
| 1149 |
impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (_gdk_root)->impl); |
| 1150 |
|
| 1151 |
_gdk_windowing_update_window_sizes (_gdk_screen); |
| 1152 |
|
| 1153 |
private->state = 0; /* We don't want GDK_WINDOW_STATE_WITHDRAWN here */ |
| 1154 |
private->window_type = GDK_WINDOW_ROOT; |
| 1155 |
private->depth = 24; |
| 1156 |
private->viewable = TRUE; |
| 1157 |
|
| 1158 |
drawable_impl = GDK_DRAWABLE_IMPL_QUARTZ (private->impl); |
| 1159 |
|
| 1160 |
drawable_impl->wrapper = GDK_DRAWABLE (private); |
| 1161 |
drawable_impl->colormap = gdk_screen_get_system_colormap (_gdk_screen); |
| 1162 |
g_object_ref (drawable_impl->colormap); |
| 1163 |
} |
| 1164 |
|
| 1165 |
static void |
| 1166 |
_gdk_quartz_window_destroy (GdkWindow *window, |
| 1167 |
gboolean recursing, |
| 1168 |
gboolean foreign_destroy) |
| 1169 |
{ |
| 1170 |
GdkWindowObject *private; |
| 1171 |
GdkWindowImplQuartz *impl; |
| 1172 |
GdkWindowObject *parent; |
| 1173 |
|
| 1174 |
private = GDK_WINDOW_OBJECT (window); |
| 1175 |
impl = GDK_WINDOW_IMPL_QUARTZ (private->impl); |
| 1176 |
|
| 1177 |
main_window_stack = g_slist_remove (main_window_stack, window); |
| 1178 |
|
| 1179 |
g_list_free (impl->sorted_children); |
| 1180 |
impl->sorted_children = NULL; |
| 1181 |
|
| 1182 |
parent = private->parent; |
| 1183 |
if (parent) |
| 1184 |
{ |
| 1185 |
GdkWindowImplQuartz *parent_impl = GDK_WINDOW_IMPL_QUARTZ (parent->impl); |
| 1186 |
|
| 1187 |
parent_impl->sorted_children = g_list_remove (parent_impl->sorted_children, window); |
| 1188 |
} |
| 1189 |
|
| 1190 |
_gdk_quartz_drawable_finish (GDK_DRAWABLE (impl)); |
| 1191 |
|
| 1192 |
if (!recursing && !foreign_destroy) |
| 1193 |
{ |
| 1194 |
GDK_QUARTZ_ALLOC_POOL; |
| 1195 |
|
| 1196 |
if (impl->toplevel) |
| 1197 |
[impl->toplevel close]; |
| 1198 |
else if (impl->view) |
| 1199 |
[impl->view removeFromSuperview]; |
| 1200 |
|
| 1201 |
GDK_QUARTZ_RELEASE_POOL; |
| 1202 |
} |
| 1203 |
} |
| 1204 |
|
| 1205 |
void |
| 1206 |
_gdk_windowing_window_destroy_foreign (GdkWindow *window) |
| 1207 |
{ |
| 1208 |
/* Foreign windows aren't supported in OSX. */ |
| 1209 |
} |
| 1210 |
|
| 1211 |
/* FIXME: This might be possible to simplify with client-side windows. Also |
| 1212 |
* note that already_mapped is not used yet, see the x11 backend. |
| 1213 |
*/ |
| 1214 |
static void |
| 1215 |
gdk_window_quartz_show (GdkWindow *window, gboolean already_mapped) |
| 1216 |
{ |
| 1217 |
GdkWindowObject *private = (GdkWindowObject *)window; |
| 1218 |
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl); |
| 1219 |
gboolean focus_on_map; |
| 1220 |
|
| 1221 |
GDK_QUARTZ_ALLOC_POOL; |
| 1222 |
|
| 1223 |
if (!GDK_WINDOW_IS_MAPPED (window)) |
| 1224 |
focus_on_map = private->focus_on_map; |
| 1225 |
else |
| 1226 |
focus_on_map = TRUE; |
| 1227 |
|
| 1228 |
if (impl->toplevel && WINDOW_IS_TOPLEVEL (window)) |
| 1229 |
{ |
| 1230 |
gboolean make_key; |
| 1231 |
|
| 1232 |
make_key = (private->accept_focus && focus_on_map && |
| 1233 |
private->window_type != GDK_WINDOW_TEMP); |
| 1234 |
|
| 1235 |
[(GdkQuartzWindow*)impl->toplevel showAndMakeKey:make_key]; |
| 1236 |
clear_toplevel_order (); |
| 1237 |
|
| 1238 |
_gdk_quartz_events_send_map_event (window); |
| 1239 |
} |
| 1240 |
else |
| 1241 |
{ |
| 1242 |
[impl->view setHidden:NO]; |
| 1243 |
} |
| 1244 |
|
| 1245 |
[impl->view setNeedsDisplay:YES]; |
| 1246 |
|
| 1247 |
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_WITHDRAWN, 0); |
| 1248 |
|
| 1249 |
if (private->state & GDK_WINDOW_STATE_MAXIMIZED) |
| 1250 |
gdk_window_maximize (window); |
| 1251 |
|
| 1252 |
if (private->state & GDK_WINDOW_STATE_ICONIFIED) |
| 1253 |
gdk_window_iconify (window); |
| 1254 |
|
| 1255 |
if (impl->transient_for && !GDK_WINDOW_DESTROYED (impl->transient_for)) |
| 1256 |
_gdk_quartz_window_attach_to_parent (window); |
| 1257 |
|
| 1258 |
GDK_QUARTZ_RELEASE_POOL; |
| 1259 |
} |
| 1260 |
|
| 1261 |
/* Temporarily unsets the parent window, if the window is a |
| 1262 |
* transient. |
| 1263 |
*/ |
| 1264 |
void |
| 1265 |
_gdk_quartz_window_detach_from_parent (GdkWindow *window) |
| 1266 |
{ |
| 1267 |
GdkWindowImplQuartz *impl; |
| 1268 |
|
| 1269 |
g_return_if_fail (GDK_IS_WINDOW (window)); |
| 1270 |
|
| 1271 |
impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl); |
| 1272 |
|
| 1273 |
g_return_if_fail (impl->toplevel != NULL); |
| 1274 |
|
| 1275 |
if (impl->transient_for && !GDK_WINDOW_DESTROYED (impl->transient_for)) |
| 1276 |
{ |
| 1277 |
GdkWindowImplQuartz *parent_impl; |
| 1278 |
|
| 1279 |
parent_impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (impl->transient_for)->impl); |
| 1280 |
[parent_impl->toplevel removeChildWindow:impl->toplevel]; |
| 1281 |
clear_toplevel_order (); |
| 1282 |
} |
| 1283 |
} |
| 1284 |
|
| 1285 |
/* Re-sets the parent window, if the window is a transient. */ |
| 1286 |
void |
| 1287 |
_gdk_quartz_window_attach_to_parent (GdkWindow *window) |
| 1288 |
{ |
| 1289 |
GdkWindowImplQuartz *impl; |
| 1290 |
|
| 1291 |
g_return_if_fail (GDK_IS_WINDOW (window)); |
| 1292 |
|
| 1293 |
impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl); |
| 1294 |
|
| 1295 |
g_return_if_fail (impl->toplevel != NULL); |
| 1296 |
|
| 1297 |
if (impl->transient_for && !GDK_WINDOW_DESTROYED (impl->transient_for)) |
| 1298 |
{ |
| 1299 |
GdkWindowImplQuartz *parent_impl; |
| 1300 |
|
| 1301 |
parent_impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (impl->transient_for)->impl); |
| 1302 |
[parent_impl->toplevel addChildWindow:impl->toplevel ordered:NSWindowAbove]; |
| 1303 |
clear_toplevel_order (); |
| 1304 |
} |
| 1305 |
} |
| 1306 |
|
| 1307 |
void |
| 1308 |
gdk_window_quartz_hide (GdkWindow *window) |
| 1309 |
{ |
| 1310 |
GdkWindowObject *private = (GdkWindowObject *)window; |
| 1311 |
GdkWindowImplQuartz *impl; |
| 1312 |
|
| 1313 |
/* Make sure we're not stuck in fullscreen mode. */ |
| 1314 |
if (get_fullscreen_geometry (window)) |
| 1315 |
SetSystemUIMode (kUIModeNormal, 0); |
| 1316 |
|
| 1317 |
check_grab_unmap (window); |
| 1318 |
|
| 1319 |
_gdk_window_clear_update_area (window); |
| 1320 |
|
| 1321 |
impl = GDK_WINDOW_IMPL_QUARTZ (private->impl); |
| 1322 |
|
| 1323 |
if (window && WINDOW_IS_TOPLEVEL (window)) |
| 1324 |
{ |
| 1325 |
/* Update main window. */ |
| 1326 |
main_window_stack = g_slist_remove (main_window_stack, window); |
| 1327 |
if ([NSApp mainWindow] == impl->toplevel) |
| 1328 |
_gdk_quartz_window_did_resign_main (window); |
| 1329 |
|
| 1330 |
if (impl->transient_for) |
| 1331 |
_gdk_quartz_window_detach_from_parent (window); |
| 1332 |
|
| 1333 |
[(GdkQuartzWindow*)impl->toplevel hide]; |
| 1334 |
} |
| 1335 |
else if (impl->view) |
| 1336 |
{ |
| 1337 |
[impl->view setHidden:YES]; |
| 1338 |
} |
| 1339 |
} |
| 1340 |
|
| 1341 |
void |
| 1342 |
gdk_window_quartz_withdraw (GdkWindow *window) |
| 1343 |
{ |
| 1344 |
gdk_window_hide (window); |
| 1345 |
} |
| 1346 |
|
| 1347 |
static void |
| 1348 |
move_resize_window_internal (GdkWindow *window, |
| 1349 |
gint x, |
| 1350 |
gint y, |
| 1351 |
gint width, |
| 1352 |
gint height) |
| 1353 |
{ |
| 1354 |
GdkWindowObject *private = (GdkWindowObject *)window; |
| 1355 |
GdkWindowImplQuartz *impl; |
| 1356 |
GdkRectangle old_visible; |
| 1357 |
GdkRectangle new_visible; |
| 1358 |
GdkRectangle scroll_rect; |
| 1359 |
GdkRegion *old_region; |
| 1360 |
GdkRegion *expose_region; |
| 1361 |
NSSize delta; |
| 1362 |
|
| 1363 |
if (GDK_WINDOW_DESTROYED (window)) |
| 1364 |
return; |
| 1365 |
|
| 1366 |
impl = GDK_WINDOW_IMPL_QUARTZ (private->impl); |
| 1367 |
|
| 1368 |
if ((x == -1 || (x == private->x)) && |
| 1369 |
(y == -1 || (y == private->y)) && |
| 1370 |
(width == -1 || (width == private->width)) && |
| 1371 |
(height == -1 || (height == private->height))) |
| 1372 |
{ |
| 1373 |
return; |
| 1374 |
} |
| 1375 |
|
| 1376 |
if (!impl->toplevel) |
| 1377 |
{ |
| 1378 |
/* The previously visible area of this window in a coordinate |
| 1379 |
* system rooted at the origin of this window. |
| 1380 |
*/ |
| 1381 |
old_visible.x = -private->x; |
| 1382 |
old_visible.y = -private->y; |
| 1383 |
|
| 1384 |
gdk_window_get_size (GDK_DRAWABLE (private->parent), |
| 1385 |
&old_visible.width, |
| 1386 |
&old_visible.height); |
| 1387 |
} |
| 1388 |
|
| 1389 |
if (x != -1) |
| 1390 |
{ |
| 1391 |
delta.width = x - private->x; |
| 1392 |
private->x = x; |
| 1393 |
} |
| 1394 |
else |
| 1395 |
{ |
| 1396 |
delta.width = 0; |
| 1397 |
} |
| 1398 |
|
| 1399 |
if (y != -1) |
| 1400 |
{ |
| 1401 |
delta.height = y - private->y; |
| 1402 |
private->y = y; |
| 1403 |
} |
| 1404 |
else |
| 1405 |
{ |
| 1406 |
delta.height = 0; |
| 1407 |
} |
| 1408 |
|
| 1409 |
if (width != -1) |
| 1410 |
private->width = width; |
| 1411 |
|
| 1412 |
if (height != -1) |
| 1413 |
private->height = height; |
| 1414 |
|
| 1415 |
GDK_QUARTZ_ALLOC_POOL; |
| 1416 |
|
| 1417 |
if (impl->toplevel) |
| 1418 |
{ |
| 1419 |
NSRect content_rect; |
| 1420 |
NSRect frame_rect; |
| 1421 |
gint gx, gy; |
| 1422 |
|
| 1423 |
_gdk_quartz_window_gdk_xy_to_xy (private->x, private->y + private->height, |
| 1424 |
&gx, &gy); |
| 1425 |
|
| 1426 |
content_rect = NSMakeRect (gx, gy, private->width, private->height); |
| 1427 |
|
| 1428 |
frame_rect = [impl->toplevel frameRectForContentRect:content_rect]; |
| 1429 |
[impl->toplevel setFrame:frame_rect display:YES]; |
| 1430 |
} |
| 1431 |
else |
| 1432 |
{ |
| 1433 |
if (!private->input_only) |
| 1434 |
{ |
| 1435 |
NSRect nsrect; |
| 1436 |
|
| 1437 |
nsrect = NSMakeRect (private->x, private->y, private->width, private->height); |
| 1438 |
|
| 1439 |
/* The newly visible area of this window in a coordinate |
| 1440 |
* system rooted at the origin of this window. |
| 1441 |
*/ |
| 1442 |
new_visible.x = -private->x; |
| 1443 |
new_visible.y = -private->y; |
| 1444 |
new_visible.width = old_visible.width; /* parent has not changed size */ |
| 1445 |
new_visible.height = old_visible.height; /* parent has not changed size */ |
| 1446 |
|
| 1447 |
expose_region = gdk_region_rectangle (&new_visible); |
| 1448 |
old_region = gdk_region_rectangle (&old_visible); |
| 1449 |
gdk_region_subtract (expose_region, old_region); |
| 1450 |
|
| 1451 |
/* Determine what (if any) part of the previously visible |
| 1452 |
* part of the window can be copied without a redraw |
| 1453 |
*/ |
| 1454 |
scroll_rect = old_visible; |
| 1455 |
scroll_rect.x -= delta.width; |
| 1456 |
scroll_rect.y -= delta.height; |
| 1457 |
gdk_rectangle_intersect (&scroll_rect, &old_visible, &scroll_rect); |
| 1458 |
|
| 1459 |
if (!gdk_region_empty (expose_region)) |
| 1460 |
{ |
| 1461 |
GdkRectangle* rects; |
| 1462 |
gint n_rects; |
| 1463 |
gint n; |
| 1464 |
|
| 1465 |
if (scroll_rect.width != 0 && scroll_rect.height != 0) |
| 1466 |
{ |
| 1467 |
[impl->view scrollRect:NSMakeRect (scroll_rect.x, |
| 1468 |
scroll_rect.y, |
| 1469 |
scroll_rect.width, |
| 1470 |
scroll_rect.height) |
| 1471 |
by:delta]; |
| 1472 |
} |
| 1473 |
|
| 1474 |
[impl->view setFrame:nsrect]; |
| 1475 |
|
| 1476 |
gdk_region_get_rectangles (expose_region, &rects, &n_rects); |
| 1477 |
|
| 1478 |
for (n = 0; n < n_rects; ++n) |
| 1479 |
_gdk_quartz_window_set_needs_display_in_rect (window, &rects[n]); |
| 1480 |
|
| 1481 |
g_free (rects); |
| 1482 |
} |
| 1483 |
else |
| 1484 |
{ |
| 1485 |
[impl->view setFrame:nsrect]; |
| 1486 |
[impl->view setNeedsDisplay:YES]; |
| 1487 |
} |
| 1488 |
|
| 1489 |
gdk_region_destroy (expose_region); |
| 1490 |
gdk_region_destroy (old_region); |
| 1491 |
} |
| 1492 |
} |
| 1493 |
|
| 1494 |
GDK_QUARTZ_RELEASE_POOL; |
| 1495 |
} |
| 1496 |
|
| 1497 |
static inline void |
| 1498 |
window_quartz_move (GdkWindow *window, |
| 1499 |
gint x, |
| 1500 |
gint y) |
| 1501 |
{ |
| 1502 |
g_return_if_fail (GDK_IS_WINDOW (window)); |
| 1503 |
|
| 1504 |
if (((GdkWindowObject *)window)->state & GDK_WINDOW_STATE_FULLSCREEN) |
| 1505 |
return; |
| 1506 |
|
| 1507 |
move_resize_window_internal (window, x, y, -1, -1); |
| 1508 |
} |
| 1509 |
|
| 1510 |
static inline void |
| 1511 |
window_quartz_resize (GdkWindow *window, |
| 1512 |
gint width, |
| 1513 |
gint height) |
| 1514 |
{ |
| 1515 |
g_return_if_fail (GDK_IS_WINDOW (window)); |
| 1516 |
|
| 1517 |
if (((GdkWindowObject *)window)->state & GDK_WINDOW_STATE_FULLSCREEN) |
| 1518 |
return; |
| 1519 |
|
| 1520 |
if (width < 1) |
| 1521 |
width = 1; |
| 1522 |
if (height < 1) |
| 1523 |
height = 1; |
| 1524 |
|
| 1525 |
move_resize_window_internal (window, -1, -1, width, height); |
| 1526 |
} |
| 1527 |
|
| 1528 |
static inline void |
| 1529 |
window_quartz_move_resize (GdkWindow *window, |
| 1530 |
gint x, |
| 1531 |
gint y, |
| 1532 |
gint width, |
| 1533 |
gint height) |
| 1534 |
{ |
| 1535 |
if (width < 1) |
| 1536 |
width = 1; |
| 1537 |
if (height < 1) |
| 1538 |
height = 1; |
| 1539 |
|
| 1540 |
move_resize_window_internal (window, x, y, width, height); |
| 1541 |
} |
| 1542 |
|
| 1543 |
static void |
| 1544 |
gdk_window_quartz_move_resize (GdkWindow *window, |
| 1545 |
gboolean with_move, |
| 1546 |
gint x, |
| 1547 |
gint y, |
| 1548 |
gint width, |
| 1549 |
gint height) |
| 1550 |
{ |
| 1551 |
if (with_move && (width < 0 && height < 0)) |
| 1552 |
window_quartz_move (window, x, y); |
| 1553 |
else |
| 1554 |
{ |
| 1555 |
if (with_move) |
| 1556 |
window_quartz_move_resize (window, x, y, width, height); |
| 1557 |
else |
| 1558 |
window_quartz_resize (window, width, height); |
| 1559 |
} |
| 1560 |
} |
| 1561 |
|
| 1562 |
/* FIXME: This might need fixing (reparenting didn't work before client-side |
| 1563 |
* windows either). |
| 1564 |
*/ |
| 1565 |
static gboolean |
| 1566 |
gdk_window_quartz_reparent (GdkWindow *window, |
| 1567 |
GdkWindow *new_parent, |
| 1568 |
gint x, |
| 1569 |
gint y) |
| 1570 |
{ |
| 1571 |
GdkWindowObject *private, *old_parent_private, *new_parent_private; |
| 1572 |
GdkWindowImplQuartz *impl, *old_parent_impl, *new_parent_impl; |
| 1573 |
NSView *view, *new_parent_view; |
| 1574 |
|
| 1575 |
if (new_parent == _gdk_root) |
| 1576 |
{ |
| 1577 |
/* Could be added, just needs implementing. */ |
| 1578 |
g_warning ("Reparenting to root window is not supported yet in the Mac OS X backend"); |
| 1579 |
return FALSE; |
| 1580 |
} |
| 1581 |
|
| 1582 |
private = GDK_WINDOW_OBJECT (window); |
| 1583 |
impl = GDK_WINDOW_IMPL_QUARTZ (private->impl); |
| 1584 |
view = impl->view; |
| 1585 |
|
| 1586 |
new_parent_private = GDK_WINDOW_OBJECT (new_parent); |
| 1587 |
new_parent_impl = GDK_WINDOW_IMPL_QUARTZ (new_parent_private->impl); |
| 1588 |
new_parent_view = new_parent_impl->view; |
| 1589 |
|
| 1590 |
old_parent_private = GDK_WINDOW_OBJECT (private->parent); |
| 1591 |
old_parent_impl = GDK_WINDOW_IMPL_QUARTZ (old_parent_private->impl); |
| 1592 |
|
| 1593 |
[view retain]; |
| 1594 |
|
| 1595 |
[view removeFromSuperview]; |
| 1596 |
[new_parent_view addSubview:view]; |
| 1597 |
|
| 1598 |
[view release]; |
| 1599 |
|
| 1600 |
private->parent = new_parent_private; |
| 1601 |
|
| 1602 |
if (old_parent_private) |
| 1603 |
{ |
| 1604 |
old_parent_impl->sorted_children = g_list_remove (old_parent_impl->sorted_children, window); |
| 1605 |
} |
| 1606 |
|
| 1607 |
new_parent_impl->sorted_children = g_list_prepend (new_parent_impl->sorted_children, window); |
| 1608 |
|
| 1609 |
return FALSE; |
| 1610 |
} |
| 1611 |
|
| 1612 |
/* Get the toplevel ordering from NSApp and update our own list. We do |
| 1613 |
* this on demand since the NSApp's list is not up to date directly |
| 1614 |
* after we get windowDidBecomeMain. |
| 1615 |
*/ |
| 1616 |
static void |
| 1617 |
update_toplevel_order (void) |
| 1618 |
{ |
| 1619 |
GdkWindowObject *root; |
| 1620 |
GdkWindowImplQuartz *root_impl; |
| 1621 |
NSEnumerator *enumerator; |
| 1622 |
id nswindow; |
| 1623 |
GList *toplevels = NULL; |
| 1624 |
|
| 1625 |
root = GDK_WINDOW_OBJECT (_gdk_root); |
| 1626 |
root_impl = GDK_WINDOW_IMPL_QUARTZ (root->impl); |
| 1627 |
|
| 1628 |
if (root_impl->sorted_children) |
| 1629 |
return; |
| 1630 |
|
| 1631 |
GDK_QUARTZ_ALLOC_POOL; |
| 1632 |
|
| 1633 |
enumerator = [[NSApp orderedWindows] objectEnumerator]; |
| 1634 |
while ((nswindow = [enumerator nextObject])) |
| 1635 |
{ |
| 1636 |
GdkWindow *window; |
| 1637 |
|
| 1638 |
if (![[nswindow contentView] isKindOfClass:[GdkQuartzView class]]) |
| 1639 |
continue; |
| 1640 |
|
| 1641 |
window = [(GdkQuartzView *)[nswindow contentView] gdkWindow]; |
| 1642 |
toplevels = g_list_prepend (toplevels, window); |
| 1643 |
} |
| 1644 |
|
| 1645 |
GDK_QUARTZ_RELEASE_POOL; |
| 1646 |
|
| 1647 |
root_impl->sorted_children = g_list_reverse (toplevels); |
| 1648 |
} |
| 1649 |
|
| 1650 |
static void |
| 1651 |
clear_toplevel_order (void) |
| 1652 |
{ |
| 1653 |
GdkWindowObject *root; |
| 1654 |
GdkWindowImplQuartz *root_impl; |
| 1655 |
|
| 1656 |
root = GDK_WINDOW_OBJECT (_gdk_root); |
| 1657 |
root_impl = GDK_WINDOW_IMPL_QUARTZ (root->impl); |
| 1658 |
|
| 1659 |
g_list_free (root_impl->sorted_children); |
| 1660 |
root_impl->sorted_children = NULL; |
| 1661 |
} |
| 1662 |
|
| 1663 |
static void |
| 1664 |
gdk_window_quartz_raise (GdkWindow *window) |
| 1665 |
{ |
| 1666 |
if (GDK_WINDOW_DESTROYED (window)) |
| 1667 |
return; |
| 1668 |
|
| 1669 |
if (WINDOW_IS_TOPLEVEL (window)) |
| 1670 |
{ |
| 1671 |
GdkWindowImplQuartz *impl; |
| 1672 |
|
| 1673 |
impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl); |
| 1674 |
[impl->toplevel orderFront:impl->toplevel]; |
| 1675 |
|
| 1676 |
clear_toplevel_order (); |
| 1677 |
} |
| 1678 |
else |
| 1679 |
{ |
| 1680 |
GdkWindowObject *parent = GDK_WINDOW_OBJECT (window)->parent; |
| 1681 |
|
| 1682 |
if (parent) |
| 1683 |
{ |
| 1684 |
GdkWindowImplQuartz *impl; |
| 1685 |
|
| 1686 |
impl = (GdkWindowImplQuartz *)parent->impl; |
| 1687 |
|
| 1688 |
impl->sorted_children = g_list_remove (impl->sorted_children, window); |
| 1689 |
impl->sorted_children = g_list_prepend (impl->sorted_children, window); |
| 1690 |
} |
| 1691 |
} |
| 1692 |
} |
| 1693 |
|
| 1694 |
static void |
| 1695 |
gdk_window_quartz_lower (GdkWindow *window) |
| 1696 |
{ |
| 1697 |
if (GDK_WINDOW_DESTROYED (window)) |
| 1698 |
return; |
| 1699 |
|
| 1700 |
if (WINDOW_IS_TOPLEVEL (window)) |
| 1701 |
{ |
| 1702 |
GdkWindowImplQuartz *impl; |
| 1703 |
|
| 1704 |
impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl); |
| 1705 |
[impl->toplevel orderBack:impl->toplevel]; |
| 1706 |
|
| 1707 |
clear_toplevel_order (); |
| 1708 |
} |
| 1709 |
else |
| 1710 |
{ |
| 1711 |
GdkWindowObject *parent = GDK_WINDOW_OBJECT (window)->parent; |
| 1712 |
|
| 1713 |
if (parent) |
| 1714 |
{ |
| 1715 |
GdkWindowImplQuartz *impl; |
| 1716 |
|
| 1717 |
impl = (GdkWindowImplQuartz *)parent->impl; |
| 1718 |
|
| 1719 |
impl->sorted_children = g_list_remove (impl->sorted_children, window); |
| 1720 |
impl->sorted_children = g_list_append (impl->sorted_children, window); |
| 1721 |
} |
| 1722 |
} |
| 1723 |
} |
| 1724 |
|
| 1725 |
static void |
| 1726 |
gdk_window_quartz_restack_toplevel (GdkWindow *window, |
| 1727 |
GdkWindow *sibling, |
| 1728 |
gboolean above) |
| 1729 |
{ |
| 1730 |
GdkWindowImplQuartz *impl; |
| 1731 |
gint sibling_num; |
| 1732 |
|
| 1733 |
impl = GDK_WINDOW_IMPL_QUARTZ (((GdkWindowObject *)sibling)->impl); |
| 1734 |
sibling_num = [impl->toplevel windowNumber]; |
| 1735 |
|
| 1736 |
impl = GDK_WINDOW_IMPL_QUARTZ (((GdkWindowObject *)window)->impl); |
| 1737 |
|
| 1738 |
if (above) |
| 1739 |
[impl->toplevel orderWindow:NSWindowAbove relativeTo:sibling_num]; |
| 1740 |
else |
| 1741 |
[impl->toplevel orderWindow:NSWindowBelow relativeTo:sibling_num]; |
| 1742 |
} |
| 1743 |
|
| 1744 |
static void |
| 1745 |
gdk_window_quartz_set_background (GdkWindow *window, |
| 1746 |
const GdkColor *color) |
| 1747 |
{ |
| 1748 |
/* FIXME: We could theoretically set the background color for toplevels |
| 1749 |
* here. (Currently we draw the background before emitting expose events) |
| 1750 |
*/ |
| 1751 |
} |
| 1752 |
|
| 1753 |
static void |
| 1754 |
gdk_window_quartz_set_back_pixmap (GdkWindow *window, |
| 1755 |
GdkPixmap *pixmap) |
| 1756 |
{ |
| 1757 |
/* FIXME: Could theoretically set some background image here. (Currently |
| 1758 |
* the back pixmap is drawn before emitting expose events. |
| 1759 |
*/ |
| 1760 |
} |
| 1761 |
|
| 1762 |
static void |
| 1763 |
gdk_window_quartz_set_cursor (GdkWindow *window, |
| 1764 |
GdkCursor *cursor) |
| 1765 |
{ |
| 1766 |
GdkCursorPrivate *cursor_private; |
| 1767 |
NSCursor *nscursor; |
| 1768 |
|
| 1769 |
cursor_private = (GdkCursorPrivate *)cursor; |
| 1770 |
|
| 1771 |
if (GDK_WINDOW_DESTROYED (window)) |
| 1772 |
return; |
| 1773 |
|
| 1774 |
if (!cursor) |
| 1775 |
nscursor = [NSCursor arrowCursor]; |
| 1776 |
else |
| 1777 |
nscursor = cursor_private->nscursor; |
| 1778 |
|
| 1779 |
[nscursor set]; |
| 1780 |
} |
| 1781 |
|
| 1782 |
static void |
| 1783 |
gdk_window_quartz_get_geometry (GdkWindow *window, |
| 1784 |
gint *x, |
| 1785 |
gint *y, |
| 1786 |
gint *width, |
| 1787 |
gint *height, |
| 1788 |
gint *depth) |
| 1789 |
{ |
| 1790 |
GdkWindowImplQuartz *impl; |
| 1791 |
GdkWindowObject *private; |
| 1792 |
NSRect ns_rect; |
| 1793 |
|
| 1794 |
if (GDK_WINDOW_DESTROYED (window)) |
| 1795 |
return; |
| 1796 |
|
| 1797 |
impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl); |
| 1798 |
private = GDK_WINDOW_OBJECT (window); |
| 1799 |
if (window == _gdk_root) |
| 1800 |
{ |
| 1801 |
if (x) |
| 1802 |
*x = 0; |
| 1803 |
if (y) |
| 1804 |
*y = 0; |
| 1805 |
|
| 1806 |
if (width) |
| 1807 |
*width = private->width; |
| 1808 |
if (height) |
| 1809 |
*height = private->height; |
| 1810 |
} |
| 1811 |
else if (WINDOW_IS_TOPLEVEL (window)) |
| 1812 |
{ |
| 1813 |
ns_rect = [impl->toplevel contentRectForFrameRect:[impl->toplevel frame]]; |
| 1814 |
|
| 1815 |
/* This doesn't work exactly as in X. There doesn't seem to be a |
| 1816 |
* way to get the coords relative to the parent window (usually |
| 1817 |
* the window frame), but that seems useless except for |
| 1818 |
* borderless windows where it's relative to the root window. So |
| 1819 |
* we return (0, 0) (should be something like (0, 22)) for |
| 1820 |
* windows with borders and the root relative coordinates |
| 1821 |
* otherwise. |
| 1822 |
*/ |
| 1823 |
if ([impl->toplevel styleMask] == NSBorderlessWindowMask) |
| 1824 |
{ |
| 1825 |
_gdk_quartz_window_xy_to_gdk_xy (ns_rect.origin.x, |
| 1826 |
ns_rect.origin.y + ns_rect.size.height, |
| 1827 |
x, y); |
| 1828 |
} |
| 1829 |
else |
| 1830 |
{ |
| 1831 |
if (x) |
| 1832 |
*x = 0; |
| 1833 |
if (y) |
| 1834 |
*y = 0; |
| 1835 |
} |
| 1836 |
|
| 1837 |
if (width) |
| 1838 |
*width = ns_rect.size.width; |
| 1839 |
if (height) |
| 1840 |
*height = ns_rect.size.height; |
| 1841 |
} |
| 1842 |
else |
| 1843 |
{ |
| 1844 |
ns_rect = [impl->view frame]; |
| 1845 |
|
| 1846 |
if (x) |
| 1847 |
*x = ns_rect.origin.x; |
| 1848 |
if (y) |
| 1849 |
*y = ns_rect.origin.y; |
| 1850 |
if (width) |
| 1851 |
*width = ns_rect.size.width; |
| 1852 |
if (height) |
| 1853 |
*height = ns_rect.size.height; |
| 1854 |
} |
| 1855 |
|
| 1856 |
if (depth) |
| 1857 |
*depth = gdk_drawable_get_depth (window); |
| 1858 |
} |
| 1859 |
|
| 1860 |
static gint |
| 1861 |
gdk_window_quartz_get_root_coords (GdkWindow *window, |
| 1862 |
gint x, |
| 1863 |
gint y, |
| 1864 |
gint *root_x, |
| 1865 |
gint *root_y) |
| 1866 |
{ |
| 1867 |
GdkWindowObject *private; |
| 1868 |
int tmp_x = 0, tmp_y = 0; |
| 1869 |
GdkWindow *toplevel; |
| 1870 |
NSRect content_rect; |
| 1871 |
GdkWindowImplQuartz *impl; |
| 1872 |
|
| 1873 |
if (GDK_WINDOW_DESTROYED (window)) |
| 1874 |
{ |
| 1875 |
if (root_x) |
| 1876 |
*root_x = 0; |
| 1877 |
if (root_y) |
| 1878 |
*root_y = 0; |
| 1879 |
|
| 1880 |
return 0; |
| 1881 |
} |
| 1882 |
|
| 1883 |
if (window == _gdk_root) |
| 1884 |
{ |
| 1885 |
if (root_x) |
| 1886 |
*root_x = x; |
| 1887 |
if (root_y) |
| 1888 |
*root_y = y; |
| 1889 |
|
| 1890 |
return 1; |
| 1891 |
} |
| 1892 |
|
| 1893 |
private = GDK_WINDOW_OBJECT (window); |
| 1894 |
|
| 1895 |
toplevel = gdk_window_get_toplevel (window); |
| 1896 |
impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (toplevel)->impl); |
| 1897 |
|
| 1898 |
content_rect = [impl->toplevel contentRectForFrameRect:[impl->toplevel frame]]; |
| 1899 |
|
| 1900 |
_gdk_quartz_window_xy_to_gdk_xy (content_rect.origin.x, |
| 1901 |
content_rect.origin.y + content_rect.size.height, |
| 1902 |
&tmp_x, &tmp_y); |
| 1903 |
|
| 1904 |
tmp_x += x; |
| 1905 |
tmp_y += y; |
| 1906 |
|
| 1907 |
while (private != GDK_WINDOW_OBJECT (toplevel)) |
| 1908 |
{ |
| 1909 |
if (_gdk_window_has_impl ((GdkWindow *)private)) |
| 1910 |
{ |
| 1911 |
tmp_x += private->x; |
| 1912 |
tmp_y += private->y; |
| 1913 |
} |
| 1914 |
|
| 1915 |
private = private->parent; |
| 1916 |
} |
| 1917 |
|
| 1918 |
if (root_x) |
| 1919 |
*root_x = tmp_x; |
| 1920 |
if (root_y) |
| 1921 |
*root_y = tmp_y; |
| 1922 |
|
| 1923 |
return TRUE; |
| 1924 |
} |
| 1925 |
|
| 1926 |
static gboolean |
| 1927 |
gdk_window_quartz_get_deskrelative_origin (GdkWindow *window, |
| 1928 |
gint *x, |
| 1929 |
gint *y) |
| 1930 |
{ |
| 1931 |
return gdk_window_get_origin (window, x, y); |
| 1932 |
} |
| 1933 |
|
| 1934 |
void |
| 1935 |
gdk_window_get_root_origin (GdkWindow *window, |
| 1936 |
gint *x, |
| 1937 |
gint *y) |
| 1938 |
{ |
| 1939 |
GdkRectangle rect; |
| 1940 |
|
| 1941 |
rect.x = 0; |
| 1942 |
rect.y = 0; |
| 1943 |
|
| 1944 |
gdk_window_get_frame_extents (window, &rect); |
| 1945 |
|
| 1946 |
if (x) |
| 1947 |
*x = rect.x; |
| 1948 |
|
| 1949 |
if (y) |
| 1950 |
*y = rect.y; |
| 1951 |
} |
| 1952 |
|
| 1953 |
/* Returns coordinates relative to the passed in window. */ |
| 1954 |
static GdkWindow * |
| 1955 |
gdk_window_quartz_get_pointer_helper (GdkWindow *window, |
| 1956 |
gint *x, |
| 1957 |
gint *y, |
| 1958 |
GdkModifierType *mask) |
| 1959 |
{ |
| 1960 |
GdkWindowObject *toplevel; |
| 1961 |
GdkWindowObject *private; |
| 1962 |
NSPoint point; |
| 1963 |
gint x_tmp, y_tmp; |
| 1964 |
GdkWindow *found_window; |
| 1965 |
|
| 1966 |
g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL); |
| 1967 |
|
| 1968 |
if (GDK_WINDOW_DESTROYED (window)) |
| 1969 |
{ |
| 1970 |
*x = 0; |
| 1971 |
*y = 0; |
| 1972 |
*mask = 0; |
| 1973 |
return NULL; |
| 1974 |
} |
| 1975 |
|
| 1976 |
toplevel = GDK_WINDOW_OBJECT (gdk_window_get_effective_toplevel (window)); |
| 1977 |
|
| 1978 |
*mask = _gdk_quartz_events_get_current_keyboard_modifiers () |
| 1979 |
| _gdk_quartz_events_get_current_mouse_modifiers (); |
| 1980 |
|
| 1981 |
/* Get the y coordinate, needs to be flipped. */ |
| 1982 |
if (window == _gdk_root) |
| 1983 |
{ |
| 1984 |
point = [NSEvent mouseLocation]; |
| 1985 |
_gdk_quartz_window_nspoint_to_gdk_xy (point, &x_tmp, &y_tmp); |
| 1986 |
} |
| 1987 |
else |
| 1988 |
{ |
| 1989 |
GdkWindowImplQuartz *impl; |
| 1990 |
NSWindow *nswindow; |
| 1991 |
|
| 1992 |
impl = GDK_WINDOW_IMPL_QUARTZ (toplevel->impl); |
| 1993 |
private = GDK_WINDOW_OBJECT (toplevel); |
| 1994 |
nswindow = impl->toplevel; |
| 1995 |
|
| 1996 |
point = [nswindow mouseLocationOutsideOfEventStream]; |
| 1997 |
|
| 1998 |
x_tmp = point.x; |
| 1999 |
y_tmp = private->height - point.y; |
| 2000 |
|
| 2001 |
window = (GdkWindow *)toplevel; |
| 2002 |
} |
| 2003 |
|
| 2004 |
found_window = _gdk_quartz_window_find_child (window, x_tmp, y_tmp); |
| 2005 |
|
| 2006 |
/* We never return the root window. */ |
| 2007 |
if (found_window == _gdk_root) |
| 2008 |
found_window = NULL; |
| 2009 |
|
| 2010 |
*x = x_tmp; |
| 2011 |
*y = y_tmp; |
| 2012 |
|
| 2013 |
return found_window; |
| 2014 |
} |
| 2015 |
|
| 2016 |
static gboolean |
| 2017 |
gdk_window_quartz_get_pointer (GdkWindow *window, |
| 2018 |
gint *x, |
| 2019 |
gint *y, |
| 2020 |
GdkModifierType *mask) |
| 2021 |
{ |
| 2022 |
return gdk_window_quartz_get_pointer_helper (window, x, y, mask) != NULL; |
| 2023 |
} |
| 2024 |
|
| 2025 |
/* Returns coordinates relative to the root. */ |
| 2026 |
void |
| 2027 |
_gdk_windowing_get_pointer (GdkDisplay *display, |
| 2028 |
GdkScreen **screen, |
| 2029 |
gint *x, |
| 2030 |
gint *y, |
| 2031 |
GdkModifierType *mask) |
| 2032 |
{ |
| 2033 |
g_return_if_fail (display == _gdk_display); |
| 2034 |
|
| 2035 |
*screen = _gdk_screen; |
| 2036 |
gdk_window_quartz_get_pointer_helper (_gdk_root, x, y, mask); |
| 2037 |
} |
| 2038 |
|
| 2039 |
void |
| 2040 |
gdk_display_warp_pointer (GdkDisplay *display, |
| 2041 |
GdkScreen *screen, |
| 2042 |
gint x, |
| 2043 |
gint y) |
| 2044 |
{ |
| 2045 |
CGDisplayMoveCursorToPoint (CGMainDisplayID (), CGPointMake (x, y)); |
| 2046 |
} |
| 2047 |
|
| 2048 |
/* Returns coordinates relative to the found window. */ |
| 2049 |
GdkWindow * |
| 2050 |
_gdk_windowing_window_at_pointer (GdkDisplay *display, |
| 2051 |
gint *win_x, |
| 2052 |
gint *win_y, |
| 2053 |
GdkModifierType *mask, |
| 2054 |
gboolean get_toplevel) |
| 2055 |
{ |
| 2056 |
GdkWindow *found_window; |
| 2057 |
gint x, y; |
| 2058 |
GdkModifierType tmp_mask = 0; |
| 2059 |
|
| 2060 |
found_window = gdk_window_quartz_get_pointer_helper (_gdk_root, |
| 2061 |
&x, &y, |
| 2062 |
&tmp_mask); |
| 2063 |
if (found_window) |
| 2064 |
{ |
| 2065 |
GdkWindowObject *private; |
| 2066 |
|
| 2067 |
/* The coordinates returned above are relative the root, we want |
| 2068 |
* coordinates relative the window here. |
| 2069 |
*/ |
| 2070 |
private = GDK_WINDOW_OBJECT (found_window); |
| 2071 |
while (private != GDK_WINDOW_OBJECT (_gdk_root)) |
| 2072 |
{ |
| 2073 |
x -= private->x; |
| 2074 |
y -= private->y; |
| 2075 |
|
| 2076 |
private = private->parent; |
| 2077 |
} |
| 2078 |
|
| 2079 |
*win_x = x; |
| 2080 |
*win_y = y; |
| 2081 |
} |
| 2082 |
else |
| 2083 |
{ |
| 2084 |
/* Mimic the X backend here, -1,-1 for unknown windows. */ |
| 2085 |
*win_x = -1; |
| 2086 |
*win_y = -1; |
| 2087 |
} |
| 2088 |
|
| 2089 |
if (mask) |
| 2090 |
*mask = tmp_mask; |
| 2091 |
|
| 2092 |
if (get_toplevel) |
| 2093 |
{ |
| 2094 |
GdkWindowObject *w = (GdkWindowObject *)found_window; |
| 2095 |
/* Requested toplevel, find it. */ |
| 2096 |
/* TODO: This can be implemented more efficient by never |
| 2097 |
recursing into children in the first place */ |
| 2098 |
if (w) |
| 2099 |
{ |
| 2100 |
/* Convert to toplevel */ |
| 2101 |
while (w->parent != NULL && |
| 2102 |
w->parent->window_type != GDK_WINDOW_ROOT) |
| 2103 |
{ |
| 2104 |
*win_x += w->x; |
| 2105 |
*win_y += w->y; |
| 2106 |
w = w->parent; |
| 2107 |
} |
| 2108 |
found_window = (GdkWindow *)w; |
| 2109 |
} |
| 2110 |
} |
| 2111 |
|
| 2112 |
return found_window; |
| 2113 |
} |
| 2114 |
|
| 2115 |
static GdkEventMask |
| 2116 |
gdk_window_quartz_get_events (GdkWindow *window) |
| 2117 |
{ |
| 2118 |
if (GDK_WINDOW_DESTROYED (window)) |
| 2119 |
return 0; |
| 2120 |
else |
| 2121 |
return GDK_WINDOW_OBJECT (window)->event_mask; |
| 2122 |
} |
| 2123 |
|
| 2124 |
static void |
| 2125 |
gdk_window_quartz_set_events (GdkWindow *window, |
| 2126 |
GdkEventMask event_mask) |
| 2127 |
{ |
| 2128 |
/* The mask is set in the common code. */ |
| 2129 |
} |
| 2130 |
|
| 2131 |
void |
| 2132 |
gdk_window_set_urgency_hint (GdkWindow *window, |
| 2133 |
gboolean urgent) |
| 2134 |
{ |
| 2135 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2136 |
!WINDOW_IS_TOPLEVEL (window)) |
| 2137 |
return; |
| 2138 |
|
| 2139 |
/* FIXME: Implement */ |
| 2140 |
} |
| 2141 |
|
| 2142 |
void |
| 2143 |
gdk_window_set_geometry_hints (GdkWindow *window, |
| 2144 |
const GdkGeometry *geometry, |
| 2145 |
GdkWindowHints geom_mask) |
| 2146 |
{ |
| 2147 |
GdkWindowImplQuartz *impl; |
| 2148 |
|
| 2149 |
g_return_if_fail (geometry != NULL); |
| 2150 |
|
| 2151 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2152 |
!WINDOW_IS_TOPLEVEL (window)) |
| 2153 |
return; |
| 2154 |
|
| 2155 |
impl = GDK_WINDOW_IMPL_QUARTZ (((GdkWindowObject *) window)->impl); |
| 2156 |
if (!impl->toplevel) |
| 2157 |
return; |
| 2158 |
|
| 2159 |
if (geom_mask & GDK_HINT_POS) |
| 2160 |
{ |
| 2161 |
/* FIXME: Implement */ |
| 2162 |
} |
| 2163 |
|
| 2164 |
if (geom_mask & GDK_HINT_USER_POS) |
| 2165 |
{ |
| 2166 |
/* FIXME: Implement */ |
| 2167 |
} |
| 2168 |
|
| 2169 |
if (geom_mask & GDK_HINT_USER_SIZE) |
| 2170 |
{ |
| 2171 |
/* FIXME: Implement */ |
| 2172 |
} |
| 2173 |
|
| 2174 |
if (geom_mask & GDK_HINT_MIN_SIZE) |
| 2175 |
{ |
| 2176 |
NSSize size; |
| 2177 |
|
| 2178 |
size.width = geometry->min_width; |
| 2179 |
size.height = geometry->min_height; |
| 2180 |
|
| 2181 |
[impl->toplevel setContentMinSize:size]; |
| 2182 |
} |
| 2183 |
|
| 2184 |
if (geom_mask & GDK_HINT_MAX_SIZE) |
| 2185 |
{ |
| 2186 |
NSSize size; |
| 2187 |
|
| 2188 |
size.width = geometry->max_width; |
| 2189 |
size.height = geometry->max_height; |
| 2190 |
|
| 2191 |
[impl->toplevel setContentMaxSize:size]; |
| 2192 |
} |
| 2193 |
|
| 2194 |
if (geom_mask & GDK_HINT_BASE_SIZE) |
| 2195 |
{ |
| 2196 |
/* FIXME: Implement */ |
| 2197 |
} |
| 2198 |
|
| 2199 |
if (geom_mask & GDK_HINT_RESIZE_INC) |
| 2200 |
{ |
| 2201 |
NSSize size; |
| 2202 |
|
| 2203 |
size.width = geometry->width_inc; |
| 2204 |
size.height = geometry->height_inc; |
| 2205 |
|
| 2206 |
[impl->toplevel setContentResizeIncrements:size]; |
| 2207 |
} |
| 2208 |
|
| 2209 |
if (geom_mask & GDK_HINT_ASPECT) |
| 2210 |
{ |
| 2211 |
NSSize size; |
| 2212 |
|
| 2213 |
if (geometry->min_aspect != geometry->max_aspect) |
| 2214 |
{ |
| 2215 |
g_warning ("Only equal minimum and maximum aspect ratios are supported on Mac OS. Using minimum aspect ratio..."); |
| 2216 |
} |
| 2217 |
|
| 2218 |
size.width = geometry->min_aspect; |
| 2219 |
size.height = 1.0; |
| 2220 |
|
| 2221 |
[impl->toplevel setContentAspectRatio:size]; |
| 2222 |
} |
| 2223 |
|
| 2224 |
if (geom_mask & GDK_HINT_WIN_GRAVITY) |
| 2225 |
{ |
| 2226 |
/* FIXME: Implement */ |
| 2227 |
} |
| 2228 |
} |
| 2229 |
|
| 2230 |
void |
| 2231 |
gdk_window_set_title (GdkWindow *window, |
| 2232 |
const gchar *title) |
| 2233 |
{ |
| 2234 |
GdkWindowImplQuartz *impl; |
| 2235 |
|
| 2236 |
g_return_if_fail (title != NULL); |
| 2237 |
|
| 2238 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2239 |
!WINDOW_IS_TOPLEVEL (window)) |
| 2240 |
return; |
| 2241 |
|
| 2242 |
impl = GDK_WINDOW_IMPL_QUARTZ (((GdkWindowObject *)window)->impl); |
| 2243 |
|
| 2244 |
if (impl->toplevel) |
| 2245 |
{ |
| 2246 |
GDK_QUARTZ_ALLOC_POOL; |
| 2247 |
[impl->toplevel setTitle:[NSString stringWithUTF8String:title]]; |
| 2248 |
GDK_QUARTZ_RELEASE_POOL; |
| 2249 |
} |
| 2250 |
} |
| 2251 |
|
| 2252 |
void |
| 2253 |
gdk_window_set_role (GdkWindow *window, |
| 2254 |
const gchar *role) |
| 2255 |
{ |
| 2256 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2257 |
WINDOW_IS_TOPLEVEL (window)) |
| 2258 |
return; |
| 2259 |
|
| 2260 |
/* FIXME: Implement */ |
| 2261 |
} |
| 2262 |
|
| 2263 |
void |
| 2264 |
gdk_window_set_transient_for (GdkWindow *window, |
| 2265 |
GdkWindow *parent) |
| 2266 |
{ |
| 2267 |
GdkWindowImplQuartz *window_impl; |
| 2268 |
GdkWindowImplQuartz *parent_impl; |
| 2269 |
|
| 2270 |
if (GDK_WINDOW_DESTROYED (window) || GDK_WINDOW_DESTROYED (parent) || |
| 2271 |
!WINDOW_IS_TOPLEVEL (window)) |
| 2272 |
return; |
| 2273 |
|
| 2274 |
window_impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl); |
| 2275 |
if (!window_impl->toplevel) |
| 2276 |
return; |
| 2277 |
|
| 2278 |
GDK_QUARTZ_ALLOC_POOL; |
| 2279 |
|
| 2280 |
if (window_impl->transient_for) |
| 2281 |
{ |
| 2282 |
_gdk_quartz_window_detach_from_parent (window); |
| 2283 |
|
| 2284 |
g_object_unref (window_impl->transient_for); |
| 2285 |
window_impl->transient_for = NULL; |
| 2286 |
} |
| 2287 |
|
| 2288 |
parent_impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (parent)->impl); |
| 2289 |
if (parent_impl->toplevel) |
| 2290 |
{ |
| 2291 |
/* We save the parent because it needs to be unset/reset when |
| 2292 |
* hiding and showing the window. |
| 2293 |
*/ |
| 2294 |
|
| 2295 |
/* We don't set transients for tooltips, they are already |
| 2296 |
* handled by the window level being the top one. If we do, then |
| 2297 |
* the parent window will be brought to the top just because the |
| 2298 |
* tooltip is, which is not what we want. |
| 2299 |
*/ |
| 2300 |
if (gdk_window_get_type_hint (window) != GDK_WINDOW_TYPE_HINT_TOOLTIP) |
| 2301 |
{ |
| 2302 |
window_impl->transient_for = g_object_ref (parent); |
| 2303 |
|
| 2304 |
/* We only add the window if it is shown, otherwise it will |
| 2305 |
* be shown unconditionally here. If it is not shown, the |
| 2306 |
* window will be added in show() instead. |
| 2307 |
*/ |
| 2308 |
if (!(GDK_WINDOW_OBJECT (window)->state & GDK_WINDOW_STATE_WITHDRAWN)) |
| 2309 |
_gdk_quartz_window_attach_to_parent (window); |
| 2310 |
} |
| 2311 |
} |
| 2312 |
|
| 2313 |
GDK_QUARTZ_RELEASE_POOL; |
| 2314 |
} |
| 2315 |
|
| 2316 |
static void |
| 2317 |
gdk_window_quartz_shape_combine_region (GdkWindow *window, |
| 2318 |
const GdkRegion *shape, |
| 2319 |
gint x, |
| 2320 |
gint y) |
| 2321 |
{ |
| 2322 |
/* FIXME: Implement */ |
| 2323 |
} |
| 2324 |
|
| 2325 |
static void |
| 2326 |
gdk_window_quartz_input_shape_combine_region (GdkWindow *window, |
| 2327 |
const GdkRegion *shape_region, |
| 2328 |
gint offset_x, |
| 2329 |
gint offset_y) |
| 2330 |
{ |
| 2331 |
/* FIXME: Implement */ |
| 2332 |
} |
| 2333 |
|
| 2334 |
void |
| 2335 |
gdk_window_set_override_redirect (GdkWindow *window, |
| 2336 |
gboolean override_redirect) |
| 2337 |
{ |
| 2338 |
/* FIXME: Implement */ |
| 2339 |
} |
| 2340 |
|
| 2341 |
void |
| 2342 |
gdk_window_set_accept_focus (GdkWindow *window, |
| 2343 |
gboolean accept_focus) |
| 2344 |
{ |
| 2345 |
GdkWindowObject *private; |
| 2346 |
|
| 2347 |
private = (GdkWindowObject *)window; |
| 2348 |
|
| 2349 |
private->accept_focus = accept_focus != FALSE; |
| 2350 |
} |
| 2351 |
|
| 2352 |
static gboolean |
| 2353 |
gdk_window_quartz_set_static_gravities (GdkWindow *window, |
| 2354 |
gboolean use_static) |
| 2355 |
{ |
| 2356 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2357 |
!WINDOW_IS_TOPLEVEL (window)) |
| 2358 |
return FALSE; |
| 2359 |
|
| 2360 |
/* FIXME: Implement */ |
| 2361 |
return FALSE; |
| 2362 |
} |
| 2363 |
|
| 2364 |
void |
| 2365 |
gdk_window_set_focus_on_map (GdkWindow *window, |
| 2366 |
gboolean focus_on_map) |
| 2367 |
{ |
| 2368 |
GdkWindowObject *private; |
| 2369 |
|
| 2370 |
private = (GdkWindowObject *)window; |
| 2371 |
|
| 2372 |
private->focus_on_map = focus_on_map != FALSE; |
| 2373 |
} |
| 2374 |
|
| 2375 |
void |
| 2376 |
gdk_window_set_icon (GdkWindow *window, |
| 2377 |
GdkWindow *icon_window, |
| 2378 |
GdkPixmap *pixmap, |
| 2379 |
GdkBitmap *mask) |
| 2380 |
{ |
| 2381 |
/* FIXME: Implement */ |
| 2382 |
} |
| 2383 |
|
| 2384 |
void |
| 2385 |
gdk_window_set_icon_name (GdkWindow *window, |
| 2386 |
const gchar *name) |
| 2387 |
{ |
| 2388 |
/* FIXME: Implement */ |
| 2389 |
} |
| 2390 |
|
| 2391 |
void |
| 2392 |
gdk_window_focus (GdkWindow *window, |
| 2393 |
guint32 timestamp) |
| 2394 |
{ |
| 2395 |
GdkWindowObject *private; |
| 2396 |
GdkWindowImplQuartz *impl; |
| 2397 |
|
| 2398 |
private = (GdkWindowObject*) window; |
| 2399 |
impl = GDK_WINDOW_IMPL_QUARTZ (private->impl); |
| 2400 |
|
| 2401 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2402 |
!WINDOW_IS_TOPLEVEL (window)) |
| 2403 |
return; |
| 2404 |
|
| 2405 |
if (private->accept_focus && private->window_type != GDK_WINDOW_TEMP) |
| 2406 |
{ |
| 2407 |
GDK_QUARTZ_ALLOC_POOL; |
| 2408 |
[impl->toplevel makeKeyAndOrderFront:impl->toplevel]; |
| 2409 |
clear_toplevel_order (); |
| 2410 |
GDK_QUARTZ_RELEASE_POOL; |
| 2411 |
} |
| 2412 |
} |
| 2413 |
|
| 2414 |
void |
| 2415 |
gdk_window_set_hints (GdkWindow *window, |
| 2416 |
gint x, |
| 2417 |
gint y, |
| 2418 |
gint min_width, |
| 2419 |
gint min_height, |
| 2420 |
gint max_width, |
| 2421 |
gint max_height, |
| 2422 |
gint flags) |
| 2423 |
{ |
| 2424 |
/* FIXME: Implement */ |
| 2425 |
} |
| 2426 |
|
| 2427 |
static gint |
| 2428 |
window_type_hint_to_level (GdkWindowTypeHint hint) |
| 2429 |
{ |
| 2430 |
/* the order in this switch statement corresponds to the actual |
| 2431 |
* stacking order: the first group is top, the last group is bottom |
| 2432 |
*/ |
| 2433 |
switch (hint) |
| 2434 |
{ |
| 2435 |
case GDK_WINDOW_TYPE_HINT_POPUP_MENU: |
| 2436 |
case GDK_WINDOW_TYPE_HINT_COMBO: |
| 2437 |
case GDK_WINDOW_TYPE_HINT_DND: |
| 2438 |
case GDK_WINDOW_TYPE_HINT_TOOLTIP: |
| 2439 |
return NSPopUpMenuWindowLevel; |
| 2440 |
|
| 2441 |
case GDK_WINDOW_TYPE_HINT_NOTIFICATION: |
| 2442 |
case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN: |
| 2443 |
return NSStatusWindowLevel; |
| 2444 |
|
| 2445 |
case GDK_WINDOW_TYPE_HINT_MENU: /* Torn-off menu */ |
| 2446 |
case GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU: /* Menu from menubar */ |
| 2447 |
return NSTornOffMenuWindowLevel; |
| 2448 |
|
| 2449 |
case GDK_WINDOW_TYPE_HINT_DOCK: |
| 2450 |
return NSFloatingWindowLevel; /* NSDockWindowLevel is deprecated, and not replaced */ |
| 2451 |
|
| 2452 |
case GDK_WINDOW_TYPE_HINT_UTILITY: |
| 2453 |
case GDK_WINDOW_TYPE_HINT_DIALOG: /* Dialog window */ |
| 2454 |
case GDK_WINDOW_TYPE_HINT_NORMAL: /* Normal toplevel window */ |
| 2455 |
case GDK_WINDOW_TYPE_HINT_TOOLBAR: /* Window used to implement toolbars */ |
| 2456 |
return NSNormalWindowLevel; |
| 2457 |
|
| 2458 |
case GDK_WINDOW_TYPE_HINT_DESKTOP: |
| 2459 |
return kCGDesktopWindowLevelKey; /* doesn't map to any real Cocoa model */ |
| 2460 |
|
| 2461 |
default: |
| 2462 |
break; |
| 2463 |
} |
| 2464 |
|
| 2465 |
return NSNormalWindowLevel; |
| 2466 |
} |
| 2467 |
|
| 2468 |
static gboolean |
| 2469 |
window_type_hint_to_shadow (GdkWindowTypeHint hint) |
| 2470 |
{ |
| 2471 |
switch (hint) |
| 2472 |
{ |
| 2473 |
case GDK_WINDOW_TYPE_HINT_NORMAL: /* Normal toplevel window */ |
| 2474 |
case GDK_WINDOW_TYPE_HINT_DIALOG: /* Dialog window */ |
| 2475 |
case GDK_WINDOW_TYPE_HINT_DOCK: |
| 2476 |
case GDK_WINDOW_TYPE_HINT_UTILITY: |
| 2477 |
case GDK_WINDOW_TYPE_HINT_MENU: /* Torn-off menu */ |
| 2478 |
case GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU: /* Menu from menubar */ |
| 2479 |
case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN: |
| 2480 |
case GDK_WINDOW_TYPE_HINT_POPUP_MENU: |
| 2481 |
case GDK_WINDOW_TYPE_HINT_COMBO: |
| 2482 |
case GDK_WINDOW_TYPE_HINT_NOTIFICATION: |
| 2483 |
case GDK_WINDOW_TYPE_HINT_TOOLTIP: |
| 2484 |
return TRUE; |
| 2485 |
|
| 2486 |
case GDK_WINDOW_TYPE_HINT_TOOLBAR: /* Window used to implement toolbars */ |
| 2487 |
case GDK_WINDOW_TYPE_HINT_DESKTOP: /* N/A */ |
| 2488 |
case GDK_WINDOW_TYPE_HINT_DND: |
| 2489 |
break; |
| 2490 |
|
| 2491 |
default: |
| 2492 |
break; |
| 2493 |
} |
| 2494 |
|
| 2495 |
return FALSE; |
| 2496 |
} |
| 2497 |
|
| 2498 |
static gboolean |
| 2499 |
window_type_hint_to_hides_on_deactivate (GdkWindowTypeHint hint) |
| 2500 |
{ |
| 2501 |
switch (hint) |
| 2502 |
{ |
| 2503 |
case GDK_WINDOW_TYPE_HINT_UTILITY: |
| 2504 |
case GDK_WINDOW_TYPE_HINT_MENU: /* Torn-off menu */ |
| 2505 |
case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN: |
| 2506 |
case GDK_WINDOW_TYPE_HINT_NOTIFICATION: |
| 2507 |
case GDK_WINDOW_TYPE_HINT_TOOLTIP: |
| 2508 |
return TRUE; |
| 2509 |
|
| 2510 |
default: |
| 2511 |
break; |
| 2512 |
} |
| 2513 |
|
| 2514 |
return FALSE; |
| 2515 |
} |
| 2516 |
|
| 2517 |
void |
| 2518 |
gdk_window_set_type_hint (GdkWindow *window, |
| 2519 |
GdkWindowTypeHint hint) |
| 2520 |
{ |
| 2521 |
GdkWindowImplQuartz *impl; |
| 2522 |
|
| 2523 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2524 |
!WINDOW_IS_TOPLEVEL (window)) |
| 2525 |
return; |
| 2526 |
|
| 2527 |
impl = GDK_WINDOW_IMPL_QUARTZ (((GdkWindowObject *) window)->impl); |
| 2528 |
|
| 2529 |
impl->type_hint = hint; |
| 2530 |
|
| 2531 |
/* Match the documentation, only do something if we're not mapped yet. */ |
| 2532 |
if (GDK_WINDOW_IS_MAPPED (window)) |
| 2533 |
return; |
| 2534 |
|
| 2535 |
[impl->toplevel setHasShadow: window_type_hint_to_shadow (hint)]; |
| 2536 |
[impl->toplevel setLevel: window_type_hint_to_level (hint)]; |
| 2537 |
[impl->toplevel setHidesOnDeactivate: window_type_hint_to_hides_on_deactivate (hint)]; |
| 2538 |
} |
| 2539 |
|
| 2540 |
GdkWindowTypeHint |
| 2541 |
gdk_window_get_type_hint (GdkWindow *window) |
| 2542 |
{ |
| 2543 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2544 |
!WINDOW_IS_TOPLEVEL (window)) |
| 2545 |
return GDK_WINDOW_TYPE_HINT_NORMAL; |
| 2546 |
|
| 2547 |
return GDK_WINDOW_IMPL_QUARTZ (((GdkWindowObject *) window)->impl)->type_hint; |
| 2548 |
} |
| 2549 |
|
| 2550 |
void |
| 2551 |
gdk_window_set_modal_hint (GdkWindow *window, |
| 2552 |
gboolean modal) |
| 2553 |
{ |
| 2554 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2555 |
!WINDOW_IS_TOPLEVEL (window)) |
| 2556 |
return; |
| 2557 |
|
| 2558 |
/* FIXME: Implement */ |
| 2559 |
} |
| 2560 |
|
| 2561 |
void |
| 2562 |
gdk_window_set_skip_taskbar_hint (GdkWindow *window, |
| 2563 |
gboolean skips_taskbar) |
| 2564 |
{ |
| 2565 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2566 |
!WINDOW_IS_TOPLEVEL (window)) |
| 2567 |
return; |
| 2568 |
|
| 2569 |
/* FIXME: Implement */ |
| 2570 |
} |
| 2571 |
|
| 2572 |
void |
| 2573 |
gdk_window_set_skip_pager_hint (GdkWindow *window, |
| 2574 |
gboolean skips_pager) |
| 2575 |
{ |
| 2576 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2577 |
!WINDOW_IS_TOPLEVEL (window)) |
| 2578 |
return; |
| 2579 |
|
| 2580 |
/* FIXME: Implement */ |
| 2581 |
} |
| 2582 |
|
| 2583 |
void |
| 2584 |
gdk_window_begin_resize_drag (GdkWindow *window, |
| 2585 |
GdkWindowEdge edge, |
| 2586 |
gint button, |
| 2587 |
gint root_x, |
| 2588 |
gint root_y, |
| 2589 |
guint32 timestamp) |
| 2590 |
{ |
| 2591 |
GdkWindowObject *private; |
| 2592 |
GdkWindowImplQuartz *impl; |
| 2593 |
|
| 2594 |
g_return_if_fail (GDK_IS_WINDOW (window)); |
| 2595 |
|
| 2596 |
if (edge != GDK_WINDOW_EDGE_SOUTH_EAST) |
| 2597 |
{ |
| 2598 |
g_warning ("Resizing is only implemented for GDK_WINDOW_EDGE_SOUTH_EAST on Mac OS"); |
| 2599 |
return; |
| 2600 |
} |
| 2601 |
|
| 2602 |
if (GDK_WINDOW_DESTROYED (window)) |
| 2603 |
return; |
| 2604 |
|
| 2605 |
private = GDK_WINDOW_OBJECT (window); |
| 2606 |
impl = GDK_WINDOW_IMPL_QUARTZ (private->impl); |
| 2607 |
|
| 2608 |
if (!impl->toplevel) |
| 2609 |
{ |
| 2610 |
g_warning ("Can't call gdk_window_begin_resize_drag on non-toplevel window"); |
| 2611 |
return; |
| 2612 |
} |
| 2613 |
|
| 2614 |
[(GdkQuartzWindow *)impl->toplevel beginManualResize]; |
| 2615 |
} |
| 2616 |
|
| 2617 |
void |
| 2618 |
gdk_window_begin_move_drag (GdkWindow *window, |
| 2619 |
gint button, |
| 2620 |
gint root_x, |
| 2621 |
gint root_y, |
| 2622 |
guint32 timestamp) |
| 2623 |
{ |
| 2624 |
GdkWindowObject *private; |
| 2625 |
GdkWindowImplQuartz *impl; |
| 2626 |
|
| 2627 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2628 |
!WINDOW_IS_TOPLEVEL (window)) |
| 2629 |
return; |
| 2630 |
|
| 2631 |
private = GDK_WINDOW_OBJECT (window); |
| 2632 |
impl = GDK_WINDOW_IMPL_QUARTZ (private->impl); |
| 2633 |
|
| 2634 |
if (!impl->toplevel) |
| 2635 |
{ |
| 2636 |
g_warning ("Can't call gdk_window_begin_move_drag on non-toplevel window"); |
| 2637 |
return; |
| 2638 |
} |
| 2639 |
|
| 2640 |
[(GdkQuartzWindow *)impl->toplevel beginManualMove]; |
| 2641 |
} |
| 2642 |
|
| 2643 |
void |
| 2644 |
gdk_window_set_icon_list (GdkWindow *window, |
| 2645 |
GList *pixbufs) |
| 2646 |
{ |
| 2647 |
/* FIXME: Implement */ |
| 2648 |
} |
| 2649 |
|
| 2650 |
void |
| 2651 |
gdk_window_get_frame_extents (GdkWindow *window, |
| 2652 |
GdkRectangle *rect) |
| 2653 |
{ |
| 2654 |
GdkWindowObject *private; |
| 2655 |
GdkWindow *toplevel; |
| 2656 |
GdkWindowImplQuartz *impl; |
| 2657 |
NSRect ns_rect; |
| 2658 |
|
| 2659 |
g_return_if_fail (rect != NULL); |
| 2660 |
|
| 2661 |
private = GDK_WINDOW_OBJECT (window); |
| 2662 |
|
| 2663 |
rect->x = 0; |
| 2664 |
rect->y = 0; |
| 2665 |
rect->width = 1; |
| 2666 |
rect->height = 1; |
| 2667 |
|
| 2668 |
toplevel = gdk_window_get_effective_toplevel (window); |
| 2669 |
impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (toplevel)->impl); |
| 2670 |
|
| 2671 |
ns_rect = [impl->toplevel frame]; |
| 2672 |
|
| 2673 |
_gdk_quartz_window_xy_to_gdk_xy (ns_rect.origin.x, |
| 2674 |
ns_rect.origin.y + ns_rect.size.height, |
| 2675 |
&rect->x, &rect->y); |
| 2676 |
|
| 2677 |
rect->width = ns_rect.size.width; |
| 2678 |
rect->height = ns_rect.size.height; |
| 2679 |
} |
| 2680 |
|
| 2681 |
/* Fake protocol to make gcc think that it's OK to call setStyleMask |
| 2682 |
even if it isn't. We check to make sure before actually calling |
| 2683 |
it. */ |
| 2684 |
|
| 2685 |
@protocol CanSetStyleMask |
| 2686 |
- (void)setStyleMask:(int)mask; |
| 2687 |
@end |
| 2688 |
|
| 2689 |
void |
| 2690 |
gdk_window_set_decorations (GdkWindow *window, |
| 2691 |
GdkWMDecoration decorations) |
| 2692 |
{ |
| 2693 |
GdkWindowImplQuartz *impl; |
| 2694 |
NSUInteger old_mask, new_mask; |
| 2695 |
NSView *old_view; |
| 2696 |
|
| 2697 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2698 |
!WINDOW_IS_TOPLEVEL (window)) |
| 2699 |
return; |
| 2700 |
|
| 2701 |
impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl); |
| 2702 |
|
| 2703 |
if (decorations == 0 || GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP || |
| 2704 |
impl->type_hint == GDK_WINDOW_TYPE_HINT_SPLASHSCREEN ) |
| 2705 |
{ |
| 2706 |
new_mask = NSBorderlessWindowMask; |
| 2707 |
} |
| 2708 |
else |
| 2709 |
{ |
| 2710 |
/* FIXME: Honor other GDK_DECOR_* flags. */ |
| 2711 |
new_mask = (NSTitledWindowMask | NSClosableWindowMask | |
| 2712 |
NSMiniaturizableWindowMask | NSResizableWindowMask); |
| 2713 |
} |
| 2714 |
|
| 2715 |
GDK_QUARTZ_ALLOC_POOL; |
| 2716 |
|
| 2717 |
old_mask = [impl->toplevel styleMask]; |
| 2718 |
|
| 2719 |
if (old_mask != new_mask) |
| 2720 |
{ |
| 2721 |
NSRect rect; |
| 2722 |
|
| 2723 |
old_view = [[impl->toplevel contentView] retain]; |
| 2724 |
|
| 2725 |
rect = [impl->toplevel frame]; |
| 2726 |
|
| 2727 |
/* Properly update the size of the window when the titlebar is |
| 2728 |
* added or removed. |
| 2729 |
*/ |
| 2730 |
if (old_mask == NSBorderlessWindowMask && |
| 2731 |
new_mask != NSBorderlessWindowMask) |
| 2732 |
{ |
| 2733 |
rect = [NSWindow frameRectForContentRect:rect styleMask:new_mask]; |
| 2734 |
|
| 2735 |
} |
| 2736 |
else if (old_mask != NSBorderlessWindowMask && |
| 2737 |
new_mask == NSBorderlessWindowMask) |
| 2738 |
{ |
| 2739 |
rect = [NSWindow contentRectForFrameRect:rect styleMask:old_mask]; |
| 2740 |
} |
| 2741 |
|
| 2742 |
/* Note, before OS 10.6 there doesn't seem to be a way to change this |
| 2743 |
* without recreating the toplevel. From 10.6 onward, a simple call to |
| 2744 |
* setStyleMask takes care of most of this, except for ensuring that the |
| 2745 |
* title is set. |
| 2746 |
*/ |
| 2747 |
if ([impl->toplevel respondsToSelector:@selector(setStyleMask:)]) |
| 2748 |
{ |
| 2749 |
NSString *title = [impl->toplevel title]; |
| 2750 |
|
| 2751 |
[(id<CanSetStyleMask>)impl->toplevel setStyleMask:new_mask]; |
| 2752 |
|
| 2753 |
/* It appears that unsetting and then resetting NSTitledWindowMask |
| 2754 |
* does not reset the title in the title bar as might be expected. |
| 2755 |
* |
| 2756 |
* In theory we only need to set this if new_mask includes |
| 2757 |
* NSTitledWindowMask. This behaved extremely oddly when |
| 2758 |
* conditionalized upon that and since it has no side effects (i.e. |
| 2759 |
* if NSTitledWindowMask is not requested, the title will not be |
| 2760 |
* displayed) just do it unconditionally. We also must null check |
| 2761 |
* 'title' before setting it to avoid crashing. |
| 2762 |
*/ |
| 2763 |
if (title) |
| 2764 |
[impl->toplevel setTitle:title]; |
| 2765 |
} |
| 2766 |
else |
| 2767 |
{ |
| 2768 |
NSString *title = [impl->toplevel title]; |
| 2769 |
NSColor *bg = [impl->toplevel backgroundColor]; |
| 2770 |
NSScreen *screen = [impl->toplevel screen]; |
| 2771 |
|
| 2772 |
/* Make sure the old window is closed, recall that releasedWhenClosed |
| 2773 |
* is set on GdkQuartzWindows. |
| 2774 |
*/ |
| 2775 |
[impl->toplevel close]; |
| 2776 |
|
| 2777 |
impl->toplevel = [[GdkQuartzWindow alloc] initWithContentRect:rect |
| 2778 |
styleMask:new_mask |
| 2779 |
backing:NSBackingStoreBuffered |
| 2780 |
defer:NO |
| 2781 |
screen:screen]; |
| 2782 |
[impl->toplevel setHasShadow: window_type_hint_to_shadow (impl->type_hint)]; |
| 2783 |
[impl->toplevel setLevel: window_type_hint_to_level (impl->type_hint)]; |
| 2784 |
if (title) |
| 2785 |
[impl->toplevel setTitle:title]; |
| 2786 |
[impl->toplevel setBackgroundColor:bg]; |
| 2787 |
[impl->toplevel setHidesOnDeactivate: window_type_hint_to_hides_on_deactivate (impl->type_hint)]; |
| 2788 |
[impl->toplevel setContentView:old_view]; |
| 2789 |
} |
| 2790 |
|
| 2791 |
if (new_mask == NSBorderlessWindowMask) |
| 2792 |
[impl->toplevel setContentSize:rect.size]; |
| 2793 |
else |
| 2794 |
[impl->toplevel setFrame:rect display:YES]; |
| 2795 |
|
| 2796 |
/* Invalidate the window shadow for non-opaque views that have shadow |
| 2797 |
* enabled, to get the shadow shape updated. |
| 2798 |
*/ |
| 2799 |
if (![old_view isOpaque] && [impl->toplevel hasShadow]) |
| 2800 |
[(GdkQuartzView*)old_view setNeedsInvalidateShadow:YES]; |
| 2801 |
|
| 2802 |
[old_view release]; |
| 2803 |
} |
| 2804 |
|
| 2805 |
GDK_QUARTZ_RELEASE_POOL; |
| 2806 |
} |
| 2807 |
|
| 2808 |
gboolean |
| 2809 |
gdk_window_get_decorations (GdkWindow *window, |
| 2810 |
GdkWMDecoration *decorations) |
| 2811 |
{ |
| 2812 |
GdkWindowImplQuartz *impl; |
| 2813 |
|
| 2814 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2815 |
!WINDOW_IS_TOPLEVEL (window)) |
| 2816 |
return FALSE; |
| 2817 |
|
| 2818 |
impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl); |
| 2819 |
|
| 2820 |
if (decorations) |
| 2821 |
{ |
| 2822 |
/* Borderless is 0, so we can't check it as a bit being set. */ |
| 2823 |
if ([impl->toplevel styleMask] == NSBorderlessWindowMask) |
| 2824 |
{ |
| 2825 |
*decorations = 0; |
| 2826 |
} |
| 2827 |
else |
| 2828 |
{ |
| 2829 |
/* FIXME: Honor the other GDK_DECOR_* flags. */ |
| 2830 |
*decorations = GDK_DECOR_ALL; |
| 2831 |
} |
| 2832 |
} |
| 2833 |
|
| 2834 |
return TRUE; |
| 2835 |
} |
| 2836 |
|
| 2837 |
void |
| 2838 |
gdk_window_set_functions (GdkWindow *window, |
| 2839 |
GdkWMFunction functions) |
| 2840 |
{ |
| 2841 |
g_return_if_fail (GDK_IS_WINDOW (window)); |
| 2842 |
|
| 2843 |
/* FIXME: Implement */ |
| 2844 |
} |
| 2845 |
|
| 2846 |
gboolean |
| 2847 |
_gdk_windowing_window_queue_antiexpose (GdkWindow *window, |
| 2848 |
GdkRegion *area) |
| 2849 |
{ |
| 2850 |
return FALSE; |
| 2851 |
} |
| 2852 |
|
| 2853 |
void |
| 2854 |
gdk_window_stick (GdkWindow *window) |
| 2855 |
{ |
| 2856 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2857 |
!WINDOW_IS_TOPLEVEL (window)) |
| 2858 |
return; |
| 2859 |
} |
| 2860 |
|
| 2861 |
void |
| 2862 |
gdk_window_unstick (GdkWindow *window) |
| 2863 |
{ |
| 2864 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2865 |
!WINDOW_IS_TOPLEVEL (window)) |
| 2866 |
return; |
| 2867 |
} |
| 2868 |
|
| 2869 |
void |
| 2870 |
gdk_window_maximize (GdkWindow *window) |
| 2871 |
{ |
| 2872 |
GdkWindowImplQuartz *impl; |
| 2873 |
|
| 2874 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2875 |
!WINDOW_IS_TOPLEVEL (window)) |
| 2876 |
return; |
| 2877 |
|
| 2878 |
impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl); |
| 2879 |
|
| 2880 |
if (GDK_WINDOW_IS_MAPPED (window)) |
| 2881 |
{ |
| 2882 |
GDK_QUARTZ_ALLOC_POOL; |
| 2883 |
|
| 2884 |
if (impl->toplevel && ![impl->toplevel isZoomed]) |
| 2885 |
[impl->toplevel zoom:nil]; |
| 2886 |
|
| 2887 |
GDK_QUARTZ_RELEASE_POOL; |
| 2888 |
} |
| 2889 |
else |
| 2890 |
{ |
| 2891 |
gdk_synthesize_window_state (window, |
| 2892 |
0, |
| 2893 |
GDK_WINDOW_STATE_MAXIMIZED); |
| 2894 |
} |
| 2895 |
} |
| 2896 |
|
| 2897 |
void |
| 2898 |
gdk_window_unmaximize (GdkWindow *window) |
| 2899 |
{ |
| 2900 |
GdkWindowImplQuartz *impl; |
| 2901 |
|
| 2902 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2903 |
!WINDOW_IS_TOPLEVEL (window)) |
| 2904 |
return; |
| 2905 |
|
| 2906 |
impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl); |
| 2907 |
|
| 2908 |
if (GDK_WINDOW_IS_MAPPED (window)) |
| 2909 |
{ |
| 2910 |
GDK_QUARTZ_ALLOC_POOL; |
| 2911 |
|
| 2912 |
if (impl->toplevel && [impl->toplevel isZoomed]) |
| 2913 |
[impl->toplevel zoom:nil]; |
| 2914 |
|
| 2915 |
GDK_QUARTZ_RELEASE_POOL; |
| 2916 |
} |
| 2917 |
else |
| 2918 |
{ |
| 2919 |
gdk_synthesize_window_state (window, |
| 2920 |
GDK_WINDOW_STATE_MAXIMIZED, |
| 2921 |
0); |
| 2922 |
} |
| 2923 |
} |
| 2924 |
|
| 2925 |
void |
| 2926 |
gdk_window_iconify (GdkWindow *window) |
| 2927 |
{ |
| 2928 |
GdkWindowImplQuartz *impl; |
| 2929 |
|
| 2930 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2931 |
!WINDOW_IS_TOPLEVEL (window)) |
| 2932 |
return; |
| 2933 |
|
| 2934 |
impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl); |
| 2935 |
|
| 2936 |
if (GDK_WINDOW_IS_MAPPED (window)) |
| 2937 |
{ |
| 2938 |
GDK_QUARTZ_ALLOC_POOL; |
| 2939 |
|
| 2940 |
if (impl->toplevel) |
| 2941 |
[impl->toplevel miniaturize:nil]; |
| 2942 |
|
| 2943 |
GDK_QUARTZ_RELEASE_POOL; |
| 2944 |
} |
| 2945 |
else |
| 2946 |
{ |
| 2947 |
gdk_synthesize_window_state (window, |
| 2948 |
0, |
| 2949 |
GDK_WINDOW_STATE_ICONIFIED); |
| 2950 |
} |
| 2951 |
} |
| 2952 |
|
| 2953 |
void |
| 2954 |
gdk_window_deiconify (GdkWindow *window) |
| 2955 |
{ |
| 2956 |
GdkWindowImplQuartz *impl; |
| 2957 |
|
| 2958 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2959 |
!WINDOW_IS_TOPLEVEL (window)) |
| 2960 |
return; |
| 2961 |
|
| 2962 |
impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl); |
| 2963 |
|
| 2964 |
if (GDK_WINDOW_IS_MAPPED (window)) |
| 2965 |
{ |
| 2966 |
GDK_QUARTZ_ALLOC_POOL; |
| 2967 |
|
| 2968 |
if (impl->toplevel) |
| 2969 |
[impl->toplevel deminiaturize:nil]; |
| 2970 |
|
| 2971 |
GDK_QUARTZ_RELEASE_POOL; |
| 2972 |
} |
| 2973 |
else |
| 2974 |
{ |
| 2975 |
gdk_synthesize_window_state (window, |
| 2976 |
GDK_WINDOW_STATE_ICONIFIED, |
| 2977 |
0); |
| 2978 |
} |
| 2979 |
} |
| 2980 |
|
| 2981 |
static FullscreenSavedGeometry * |
| 2982 |
get_fullscreen_geometry (GdkWindow *window) |
| 2983 |
{ |
| 2984 |
return g_object_get_data (G_OBJECT (window), FULLSCREEN_DATA); |
| 2985 |
} |
| 2986 |
|
| 2987 |
void |
| 2988 |
gdk_window_fullscreen (GdkWindow *window) |
| 2989 |
{ |
| 2990 |
FullscreenSavedGeometry *geometry; |
| 2991 |
GdkWindowObject *private = (GdkWindowObject *) window; |
| 2992 |
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl); |
| 2993 |
NSRect frame; |
| 2994 |
|
| 2995 |
if (GDK_WINDOW_DESTROYED (window) || |
| 2996 |
!WINDOW_IS_TOPLEVEL (window)) |
| 2997 |
return; |
| 2998 |
|
| 2999 |
geometry = get_fullscreen_geometry (window); |
| 3000 |
if (!geometry) |
| 3001 |
{ |
| 3002 |
geometry = g_new (FullscreenSavedGeometry, 1); |
| 3003 |
|
| 3004 |
geometry->x = private->x; |
| 3005 |
geometry->y = private->y; |
| 3006 |
geometry->width = private->width; |
| 3007 |
geometry->height = private->height; |
| 3008 |
|
| 3009 |
if (!gdk_window_get_decorations (window, &geometry->decor)) |
| 3010 |
geometry->decor = GDK_DECOR_ALL; |
| 3011 |
|
| 3012 |
g_object_set_data_full (G_OBJECT (window), |
| 3013 |
FULLSCREEN_DATA, geometry, |
| 3014 |
g_free); |
| 3015 |
|
| 3016 |
gdk_window_set_decorations (window, 0); |
| 3017 |
|
| 3018 |
frame = [[impl->toplevel screen] frame]; |
| 3019 |
move_resize_window_internal (window, |
| 3020 |
0, 0, |
| 3021 |
frame.size.width, frame.size.height); |
| 3022 |
[impl->toplevel setContentSize:frame.size]; |
| 3023 |
[impl->toplevel makeKeyAndOrderFront:impl->toplevel]; |
| 3024 |
|
| 3025 |
clear_toplevel_order (); |
| 3026 |
} |
| 3027 |
|
| 3028 |
if ([NSWindow respondsToSelector:@selector(toggleFullScreen:)]) |
| 3029 |
{ |
| 3030 |
[impl->toplevel toggleFullScreen:nil]; |
| 3031 |
} |
| 3032 |
else |
| 3033 |
{ |
| 3034 |
SetSystemUIMode (kUIModeAllHidden, kUIOptionAutoShowMenuBar); |
| 3035 |
} |
| 3036 |
|
| 3037 |
gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FULLSCREEN); |
| 3038 |
} |
| 3039 |
|
| 3040 |
void |
| 3041 |
gdk_window_unfullscreen (GdkWindow *window) |
| 3042 |
{ |
| 3043 |
GdkWindowObject *private = (GdkWindowObject *) window; |
| 3044 |
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl); |
| 3045 |
FullscreenSavedGeometry *geometry; |
| 3046 |
|
| 3047 |
if (GDK_WINDOW_DESTROYED (window) || |
| 3048 |
!WINDOW_IS_TOPLEVEL (window)) |
| 3049 |
return; |
| 3050 |
|
| 3051 |
geometry = get_fullscreen_geometry (window); |
| 3052 |
if (geometry) |
| 3053 |
{ |
| 3054 |
if ([NSWindow respondsToSelector:@selector(toggleFullScreen:)]) |
| 3055 |
{ |
| 3056 |
[impl->toplevel toggleFullScreen:nil]; |
| 3057 |
} |
| 3058 |
else |
| 3059 |
{ |
| 3060 |
SetSystemUIMode (kUIModeNormal, 0); |
| 3061 |
} |
| 3062 |
|
| 3063 |
move_resize_window_internal (window, |
| 3064 |
geometry->x, |
| 3065 |
geometry->y, |
| 3066 |
geometry->width, |
| 3067 |
geometry->height); |
| 3068 |
|
| 3069 |
gdk_window_set_decorations (window, geometry->decor); |
| 3070 |
|
| 3071 |
g_object_set_data (G_OBJECT (window), FULLSCREEN_DATA, NULL); |
| 3072 |
|
| 3073 |
[impl->toplevel makeKeyAndOrderFront:impl->toplevel]; |
| 3074 |
clear_toplevel_order (); |
| 3075 |
|
| 3076 |
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FULLSCREEN, 0); |
| 3077 |
} |
| 3078 |
} |
| 3079 |
|
| 3080 |
void |
| 3081 |
gdk_window_set_keep_above (GdkWindow *window, gboolean setting) |
| 3082 |
{ |
| 3083 |
GdkWindowObject *private = (GdkWindowObject *) window; |
| 3084 |
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl); |
| 3085 |
gint level; |
| 3086 |
|
| 3087 |
g_return_if_fail (GDK_IS_WINDOW (window)); |
| 3088 |
|
| 3089 |
if (GDK_WINDOW_DESTROYED (window) || |
| 3090 |
!WINDOW_IS_TOPLEVEL (window)) |
| 3091 |
return; |
| 3092 |
|
| 3093 |
level = window_type_hint_to_level (gdk_window_get_type_hint (window)); |
| 3094 |
|
| 3095 |
/* Adjust normal window level by one if necessary. */ |
| 3096 |
[impl->toplevel setLevel: level + (setting ? 1 : 0)]; |
| 3097 |
} |
| 3098 |
|
| 3099 |
void |
| 3100 |
gdk_window_set_keep_below (GdkWindow *window, gboolean setting) |
| 3101 |
{ |
| 3102 |
GdkWindowObject *private = (GdkWindowObject *) window; |
| 3103 |
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl); |
| 3104 |
gint level; |
| 3105 |
|
| 3106 |
g_return_if_fail (GDK_IS_WINDOW (window)); |
| 3107 |
|
| 3108 |
if (GDK_WINDOW_DESTROYED (window) || |
| 3109 |
!WINDOW_IS_TOPLEVEL (window)) |
| 3110 |
return; |
| 3111 |
|
| 3112 |
level = window_type_hint_to_level (gdk_window_get_type_hint (window)); |
| 3113 |
|
| 3114 |
/* Adjust normal window level by one if necessary. */ |
| 3115 |
[impl->toplevel setLevel: level - (setting ? 1 : 0)]; |
| 3116 |
} |
| 3117 |
|
| 3118 |
GdkWindow * |
| 3119 |
gdk_window_get_group (GdkWindow *window) |
| 3120 |
{ |
| 3121 |
g_return_val_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD, NULL); |
| 3122 |
|
| 3123 |
if (GDK_WINDOW_DESTROYED (window) || |
| 3124 |
!WINDOW_IS_TOPLEVEL (window)) |
| 3125 |
return NULL; |
| 3126 |
|
| 3127 |
/* FIXME: Implement */ |
| 3128 |
|
| 3129 |
return NULL; |
| 3130 |
} |
| 3131 |
|
| 3132 |
void |
| 3133 |
gdk_window_set_group (GdkWindow *window, |
| 3134 |
GdkWindow *leader) |
| 3135 |
{ |
| 3136 |
/* FIXME: Implement */ |
| 3137 |
} |
| 3138 |
|
| 3139 |
GdkWindow* |
| 3140 |
gdk_window_foreign_new_for_display (GdkDisplay *display, |
| 3141 |
GdkNativeWindow anid) |
| 3142 |
{ |
| 3143 |
/* Foreign windows aren't supported in Mac OS X */ |
| 3144 |
return NULL; |
| 3145 |
} |
| 3146 |
|
| 3147 |
GdkWindow* |
| 3148 |
gdk_window_lookup (GdkNativeWindow anid) |
| 3149 |
{ |
| 3150 |
/* Foreign windows aren't supported in Mac OS X */ |
| 3151 |
return NULL; |
| 3152 |
} |
| 3153 |
|
| 3154 |
GdkWindow * |
| 3155 |
gdk_window_lookup_for_display (GdkDisplay *display, GdkNativeWindow anid) |
| 3156 |
{ |
| 3157 |
/* Foreign windows aren't supported in Mac OS X */ |
| 3158 |
return NULL; |
| 3159 |
} |
| 3160 |
|
| 3161 |
void |
| 3162 |
gdk_window_enable_synchronized_configure (GdkWindow *window) |
| 3163 |
{ |
| 3164 |
} |
| 3165 |
|
| 3166 |
void |
| 3167 |
gdk_window_configure_finished (GdkWindow *window) |
| 3168 |
{ |
| 3169 |
} |
| 3170 |
|
| 3171 |
void |
| 3172 |
gdk_window_destroy_notify (GdkWindow *window) |
| 3173 |
{ |
| 3174 |
check_grab_destroy (window); |
| 3175 |
} |
| 3176 |
|
| 3177 |
void |
| 3178 |
_gdk_windowing_window_beep (GdkWindow *window) |
| 3179 |
{ |
| 3180 |
g_return_if_fail (GDK_IS_WINDOW (window)); |
| 3181 |
|
| 3182 |
gdk_display_beep (_gdk_display); |
| 3183 |
} |
| 3184 |
|
| 3185 |
void |
| 3186 |
gdk_window_set_opacity (GdkWindow *window, |
| 3187 |
gdouble opacity) |
| 3188 |
{ |
| 3189 |
GdkWindowObject *private = (GdkWindowObject *) window; |
| 3190 |
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl); |
| 3191 |
|
| 3192 |
g_return_if_fail (GDK_IS_WINDOW (window)); |
| 3193 |
g_return_if_fail (WINDOW_IS_TOPLEVEL (window)); |
| 3194 |
|
| 3195 |
if (GDK_WINDOW_DESTROYED (window) || |
| 3196 |
!WINDOW_IS_TOPLEVEL (window)) |
| 3197 |
return; |
| 3198 |
|
| 3199 |
if (opacity < 0) |
| 3200 |
opacity = 0; |
| 3201 |
else if (opacity > 1) |
| 3202 |
opacity = 1; |
| 3203 |
|
| 3204 |
[impl->toplevel setAlphaValue: opacity]; |
| 3205 |
} |
| 3206 |
|
| 3207 |
void |
| 3208 |
_gdk_windowing_window_set_composited (GdkWindow *window, gboolean composited) |
| 3209 |
{ |
| 3210 |
} |
| 3211 |
|
| 3212 |
GdkRegion * |
| 3213 |
_gdk_windowing_get_shape_for_mask (GdkBitmap *mask) |
| 3214 |
{ |
| 3215 |
/* FIXME: implement */ |
| 3216 |
return NULL; |
| 3217 |
} |
| 3218 |
|
| 3219 |
GdkRegion * |
| 3220 |
_gdk_windowing_window_get_shape (GdkWindow *window) |
| 3221 |
{ |
| 3222 |
/* FIXME: implement */ |
| 3223 |
return NULL; |
| 3224 |
} |
| 3225 |
|
| 3226 |
GdkRegion * |
| 3227 |
_gdk_windowing_window_get_input_shape (GdkWindow *window) |
| 3228 |
{ |
| 3229 |
/* FIXME: implement */ |
| 3230 |
return NULL; |
| 3231 |
} |
| 3232 |
|
| 3233 |
static void |
| 3234 |
gdk_window_impl_iface_init (GdkWindowImplIface *iface) |
| 3235 |
{ |
| 3236 |
iface->show = gdk_window_quartz_show; |
| 3237 |
iface->hide = gdk_window_quartz_hide; |
| 3238 |
iface->withdraw = gdk_window_quartz_withdraw; |
| 3239 |
iface->set_events = gdk_window_quartz_set_events; |
| 3240 |
iface->get_events = gdk_window_quartz_get_events; |
| 3241 |
iface->raise = gdk_window_quartz_raise; |
| 3242 |
iface->lower = gdk_window_quartz_lower; |
| 3243 |
iface->restack_toplevel = gdk_window_quartz_restack_toplevel; |
| 3244 |
iface->move_resize = gdk_window_quartz_move_resize; |
| 3245 |
iface->set_background = gdk_window_quartz_set_background; |
| 3246 |
iface->set_back_pixmap = gdk_window_quartz_set_back_pixmap; |
| 3247 |
iface->reparent = gdk_window_quartz_reparent; |
| 3248 |
iface->set_cursor = gdk_window_quartz_set_cursor; |
| 3249 |
iface->get_geometry = gdk_window_quartz_get_geometry; |
| 3250 |
iface->get_root_coords = gdk_window_quartz_get_root_coords; |
| 3251 |
iface->get_pointer = gdk_window_quartz_get_pointer; |
| 3252 |
iface->get_deskrelative_origin = gdk_window_quartz_get_deskrelative_origin; |
| 3253 |
iface->shape_combine_region = gdk_window_quartz_shape_combine_region; |
| 3254 |
iface->input_shape_combine_region = gdk_window_quartz_input_shape_combine_region; |
| 3255 |
iface->set_static_gravities = gdk_window_quartz_set_static_gravities; |
| 3256 |
iface->queue_antiexpose = _gdk_quartz_window_queue_antiexpose; |
| 3257 |
iface->queue_translation = _gdk_quartz_window_queue_translation; |
| 3258 |
iface->destroy = _gdk_quartz_window_destroy; |
| 3259 |
iface->input_window_destroy = _gdk_input_window_destroy; |
| 3260 |
iface->input_window_crossing = _gdk_input_window_crossing; |
| 3261 |
} |