1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
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.
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.
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.
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.
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().
33 * The X11 version by Owen Taylor <otaylor@redhat.com>
34 * Copyright Red Hat, Inc. 2000
35 * Win32 hack by Tor Lillqvist <tml@iki.fi>
36 * and Hans Breuer <hans@breuer.org>
37 * Modified by Ivan, Wong Yat Cheung <email@ivanwong.info>
38 * so that big window emulation finally works.
42 #include "gdk.h" /* For gdk_rectangle_intersect */
43 #include "gdkinternals.h"
44 #include "gdkprivate-win32.h"
46 #define SIZE_LIMIT 32767
48 typedef struct _GdkWindowParentPos GdkWindowParentPos;
50 static void tmp_unset_bg (GdkWindow *window);
51 static void tmp_reset_bg (GdkWindow *window);
54 _gdk_window_move_resize_child (GdkWindow *window,
60 GdkWindowImplWin32 *impl;
65 g_return_if_fail (window != NULL);
66 g_return_if_fail (GDK_IS_WINDOW (window));
68 obj = GDK_WINDOW_OBJECT (window);
69 impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
71 is_move = (x - obj->x != 0) && (y - obj->y != 0);
72 is_resize = obj->width != width && obj->height != height;
74 GDK_NOTE (MISC, g_print ("_gdk_window_move_resize_child: %s@%+d%+d %dx%d@%+d%+d\n",
75 _gdk_win32_drawable_description (window),
76 obj->x, obj->y, width, height, x, y));
78 if (width > 65535 || height > 65535)
80 g_warning ("Native children wider or taller than 65535 pixels are not supported.");
93 _gdk_win32_window_tmp_unset_parent_bg (window);
94 _gdk_win32_window_tmp_unset_bg (window, TRUE);
96 GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,%d,%d,%d,%d,"
97 "NOACTIVATE|NOZORDER%s%s)\n",
98 GDK_WINDOW_HWND (window),
99 obj->x + obj->parent->abs_x, obj->y + obj->parent->abs_y,
101 (is_move ? "" : "|NOMOVE"),
102 (is_resize ? "" : "|NOSIZE")));
104 API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), NULL,
105 obj->x + obj->parent->abs_x, obj->y + obj->parent->abs_y,
107 SWP_NOACTIVATE | SWP_NOZORDER |
108 (is_move ? 0 : SWP_NOMOVE) |
109 (is_resize ? 0 : SWP_NOSIZE)));
111 //_gdk_win32_window_tmp_reset_parent_bg (window);
112 _gdk_win32_window_tmp_reset_bg (window, TRUE);
116 _gdk_win32_window_tmp_unset_bg (GdkWindow *window,
119 GdkWindowObject *private;
121 g_return_if_fail (GDK_IS_WINDOW (window));
123 private = (GdkWindowObject *)window;
125 if (private->input_only || private->destroyed ||
126 (private->window_type != GDK_WINDOW_ROOT &&
127 !GDK_WINDOW_IS_MAPPED (window)))
130 if (_gdk_window_has_impl (window) &&
131 GDK_WINDOW_IS_WIN32 (window) &&
132 private->window_type != GDK_WINDOW_ROOT &&
133 private->window_type != GDK_WINDOW_FOREIGN)
134 tmp_unset_bg (window);
140 for (l = private->children; l != NULL; l = l->next)
141 _gdk_win32_window_tmp_unset_bg (l->data, TRUE);
146 tmp_unset_bg (GdkWindow *window)
148 GdkWindowImplWin32 *impl;
149 GdkWindowObject *obj;
151 obj = (GdkWindowObject *) window;
152 impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
157 * The X version sets background = None to avoid updateing for a moment.
158 * Not sure if this could really emulate it.
160 if (obj->bg_pixmap != GDK_NO_BG)
162 ///* handled in WM_ERASEBKGRND proceesing */;
164 //HDC hdc = GetDC (GDK_WINDOW_HWND (window));
165 //erase_background (window, hdc);
170 tmp_reset_bg (GdkWindow *window)
172 GdkWindowObject *obj;
173 GdkWindowImplWin32 *impl;
175 obj = GDK_WINDOW_OBJECT (window);
176 impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
182 _gdk_win32_window_tmp_unset_parent_bg (GdkWindow *window)
184 GdkWindowObject *private = (GdkWindowObject*)window;
186 if (GDK_WINDOW_TYPE (private->parent) == GDK_WINDOW_ROOT)
189 window = _gdk_window_get_impl_window ((GdkWindow*)private->parent);
190 _gdk_win32_window_tmp_unset_bg (window, FALSE);
194 _gdk_win32_window_tmp_reset_bg (GdkWindow *window,
197 GdkWindowObject *private = (GdkWindowObject*)window;
199 g_return_if_fail (GDK_IS_WINDOW (window));
201 if (private->input_only || private->destroyed ||
202 (private->window_type != GDK_WINDOW_ROOT && !GDK_WINDOW_IS_MAPPED (window)))
205 if (_gdk_window_has_impl (window) &&
206 GDK_WINDOW_IS_WIN32 (window) &&
207 private->window_type != GDK_WINDOW_ROOT &&
208 private->window_type != GDK_WINDOW_FOREIGN)
210 tmp_reset_bg (window);
217 for (l = private->children; l != NULL; l = l->next)
218 _gdk_win32_window_tmp_reset_bg (l->data, TRUE);
224 _gdk_win32_window_tmp_reset_bg (GdkWindow *window)
226 GdkWindowImplWin32 *impl;
227 GdkWindowObject *obj;
229 obj = (GdkWindowObject *) window;
230 impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
237 static cairo_region_t *
238 gdk_window_clip_changed (GdkWindow *window,
239 GdkRectangle *old_clip,
240 GdkRectangle *new_clip)
242 GdkWindowImplWin32 *impl;
243 GdkWindowObject *obj;
244 cairo_region_t *old_clip_region;
245 cairo_region_t *new_clip_region;
247 if (((GdkWindowObject *)window)->input_only)
250 obj = (GdkWindowObject *) window;
251 impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
253 old_clip_region = cairo_region_create_rectangle (old_clip);
254 new_clip_region = cairo_region_create_rectangle (new_clip);
256 /* Trim invalid region of window to new clip rectangle
258 if (obj->update_area)
259 cairo_region_intersect (obj->update_area, new_clip_region);
261 /* Invalidate newly exposed portion of window
263 cairo_region_subtract (new_clip_region, old_clip_region);
264 if (!cairo_region_is_empty (new_clip_region))
265 gdk_window_tmp_unset_bg (window);
268 cairo_region_destroy (new_clip_region);
269 new_clip_region = NULL;
272 cairo_region_destroy (old_clip_region);
274 return new_clip_region;
280 gdk_window_post_scroll (GdkWindow *window,
281 cairo_region_t *new_clip_region)
284 g_print ("gdk_window_clip_changed: invalidating region: %s\n",
285 _gdk_win32_gdkregion_to_string (new_clip_region)));
287 gdk_window_invalidate_region (window, new_clip_region, FALSE);
288 g_print ("gdk_window_post_scroll\n");
289 cairo_region_destroy (new_clip_region);