Debian Codegraph @

gdk/win32/gdkgeometry-win32.c

raw
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, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 */
19
20 /* gdkgeometry-win32.c: emulation of 32 bit coordinates within the
21 * limits of Win32 GDI. The idea of big window emulation is more or less
22 * a copy of the X11 version, and the equvalent of guffaw scrolling
23 * is ScrollWindowEx(). While we determine the invalidated region
24 * ourself during scrolling, we do not pass SW_INVALIDATE to
25 * ScrollWindowEx() to avoid a unnecessary WM_PAINT.
26 *
27 * Bits are always scrolled correctly by ScrollWindowEx(), but
28 * some big children may hit the coordinate boundary (i.e.
29 * win32_x/win32_y < -16383) after scrolling. They needed to be moved
30 * back to the real position determined by gdk_window_compute_position().
31 * This is handled in gdk_window_postmove().
32 *
33 * The X11 version by Owen Taylor <[email protected]>
34 * Copyright Red Hat, Inc. 2000
35 * Win32 hack by Tor Lillqvist <[email protected]>
36 * and Hans Breuer <[email protected]>
37 * Modified by Ivan, Wong Yat Cheung <[email protected]>
38 * so that big window emulation finally works.
39 */
40
41 #include "config.h"
42 #include "gdk.h" /* For gdk_rectangle_intersect */
43 #include "gdkregion.h"
44 #include "gdkregion-generic.h"
45 #include "gdkinternals.h"
46 #include "gdkprivate-win32.h"
47
48 #define SIZE_LIMIT 32767
49
50 typedef struct _GdkWindowParentPos GdkWindowParentPos;
51
52 static void tmp_unset_bg (GdkWindow *window);
53 static void tmp_reset_bg (GdkWindow *window);
54
55 void
56 _gdk_window_move_resize_child (GdkWindow *window,
57 gint x,
58 gint y,
59 gint width,
60 gint height)
61 {
62 GdkWindowImplWin32 *impl;
63 GdkWindowObject *obj;
64
65 g_return_if_fail (window != NULL);
66 g_return_if_fail (GDK_IS_WINDOW (window));
67
68 obj = GDK_WINDOW_OBJECT (window);
69 impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
70
71 GDK_NOTE (MISC, g_print ("_gdk_window_move_resize_child: %s@%+d%+d %dx%d@%+d%+d\n",
72 _gdk_win32_drawable_description (window),
73 obj->x, obj->y, width, height, x, y));
74
75 if (width > 65535 || height > 65535)
76 {
77 g_warning ("Native children wider or taller than 65535 pixels are not supported.");
78
79 if (width > 65535)
80 width = 65535;
81 if (height > 65535)
82 height = 65535;
83 }
84
85 obj->x = x;
86 obj->y = y;
87 obj->width = width;
88 obj->height = height;
89
90 _gdk_win32_window_tmp_unset_parent_bg (window);
91 _gdk_win32_window_tmp_unset_bg (window, TRUE);
92
93 GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,%d,%d,%d,%d,"
94 "NOACTIVATE|NOZORDER)\n",
95 GDK_WINDOW_HWND (window),
96 obj->x + obj->parent->abs_x, obj->y + obj->parent->abs_y,
97 width, height));
98
99 API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), NULL,
100 obj->x + obj->parent->abs_x, obj->y + obj->parent->abs_y,
101 width, height,
102 SWP_NOACTIVATE | SWP_NOZORDER));
103
104 //_gdk_win32_window_tmp_reset_parent_bg (window);
105 _gdk_win32_window_tmp_reset_bg (window, TRUE);
106 }
107
108 void
109 _gdk_win32_window_tmp_unset_bg (GdkWindow *window,
110 gboolean recurse)
111 {
112 GdkWindowObject *private;
113
114 g_return_if_fail (GDK_IS_WINDOW (window));
115
116 private = (GdkWindowObject *)window;
117
118 if (private->input_only || private->destroyed ||
119 (private->window_type != GDK_WINDOW_ROOT &&
120 !GDK_WINDOW_IS_MAPPED (window)))
121 return;
122
123 if (_gdk_window_has_impl (window) &&
124 GDK_WINDOW_IS_WIN32 (window) &&
125 private->window_type != GDK_WINDOW_ROOT &&
126 private->window_type != GDK_WINDOW_FOREIGN)
127 tmp_unset_bg (window);
128
129 if (recurse)
130 {
131 GList *l;
132
133 for (l = private->children; l != NULL; l = l->next)
134 _gdk_win32_window_tmp_unset_bg (l->data, TRUE);
135 }
136 }
137
138 static void
139 tmp_unset_bg (GdkWindow *window)
140 {
141 GdkWindowImplWin32 *impl;
142 GdkWindowObject *obj;
143
144 obj = (GdkWindowObject *) window;
145 impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
146
147 impl->no_bg = TRUE;
148
149 /*
150 * The X version sets background = None to avoid updateing for a moment.
151 * Not sure if this could really emulate it.
152 */
153 if (obj->bg_pixmap != GDK_NO_BG)
154 {
155 ///* handled in WM_ERASEBKGRND proceesing */;
156
157 //HDC hdc = GetDC (GDK_WINDOW_HWND (window));
158 //erase_background (window, hdc);
159 }
160 }
161
162 static void
163 tmp_reset_bg (GdkWindow *window)
164 {
165 GdkWindowObject *obj;
166 GdkWindowImplWin32 *impl;
167
168 obj = GDK_WINDOW_OBJECT (window);
169 impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
170
171 impl->no_bg = FALSE;
172 }
173
174 void
175 _gdk_win32_window_tmp_unset_parent_bg (GdkWindow *window)
176 {
177 GdkWindowObject *private = (GdkWindowObject*)window;
178
179 if (GDK_WINDOW_TYPE (private->parent) == GDK_WINDOW_ROOT)
180 return;
181
182 window = _gdk_window_get_impl_window ((GdkWindow*)private->parent);
183 _gdk_win32_window_tmp_unset_bg (window, FALSE);
184 }
185
186 void
187 _gdk_win32_window_tmp_reset_bg (GdkWindow *window,
188 gboolean recurse)
189 {
190 GdkWindowObject *private = (GdkWindowObject*)window;
191
192 g_return_if_fail (GDK_IS_WINDOW (window));
193
194 if (private->input_only || private->destroyed ||
195 (private->window_type != GDK_WINDOW_ROOT && !GDK_WINDOW_IS_MAPPED (window)))
196 return;
197
198 if (_gdk_window_has_impl (window) &&
199 GDK_WINDOW_IS_WIN32 (window) &&
200 private->window_type != GDK_WINDOW_ROOT &&
201 private->window_type != GDK_WINDOW_FOREIGN)
202 {
203 tmp_reset_bg (window);
204 }
205
206 if (recurse)
207 {
208 GList *l;
209
210 for (l = private->children; l != NULL; l = l->next)
211 _gdk_win32_window_tmp_reset_bg (l->data, TRUE);
212 }
213 }
214
215 /*
216 void
217 _gdk_win32_window_tmp_reset_bg (GdkWindow *window)
218 {
219 GdkWindowImplWin32 *impl;
220 GdkWindowObject *obj;
221
222 obj = (GdkWindowObject *) window;
223 impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
224
225 impl->no_bg = FALSE;
226 }
227 */
228
229 #if 0
230 static GdkRegion *
231 gdk_window_clip_changed (GdkWindow *window,
232 GdkRectangle *old_clip,
233 GdkRectangle *new_clip)
234 {
235 GdkWindowImplWin32 *impl;
236 GdkWindowObject *obj;
237 GdkRegion *old_clip_region;
238 GdkRegion *new_clip_region;
239
240 if (((GdkWindowObject *)window)->input_only)
241 return NULL;
242
243 obj = (GdkWindowObject *) window;
244 impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
245
246 old_clip_region = gdk_region_rectangle (old_clip);
247 new_clip_region = gdk_region_rectangle (new_clip);
248
249 /* Trim invalid region of window to new clip rectangle
250 */
251 if (obj->update_area)
252 gdk_region_intersect (obj->update_area, new_clip_region);
253
254 /* Invalidate newly exposed portion of window
255 */
256 gdk_region_subtract (new_clip_region, old_clip_region);
257 if (!gdk_region_empty (new_clip_region))
258 gdk_window_tmp_unset_bg (window);
259 else
260 {
261 gdk_region_destroy (new_clip_region);
262 new_clip_region = NULL;
263 }
264
265 gdk_region_destroy (old_clip_region);
266
267 return new_clip_region;
268 }
269 #endif
270
271 #if 0
272 static void
273 gdk_window_post_scroll (GdkWindow *window,
274 GdkRegion *new_clip_region)
275 {
276 GDK_NOTE (EVENTS,
277 g_print ("gdk_window_clip_changed: invalidating region: %s\n",
278 _gdk_win32_gdkregion_to_string (new_clip_region)));
279
280 gdk_window_invalidate_region (window, new_clip_region, FALSE);
281 g_print ("gdk_window_post_scroll\n");
282 gdk_region_destroy (new_clip_region);
283 }
284
285 #endif