]> Pileus Git - ~andy/gtk/blob - gdk/win32/gdkgeometry-win32.c
gdk: fix gdk_keyval_to_lower/upper() for Quartz, Win32 and Broadway
[~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, 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 <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.
39  */
40
41 #include "config.h"
42 #include "gdk.h"                /* For gdk_rectangle_intersect */
43 #include "gdkinternals.h"
44 #include "gdkprivate-win32.h"
45 #include "gdkwin32.h"
46
47 #define SIZE_LIMIT 32767
48
49 typedef struct _GdkWindowParentPos GdkWindowParentPos;
50
51 static void tmp_unset_bg (GdkWindow *window);
52 static void tmp_reset_bg (GdkWindow *window);
53
54 void
55 _gdk_window_move_resize_child (GdkWindow *window,
56                                gint       x,
57                                gint       y,
58                                gint       width,
59                                gint       height)
60 {
61   GdkWindowImplWin32 *impl;
62   gboolean is_move;
63   gboolean is_resize;
64
65   g_return_if_fail (window != NULL);
66   g_return_if_fail (GDK_IS_WINDOW (window));
67
68   impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
69
70   is_move = (x - window->x != 0) && (y - window->y != 0);
71   is_resize = window->width != width && window->height != height;
72   
73   GDK_NOTE (MISC, g_print ("_gdk_window_move_resize_child: %s@%+d%+d %dx%d@%+d%+d\n",
74                            _gdk_win32_window_description (window),
75                            window->x, window->y, width, height, x, y));
76
77   if (width > 65535 || height > 65535)
78   {
79     g_warning ("Native children wider or taller than 65535 pixels are not supported.");
80
81     if (width > 65535)
82       width = 65535;
83     if (height > 65535)
84       height = 65535;
85   }
86
87   window->x = x;
88   window->y = y;
89   window->width = width;
90   window->height = height;
91
92   _gdk_win32_window_tmp_unset_parent_bg (window);
93   _gdk_win32_window_tmp_unset_bg (window, TRUE);
94   
95   GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,%d,%d,%d,%d,"
96                            "NOACTIVATE|NOZORDER%s%s)\n",
97                            GDK_WINDOW_HWND (window),
98                            window->x + window->parent->abs_x, window->y + window->parent->abs_y, 
99                            width, height,
100                            (is_move ? "" : "|NOMOVE"),
101                            (is_resize ? "" : "|NOSIZE")));
102
103   API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), NULL,
104                            window->x + window->parent->abs_x, window->y + window->parent->abs_y, 
105                            width, height,
106                            SWP_NOACTIVATE | SWP_NOZORDER | 
107                            (is_move ? 0 : SWP_NOMOVE) |
108                            (is_resize ? 0 : SWP_NOSIZE)));
109
110   _gdk_win32_window_tmp_reset_bg (window, TRUE);
111 }
112
113 void
114 _gdk_win32_window_tmp_unset_bg (GdkWindow *window,
115                                 gboolean recurse)
116 {
117   g_return_if_fail (GDK_IS_WINDOW (window));
118
119   if (window->input_only || window->destroyed ||
120       (window->window_type != GDK_WINDOW_ROOT &&
121        !GDK_WINDOW_IS_MAPPED (window)))
122     return;
123
124   if (_gdk_window_has_impl (window) &&
125       GDK_WINDOW_IS_WIN32 (window) &&
126       window->window_type != GDK_WINDOW_ROOT &&
127       window->window_type != GDK_WINDOW_FOREIGN)
128     tmp_unset_bg (window);
129
130   if (recurse)
131     {
132       GList *l;
133
134       for (l = window->children; l != NULL; l = l->next)
135         _gdk_win32_window_tmp_unset_bg (l->data, TRUE);
136     }
137 }
138
139 static void
140 tmp_unset_bg (GdkWindow *window)
141 {
142   GdkWindowImplWin32 *impl;
143
144   impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
145
146   impl->no_bg = TRUE;
147 }
148
149 static void
150 tmp_reset_bg (GdkWindow *window)
151 {
152   GdkWindowImplWin32 *impl;
153
154   impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
155
156   impl->no_bg = FALSE;
157 }
158
159 void
160 _gdk_win32_window_tmp_unset_parent_bg (GdkWindow *window)
161 {
162   if (GDK_WINDOW_TYPE (window->parent) == GDK_WINDOW_ROOT)
163     return;
164
165   window = _gdk_window_get_impl_window (window->parent);
166   _gdk_win32_window_tmp_unset_bg (window, FALSE);
167 }
168
169 void
170 _gdk_win32_window_tmp_reset_bg (GdkWindow *window,
171                                 gboolean   recurse)
172 {
173   g_return_if_fail (GDK_IS_WINDOW (window));
174
175   if (window->input_only || window->destroyed ||
176       (window->window_type != GDK_WINDOW_ROOT && !GDK_WINDOW_IS_MAPPED (window)))
177     return;
178
179   if (_gdk_window_has_impl (window) &&
180       GDK_WINDOW_IS_WIN32 (window) &&
181       window->window_type != GDK_WINDOW_ROOT &&
182       window->window_type != GDK_WINDOW_FOREIGN)
183     {
184       tmp_reset_bg (window);
185     }
186
187   if (recurse)
188     {
189       GList *l;
190
191       for (l = window->children; l != NULL; l = l->next)
192         _gdk_win32_window_tmp_reset_bg (l->data, TRUE);
193     }
194 }