1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 * Copyright (C) 1998-2004 Tor Lillqvist
4 * Copyright (C) 2001-2009 Hans Breuer
5 * Copyright (C) 2007-2009 Cody Russell
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
24 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
25 * file for a list of people on the GTK+ Team. See the ChangeLog
26 * files for a list of changes. These files are distributed with
27 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
34 #include "gdkwindowimpl.h"
35 #include "gdkprivate-win32.h"
36 #include "gdkdeviceprivate.h"
37 #include "gdkdevicemanager-win32.h"
38 #include "gdkenumtypes.h"
40 static void gdk_window_impl_win32_init (GdkWindowImplWin32 *window);
41 static void gdk_window_impl_win32_class_init (GdkWindowImplWin32Class *klass);
42 static void gdk_window_impl_win32_finalize (GObject *object);
44 static gpointer parent_class = NULL;
45 static GSList *modal_window_stack = NULL;
47 static void update_style_bits (GdkWindow *window);
48 static gboolean _gdk_window_get_functions (GdkWindow *window,
49 GdkWMFunction *functions);
51 #define WINDOW_IS_TOPLEVEL(window) \
52 (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \
53 GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN && \
54 GDK_WINDOW_TYPE (window) != GDK_WINDOW_OFFSCREEN)
56 static void gdk_window_impl_iface_init (GdkWindowImplIface *iface);
59 GDK_WINDOW_SCREEN (GObject *win)
65 _gdk_window_impl_win32_get_type (void)
67 static GType object_type = 0;
71 const GTypeInfo object_info =
73 sizeof (GdkWindowImplWin32Class),
75 (GBaseFinalizeFunc) NULL,
76 (GClassInitFunc) gdk_window_impl_win32_class_init,
77 NULL, /* class_finalize */
78 NULL, /* class_data */
79 sizeof (GdkWindowImplWin32),
81 (GInstanceInitFunc) gdk_window_impl_win32_init,
84 const GInterfaceInfo window_impl_info =
86 (GInterfaceInitFunc) gdk_window_impl_iface_init,
91 object_type = g_type_register_static (GDK_TYPE_DRAWABLE_IMPL_WIN32,
94 g_type_add_interface_static (object_type,
103 gdk_window_impl_win32_init (GdkWindowImplWin32 *impl)
105 impl->toplevel_window_type = -1;
106 impl->hcursor = NULL;
107 impl->hicon_big = NULL;
108 impl->hicon_small = NULL;
109 impl->hint_flags = 0;
110 impl->type_hint = GDK_WINDOW_TYPE_HINT_NORMAL;
111 impl->extension_events_selected = FALSE;
112 impl->transient_owner = NULL;
113 impl->transient_children = NULL;
114 impl->num_transients = 0;
115 impl->changing_state = FALSE;
119 gdk_window_impl_win32_class_init (GdkWindowImplWin32Class *klass)
121 GObjectClass *object_class = G_OBJECT_CLASS (klass);
123 parent_class = g_type_class_peek_parent (klass);
125 object_class->finalize = gdk_window_impl_win32_finalize;
129 gdk_window_impl_win32_finalize (GObject *object)
131 GdkWindowObject *wrapper;
132 GdkDrawableImplWin32 *draw_impl;
133 GdkWindowImplWin32 *window_impl;
135 g_return_if_fail (GDK_IS_WINDOW_IMPL_WIN32 (object));
137 draw_impl = GDK_DRAWABLE_IMPL_WIN32 (object);
138 window_impl = GDK_WINDOW_IMPL_WIN32 (object);
140 wrapper = (GdkWindowObject*) draw_impl->wrapper;
142 if (!GDK_WINDOW_DESTROYED (wrapper))
144 gdk_win32_handle_table_remove (draw_impl->handle);
147 if (window_impl->hcursor != NULL)
149 if (GetCursor () == window_impl->hcursor)
152 GDI_CALL (DestroyCursor, (window_impl->hcursor));
153 window_impl->hcursor = NULL;
156 if (window_impl->hicon_big != NULL)
158 GDI_CALL (DestroyIcon, (window_impl->hicon_big));
159 window_impl->hicon_big = NULL;
162 if (window_impl->hicon_small != NULL)
164 GDI_CALL (DestroyIcon, (window_impl->hicon_small));
165 window_impl->hicon_small = NULL;
168 G_OBJECT_CLASS (parent_class)->finalize (object);
172 _gdk_win32_adjust_client_rect (GdkWindow *window,
177 style = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
178 exstyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE);
179 API_CALL (AdjustWindowRectEx, (rect, style, FALSE, exstyle));
183 _gdk_root_window_size_init (void)
185 GdkWindowObject *window_object;
189 window_object = GDK_WINDOW_OBJECT (_gdk_root);
190 rect = _gdk_monitors[0].rect;
191 for (i = 1; i < _gdk_num_monitors; i++)
192 gdk_rectangle_union (&rect, &_gdk_monitors[i].rect, &rect);
194 window_object->width = rect.width;
195 window_object->height = rect.height;
199 _gdk_windowing_window_init (GdkScreen *screen)
201 GdkWindowObject *private;
202 GdkDrawableImplWin32 *draw_impl;
204 g_assert (_gdk_root == NULL);
206 _gdk_root = g_object_new (GDK_TYPE_WINDOW, NULL);
207 private = (GdkWindowObject *)_gdk_root;
208 private->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_WIN32, NULL);
209 private->impl_window = private;
210 private->visual = gdk_screen_get_system_visual (screen);
212 draw_impl = GDK_DRAWABLE_IMPL_WIN32 (private->impl);
214 draw_impl->handle = GetDesktopWindow ();
215 draw_impl->wrapper = GDK_DRAWABLE (private);
217 private->window_type = GDK_WINDOW_ROOT;
218 private->depth = gdk_visual_get_system ()->depth;
220 _gdk_root_window_size_init ();
226 /* width and height already initialised in _gdk_root_window_size_init() */
227 private->viewable = TRUE;
229 gdk_win32_handle_table_insert ((HANDLE *) &draw_impl->handle, _gdk_root);
231 GDK_NOTE (MISC, g_print ("_gdk_root=%p\n", GDK_WINDOW_HWND (_gdk_root)));
235 get_default_title (void)
238 title = g_get_application_name ();
240 title = g_get_prgname ();
246 * is a wrapper function for RegisterWindowClassEx.
247 * It creates at least one unique class for every
248 * GdkWindowType. If support for single window-specific icons
249 * is ever needed (e.g Dialog specific), every such window should
253 RegisterGdkClass (GdkWindowType wtype, GdkWindowTypeHint wtype_hint)
255 static ATOM klassTOPLEVEL = 0;
256 static ATOM klassCHILD = 0;
257 static ATOM klassTEMP = 0;
258 static ATOM klassTEMPSHADOW = 0;
259 static HICON hAppIcon = NULL;
260 static HICON hAppIconSm = NULL;
261 static WNDCLASSEXW wcl;
264 wcl.cbSize = sizeof (WNDCLASSEX);
265 wcl.style = 0; /* DON'T set CS_<H,V>REDRAW. It causes total redraw
266 * on WM_SIZE and WM_MOVE. Flicker, Performance!
268 wcl.lpfnWndProc = _gdk_win32_window_procedure;
271 wcl.hInstance = _gdk_app_hmodule;
275 /* initialize once! */
276 if (0 == hAppIcon && 0 == hAppIconSm)
278 gchar sLoc [MAX_PATH+1];
280 if (0 != GetModuleFileName (_gdk_app_hmodule, sLoc, MAX_PATH))
282 ExtractIconEx (sLoc, 0, &hAppIcon, &hAppIconSm, 1);
284 if (0 == hAppIcon && 0 == hAppIconSm)
286 if (0 != GetModuleFileName (_gdk_dll_hinstance, sLoc, MAX_PATH))
288 ExtractIconEx (sLoc, 0, &hAppIcon, &hAppIconSm, 1);
293 if (0 == hAppIcon && 0 == hAppIconSm)
295 hAppIcon = LoadImage (NULL, IDI_APPLICATION, IMAGE_ICON,
296 GetSystemMetrics (SM_CXICON),
297 GetSystemMetrics (SM_CYICON), 0);
298 hAppIconSm = LoadImage (NULL, IDI_APPLICATION, IMAGE_ICON,
299 GetSystemMetrics (SM_CXSMICON),
300 GetSystemMetrics (SM_CYSMICON), 0);
305 hAppIcon = hAppIconSm;
306 else if (0 == hAppIconSm)
307 hAppIconSm = hAppIcon;
309 wcl.lpszMenuName = NULL;
311 /* initialize once per class */
313 * HB: Setting the background brush leads to flicker, because we
314 * don't get asked how to clear the background. This is not what
315 * we want, at least not for input_only windows ...
317 #define ONCE_PER_CLASS() \
318 wcl.hIcon = CopyIcon (hAppIcon); \
319 wcl.hIconSm = CopyIcon (hAppIconSm); \
320 wcl.hbrBackground = NULL; \
321 wcl.hCursor = LoadCursor (NULL, IDC_ARROW);
325 case GDK_WINDOW_TOPLEVEL:
326 if (0 == klassTOPLEVEL)
328 wcl.lpszClassName = L"gdkWindowToplevel";
331 klassTOPLEVEL = RegisterClassExW (&wcl);
333 klass = klassTOPLEVEL;
336 case GDK_WINDOW_CHILD:
339 wcl.lpszClassName = L"gdkWindowChild";
341 wcl.style |= CS_PARENTDC; /* MSDN: ... enhances system performance. */
343 klassCHILD = RegisterClassExW (&wcl);
348 case GDK_WINDOW_TEMP:
349 if ((wtype_hint == GDK_WINDOW_TYPE_HINT_MENU) ||
350 (wtype_hint == GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU) ||
351 (wtype_hint == GDK_WINDOW_TYPE_HINT_POPUP_MENU) ||
352 (wtype_hint == GDK_WINDOW_TYPE_HINT_TOOLTIP))
354 if (klassTEMPSHADOW == 0)
356 wcl.lpszClassName = L"gdkWindowTempShadow";
357 wcl.style |= CS_SAVEBITS;
358 if (LOBYTE (g_win32_get_windows_version()) > 0x05 ||
359 LOWORD (g_win32_get_windows_version()) == 0x0105)
361 /* Windows XP (5.1) or above */
362 wcl.style |= 0x00020000; /* CS_DROPSHADOW */
365 klassTEMPSHADOW = RegisterClassExW (&wcl);
368 klass = klassTEMPSHADOW;
374 wcl.lpszClassName = L"gdkWindowTemp";
375 wcl.style |= CS_SAVEBITS;
377 klassTEMP = RegisterClassExW (&wcl);
385 g_assert_not_reached ();
391 WIN32_API_FAILED ("RegisterClassExW");
392 g_error ("That is a fatal error");
398 _gdk_window_impl_new (GdkWindow *window,
399 GdkWindow *real_parent,
401 GdkEventMask event_mask,
402 GdkWindowAttr *attributes,
403 gint attributes_mask)
408 DWORD dwStyle = 0, dwExStyle;
410 GdkWindow *orig_parent;
411 GdkWindowObject *private;
412 GdkWindowImplWin32 *impl;
413 GdkDrawableImplWin32 *draw_impl;
416 gint window_width, window_height;
417 gint offset_x = 0, offset_y = 0;
419 private = (GdkWindowObject *)window;
421 orig_parent = real_parent;
424 g_print ("_gdk_window_impl_new: %s\n",
425 (attributes->window_type == GDK_WINDOW_TOPLEVEL ? "TOPLEVEL" :
426 (attributes->window_type == GDK_WINDOW_CHILD ? "CHILD" :
427 (attributes->window_type == GDK_WINDOW_TEMP ? "TEMP" :
430 hparent = GDK_WINDOW_HWND (real_parent);
432 impl = g_object_new (GDK_TYPE_WINDOW_IMPL_WIN32, NULL);
433 private->impl = (GdkDrawable *)impl;
434 draw_impl = GDK_DRAWABLE_IMPL_WIN32 (impl);
435 draw_impl->wrapper = GDK_DRAWABLE (window);
437 // XXX: xattributes_mask = 0
440 if (attributes_mask & GDK_WA_VISUAL)
441 visual = attributes->visual;
443 visual = gdk_visual_get_system ();
447 impl->width = (attributes->width > 1) ? (attributes->width) : (1);
448 impl->height = (attributes->height > 1) ? (attributes->height) : (1);
450 impl->extension_events_selected = FALSE;
453 if (attributes->wclass == GDK_INPUT_OUTPUT)
457 private->input_only = FALSE;
461 /* I very much doubt using WS_EX_TRANSPARENT actually
462 * corresponds to how X11 InputOnly windows work, but it appears
463 * to work well enough for the actual use cases in gtk.
465 dwExStyle = WS_EX_TRANSPARENT;
467 private->input_only = TRUE;
468 GDK_NOTE (MISC, g_print ("... GDK_INPUT_ONLY\n"));
471 switch (private->window_type)
473 case GDK_WINDOW_TOPLEVEL:
474 if (GDK_WINDOW_TYPE (private->parent) != GDK_WINDOW_ROOT)
476 /* The common code warns for this case. */
477 hparent = GetDesktopWindow ();
479 /* Children of foreign windows aren't toplevel windows */
480 if (GDK_WINDOW_TYPE (orig_parent) == GDK_WINDOW_FOREIGN)
482 dwStyle = WS_CHILDWINDOW | WS_CLIPCHILDREN;
486 if (private->window_type == GDK_WINDOW_TOPLEVEL)
487 dwStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN;
489 dwStyle = WS_OVERLAPPED | WS_MINIMIZEBOX | WS_SYSMENU | WS_CAPTION | WS_THICKFRAME | WS_CLIPCHILDREN;
491 offset_x = _gdk_offset_x;
492 offset_y = _gdk_offset_y;
496 case GDK_WINDOW_CHILD:
497 dwStyle = WS_CHILDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
500 case GDK_WINDOW_TEMP:
501 /* A temp window is not necessarily a top level window */
502 dwStyle = (_gdk_root == real_parent ? WS_POPUP : WS_CHILDWINDOW);
503 dwStyle |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
504 dwExStyle |= WS_EX_TOOLWINDOW;
505 offset_x = _gdk_offset_x;
506 offset_y = _gdk_offset_y;
510 g_assert_not_reached ();
513 if (private->window_type != GDK_WINDOW_CHILD)
515 rect.left = rect.top = 0;
516 rect.right = private->width;
517 rect.bottom = private->height;
519 AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle);
521 window_width = rect.right - rect.left;
522 window_height = rect.bottom - rect.top;
526 window_width = private->width;
527 window_height = private->height;
530 if (attributes_mask & GDK_WA_TITLE)
531 title = attributes->title;
533 title = get_default_title ();
534 if (!title || !*title)
537 private->event_mask = GDK_STRUCTURE_MASK | attributes->event_mask;
539 if (attributes_mask & GDK_WA_TYPE_HINT)
540 impl->type_hint = attributes->type_hint;
542 impl->type_hint = GDK_WINDOW_TYPE_HINT_NORMAL;
544 if (impl->type_hint == GDK_WINDOW_TYPE_HINT_UTILITY)
545 dwExStyle |= WS_EX_TOOLWINDOW;
548 private->parent->children = g_list_prepend (private->parent->children, window);
550 klass = RegisterGdkClass (private->window_type, impl->type_hint);
552 wtitle = g_utf8_to_utf16 (title, -1, NULL, NULL, NULL);
554 hwndNew = CreateWindowExW (dwExStyle,
555 MAKEINTRESOURCEW (klass),
558 ((attributes_mask & GDK_WA_X) ?
559 private->x - offset_x : CW_USEDEFAULT),
560 private->y - offset_y,
561 window_width, window_height,
566 if (GDK_WINDOW_HWND (window) != hwndNew)
568 g_warning ("gdk_window_new: gdk_event_translate::WM_CREATE (%p, %p) HWND mismatch.",
569 GDK_WINDOW_HWND (window),
572 /* HB: IHMO due to a race condition the handle was increased by
573 * one, which causes much trouble. Because I can't find the
574 * real bug, try to workaround it ...
575 * To reproduce: compile with MSVC 5, DEBUG=1
578 gdk_win32_handle_table_remove (GDK_WINDOW_HWND (window));
579 GDK_WINDOW_HWND (window) = hwndNew;
580 gdk_win32_handle_table_insert (&GDK_WINDOW_HWND (window), window);
582 /* the old behaviour, but with warning */
583 draw_impl->handle = hwndNew;
588 g_object_ref (window);
589 gdk_win32_handle_table_insert (&GDK_WINDOW_HWND (window), window);
591 GDK_NOTE (MISC, g_print ("... \"%s\" %dx%d@%+d%+d %p = %p\n",
593 window_width, window_height,
594 ((attributes_mask & GDK_WA_X) ?
595 private->x - offset_x: CW_USEDEFAULT),
596 private->y - offset_y,
598 GDK_WINDOW_HWND (window)));
600 /* Add window handle to title */
601 GDK_NOTE (MISC_OR_EVENTS, gdk_window_set_title (window, title));
605 if (draw_impl->handle == NULL)
607 WIN32_API_FAILED ("CreateWindowExW");
608 g_object_unref (window);
612 // if (!from_set_skip_taskbar_hint && private->window_type == GDK_WINDOW_TEMP)
613 // gdk_window_set_skip_taskbar_hint (window, TRUE);
615 gdk_window_set_cursor (window, ((attributes_mask & GDK_WA_CURSOR) ?
616 (attributes->cursor) :
621 gdk_window_foreign_new_for_display (GdkDisplay *display,
622 GdkNativeWindow anid)
625 GdkWindowObject *private;
626 GdkWindowImplWin32 *impl;
627 GdkDrawableImplWin32 *draw_impl;
633 g_return_val_if_fail (display == _gdk_display, NULL);
635 window = g_object_new (GDK_TYPE_WINDOW, NULL);
636 private = (GdkWindowObject *)window;
637 private->visual = gdk_screen_get_system_visual (_gdk_screen);
638 private->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_WIN32, NULL);
639 impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
640 draw_impl = GDK_DRAWABLE_IMPL_WIN32 (private->impl);
641 draw_impl->wrapper = GDK_DRAWABLE (window);
642 parent = GetParent ((HWND)anid);
644 private->parent = gdk_win32_handle_table_lookup ((GdkNativeWindow) parent);
645 if (!private->parent || GDK_WINDOW_TYPE (private->parent) == GDK_WINDOW_FOREIGN)
646 private->parent = (GdkWindowObject *)_gdk_root;
648 private->parent->children = g_list_prepend (private->parent->children, window);
650 draw_impl->handle = (HWND) anid;
651 GetClientRect ((HWND) anid, &rect);
653 point.y = rect.right;
654 ClientToScreen ((HWND) anid, &point);
655 if (parent != GetDesktopWindow ())
656 ScreenToClient (parent, &point);
657 private->x = point.x;
658 private->y = point.y;
659 private->width = rect.right - rect.left;
660 private->height = rect.bottom - rect.top;
661 private->window_type = GDK_WINDOW_FOREIGN;
662 private->destroyed = FALSE;
663 private->event_mask = GDK_ALL_EVENTS_MASK; /* XXX */
664 if (IsWindowVisible ((HWND) anid))
665 private->state &= (~GDK_WINDOW_STATE_WITHDRAWN);
667 private->state |= GDK_WINDOW_STATE_WITHDRAWN;
668 if (GetWindowLong ((HWND)anid, GWL_EXSTYLE) & WS_EX_TOPMOST)
669 private->state |= GDK_WINDOW_STATE_ABOVE;
671 private->state &= (~GDK_WINDOW_STATE_ABOVE);
672 private->state &= (~GDK_WINDOW_STATE_BELOW);
673 private->viewable = TRUE;
675 private->depth = gdk_visual_get_system ()->depth;
677 g_object_ref (window);
678 gdk_win32_handle_table_insert (&GDK_WINDOW_HWND (window), window);
680 GDK_NOTE (MISC, g_print ("gdk_window_foreign_new_for_display: %p: %s@%+d%+d\n",
682 _gdk_win32_drawable_description (window),
683 private->x, private->y));
689 gdk_window_lookup (GdkNativeWindow hwnd)
691 return (GdkWindow*) gdk_win32_handle_table_lookup (hwnd);
695 _gdk_win32_window_destroy (GdkWindow *window,
697 gboolean foreign_destroy)
699 GdkWindowObject *private = (GdkWindowObject *)window;
700 GdkWindowImplWin32 *window_impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
703 g_return_if_fail (GDK_IS_WINDOW (window));
705 GDK_NOTE (MISC, g_print ("_gdk_win32_window_destroy: %p\n",
706 GDK_WINDOW_HWND (window)));
708 /* Remove ourself from the modal stack */
709 _gdk_remove_modal_window (window);
711 /* Remove all our transient children */
712 tmp = window_impl->transient_children;
715 GdkWindow *child = tmp->data;
716 GdkWindowImplWin32 *child_impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (child)->impl);
718 child_impl->transient_owner = NULL;
719 tmp = g_slist_next (tmp);
721 g_slist_free (window_impl->transient_children);
722 window_impl->transient_children = NULL;
724 /* Remove ourself from our transient owner */
725 if (window_impl->transient_owner != NULL)
727 gdk_window_set_transient_for (window, NULL);
730 if (!recursing && !foreign_destroy)
732 _gdk_win32_drawable_finish (private->impl);
734 private->destroyed = TRUE;
735 DestroyWindow (GDK_WINDOW_HWND (window));
738 gdk_win32_handle_table_remove (GDK_WINDOW_HWND (window));
741 static cairo_surface_t *
742 gdk_win32_window_resize_cairo_surface (GdkDrawable *drawable,
743 cairo_surface_t *surface,
747 /* XXX: Make Cairo surface use DC clip */
748 cairo_surface_destroy (surface);
754 _gdk_windowing_window_destroy_foreign (GdkWindow *window)
756 /* It's somebody else's window, but in our hierarchy, so reparent it
757 * to the desktop, and then try to destroy it.
759 gdk_window_hide (window);
760 gdk_window_reparent (window, NULL, 0, 0);
762 PostMessage (GDK_WINDOW_HWND (window), WM_CLOSE, 0, 0);
765 /* This function is called when the window really gone.
768 gdk_window_destroy_notify (GdkWindow *window)
770 g_return_if_fail (GDK_IS_WINDOW (window));
773 g_print ("gdk_window_destroy_notify: %p%s\n",
774 GDK_WINDOW_HWND (window),
775 (GDK_WINDOW_DESTROYED (window) ? " (destroyed)" : "")));
777 if (!GDK_WINDOW_DESTROYED (window))
779 if (GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN)
780 g_warning ("window %p unexpectedly destroyed",
781 GDK_WINDOW_HWND (window));
783 _gdk_window_destroy (window, TRUE);
786 gdk_win32_handle_table_remove (GDK_WINDOW_HWND (window));
787 g_object_unref (window);
791 get_outer_rect (GdkWindow *window,
796 rect->left = rect->top = 0;
798 rect->bottom = height;
800 _gdk_win32_adjust_client_rect (window, rect);
804 adjust_for_gravity_hints (GdkWindow *window,
809 GdkWindowObject *obj;
810 GdkWindowImplWin32 *impl;
812 obj = GDK_WINDOW_OBJECT (window);
813 impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
815 if (impl->hint_flags & GDK_HINT_WIN_GRAVITY)
817 gint orig_x = *x, orig_y = *y;
819 switch (impl->hints.win_gravity)
821 case GDK_GRAVITY_NORTH:
822 case GDK_GRAVITY_CENTER:
823 case GDK_GRAVITY_SOUTH:
824 *x -= (outer_rect->right - outer_rect->left) / 2;
825 *x += obj->width / 2;
828 case GDK_GRAVITY_SOUTH_EAST:
829 case GDK_GRAVITY_EAST:
830 case GDK_GRAVITY_NORTH_EAST:
831 *x -= outer_rect->right - outer_rect->left;
835 case GDK_GRAVITY_STATIC:
836 *x += outer_rect->left;
843 switch (impl->hints.win_gravity)
845 case GDK_GRAVITY_WEST:
846 case GDK_GRAVITY_CENTER:
847 case GDK_GRAVITY_EAST:
848 *y -= (outer_rect->bottom - outer_rect->top) / 2;
849 *y += obj->height / 2;
852 case GDK_GRAVITY_SOUTH_WEST:
853 case GDK_GRAVITY_SOUTH:
854 case GDK_GRAVITY_SOUTH_EAST:
855 *y -= outer_rect->bottom - outer_rect->top;
859 case GDK_GRAVITY_STATIC:
860 *y += outer_rect->top;
867 (orig_x != *x || orig_y != *y) ?
868 g_print ("adjust_for_gravity_hints: x: %d->%d, y: %d->%d\n",
869 orig_x, *x, orig_y, *y)
875 show_window_internal (GdkWindow *window,
879 GdkWindowObject *private;
880 HWND old_active_window;
881 gboolean focus_on_map = TRUE;
885 private = (GdkWindowObject *) window;
887 if (private->destroyed)
890 GDK_NOTE (MISC, g_print ("show_window_internal: %p: %s%s%s\n",
891 GDK_WINDOW_HWND (window),
892 _gdk_win32_window_state_to_string (private->state),
893 (raise ? " raise" : ""),
894 (deiconify ? " deiconify" : "")));
896 /* If asked to show (not deiconify) an withdrawn and iconified
900 !GDK_WINDOW_IS_MAPPED (window) &&
901 (private->state & GDK_WINDOW_STATE_ICONIFIED))
903 ShowWindow (GDK_WINDOW_HWND (window), SW_MINIMIZE);
907 /* If asked to just show an iconified window, do nothing. */
908 if (!deiconify && (private->state & GDK_WINDOW_STATE_ICONIFIED))
911 /* If asked to deiconify an already noniconified window, do
912 * nothing. (Especially, don't cause the window to rise and
913 * activate. There are different calls for that.)
915 if (deiconify && !(private->state & GDK_WINDOW_STATE_ICONIFIED))
918 /* If asked to show (but not raise) a window that is already
919 * visible, do nothing.
921 if (!deiconify && !raise && IsWindowVisible (GDK_WINDOW_HWND (window)))
926 if (!GDK_WINDOW_IS_MAPPED (window))
928 gdk_synthesize_window_state (window,
929 GDK_WINDOW_STATE_WITHDRAWN,
931 focus_on_map = private->focus_on_map;
934 exstyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE);
936 if (private->state & GDK_WINDOW_STATE_BELOW)
937 exstyle &= (~WS_EX_TOPMOST);
939 if (private->state & GDK_WINDOW_STATE_ABOVE)
940 exstyle |= WS_EX_TOPMOST;
942 if (exstyle & WS_EX_TOPMOST)
947 /* Use SetWindowPos to show transparent windows so automatic redraws
948 * in other windows can be suppressed.
950 if (exstyle & WS_EX_TRANSPARENT)
952 UINT flags = SWP_SHOWWINDOW | SWP_NOREDRAW | SWP_NOMOVE | SWP_NOSIZE;
955 flags |= SWP_NOZORDER;
956 if (!raise || GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP || !focus_on_map)
957 flags |= SWP_NOACTIVATE;
959 SetWindowPos (GDK_WINDOW_HWND (window), top, 0, 0, 0, 0, flags);
964 old_active_window = GetActiveWindow ();
966 if (private->state & GDK_WINDOW_STATE_FULLSCREEN)
968 gdk_window_fullscreen (window);
970 else if (private->state & GDK_WINDOW_STATE_MAXIMIZED)
972 ShowWindow (GDK_WINDOW_HWND (window), SW_MAXIMIZE);
974 else if (private->state & GDK_WINDOW_STATE_ICONIFIED)
976 ShowWindow (GDK_WINDOW_HWND (window), SW_RESTORE);
978 else if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP || !focus_on_map)
980 ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWNOACTIVATE);
984 ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWNORMAL);
989 if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP)
990 SetWindowPos (GDK_WINDOW_HWND (window), HWND_TOPMOST,
992 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
993 else if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TOPLEVEL)
995 if (focus_on_map && private->accept_focus)
997 SetForegroundWindow (GDK_WINDOW_HWND (window));
998 if (top == HWND_TOPMOST)
999 SetWindowPos (GDK_WINDOW_HWND (window), top,
1001 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
1005 SetWindowPos (GDK_WINDOW_HWND (window), top,
1007 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
1012 BringWindowToTop (GDK_WINDOW_HWND (window));
1015 else if (old_active_window != GDK_WINDOW_HWND (window))
1017 SetActiveWindow (old_active_window);
1022 gdk_win32_window_show (GdkWindow *window,
1023 gboolean already_mapped)
1025 show_window_internal (window, FALSE, FALSE);
1029 gdk_win32_window_hide (GdkWindow *window)
1031 GdkWindowObject *private;
1033 private = (GdkWindowObject*) window;
1034 if (private->destroyed)
1037 GDK_NOTE (MISC, g_print ("gdk_win32_window_hide: %p: %s\n",
1038 GDK_WINDOW_HWND (window),
1039 _gdk_win32_window_state_to_string (private->state)));
1041 if (GDK_WINDOW_IS_MAPPED (window))
1042 gdk_synthesize_window_state (window,
1044 GDK_WINDOW_STATE_WITHDRAWN);
1046 _gdk_window_clear_update_area (window);
1048 if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TOPLEVEL)
1049 ShowOwnedPopups (GDK_WINDOW_HWND (window), FALSE);
1051 if (GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE) & WS_EX_TRANSPARENT)
1053 SetWindowPos (GDK_WINDOW_HWND (window), HWND_BOTTOM,
1055 SWP_HIDEWINDOW | SWP_NOREDRAW | SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE);
1059 ShowWindow (GDK_WINDOW_HWND (window), SW_HIDE);
1064 gdk_win32_window_withdraw (GdkWindow *window)
1066 GdkWindowObject *private;
1068 private = (GdkWindowObject*) window;
1069 if (private->destroyed)
1072 GDK_NOTE (MISC, g_print ("gdk_win32_window_withdraw: %p: %s\n",
1073 GDK_WINDOW_HWND (window),
1074 _gdk_win32_window_state_to_string (private->state)));
1076 gdk_window_hide (window); /* ??? */
1080 gdk_win32_window_move (GdkWindow *window,
1083 GdkWindowObject *private = (GdkWindowObject *)window;
1084 GdkWindowImplWin32 *impl;
1086 g_return_if_fail (GDK_IS_WINDOW (window));
1088 if (GDK_WINDOW_DESTROYED (window))
1091 GDK_NOTE (MISC, g_print ("gdk_win32_window_move: %p: %+d%+d\n",
1092 GDK_WINDOW_HWND (window), x, y));
1094 impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
1096 if (private->state & GDK_WINDOW_STATE_FULLSCREEN)
1099 /* Don't check GDK_WINDOW_TYPE (private) == GDK_WINDOW_CHILD.
1100 * Foreign windows (another app's windows) might be children of our
1101 * windows! Especially in the case of gtkplug/socket.
1103 if (GetAncestor (GDK_WINDOW_HWND (window), GA_PARENT) != GetDesktopWindow ())
1105 _gdk_window_move_resize_child (window, x, y, private->width, private->height);
1111 get_outer_rect (window, private->width, private->height, &outer_rect);
1113 adjust_for_gravity_hints (window, &outer_rect, &x, &y);
1115 GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,%d,%d,0,0,"
1116 "NOACTIVATE|NOSIZE|NOZORDER)\n",
1117 GDK_WINDOW_HWND (window),
1118 x - _gdk_offset_x, y - _gdk_offset_y));
1120 API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), NULL,
1121 x - _gdk_offset_x, y - _gdk_offset_y, 0, 0,
1122 SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER));
1127 gdk_win32_window_resize (GdkWindow *window,
1128 gint width, gint height)
1130 GdkWindowObject *private = (GdkWindowObject*) window;
1131 GdkWindowImplWin32 *impl;
1133 g_return_if_fail (GDK_IS_WINDOW (window));
1135 if (GDK_WINDOW_DESTROYED (window))
1143 GDK_NOTE (MISC, g_print ("gdk_win32_window_resize: %p: %dx%d\n",
1144 GDK_WINDOW_HWND (window), width, height));
1146 impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
1148 if (private->state & GDK_WINDOW_STATE_FULLSCREEN)
1151 if (GetAncestor (GDK_WINDOW_HWND (window), GA_PARENT) != GetDesktopWindow ())
1153 _gdk_window_move_resize_child (window, private->x, private->y, width, height);
1159 get_outer_rect (window, width, height, &outer_rect);
1161 GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,0,0,%ld,%ld,"
1162 "NOACTIVATE|NOMOVE|NOZORDER)\n",
1163 GDK_WINDOW_HWND (window),
1164 outer_rect.right - outer_rect.left,
1165 outer_rect.bottom - outer_rect.top));
1167 API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), NULL,
1169 outer_rect.right - outer_rect.left,
1170 outer_rect.bottom - outer_rect.top,
1171 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER));
1172 private->resize_count += 1;
1177 gdk_win32_window_move_resize_internal (GdkWindow *window,
1183 GdkWindowObject *private;
1184 GdkWindowImplWin32 *impl;
1186 g_return_if_fail (GDK_IS_WINDOW (window));
1188 if (GDK_WINDOW_DESTROYED (window))
1196 private = GDK_WINDOW_OBJECT (window);
1197 impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
1199 if (private->state & GDK_WINDOW_STATE_FULLSCREEN)
1202 GDK_NOTE (MISC, g_print ("gdk_win32_window_move_resize: %p: %dx%d@%+d%+d\n",
1203 GDK_WINDOW_HWND (window),
1204 width, height, x, y));
1206 if (GetAncestor (GDK_WINDOW_HWND (window), GA_PARENT) != GetDesktopWindow ())
1208 _gdk_window_move_resize_child (window, x, y, width, height);
1214 get_outer_rect (window, width, height, &outer_rect);
1216 adjust_for_gravity_hints (window, &outer_rect, &x, &y);
1218 GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,%d,%d,%ld,%ld,"
1219 "NOACTIVATE|NOZORDER)\n",
1220 GDK_WINDOW_HWND (window),
1221 x - _gdk_offset_x, y - _gdk_offset_y,
1222 outer_rect.right - outer_rect.left,
1223 outer_rect.bottom - outer_rect.top));
1225 API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), NULL,
1226 x - _gdk_offset_x, y - _gdk_offset_y,
1227 outer_rect.right - outer_rect.left,
1228 outer_rect.bottom - outer_rect.top,
1229 SWP_NOACTIVATE | SWP_NOZORDER));
1234 gdk_win32_window_move_resize (GdkWindow *window,
1241 if (with_move && (width < 0 && height < 0))
1243 gdk_win32_window_move (window, x, y);
1249 gdk_win32_window_move_resize_internal (window, x, y, width, height);
1253 gdk_win32_window_resize (window, width, height);
1259 gdk_win32_window_reparent (GdkWindow *window,
1260 GdkWindow *new_parent,
1264 GdkWindowObject *window_private;
1265 GdkWindowObject *parent_private;
1266 GdkWindowObject *old_parent_private;
1267 GdkWindowImplWin32 *impl;
1268 gboolean was_toplevel;
1272 new_parent = _gdk_root;
1274 window_private = (GdkWindowObject*) window;
1275 old_parent_private = (GdkWindowObject *) window_private->parent;
1276 parent_private = (GdkWindowObject*) new_parent;
1277 impl = GDK_WINDOW_IMPL_WIN32 (window_private->impl);
1279 GDK_NOTE (MISC, g_print ("gdk_win32_window_reparent: %p: %p\n",
1280 GDK_WINDOW_HWND (window),
1281 GDK_WINDOW_HWND (new_parent)));
1283 style = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
1285 was_toplevel = GetAncestor (GDK_WINDOW_HWND (window), GA_PARENT) == GetDesktopWindow ();
1286 if (was_toplevel && new_parent != _gdk_root)
1288 /* Reparenting from top-level (child of desktop). Clear out
1291 style &= ~(WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
1293 SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE, style);
1295 else if (new_parent == _gdk_root)
1297 /* Reparenting to top-level. Add decorations. */
1298 style &= ~(WS_CHILD);
1299 style |= WS_OVERLAPPEDWINDOW;
1300 SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE, style);
1303 API_CALL (SetParent, (GDK_WINDOW_HWND (window),
1304 GDK_WINDOW_HWND (new_parent)));
1306 API_CALL (MoveWindow, (GDK_WINDOW_HWND (window),
1307 x, y, window_private->width, window_private->height, TRUE));
1309 /* From here on, we treat parents of type GDK_WINDOW_FOREIGN like
1312 if (GDK_WINDOW_TYPE (new_parent) == GDK_WINDOW_FOREIGN)
1313 new_parent = _gdk_root;
1315 window_private->parent = (GdkWindowObject *)new_parent;
1317 /* Switch the window type as appropriate */
1319 switch (GDK_WINDOW_TYPE (new_parent))
1321 case GDK_WINDOW_ROOT:
1322 if (impl->toplevel_window_type != -1)
1323 GDK_WINDOW_TYPE (window) = impl->toplevel_window_type;
1324 else if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD)
1325 GDK_WINDOW_TYPE (window) = GDK_WINDOW_TOPLEVEL;
1328 case GDK_WINDOW_TOPLEVEL:
1329 case GDK_WINDOW_CHILD:
1330 case GDK_WINDOW_TEMP:
1331 if (WINDOW_IS_TOPLEVEL (window))
1333 /* Save the original window type so we can restore it if the
1334 * window is reparented back to be a toplevel.
1336 impl->toplevel_window_type = GDK_WINDOW_TYPE (window);
1337 GDK_WINDOW_TYPE (window) = GDK_WINDOW_CHILD;
1341 if (old_parent_private)
1342 old_parent_private->children =
1343 g_list_remove (old_parent_private->children, window);
1345 parent_private->children = g_list_prepend (parent_private->children, window);
1351 gdk_win32_window_raise (GdkWindow *window)
1353 if (!GDK_WINDOW_DESTROYED (window))
1355 GDK_NOTE (MISC, g_print ("gdk_win32_window_raise: %p\n",
1356 GDK_WINDOW_HWND (window)));
1358 if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP)
1359 API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), HWND_TOPMOST,
1361 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE));
1362 else if (((GdkWindowObject *)window)->accept_focus)
1363 API_CALL (BringWindowToTop, (GDK_WINDOW_HWND (window)));
1365 API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), HWND_TOP,
1367 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE));
1372 gdk_win32_window_lower (GdkWindow *window)
1374 if (!GDK_WINDOW_DESTROYED (window))
1376 GDK_NOTE (MISC, g_print ("gdk_win32_window_lower: %p\n"
1377 "... SetWindowPos(%p,HWND_BOTTOM,0,0,0,0,"
1378 "NOACTIVATE|NOMOVE|NOSIZE)\n",
1379 GDK_WINDOW_HWND (window),
1380 GDK_WINDOW_HWND (window)));
1382 API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), HWND_BOTTOM,
1384 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE));
1389 gdk_window_set_urgency_hint (GdkWindow *window,
1392 FLASHWINFO flashwinfo;
1393 typedef BOOL (*PFN_FlashWindowEx) (FLASHWINFO*);
1394 PFN_FlashWindowEx flashWindowEx = NULL;
1396 g_return_if_fail (GDK_IS_WINDOW (window));
1397 g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD);
1399 if (GDK_WINDOW_DESTROYED (window))
1402 flashWindowEx = (PFN_FlashWindowEx) GetProcAddress (GetModuleHandle ("user32.dll"), "FlashWindowEx");
1406 flashwinfo.cbSize = sizeof (flashwinfo);
1407 flashwinfo.hwnd = GDK_WINDOW_HWND (window);
1409 flashwinfo.dwFlags = FLASHW_ALL | FLASHW_TIMER;
1411 flashwinfo.dwFlags = FLASHW_STOP;
1412 flashwinfo.uCount = 0;
1413 flashwinfo.dwTimeout = 0;
1415 flashWindowEx (&flashwinfo);
1419 FlashWindow (GDK_WINDOW_HWND (window), urgent);
1424 get_effective_window_decorations (GdkWindow *window,
1425 GdkWMDecoration *decoration)
1427 GdkWindowImplWin32 *impl;
1429 impl = (GdkWindowImplWin32 *)((GdkWindowObject *)window)->impl;
1431 if (gdk_window_get_decorations (window, decoration))
1434 if (((GdkWindowObject *) window)->window_type != GDK_WINDOW_TOPLEVEL)
1439 if ((impl->hint_flags & GDK_HINT_MIN_SIZE) &&
1440 (impl->hint_flags & GDK_HINT_MAX_SIZE) &&
1441 impl->hints.min_width == impl->hints.max_width &&
1442 impl->hints.min_height == impl->hints.max_height)
1444 *decoration = GDK_DECOR_ALL | GDK_DECOR_RESIZEH | GDK_DECOR_MAXIMIZE;
1446 if (impl->type_hint == GDK_WINDOW_TYPE_HINT_DIALOG ||
1447 impl->type_hint == GDK_WINDOW_TYPE_HINT_MENU ||
1448 impl->type_hint == GDK_WINDOW_TYPE_HINT_TOOLBAR)
1450 *decoration |= GDK_DECOR_MINIMIZE;
1452 else if (impl->type_hint == GDK_WINDOW_TYPE_HINT_SPLASHSCREEN)
1454 *decoration |= GDK_DECOR_MENU | GDK_DECOR_MINIMIZE;
1459 else if (impl->hint_flags & GDK_HINT_MAX_SIZE)
1461 *decoration = GDK_DECOR_ALL | GDK_DECOR_MAXIMIZE;
1462 if (impl->type_hint == GDK_WINDOW_TYPE_HINT_DIALOG ||
1463 impl->type_hint == GDK_WINDOW_TYPE_HINT_MENU ||
1464 impl->type_hint == GDK_WINDOW_TYPE_HINT_TOOLBAR)
1466 *decoration |= GDK_DECOR_MINIMIZE;
1473 switch (impl->type_hint)
1475 case GDK_WINDOW_TYPE_HINT_DIALOG:
1476 *decoration = (GDK_DECOR_ALL | GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE);
1479 case GDK_WINDOW_TYPE_HINT_MENU:
1480 *decoration = (GDK_DECOR_ALL | GDK_DECOR_RESIZEH | GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE);
1483 case GDK_WINDOW_TYPE_HINT_TOOLBAR:
1484 case GDK_WINDOW_TYPE_HINT_UTILITY:
1485 gdk_window_set_skip_taskbar_hint (window, TRUE);
1486 gdk_window_set_skip_pager_hint (window, TRUE);
1487 *decoration = (GDK_DECOR_ALL | GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE);
1490 case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
1491 *decoration = (GDK_DECOR_ALL | GDK_DECOR_RESIZEH | GDK_DECOR_MENU |
1492 GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE);
1495 case GDK_WINDOW_TYPE_HINT_DOCK:
1498 case GDK_WINDOW_TYPE_HINT_DESKTOP:
1503 case GDK_WINDOW_TYPE_HINT_NORMAL:
1504 *decoration = GDK_DECOR_ALL;
1513 gdk_window_set_geometry_hints (GdkWindow *window,
1514 const GdkGeometry *geometry,
1515 GdkWindowHints geom_mask)
1517 GdkWindowImplWin32 *impl;
1519 g_return_if_fail (GDK_IS_WINDOW (window));
1521 if (GDK_WINDOW_DESTROYED (window))
1524 GDK_NOTE (MISC, g_print ("gdk_window_set_geometry_hints: %p\n",
1525 GDK_WINDOW_HWND (window)));
1527 impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
1529 impl->hint_flags = geom_mask;
1530 impl->hints = *geometry;
1532 if (geom_mask & GDK_HINT_POS)
1533 ; /* even the X11 mplementation doesn't care */
1535 if (geom_mask & GDK_HINT_MIN_SIZE)
1537 GDK_NOTE (MISC, g_print ("... MIN_SIZE: %dx%d\n",
1538 geometry->min_width, geometry->min_height));
1541 if (geom_mask & GDK_HINT_MAX_SIZE)
1543 GDK_NOTE (MISC, g_print ("... MAX_SIZE: %dx%d\n",
1544 geometry->max_width, geometry->max_height));
1547 if (geom_mask & GDK_HINT_BASE_SIZE)
1549 GDK_NOTE (MISC, g_print ("... BASE_SIZE: %dx%d\n",
1550 geometry->base_width, geometry->base_height));
1553 if (geom_mask & GDK_HINT_RESIZE_INC)
1555 GDK_NOTE (MISC, g_print ("... RESIZE_INC: (%d,%d)\n",
1556 geometry->width_inc, geometry->height_inc));
1559 if (geom_mask & GDK_HINT_ASPECT)
1561 GDK_NOTE (MISC, g_print ("... ASPECT: %g--%g\n",
1562 geometry->min_aspect, geometry->max_aspect));
1565 if (geom_mask & GDK_HINT_WIN_GRAVITY)
1567 GDK_NOTE (MISC, g_print ("... GRAVITY: %d\n", geometry->win_gravity));
1570 update_style_bits (window);
1574 gdk_window_set_title (GdkWindow *window,
1579 g_return_if_fail (GDK_IS_WINDOW (window));
1580 g_return_if_fail (title != NULL);
1582 if (GDK_WINDOW_DESTROYED (window))
1585 /* Empty window titles not allowed, so set it to just a period. */
1589 GDK_NOTE (MISC, g_print ("gdk_window_set_title: %p: %s\n",
1590 GDK_WINDOW_HWND (window), title));
1592 GDK_NOTE (MISC_OR_EVENTS, title = g_strdup_printf ("%p %s", GDK_WINDOW_HWND (window), title));
1594 wtitle = g_utf8_to_utf16 (title, -1, NULL, NULL, NULL);
1595 API_CALL (SetWindowTextW, (GDK_WINDOW_HWND (window), wtitle));
1598 GDK_NOTE (MISC_OR_EVENTS, g_free ((char *) title));
1602 gdk_window_set_role (GdkWindow *window,
1605 g_return_if_fail (GDK_IS_WINDOW (window));
1607 GDK_NOTE (MISC, g_print ("gdk_window_set_role: %p: %s\n",
1608 GDK_WINDOW_HWND (window),
1609 (role ? role : "NULL")));
1614 gdk_window_set_transient_for (GdkWindow *window,
1617 HWND window_id, parent_id;
1618 GdkWindowImplWin32 *window_impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
1619 GdkWindowImplWin32 *parent_impl = NULL;
1622 g_return_if_fail (GDK_IS_WINDOW (window));
1624 window_id = GDK_WINDOW_HWND (window);
1625 parent_id = parent != NULL ? GDK_WINDOW_HWND (parent) : NULL;
1627 GDK_NOTE (MISC, g_print ("gdk_window_set_transient_for: %p: %p\n", window_id, parent_id));
1629 if (GDK_WINDOW_DESTROYED (window) || (parent && GDK_WINDOW_DESTROYED (parent)))
1631 if (GDK_WINDOW_DESTROYED (window))
1632 GDK_NOTE (MISC, g_print ("... destroyed!\n"));
1634 GDK_NOTE (MISC, g_print ("... owner destroyed!\n"));
1639 if (((GdkWindowObject *) window)->window_type == GDK_WINDOW_CHILD)
1641 GDK_NOTE (MISC, g_print ("... a child window!\n"));
1647 GdkWindowImplWin32 *trans_impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window_impl->transient_owner)->impl);
1648 if (trans_impl->transient_children != NULL)
1650 item = g_slist_find (trans_impl->transient_children, window);
1652 trans_impl->transient_children = g_slist_delete_link (trans_impl->transient_children, item);
1653 trans_impl->num_transients--;
1655 if (!trans_impl->num_transients)
1657 trans_impl->transient_children = NULL;
1660 g_object_unref (G_OBJECT (window_impl->transient_owner));
1661 g_object_unref (G_OBJECT (window));
1663 window_impl->transient_owner = NULL;
1667 parent_impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (parent)->impl);
1669 parent_impl->transient_children = g_slist_append (parent_impl->transient_children, window);
1670 g_object_ref (G_OBJECT (window));
1671 parent_impl->num_transients++;
1672 window_impl->transient_owner = parent;
1673 g_object_ref (G_OBJECT (parent));
1676 /* This changes the *owner* of the window, despite the misleading
1677 * name. (Owner and parent are unrelated concepts.) At least that's
1678 * what people who seem to know what they talk about say on
1679 * USENET. Search on Google.
1682 if (SetWindowLongPtr (window_id, GWLP_HWNDPARENT, (LONG_PTR) parent_id) == 0 &&
1683 GetLastError () != 0)
1684 WIN32_API_FAILED ("SetWindowLongPtr");
1688 _gdk_push_modal_window (GdkWindow *window)
1690 modal_window_stack = g_slist_prepend (modal_window_stack,
1695 _gdk_remove_modal_window (GdkWindow *window)
1699 g_return_if_fail (window != NULL);
1701 /* It's possible to be NULL here if someone sets the modal hint of the window
1702 * to FALSE before a modal window stack has ever been created. */
1703 if (modal_window_stack == NULL)
1706 /* Find the requested window in the stack and remove it. Yeah, I realize this
1707 * means we're not a 'real stack', strictly speaking. Sue me. :) */
1708 tmp = g_slist_find (modal_window_stack, window);
1711 modal_window_stack = g_slist_delete_link (modal_window_stack, tmp);
1716 _gdk_modal_current (void)
1718 if (modal_window_stack != NULL)
1720 GSList *tmp = modal_window_stack;
1722 while (tmp != NULL && !GDK_WINDOW_IS_MAPPED (tmp->data))
1724 tmp = g_slist_next (tmp);
1727 return tmp != NULL ? tmp->data : NULL;
1736 gdk_win32_window_set_background (GdkWindow *window,
1737 cairo_pattern_t *pattern)
1742 gdk_win32_window_set_device_cursor (GdkWindow *window,
1746 GdkWindowImplWin32 *impl;
1747 GdkCursorPrivate *cursor_private;
1749 HCURSOR hprevcursor;
1751 impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
1752 cursor_private = (GdkCursorPrivate*) cursor;
1754 if (GDK_WINDOW_DESTROYED (window))
1760 hcursor = cursor_private->hcursor;
1762 GDK_NOTE (MISC, g_print ("gdk_win32_window_set_cursor: %p: %p\n",
1763 GDK_WINDOW_HWND (window),
1766 /* First get the old cursor, if any (we wait to free the old one
1767 * since it may be the current cursor set in the Win32 API right
1770 hprevcursor = impl->hcursor;
1772 GDK_DEVICE_GET_CLASS (device)->set_window_cursor (device, window, cursor);
1774 if (hcursor == NULL)
1775 impl->hcursor = NULL;
1778 /* We must copy the cursor as it is OK to destroy the GdkCursor
1779 * while still in use for some window. See for instance
1780 * gimp_change_win_cursor() which calls gdk_window_set_cursor
1781 * (win, cursor), and immediately afterwards gdk_cursor_destroy
1784 if ((impl->hcursor = CopyCursor (hcursor)) == NULL)
1785 WIN32_API_FAILED ("CopyCursor");
1786 GDK_NOTE (MISC, g_print ("... CopyCursor (%p) = %p\n",
1787 hcursor, impl->hcursor));
1790 /* Destroy the previous cursor */
1791 if (hprevcursor != NULL)
1793 GDK_NOTE (MISC, g_print ("... DestroyCursor (%p)\n", hprevcursor));
1794 API_CALL (DestroyCursor, (hprevcursor));
1799 gdk_win32_window_get_geometry (GdkWindow *window,
1809 if (!GDK_WINDOW_DESTROYED (window))
1813 API_CALL (GetClientRect, (GDK_WINDOW_HWND (window), &rect));
1815 if (window != _gdk_root)
1818 GdkWindow *parent = gdk_window_get_parent (window);
1822 ClientToScreen (GDK_WINDOW_HWND (window), &pt);
1823 ScreenToClient (GDK_WINDOW_HWND (parent), &pt);
1829 ClientToScreen (GDK_WINDOW_HWND (window), &pt);
1830 ScreenToClient (GDK_WINDOW_HWND (parent), &pt);
1834 if (parent == _gdk_root)
1836 rect.left += _gdk_offset_x;
1837 rect.top += _gdk_offset_y;
1838 rect.right += _gdk_offset_x;
1839 rect.bottom += _gdk_offset_y;
1848 *width = rect.right - rect.left;
1850 *height = rect.bottom - rect.top;
1852 *depth = gdk_window_get_visual (window)->depth;
1854 GDK_NOTE (MISC, g_print ("gdk_win32_window_get_geometry: %p: %ldx%ldx%d@%+ld%+ld\n",
1855 GDK_WINDOW_HWND (window),
1856 rect.right - rect.left, rect.bottom - rect.top,
1857 gdk_window_get_visual (window)->depth,
1858 rect.left, rect.top));
1863 gdk_win32_window_get_root_coords (GdkWindow *window,
1875 ClientToScreen (GDK_WINDOW_HWND (window), &pt);
1880 *root_x = tx + _gdk_offset_x;
1882 *root_y = ty + _gdk_offset_y;
1884 GDK_NOTE (MISC, g_print ("gdk_win32_window_get_root_coords: %p: %+d%+d %+d%+d\n",
1885 GDK_WINDOW_HWND (window),
1887 tx + _gdk_offset_x, ty + _gdk_offset_y));
1892 gdk_win32_window_restack_under (GdkWindow *window,
1893 GList *native_siblings)
1899 gdk_win32_window_restack_toplevel (GdkWindow *window,
1907 gdk_window_get_root_origin (GdkWindow *window,
1913 g_return_if_fail (GDK_IS_WINDOW (window));
1915 gdk_window_get_frame_extents (window, &rect);
1923 GDK_NOTE (MISC, g_print ("gdk_window_get_root_origin: %p: %+d%+d\n",
1924 GDK_WINDOW_HWND (window), rect.x, rect.y));
1928 gdk_window_get_frame_extents (GdkWindow *window,
1931 GdkWindowObject *private;
1935 g_return_if_fail (GDK_IS_WINDOW (window));
1936 g_return_if_fail (rect != NULL);
1938 private = GDK_WINDOW_OBJECT (window);
1945 if (GDK_WINDOW_DESTROYED (window))
1948 /* FIXME: window is documented to be a toplevel GdkWindow, so is it really
1949 * necessary to walk its parent chain?
1951 while (private->parent && ((GdkWindowObject*) private->parent)->parent)
1952 private = (GdkWindowObject*) private->parent;
1954 hwnd = GDK_WINDOW_HWND (window);
1955 API_CALL (GetWindowRect, (hwnd, &r));
1957 rect->x = r.left + _gdk_offset_x;
1958 rect->y = r.top + _gdk_offset_y;
1959 rect->width = r.right - r.left;
1960 rect->height = r.bottom - r.top;
1962 GDK_NOTE (MISC, g_print ("gdk_window_get_frame_extents: %p: %ldx%ld@%+ld%+ld\n",
1963 GDK_WINDOW_HWND (window),
1964 r.right - r.left, r.bottom - r.top,
1969 gdk_window_win32_get_device_state (GdkWindow *window,
1973 GdkModifierType *mask)
1977 g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), FALSE);
1979 GDK_DEVICE_GET_CLASS (device)->query_state (device, window,
1983 return (child != NULL);
1987 _gdk_windowing_get_device_state (GdkDisplay *display,
1992 GdkModifierType *mask)
1994 g_return_if_fail (display == _gdk_display);
1997 *screen = _gdk_screen;
1999 GDK_DEVICE_GET_CLASS (device)->query_state (device,
2000 gdk_screen_get_root_window (_gdk_screen),
2008 gdk_display_warp_pointer (GdkDisplay *display,
2013 GdkDeviceManagerWin32 *device_manager;
2015 g_return_if_fail (display == _gdk_display);
2016 g_return_if_fail (screen == _gdk_screen);
2018 device_manager = GDK_DEVICE_MANAGER_WIN32 (gdk_display_get_device_manager (display));
2019 GDK_DEVICE_GET_CLASS (device_manager->core_pointer)->warp (device_manager->core_pointer,
2024 gdk_display_warp_device (GdkDisplay *display,
2030 g_return_if_fail (display == _gdk_display);
2031 g_return_if_fail (screen == _gdk_screen);
2032 g_return_if_fail (GDK_IS_DEVICE (device));
2033 g_return_if_fail (display == gdk_device_get_display (device));
2035 GDK_DEVICE_GET_CLASS (device)->warp (device, screen, x, y);
2039 _gdk_windowing_window_at_device_position (GdkDisplay *display,
2043 GdkModifierType *mask,
2044 gboolean get_toplevel)
2046 return GDK_DEVICE_GET_CLASS (device)->window_at_position (device, win_x, win_y, mask, get_toplevel);
2050 gdk_win32_window_get_events (GdkWindow *window)
2052 if (GDK_WINDOW_DESTROYED (window))
2055 return GDK_WINDOW_OBJECT (window)->event_mask;
2059 gdk_win32_window_set_events (GdkWindow *window,
2060 GdkEventMask event_mask)
2062 /* gdk_window_new() always sets the GDK_STRUCTURE_MASK, so better
2063 * set it here, too. Not that I know or remember why it is
2064 * necessary, will have to test some day.
2066 GDK_WINDOW_OBJECT (window)->event_mask = GDK_STRUCTURE_MASK | event_mask;
2070 do_shape_combine_region (GdkWindow *window,
2076 GetClientRect (GDK_WINDOW_HWND (window), &rect);
2077 _gdk_win32_adjust_client_rect (window, &rect);
2079 OffsetRgn (hrgn, -rect.left, -rect.top);
2080 OffsetRgn (hrgn, x, y);
2082 /* If this is a top-level window, add the title bar to the region */
2083 if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TOPLEVEL)
2085 HRGN tmp = CreateRectRgn (0, 0, rect.right - rect.left, -rect.top);
2086 CombineRgn (hrgn, hrgn, tmp, RGN_OR);
2090 SetWindowRgn (GDK_WINDOW_HWND (window), hrgn, TRUE);
2094 gdk_window_set_override_redirect (GdkWindow *window,
2095 gboolean override_redirect)
2097 g_return_if_fail (GDK_IS_WINDOW (window));
2099 g_warning ("gdk_window_set_override_redirect not implemented");
2103 gdk_window_set_accept_focus (GdkWindow *window,
2104 gboolean accept_focus)
2106 GdkWindowObject *private;
2108 g_return_if_fail (GDK_IS_WINDOW (window));
2110 private = (GdkWindowObject *)window;
2112 accept_focus = accept_focus != FALSE;
2114 if (private->accept_focus != accept_focus)
2115 private->accept_focus = accept_focus;
2119 gdk_window_set_focus_on_map (GdkWindow *window,
2120 gboolean focus_on_map)
2122 GdkWindowObject *private;
2124 g_return_if_fail (GDK_IS_WINDOW (window));
2126 private = (GdkWindowObject *)window;
2128 focus_on_map = focus_on_map != FALSE;
2130 if (private->focus_on_map != focus_on_map)
2131 private->focus_on_map = focus_on_map;
2135 gdk_window_set_icon_list (GdkWindow *window,
2138 GdkPixbuf *pixbuf, *big_pixbuf, *small_pixbuf;
2139 gint big_diff, small_diff;
2140 gint big_w, big_h, small_w, small_h;
2143 HICON small_hicon, big_hicon;
2144 GdkWindowImplWin32 *impl;
2145 gint i, big_i, small_i;
2147 g_return_if_fail (GDK_IS_WINDOW (window));
2149 if (GDK_WINDOW_DESTROYED (window))
2152 impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
2154 /* ideal sizes for small and large icons */
2155 big_w = GetSystemMetrics (SM_CXICON);
2156 big_h = GetSystemMetrics (SM_CYICON);
2157 small_w = GetSystemMetrics (SM_CXSMICON);
2158 small_h = GetSystemMetrics (SM_CYSMICON);
2160 /* find closest sized icons in the list */
2162 small_pixbuf = NULL;
2168 pixbuf = (GdkPixbuf*) pixbufs->data;
2169 w = gdk_pixbuf_get_width (pixbuf);
2170 h = gdk_pixbuf_get_height (pixbuf);
2172 dw = ABS (w - big_w);
2173 dh = ABS (h - big_h);
2174 diff = dw*dw + dh*dh;
2175 if (big_pixbuf == NULL || diff < big_diff)
2177 big_pixbuf = pixbuf;
2182 dw = ABS (w - small_w);
2183 dh = ABS (h - small_h);
2184 diff = dw*dw + dh*dh;
2185 if (small_pixbuf == NULL || diff < small_diff)
2187 small_pixbuf = pixbuf;
2192 pixbufs = g_list_next (pixbufs);
2196 /* Create the icons */
2197 big_hicon = _gdk_win32_pixbuf_to_hicon (big_pixbuf);
2198 small_hicon = _gdk_win32_pixbuf_to_hicon (small_pixbuf);
2201 SendMessageW (GDK_WINDOW_HWND (window), WM_SETICON, ICON_BIG,
2203 SendMessageW (GDK_WINDOW_HWND (window), WM_SETICON, ICON_SMALL,
2204 (LPARAM)small_hicon);
2206 /* Store the icons, destroying any previous icons */
2207 if (impl->hicon_big)
2208 GDI_CALL (DestroyIcon, (impl->hicon_big));
2209 impl->hicon_big = big_hicon;
2210 if (impl->hicon_small)
2211 GDI_CALL (DestroyIcon, (impl->hicon_small));
2212 impl->hicon_small = small_hicon;
2216 gdk_window_set_icon_name (GdkWindow *window,
2219 /* In case I manage to confuse this again (or somebody else does):
2220 * Please note that "icon name" here really *does* mean the name or
2221 * title of an window minimized as an icon on the desktop, or in the
2222 * taskbar. It has nothing to do with the freedesktop.org icon
2226 g_return_if_fail (GDK_IS_WINDOW (window));
2228 if (GDK_WINDOW_DESTROYED (window))
2232 /* This is not the correct thing to do. We should keep both the
2233 * "normal" window title, and the icon name. When the window is
2234 * minimized, call SetWindowText() with the icon name, and when the
2235 * window is restored, with the normal window title. Also, the name
2236 * is in UTF-8, so we should do the normal conversion to either wide
2237 * chars or system codepage, and use either the W or A version of
2238 * SetWindowText(), depending on Windows version.
2240 API_CALL (SetWindowText, (GDK_WINDOW_HWND (window), name));
2245 gdk_window_get_group (GdkWindow *window)
2247 g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
2248 g_return_val_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD, NULL);
2250 if (GDK_WINDOW_DESTROYED (window))
2253 g_warning ("gdk_window_get_group not yet implemented");
2259 gdk_window_set_group (GdkWindow *window,
2262 g_return_if_fail (GDK_IS_WINDOW (window));
2263 g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD);
2264 g_return_if_fail (leader == NULL || GDK_IS_WINDOW (leader));
2266 if (GDK_WINDOW_DESTROYED (window) || GDK_WINDOW_DESTROYED (leader))
2269 g_warning ("gdk_window_set_group not implemented");
2273 update_single_bit (LONG *style,
2278 /* all controls the interpretation of gdk_bit -- if all is TRUE,
2279 * gdk_bit indicates whether style_bit is off; if all is FALSE, gdk
2280 * bit indicate whether style_bit is on
2282 if ((!all && gdk_bit) || (all && !gdk_bit))
2283 *style |= style_bit;
2285 *style &= ~style_bit;
2289 update_style_bits (GdkWindow *window)
2291 GdkWindowObject *private = (GdkWindowObject *)window;
2292 GdkWindowImplWin32 *impl = (GdkWindowImplWin32 *)private->impl;
2293 GdkWMDecoration decorations;
2294 LONG old_style, new_style, old_exstyle, new_exstyle;
2296 RECT rect, before, after;
2298 old_style = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
2299 old_exstyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE);
2301 GetClientRect (GDK_WINDOW_HWND (window), &before);
2303 AdjustWindowRectEx (&before, old_style, FALSE, old_exstyle);
2305 new_style = old_style;
2306 new_exstyle = old_exstyle;
2308 if (private->window_type == GDK_WINDOW_TEMP ||
2309 impl->type_hint == GDK_WINDOW_TYPE_HINT_UTILITY)
2310 new_exstyle |= WS_EX_TOOLWINDOW;
2312 new_exstyle &= ~WS_EX_TOOLWINDOW;
2314 if (get_effective_window_decorations (window, &decorations))
2316 all = (decorations & GDK_DECOR_ALL);
2317 update_single_bit (&new_style, all, decorations & GDK_DECOR_BORDER, WS_BORDER);
2318 update_single_bit (&new_style, all, decorations & GDK_DECOR_RESIZEH, WS_THICKFRAME);
2319 update_single_bit (&new_style, all, decorations & GDK_DECOR_TITLE, WS_CAPTION);
2320 update_single_bit (&new_style, all, decorations & GDK_DECOR_MENU, WS_SYSMENU);
2321 update_single_bit (&new_style, all, decorations & GDK_DECOR_MINIMIZE, WS_MINIMIZEBOX);
2322 update_single_bit (&new_style, all, decorations & GDK_DECOR_MAXIMIZE, WS_MAXIMIZEBOX);
2325 if (old_style == new_style && old_exstyle == new_exstyle )
2327 GDK_NOTE (MISC, g_print ("update_style_bits: %p: no change\n",
2328 GDK_WINDOW_HWND (window)));
2332 if (old_style != new_style)
2334 GDK_NOTE (MISC, g_print ("update_style_bits: %p: STYLE: %s => %s\n",
2335 GDK_WINDOW_HWND (window),
2336 _gdk_win32_window_style_to_string (old_style),
2337 _gdk_win32_window_style_to_string (new_style)));
2339 SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE, new_style);
2342 if (old_exstyle != new_exstyle)
2344 GDK_NOTE (MISC, g_print ("update_style_bits: %p: EXSTYLE: %s => %s\n",
2345 GDK_WINDOW_HWND (window),
2346 _gdk_win32_window_exstyle_to_string (old_exstyle),
2347 _gdk_win32_window_exstyle_to_string (new_exstyle)));
2349 SetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE, new_exstyle);
2352 AdjustWindowRectEx (&after, new_style, FALSE, new_exstyle);
2354 GetWindowRect (GDK_WINDOW_HWND (window), &rect);
2355 rect.left += after.left - before.left;
2356 rect.top += after.top - before.top;
2357 rect.right += after.right - before.right;
2358 rect.bottom += after.bottom - before.bottom;
2360 SetWindowPos (GDK_WINDOW_HWND (window), NULL,
2361 rect.left, rect.top,
2362 rect.right - rect.left, rect.bottom - rect.top,
2363 SWP_FRAMECHANGED | SWP_NOACTIVATE |
2364 SWP_NOREPOSITION | SWP_NOZORDER);
2369 update_single_system_menu_entry (HMENU hmenu,
2374 /* all controls the interpretation of gdk_bit -- if all is TRUE,
2375 * gdk_bit indicates whether menu entry is disabled; if all is
2376 * FALSE, gdk bit indicate whether menu entry is enabled
2378 if ((!all && gdk_bit) || (all && !gdk_bit))
2379 EnableMenuItem (hmenu, menu_entry, MF_BYCOMMAND | MF_ENABLED);
2381 EnableMenuItem (hmenu, menu_entry, MF_BYCOMMAND | MF_GRAYED);
2385 update_system_menu (GdkWindow *window)
2387 GdkWMFunction functions;
2390 if (_gdk_window_get_functions (window, &functions))
2392 HMENU hmenu = GetSystemMenu (GDK_WINDOW_HWND (window), FALSE);
2394 all = (functions & GDK_FUNC_ALL);
2395 update_single_system_menu_entry (hmenu, all, functions & GDK_FUNC_RESIZE, SC_SIZE);
2396 update_single_system_menu_entry (hmenu, all, functions & GDK_FUNC_MOVE, SC_MOVE);
2397 update_single_system_menu_entry (hmenu, all, functions & GDK_FUNC_MINIMIZE, SC_MINIMIZE);
2398 update_single_system_menu_entry (hmenu, all, functions & GDK_FUNC_MAXIMIZE, SC_MAXIMIZE);
2399 update_single_system_menu_entry (hmenu, all, functions & GDK_FUNC_CLOSE, SC_CLOSE);
2404 get_decorations_quark ()
2406 static GQuark quark = 0;
2409 quark = g_quark_from_static_string ("gdk-window-decorations");
2415 gdk_window_set_decorations (GdkWindow *window,
2416 GdkWMDecoration decorations)
2418 GdkWMDecoration* decorations_copy;
2420 g_return_if_fail (GDK_IS_WINDOW (window));
2422 GDK_NOTE (MISC, g_print ("gdk_window_set_decorations: %p: %s %s%s%s%s%s%s\n",
2423 GDK_WINDOW_HWND (window),
2424 (decorations & GDK_DECOR_ALL ? "clearing" : "setting"),
2425 (decorations & GDK_DECOR_BORDER ? "BORDER " : ""),
2426 (decorations & GDK_DECOR_RESIZEH ? "RESIZEH " : ""),
2427 (decorations & GDK_DECOR_TITLE ? "TITLE " : ""),
2428 (decorations & GDK_DECOR_MENU ? "MENU " : ""),
2429 (decorations & GDK_DECOR_MINIMIZE ? "MINIMIZE " : ""),
2430 (decorations & GDK_DECOR_MAXIMIZE ? "MAXIMIZE " : "")));
2432 decorations_copy = g_malloc (sizeof (GdkWMDecoration));
2433 *decorations_copy = decorations;
2434 g_object_set_qdata_full (G_OBJECT (window), get_decorations_quark (), decorations_copy, g_free);
2436 update_style_bits (window);
2440 gdk_window_get_decorations (GdkWindow *window,
2441 GdkWMDecoration *decorations)
2443 GdkWMDecoration* decorations_set;
2445 g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
2447 decorations_set = g_object_get_qdata (G_OBJECT (window), get_decorations_quark ());
2448 if (decorations_set)
2449 *decorations = *decorations_set;
2451 return (decorations_set != NULL);
2455 get_functions_quark ()
2457 static GQuark quark = 0;
2460 quark = g_quark_from_static_string ("gdk-window-functions");
2466 gdk_window_set_functions (GdkWindow *window,
2467 GdkWMFunction functions)
2469 GdkWMFunction* functions_copy;
2471 g_return_if_fail (GDK_IS_WINDOW (window));
2473 GDK_NOTE (MISC, g_print ("gdk_window_set_functions: %p: %s %s%s%s%s%s\n",
2474 GDK_WINDOW_HWND (window),
2475 (functions & GDK_FUNC_ALL ? "clearing" : "setting"),
2476 (functions & GDK_FUNC_RESIZE ? "RESIZE " : ""),
2477 (functions & GDK_FUNC_MOVE ? "MOVE " : ""),
2478 (functions & GDK_FUNC_MINIMIZE ? "MINIMIZE " : ""),
2479 (functions & GDK_FUNC_MAXIMIZE ? "MAXIMIZE " : ""),
2480 (functions & GDK_FUNC_CLOSE ? "CLOSE " : "")));
2482 functions_copy = g_malloc (sizeof (GdkWMFunction));
2483 *functions_copy = functions;
2484 g_object_set_qdata_full (G_OBJECT (window), get_functions_quark (), functions_copy, g_free);
2486 update_system_menu (window);
2490 _gdk_window_get_functions (GdkWindow *window,
2491 GdkWMFunction *functions)
2493 GdkWMDecoration* functions_set;
2495 functions_set = g_object_get_qdata (G_OBJECT (window), get_functions_quark ());
2497 *functions = *functions_set;
2499 return (functions_set != NULL);
2503 gdk_win32_window_set_static_gravities (GdkWindow *window,
2504 gboolean use_static)
2506 g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
2512 gdk_window_begin_resize_drag (GdkWindow *window,
2521 g_return_if_fail (GDK_IS_WINDOW (window));
2523 if (GDK_WINDOW_DESTROYED (window))
2526 /* Tell Windows to start interactively resizing the window by pretending that
2527 * the left pointer button was clicked in the suitable edge or corner. This
2528 * will only work if the button is down when this function is called, and
2529 * will only work with button 1 (left), since Windows only allows window
2530 * dragging using the left mouse button.
2535 /* Must break the automatic grab that occured when the button was
2536 * pressed, otherwise it won't work.
2538 gdk_display_pointer_ungrab (_gdk_display, 0);
2542 case GDK_WINDOW_EDGE_NORTH_WEST:
2543 winedge = HTTOPLEFT;
2546 case GDK_WINDOW_EDGE_NORTH:
2550 case GDK_WINDOW_EDGE_NORTH_EAST:
2551 winedge = HTTOPRIGHT;
2554 case GDK_WINDOW_EDGE_WEST:
2558 case GDK_WINDOW_EDGE_EAST:
2562 case GDK_WINDOW_EDGE_SOUTH_WEST:
2563 winedge = HTBOTTOMLEFT;
2566 case GDK_WINDOW_EDGE_SOUTH:
2570 case GDK_WINDOW_EDGE_SOUTH_EAST:
2572 winedge = HTBOTTOMRIGHT;
2576 DefWindowProcW (GDK_WINDOW_HWND (window), WM_NCLBUTTONDOWN, winedge,
2577 MAKELPARAM (root_x - _gdk_offset_x, root_y - _gdk_offset_y));
2581 gdk_window_begin_move_drag (GdkWindow *window,
2587 g_return_if_fail (GDK_IS_WINDOW (window));
2589 if (GDK_WINDOW_DESTROYED (window))
2592 /* Tell Windows to start interactively moving the window by pretending that
2593 * the left pointer button was clicked in the titlebar. This will only work
2594 * if the button is down when this function is called, and will only work
2595 * with button 1 (left), since Windows only allows window dragging using the
2596 * left mouse button.
2601 /* Must break the automatic grab that occured when the button was pressed,
2602 * otherwise it won't work.
2604 gdk_display_pointer_ungrab (_gdk_display, 0);
2606 DefWindowProcW (GDK_WINDOW_HWND (window), WM_NCLBUTTONDOWN, HTCAPTION,
2607 MAKELPARAM (root_x - _gdk_offset_x, root_y - _gdk_offset_y));
2612 * Setting window states
2615 gdk_window_iconify (GdkWindow *window)
2617 HWND old_active_window;
2619 g_return_if_fail (GDK_IS_WINDOW (window));
2621 if (GDK_WINDOW_DESTROYED (window))
2624 GDK_NOTE (MISC, g_print ("gdk_window_iconify: %p: %s\n",
2625 GDK_WINDOW_HWND (window),
2626 _gdk_win32_window_state_to_string (((GdkWindowObject *) window)->state)));
2628 if (GDK_WINDOW_IS_MAPPED (window))
2630 old_active_window = GetActiveWindow ();
2631 ShowWindow (GDK_WINDOW_HWND (window), SW_MINIMIZE);
2632 if (old_active_window != GDK_WINDOW_HWND (window))
2633 SetActiveWindow (old_active_window);
2637 gdk_synthesize_window_state (window,
2639 GDK_WINDOW_STATE_ICONIFIED);
2644 gdk_window_deiconify (GdkWindow *window)
2646 g_return_if_fail (GDK_IS_WINDOW (window));
2648 if (GDK_WINDOW_DESTROYED (window))
2651 GDK_NOTE (MISC, g_print ("gdk_window_deiconify: %p: %s\n",
2652 GDK_WINDOW_HWND (window),
2653 _gdk_win32_window_state_to_string (((GdkWindowObject *) window)->state)));
2655 if (GDK_WINDOW_IS_MAPPED (window))
2657 show_window_internal (window, FALSE, TRUE);
2661 gdk_synthesize_window_state (window,
2662 GDK_WINDOW_STATE_ICONIFIED,
2668 gdk_window_stick (GdkWindow *window)
2670 g_return_if_fail (GDK_IS_WINDOW (window));
2672 if (GDK_WINDOW_DESTROYED (window))
2675 /* FIXME: Do something? */
2679 gdk_window_unstick (GdkWindow *window)
2681 g_return_if_fail (GDK_IS_WINDOW (window));
2683 if (GDK_WINDOW_DESTROYED (window))
2686 /* FIXME: Do something? */
2690 gdk_window_maximize (GdkWindow *window)
2692 g_return_if_fail (GDK_IS_WINDOW (window));
2694 if (GDK_WINDOW_DESTROYED (window))
2697 GDK_NOTE (MISC, g_print ("gdk_window_maximize: %p: %s\n",
2698 GDK_WINDOW_HWND (window),
2699 _gdk_win32_window_state_to_string (((GdkWindowObject *) window)->state)));
2701 if (GDK_WINDOW_IS_MAPPED (window))
2702 ShowWindow (GDK_WINDOW_HWND (window), SW_MAXIMIZE);
2704 gdk_synthesize_window_state (window,
2706 GDK_WINDOW_STATE_MAXIMIZED);
2710 gdk_window_unmaximize (GdkWindow *window)
2712 g_return_if_fail (GDK_IS_WINDOW (window));
2714 if (GDK_WINDOW_DESTROYED (window))
2717 GDK_NOTE (MISC, g_print ("gdk_window_unmaximize: %p: %s\n",
2718 GDK_WINDOW_HWND (window),
2719 _gdk_win32_window_state_to_string (((GdkWindowObject *) window)->state)));
2721 if (GDK_WINDOW_IS_MAPPED (window))
2722 ShowWindow (GDK_WINDOW_HWND (window), SW_RESTORE);
2724 gdk_synthesize_window_state (window,
2725 GDK_WINDOW_STATE_MAXIMIZED,
2729 typedef struct _FullscreenInfo FullscreenInfo;
2731 struct _FullscreenInfo
2739 gdk_window_fullscreen (GdkWindow *window)
2741 gint x, y, width, height;
2743 GdkWindowObject *private = (GdkWindowObject *) window;
2747 g_return_if_fail (GDK_IS_WINDOW (window));
2749 fi = g_new (FullscreenInfo, 1);
2751 if (!GetWindowRect (GDK_WINDOW_HWND (window), &(fi->r)))
2755 GdkWindowImplWin32 *impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
2757 monitor = MonitorFromWindow (GDK_WINDOW_HWND (window), MONITOR_DEFAULTTONEAREST);
2758 mi.cbSize = sizeof (mi);
2759 if (monitor && GetMonitorInfo (monitor, &mi))
2761 x = mi.rcMonitor.left;
2762 y = mi.rcMonitor.top;
2763 width = mi.rcMonitor.right - x;
2764 height = mi.rcMonitor.bottom - y;
2769 width = GetSystemMetrics (SM_CXSCREEN);
2770 height = GetSystemMetrics (SM_CYSCREEN);
2773 /* remember for restoring */
2774 fi->hint_flags = impl->hint_flags;
2775 impl->hint_flags &= ~GDK_HINT_MAX_SIZE;
2776 g_object_set_data (G_OBJECT (window), "fullscreen-info", fi);
2777 fi->style = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
2779 SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE,
2780 (fi->style & ~WS_OVERLAPPEDWINDOW) | WS_POPUP);
2782 API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), HWND_TOP,
2783 x, y, width, height,
2784 SWP_NOCOPYBITS | SWP_SHOWWINDOW));
2786 gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FULLSCREEN);
2791 gdk_window_unfullscreen (GdkWindow *window)
2794 GdkWindowObject *private = (GdkWindowObject *) window;
2796 g_return_if_fail (GDK_IS_WINDOW (window));
2798 fi = g_object_get_data (G_OBJECT (window), "fullscreen-info");
2801 GdkWindowImplWin32 *impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
2803 impl->hint_flags = fi->hint_flags;
2804 SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE, fi->style);
2805 API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), HWND_NOTOPMOST,
2806 fi->r.left, fi->r.top,
2807 fi->r.right - fi->r.left, fi->r.bottom - fi->r.top,
2808 SWP_NOCOPYBITS | SWP_SHOWWINDOW));
2810 g_object_set_data (G_OBJECT (window), "fullscreen-info", NULL);
2813 gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FULLSCREEN, 0);
2818 gdk_window_set_keep_above (GdkWindow *window,
2821 g_return_if_fail (GDK_IS_WINDOW (window));
2823 if (GDK_WINDOW_DESTROYED (window))
2826 GDK_NOTE (MISC, g_print ("gdk_window_set_keep_above: %p: %s\n",
2827 GDK_WINDOW_HWND (window),
2828 setting ? "YES" : "NO"));
2830 if (GDK_WINDOW_IS_MAPPED (window))
2832 API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window),
2833 setting ? HWND_TOPMOST : HWND_NOTOPMOST,
2835 SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE));
2838 gdk_synthesize_window_state (window,
2839 setting ? GDK_WINDOW_STATE_BELOW : GDK_WINDOW_STATE_ABOVE,
2840 setting ? GDK_WINDOW_STATE_ABOVE : 0);
2844 gdk_window_set_keep_below (GdkWindow *window,
2847 g_return_if_fail (GDK_IS_WINDOW (window));
2849 if (GDK_WINDOW_DESTROYED (window))
2852 GDK_NOTE (MISC, g_print ("gdk_window_set_keep_below: %p: %s\n",
2853 GDK_WINDOW_HWND (window),
2854 setting ? "YES" : "NO"));
2856 if (GDK_WINDOW_IS_MAPPED (window))
2858 API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window),
2859 setting ? HWND_BOTTOM : HWND_NOTOPMOST,
2861 SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE));
2864 gdk_synthesize_window_state (window,
2865 setting ? GDK_WINDOW_STATE_ABOVE : GDK_WINDOW_STATE_BELOW,
2866 setting ? GDK_WINDOW_STATE_BELOW : 0);
2870 gdk_window_focus (GdkWindow *window,
2873 g_return_if_fail (GDK_IS_WINDOW (window));
2875 if (GDK_WINDOW_DESTROYED (window))
2878 GDK_NOTE (MISC, g_print ("gdk_window_focus: %p: %s\n",
2879 GDK_WINDOW_HWND (window),
2880 _gdk_win32_window_state_to_string (((GdkWindowObject *) window)->state)));
2882 if (((GdkWindowObject *) window)->state & GDK_WINDOW_STATE_MAXIMIZED)
2883 ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWMAXIMIZED);
2885 ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWNORMAL);
2886 SetFocus (GDK_WINDOW_HWND (window));
2890 gdk_window_set_modal_hint (GdkWindow *window,
2893 GdkWindowObject *private;
2895 g_return_if_fail (GDK_IS_WINDOW (window));
2897 if (GDK_WINDOW_DESTROYED (window))
2900 GDK_NOTE (MISC, g_print ("gdk_window_set_modal_hint: %p: %s\n",
2901 GDK_WINDOW_HWND (window),
2902 modal ? "YES" : "NO"));
2904 private = (GdkWindowObject*) window;
2906 if (modal == private->modal_hint)
2909 private->modal_hint = modal;
2912 /* Not sure about this one.. -- Cody */
2913 if (GDK_WINDOW_IS_MAPPED (window))
2914 API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window),
2915 modal ? HWND_TOPMOST : HWND_NOTOPMOST,
2917 SWP_NOMOVE | SWP_NOSIZE));
2922 _gdk_push_modal_window (window);
2923 gdk_window_raise (window);
2927 _gdk_remove_modal_window (window);
2934 gdk_window_set_skip_taskbar_hint (GdkWindow *window,
2935 gboolean skips_taskbar)
2937 static GdkWindow *owner = NULL;
2940 g_return_if_fail (GDK_IS_WINDOW (window));
2942 GDK_NOTE (MISC, g_print ("gdk_window_set_skip_taskbar_hint: %p: %s, doing nothing\n",
2943 GDK_WINDOW_HWND (window),
2944 skips_taskbar ? "YES" : "NO"));
2946 // ### TODO: Need to figure out what to do here.
2954 wa.window_type = GDK_WINDOW_TEMP;
2955 wa.wclass = GDK_INPUT_OUTPUT;
2956 wa.width = wa.height = 1;
2958 owner = gdk_window_new_internal (NULL, &wa, 0, TRUE);
2962 SetWindowLongPtr (GDK_WINDOW_HWND (window), GWLP_HWNDPARENT, (LONG_PTR) GDK_WINDOW_HWND (owner));
2964 #if 0 /* Should we also turn off the minimize and maximize buttons? */
2965 SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE,
2966 GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE) & ~(WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_SYSMENU));
2968 SetWindowPos (GDK_WINDOW_HWND (window), NULL,
2970 SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE |
2971 SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER);
2976 SetWindowLongPtr (GDK_WINDOW_HWND (window), GWLP_HWNDPARENT, 0);
2981 gdk_window_set_skip_pager_hint (GdkWindow *window,
2982 gboolean skips_pager)
2984 g_return_if_fail (GDK_IS_WINDOW (window));
2986 GDK_NOTE (MISC, g_print ("gdk_window_set_skip_pager_hint: %p: %s, doing nothing\n",
2987 GDK_WINDOW_HWND (window),
2988 skips_pager ? "YES" : "NO"));
2992 gdk_window_set_type_hint (GdkWindow *window,
2993 GdkWindowTypeHint hint)
2995 g_return_if_fail (GDK_IS_WINDOW (window));
2997 if (GDK_WINDOW_DESTROYED (window))
3002 static GEnumClass *class = NULL;
3004 class = g_type_class_ref (GDK_TYPE_WINDOW_TYPE_HINT);
3005 g_print ("gdk_window_set_type_hint: %p: %s\n",
3006 GDK_WINDOW_HWND (window),
3007 g_enum_get_value (class, hint)->value_name);
3010 ((GdkWindowImplWin32 *)((GdkWindowObject *)window)->impl)->type_hint = hint;
3012 update_style_bits (window);
3016 gdk_window_get_type_hint (GdkWindow *window)
3018 g_return_val_if_fail (GDK_IS_WINDOW (window), GDK_WINDOW_TYPE_HINT_NORMAL);
3020 if (GDK_WINDOW_DESTROYED (window))
3021 return GDK_WINDOW_TYPE_HINT_NORMAL;
3023 return GDK_WINDOW_IMPL_WIN32 (((GdkWindowObject *) window)->impl)->type_hint;
3027 cairo_region_to_hrgn (const cairo_region_t *region,
3034 cairo_rectangle_int_t r;
3035 const int nrects = cairo_region_num_rectangles (region);
3037 sizeof (RGNDATAHEADER) + (sizeof (RECT) * nrects);
3040 rgndata = g_malloc (nbytes);
3041 rgndata->rdh.dwSize = sizeof (RGNDATAHEADER);
3042 rgndata->rdh.iType = RDH_RECTANGLES;
3043 rgndata->rdh.nCount = rgndata->rdh.nRgnSize = 0;
3044 SetRect (&rgndata->rdh.rcBound,
3045 G_MAXLONG, G_MAXLONG, G_MINLONG, G_MINLONG);
3047 for (i = 0; i < nrects; i++)
3049 rect = ((RECT *) rgndata->Buffer) + rgndata->rdh.nCount++;
3051 cairo_region_get_rectangle (region, i, &r);
3052 rect->left = r.x + x_origin;
3053 rect->right = rect->left + r.width;
3054 rect->top = r.y + y_origin;
3055 rect->bottom = rect->top + r.height;
3057 if (rect->left < rgndata->rdh.rcBound.left)
3058 rgndata->rdh.rcBound.left = rect->left;
3059 if (rect->right > rgndata->rdh.rcBound.right)
3060 rgndata->rdh.rcBound.right = rect->right;
3061 if (rect->top < rgndata->rdh.rcBound.top)
3062 rgndata->rdh.rcBound.top = rect->top;
3063 if (rect->bottom > rgndata->rdh.rcBound.bottom)
3064 rgndata->rdh.rcBound.bottom = rect->bottom;
3066 if ((hrgn = ExtCreateRegion (NULL, nbytes, rgndata)) == NULL)
3067 WIN32_API_FAILED ("ExtCreateRegion");
3075 gdk_win32_window_shape_combine_region (GdkWindow *window,
3076 const cairo_region_t *shape_region,
3080 if (GDK_WINDOW_DESTROYED (window))
3085 GDK_NOTE (MISC, g_print ("gdk_win32_window_shape_combine_region: %p: none\n",
3086 GDK_WINDOW_HWND (window)));
3087 SetWindowRgn (GDK_WINDOW_HWND (window), NULL, TRUE);
3093 hrgn = cairo_region_to_hrgn (shape_region, 0, 0);
3095 GDK_NOTE (MISC, g_print ("gdk_win32_window_shape_combine_region: %p: %p\n",
3096 GDK_WINDOW_HWND (window),
3099 do_shape_combine_region (window, hrgn, offset_x, offset_y);
3104 gdk_window_lookup_for_display (GdkDisplay *display,
3105 GdkNativeWindow anid)
3107 g_return_val_if_fail (display == _gdk_display, NULL);
3109 return gdk_window_lookup (anid);
3113 gdk_window_enable_synchronized_configure (GdkWindow *window)
3115 g_return_if_fail (GDK_IS_WINDOW (window));
3119 gdk_window_configure_finished (GdkWindow *window)
3121 g_return_if_fail (GDK_IS_WINDOW (window));
3125 _gdk_windowing_window_beep (GdkWindow *window)
3127 gdk_display_beep (_gdk_display);
3131 gdk_window_set_opacity (GdkWindow *window,
3135 typedef BOOL (*PFN_SetLayeredWindowAttributes) (HWND, COLORREF, BYTE, DWORD);
3136 PFN_SetLayeredWindowAttributes setLayeredWindowAttributes = NULL;
3138 g_return_if_fail (GDK_IS_WINDOW (window));
3139 g_return_if_fail (WINDOW_IS_TOPLEVEL (window));
3141 if (GDK_WINDOW_DESTROYED (window))
3146 else if (opacity > 1)
3149 exstyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE);
3151 if (!(exstyle & WS_EX_LAYERED))
3152 API_CALL (SetWindowLong, (GDK_WINDOW_HWND (window),
3154 exstyle | WS_EX_LAYERED));
3156 setLayeredWindowAttributes =
3157 (PFN_SetLayeredWindowAttributes)GetProcAddress (GetModuleHandle ("user32.dll"), "SetLayeredWindowAttributes");
3159 if (setLayeredWindowAttributes)
3161 API_CALL (setLayeredWindowAttributes, (GDK_WINDOW_HWND (window),
3169 _gdk_windowing_window_set_composited (GdkWindow *window, gboolean composited)
3174 _gdk_windowing_window_get_shape (GdkWindow *window)
3176 HRGN hrgn = CreateRectRgn (0, 0, 0, 0);
3177 int type = GetWindowRgn (GDK_WINDOW_HWND (window), hrgn);
3179 if (type == SIMPLEREGION || type == COMPLEXREGION)
3181 cairo_region_t *region = _gdk_win32_hrgn_to_region (hrgn);
3183 DeleteObject (hrgn);
3191 _gdk_windowing_window_get_input_shape (GdkWindow *window)
3193 /* CHECK: are these really supposed to be the same? */
3194 return _gdk_windowing_window_get_shape (window);
3198 _gdk_win32_window_queue_antiexpose (GdkWindow *window,
3199 cairo_region_t *area)
3201 HRGN hrgn = cairo_region_to_hrgn (area, 0, 0);
3203 GDK_NOTE (EVENTS, g_print ("_gdk_windowing_window_queue_antiexpose: ValidateRgn %p %s\n",
3204 GDK_WINDOW_HWND (window),
3205 _gdk_win32_cairo_region_to_string (area)));
3207 ValidateRgn (GDK_WINDOW_HWND (window), hrgn);
3209 DeleteObject (hrgn);
3214 /* FIXME: Tis function has never been compiled.
3215 * Please make it work. */
3217 _gdk_win32_window_translate (GdkWindow *window,
3218 cairo_region_t *area,
3222 HRGN hrgn = CreateRectRgn (0, 0, 0, 0);
3225 GdkRectangle extents;
3227 cairo_region_get_extents (area, &extents);
3228 hdc = _gdk_win32_drawable_acquire_dc (GDK_DRAWABLE (window));
3229 GDI_CALL (BitBlt, (hdc, extents.x, extents.y, extents.width, extents.height,
3230 hdc, extents.x + dx, extents.y + dy, SRCCOPY));
3232 /* XXX: We probably need to get invalidations for the whole extents and not
3233 * just the area as we BitBlt */
3234 ret = GetUpdateRgn (GDK_WINDOW_HWND (window), hrgn, FALSE);
3236 WIN32_API_FAILED ("GetUpdateRgn");
3237 else if (ret != NULLREGION)
3239 /* Get current updateregion, move any part of it that intersects area by dx,dy */
3240 HRGN update = cairo_region_to_hrgn (area, 0, 0);
3241 ret = CombineRgn (update, hrgn, update, RGN_AND);
3243 WIN32_API_FAILED ("CombineRgn");
3244 else if (ret != NULLREGION)
3246 OffsetRgn (update, dx, dy);
3247 API_CALL (InvalidateRgn, (GDK_WINDOW_HWND (window), update, TRUE));
3249 DeleteObject (update);
3251 DeleteObject (hrgn);
3255 gdk_win32_input_shape_combine_region (GdkWindow *window,
3256 const cairo_region_t *shape_region,
3260 if (GDK_WINDOW_DESTROYED (window))
3262 /* CHECK: are these really supposed to be the same? */
3263 gdk_win32_window_shape_combine_region (window, shape_region, offset_x, offset_y);
3267 _gdk_windowing_window_process_updates_recurse (GdkWindow *window,
3268 cairo_region_t *region)
3270 _gdk_window_process_updates_recurse (window, region);
3274 _gdk_windowing_before_process_all_updates (void)
3279 _gdk_windowing_after_process_all_updates (void)
3284 gdk_window_impl_iface_init (GdkWindowImplIface *iface)
3286 iface->show = gdk_win32_window_show;
3287 iface->hide = gdk_win32_window_hide;
3288 iface->withdraw = gdk_win32_window_withdraw;
3289 iface->set_events = gdk_win32_window_set_events;
3290 iface->get_events = gdk_win32_window_get_events;
3291 iface->raise = gdk_win32_window_raise;
3292 iface->lower = gdk_win32_window_lower;
3293 iface->restack_under = gdk_win32_window_restack_under;
3294 iface->restack_toplevel = gdk_win32_window_restack_toplevel;
3295 iface->move_resize = gdk_win32_window_move_resize;
3296 iface->set_background = gdk_win32_window_set_background;
3297 iface->reparent = gdk_win32_window_reparent;
3298 iface->set_device_cursor = gdk_win32_window_set_device_cursor;
3299 iface->get_geometry = gdk_win32_window_get_geometry;
3300 iface->get_device_state = gdk_window_win32_get_device_state;
3301 iface->get_root_coords = gdk_win32_window_get_root_coords;
3302 iface->shape_combine_region = gdk_win32_window_shape_combine_region;
3303 iface->input_shape_combine_region = gdk_win32_input_shape_combine_region;
3304 iface->set_static_gravities = gdk_win32_window_set_static_gravities;
3305 iface->queue_antiexpose = _gdk_win32_window_queue_antiexpose;
3306 iface->translate = _gdk_win32_window_translate;
3307 iface->destroy = _gdk_win32_window_destroy;
3308 iface->resize_cairo_surface = gdk_win32_window_resize_cairo_surface;
3312 gdk_win32_window_is_win32 (GdkWindow *window)
3314 return GDK_WINDOW_IS_WIN32 (window);