]> Pileus Git - ~andy/gtk/blob - gdk/win32/gdkgeometry-win32.c
Change FSF Address
[~andy/gtk] / gdk / win32 / gdkgeometry-win32.c
1 /* GDK - The GIMP Drawing Kit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 /* gdkgeometry-win32.c: emulation of 32 bit coordinates within the
19  * limits of Win32 GDI. The idea of big window emulation is more or less
20  * a copy of the X11 version, and the equvalent of guffaw scrolling
21  * is ScrollWindowEx(). While we determine the invalidated region
22  * ourself during scrolling, we do not pass SW_INVALIDATE to
23  * ScrollWindowEx() to avoid a unnecessary WM_PAINT.
24  *
25  * Bits are always scrolled correctly by ScrollWindowEx(), but
26  * some big children may hit the coordinate boundary (i.e.
27  * win32_x/win32_y < -16383) after scrolling. They needed to be moved
28  * back to the real position determined by gdk_window_compute_position().
29  * This is handled in gdk_window_postmove().
30  * 
31  * The X11 version by Owen Taylor <otaylor@redhat.com>
32  * Copyright Red Hat, Inc. 2000
33  * Win32 hack by Tor Lillqvist <tml@iki.fi>
34  * and Hans Breuer <hans@breuer.org>
35  * Modified by Ivan, Wong Yat Cheung <email@ivanwong.info>
36  * so that big window emulation finally works.
37  */
38
39 #include "config.h"
40 #include "gdk.h"                /* For gdk_rectangle_intersect */
41 #include "gdkinternals.h"
42 #include "gdkprivate-win32.h"
43 #include "gdkwin32.h"
44
45 #define SIZE_LIMIT 32767
46
47 typedef struct _GdkWindowParentPos GdkWindowParentPos;
48
49 static void tmp_unset_bg (GdkWindow *window);
50 static void tmp_reset_bg (GdkWindow *window);
51
52 void
53 _gdk_window_move_resize_child (GdkWindow *window,
54                                gint       x,
55                                gint       y,
56                                gint       width,
57                                gint       height)
58 {
59   GdkWindowImplWin32 *impl;
60
61   g_return_if_fail (window != NULL);
62   g_return_if_fail (GDK_IS_WINDOW (window));
63
64   impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
65
66   GDK_NOTE (MISC, g_print ("_gdk_window_move_resize_child: %s@%+d%+d %dx%d@%+d%+d\n",
67                            _gdk_win32_window_description (window),
68                            window->x, window->y, width, height, x, y));
69
70   if (width > 65535 || height > 65535)
71   {
72     g_warning ("Native children wider or taller than 65535 pixels are not supported.");
73
74     if (width > 65535)
75       width = 65535;
76     if (height > 65535)
77       height = 65535;
78   }
79
80   window->x = x;
81   window->y = y;
82   window->width = width;
83   window->height = height;
84
85   _gdk_win32_window_tmp_unset_parent_bg (window);
86   _gdk_win32_window_tmp_unset_bg (window, TRUE);
87   
88   GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,%d,%d,%d,%d,"
89                            "NOACTIVATE|NOZORDER)\n",
90                            GDK_WINDOW_HWND (window),
91                            window->x + window->parent->abs_x, window->y + window->parent->abs_y, 
92                            width, height));
93
94   API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), NULL,
95                            window->x + window->parent->abs_x, window->y + window->parent->abs_y, 
96                            width, height,
97                            SWP_NOACTIVATE | SWP_NOZORDER));
98
99   _gdk_win32_window_tmp_reset_bg (window, TRUE);
100 }
101
102 void
103 _gdk_win32_window_tmp_unset_bg (GdkWindow *window,
104                                 gboolean recurse)
105 {
106   g_return_if_fail (GDK_IS_WINDOW (window));
107
108   if (window->input_only || window->destroyed ||
109       (window->window_type != GDK_WINDOW_ROOT &&
110        !GDK_WINDOW_IS_MAPPED (window)))
111     return;
112
113   if (_gdk_window_has_impl (window) &&
114       GDK_WINDOW_IS_WIN32 (window) &&
115       window->window_type != GDK_WINDOW_ROOT &&
116       window->window_type != GDK_WINDOW_FOREIGN)
117     tmp_unset_bg (window);
118
119   if (recurse)
120     {
121       GList *l;
122
123       for (l = window->children; l != NULL; l = l->next)
124         _gdk_win32_window_tmp_unset_bg (l->data, TRUE);
125     }
126 }
127
128 static void
129 tmp_unset_bg (GdkWindow *window)
130 {
131   GdkWindowImplWin32 *impl;
132
133   impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
134
135   impl->no_bg = TRUE;
136 }
137
138 static void
139 tmp_reset_bg (GdkWindow *window)
140 {
141   GdkWindowImplWin32 *impl;
142
143   impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
144
145   impl->no_bg = FALSE;
146 }
147
148 void
149 _gdk_win32_window_tmp_unset_parent_bg (GdkWindow *window)
150 {
151   if (GDK_WINDOW_TYPE (window->parent) == GDK_WINDOW_ROOT)
152     return;
153
154   window = _gdk_window_get_impl_window (window->parent);
155   _gdk_win32_window_tmp_unset_bg (window, FALSE);
156 }
157
158 void
159 _gdk_win32_window_tmp_reset_bg (GdkWindow *window,
160                                 gboolean   recurse)
161 {
162   g_return_if_fail (GDK_IS_WINDOW (window));
163
164   if (window->input_only || window->destroyed ||
165       (window->window_type != GDK_WINDOW_ROOT && !GDK_WINDOW_IS_MAPPED (window)))
166     return;
167
168   if (_gdk_window_has_impl (window) &&
169       GDK_WINDOW_IS_WIN32 (window) &&
170       window->window_type != GDK_WINDOW_ROOT &&
171       window->window_type != GDK_WINDOW_FOREIGN)
172     {
173       tmp_reset_bg (window);
174     }
175
176   if (recurse)
177     {
178       GList *l;
179
180       for (l = window->children; l != NULL; l = l->next)
181         _gdk_win32_window_tmp_reset_bg (l->data, TRUE);
182     }
183 }