]> Pileus Git - ~andy/gtk/blob - gdk/quartz/gdkgeometry-quartz.c
Whitespace cleanup. (synthesize_crossing_events): Add comments and prevent
[~andy/gtk] / gdk / quartz / gdkgeometry-quartz.c
1 /* gdkgeometry-quartz.c
2  *
3  * Copyright (C) 2005 Imendio AB
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 #include <config.h>
22
23 #include "gdkprivate-quartz.h"
24
25 void
26 gdk_window_scroll (GdkWindow *window,
27                    gint       dx,
28                    gint       dy)
29 {
30   NSRect visible_nsrect;
31   GdkRectangle visible_rect, scrolled_rect;
32   GdkRegion *visible_region, *scrolled_region;
33   GdkRectangle *rects;
34   gint n_rects, i;
35   GdkWindowObject *private = GDK_WINDOW_OBJECT (window);
36   GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
37   GList *list;
38
39   g_return_if_fail (GDK_IS_WINDOW (window));
40
41   visible_nsrect = [impl->view visibleRect];
42
43   visible_rect.x = visible_nsrect.origin.x;
44   visible_rect.y = visible_nsrect.origin.y;
45   visible_rect.width = visible_nsrect.size.width;
46   visible_rect.height = visible_nsrect.size.height;
47   
48   scrolled_rect = visible_rect;
49   scrolled_rect.x += dx;
50   scrolled_rect.y += dy;
51   
52   gdk_rectangle_intersect (&visible_rect, &scrolled_rect, &scrolled_rect);
53   
54   visible_region = gdk_region_rectangle (&visible_rect);
55   scrolled_region = gdk_region_rectangle (&scrolled_rect);
56
57   gdk_region_subtract (visible_region, scrolled_region);
58
59   [impl->view scrollRect:[impl->view bounds] by:NSMakeSize(dx, dy)];
60
61   gdk_region_get_rectangles (visible_region, &rects, &n_rects);
62   for (i = 0; i < n_rects; i++)
63     [impl->view setNeedsDisplayInRect:NSMakeRect (rects[i].x, rects[i].y, rects[i].width, rects[i].height)];
64   
65   g_free (rects);
66
67   gdk_region_destroy (visible_region);
68   gdk_region_destroy (scrolled_region);
69
70   /* Move child windows */
71   for (list = private->children; list; list = list->next)
72     {
73       GdkWindowObject *child = GDK_WINDOW_OBJECT (list->data);
74
75       gdk_window_move (list->data,
76                        child->x + dx,
77                        child->y + dy);
78     }
79 }
80
81 void
82 gdk_window_move_region (GdkWindow *window,
83                         GdkRegion *region,
84                         gint       dx,
85                         gint       dy)
86 {
87   /* FIXME: Implement */
88 }