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 "gdkregion.h"
44 #include "gdkregion-generic.h"
45 #include "gdkinternals.h"
46 #include "gdkprivate-win32.h"
48 #define SIZE_LIMIT 32767
50 typedef struct _GdkWindowParentPos GdkWindowParentPos;
53 _gdk_window_move_resize_child (GdkWindow *window,
59 GdkWindowImplWin32 *impl;
64 g_return_if_fail (window != NULL);
65 g_return_if_fail (GDK_IS_WINDOW (window));
67 obj = GDK_WINDOW_OBJECT (window);
68 impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
70 is_move = (x - obj->x != 0) && (y - obj->y != 0);
71 is_resize = obj->width != width && obj->height != height;
73 GDK_NOTE (MISC, g_print ("_gdk_window_move_resize_child: %s@%+d%+d %dx%d@%+d%+d\n",
74 _gdk_win32_drawable_description (window),
75 obj->x, obj->y, width, height, x, y));
77 if (width > 65535 || height > 65535)
79 g_warning ("Native children wider or taller than 65535 pixels are not supported.");
92 GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,%d,%d,%d,%d,"
93 "NOACTIVATE|NOZORDER%s%s)\n",
94 GDK_WINDOW_HWND (window),
95 obj->x + obj->parent->abs_x, obj->y + obj->parent->abs_y,
97 (is_move ? "" : "|NOMOVE"),
98 (is_resize ? "" : "|NOSIZE")));
100 API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), NULL,
101 obj->x + obj->parent->abs_x, obj->y + obj->parent->abs_y,
103 SWP_NOACTIVATE | SWP_NOZORDER |
104 (is_move ? 0 : SWP_NOMOVE) |
105 (is_resize ? 0 : SWP_NOSIZE)));
109 _gdk_window_process_expose (GdkWindow *window,
110 GdkRegion *invalidate_region)
112 GdkWindowImplWin32 *impl;
113 //GdkRegion *clip_region;
114 impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
116 GDK_NOTE (EVENTS, g_print ("_gdk_window_process_expose: %p %s\n",
117 GDK_WINDOW_HWND (window),
118 _gdk_win32_gdkregion_to_string (invalidate_region)));
120 if (!gdk_region_empty (invalidate_region))
121 _gdk_window_invalidate_for_expose (window, invalidate_region);
123 g_print ("_gdk_window_process_expose\n");
124 gdk_region_destroy (invalidate_region);
128 gdk_window_tmp_unset_bg (GdkWindow *window)
130 GdkWindowImplWin32 *impl;
131 GdkWindowObject *obj;
133 obj = (GdkWindowObject *) window;
134 impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
139 * The X version sets background = None to avoid updateing for a moment.
140 * Not sure if this could really emulate it.
142 if (obj->bg_pixmap != GDK_NO_BG)
143 /* handled in WM_ERASEBKGRND proceesing */;
147 gdk_window_tmp_reset_bg (GdkWindow *window)
149 GdkWindowImplWin32 *impl;
150 GdkWindowObject *obj;
152 obj = (GdkWindowObject *) window;
153 impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
159 gdk_window_clip_changed (GdkWindow *window,
160 GdkRectangle *old_clip,
161 GdkRectangle *new_clip)
163 GdkWindowImplWin32 *impl;
164 GdkWindowObject *obj;
165 GdkRegion *old_clip_region;
166 GdkRegion *new_clip_region;
168 if (((GdkWindowObject *)window)->input_only)
171 obj = (GdkWindowObject *) window;
172 impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
174 old_clip_region = gdk_region_rectangle (old_clip);
175 new_clip_region = gdk_region_rectangle (new_clip);
177 /* Trim invalid region of window to new clip rectangle
179 if (obj->update_area)
180 gdk_region_intersect (obj->update_area, new_clip_region);
182 /* Invalidate newly exposed portion of window
184 gdk_region_subtract (new_clip_region, old_clip_region);
185 if (!gdk_region_empty (new_clip_region))
186 gdk_window_tmp_unset_bg (window);
189 g_print ("gdk_window_clip_changed (new_clip_region)\n");
190 gdk_region_destroy (new_clip_region);
191 new_clip_region = NULL;
193 g_print ("gdk_window_clip_changed (old_clip_region)\n");
194 gdk_region_destroy (old_clip_region);
196 return new_clip_region;
200 gdk_window_post_scroll (GdkWindow *window,
201 GdkRegion *new_clip_region)
204 g_print ("gdk_window_clip_changed: invalidating region: %s\n",
205 _gdk_win32_gdkregion_to_string (new_clip_region)));
207 gdk_window_invalidate_region (window, new_clip_region, FALSE);
208 g_print ("gdk_window_post_scroll\n");
209 gdk_region_destroy (new_clip_region);