Debian Codegraph @

gdk/win32/gdkwindow-win32.h

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 Library 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 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 /*
19 * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
20 * file for a list of people on the GTK+ Team. See the ChangeLog
21 * files for a list of changes. These files are distributed with
22 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
23 */
24
25 #ifndef __GDK_WINDOW_WIN32_H__
26 #define __GDK_WINDOW_WIN32_H__
27
28 #include "gdk/win32/gdkprivate-win32.h"
29 #include "gdk/win32/gdkglcontext-win32.h"
30 #include "gdk/gdkwindowimpl.h"
31 #include "gdk/gdkcursor.h"
32
33 #include <windows.h>
34
35 G_BEGIN_DECLS
36
37 /* Window implementation for Win32
38 */
39
40 typedef struct _GdkWindowImplWin32 GdkWindowImplWin32;
41 typedef struct _GdkWindowImplWin32Class GdkWindowImplWin32Class;
42
43 #define GDK_TYPE_WINDOW_IMPL_WIN32 (_gdk_window_impl_win32_get_type ())
44 #define GDK_WINDOW_IMPL_WIN32(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WINDOW_IMPL_WIN32, GdkWindowImplWin32))
45 #define GDK_WINDOW_IMPL_WIN32_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WINDOW_IMPL_WIN32, GdkWindowImplWin32Class))
46 #define GDK_IS_WINDOW_IMPL_WIN32(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WINDOW_IMPL_WIN32))
47 #define GDK_IS_WINDOW_IMPL_WIN32_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WINDOW_IMPL_WIN32))
48 #define GDK_WINDOW_IMPL_WIN32_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WINDOW_IMPL_WIN32, GdkWindowImplWin32Class))
49
50 enum _GdkWin32AeroSnapCombo
51 {
52 GDK_WIN32_AEROSNAP_COMBO_NOTHING = 0,
53 GDK_WIN32_AEROSNAP_COMBO_UP,
54 GDK_WIN32_AEROSNAP_COMBO_DOWN,
55 GDK_WIN32_AEROSNAP_COMBO_LEFT,
56 GDK_WIN32_AEROSNAP_COMBO_RIGHT,
57 /* Same order as non-shift variants. We use it to do things like:
58 * AEROSNAP_UP + 4 = AEROSNAP_SHIFTUP
59 */
60 GDK_WIN32_AEROSNAP_COMBO_SHIFTUP,
61 GDK_WIN32_AEROSNAP_COMBO_SHIFTDOWN,
62 GDK_WIN32_AEROSNAP_COMBO_SHIFTLEFT,
63 GDK_WIN32_AEROSNAP_COMBO_SHIFTRIGHT
64 };
65
66 typedef enum _GdkWin32AeroSnapCombo GdkWin32AeroSnapCombo;
67
68 enum _GdkWin32AeroSnapState
69 {
70 GDK_WIN32_AEROSNAP_STATE_UNDETERMINED = 0,
71 GDK_WIN32_AEROSNAP_STATE_HALFLEFT,
72 GDK_WIN32_AEROSNAP_STATE_HALFRIGHT,
73 GDK_WIN32_AEROSNAP_STATE_FULLUP,
74 /* Maximize state is only used by edge-snap */
75 GDK_WIN32_AEROSNAP_STATE_MAXIMIZE
76 };
77
78 typedef enum _GdkWin32AeroSnapState GdkWin32AeroSnapState;
79
80 struct _GdkRectangleDouble
81 {
82 gdouble x;
83 gdouble y;
84 gdouble width;
85 gdouble height;
86 };
87
88 typedef struct _GdkRectangleDouble GdkRectangleDouble;
89
90 enum _GdkW32WindowDragOp
91 {
92 GDK_WIN32_DRAGOP_NONE = 0,
93 GDK_WIN32_DRAGOP_RESIZE,
94 GDK_WIN32_DRAGOP_MOVE,
95 GDK_WIN32_DRAGOP_COUNT
96 };
97
98 typedef enum _GdkW32WindowDragOp GdkW32WindowDragOp;
99
100 typedef enum _GdkWin32MonitorDpiType
101 {
102 MDT_EFFECTIVE_DPI = 0,
103 MDT_ANGULAR_DPI = 1,
104 MDT_RAW_DPI = 2,
105 MDT_DEFAULT = MDT_EFFECTIVE_DPI
106 } GdkWin32MonitorDpiType;
107
108 struct _GdkW32DragMoveResizeContext
109 {
110 /* The window that is being moved/resized */
111 GdkWindow *window;
112
113 /* The kind of drag-operation going on. */
114 GdkW32WindowDragOp op;
115
116 /* The edge that was grabbed for resizing. Not used for moving. */
117 GdkWindowEdge edge;
118
119 /* The device used to initiate the op.
120 * We grab it at the beginning and ungrab it at the end.
121 */
122 GdkDevice *device;
123
124 /* The button pressed down to initiate the op.
125 * The op will be canceled only when *this* button
126 * is released.
127 */
128 gint button;
129
130 /* Initial cursor position when the operation began.
131 * Current cursor position is subtracted from it to find how far
132 * to move window border(s).
133 */
134 gint start_root_x;
135 gint start_root_y;
136
137 /* Initial window rectangle (position and size).
138 * The window is resized/moved relative to this (see start_root_*).
139 */
140 RECT start_rect;
141
142 /* Not used */
143 guint32 timestamp;
144
145 /* TRUE if during the next redraw we should call SetWindowPos() to push
146 * the window size and poistion to the native window.
147 */
148 gboolean native_move_resize_pending;
149
150 /* The cursor we should use while the operation is running. */
151 GdkCursor *cursor;
152
153 /* This window looks like an outline and is drawn under the window
154 * that is being dragged. It indicates the shape the dragged window
155 * will take if released at a particular point.
156 * Indicator window size always matches the target indicator shape,
157 * the the actual indicator drawn on it might not, depending on
158 * how much time elapsed since the animation started.
159 */
160 HWND shape_indicator;
161
162 /* Used to draw the indicator */
163 cairo_surface_t *indicator_surface;
164 gint indicator_surface_width;
165 gint indicator_surface_height;
166
167 /* Size/position of shape_indicator */
168 GdkRectangle indicator_window_rect;
169
170 /* Indicator will animate to occupy this rectangle */
171 GdkRectangle indicator_target;
172
173 /* Indicator will start animating from this rectangle */
174 GdkRectangle indicator_start;
175
176 /* Timestamp of the animation start */
177 gint64 indicator_start_time;
178
179 /* Timer that drives the animation */
180 guint timer;
181
182 /* A special timestamp, if we want to draw not how
183 * the animation should look *now*, but how it should
184 * look at arbitrary moment of time.
185 * Set to 0 to tell GDK to use current time.
186 */
187 gint64 draw_timestamp;
188
189 /* Indicates that a transformation was revealed:
190 *
191 * For drag-resize: If it's FALSE,
192 * then the pointer have not yet hit a trigger that triggers fullup.
193 * If TRUE, then the pointer did hit a trigger that triggers fullup
194 * at some point during this drag op.
195 * This is used to prevent drag-resize from triggering
196 * a transformation when first approaching a trigger of the work area -
197 * one must drag it all the way to the very trigger to trigger; afterwards
198 * a transformation will start triggering at some distance from the trigger
199 * for as long as the op is still running. This is how AeroSnap works.
200 *
201 * For drag-move: If it's FALSE,
202 * then the pointer have not yet hit a trigger, even if it is
203 * already within a edge region.
204 * If it's TRUE, then the pointer did hit a trigger within an
205 * edge region, and have not yet left an edge region
206 * (passing from one edge region into another doesn't count).
207 */
208 gboolean revealed;
209
210 /* Arrays of GdkRectangle pairs, describing the areas of the virtual
211 * desktop that trigger various AeroSnap window transofrmations
212 * Coordinates are GDK screen coordinates.
213 */
214 GArray *halfleft_regions;
215 GArray *halfright_regions;
216 GArray *maximize_regions;
217 GArray *fullup_regions;
218
219 /* Current pointer position will result in this kind of snapping,
220 * if the drag op is finished.
221 */
222 GdkWin32AeroSnapState current_snap;
223 };
224
225 typedef struct _GdkW32DragMoveResizeContext GdkW32DragMoveResizeContext;
226
227 struct _GdkWindowImplWin32
228 {
229 GdkWindowImpl parent_instance;
230
231 GdkWindow *wrapper;
232 HANDLE handle;
233
234 gint8 toplevel_window_type;
235
236 GdkCursor *cursor;
237 HICON hicon_big;
238 HICON hicon_small;
239
240 /* Window size hints */
241 gint hint_flags;
242 GdkGeometry hints;
243
244 GdkEventMask native_event_mask;
245
246 GdkWindowTypeHint type_hint;
247
248 GdkWindow *transient_owner;
249 GSList *transient_children;
250 gint num_transients;
251 gboolean changing_state;
252
253 gint initial_x;
254 gint initial_y;
255
256 /* left/right/top/bottom width of the shadow/resize-grip around the window */
257 RECT margins;
258
259 /* left+right and top+bottom from @margins */
260 gint margins_x;
261 gint margins_y;
262
263 /* Set to TRUE when GTK tells us that margins are 0 everywhere.
264 * We don't actually set margins to 0, we just set this bit.
265 */
266 guint zero_margins : 1;
267 guint no_bg : 1;
268 guint inhibit_configure : 1;
269 guint override_redirect : 1;
270
271 /* Set to TRUE if window is using true layered mode adjustments
272 * via UpdateLayeredWindow().
273 * Layered windows that get SetLayeredWindowAttributes() called
274 * on them are not true layered windows.
275 */
276 guint layered : 1;
277
278 /* If TRUE, the @temp_styles is set to the styles that were temporarily
279 * added to this window.
280 */
281 guint have_temp_styles : 1;
282
283 /* If TRUE, the window is in the process of being maximized.
284 * This is set by WM_SYSCOMMAND and by gdk_win32_window_maximize (),
285 * and is unset when WM_WINDOWPOSCHANGING is handled.
286 */
287 guint maximizing : 1;
288
289 /* GDK does not keep window contents around, it just draws new
290 * stuff over the window where changes occurred.
291 * cache_surface retains old window contents, because
292 * UpdateLayeredWindow() doesn't do partial redraws.
293 */
294 cairo_surface_t *cache_surface;
295 cairo_surface_t *cairo_surface;
296
297 /* Unlike window-backed surfaces, DIB-backed surface
298 * does not provide a way to query its size,
299 * so we have to remember it ourselves.
300 */
301 gint dib_width;
302 gint dib_height;
303
304 /* If the client wants uniformly-transparent window,
305 * we remember the opacity value here and apply it
306 * during UpdateLayredWindow() call, for layered windows.
307 */
308 gdouble layered_opacity;
309
310 HDC hdc;
311 int hdc_count;
312 HBITMAP saved_dc_bitmap; /* Original bitmap for dc */
313
314 GdkW32DragMoveResizeContext drag_move_resize_context;
315
316 /* Remembers where the window was snapped.
317 * Some snap operations change their meaning if
318 * the window is already snapped.
319 */
320 GdkWin32AeroSnapState snap_state;
321
322 /* Remembers window position before it was snapped.
323 * This is used to unsnap it.
324 * Position and size are percentages of the workarea
325 * of the monitor on which the window was before it was snapped.
326 */
327 GdkRectangleDouble *snap_stash;
328
329 /* Also remember the same position, but in absolute form. */
330 GdkRectangle *snap_stash_int;
331
332 /* Decorations set by gdk_window_set_decorations() or NULL if unset */
333 GdkWMDecoration* decorations;
334
335 /* No. of windows to force layered windows off */
336 guint suppress_layered;
337
338 /* Temporary styles that this window got for the purpose of
339 * handling WM_SYSMENU.
340 * They are removed at the first opportunity (usually WM_INITMENU).
341 */
342 LONG_PTR temp_styles;
343
344 /* scale of window on HiDPI */
345 gint window_scale;
346 gint unscaled_width;
347 gint unscaled_height;
348
349 #ifdef GDK_WIN32_ENABLE_EGL
350 EGLSurface egl_surface;
351 EGLSurface egl_dummy_surface;
352 guint egl_force_redraw_all : 1;
353 #endif
354 };
355
356 struct _GdkWindowImplWin32Class
357 {
358 GdkWindowImplClass parent_class;
359 };
360
361 GType _gdk_window_impl_win32_get_type (void);
362
363 void _gdk_win32_window_tmp_unset_bg (GdkWindow *window,
364 gboolean recurse);
365 void _gdk_win32_window_tmp_reset_bg (GdkWindow *window,
366 gboolean recurse);
367
368 void _gdk_win32_window_tmp_unset_parent_bg (GdkWindow *window);
369 void _gdk_win32_window_tmp_reset_parent_bg (GdkWindow *window);
370
371 void _gdk_win32_window_update_style_bits (GdkWindow *window);
372
373 gint _gdk_win32_window_get_scale_factor (GdkWindow *window);
374
375 #ifdef GDK_WIN32_ENABLE_EGL
376 EGLSurface _gdk_win32_window_get_egl_surface (GdkWindow *window,
377 EGLConfig config,
378 gboolean is_dummy);
379 #endif
380
381 G_END_DECLS
382
383 #endif /* __GDK_WINDOW_WIN32_H__ */