~ubuntu-branches/ubuntu/raring/gtk+2.0/raring-proposed

« back to all changes in this revision

Viewing changes to gdk/quartz/gdkdrawable-quartz.c

  • Committer: Package Import Robot
  • Author(s): Robert Ancell
  • Date: 2013-01-10 12:53:20 UTC
  • mfrom: (1.14.16)
  • Revision ID: package-import@ubuntu.com-20130110125320-x13bjpwtqq36izs2
Tags: 2.24.14-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
361
361
        {
362
362
          NSRect rect = NSMakeRect (xsrc, ysrc, width, height);
363
363
          NSSize offset = NSMakeSize (xdest - xsrc, ydest - ysrc);
364
 
 
365
 
          [window_impl->view scrollRect:rect by:offset];
366
 
 
367
 
          /* The scrollRect only "takes effect" on the next redraw, we must
368
 
           * set that the offset rectangle needs display.
369
 
           */
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;
 
367
 
 
368
          /* Origin region */
 
369
          tmp_rect.x = xsrc;
 
370
          tmp_rect.y = ysrc;
 
371
          tmp_rect.width = width;
 
372
          tmp_rect.height = height;
 
373
          orig_region = gdk_region_rectangle (&tmp_rect);
 
374
 
 
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);
 
378
 
 
379
          need_display_region = gdk_region_copy (orig_region);
 
380
 
 
381
          if (window_impl->in_paint_rect_count == 0)
 
382
            {
 
383
              GdkRegion *bottom_border_region;
 
384
 
 
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.
 
388
               *
 
389
               * Note: any area in this moved region that already needed
 
390
               * display will be handled by GDK (queue translation).
 
391
               *
 
392
               * Queuing the redraw below is important, otherwise the
 
393
               * results from scrollRect will not take effect!
 
394
               */
 
395
              [window_impl->view scrollRect:rect by:offset];
 
396
 
 
397
              gdk_region_subtract (need_display_region, offset_region);
 
398
 
 
399
              /* Here we take special care with the bottom window border,
 
400
               * which extents 4 pixels and typically draws rounded corners.
 
401
               */
 
402
              tmp_rect.x = 0;
 
403
              tmp_rect.y = gdk_window_get_height (window) - 4;
 
404
              tmp_rect.width = gdk_window_get_width (window);
 
405
              tmp_rect.height = 4;
 
406
 
 
407
              if (gdk_region_rect_in (offset_region, &tmp_rect) !=
 
408
                  GDK_OVERLAP_RECTANGLE_OUT)
 
409
                {
 
410
                  /* We are copying pixels to the bottom border, we need
 
411
                   * to submit this area for redisplay to get the rounded
 
412
                   * corners drawn.
 
413
                   */
 
414
                  gdk_region_union_with_rect (need_display_region,
 
415
                                              &tmp_rect);
 
416
                }
 
417
 
 
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.
 
422
               */
 
423
              bottom_border_region = gdk_region_rectangle (&tmp_rect);
 
424
              gdk_region_intersect (bottom_border_region,
 
425
                                    orig_region);
 
426
 
 
427
              gdk_region_offset (bottom_border_region,
 
428
                                 offset.width, offset.height);
 
429
 
 
430
              gdk_region_union (need_display_region, bottom_border_region);
 
431
 
 
432
              gdk_region_destroy (bottom_border_region);
 
433
            }
 
434
          else
 
435
            {
 
436
              /* If we cannot handle things with a scroll, we must redisplay
 
437
               * the union of the source area and the destination area.
 
438
               */
 
439
              gdk_region_union (need_display_region, offset_region);
 
440
            }
 
441
 
 
442
          _gdk_quartz_window_set_needs_display_in_region (window,
 
443
                                                          need_display_region);
 
444
 
 
445
          gdk_region_destroy (orig_region);
 
446
          gdk_region_destroy (offset_region);
 
447
          gdk_region_destroy (need_display_region);
373
448
        }
374
449
      else
375
450
        g_warning ("Drawing with window source != dest is not supported");