362
362
NSRect rect = NSMakeRect (xsrc, ysrc, width, height);
363
363
NSSize offset = NSMakeSize (xdest - xsrc, ydest - ysrc);
365
[window_impl->view scrollRect:rect by:offset];
367
/* The scrollRect only "takes effect" on the next redraw, we must
368
* set that the offset rectangle needs display.
370
rect.origin.x += offset.width;
371
rect.origin.y += offset.height;
372
[window_impl->view setNeedsDisplayInRect:rect];
364
GdkRectangle tmp_rect;
365
GdkRegion *orig_region, *offset_region, *need_display_region;
366
GdkWindow *window = GDK_DRAWABLE_IMPL_QUARTZ (drawable)->wrapper;
371
tmp_rect.width = width;
372
tmp_rect.height = height;
373
orig_region = gdk_region_rectangle (&tmp_rect);
375
/* Destination region (or the offset region) */
376
offset_region = gdk_region_copy (orig_region);
377
gdk_region_offset (offset_region, offset.width, offset.height);
379
need_display_region = gdk_region_copy (orig_region);
381
if (window_impl->in_paint_rect_count == 0)
383
GdkRegion *bottom_border_region;
385
/* If we are not in drawRect:, we can use scrollRect:.
386
* We apply scrollRect on the rectangle to be moved and
387
* subtract this area from the rectangle that needs display.
389
* Note: any area in this moved region that already needed
390
* display will be handled by GDK (queue translation).
392
* Queuing the redraw below is important, otherwise the
393
* results from scrollRect will not take effect!
395
[window_impl->view scrollRect:rect by:offset];
397
gdk_region_subtract (need_display_region, offset_region);
399
/* Here we take special care with the bottom window border,
400
* which extents 4 pixels and typically draws rounded corners.
403
tmp_rect.y = gdk_window_get_height (window) - 4;
404
tmp_rect.width = gdk_window_get_width (window);
407
if (gdk_region_rect_in (offset_region, &tmp_rect) !=
408
GDK_OVERLAP_RECTANGLE_OUT)
410
/* We are copying pixels to the bottom border, we need
411
* to submit this area for redisplay to get the rounded
414
gdk_region_union_with_rect (need_display_region,
418
/* Compute whether the bottom border is moved elsewhere.
419
* Because this part will have rounded corners, we have
420
* to fill the contents of where the rounded corners used
421
* to be. We post this area for redisplay.
423
bottom_border_region = gdk_region_rectangle (&tmp_rect);
424
gdk_region_intersect (bottom_border_region,
427
gdk_region_offset (bottom_border_region,
428
offset.width, offset.height);
430
gdk_region_union (need_display_region, bottom_border_region);
432
gdk_region_destroy (bottom_border_region);
436
/* If we cannot handle things with a scroll, we must redisplay
437
* the union of the source area and the destination area.
439
gdk_region_union (need_display_region, offset_region);
442
_gdk_quartz_window_set_needs_display_in_region (window,
443
need_display_region);
445
gdk_region_destroy (orig_region);
446
gdk_region_destroy (offset_region);
447
gdk_region_destroy (need_display_region);
375
450
g_warning ("Drawing with window source != dest is not supported");