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_get_type (void)
105 return _gdk_window_impl_win32_get_type ();
109 gdk_window_impl_win32_init (GdkWindowImplWin32 *impl)
111 impl->toplevel_window_type = -1;
112 impl->hcursor = NULL;
113 impl->hicon_big = NULL;
114 impl->hicon_small = NULL;
115 impl->hint_flags = 0;
116 impl->type_hint = GDK_WINDOW_TYPE_HINT_NORMAL;
117 impl->extension_events_selected = FALSE;
118 impl->transient_owner = NULL;
119 impl->transient_children = NULL;
120 impl->num_transients = 0;
121 impl->changing_state = FALSE;
125 gdk_window_impl_win32_class_init (GdkWindowImplWin32Class *klass)
127 GObjectClass *object_class = G_OBJECT_CLASS (klass);
129 parent_class = g_type_class_peek_parent (klass);
131 object_class->finalize = gdk_window_impl_win32_finalize;
135 gdk_window_impl_win32_finalize (GObject *object)
137 GdkWindowObject *wrapper;
138 GdkDrawableImplWin32 *draw_impl;
139 GdkWindowImplWin32 *window_impl;
141 g_return_if_fail (GDK_IS_WINDOW_IMPL_WIN32 (object));
143 draw_impl = GDK_DRAWABLE_IMPL_WIN32 (object);
144 window_impl = GDK_WINDOW_IMPL_WIN32 (object);
146 wrapper = (GdkWindowObject*) draw_impl->wrapper;
148 if (!GDK_WINDOW_DESTROYED (wrapper))
150 gdk_win32_handle_table_remove (draw_impl->handle);
153 if (window_impl->hcursor != NULL)
155 if (GetCursor () == window_impl->hcursor)
158 GDI_CALL (DestroyCursor, (window_impl->hcursor));
159 window_impl->hcursor = NULL;
162 if (window_impl->hicon_big != NULL)
164 GDI_CALL (DestroyIcon, (window_impl->hicon_big));
165 window_impl->hicon_big = NULL;
168 if (window_impl->hicon_small != NULL)
170 GDI_CALL (DestroyIcon, (window_impl->hicon_small));
171 window_impl->hicon_small = NULL;
174 G_OBJECT_CLASS (parent_class)->finalize (object);
178 _gdk_win32_adjust_client_rect (GdkWindow *window,
183 style = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
184 exstyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE);
185 API_CALL (AdjustWindowRectEx, (rect, style, FALSE, exstyle));
189 _gdk_root_window_size_init (void)
191 GdkWindowObject *window_object;
195 window_object = GDK_WINDOW_OBJECT (_gdk_root);
196 rect = _gdk_monitors[0].rect;
197 for (i = 1; i < _gdk_num_monitors; i++)
198 gdk_rectangle_union (&rect, &_gdk_monitors[i].rect, &rect);
200 window_object->width = rect.width;
201 window_object->height = rect.height;
205 _gdk_windowing_window_init (GdkScreen *screen)
207 GdkWindowObject *private;
208 GdkDrawableImplWin32 *draw_impl;
210 g_assert (_gdk_root == NULL);
212 _gdk_root = g_object_new (GDK_TYPE_WINDOW, NULL);
213 private = (GdkWindowObject *)_gdk_root;
214 private->impl = g_object_new (_gdk_window_impl_get_type (), NULL);
215 private->impl_window = private;
216 private->visual = gdk_screen_get_system_visual (screen);
218 draw_impl = GDK_DRAWABLE_IMPL_WIN32 (private->impl);
220 draw_impl->handle = GetDesktopWindow ();
221 draw_impl->wrapper = GDK_DRAWABLE (private);
223 private->window_type = GDK_WINDOW_ROOT;
224 private->depth = gdk_visual_get_system ()->depth;
226 _gdk_root_window_size_init ();
232 /* width and height already initialised in _gdk_root_window_size_init() */
233 private->viewable = TRUE;
235 gdk_win32_handle_table_insert ((HANDLE *) &draw_impl->handle, _gdk_root);
237 GDK_NOTE (MISC, g_print ("_gdk_root=%p\n", GDK_WINDOW_HWND (_gdk_root)));
241 get_default_title (void)
244 title = g_get_application_name ();
246 title = g_get_prgname ();
252 * is a wrapper function for RegisterWindowClassEx.
253 * It creates at least one unique class for every
254 * GdkWindowType. If support for single window-specific icons
255 * is ever needed (e.g Dialog specific), every such window should
259 RegisterGdkClass (GdkWindowType wtype, GdkWindowTypeHint wtype_hint)
261 static ATOM klassTOPLEVEL = 0;
262 static ATOM klassCHILD = 0;
263 static ATOM klassTEMP = 0;
264 static ATOM klassTEMPSHADOW = 0;
265 static HICON hAppIcon = NULL;
266 static HICON hAppIconSm = NULL;
267 static WNDCLASSEXW wcl;
270 wcl.cbSize = sizeof (WNDCLASSEX);
271 wcl.style = 0; /* DON'T set CS_<H,V>REDRAW. It causes total redraw
272 * on WM_SIZE and WM_MOVE. Flicker, Performance!
274 wcl.lpfnWndProc = _gdk_win32_window_procedure;
277 wcl.hInstance = _gdk_app_hmodule;
281 /* initialize once! */
282 if (0 == hAppIcon && 0 == hAppIconSm)
284 gchar sLoc [MAX_PATH+1];
286 if (0 != GetModuleFileName (_gdk_app_hmodule, sLoc, MAX_PATH))
288 ExtractIconEx (sLoc, 0, &hAppIcon, &hAppIconSm, 1);
290 if (0 == hAppIcon && 0 == hAppIconSm)
292 if (0 != GetModuleFileName (_gdk_dll_hinstance, sLoc, MAX_PATH))
294 ExtractIconEx (sLoc, 0, &hAppIcon, &hAppIconSm, 1);
299 if (0 == hAppIcon && 0 == hAppIconSm)
301 hAppIcon = LoadImage (NULL, IDI_APPLICATION, IMAGE_ICON,
302 GetSystemMetrics (SM_CXICON),
303 GetSystemMetrics (SM_CYICON), 0);
304 hAppIconSm = LoadImage (NULL, IDI_APPLICATION, IMAGE_ICON,
305 GetSystemMetrics (SM_CXSMICON),
306 GetSystemMetrics (SM_CYSMICON), 0);
311 hAppIcon = hAppIconSm;
312 else if (0 == hAppIconSm)
313 hAppIconSm = hAppIcon;
315 wcl.lpszMenuName = NULL;
317 /* initialize once per class */
319 * HB: Setting the background brush leads to flicker, because we
320 * don't get asked how to clear the background. This is not what
321 * we want, at least not for input_only windows ...
323 #define ONCE_PER_CLASS() \
324 wcl.hIcon = CopyIcon (hAppIcon); \
325 wcl.hIconSm = CopyIcon (hAppIconSm); \
326 wcl.hbrBackground = NULL; \
327 wcl.hCursor = LoadCursor (NULL, IDC_ARROW);
331 case GDK_WINDOW_TOPLEVEL:
332 if (0 == klassTOPLEVEL)
334 wcl.lpszClassName = L"gdkWindowToplevel";
337 klassTOPLEVEL = RegisterClassExW (&wcl);
339 klass = klassTOPLEVEL;
342 case GDK_WINDOW_CHILD:
345 wcl.lpszClassName = L"gdkWindowChild";
347 wcl.style |= CS_PARENTDC; /* MSDN: ... enhances system performance. */
349 klassCHILD = RegisterClassExW (&wcl);
354 case GDK_WINDOW_TEMP:
355 if ((wtype_hint == GDK_WINDOW_TYPE_HINT_MENU) ||
356 (wtype_hint == GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU) ||
357 (wtype_hint == GDK_WINDOW_TYPE_HINT_POPUP_MENU) ||
358 (wtype_hint == GDK_WINDOW_TYPE_HINT_TOOLTIP))
360 if (klassTEMPSHADOW == 0)
362 wcl.lpszClassName = L"gdkWindowTempShadow";
363 wcl.style |= CS_SAVEBITS;
364 if (LOBYTE (g_win32_get_windows_version()) > 0x05 ||
365 LOWORD (g_win32_get_windows_version()) == 0x0105)
367 /* Windows XP (5.1) or above */
368 wcl.style |= 0x00020000; /* CS_DROPSHADOW */
371 klassTEMPSHADOW = RegisterClassExW (&wcl);
374 klass = klassTEMPSHADOW;
380 wcl.lpszClassName = L"gdkWindowTemp";
381 wcl.style |= CS_SAVEBITS;
383 klassTEMP = RegisterClassExW (&wcl);
391 g_assert_not_reached ();
397 WIN32_API_FAILED ("RegisterClassExW");
398 g_error ("That is a fatal error");
404 _gdk_window_impl_new (GdkWindow *window,
405 GdkWindow *real_parent,
407 GdkEventMask event_mask,
408 GdkWindowAttr *attributes,
409 gint attributes_mask)
414 DWORD dwStyle = 0, dwExStyle;
416 GdkWindow *orig_parent;
417 GdkWindowObject *private;
418 GdkWindowImplWin32 *impl;
419 GdkDrawableImplWin32 *draw_impl;
422 gint window_width, window_height;
423 gint offset_x = 0, offset_y = 0;
425 private = (GdkWindowObject *)window;
427 orig_parent = real_parent;
430 g_print ("_gdk_window_impl_new: %s\n",
431 (attributes->window_type == GDK_WINDOW_TOPLEVEL ? "TOPLEVEL" :
432 (attributes->window_type == GDK_WINDOW_CHILD ? "CHILD" :
433 (attributes->window_type == GDK_WINDOW_TEMP ? "TEMP" :
436 hparent = GDK_WINDOW_HWND (real_parent);
438 impl = g_object_new (_gdk_window_impl_get_type (), NULL);
439 private->impl = (GdkDrawable *)impl;
440 draw_impl = GDK_DRAWABLE_IMPL_WIN32 (impl);
441 draw_impl->wrapper = GDK_DRAWABLE (window);
443 // XXX: xattributes_mask = 0
446 if (attributes_mask & GDK_WA_VISUAL)
447 visual = attributes->visual;
449 visual = gdk_visual_get_system ();
453 impl->width = (attributes->width > 1) ? (attributes->width) : (1);
454 impl->height = (attributes->height > 1) ? (attributes->height) : (1);
456 impl->extension_events_selected = FALSE;
459 if (attributes->wclass == GDK_INPUT_OUTPUT)
463 private->input_only = FALSE;
467 /* I very much doubt using WS_EX_TRANSPARENT actually
468 * corresponds to how X11 InputOnly windows work, but it appears
469 * to work well enough for the actual use cases in gtk.
471 dwExStyle = WS_EX_TRANSPARENT;
473 private->input_only = TRUE;
474 GDK_NOTE (MISC, g_print ("... GDK_INPUT_ONLY\n"));
477 switch (private->window_type)
479 case GDK_WINDOW_TOPLEVEL:
480 if (GDK_WINDOW_TYPE (private->parent) != GDK_WINDOW_ROOT)
482 /* The common code warns for this case. */
483 hparent = GetDesktopWindow ();
485 /* Children of foreign windows aren't toplevel windows */
486 if (GDK_WINDOW_TYPE (orig_parent) == GDK_WINDOW_FOREIGN)
488 dwStyle = WS_CHILDWINDOW | WS_CLIPCHILDREN;
492 if (private->window_type == GDK_WINDOW_TOPLEVEL)
493 dwStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN;
495 dwStyle = WS_OVERLAPPED | WS_MINIMIZEBOX | WS_SYSMENU | WS_CAPTION | WS_THICKFRAME | WS_CLIPCHILDREN;
497 offset_x = _gdk_offset_x;
498 offset_y = _gdk_offset_y;
502 case GDK_WINDOW_CHILD:
503 dwStyle = WS_CHILDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
506 case GDK_WINDOW_TEMP:
507 /* A temp window is not necessarily a top level window */
508 dwStyle = (_gdk_root == real_parent ? WS_POPUP : WS_CHILDWINDOW);
509 dwStyle |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
510 dwExStyle |= WS_EX_TOOLWINDOW;
511 offset_x = _gdk_offset_x;
512 offset_y = _gdk_offset_y;
516 g_assert_not_reached ();
519 if (private->window_type != GDK_WINDOW_CHILD)
521 rect.left = rect.top = 0;
522 rect.right = private->width;
523 rect.bottom = private->height;
525 AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle);
527 window_width = rect.right - rect.left;
528 window_height = rect.bottom - rect.top;
532 window_width = private->width;
533 window_height = private->height;
536 if (attributes_mask & GDK_WA_TITLE)
537 title = attributes->title;
539 title = get_default_title ();
540 if (!title || !*title)
543 private->event_mask = GDK_STRUCTURE_MASK | attributes->event_mask;
545 if (attributes_mask & GDK_WA_TYPE_HINT)
546 impl->type_hint = attributes->type_hint;
548 impl->type_hint = GDK_WINDOW_TYPE_HINT_NORMAL;
550 if (impl->type_hint == GDK_WINDOW_TYPE_HINT_UTILITY)
551 dwExStyle |= WS_EX_TOOLWINDOW;
554 private->parent->children = g_list_prepend (private->parent->children, window);
556 klass = RegisterGdkClass (private->window_type, impl->type_hint);
558 wtitle = g_utf8_to_utf16 (title, -1, NULL, NULL, NULL);
560 hwndNew = CreateWindowExW (dwExStyle,
561 MAKEINTRESOURCEW (klass),
564 ((attributes_mask & GDK_WA_X) ?
565 private->x - offset_x : CW_USEDEFAULT),
566 private->y - offset_y,
567 window_width, window_height,
572 if (GDK_WINDOW_HWND (window) != hwndNew)
574 g_warning ("gdk_window_new: gdk_event_translate::WM_CREATE (%p, %p) HWND mismatch.",
575 GDK_WINDOW_HWND (window),
578 /* HB: IHMO due to a race condition the handle was increased by
579 * one, which causes much trouble. Because I can't find the
580 * real bug, try to workaround it ...
581 * To reproduce: compile with MSVC 5, DEBUG=1
584 gdk_win32_handle_table_remove (GDK_WINDOW_HWND (window));
585 GDK_WINDOW_HWND (window) = hwndNew;
586 gdk_win32_handle_table_insert (&GDK_WINDOW_HWND (window), window);
588 /* the old behaviour, but with warning */
589 draw_impl->handle = hwndNew;
594 g_object_ref (window);
595 gdk_win32_handle_table_insert (&GDK_WINDOW_HWND (window), window);
597 GDK_NOTE (MISC, g_print ("... \"%s\" %dx%d@%+d%+d %p = %p\n",
599 window_width, window_height,
600 ((attributes_mask & GDK_WA_X) ?
601 private->x - offset_x: CW_USEDEFAULT),
602 private->y - offset_y,
604 GDK_WINDOW_HWND (window)));
606 /* Add window handle to title */
607 GDK_NOTE (MISC_OR_EVENTS, gdk_window_set_title (window, title));
611 if (draw_impl->handle == NULL)
613 WIN32_API_FAILED ("CreateWindowExW");
614 g_object_unref (window);
618 // if (!from_set_skip_taskbar_hint && private->window_type == GDK_WINDOW_TEMP)
619 // gdk_window_set_skip_taskbar_hint (window, TRUE);
621 gdk_window_set_cursor (window, ((attributes_mask & GDK_WA_CURSOR) ?
622 (attributes->cursor) :
627 gdk_window_foreign_new_for_display (GdkDisplay *display,
628 GdkNativeWindow anid)
631 GdkWindowObject *private;
632 GdkWindowImplWin32 *impl;
633 GdkDrawableImplWin32 *draw_impl;
639 g_return_val_if_fail (display == _gdk_display, NULL);
641 window = g_object_new (GDK_TYPE_WINDOW, NULL);
642 private = (GdkWindowObject *)window;
643 private->visual = gdk_screen_get_system_visual (_gdk_screen);
644 private->impl = g_object_new (_gdk_window_impl_get_type (), NULL);
645 impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
646 draw_impl = GDK_DRAWABLE_IMPL_WIN32 (private->impl);
647 draw_impl->wrapper = GDK_DRAWABLE (window);
648 parent = GetParent ((HWND)anid);
650 private->parent = gdk_win32_handle_table_lookup ((GdkNativeWindow) parent);
651 if (!private->parent || GDK_WINDOW_TYPE (private->parent) == GDK_WINDOW_FOREIGN)
652 private->parent = (GdkWindowObject *)_gdk_root;
654 private->parent->children = g_list_prepend (private->parent->children, window);
656 draw_impl->handle = (HWND) anid;
657 GetClientRect ((HWND) anid, &rect);
659 point.y = rect.right;
660 ClientToScreen ((HWND) anid, &point);
661 if (parent != GetDesktopWindow ())
662 ScreenToClient (parent, &point);
663 private->x = point.x;
664 private->y = point.y;
665 private->width = rect.right - rect.left;
666 private->height = rect.bottom - rect.top;
667 private->window_type = GDK_WINDOW_FOREIGN;
668 private->destroyed = FALSE;
669 private->event_mask = GDK_ALL_EVENTS_MASK; /* XXX */
670 if (IsWindowVisible ((HWND) anid))
671 private->state &= (~GDK_WINDOW_STATE_WITHDRAWN);
673 private->state |= GDK_WINDOW_STATE_WITHDRAWN;
674 if (GetWindowLong ((HWND)anid, GWL_EXSTYLE) & WS_EX_TOPMOST)
675 private->state |= GDK_WINDOW_STATE_ABOVE;
677 private->state &= (~GDK_WINDOW_STATE_ABOVE);
678 private->state &= (~GDK_WINDOW_STATE_BELOW);
679 private->viewable = TRUE;
681 private->depth = gdk_visual_get_system ()->depth;
683 g_object_ref (window);
684 gdk_win32_handle_table_insert (&GDK_WINDOW_HWND (window), window);
686 GDK_NOTE (MISC, g_print ("gdk_window_foreign_new_for_display: %p: %s@%+d%+d\n",
688 _gdk_win32_drawable_description (window),
689 private->x, private->y));
695 gdk_window_lookup (GdkNativeWindow hwnd)
697 return (GdkWindow*) gdk_win32_handle_table_lookup (hwnd);
701 _gdk_win32_window_destroy (GdkWindow *window,
703 gboolean foreign_destroy)
705 GdkWindowObject *private = (GdkWindowObject *)window;
706 GdkWindowImplWin32 *window_impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
709 g_return_if_fail (GDK_IS_WINDOW (window));
711 GDK_NOTE (MISC, g_print ("_gdk_win32_window_destroy: %p\n",
712 GDK_WINDOW_HWND (window)));
714 /* Remove ourself from the modal stack */
715 _gdk_remove_modal_window (window);
717 /* Remove all our transient children */
718 tmp = window_impl->transient_children;
721 GdkWindow *child = tmp->data;
722 GdkWindowImplWin32 *child_impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (child)->impl);
724 child_impl->transient_owner = NULL;
725 tmp = g_slist_next (tmp);
727 g_slist_free (window_impl->transient_children);
728 window_impl->transient_children = NULL;
730 /* Remove ourself from our transient owner */
731 if (window_impl->transient_owner != NULL)
733 gdk_window_set_transient_for (window, NULL);
736 if (!recursing && !foreign_destroy)
738 _gdk_win32_drawable_finish (private->impl);
740 private->destroyed = TRUE;
741 DestroyWindow (GDK_WINDOW_HWND (window));
744 gdk_win32_handle_table_remove (GDK_WINDOW_HWND (window));
747 static cairo_surface_t *
748 gdk_win32_window_resize_cairo_surface (GdkWindow *window,
749 cairo_surface_t *surface,
753 /* XXX: Make Cairo surface use DC clip */
754 cairo_surface_destroy (surface);
760 _gdk_windowing_window_destroy_foreign (GdkWindow *window)
762 /* It's somebody else's window, but in our hierarchy, so reparent it
763 * to the desktop, and then try to destroy it.
765 gdk_window_hide (window);
766 gdk_window_reparent (window, NULL, 0, 0);
768 PostMessage (GDK_WINDOW_HWND (window), WM_CLOSE, 0, 0);
771 /* This function is called when the window really gone.
774 gdk_window_destroy_notify (GdkWindow *window)
776 g_return_if_fail (GDK_IS_WINDOW (window));
779 g_print ("gdk_window_destroy_notify: %p%s\n",
780 GDK_WINDOW_HWND (window),
781 (GDK_WINDOW_DESTROYED (window) ? " (destroyed)" : "")));
783 if (!GDK_WINDOW_DESTROYED (window))
785 if (GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN)
786 g_warning ("window %p unexpectedly destroyed",
787 GDK_WINDOW_HWND (window));
789 _gdk_window_destroy (window, TRUE);
792 gdk_win32_handle_table_remove (GDK_WINDOW_HWND (window));
793 g_object_unref (window);
797 get_outer_rect (GdkWindow *window,
802 rect->left = rect->top = 0;
804 rect->bottom = height;
806 _gdk_win32_adjust_client_rect (window, rect);
810 adjust_for_gravity_hints (GdkWindow *window,
815 GdkWindowObject *obj;
816 GdkWindowImplWin32 *impl;
818 obj = GDK_WINDOW_OBJECT (window);
819 impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
821 if (impl->hint_flags & GDK_HINT_WIN_GRAVITY)
823 gint orig_x = *x, orig_y = *y;
825 switch (impl->hints.win_gravity)
827 case GDK_GRAVITY_NORTH:
828 case GDK_GRAVITY_CENTER:
829 case GDK_GRAVITY_SOUTH:
830 *x -= (outer_rect->right - outer_rect->left) / 2;
831 *x += obj->width / 2;
834 case GDK_GRAVITY_SOUTH_EAST:
835 case GDK_GRAVITY_EAST:
836 case GDK_GRAVITY_NORTH_EAST:
837 *x -= outer_rect->right - outer_rect->left;
841 case GDK_GRAVITY_STATIC:
842 *x += outer_rect->left;
849 switch (impl->hints.win_gravity)
851 case GDK_GRAVITY_WEST:
852 case GDK_GRAVITY_CENTER:
853 case GDK_GRAVITY_EAST:
854 *y -= (outer_rect->bottom - outer_rect->top) / 2;
855 *y += obj->height / 2;
858 case GDK_GRAVITY_SOUTH_WEST:
859 case GDK_GRAVITY_SOUTH:
860 case GDK_GRAVITY_SOUTH_EAST:
861 *y -= outer_rect->bottom - outer_rect->top;
865 case GDK_GRAVITY_STATIC:
866 *y += outer_rect->top;
873 (orig_x != *x || orig_y != *y) ?
874 g_print ("adjust_for_gravity_hints: x: %d->%d, y: %d->%d\n",
875 orig_x, *x, orig_y, *y)
881 show_window_internal (GdkWindow *window,
885 GdkWindowObject *private;
886 HWND old_active_window;
887 gboolean focus_on_map = TRUE;
891 private = (GdkWindowObject *) window;
893 if (private->destroyed)
896 GDK_NOTE (MISC, g_print ("show_window_internal: %p: %s%s%s\n",
897 GDK_WINDOW_HWND (window),
898 _gdk_win32_window_state_to_string (private->state),
899 (raise ? " raise" : ""),
900 (deiconify ? " deiconify" : "")));
902 /* If asked to show (not deiconify) an withdrawn and iconified
906 !GDK_WINDOW_IS_MAPPED (window) &&
907 (private->state & GDK_WINDOW_STATE_ICONIFIED))
909 ShowWindow (GDK_WINDOW_HWND (window), SW_MINIMIZE);
913 /* If asked to just show an iconified window, do nothing. */
914 if (!deiconify && (private->state & GDK_WINDOW_STATE_ICONIFIED))
917 /* If asked to deiconify an already noniconified window, do
918 * nothing. (Especially, don't cause the window to rise and
919 * activate. There are different calls for that.)
921 if (deiconify && !(private->state & GDK_WINDOW_STATE_ICONIFIED))
924 /* If asked to show (but not raise) a window that is already
925 * visible, do nothing.
927 if (!deiconify && !raise && IsWindowVisible (GDK_WINDOW_HWND (window)))
932 if (!GDK_WINDOW_IS_MAPPED (window))
934 gdk_synthesize_window_state (window,
935 GDK_WINDOW_STATE_WITHDRAWN,
937 focus_on_map = private->focus_on_map;
940 exstyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE);
942 if (private->state & GDK_WINDOW_STATE_BELOW)
943 exstyle &= (~WS_EX_TOPMOST);
945 if (private->state & GDK_WINDOW_STATE_ABOVE)
946 exstyle |= WS_EX_TOPMOST;
948 if (exstyle & WS_EX_TOPMOST)
953 /* Use SetWindowPos to show transparent windows so automatic redraws
954 * in other windows can be suppressed.
956 if (exstyle & WS_EX_TRANSPARENT)
958 UINT flags = SWP_SHOWWINDOW | SWP_NOREDRAW | SWP_NOMOVE | SWP_NOSIZE;
961 flags |= SWP_NOZORDER;
962 if (!raise || GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP || !focus_on_map)
963 flags |= SWP_NOACTIVATE;
965 SetWindowPos (GDK_WINDOW_HWND (window), top, 0, 0, 0, 0, flags);
970 old_active_window = GetActiveWindow ();
972 if (private->state & GDK_WINDOW_STATE_FULLSCREEN)
974 gdk_window_fullscreen (window);
976 else if (private->state & GDK_WINDOW_STATE_MAXIMIZED)
978 ShowWindow (GDK_WINDOW_HWND (window), SW_MAXIMIZE);
980 else if (private->state & GDK_WINDOW_STATE_ICONIFIED)
982 ShowWindow (GDK_WINDOW_HWND (window), SW_RESTORE);
984 else if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP || !focus_on_map)
986 ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWNOACTIVATE);
990 ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWNORMAL);
995 if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP)
996 SetWindowPos (GDK_WINDOW_HWND (window), HWND_TOPMOST,
998 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
999 else if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TOPLEVEL)
1001 if (focus_on_map && private->accept_focus)
1003 SetForegroundWindow (GDK_WINDOW_HWND (window));
1004 if (top == HWND_TOPMOST)
1005 SetWindowPos (GDK_WINDOW_HWND (window), top,
1007 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
1011 SetWindowPos (GDK_WINDOW_HWND (window), top,
1013 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
1018 BringWindowToTop (GDK_WINDOW_HWND (window));
1021 else if (old_active_window != GDK_WINDOW_HWND (window))
1023 SetActiveWindow (old_active_window);
1028 gdk_win32_window_show (GdkWindow *window,
1029 gboolean already_mapped)
1031 show_window_internal (window, FALSE, FALSE);
1035 gdk_win32_window_hide (GdkWindow *window)
1037 GdkWindowObject *private;
1039 private = (GdkWindowObject*) window;
1040 if (private->destroyed)
1043 GDK_NOTE (MISC, g_print ("gdk_win32_window_hide: %p: %s\n",
1044 GDK_WINDOW_HWND (window),
1045 _gdk_win32_window_state_to_string (private->state)));
1047 if (GDK_WINDOW_IS_MAPPED (window))
1048 gdk_synthesize_window_state (window,
1050 GDK_WINDOW_STATE_WITHDRAWN);
1052 _gdk_window_clear_update_area (window);
1054 if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TOPLEVEL)
1055 ShowOwnedPopups (GDK_WINDOW_HWND (window), FALSE);
1057 if (GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE) & WS_EX_TRANSPARENT)
1059 SetWindowPos (GDK_WINDOW_HWND (window), HWND_BOTTOM,
1061 SWP_HIDEWINDOW | SWP_NOREDRAW | SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE);
1065 ShowWindow (GDK_WINDOW_HWND (window), SW_HIDE);
1070 gdk_win32_window_withdraw (GdkWindow *window)
1072 GdkWindowObject *private;
1074 private = (GdkWindowObject*) window;
1075 if (private->destroyed)
1078 GDK_NOTE (MISC, g_print ("gdk_win32_window_withdraw: %p: %s\n",
1079 GDK_WINDOW_HWND (window),
1080 _gdk_win32_window_state_to_string (private->state)));
1082 gdk_window_hide (window); /* ??? */
1086 gdk_win32_window_move (GdkWindow *window,
1089 GdkWindowObject *private = (GdkWindowObject *)window;
1090 GdkWindowImplWin32 *impl;
1092 g_return_if_fail (GDK_IS_WINDOW (window));
1094 if (GDK_WINDOW_DESTROYED (window))
1097 GDK_NOTE (MISC, g_print ("gdk_win32_window_move: %p: %+d%+d\n",
1098 GDK_WINDOW_HWND (window), x, y));
1100 impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
1102 if (private->state & GDK_WINDOW_STATE_FULLSCREEN)
1105 /* Don't check GDK_WINDOW_TYPE (private) == GDK_WINDOW_CHILD.
1106 * Foreign windows (another app's windows) might be children of our
1107 * windows! Especially in the case of gtkplug/socket.
1109 if (GetAncestor (GDK_WINDOW_HWND (window), GA_PARENT) != GetDesktopWindow ())
1111 _gdk_window_move_resize_child (window, x, y, private->width, private->height);
1117 get_outer_rect (window, private->width, private->height, &outer_rect);
1119 adjust_for_gravity_hints (window, &outer_rect, &x, &y);
1121 GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,%d,%d,0,0,"
1122 "NOACTIVATE|NOSIZE|NOZORDER)\n",
1123 GDK_WINDOW_HWND (window),
1124 x - _gdk_offset_x, y - _gdk_offset_y));
1126 API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), NULL,
1127 x - _gdk_offset_x, y - _gdk_offset_y, 0, 0,
1128 SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER));
1133 gdk_win32_window_resize (GdkWindow *window,
1134 gint width, gint height)
1136 GdkWindowObject *private = (GdkWindowObject*) window;
1137 GdkWindowImplWin32 *impl;
1139 g_return_if_fail (GDK_IS_WINDOW (window));
1141 if (GDK_WINDOW_DESTROYED (window))
1149 GDK_NOTE (MISC, g_print ("gdk_win32_window_resize: %p: %dx%d\n",
1150 GDK_WINDOW_HWND (window), width, height));
1152 impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
1154 if (private->state & GDK_WINDOW_STATE_FULLSCREEN)
1157 if (GetAncestor (GDK_WINDOW_HWND (window), GA_PARENT) != GetDesktopWindow ())
1159 _gdk_window_move_resize_child (window, private->x, private->y, width, height);
1165 get_outer_rect (window, width, height, &outer_rect);
1167 GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,0,0,%ld,%ld,"
1168 "NOACTIVATE|NOMOVE|NOZORDER)\n",
1169 GDK_WINDOW_HWND (window),
1170 outer_rect.right - outer_rect.left,
1171 outer_rect.bottom - outer_rect.top));
1173 API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), NULL,
1175 outer_rect.right - outer_rect.left,
1176 outer_rect.bottom - outer_rect.top,
1177 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER));
1178 private->resize_count += 1;
1183 gdk_win32_window_move_resize_internal (GdkWindow *window,
1189 GdkWindowObject *private;
1190 GdkWindowImplWin32 *impl;
1192 g_return_if_fail (GDK_IS_WINDOW (window));
1194 if (GDK_WINDOW_DESTROYED (window))
1202 private = GDK_WINDOW_OBJECT (window);
1203 impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
1205 if (private->state & GDK_WINDOW_STATE_FULLSCREEN)
1208 GDK_NOTE (MISC, g_print ("gdk_win32_window_move_resize: %p: %dx%d@%+d%+d\n",
1209 GDK_WINDOW_HWND (window),
1210 width, height, x, y));
1212 if (GetAncestor (GDK_WINDOW_HWND (window), GA_PARENT) != GetDesktopWindow ())
1214 _gdk_window_move_resize_child (window, x, y, width, height);
1220 get_outer_rect (window, width, height, &outer_rect);
1222 adjust_for_gravity_hints (window, &outer_rect, &x, &y);
1224 GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,%d,%d,%ld,%ld,"
1225 "NOACTIVATE|NOZORDER)\n",
1226 GDK_WINDOW_HWND (window),
1227 x - _gdk_offset_x, y - _gdk_offset_y,
1228 outer_rect.right - outer_rect.left,
1229 outer_rect.bottom - outer_rect.top));
1231 API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), NULL,
1232 x - _gdk_offset_x, y - _gdk_offset_y,
1233 outer_rect.right - outer_rect.left,
1234 outer_rect.bottom - outer_rect.top,
1235 SWP_NOACTIVATE | SWP_NOZORDER));
1240 gdk_win32_window_move_resize (GdkWindow *window,
1247 if (with_move && (width < 0 && height < 0))
1249 gdk_win32_window_move (window, x, y);
1255 gdk_win32_window_move_resize_internal (window, x, y, width, height);
1259 gdk_win32_window_resize (window, width, height);
1265 gdk_win32_window_reparent (GdkWindow *window,
1266 GdkWindow *new_parent,
1270 GdkWindowObject *window_private;
1271 GdkWindowObject *parent_private;
1272 GdkWindowObject *old_parent_private;
1273 GdkWindowImplWin32 *impl;
1274 gboolean was_toplevel;
1278 new_parent = _gdk_root;
1280 window_private = (GdkWindowObject*) window;
1281 old_parent_private = (GdkWindowObject *) window_private->parent;
1282 parent_private = (GdkWindowObject*) new_parent;
1283 impl = GDK_WINDOW_IMPL_WIN32 (window_private->impl);
1285 GDK_NOTE (MISC, g_print ("gdk_win32_window_reparent: %p: %p\n",
1286 GDK_WINDOW_HWND (window),
1287 GDK_WINDOW_HWND (new_parent)));
1289 style = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
1291 was_toplevel = GetAncestor (GDK_WINDOW_HWND (window), GA_PARENT) == GetDesktopWindow ();
1292 if (was_toplevel && new_parent != _gdk_root)
1294 /* Reparenting from top-level (child of desktop). Clear out
1297 style &= ~(WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
1299 SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE, style);
1301 else if (new_parent == _gdk_root)
1303 /* Reparenting to top-level. Add decorations. */
1304 style &= ~(WS_CHILD);
1305 style |= WS_OVERLAPPEDWINDOW;
1306 SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE, style);
1309 API_CALL (SetParent, (GDK_WINDOW_HWND (window),
1310 GDK_WINDOW_HWND (new_parent)));
1312 API_CALL (MoveWindow, (GDK_WINDOW_HWND (window),
1313 x, y, window_private->width, window_private->height, TRUE));
1315 /* From here on, we treat parents of type GDK_WINDOW_FOREIGN like
1318 if (GDK_WINDOW_TYPE (new_parent) == GDK_WINDOW_FOREIGN)
1319 new_parent = _gdk_root;
1321 window_private->parent = (GdkWindowObject *)new_parent;
1323 /* Switch the window type as appropriate */
1325 switch (GDK_WINDOW_TYPE (new_parent))
1327 case GDK_WINDOW_ROOT:
1328 if (impl->toplevel_window_type != -1)
1329 GDK_WINDOW_TYPE (window) = impl->toplevel_window_type;
1330 else if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD)
1331 GDK_WINDOW_TYPE (window) = GDK_WINDOW_TOPLEVEL;
1334 case GDK_WINDOW_TOPLEVEL:
1335 case GDK_WINDOW_CHILD:
1336 case GDK_WINDOW_TEMP:
1337 if (WINDOW_IS_TOPLEVEL (window))
1339 /* Save the original window type so we can restore it if the
1340 * window is reparented back to be a toplevel.
1342 impl->toplevel_window_type = GDK_WINDOW_TYPE (window);
1343 GDK_WINDOW_TYPE (window) = GDK_WINDOW_CHILD;
1347 if (old_parent_private)
1348 old_parent_private->children =
1349 g_list_remove (old_parent_private->children, window);
1351 parent_private->children = g_list_prepend (parent_private->children, window);
1357 gdk_win32_window_raise (GdkWindow *window)
1359 if (!GDK_WINDOW_DESTROYED (window))
1361 GDK_NOTE (MISC, g_print ("gdk_win32_window_raise: %p\n",
1362 GDK_WINDOW_HWND (window)));
1364 if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP)
1365 API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), HWND_TOPMOST,
1367 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE));
1368 else if (((GdkWindowObject *)window)->accept_focus)
1369 API_CALL (BringWindowToTop, (GDK_WINDOW_HWND (window)));
1371 API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), HWND_TOP,
1373 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE));
1378 gdk_win32_window_lower (GdkWindow *window)
1380 if (!GDK_WINDOW_DESTROYED (window))
1382 GDK_NOTE (MISC, g_print ("gdk_win32_window_lower: %p\n"
1383 "... SetWindowPos(%p,HWND_BOTTOM,0,0,0,0,"
1384 "NOACTIVATE|NOMOVE|NOSIZE)\n",
1385 GDK_WINDOW_HWND (window),
1386 GDK_WINDOW_HWND (window)));
1388 API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), HWND_BOTTOM,
1390 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE));
1395 gdk_window_set_urgency_hint (GdkWindow *window,
1398 FLASHWINFO flashwinfo;
1399 typedef BOOL (*PFN_FlashWindowEx) (FLASHWINFO*);
1400 PFN_FlashWindowEx flashWindowEx = NULL;
1402 g_return_if_fail (GDK_IS_WINDOW (window));
1403 g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD);
1405 if (GDK_WINDOW_DESTROYED (window))
1408 flashWindowEx = (PFN_FlashWindowEx) GetProcAddress (GetModuleHandle ("user32.dll"), "FlashWindowEx");
1412 flashwinfo.cbSize = sizeof (flashwinfo);
1413 flashwinfo.hwnd = GDK_WINDOW_HWND (window);
1415 flashwinfo.dwFlags = FLASHW_ALL | FLASHW_TIMER;
1417 flashwinfo.dwFlags = FLASHW_STOP;
1418 flashwinfo.uCount = 0;
1419 flashwinfo.dwTimeout = 0;
1421 flashWindowEx (&flashwinfo);
1425 FlashWindow (GDK_WINDOW_HWND (window), urgent);
1430 get_effective_window_decorations (GdkWindow *window,
1431 GdkWMDecoration *decoration)
1433 GdkWindowImplWin32 *impl;
1435 impl = (GdkWindowImplWin32 *)((GdkWindowObject *)window)->impl;
1437 if (gdk_window_get_decorations (window, decoration))
1440 if (((GdkWindowObject *) window)->window_type != GDK_WINDOW_TOPLEVEL)
1445 if ((impl->hint_flags & GDK_HINT_MIN_SIZE) &&
1446 (impl->hint_flags & GDK_HINT_MAX_SIZE) &&
1447 impl->hints.min_width == impl->hints.max_width &&
1448 impl->hints.min_height == impl->hints.max_height)
1450 *decoration = GDK_DECOR_ALL | GDK_DECOR_RESIZEH | GDK_DECOR_MAXIMIZE;
1452 if (impl->type_hint == GDK_WINDOW_TYPE_HINT_DIALOG ||
1453 impl->type_hint == GDK_WINDOW_TYPE_HINT_MENU ||
1454 impl->type_hint == GDK_WINDOW_TYPE_HINT_TOOLBAR)
1456 *decoration |= GDK_DECOR_MINIMIZE;
1458 else if (impl->type_hint == GDK_WINDOW_TYPE_HINT_SPLASHSCREEN)
1460 *decoration |= GDK_DECOR_MENU | GDK_DECOR_MINIMIZE;
1465 else if (impl->hint_flags & GDK_HINT_MAX_SIZE)
1467 *decoration = GDK_DECOR_ALL | GDK_DECOR_MAXIMIZE;
1468 if (impl->type_hint == GDK_WINDOW_TYPE_HINT_DIALOG ||
1469 impl->type_hint == GDK_WINDOW_TYPE_HINT_MENU ||
1470 impl->type_hint == GDK_WINDOW_TYPE_HINT_TOOLBAR)
1472 *decoration |= GDK_DECOR_MINIMIZE;
1479 switch (impl->type_hint)
1481 case GDK_WINDOW_TYPE_HINT_DIALOG:
1482 *decoration = (GDK_DECOR_ALL | GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE);
1485 case GDK_WINDOW_TYPE_HINT_MENU:
1486 *decoration = (GDK_DECOR_ALL | GDK_DECOR_RESIZEH | GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE);
1489 case GDK_WINDOW_TYPE_HINT_TOOLBAR:
1490 case GDK_WINDOW_TYPE_HINT_UTILITY:
1491 gdk_window_set_skip_taskbar_hint (window, TRUE);
1492 gdk_window_set_skip_pager_hint (window, TRUE);
1493 *decoration = (GDK_DECOR_ALL | GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE);
1496 case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
1497 *decoration = (GDK_DECOR_ALL | GDK_DECOR_RESIZEH | GDK_DECOR_MENU |
1498 GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE);
1501 case GDK_WINDOW_TYPE_HINT_DOCK:
1504 case GDK_WINDOW_TYPE_HINT_DESKTOP:
1509 case GDK_WINDOW_TYPE_HINT_NORMAL:
1510 *decoration = GDK_DECOR_ALL;
1519 gdk_window_set_geometry_hints (GdkWindow *window,
1520 const GdkGeometry *geometry,
1521 GdkWindowHints geom_mask)
1523 GdkWindowImplWin32 *impl;
1525 g_return_if_fail (GDK_IS_WINDOW (window));
1527 if (GDK_WINDOW_DESTROYED (window))
1530 GDK_NOTE (MISC, g_print ("gdk_window_set_geometry_hints: %p\n",
1531 GDK_WINDOW_HWND (window)));
1533 impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
1535 impl->hint_flags = geom_mask;
1536 impl->hints = *geometry;
1538 if (geom_mask & GDK_HINT_POS)
1539 ; /* even the X11 mplementation doesn't care */
1541 if (geom_mask & GDK_HINT_MIN_SIZE)
1543 GDK_NOTE (MISC, g_print ("... MIN_SIZE: %dx%d\n",
1544 geometry->min_width, geometry->min_height));
1547 if (geom_mask & GDK_HINT_MAX_SIZE)
1549 GDK_NOTE (MISC, g_print ("... MAX_SIZE: %dx%d\n",
1550 geometry->max_width, geometry->max_height));
1553 if (geom_mask & GDK_HINT_BASE_SIZE)
1555 GDK_NOTE (MISC, g_print ("... BASE_SIZE: %dx%d\n",
1556 geometry->base_width, geometry->base_height));
1559 if (geom_mask & GDK_HINT_RESIZE_INC)
1561 GDK_NOTE (MISC, g_print ("... RESIZE_INC: (%d,%d)\n",
1562 geometry->width_inc, geometry->height_inc));
1565 if (geom_mask & GDK_HINT_ASPECT)
1567 GDK_NOTE (MISC, g_print ("... ASPECT: %g--%g\n",
1568 geometry->min_aspect, geometry->max_aspect));
1571 if (geom_mask & GDK_HINT_WIN_GRAVITY)
1573 GDK_NOTE (MISC, g_print ("... GRAVITY: %d\n", geometry->win_gravity));
1576 update_style_bits (window);
1580 gdk_window_set_title (GdkWindow *window,
1585 g_return_if_fail (GDK_IS_WINDOW (window));
1586 g_return_if_fail (title != NULL);
1588 if (GDK_WINDOW_DESTROYED (window))
1591 /* Empty window titles not allowed, so set it to just a period. */
1595 GDK_NOTE (MISC, g_print ("gdk_window_set_title: %p: %s\n",
1596 GDK_WINDOW_HWND (window), title));
1598 GDK_NOTE (MISC_OR_EVENTS, title = g_strdup_printf ("%p %s", GDK_WINDOW_HWND (window), title));
1600 wtitle = g_utf8_to_utf16 (title, -1, NULL, NULL, NULL);
1601 API_CALL (SetWindowTextW, (GDK_WINDOW_HWND (window), wtitle));
1604 GDK_NOTE (MISC_OR_EVENTS, g_free ((char *) title));
1608 gdk_window_set_role (GdkWindow *window,
1611 g_return_if_fail (GDK_IS_WINDOW (window));
1613 GDK_NOTE (MISC, g_print ("gdk_window_set_role: %p: %s\n",
1614 GDK_WINDOW_HWND (window),
1615 (role ? role : "NULL")));
1620 gdk_window_set_transient_for (GdkWindow *window,
1623 HWND window_id, parent_id;
1624 GdkWindowImplWin32 *window_impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
1625 GdkWindowImplWin32 *parent_impl = NULL;
1628 g_return_if_fail (GDK_IS_WINDOW (window));
1630 window_id = GDK_WINDOW_HWND (window);
1631 parent_id = parent != NULL ? GDK_WINDOW_HWND (parent) : NULL;
1633 GDK_NOTE (MISC, g_print ("gdk_window_set_transient_for: %p: %p\n", window_id, parent_id));
1635 if (GDK_WINDOW_DESTROYED (window) || (parent && GDK_WINDOW_DESTROYED (parent)))
1637 if (GDK_WINDOW_DESTROYED (window))
1638 GDK_NOTE (MISC, g_print ("... destroyed!\n"));
1640 GDK_NOTE (MISC, g_print ("... owner destroyed!\n"));
1645 if (((GdkWindowObject *) window)->window_type == GDK_WINDOW_CHILD)
1647 GDK_NOTE (MISC, g_print ("... a child window!\n"));
1653 GdkWindowImplWin32 *trans_impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window_impl->transient_owner)->impl);
1654 if (trans_impl->transient_children != NULL)
1656 item = g_slist_find (trans_impl->transient_children, window);
1658 trans_impl->transient_children = g_slist_delete_link (trans_impl->transient_children, item);
1659 trans_impl->num_transients--;
1661 if (!trans_impl->num_transients)
1663 trans_impl->transient_children = NULL;
1666 g_object_unref (G_OBJECT (window_impl->transient_owner));
1667 g_object_unref (G_OBJECT (window));
1669 window_impl->transient_owner = NULL;
1673 parent_impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (parent)->impl);
1675 parent_impl->transient_children = g_slist_append (parent_impl->transient_children, window);
1676 g_object_ref (G_OBJECT (window));
1677 parent_impl->num_transients++;
1678 window_impl->transient_owner = parent;
1679 g_object_ref (G_OBJECT (parent));
1682 /* This changes the *owner* of the window, despite the misleading
1683 * name. (Owner and parent are unrelated concepts.) At least that's
1684 * what people who seem to know what they talk about say on
1685 * USENET. Search on Google.
1688 if (SetWindowLongPtr (window_id, GWLP_HWNDPARENT, (LONG_PTR) parent_id) == 0 &&
1689 GetLastError () != 0)
1690 WIN32_API_FAILED ("SetWindowLongPtr");
1694 _gdk_push_modal_window (GdkWindow *window)
1696 modal_window_stack = g_slist_prepend (modal_window_stack,
1701 _gdk_remove_modal_window (GdkWindow *window)
1705 g_return_if_fail (window != NULL);
1707 /* It's possible to be NULL here if someone sets the modal hint of the window
1708 * to FALSE before a modal window stack has ever been created. */
1709 if (modal_window_stack == NULL)
1712 /* Find the requested window in the stack and remove it. Yeah, I realize this
1713 * means we're not a 'real stack', strictly speaking. Sue me. :) */
1714 tmp = g_slist_find (modal_window_stack, window);
1717 modal_window_stack = g_slist_delete_link (modal_window_stack, tmp);
1722 _gdk_modal_current (void)
1724 if (modal_window_stack != NULL)
1726 GSList *tmp = modal_window_stack;
1728 while (tmp != NULL && !GDK_WINDOW_IS_MAPPED (tmp->data))
1730 tmp = g_slist_next (tmp);
1733 return tmp != NULL ? tmp->data : NULL;
1742 gdk_win32_window_set_background (GdkWindow *window,
1743 cairo_pattern_t *pattern)
1748 gdk_win32_window_set_device_cursor (GdkWindow *window,
1752 GdkWindowImplWin32 *impl;
1753 GdkCursorPrivate *cursor_private;
1755 HCURSOR hprevcursor;
1757 impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
1758 cursor_private = (GdkCursorPrivate*) cursor;
1760 if (GDK_WINDOW_DESTROYED (window))
1766 hcursor = cursor_private->hcursor;
1768 GDK_NOTE (MISC, g_print ("gdk_win32_window_set_cursor: %p: %p\n",
1769 GDK_WINDOW_HWND (window),
1772 /* First get the old cursor, if any (we wait to free the old one
1773 * since it may be the current cursor set in the Win32 API right
1776 hprevcursor = impl->hcursor;
1778 GDK_DEVICE_GET_CLASS (device)->set_window_cursor (device, window, cursor);
1780 if (hcursor == NULL)
1781 impl->hcursor = NULL;
1784 /* We must copy the cursor as it is OK to destroy the GdkCursor
1785 * while still in use for some window. See for instance
1786 * gimp_change_win_cursor() which calls gdk_window_set_cursor
1787 * (win, cursor), and immediately afterwards gdk_cursor_destroy
1790 if ((impl->hcursor = CopyCursor (hcursor)) == NULL)
1791 WIN32_API_FAILED ("CopyCursor");
1792 GDK_NOTE (MISC, g_print ("... CopyCursor (%p) = %p\n",
1793 hcursor, impl->hcursor));
1796 /* Destroy the previous cursor */
1797 if (hprevcursor != NULL)
1799 GDK_NOTE (MISC, g_print ("... DestroyCursor (%p)\n", hprevcursor));
1800 API_CALL (DestroyCursor, (hprevcursor));
1805 gdk_win32_window_get_geometry (GdkWindow *window,
1815 if (!GDK_WINDOW_DESTROYED (window))
1819 API_CALL (GetClientRect, (GDK_WINDOW_HWND (window), &rect));
1821 if (window != _gdk_root)
1824 GdkWindow *parent = gdk_window_get_parent (window);
1828 ClientToScreen (GDK_WINDOW_HWND (window), &pt);
1829 ScreenToClient (GDK_WINDOW_HWND (parent), &pt);
1835 ClientToScreen (GDK_WINDOW_HWND (window), &pt);
1836 ScreenToClient (GDK_WINDOW_HWND (parent), &pt);
1840 if (parent == _gdk_root)
1842 rect.left += _gdk_offset_x;
1843 rect.top += _gdk_offset_y;
1844 rect.right += _gdk_offset_x;
1845 rect.bottom += _gdk_offset_y;
1854 *width = rect.right - rect.left;
1856 *height = rect.bottom - rect.top;
1858 *depth = gdk_window_get_visual (window)->depth;
1860 GDK_NOTE (MISC, g_print ("gdk_win32_window_get_geometry: %p: %ldx%ldx%d@%+ld%+ld\n",
1861 GDK_WINDOW_HWND (window),
1862 rect.right - rect.left, rect.bottom - rect.top,
1863 gdk_window_get_visual (window)->depth,
1864 rect.left, rect.top));
1869 gdk_win32_window_get_root_coords (GdkWindow *window,
1881 ClientToScreen (GDK_WINDOW_HWND (window), &pt);
1886 *root_x = tx + _gdk_offset_x;
1888 *root_y = ty + _gdk_offset_y;
1890 GDK_NOTE (MISC, g_print ("gdk_win32_window_get_root_coords: %p: %+d%+d %+d%+d\n",
1891 GDK_WINDOW_HWND (window),
1893 tx + _gdk_offset_x, ty + _gdk_offset_y));
1898 gdk_win32_window_restack_under (GdkWindow *window,
1899 GList *native_siblings)
1905 gdk_win32_window_restack_toplevel (GdkWindow *window,
1913 gdk_window_get_root_origin (GdkWindow *window,
1919 g_return_if_fail (GDK_IS_WINDOW (window));
1921 gdk_window_get_frame_extents (window, &rect);
1929 GDK_NOTE (MISC, g_print ("gdk_window_get_root_origin: %p: %+d%+d\n",
1930 GDK_WINDOW_HWND (window), rect.x, rect.y));
1934 gdk_window_get_frame_extents (GdkWindow *window,
1937 GdkWindowObject *private;
1941 g_return_if_fail (GDK_IS_WINDOW (window));
1942 g_return_if_fail (rect != NULL);
1944 private = GDK_WINDOW_OBJECT (window);
1951 if (GDK_WINDOW_DESTROYED (window))
1954 /* FIXME: window is documented to be a toplevel GdkWindow, so is it really
1955 * necessary to walk its parent chain?
1957 while (private->parent && ((GdkWindowObject*) private->parent)->parent)
1958 private = (GdkWindowObject*) private->parent;
1960 hwnd = GDK_WINDOW_HWND (window);
1961 API_CALL (GetWindowRect, (hwnd, &r));
1963 rect->x = r.left + _gdk_offset_x;
1964 rect->y = r.top + _gdk_offset_y;
1965 rect->width = r.right - r.left;
1966 rect->height = r.bottom - r.top;
1968 GDK_NOTE (MISC, g_print ("gdk_window_get_frame_extents: %p: %ldx%ld@%+ld%+ld\n",
1969 GDK_WINDOW_HWND (window),
1970 r.right - r.left, r.bottom - r.top,
1975 gdk_window_win32_get_device_state (GdkWindow *window,
1979 GdkModifierType *mask)
1983 g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), FALSE);
1985 GDK_DEVICE_GET_CLASS (device)->query_state (device, window,
1989 return (child != NULL);
1993 _gdk_windowing_get_device_state (GdkDisplay *display,
1998 GdkModifierType *mask)
2000 g_return_if_fail (display == _gdk_display);
2003 *screen = _gdk_screen;
2005 GDK_DEVICE_GET_CLASS (device)->query_state (device,
2006 gdk_screen_get_root_window (_gdk_screen),
2014 gdk_display_warp_pointer (GdkDisplay *display,
2019 GdkDeviceManagerWin32 *device_manager;
2021 g_return_if_fail (display == _gdk_display);
2022 g_return_if_fail (screen == _gdk_screen);
2024 device_manager = GDK_DEVICE_MANAGER_WIN32 (gdk_display_get_device_manager (display));
2025 GDK_DEVICE_GET_CLASS (device_manager->core_pointer)->warp (device_manager->core_pointer,
2030 gdk_display_warp_device (GdkDisplay *display,
2036 g_return_if_fail (display == _gdk_display);
2037 g_return_if_fail (screen == _gdk_screen);
2038 g_return_if_fail (GDK_IS_DEVICE (device));
2039 g_return_if_fail (display == gdk_device_get_display (device));
2041 GDK_DEVICE_GET_CLASS (device)->warp (device, screen, x, y);
2045 _gdk_windowing_window_at_device_position (GdkDisplay *display,
2049 GdkModifierType *mask,
2050 gboolean get_toplevel)
2052 return GDK_DEVICE_GET_CLASS (device)->window_at_position (device, win_x, win_y, mask, get_toplevel);
2056 gdk_win32_window_get_events (GdkWindow *window)
2058 if (GDK_WINDOW_DESTROYED (window))
2061 return GDK_WINDOW_OBJECT (window)->event_mask;
2065 gdk_win32_window_set_events (GdkWindow *window,
2066 GdkEventMask event_mask)
2068 /* gdk_window_new() always sets the GDK_STRUCTURE_MASK, so better
2069 * set it here, too. Not that I know or remember why it is
2070 * necessary, will have to test some day.
2072 GDK_WINDOW_OBJECT (window)->event_mask = GDK_STRUCTURE_MASK | event_mask;
2076 do_shape_combine_region (GdkWindow *window,
2082 GetClientRect (GDK_WINDOW_HWND (window), &rect);
2083 _gdk_win32_adjust_client_rect (window, &rect);
2085 OffsetRgn (hrgn, -rect.left, -rect.top);
2086 OffsetRgn (hrgn, x, y);
2088 /* If this is a top-level window, add the title bar to the region */
2089 if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TOPLEVEL)
2091 HRGN tmp = CreateRectRgn (0, 0, rect.right - rect.left, -rect.top);
2092 CombineRgn (hrgn, hrgn, tmp, RGN_OR);
2096 SetWindowRgn (GDK_WINDOW_HWND (window), hrgn, TRUE);
2100 gdk_window_set_override_redirect (GdkWindow *window,
2101 gboolean override_redirect)
2103 g_return_if_fail (GDK_IS_WINDOW (window));
2105 g_warning ("gdk_window_set_override_redirect not implemented");
2109 gdk_window_set_accept_focus (GdkWindow *window,
2110 gboolean accept_focus)
2112 GdkWindowObject *private;
2114 g_return_if_fail (GDK_IS_WINDOW (window));
2116 private = (GdkWindowObject *)window;
2118 accept_focus = accept_focus != FALSE;
2120 if (private->accept_focus != accept_focus)
2121 private->accept_focus = accept_focus;
2125 gdk_window_set_focus_on_map (GdkWindow *window,
2126 gboolean focus_on_map)
2128 GdkWindowObject *private;
2130 g_return_if_fail (GDK_IS_WINDOW (window));
2132 private = (GdkWindowObject *)window;
2134 focus_on_map = focus_on_map != FALSE;
2136 if (private->focus_on_map != focus_on_map)
2137 private->focus_on_map = focus_on_map;
2141 gdk_window_set_icon_list (GdkWindow *window,
2144 GdkPixbuf *pixbuf, *big_pixbuf, *small_pixbuf;
2145 gint big_diff, small_diff;
2146 gint big_w, big_h, small_w, small_h;
2149 HICON small_hicon, big_hicon;
2150 GdkWindowImplWin32 *impl;
2151 gint i, big_i, small_i;
2153 g_return_if_fail (GDK_IS_WINDOW (window));
2155 if (GDK_WINDOW_DESTROYED (window))
2158 impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
2160 /* ideal sizes for small and large icons */
2161 big_w = GetSystemMetrics (SM_CXICON);
2162 big_h = GetSystemMetrics (SM_CYICON);
2163 small_w = GetSystemMetrics (SM_CXSMICON);
2164 small_h = GetSystemMetrics (SM_CYSMICON);
2166 /* find closest sized icons in the list */
2168 small_pixbuf = NULL;
2174 pixbuf = (GdkPixbuf*) pixbufs->data;
2175 w = gdk_pixbuf_get_width (pixbuf);
2176 h = gdk_pixbuf_get_height (pixbuf);
2178 dw = ABS (w - big_w);
2179 dh = ABS (h - big_h);
2180 diff = dw*dw + dh*dh;
2181 if (big_pixbuf == NULL || diff < big_diff)
2183 big_pixbuf = pixbuf;
2188 dw = ABS (w - small_w);
2189 dh = ABS (h - small_h);
2190 diff = dw*dw + dh*dh;
2191 if (small_pixbuf == NULL || diff < small_diff)
2193 small_pixbuf = pixbuf;
2198 pixbufs = g_list_next (pixbufs);
2202 /* Create the icons */
2203 big_hicon = _gdk_win32_pixbuf_to_hicon (big_pixbuf);
2204 small_hicon = _gdk_win32_pixbuf_to_hicon (small_pixbuf);
2207 SendMessageW (GDK_WINDOW_HWND (window), WM_SETICON, ICON_BIG,
2209 SendMessageW (GDK_WINDOW_HWND (window), WM_SETICON, ICON_SMALL,
2210 (LPARAM)small_hicon);
2212 /* Store the icons, destroying any previous icons */
2213 if (impl->hicon_big)
2214 GDI_CALL (DestroyIcon, (impl->hicon_big));
2215 impl->hicon_big = big_hicon;
2216 if (impl->hicon_small)
2217 GDI_CALL (DestroyIcon, (impl->hicon_small));
2218 impl->hicon_small = small_hicon;
2222 gdk_window_set_icon_name (GdkWindow *window,
2225 /* In case I manage to confuse this again (or somebody else does):
2226 * Please note that "icon name" here really *does* mean the name or
2227 * title of an window minimized as an icon on the desktop, or in the
2228 * taskbar. It has nothing to do with the freedesktop.org icon
2232 g_return_if_fail (GDK_IS_WINDOW (window));
2234 if (GDK_WINDOW_DESTROYED (window))
2238 /* This is not the correct thing to do. We should keep both the
2239 * "normal" window title, and the icon name. When the window is
2240 * minimized, call SetWindowText() with the icon name, and when the
2241 * window is restored, with the normal window title. Also, the name
2242 * is in UTF-8, so we should do the normal conversion to either wide
2243 * chars or system codepage, and use either the W or A version of
2244 * SetWindowText(), depending on Windows version.
2246 API_CALL (SetWindowText, (GDK_WINDOW_HWND (window), name));
2251 gdk_window_get_group (GdkWindow *window)
2253 g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
2254 g_return_val_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD, NULL);
2256 if (GDK_WINDOW_DESTROYED (window))
2259 g_warning ("gdk_window_get_group not yet implemented");
2265 gdk_window_set_group (GdkWindow *window,
2268 g_return_if_fail (GDK_IS_WINDOW (window));
2269 g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD);
2270 g_return_if_fail (leader == NULL || GDK_IS_WINDOW (leader));
2272 if (GDK_WINDOW_DESTROYED (window) || GDK_WINDOW_DESTROYED (leader))
2275 g_warning ("gdk_window_set_group not implemented");
2279 update_single_bit (LONG *style,
2284 /* all controls the interpretation of gdk_bit -- if all is TRUE,
2285 * gdk_bit indicates whether style_bit is off; if all is FALSE, gdk
2286 * bit indicate whether style_bit is on
2288 if ((!all && gdk_bit) || (all && !gdk_bit))
2289 *style |= style_bit;
2291 *style &= ~style_bit;
2295 update_style_bits (GdkWindow *window)
2297 GdkWindowObject *private = (GdkWindowObject *)window;
2298 GdkWindowImplWin32 *impl = (GdkWindowImplWin32 *)private->impl;
2299 GdkWMDecoration decorations;
2300 LONG old_style, new_style, old_exstyle, new_exstyle;
2302 RECT rect, before, after;
2304 old_style = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
2305 old_exstyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE);
2307 GetClientRect (GDK_WINDOW_HWND (window), &before);
2309 AdjustWindowRectEx (&before, old_style, FALSE, old_exstyle);
2311 new_style = old_style;
2312 new_exstyle = old_exstyle;
2314 if (private->window_type == GDK_WINDOW_TEMP ||
2315 impl->type_hint == GDK_WINDOW_TYPE_HINT_UTILITY)
2316 new_exstyle |= WS_EX_TOOLWINDOW;
2318 new_exstyle &= ~WS_EX_TOOLWINDOW;
2320 if (get_effective_window_decorations (window, &decorations))
2322 all = (decorations & GDK_DECOR_ALL);
2323 update_single_bit (&new_style, all, decorations & GDK_DECOR_BORDER, WS_BORDER);
2324 update_single_bit (&new_style, all, decorations & GDK_DECOR_RESIZEH, WS_THICKFRAME);
2325 update_single_bit (&new_style, all, decorations & GDK_DECOR_TITLE, WS_CAPTION);
2326 update_single_bit (&new_style, all, decorations & GDK_DECOR_MENU, WS_SYSMENU);
2327 update_single_bit (&new_style, all, decorations & GDK_DECOR_MINIMIZE, WS_MINIMIZEBOX);
2328 update_single_bit (&new_style, all, decorations & GDK_DECOR_MAXIMIZE, WS_MAXIMIZEBOX);
2331 if (old_style == new_style && old_exstyle == new_exstyle )
2333 GDK_NOTE (MISC, g_print ("update_style_bits: %p: no change\n",
2334 GDK_WINDOW_HWND (window)));
2338 if (old_style != new_style)
2340 GDK_NOTE (MISC, g_print ("update_style_bits: %p: STYLE: %s => %s\n",
2341 GDK_WINDOW_HWND (window),
2342 _gdk_win32_window_style_to_string (old_style),
2343 _gdk_win32_window_style_to_string (new_style)));
2345 SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE, new_style);
2348 if (old_exstyle != new_exstyle)
2350 GDK_NOTE (MISC, g_print ("update_style_bits: %p: EXSTYLE: %s => %s\n",
2351 GDK_WINDOW_HWND (window),
2352 _gdk_win32_window_exstyle_to_string (old_exstyle),
2353 _gdk_win32_window_exstyle_to_string (new_exstyle)));
2355 SetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE, new_exstyle);
2358 AdjustWindowRectEx (&after, new_style, FALSE, new_exstyle);
2360 GetWindowRect (GDK_WINDOW_HWND (window), &rect);
2361 rect.left += after.left - before.left;
2362 rect.top += after.top - before.top;
2363 rect.right += after.right - before.right;
2364 rect.bottom += after.bottom - before.bottom;
2366 SetWindowPos (GDK_WINDOW_HWND (window), NULL,
2367 rect.left, rect.top,
2368 rect.right - rect.left, rect.bottom - rect.top,
2369 SWP_FRAMECHANGED | SWP_NOACTIVATE |
2370 SWP_NOREPOSITION | SWP_NOZORDER);
2375 update_single_system_menu_entry (HMENU hmenu,
2380 /* all controls the interpretation of gdk_bit -- if all is TRUE,
2381 * gdk_bit indicates whether menu entry is disabled; if all is
2382 * FALSE, gdk bit indicate whether menu entry is enabled
2384 if ((!all && gdk_bit) || (all && !gdk_bit))
2385 EnableMenuItem (hmenu, menu_entry, MF_BYCOMMAND | MF_ENABLED);
2387 EnableMenuItem (hmenu, menu_entry, MF_BYCOMMAND | MF_GRAYED);
2391 update_system_menu (GdkWindow *window)
2393 GdkWMFunction functions;
2396 if (_gdk_window_get_functions (window, &functions))
2398 HMENU hmenu = GetSystemMenu (GDK_WINDOW_HWND (window), FALSE);
2400 all = (functions & GDK_FUNC_ALL);
2401 update_single_system_menu_entry (hmenu, all, functions & GDK_FUNC_RESIZE, SC_SIZE);
2402 update_single_system_menu_entry (hmenu, all, functions & GDK_FUNC_MOVE, SC_MOVE);
2403 update_single_system_menu_entry (hmenu, all, functions & GDK_FUNC_MINIMIZE, SC_MINIMIZE);
2404 update_single_system_menu_entry (hmenu, all, functions & GDK_FUNC_MAXIMIZE, SC_MAXIMIZE);
2405 update_single_system_menu_entry (hmenu, all, functions & GDK_FUNC_CLOSE, SC_CLOSE);
2410 get_decorations_quark ()
2412 static GQuark quark = 0;
2415 quark = g_quark_from_static_string ("gdk-window-decorations");
2421 gdk_window_set_decorations (GdkWindow *window,
2422 GdkWMDecoration decorations)
2424 GdkWMDecoration* decorations_copy;
2426 g_return_if_fail (GDK_IS_WINDOW (window));
2428 GDK_NOTE (MISC, g_print ("gdk_window_set_decorations: %p: %s %s%s%s%s%s%s\n",
2429 GDK_WINDOW_HWND (window),
2430 (decorations & GDK_DECOR_ALL ? "clearing" : "setting"),
2431 (decorations & GDK_DECOR_BORDER ? "BORDER " : ""),
2432 (decorations & GDK_DECOR_RESIZEH ? "RESIZEH " : ""),
2433 (decorations & GDK_DECOR_TITLE ? "TITLE " : ""),
2434 (decorations & GDK_DECOR_MENU ? "MENU " : ""),
2435 (decorations & GDK_DECOR_MINIMIZE ? "MINIMIZE " : ""),
2436 (decorations & GDK_DECOR_MAXIMIZE ? "MAXIMIZE " : "")));
2438 decorations_copy = g_malloc (sizeof (GdkWMDecoration));
2439 *decorations_copy = decorations;
2440 g_object_set_qdata_full (G_OBJECT (window), get_decorations_quark (), decorations_copy, g_free);
2442 update_style_bits (window);
2446 gdk_window_get_decorations (GdkWindow *window,
2447 GdkWMDecoration *decorations)
2449 GdkWMDecoration* decorations_set;
2451 g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
2453 decorations_set = g_object_get_qdata (G_OBJECT (window), get_decorations_quark ());
2454 if (decorations_set)
2455 *decorations = *decorations_set;
2457 return (decorations_set != NULL);
2461 get_functions_quark ()
2463 static GQuark quark = 0;
2466 quark = g_quark_from_static_string ("gdk-window-functions");
2472 gdk_window_set_functions (GdkWindow *window,
2473 GdkWMFunction functions)
2475 GdkWMFunction* functions_copy;
2477 g_return_if_fail (GDK_IS_WINDOW (window));
2479 GDK_NOTE (MISC, g_print ("gdk_window_set_functions: %p: %s %s%s%s%s%s\n",
2480 GDK_WINDOW_HWND (window),
2481 (functions & GDK_FUNC_ALL ? "clearing" : "setting"),
2482 (functions & GDK_FUNC_RESIZE ? "RESIZE " : ""),
2483 (functions & GDK_FUNC_MOVE ? "MOVE " : ""),
2484 (functions & GDK_FUNC_MINIMIZE ? "MINIMIZE " : ""),
2485 (functions & GDK_FUNC_MAXIMIZE ? "MAXIMIZE " : ""),
2486 (functions & GDK_FUNC_CLOSE ? "CLOSE " : "")));
2488 functions_copy = g_malloc (sizeof (GdkWMFunction));
2489 *functions_copy = functions;
2490 g_object_set_qdata_full (G_OBJECT (window), get_functions_quark (), functions_copy, g_free);
2492 update_system_menu (window);
2496 _gdk_window_get_functions (GdkWindow *window,
2497 GdkWMFunction *functions)
2499 GdkWMDecoration* functions_set;
2501 functions_set = g_object_get_qdata (G_OBJECT (window), get_functions_quark ());
2503 *functions = *functions_set;
2505 return (functions_set != NULL);
2509 gdk_win32_window_set_static_gravities (GdkWindow *window,
2510 gboolean use_static)
2512 g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
2518 gdk_window_begin_resize_drag (GdkWindow *window,
2527 g_return_if_fail (GDK_IS_WINDOW (window));
2529 if (GDK_WINDOW_DESTROYED (window))
2532 /* Tell Windows to start interactively resizing the window by pretending that
2533 * the left pointer button was clicked in the suitable edge or corner. This
2534 * will only work if the button is down when this function is called, and
2535 * will only work with button 1 (left), since Windows only allows window
2536 * dragging using the left mouse button.
2541 /* Must break the automatic grab that occured when the button was
2542 * pressed, otherwise it won't work.
2544 gdk_display_pointer_ungrab (_gdk_display, 0);
2548 case GDK_WINDOW_EDGE_NORTH_WEST:
2549 winedge = HTTOPLEFT;
2552 case GDK_WINDOW_EDGE_NORTH:
2556 case GDK_WINDOW_EDGE_NORTH_EAST:
2557 winedge = HTTOPRIGHT;
2560 case GDK_WINDOW_EDGE_WEST:
2564 case GDK_WINDOW_EDGE_EAST:
2568 case GDK_WINDOW_EDGE_SOUTH_WEST:
2569 winedge = HTBOTTOMLEFT;
2572 case GDK_WINDOW_EDGE_SOUTH:
2576 case GDK_WINDOW_EDGE_SOUTH_EAST:
2578 winedge = HTBOTTOMRIGHT;
2582 DefWindowProcW (GDK_WINDOW_HWND (window), WM_NCLBUTTONDOWN, winedge,
2583 MAKELPARAM (root_x - _gdk_offset_x, root_y - _gdk_offset_y));
2587 gdk_window_begin_move_drag (GdkWindow *window,
2593 g_return_if_fail (GDK_IS_WINDOW (window));
2595 if (GDK_WINDOW_DESTROYED (window))
2598 /* Tell Windows to start interactively moving the window by pretending that
2599 * the left pointer button was clicked in the titlebar. This will only work
2600 * if the button is down when this function is called, and will only work
2601 * with button 1 (left), since Windows only allows window dragging using the
2602 * left mouse button.
2607 /* Must break the automatic grab that occured when the button was pressed,
2608 * otherwise it won't work.
2610 gdk_display_pointer_ungrab (_gdk_display, 0);
2612 DefWindowProcW (GDK_WINDOW_HWND (window), WM_NCLBUTTONDOWN, HTCAPTION,
2613 MAKELPARAM (root_x - _gdk_offset_x, root_y - _gdk_offset_y));
2618 * Setting window states
2621 gdk_window_iconify (GdkWindow *window)
2623 HWND old_active_window;
2625 g_return_if_fail (GDK_IS_WINDOW (window));
2627 if (GDK_WINDOW_DESTROYED (window))
2630 GDK_NOTE (MISC, g_print ("gdk_window_iconify: %p: %s\n",
2631 GDK_WINDOW_HWND (window),
2632 _gdk_win32_window_state_to_string (((GdkWindowObject *) window)->state)));
2634 if (GDK_WINDOW_IS_MAPPED (window))
2636 old_active_window = GetActiveWindow ();
2637 ShowWindow (GDK_WINDOW_HWND (window), SW_MINIMIZE);
2638 if (old_active_window != GDK_WINDOW_HWND (window))
2639 SetActiveWindow (old_active_window);
2643 gdk_synthesize_window_state (window,
2645 GDK_WINDOW_STATE_ICONIFIED);
2650 gdk_window_deiconify (GdkWindow *window)
2652 g_return_if_fail (GDK_IS_WINDOW (window));
2654 if (GDK_WINDOW_DESTROYED (window))
2657 GDK_NOTE (MISC, g_print ("gdk_window_deiconify: %p: %s\n",
2658 GDK_WINDOW_HWND (window),
2659 _gdk_win32_window_state_to_string (((GdkWindowObject *) window)->state)));
2661 if (GDK_WINDOW_IS_MAPPED (window))
2663 show_window_internal (window, FALSE, TRUE);
2667 gdk_synthesize_window_state (window,
2668 GDK_WINDOW_STATE_ICONIFIED,
2674 gdk_window_stick (GdkWindow *window)
2676 g_return_if_fail (GDK_IS_WINDOW (window));
2678 if (GDK_WINDOW_DESTROYED (window))
2681 /* FIXME: Do something? */
2685 gdk_window_unstick (GdkWindow *window)
2687 g_return_if_fail (GDK_IS_WINDOW (window));
2689 if (GDK_WINDOW_DESTROYED (window))
2692 /* FIXME: Do something? */
2696 gdk_window_maximize (GdkWindow *window)
2698 g_return_if_fail (GDK_IS_WINDOW (window));
2700 if (GDK_WINDOW_DESTROYED (window))
2703 GDK_NOTE (MISC, g_print ("gdk_window_maximize: %p: %s\n",
2704 GDK_WINDOW_HWND (window),
2705 _gdk_win32_window_state_to_string (((GdkWindowObject *) window)->state)));
2707 if (GDK_WINDOW_IS_MAPPED (window))
2708 ShowWindow (GDK_WINDOW_HWND (window), SW_MAXIMIZE);
2710 gdk_synthesize_window_state (window,
2712 GDK_WINDOW_STATE_MAXIMIZED);
2716 gdk_window_unmaximize (GdkWindow *window)
2718 g_return_if_fail (GDK_IS_WINDOW (window));
2720 if (GDK_WINDOW_DESTROYED (window))
2723 GDK_NOTE (MISC, g_print ("gdk_window_unmaximize: %p: %s\n",
2724 GDK_WINDOW_HWND (window),
2725 _gdk_win32_window_state_to_string (((GdkWindowObject *) window)->state)));
2727 if (GDK_WINDOW_IS_MAPPED (window))
2728 ShowWindow (GDK_WINDOW_HWND (window), SW_RESTORE);
2730 gdk_synthesize_window_state (window,
2731 GDK_WINDOW_STATE_MAXIMIZED,
2735 typedef struct _FullscreenInfo FullscreenInfo;
2737 struct _FullscreenInfo
2745 gdk_window_fullscreen (GdkWindow *window)
2747 gint x, y, width, height;
2749 GdkWindowObject *private = (GdkWindowObject *) window;
2753 g_return_if_fail (GDK_IS_WINDOW (window));
2755 fi = g_new (FullscreenInfo, 1);
2757 if (!GetWindowRect (GDK_WINDOW_HWND (window), &(fi->r)))
2761 GdkWindowImplWin32 *impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
2763 monitor = MonitorFromWindow (GDK_WINDOW_HWND (window), MONITOR_DEFAULTTONEAREST);
2764 mi.cbSize = sizeof (mi);
2765 if (monitor && GetMonitorInfo (monitor, &mi))
2767 x = mi.rcMonitor.left;
2768 y = mi.rcMonitor.top;
2769 width = mi.rcMonitor.right - x;
2770 height = mi.rcMonitor.bottom - y;
2775 width = GetSystemMetrics (SM_CXSCREEN);
2776 height = GetSystemMetrics (SM_CYSCREEN);
2779 /* remember for restoring */
2780 fi->hint_flags = impl->hint_flags;
2781 impl->hint_flags &= ~GDK_HINT_MAX_SIZE;
2782 g_object_set_data (G_OBJECT (window), "fullscreen-info", fi);
2783 fi->style = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
2785 SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE,
2786 (fi->style & ~WS_OVERLAPPEDWINDOW) | WS_POPUP);
2788 API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), HWND_TOP,
2789 x, y, width, height,
2790 SWP_NOCOPYBITS | SWP_SHOWWINDOW));
2792 gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FULLSCREEN);
2797 gdk_window_unfullscreen (GdkWindow *window)
2800 GdkWindowObject *private = (GdkWindowObject *) window;
2802 g_return_if_fail (GDK_IS_WINDOW (window));
2804 fi = g_object_get_data (G_OBJECT (window), "fullscreen-info");
2807 GdkWindowImplWin32 *impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
2809 impl->hint_flags = fi->hint_flags;
2810 SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE, fi->style);
2811 API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), HWND_NOTOPMOST,
2812 fi->r.left, fi->r.top,
2813 fi->r.right - fi->r.left, fi->r.bottom - fi->r.top,
2814 SWP_NOCOPYBITS | SWP_SHOWWINDOW));
2816 g_object_set_data (G_OBJECT (window), "fullscreen-info", NULL);
2819 gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FULLSCREEN, 0);
2824 gdk_window_set_keep_above (GdkWindow *window,
2827 g_return_if_fail (GDK_IS_WINDOW (window));
2829 if (GDK_WINDOW_DESTROYED (window))
2832 GDK_NOTE (MISC, g_print ("gdk_window_set_keep_above: %p: %s\n",
2833 GDK_WINDOW_HWND (window),
2834 setting ? "YES" : "NO"));
2836 if (GDK_WINDOW_IS_MAPPED (window))
2838 API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window),
2839 setting ? HWND_TOPMOST : HWND_NOTOPMOST,
2841 SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE));
2844 gdk_synthesize_window_state (window,
2845 setting ? GDK_WINDOW_STATE_BELOW : GDK_WINDOW_STATE_ABOVE,
2846 setting ? GDK_WINDOW_STATE_ABOVE : 0);
2850 gdk_window_set_keep_below (GdkWindow *window,
2853 g_return_if_fail (GDK_IS_WINDOW (window));
2855 if (GDK_WINDOW_DESTROYED (window))
2858 GDK_NOTE (MISC, g_print ("gdk_window_set_keep_below: %p: %s\n",
2859 GDK_WINDOW_HWND (window),
2860 setting ? "YES" : "NO"));
2862 if (GDK_WINDOW_IS_MAPPED (window))
2864 API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window),
2865 setting ? HWND_BOTTOM : HWND_NOTOPMOST,
2867 SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE));
2870 gdk_synthesize_window_state (window,
2871 setting ? GDK_WINDOW_STATE_ABOVE : GDK_WINDOW_STATE_BELOW,
2872 setting ? GDK_WINDOW_STATE_BELOW : 0);
2876 gdk_window_focus (GdkWindow *window,
2879 g_return_if_fail (GDK_IS_WINDOW (window));
2881 if (GDK_WINDOW_DESTROYED (window))
2884 GDK_NOTE (MISC, g_print ("gdk_window_focus: %p: %s\n",
2885 GDK_WINDOW_HWND (window),
2886 _gdk_win32_window_state_to_string (((GdkWindowObject *) window)->state)));
2888 if (((GdkWindowObject *) window)->state & GDK_WINDOW_STATE_MAXIMIZED)
2889 ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWMAXIMIZED);
2891 ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWNORMAL);
2892 SetFocus (GDK_WINDOW_HWND (window));
2896 gdk_window_set_modal_hint (GdkWindow *window,
2899 GdkWindowObject *private;
2901 g_return_if_fail (GDK_IS_WINDOW (window));
2903 if (GDK_WINDOW_DESTROYED (window))
2906 GDK_NOTE (MISC, g_print ("gdk_window_set_modal_hint: %p: %s\n",
2907 GDK_WINDOW_HWND (window),
2908 modal ? "YES" : "NO"));
2910 private = (GdkWindowObject*) window;
2912 if (modal == private->modal_hint)
2915 private->modal_hint = modal;
2918 /* Not sure about this one.. -- Cody */
2919 if (GDK_WINDOW_IS_MAPPED (window))
2920 API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window),
2921 modal ? HWND_TOPMOST : HWND_NOTOPMOST,
2923 SWP_NOMOVE | SWP_NOSIZE));
2928 _gdk_push_modal_window (window);
2929 gdk_window_raise (window);
2933 _gdk_remove_modal_window (window);
2940 gdk_window_set_skip_taskbar_hint (GdkWindow *window,
2941 gboolean skips_taskbar)
2943 static GdkWindow *owner = NULL;
2946 g_return_if_fail (GDK_IS_WINDOW (window));
2948 GDK_NOTE (MISC, g_print ("gdk_window_set_skip_taskbar_hint: %p: %s, doing nothing\n",
2949 GDK_WINDOW_HWND (window),
2950 skips_taskbar ? "YES" : "NO"));
2952 // ### TODO: Need to figure out what to do here.
2960 wa.window_type = GDK_WINDOW_TEMP;
2961 wa.wclass = GDK_INPUT_OUTPUT;
2962 wa.width = wa.height = 1;
2964 owner = gdk_window_new_internal (NULL, &wa, 0, TRUE);
2968 SetWindowLongPtr (GDK_WINDOW_HWND (window), GWLP_HWNDPARENT, (LONG_PTR) GDK_WINDOW_HWND (owner));
2970 #if 0 /* Should we also turn off the minimize and maximize buttons? */
2971 SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE,
2972 GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE) & ~(WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_SYSMENU));
2974 SetWindowPos (GDK_WINDOW_HWND (window), NULL,
2976 SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE |
2977 SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER);
2982 SetWindowLongPtr (GDK_WINDOW_HWND (window), GWLP_HWNDPARENT, 0);
2987 gdk_window_set_skip_pager_hint (GdkWindow *window,
2988 gboolean skips_pager)
2990 g_return_if_fail (GDK_IS_WINDOW (window));
2992 GDK_NOTE (MISC, g_print ("gdk_window_set_skip_pager_hint: %p: %s, doing nothing\n",
2993 GDK_WINDOW_HWND (window),
2994 skips_pager ? "YES" : "NO"));
2998 gdk_window_set_type_hint (GdkWindow *window,
2999 GdkWindowTypeHint hint)
3001 g_return_if_fail (GDK_IS_WINDOW (window));
3003 if (GDK_WINDOW_DESTROYED (window))
3008 static GEnumClass *class = NULL;
3010 class = g_type_class_ref (GDK_TYPE_WINDOW_TYPE_HINT);
3011 g_print ("gdk_window_set_type_hint: %p: %s\n",
3012 GDK_WINDOW_HWND (window),
3013 g_enum_get_value (class, hint)->value_name);
3016 ((GdkWindowImplWin32 *)((GdkWindowObject *)window)->impl)->type_hint = hint;
3018 update_style_bits (window);
3022 gdk_window_get_type_hint (GdkWindow *window)
3024 g_return_val_if_fail (GDK_IS_WINDOW (window), GDK_WINDOW_TYPE_HINT_NORMAL);
3026 if (GDK_WINDOW_DESTROYED (window))
3027 return GDK_WINDOW_TYPE_HINT_NORMAL;
3029 return GDK_WINDOW_IMPL_WIN32 (((GdkWindowObject *) window)->impl)->type_hint;
3033 cairo_region_to_hrgn (const cairo_region_t *region,
3040 cairo_rectangle_int_t r;
3041 const int nrects = cairo_region_num_rectangles (region);
3043 sizeof (RGNDATAHEADER) + (sizeof (RECT) * nrects);
3046 rgndata = g_malloc (nbytes);
3047 rgndata->rdh.dwSize = sizeof (RGNDATAHEADER);
3048 rgndata->rdh.iType = RDH_RECTANGLES;
3049 rgndata->rdh.nCount = rgndata->rdh.nRgnSize = 0;
3050 SetRect (&rgndata->rdh.rcBound,
3051 G_MAXLONG, G_MAXLONG, G_MINLONG, G_MINLONG);
3053 for (i = 0; i < nrects; i++)
3055 rect = ((RECT *) rgndata->Buffer) + rgndata->rdh.nCount++;
3057 cairo_region_get_rectangle (region, i, &r);
3058 rect->left = r.x + x_origin;
3059 rect->right = rect->left + r.width;
3060 rect->top = r.y + y_origin;
3061 rect->bottom = rect->top + r.height;
3063 if (rect->left < rgndata->rdh.rcBound.left)
3064 rgndata->rdh.rcBound.left = rect->left;
3065 if (rect->right > rgndata->rdh.rcBound.right)
3066 rgndata->rdh.rcBound.right = rect->right;
3067 if (rect->top < rgndata->rdh.rcBound.top)
3068 rgndata->rdh.rcBound.top = rect->top;
3069 if (rect->bottom > rgndata->rdh.rcBound.bottom)
3070 rgndata->rdh.rcBound.bottom = rect->bottom;
3072 if ((hrgn = ExtCreateRegion (NULL, nbytes, rgndata)) == NULL)
3073 WIN32_API_FAILED ("ExtCreateRegion");
3081 gdk_win32_window_shape_combine_region (GdkWindow *window,
3082 const cairo_region_t *shape_region,
3086 if (GDK_WINDOW_DESTROYED (window))
3091 GDK_NOTE (MISC, g_print ("gdk_win32_window_shape_combine_region: %p: none\n",
3092 GDK_WINDOW_HWND (window)));
3093 SetWindowRgn (GDK_WINDOW_HWND (window), NULL, TRUE);
3099 hrgn = cairo_region_to_hrgn (shape_region, 0, 0);
3101 GDK_NOTE (MISC, g_print ("gdk_win32_window_shape_combine_region: %p: %p\n",
3102 GDK_WINDOW_HWND (window),
3105 do_shape_combine_region (window, hrgn, offset_x, offset_y);
3110 gdk_window_lookup_for_display (GdkDisplay *display,
3111 GdkNativeWindow anid)
3113 g_return_val_if_fail (display == _gdk_display, NULL);
3115 return gdk_window_lookup (anid);
3119 gdk_window_enable_synchronized_configure (GdkWindow *window)
3121 g_return_if_fail (GDK_IS_WINDOW (window));
3125 gdk_window_configure_finished (GdkWindow *window)
3127 g_return_if_fail (GDK_IS_WINDOW (window));
3131 _gdk_windowing_window_beep (GdkWindow *window)
3133 gdk_display_beep (_gdk_display);
3137 gdk_window_set_opacity (GdkWindow *window,
3141 typedef BOOL (*PFN_SetLayeredWindowAttributes) (HWND, COLORREF, BYTE, DWORD);
3142 PFN_SetLayeredWindowAttributes setLayeredWindowAttributes = NULL;
3144 g_return_if_fail (GDK_IS_WINDOW (window));
3145 g_return_if_fail (WINDOW_IS_TOPLEVEL (window));
3147 if (GDK_WINDOW_DESTROYED (window))
3152 else if (opacity > 1)
3155 exstyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE);
3157 if (!(exstyle & WS_EX_LAYERED))
3158 API_CALL (SetWindowLong, (GDK_WINDOW_HWND (window),
3160 exstyle | WS_EX_LAYERED));
3162 setLayeredWindowAttributes =
3163 (PFN_SetLayeredWindowAttributes)GetProcAddress (GetModuleHandle ("user32.dll"), "SetLayeredWindowAttributes");
3165 if (setLayeredWindowAttributes)
3167 API_CALL (setLayeredWindowAttributes, (GDK_WINDOW_HWND (window),
3175 _gdk_windowing_window_set_composited (GdkWindow *window, gboolean composited)
3180 _gdk_windowing_window_get_shape (GdkWindow *window)
3182 HRGN hrgn = CreateRectRgn (0, 0, 0, 0);
3183 int type = GetWindowRgn (GDK_WINDOW_HWND (window), hrgn);
3185 if (type == SIMPLEREGION || type == COMPLEXREGION)
3187 cairo_region_t *region = _gdk_win32_hrgn_to_region (hrgn);
3189 DeleteObject (hrgn);
3197 _gdk_windowing_window_get_input_shape (GdkWindow *window)
3199 /* CHECK: are these really supposed to be the same? */
3200 return _gdk_windowing_window_get_shape (window);
3204 _gdk_win32_window_queue_antiexpose (GdkWindow *window,
3205 cairo_region_t *area)
3207 HRGN hrgn = cairo_region_to_hrgn (area, 0, 0);
3209 GDK_NOTE (EVENTS, g_print ("_gdk_windowing_window_queue_antiexpose: ValidateRgn %p %s\n",
3210 GDK_WINDOW_HWND (window),
3211 _gdk_win32_cairo_region_to_string (area)));
3213 ValidateRgn (GDK_WINDOW_HWND (window), hrgn);
3215 DeleteObject (hrgn);
3220 /* FIXME: Tis function has never been compiled.
3221 * Please make it work. */
3223 _gdk_win32_window_translate (GdkWindow *window,
3224 cairo_region_t *area,
3228 HRGN hrgn = CreateRectRgn (0, 0, 0, 0);
3231 GdkRectangle extents;
3233 cairo_region_get_extents (area, &extents);
3234 hdc = _gdk_win32_drawable_acquire_dc (GDK_DRAWABLE (window));
3235 GDI_CALL (BitBlt, (hdc, extents.x, extents.y, extents.width, extents.height,
3236 hdc, extents.x + dx, extents.y + dy, SRCCOPY));
3238 /* XXX: We probably need to get invalidations for the whole extents and not
3239 * just the area as we BitBlt */
3240 ret = GetUpdateRgn (GDK_WINDOW_HWND (window), hrgn, FALSE);
3242 WIN32_API_FAILED ("GetUpdateRgn");
3243 else if (ret != NULLREGION)
3245 /* Get current updateregion, move any part of it that intersects area by dx,dy */
3246 HRGN update = cairo_region_to_hrgn (area, 0, 0);
3247 ret = CombineRgn (update, hrgn, update, RGN_AND);
3249 WIN32_API_FAILED ("CombineRgn");
3250 else if (ret != NULLREGION)
3252 OffsetRgn (update, dx, dy);
3253 API_CALL (InvalidateRgn, (GDK_WINDOW_HWND (window), update, TRUE));
3255 DeleteObject (update);
3257 DeleteObject (hrgn);
3261 gdk_win32_input_shape_combine_region (GdkWindow *window,
3262 const cairo_region_t *shape_region,
3266 if (GDK_WINDOW_DESTROYED (window))
3268 /* CHECK: are these really supposed to be the same? */
3269 gdk_win32_window_shape_combine_region (window, shape_region, offset_x, offset_y);
3273 _gdk_windowing_window_process_updates_recurse (GdkWindow *window,
3274 cairo_region_t *region)
3276 _gdk_window_process_updates_recurse (window, region);
3280 _gdk_windowing_before_process_all_updates (void)
3285 _gdk_windowing_after_process_all_updates (void)
3290 gdk_window_impl_iface_init (GdkWindowImplIface *iface)
3292 iface->show = gdk_win32_window_show;
3293 iface->hide = gdk_win32_window_hide;
3294 iface->withdraw = gdk_win32_window_withdraw;
3295 iface->set_events = gdk_win32_window_set_events;
3296 iface->get_events = gdk_win32_window_get_events;
3297 iface->raise = gdk_win32_window_raise;
3298 iface->lower = gdk_win32_window_lower;
3299 iface->restack_under = gdk_win32_window_restack_under;
3300 iface->restack_toplevel = gdk_win32_window_restack_toplevel;
3301 iface->move_resize = gdk_win32_window_move_resize;
3302 iface->set_background = gdk_win32_window_set_background;
3303 iface->reparent = gdk_win32_window_reparent;
3304 iface->set_device_cursor = gdk_win32_window_set_device_cursor;
3305 iface->get_geometry = gdk_win32_window_get_geometry;
3306 iface->get_device_state = gdk_window_win32_get_device_state;
3307 iface->get_root_coords = gdk_win32_window_get_root_coords;
3308 iface->shape_combine_region = gdk_win32_window_shape_combine_region;
3309 iface->input_shape_combine_region = gdk_win32_input_shape_combine_region;
3310 iface->set_static_gravities = gdk_win32_window_set_static_gravities;
3311 iface->queue_antiexpose = _gdk_win32_window_queue_antiexpose;
3312 iface->translate = _gdk_win32_window_translate;
3313 iface->destroy = _gdk_win32_window_destroy;
3314 iface->resize_cairo_surface = gdk_win32_window_resize_cairo_surface;
3318 gdk_win32_window_is_win32 (GdkWindow *window)
3320 return GDK_WINDOW_IS_WIN32 (window);