1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
28 #include <X11/Xutil.h>
29 #include <X11/Xatom.h>
30 #include <netinet/in.h>
34 #include "gdkwindow.h"
35 #include "gdkinputprivate.h"
36 #include "gdkprivate-x11.h"
37 #include "gdkregion.h"
38 #include "gdkinternals.h"
40 #include "gdkwindow-x11.h"
48 #include <X11/extensions/shape.h>
51 const int gdk_event_mask_table[21] =
55 PointerMotionHintMask,
72 SubstructureNotifyMask,
73 ButtonPressMask /* SCROLL; on X mouse wheel events is treated as mouse button 4/5 */
75 const int gdk_nevent_masks = sizeof (gdk_event_mask_table) / sizeof (int);
77 /* Forward declarations */
78 static gboolean gdk_window_gravity_works (void);
79 static void gdk_window_set_static_win_gravity (GdkWindow *window,
81 static gboolean gdk_window_have_shape_ext (void);
82 static gboolean gdk_window_icon_name_set (GdkWindow *window);
84 static GdkColormap* gdk_window_impl_x11_get_colormap (GdkDrawable *drawable);
85 static void gdk_window_impl_x11_set_colormap (GdkDrawable *drawable,
87 static void gdk_window_impl_x11_get_size (GdkDrawable *drawable,
90 static GdkRegion* gdk_window_impl_x11_get_visible_region (GdkDrawable *drawable);
91 static void gdk_window_impl_x11_init (GdkWindowImplX11 *window);
92 static void gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass);
93 static void gdk_window_impl_x11_finalize (GObject *object);
95 static gpointer parent_class = NULL;
98 gdk_window_impl_x11_get_type (void)
100 static GType object_type = 0;
104 static const GTypeInfo object_info =
106 sizeof (GdkWindowImplX11Class),
107 (GBaseInitFunc) NULL,
108 (GBaseFinalizeFunc) NULL,
109 (GClassInitFunc) gdk_window_impl_x11_class_init,
110 NULL, /* class_finalize */
111 NULL, /* class_data */
112 sizeof (GdkWindowImplX11),
114 (GInstanceInitFunc) gdk_window_impl_x11_init,
117 object_type = g_type_register_static (GDK_TYPE_DRAWABLE_IMPL_X11,
126 _gdk_window_impl_get_type (void)
128 return gdk_window_impl_x11_get_type ();
132 gdk_window_impl_x11_init (GdkWindowImplX11 *impl)
139 gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass)
141 GObjectClass *object_class = G_OBJECT_CLASS (klass);
142 GdkDrawableClass *drawable_class = GDK_DRAWABLE_CLASS (klass);
144 parent_class = g_type_class_peek_parent (klass);
146 object_class->finalize = gdk_window_impl_x11_finalize;
148 drawable_class->set_colormap = gdk_window_impl_x11_set_colormap;
149 drawable_class->get_colormap = gdk_window_impl_x11_get_colormap;
150 drawable_class->get_size = gdk_window_impl_x11_get_size;
152 /* Visible and clip regions are the same */
153 drawable_class->get_clip_region = gdk_window_impl_x11_get_visible_region;
154 drawable_class->get_visible_region = gdk_window_impl_x11_get_visible_region;
158 gdk_window_impl_x11_finalize (GObject *object)
160 GdkWindowObject *wrapper;
161 GdkDrawableImplX11 *draw_impl;
162 GdkWindowImplX11 *window_impl;
164 g_return_if_fail (GDK_IS_WINDOW_IMPL_X11 (object));
166 draw_impl = GDK_DRAWABLE_IMPL_X11 (object);
167 window_impl = GDK_WINDOW_IMPL_X11 (object);
169 wrapper = (GdkWindowObject*) draw_impl->wrapper;
171 if (!GDK_WINDOW_DESTROYED (wrapper))
173 gdk_xid_table_remove (draw_impl->xid);
174 if (window_impl->focus_window)
175 gdk_xid_table_remove (window_impl->focus_window);
178 G_OBJECT_CLASS (parent_class)->finalize (object);
182 gdk_window_impl_x11_get_colormap (GdkDrawable *drawable)
184 GdkDrawableImplX11 *drawable_impl;
185 GdkWindowImplX11 *window_impl;
187 g_return_val_if_fail (GDK_IS_WINDOW_IMPL_X11 (drawable), NULL);
189 drawable_impl = GDK_DRAWABLE_IMPL_X11 (drawable);
190 window_impl = GDK_WINDOW_IMPL_X11 (drawable);
192 if (!((GdkWindowObject *) drawable_impl->wrapper)->input_only &&
193 drawable_impl->colormap == NULL)
195 XWindowAttributes window_attributes;
197 XGetWindowAttributes (drawable_impl->xdisplay,
200 drawable_impl->colormap =
201 gdk_colormap_lookup (window_attributes.colormap);
204 return drawable_impl->colormap;
208 gdk_window_impl_x11_set_colormap (GdkDrawable *drawable,
211 GdkWindowImplX11 *impl;
212 GdkDrawableImplX11 *draw_impl;
214 g_return_if_fail (GDK_IS_WINDOW_IMPL_X11 (drawable));
216 impl = GDK_WINDOW_IMPL_X11 (drawable);
217 draw_impl = GDK_DRAWABLE_IMPL_X11 (drawable);
220 GDK_DRAWABLE_CLASS (parent_class)->set_colormap (drawable, cmap);
224 XSetWindowColormap (draw_impl->xdisplay,
226 GDK_COLORMAP_XCOLORMAP (cmap));
228 if (((GdkWindowObject*)draw_impl->wrapper)->window_type !=
230 gdk_window_add_colormap_windows (GDK_WINDOW (draw_impl->wrapper));
236 gdk_window_impl_x11_get_size (GdkDrawable *drawable,
240 g_return_if_fail (GDK_IS_WINDOW_IMPL_X11 (drawable));
243 *width = GDK_WINDOW_IMPL_X11 (drawable)->width;
245 *height = GDK_WINDOW_IMPL_X11 (drawable)->height;
249 gdk_window_impl_x11_get_visible_region (GdkDrawable *drawable)
251 GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (drawable);
252 GdkRectangle result_rect;
256 result_rect.width = impl->width;
257 result_rect.height = impl->height;
259 gdk_rectangle_intersect (&result_rect, &impl->position_info.clip_rect, &result_rect);
261 return gdk_region_rectangle (&result_rect);
265 _gdk_windowing_window_init (void)
267 GdkWindowObject *private;
268 GdkWindowImplX11 *impl;
269 GdkDrawableImplX11 *draw_impl;
270 XWindowAttributes xattributes;
273 unsigned int border_width;
277 g_assert (gdk_parent_root == NULL);
279 XGetGeometry (gdk_display, gdk_root_window, &gdk_root_window,
280 &x, &y, &width, &height, &border_width, &depth);
281 XGetWindowAttributes (gdk_display, gdk_root_window, &xattributes);
283 gdk_parent_root = g_object_new (GDK_TYPE_WINDOW, NULL);
284 private = (GdkWindowObject *)gdk_parent_root;
285 impl = GDK_WINDOW_IMPL_X11 (private->impl);
286 draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl);
288 draw_impl->xdisplay = gdk_display;
289 draw_impl->xid = gdk_root_window;
290 draw_impl->wrapper = GDK_DRAWABLE (private);
292 private->window_type = GDK_WINDOW_ROOT;
293 private->depth = depth;
295 impl->height = height;
297 gdk_xid_table_insert (&gdk_root_window, gdk_parent_root);
300 static GdkAtom wm_client_leader_atom = GDK_NONE;
303 gdk_window_new (GdkWindow *parent,
304 GdkWindowAttr *attributes,
305 gint attributes_mask)
308 GdkWindowObject *private;
309 GdkWindowObject *parent_private;
310 GdkWindowImplX11 *impl;
311 GdkDrawableImplX11 *draw_impl;
319 XSetWindowAttributes xattributes;
320 long xattributes_mask;
321 XSizeHints size_hints;
323 XClassHint *class_hint;
330 g_return_val_if_fail (attributes != NULL, NULL);
333 parent = gdk_parent_root;
335 g_return_val_if_fail (GDK_IS_WINDOW (parent), NULL);
337 parent_private = (GdkWindowObject*) parent;
338 if (GDK_WINDOW_DESTROYED (parent))
341 xparent = GDK_WINDOW_XID (parent);
343 window = g_object_new (GDK_TYPE_WINDOW, NULL);
344 private = (GdkWindowObject *)window;
345 impl = GDK_WINDOW_IMPL_X11 (private->impl);
346 draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl);
347 draw_impl->wrapper = GDK_DRAWABLE (window);
349 xdisplay = draw_impl->xdisplay = GDK_WINDOW_XDISPLAY (parent);
351 private->parent = (GdkWindowObject *)parent;
353 xattributes_mask = 0;
355 if (attributes_mask & GDK_WA_X)
360 if (attributes_mask & GDK_WA_Y)
367 impl->width = (attributes->width > 1) ? (attributes->width) : (1);
368 impl->height = (attributes->height > 1) ? (attributes->height) : (1);
370 if (attributes->wclass == GDK_INPUT_ONLY)
372 /* Backwards compatiblity - we've always ignored
373 * attributes->window_type for input-only windows
376 if (GDK_WINDOW_TYPE (parent) == GDK_WINDOW_ROOT &&
377 GDK_WINDOW_TYPE (parent) == GDK_WINDOW_FOREIGN)
378 private->window_type = GDK_WINDOW_TEMP;
380 private->window_type = GDK_WINDOW_CHILD;
383 private->window_type = attributes->window_type;
385 _gdk_window_init_position (GDK_WINDOW (private));
386 if (impl->position_info.big)
387 private->guffaw_gravity = TRUE;
389 if (attributes_mask & GDK_WA_VISUAL)
390 visual = attributes->visual;
392 visual = gdk_visual_get_system ();
393 xvisual = ((GdkVisualPrivate*) visual)->xvisual;
395 xattributes.event_mask = StructureNotifyMask;
396 for (i = 0; i < gdk_nevent_masks; i++)
398 if (attributes->event_mask & (1 << (i + 1)))
399 xattributes.event_mask |= gdk_event_mask_table[i];
402 if (xattributes.event_mask)
403 xattributes_mask |= CWEventMask;
405 if (attributes_mask & GDK_WA_NOREDIR)
407 xattributes.override_redirect =
408 (attributes->override_redirect == FALSE)?False:True;
409 xattributes_mask |= CWOverrideRedirect;
412 xattributes.override_redirect = False;
414 if (parent_private && parent_private->guffaw_gravity)
416 xattributes.win_gravity = StaticGravity;
417 xattributes_mask |= CWWinGravity;
421 switch (private->window_type)
423 case GDK_WINDOW_TOPLEVEL:
424 case GDK_WINDOW_DIALOG:
425 case GDK_WINDOW_TEMP:
426 if (GDK_WINDOW_TYPE (parent) != GDK_WINDOW_ROOT &&
427 GDK_WINDOW_TYPE (parent) != GDK_WINDOW_FOREIGN)
429 g_warning (G_STRLOC "Toplevel windows must be created as children of\n"
430 "of a window of type GDK_WINDOW_ROOT or GDK_WINDOW_FOREIGN");
431 xparent = gdk_root_window;
433 case GDK_WINDOW_CHILD:
436 g_warning (G_STRLOC "cannot make windows of type %d", private->window_type);
440 if (attributes->wclass == GDK_INPUT_OUTPUT)
443 depth = visual->depth;
445 private->input_only = FALSE;
446 private->depth = depth;
448 if (attributes_mask & GDK_WA_COLORMAP)
450 draw_impl->colormap = attributes->colormap;
451 gdk_colormap_ref (attributes->colormap);
455 if ((((GdkVisualPrivate*)gdk_visual_get_system ())->xvisual) == xvisual)
457 draw_impl->colormap =
458 gdk_colormap_get_system ();
459 gdk_colormap_ref (draw_impl->colormap);
463 draw_impl->colormap =
464 gdk_colormap_new (visual, FALSE);
468 private->bg_color.pixel = BlackPixel (gdk_display, gdk_screen);
469 xattributes.background_pixel = private->bg_color.pixel;
471 private->bg_pixmap = NULL;
473 xattributes.border_pixel = BlackPixel (gdk_display, gdk_screen);
474 xattributes_mask |= CWBorderPixel | CWBackPixel;
476 if (private->guffaw_gravity)
477 xattributes.bit_gravity = StaticGravity;
479 xattributes.bit_gravity = NorthWestGravity;
481 xattributes_mask |= CWBitGravity;
483 xattributes.colormap = GDK_COLORMAP_XCOLORMAP (draw_impl->colormap);
484 xattributes_mask |= CWColormap;
486 if (private->window_type == GDK_WINDOW_TEMP)
488 xattributes.save_under = True;
489 xattributes.override_redirect = True;
490 xattributes.cursor = None;
491 xattributes_mask |= CWSaveUnder | CWOverrideRedirect;
499 private->input_only = TRUE;
500 draw_impl->colormap = gdk_colormap_get_system ();
501 gdk_colormap_ref (draw_impl->colormap);
504 xid = draw_impl->xid = XCreateWindow (xdisplay, xparent,
505 impl->position_info.x, impl->position_info.y,
506 impl->position_info.width, impl->position_info.height,
507 0, depth, class, xvisual,
508 xattributes_mask, &xattributes);
510 gdk_drawable_ref (window);
511 gdk_xid_table_insert (&draw_impl->xid, window);
513 gdk_window_set_cursor (window, ((attributes_mask & GDK_WA_CURSOR) ?
514 (attributes->cursor) :
518 parent_private->children = g_list_prepend (parent_private->children, window);
520 switch (GDK_WINDOW_TYPE (private))
522 case GDK_WINDOW_DIALOG:
523 XSetTransientForHint (xdisplay, xid, xparent);
524 case GDK_WINDOW_TOPLEVEL:
525 case GDK_WINDOW_TEMP:
526 XSetWMProtocols (xdisplay, xid,
527 gdk_wm_window_protocols, 3);
529 case GDK_WINDOW_CHILD:
530 if ((attributes->wclass == GDK_INPUT_OUTPUT) &&
531 (draw_impl->colormap != gdk_colormap_get_system ()) &&
532 (draw_impl->colormap != gdk_window_get_colormap (gdk_window_get_toplevel (window))))
534 GDK_NOTE (MISC, g_message ("adding colormap window\n"));
535 gdk_window_add_colormap_windows (window);
544 if (class != InputOnly)
546 /* The focus window is off the visible area, and serves to receive key
547 * press events so they don't get sent to child windows.
549 impl->focus_window = XCreateSimpleWindow (xdisplay, xid,
551 xattributes.background_pixel,
552 xattributes.background_pixel);
553 /* FIXME: probably better to actually track the requested event mask for the toplevel
555 XSelectInput (xdisplay, impl->focus_window,
556 KeyPressMask | KeyReleaseMask | FocusChangeMask);
558 XMapWindow (xdisplay, impl->focus_window);
559 gdk_xid_table_insert (&impl->focus_window, window);
562 size_hints.flags = PSize;
563 size_hints.width = impl->width;
564 size_hints.height = impl->height;
566 wm_hints.flags = StateHint | WindowGroupHint;
567 wm_hints.window_group = gdk_leader_window;
568 wm_hints.input = True;
569 wm_hints.initial_state = NormalState;
571 /* FIXME: Is there any point in doing this? Do any WM's pay
572 * attention to PSize, and even if they do, is this the
575 XSetWMNormalHints (xdisplay, xid, &size_hints);
577 XSetWMHints (xdisplay, xid, &wm_hints);
579 if (!wm_client_leader_atom)
580 wm_client_leader_atom = gdk_atom_intern ("WM_CLIENT_LEADER", FALSE);
582 XChangeProperty (xdisplay, xid,
583 wm_client_leader_atom,
584 XA_WINDOW, 32, PropModeReplace,
585 (guchar*) &gdk_leader_window, 1);
587 if (attributes_mask & GDK_WA_TITLE)
588 title = attributes->title;
590 title = g_get_prgname ();
592 gdk_window_set_title (window, title);
594 if (attributes_mask & GDK_WA_WMCLASS)
596 class_hint = XAllocClassHint ();
597 class_hint->res_name = attributes->wmclass_name;
598 class_hint->res_class = attributes->wmclass_class;
599 XSetClassHint (xdisplay, xid, class_hint);
607 gdk_window_foreign_new (GdkNativeWindow anid)
610 GdkWindowObject *private;
611 GdkWindowObject *parent_private;
612 GdkWindowImplX11 *impl;
613 GdkDrawableImplX11 *draw_impl;
614 XWindowAttributes attrs;
616 Window *children = NULL;
620 gdk_error_trap_push ();
621 result = XGetWindowAttributes (gdk_display, anid, &attrs);
622 if (gdk_error_trap_pop () || !result)
625 /* FIXME: This is pretty expensive. Maybe the caller should supply
627 gdk_error_trap_push ();
628 result = XQueryTree (gdk_display, anid, &root, &parent, &children, &nchildren);
629 if (gdk_error_trap_pop () || !result)
635 window = g_object_new (GDK_TYPE_WINDOW, NULL);
636 private = (GdkWindowObject *)window;
637 impl = GDK_WINDOW_IMPL_X11 (private->impl);
638 draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl);
639 draw_impl->wrapper = GDK_DRAWABLE (window);
641 private->parent = gdk_xid_table_lookup (parent);
643 parent_private = (GdkWindowObject *)private->parent;
646 parent_private->children = g_list_prepend (parent_private->children, window);
648 draw_impl->xid = anid;
649 draw_impl->xdisplay = gdk_display;
651 private->x = attrs.x;
652 private->y = attrs.y;
653 impl->width = attrs.width;
654 impl->height = attrs.height;
655 private->window_type = GDK_WINDOW_FOREIGN;
656 private->destroyed = FALSE;
658 if (attrs.map_state == IsUnmapped)
659 private->state = GDK_WINDOW_STATE_WITHDRAWN;
663 private->depth = attrs.depth;
665 _gdk_window_init_position (GDK_WINDOW (private));
667 gdk_drawable_ref (window);
668 gdk_xid_table_insert (&GDK_WINDOW_XID (window), window);
674 _gdk_windowing_window_destroy (GdkWindow *window,
676 gboolean foreign_destroy)
678 GdkWindowObject *private = (GdkWindowObject *)window;
680 g_return_if_fail (GDK_IS_WINDOW (window));
682 _gdk_selection_window_destroyed (window);
684 if (private->extension_events != 0)
685 gdk_input_window_destroy (window);
687 if (private->window_type == GDK_WINDOW_FOREIGN)
689 if (!foreign_destroy && (private->parent != NULL))
691 /* It's somebody else's window, but in our heirarchy,
692 * so reparent it to the root window, and then send
693 * it a delete event, as if we were a WM
695 XClientMessageEvent xevent;
697 gdk_error_trap_push ();
698 gdk_window_hide (window);
699 gdk_window_reparent (window, NULL, 0, 0);
701 xevent.type = ClientMessage;
702 xevent.window = GDK_WINDOW_XID (window);
703 xevent.message_type = gdk_wm_protocols;
705 xevent.data.l[0] = gdk_wm_delete_window;
706 xevent.data.l[1] = CurrentTime;
708 XSendEvent (GDK_WINDOW_XDISPLAY (window),
709 GDK_WINDOW_XID (window),
710 False, 0, (XEvent *)&xevent);
712 gdk_error_trap_pop ();
715 else if (!recursing && !foreign_destroy)
716 XDestroyWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
719 /* This function is called when the XWindow is really gone.
722 gdk_window_destroy_notify (GdkWindow *window)
724 GdkWindowImplX11 *window_impl;
726 g_return_if_fail (window != NULL);
728 window_impl = GDK_WINDOW_IMPL_X11 (((GdkWindowObject *)window)->impl);
730 if (!GDK_WINDOW_DESTROYED (window))
732 if (GDK_WINDOW_TYPE(window) != GDK_WINDOW_FOREIGN)
733 g_warning ("GdkWindow %#lx unexpectedly destroyed", GDK_WINDOW_XID (window));
735 _gdk_window_destroy (window, TRUE);
738 gdk_xid_table_remove (GDK_WINDOW_XID (window));
739 if (window_impl->focus_window)
740 gdk_xid_table_remove (window_impl->focus_window);
742 gdk_drawable_unref (window);
746 set_initial_hints (GdkWindow *window)
748 GdkWindowObject *private;
752 private = (GdkWindowObject*) window;
754 if (private->state & GDK_WINDOW_STATE_ICONIFIED)
758 wm_hints = XGetWMHints (GDK_WINDOW_XDISPLAY (window),
759 GDK_WINDOW_XID (window));
761 wm_hints = XAllocWMHints ();
763 wm_hints->flags |= StateHint;
764 wm_hints->initial_state = IconicState;
766 XSetWMHints (GDK_WINDOW_XDISPLAY (window),
767 GDK_WINDOW_XID (window), wm_hints);
771 /* We set the spec hints regardless of whether the spec is supported,
772 * since it can't hurt and it's kind of expensive to check whether
778 if (private->state & GDK_WINDOW_STATE_MAXIMIZED)
780 atoms[i] = gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_VERT", FALSE);
782 atoms[i] = gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_HORZ", FALSE);
786 if (private->state & GDK_WINDOW_STATE_STICKY)
788 atoms[i] = gdk_atom_intern ("_NET_WM_STATE_STICKY", FALSE);
792 if (private->modal_hint)
794 atoms[i] = gdk_atom_intern ("_NET_WM_STATE_MODAL", FALSE);
800 XChangeProperty (GDK_WINDOW_XDISPLAY (window),
801 GDK_WINDOW_XID (window),
802 gdk_atom_intern ("_NET_WM_STATE", FALSE),
803 XA_ATOM, 32, PropModeReplace,
807 if (private->state & GDK_WINDOW_STATE_STICKY)
809 atoms[0] = 0xFFFFFFFF;
810 XChangeProperty (GDK_WINDOW_XDISPLAY (window),
811 GDK_WINDOW_XID (window),
812 gdk_atom_intern ("_NET_WM_DESKTOP", FALSE),
813 XA_CARDINAL, 32, PropModeReplace,
819 show_window_internal (GdkWindow *window,
822 GdkWindowObject *private;
824 g_return_if_fail (GDK_IS_WINDOW (window));
826 private = (GdkWindowObject*) window;
827 if (!private->destroyed)
830 XRaiseWindow (GDK_WINDOW_XDISPLAY (window),
831 GDK_WINDOW_XID (window));
833 if (!GDK_WINDOW_IS_MAPPED (window))
835 set_initial_hints (window);
837 gdk_synthesize_window_state (window,
838 GDK_WINDOW_STATE_WITHDRAWN,
842 g_assert (GDK_WINDOW_IS_MAPPED (window));
844 if (GDK_WINDOW_IMPL_X11 (private->impl)->position_info.mapped)
845 XMapWindow (GDK_WINDOW_XDISPLAY (window),
846 GDK_WINDOW_XID (window));
851 * gdk_window_show_unraised:
852 * @window: a #GdkWindow
854 * Shows a #GdkWindow onscreen, but does not modify its stacking
855 * order. In contrast, gdk_window_show() will raise the window
856 * to the top of the window stack.
860 gdk_window_show_unraised (GdkWindow *window)
862 g_return_if_fail (GDK_IS_WINDOW (window));
864 show_window_internal (window, FALSE);
868 gdk_window_show (GdkWindow *window)
870 g_return_if_fail (GDK_IS_WINDOW (window));
872 show_window_internal (window, TRUE);
876 gdk_window_hide (GdkWindow *window)
878 GdkWindowObject *private;
880 g_return_if_fail (window != NULL);
882 private = (GdkWindowObject*) window;
884 /* You can't simply unmap toplevel windows. */
885 switch (private->window_type)
887 case GDK_WINDOW_TOPLEVEL:
888 case GDK_WINDOW_DIALOG:
889 case GDK_WINDOW_TEMP: /* ? */
890 gdk_window_withdraw (window);
894 case GDK_WINDOW_FOREIGN:
895 case GDK_WINDOW_ROOT:
896 case GDK_WINDOW_CHILD:
900 if (!private->destroyed)
902 if (GDK_WINDOW_IS_MAPPED (window))
903 gdk_synthesize_window_state (window,
905 GDK_WINDOW_STATE_WITHDRAWN);
907 g_assert (!GDK_WINDOW_IS_MAPPED (window));
909 _gdk_window_clear_update_area (window);
911 XUnmapWindow (GDK_WINDOW_XDISPLAY (window),
912 GDK_WINDOW_XID (window));
917 gdk_window_withdraw (GdkWindow *window)
919 GdkWindowObject *private;
921 g_return_if_fail (window != NULL);
923 private = (GdkWindowObject*) window;
924 if (!private->destroyed)
926 if (GDK_WINDOW_IS_MAPPED (window))
927 gdk_synthesize_window_state (window,
929 GDK_WINDOW_STATE_WITHDRAWN);
931 g_assert (!GDK_WINDOW_IS_MAPPED (window));
933 XWithdrawWindow (GDK_WINDOW_XDISPLAY (window),
934 GDK_WINDOW_XID (window), 0);
939 gdk_window_move (GdkWindow *window,
943 GdkWindowObject *private = (GdkWindowObject *)window;
944 GdkWindowImplX11 *impl;
946 g_return_if_fail (window != NULL);
947 g_return_if_fail (GDK_IS_WINDOW (window));
949 impl = GDK_WINDOW_IMPL_X11 (private->impl);
951 if (!GDK_WINDOW_DESTROYED (window))
953 if (GDK_WINDOW_TYPE (private) == GDK_WINDOW_CHILD)
954 _gdk_window_move_resize_child (window, x, y,
955 impl->width, impl->height);
958 XMoveWindow (GDK_WINDOW_XDISPLAY (window),
959 GDK_WINDOW_XID (window),
966 gdk_window_resize (GdkWindow *window,
970 GdkWindowObject *private;
972 g_return_if_fail (window != NULL);
973 g_return_if_fail (GDK_IS_WINDOW (window));
980 private = (GdkWindowObject*) window;
982 if (!GDK_WINDOW_DESTROYED (window))
984 if (GDK_WINDOW_TYPE (private) == GDK_WINDOW_CHILD)
985 _gdk_window_move_resize_child (window, private->x, private->y,
989 GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (private->impl);
991 if (width != impl->width || height != impl->height)
992 private->resize_count += 1;
994 XResizeWindow (GDK_WINDOW_XDISPLAY (window),
995 GDK_WINDOW_XID (window),
1002 gdk_window_move_resize (GdkWindow *window,
1008 GdkWindowObject *private;
1010 g_return_if_fail (window != NULL);
1011 g_return_if_fail (GDK_IS_WINDOW (window));
1018 private = (GdkWindowObject*) window;
1020 if (!GDK_WINDOW_DESTROYED (window))
1022 if (GDK_WINDOW_TYPE (private) == GDK_WINDOW_CHILD)
1023 _gdk_window_move_resize_child (window, x, y, width, height);
1026 GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (private->impl);
1028 if (width != impl->width || height != impl->height)
1029 private->resize_count += 1;
1031 XMoveResizeWindow (GDK_WINDOW_XDISPLAY (window),
1032 GDK_WINDOW_XID (window),
1033 x, y, width, height);
1039 gdk_window_reparent (GdkWindow *window,
1040 GdkWindow *new_parent,
1044 GdkWindowObject *window_private;
1045 GdkWindowObject *parent_private;
1046 GdkWindowObject *old_parent_private;
1048 g_return_if_fail (window != NULL);
1049 g_return_if_fail (GDK_IS_WINDOW (window));
1050 g_return_if_fail (new_parent == NULL || GDK_IS_WINDOW (new_parent));
1051 g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_ROOT);
1054 new_parent = gdk_parent_root;
1056 window_private = (GdkWindowObject*) window;
1057 old_parent_private = (GdkWindowObject*)window_private->parent;
1058 parent_private = (GdkWindowObject*) new_parent;
1060 if (!GDK_WINDOW_DESTROYED (window) && !GDK_WINDOW_DESTROYED (new_parent))
1061 XReparentWindow (GDK_WINDOW_XDISPLAY (window),
1062 GDK_WINDOW_XID (window),
1063 GDK_WINDOW_XID (new_parent),
1066 window_private->parent = (GdkWindowObject *)new_parent;
1068 /* Switch the window type as appropriate */
1070 switch (GDK_WINDOW_TYPE (new_parent))
1072 case GDK_WINDOW_ROOT:
1073 case GDK_WINDOW_FOREIGN:
1074 /* Now a toplevel */
1075 if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD)
1077 GDK_WINDOW_TYPE (window) = GDK_WINDOW_TOPLEVEL;
1078 XSetWMProtocols (GDK_WINDOW_XDISPLAY (window),
1079 GDK_WINDOW_XID (window),
1080 gdk_wm_window_protocols, 3);
1082 case GDK_WINDOW_TOPLEVEL:
1083 case GDK_WINDOW_CHILD:
1084 case GDK_WINDOW_DIALOG:
1085 case GDK_WINDOW_TEMP:
1086 if (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD &&
1087 GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN)
1089 /* If we were being sophisticated, we'd save the old window type
1090 * here, and restore it if we were reparented back to the
1091 * toplevel. However, the difference between different types
1092 * of toplevels only really matters on creation anyways.
1094 GDK_WINDOW_TYPE (window) = GDK_WINDOW_CHILD;
1098 if (old_parent_private)
1099 old_parent_private->children = g_list_remove (old_parent_private->children, window);
1101 if ((old_parent_private &&
1102 (!old_parent_private->guffaw_gravity != !parent_private->guffaw_gravity)) ||
1103 (!old_parent_private && parent_private->guffaw_gravity))
1104 gdk_window_set_static_win_gravity (window, parent_private->guffaw_gravity);
1106 parent_private->children = g_list_prepend (parent_private->children, window);
1107 _gdk_window_init_position (GDK_WINDOW (window_private));
1111 _gdk_windowing_window_clear_area (GdkWindow *window,
1117 g_return_if_fail (window != NULL);
1118 g_return_if_fail (GDK_IS_WINDOW (window));
1120 if (!GDK_WINDOW_DESTROYED (window))
1121 XClearArea (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
1122 x, y, width, height, False);
1126 _gdk_windowing_window_clear_area_e (GdkWindow *window,
1132 g_return_if_fail (window != NULL);
1133 g_return_if_fail (GDK_IS_WINDOW (window));
1135 if (!GDK_WINDOW_DESTROYED (window))
1136 XClearArea (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
1137 x, y, width, height, True);
1141 gdk_window_raise (GdkWindow *window)
1143 g_return_if_fail (window != NULL);
1144 g_return_if_fail (GDK_IS_WINDOW (window));
1146 if (!GDK_WINDOW_DESTROYED (window))
1147 XRaiseWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
1151 gdk_window_lower (GdkWindow *window)
1153 g_return_if_fail (window != NULL);
1154 g_return_if_fail (GDK_IS_WINDOW (window));
1156 if (!GDK_WINDOW_DESTROYED (window))
1157 XLowerWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
1161 gdk_window_focus (GdkWindow *window,
1164 g_return_if_fail (GDK_IS_WINDOW (window));
1166 if (GDK_WINDOW_DESTROYED (window))
1169 if (gdk_net_wm_supports (gdk_atom_intern ("_NET_ACTIVE_WINDOW", FALSE)))
1173 xev.xclient.type = ClientMessage;
1174 xev.xclient.serial = 0;
1175 xev.xclient.send_event = True;
1176 xev.xclient.window = GDK_WINDOW_XWINDOW (window);
1177 xev.xclient.display = gdk_display;
1178 xev.xclient.message_type = gdk_atom_intern ("_NET_ACTIVE_WINDOW", FALSE);
1179 xev.xclient.format = 32;
1180 xev.xclient.data.l[0] = 0;
1182 XSendEvent (gdk_display, gdk_root_window, False,
1183 SubstructureRedirectMask | SubstructureNotifyMask,
1188 XRaiseWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
1190 /* There is no way of knowing reliably whether we are viewable so we need
1191 * to trap errors so we don't cause a BadMatch.
1193 gdk_error_trap_push ();
1194 XSetInputFocus (GDK_WINDOW_XDISPLAY (window),
1195 GDK_WINDOW_XWINDOW (window),
1198 XSync (GDK_WINDOW_XDISPLAY (window), False);
1199 gdk_error_trap_pop ();
1204 gdk_window_set_hints (GdkWindow *window,
1213 XSizeHints size_hints;
1215 g_return_if_fail (window != NULL);
1216 g_return_if_fail (GDK_IS_WINDOW (window));
1218 if (GDK_WINDOW_DESTROYED (window))
1221 size_hints.flags = 0;
1223 if (flags & GDK_HINT_POS)
1225 size_hints.flags |= PPosition;
1230 if (flags & GDK_HINT_MIN_SIZE)
1232 size_hints.flags |= PMinSize;
1233 size_hints.min_width = min_width;
1234 size_hints.min_height = min_height;
1237 if (flags & GDK_HINT_MAX_SIZE)
1239 size_hints.flags |= PMaxSize;
1240 size_hints.max_width = max_width;
1241 size_hints.max_height = max_height;
1244 /* FIXME: Would it be better to delete this property if
1245 * flags == 0? It would save space on the server
1247 XSetWMNormalHints (GDK_WINDOW_XDISPLAY (window),
1248 GDK_WINDOW_XID (window),
1253 * gdk_window_set_type_hint:
1254 * @window: A #GdkWindow
1255 * @hint: A hint of the function this window will have
1257 * The application can use this call to provide a hint to the window
1258 * manager about the functionality of a window. The window manager
1259 * can use this information when determining the decoration and behaviour
1262 * The hint must be set before the window is mapped.
1265 gdk_window_set_type_hint (GdkWindow *window,
1266 GdkWindowTypeHint hint)
1270 g_return_if_fail (window != NULL);
1271 g_return_if_fail (GDK_IS_WINDOW (window));
1273 if (GDK_WINDOW_DESTROYED (window))
1278 case GDK_WINDOW_TYPE_HINT_DIALOG:
1279 atom = gdk_atom_intern ("_NET_WM_WINDOW_TYPE_DIALOG", FALSE);
1281 case GDK_WINDOW_TYPE_HINT_MENU:
1282 atom = gdk_atom_intern ("_NET_WM_WINDOW_TYPE_MENU", FALSE);
1284 case GDK_WINDOW_TYPE_HINT_TOOLBAR:
1285 atom = gdk_atom_intern ("_NET_WM_WINDOW_TYPE_TOOLBAR", FALSE);
1288 g_warning ("Unknown hint %d passed to gdk_window_set_type_hint", hint);
1290 case GDK_WINDOW_TYPE_HINT_NORMAL:
1291 atom = gdk_atom_intern ("_NET_WM_WINDOW_TYPE_NORMAL", FALSE);
1295 XChangeProperty (GDK_WINDOW_XDISPLAY (window),
1296 GDK_WINDOW_XID (window),
1297 gdk_atom_intern ("_NET_WM_WINDOW_TYPE", FALSE),
1298 XA_ATOM, 32, PropModeReplace,
1299 (guchar *)&atom, 1);
1304 gdk_wmspec_change_state (gboolean add,
1311 #define _NET_WM_STATE_REMOVE 0 /* remove/unset property */
1312 #define _NET_WM_STATE_ADD 1 /* add/set property */
1313 #define _NET_WM_STATE_TOGGLE 2 /* toggle property */
1315 xev.xclient.type = ClientMessage;
1316 xev.xclient.serial = 0;
1317 xev.xclient.send_event = True;
1318 xev.xclient.display = gdk_display;
1319 xev.xclient.window = GDK_WINDOW_XID (window);
1320 xev.xclient.message_type = gdk_atom_intern ("_NET_WM_STATE", FALSE);
1321 xev.xclient.format = 32;
1322 xev.xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
1323 xev.xclient.data.l[1] = state1;
1324 xev.xclient.data.l[2] = state2;
1326 XSendEvent (gdk_display, gdk_root_window, False,
1327 SubstructureRedirectMask | SubstructureNotifyMask,
1331 * gdk_window_set_modal_hint:
1332 * @window: A #GdkWindow
1333 * @modal: TRUE if the window is modal, FALSE otherwise.
1335 * The application can use this hint to tell the window manager
1336 * that a certain window has modal behaviour. The window manager
1337 * can use this information to handle modal windows in a special
1340 * You should only use this on windows for which you have
1341 * previously called #gdk_window_set_transient_for()
1344 gdk_window_set_modal_hint (GdkWindow *window,
1347 GdkWindowObject *private;
1349 g_return_if_fail (window != NULL);
1350 g_return_if_fail (GDK_IS_WINDOW (window));
1352 if (GDK_WINDOW_DESTROYED (window))
1355 private = (GdkWindowObject*) window;
1357 private->modal_hint = modal;
1359 if (GDK_WINDOW_IS_MAPPED (window))
1360 gdk_wmspec_change_state (modal, window,
1361 gdk_atom_intern ("_NET_WM_STATE_MODAL", FALSE),
1366 gdk_window_set_geometry_hints (GdkWindow *window,
1367 GdkGeometry *geometry,
1368 GdkWindowHints geom_mask)
1370 XSizeHints size_hints;
1372 g_return_if_fail (window != NULL);
1373 g_return_if_fail (GDK_IS_WINDOW (window));
1375 if (GDK_WINDOW_DESTROYED (window))
1378 size_hints.flags = 0;
1380 if (geom_mask & GDK_HINT_POS)
1382 size_hints.flags |= PPosition;
1383 /* We need to initialize the following obsolete fields because KWM
1384 * apparently uses these fields if they are non-zero.
1391 if (geom_mask & GDK_HINT_USER_POS)
1393 size_hints.flags |= USPosition;
1396 if (geom_mask & GDK_HINT_USER_SIZE)
1398 size_hints.flags |= USSize;
1401 if (geom_mask & GDK_HINT_MIN_SIZE)
1403 size_hints.flags |= PMinSize;
1404 size_hints.min_width = geometry->min_width;
1405 size_hints.min_height = geometry->min_height;
1408 if (geom_mask & GDK_HINT_MAX_SIZE)
1410 size_hints.flags |= PMaxSize;
1411 size_hints.max_width = MAX (geometry->max_width, 1);
1412 size_hints.max_height = MAX (geometry->max_height, 1);
1415 if (geom_mask & GDK_HINT_BASE_SIZE)
1417 size_hints.flags |= PBaseSize;
1418 size_hints.base_width = geometry->base_width;
1419 size_hints.base_height = geometry->base_height;
1422 if (geom_mask & GDK_HINT_RESIZE_INC)
1424 size_hints.flags |= PResizeInc;
1425 size_hints.width_inc = geometry->width_inc;
1426 size_hints.height_inc = geometry->height_inc;
1429 if (geom_mask & GDK_HINT_ASPECT)
1431 size_hints.flags |= PAspect;
1432 if (geometry->min_aspect <= 1)
1434 size_hints.min_aspect.x = 65536 * geometry->min_aspect;
1435 size_hints.min_aspect.y = 65536;
1439 size_hints.min_aspect.x = 65536;
1440 size_hints.min_aspect.y = 65536 / geometry->min_aspect;;
1442 if (geometry->max_aspect <= 1)
1444 size_hints.max_aspect.x = 65536 * geometry->max_aspect;
1445 size_hints.max_aspect.y = 65536;
1449 size_hints.max_aspect.x = 65536;
1450 size_hints.max_aspect.y = 65536 / geometry->max_aspect;;
1454 if (geom_mask & GDK_HINT_WIN_GRAVITY)
1456 size_hints.flags |= PWinGravity;
1457 size_hints.win_gravity = geometry->win_gravity;
1460 /* FIXME: Would it be better to delete this property if
1461 * geom_mask == 0? It would save space on the server
1463 XSetWMNormalHints (GDK_WINDOW_XDISPLAY (window),
1464 GDK_WINDOW_XID (window),
1469 gdk_window_get_geometry_hints (GdkWindow *window,
1470 GdkGeometry *geometry,
1471 GdkWindowHints *geom_mask)
1473 XSizeHints size_hints;
1474 glong junk_size_mask = 0;
1476 g_return_if_fail (GDK_IS_WINDOW (window));
1477 g_return_if_fail (geometry != NULL);
1478 g_return_if_fail (geom_mask != NULL);
1482 if (GDK_WINDOW_DESTROYED (window))
1485 if (!XGetWMNormalHints (GDK_WINDOW_XDISPLAY (window),
1486 GDK_WINDOW_XID (window),
1491 if (size_hints.flags & PMinSize)
1493 *geom_mask |= GDK_HINT_MIN_SIZE;
1494 geometry->min_width = size_hints.min_width;
1495 geometry->min_height = size_hints.min_height;
1498 if (size_hints.flags & PMaxSize)
1500 *geom_mask |= GDK_HINT_MAX_SIZE;
1501 geometry->max_width = MAX (size_hints.max_width, 1);
1502 geometry->max_height = MAX (size_hints.max_height, 1);
1505 if (size_hints.flags & PResizeInc)
1507 *geom_mask |= GDK_HINT_RESIZE_INC;
1508 geometry->width_inc = size_hints.width_inc;
1509 geometry->height_inc = size_hints.height_inc;
1512 if (size_hints.flags & PAspect)
1514 *geom_mask |= GDK_HINT_ASPECT;
1516 geometry->min_aspect = (gdouble) size_hints.min_aspect.x / (gdouble) size_hints.min_aspect.y;
1517 geometry->max_aspect = (gdouble) size_hints.max_aspect.x / (gdouble) size_hints.max_aspect.y;
1520 if (size_hints.flags & PWinGravity)
1522 *geom_mask |= GDK_HINT_WIN_GRAVITY;
1523 geometry->win_gravity = size_hints.win_gravity;
1528 utf8_is_latin1 (const gchar *str)
1530 const char *p = str;
1534 gunichar ch = g_utf8_get_char (p);
1539 p = g_utf8_next_char (p);
1545 /* Set the property to @utf8_str as STRING if the @utf8_str is fully
1546 * convertable to STRING, otherwise, set it as compound text
1549 set_text_property (GdkWindow *window,
1551 const gchar *utf8_str)
1553 guchar *prop_text = NULL;
1558 if (utf8_is_latin1 (utf8_str))
1560 prop_type = GDK_TARGET_STRING;
1561 prop_text = gdk_utf8_to_string_target (utf8_str);
1562 prop_length = strlen (prop_text);
1567 gdk_utf8_to_compound_text (utf8_str, &prop_type, &prop_format,
1568 &prop_text, &prop_length);
1573 XChangeProperty (GDK_WINDOW_XDISPLAY (window),
1574 GDK_WINDOW_XID (window),
1576 prop_type, prop_format,
1577 PropModeReplace, prop_text,
1585 gdk_window_set_title (GdkWindow *window,
1588 g_return_if_fail (window != NULL);
1589 g_return_if_fail (GDK_IS_WINDOW (window));
1591 if (GDK_WINDOW_DESTROYED (window))
1594 XChangeProperty (GDK_WINDOW_XDISPLAY (window),
1595 GDK_WINDOW_XID (window),
1596 gdk_atom_intern ("_NET_WM_NAME", FALSE),
1597 gdk_atom_intern ("UTF8_STRING", FALSE), 8,
1598 PropModeReplace, title,
1601 set_text_property (window, gdk_atom_intern ("WM_NAME", FALSE), title);
1602 if (!gdk_window_icon_name_set (window))
1604 XChangeProperty (GDK_WINDOW_XDISPLAY (window),
1605 GDK_WINDOW_XID (window),
1606 gdk_atom_intern ("_NET_WM_ICON_NAME", FALSE),
1607 gdk_atom_intern ("UTF8_STRING", FALSE), 8,
1608 PropModeReplace, title,
1610 set_text_property (window, gdk_atom_intern ("WM_ICON_NAME", FALSE), title);
1615 gdk_window_set_role (GdkWindow *window,
1618 g_return_if_fail (window != NULL);
1619 g_return_if_fail (GDK_IS_WINDOW (window));
1621 if (!GDK_WINDOW_DESTROYED (window))
1624 XChangeProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
1625 gdk_atom_intern ("WM_WINDOW_ROLE", FALSE), XA_STRING,
1626 8, PropModeReplace, role, strlen (role));
1628 XDeleteProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
1629 gdk_atom_intern ("WM_WINDOW_ROLE", FALSE));
1634 gdk_window_set_transient_for (GdkWindow *window,
1637 GdkWindowObject *private;
1638 GdkWindowObject *parent_private;
1640 g_return_if_fail (window != NULL);
1641 g_return_if_fail (GDK_IS_WINDOW (window));
1643 private = (GdkWindowObject*) window;
1644 parent_private = (GdkWindowObject*) parent;
1646 if (!GDK_WINDOW_DESTROYED (window) && !GDK_WINDOW_DESTROYED (parent))
1647 XSetTransientForHint (GDK_WINDOW_XDISPLAY (window),
1648 GDK_WINDOW_XID (window),
1649 GDK_WINDOW_XID (parent));
1653 gdk_window_set_background (GdkWindow *window,
1656 GdkWindowObject *private = (GdkWindowObject *)window;
1658 g_return_if_fail (window != NULL);
1659 g_return_if_fail (GDK_IS_WINDOW (window));
1661 if (!GDK_WINDOW_DESTROYED (window))
1662 XSetWindowBackground (GDK_WINDOW_XDISPLAY (window),
1663 GDK_WINDOW_XID (window), color->pixel);
1665 private->bg_color = *color;
1667 if (private->bg_pixmap &&
1668 private->bg_pixmap != GDK_PARENT_RELATIVE_BG &&
1669 private->bg_pixmap != GDK_NO_BG)
1671 gdk_pixmap_unref (private->bg_pixmap);
1672 private->bg_pixmap = NULL;
1677 gdk_window_set_back_pixmap (GdkWindow *window,
1679 gboolean parent_relative)
1681 GdkWindowObject *private = (GdkWindowObject *)window;
1684 g_return_if_fail (window != NULL);
1685 g_return_if_fail (GDK_IS_WINDOW (window));
1686 g_return_if_fail (pixmap == NULL || !parent_relative);
1688 if (private->bg_pixmap &&
1689 private->bg_pixmap != GDK_PARENT_RELATIVE_BG &&
1690 private->bg_pixmap != GDK_NO_BG)
1691 gdk_pixmap_unref (private->bg_pixmap);
1693 if (parent_relative)
1695 xpixmap = ParentRelative;
1696 private->bg_pixmap = GDK_PARENT_RELATIVE_BG;
1702 gdk_pixmap_ref (pixmap);
1703 private->bg_pixmap = pixmap;
1704 xpixmap = GDK_PIXMAP_XID (pixmap);
1709 private->bg_pixmap = GDK_NO_BG;
1713 if (!GDK_WINDOW_DESTROYED (window))
1714 XSetWindowBackgroundPixmap (GDK_WINDOW_XDISPLAY (window),
1715 GDK_WINDOW_XID (window), xpixmap);
1719 gdk_window_set_cursor (GdkWindow *window,
1722 GdkCursorPrivate *cursor_private;
1725 g_return_if_fail (window != NULL);
1726 g_return_if_fail (GDK_IS_WINDOW (window));
1728 cursor_private = (GdkCursorPrivate*) cursor;
1733 xcursor = cursor_private->xcursor;
1735 if (!GDK_WINDOW_DESTROYED (window))
1736 XDefineCursor (GDK_WINDOW_XDISPLAY (window),
1737 GDK_WINDOW_XID (window),
1742 gdk_window_get_geometry (GdkWindow *window,
1754 guint tborder_width;
1757 g_return_if_fail (window == NULL || GDK_IS_WINDOW (window));
1760 window = gdk_parent_root;
1762 if (!GDK_WINDOW_DESTROYED (window))
1764 XGetGeometry (GDK_WINDOW_XDISPLAY (window),
1765 GDK_WINDOW_XID (window),
1766 &root, &tx, &ty, &twidth, &theight, &tborder_width, &tdepth);
1782 * gdk_window_get_origin:
1783 * @window: a #GdkWindow
1784 * @x: return location for X coordinate
1785 * @y: return location for Y coordinate
1787 * Obtains the position of a window in root window coordinates.
1788 * (Compare with gdk_window_get_position() and
1789 * gdk_window_get_geometry() which return the position of a window
1790 * relative to its parent window.)
1792 * Return value: not meaningful, ignore
1795 gdk_window_get_origin (GdkWindow *window,
1804 g_return_val_if_fail (window != NULL, 0);
1806 if (!GDK_WINDOW_DESTROYED (window))
1808 return_val = XTranslateCoordinates (GDK_WINDOW_XDISPLAY (window),
1809 GDK_WINDOW_XID (window),
1827 * gdk_window_get_deskrelative_origin:
1828 * @window: a #GdkWindow
1829 * @x: return location for X coordinate
1830 * @y: return location for Y coordinate
1832 * This gets the origin of a #GdkWindow relative to
1833 * an Enlightenment-window-manager desktop. As long as you don't
1834 * assume that the user's desktop/workspace covers the entire
1835 * root window (i.e. you don't assume that the desktop begins
1836 * at root window coordinate 0,0) this function is not necessary.
1837 * It's deprecated for that reason.
1839 * Return value: not meaningful
1842 gdk_window_get_deskrelative_origin (GdkWindow *window,
1846 gboolean return_val = FALSE;
1847 gint num_children, format_return;
1848 Window win, *child, parent, root;
1852 static Atom atom = 0;
1853 gulong number_return, bytes_after_return;
1854 guchar *data_return;
1856 g_return_val_if_fail (window != NULL, 0);
1857 g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
1859 if (!GDK_WINDOW_DESTROYED (window))
1862 atom = gdk_atom_intern ("ENLIGHTENMENT_DESKTOP", FALSE);
1863 win = GDK_WINDOW_XID (window);
1865 while (XQueryTree (GDK_WINDOW_XDISPLAY (window), win, &root, &parent,
1866 &child, (unsigned int *)&num_children))
1868 if ((child) && (num_children > 0))
1880 XGetWindowProperty (GDK_WINDOW_XDISPLAY (window), win, atom, 0, 0,
1881 False, XA_CARDINAL, &type_return, &format_return,
1882 &number_return, &bytes_after_return, &data_return);
1883 if (type_return == XA_CARDINAL)
1885 XFree (data_return);
1890 return_val = XTranslateCoordinates (GDK_WINDOW_XDISPLAY (window),
1891 GDK_WINDOW_XID (window),
1906 * gdk_window_get_root_origin:
1907 * @window: a #GdkWindow
1908 * @x: return location for X position of window frame
1909 * @y: return location for Y position of window frame
1911 * Obtains the top-left corner of the window manager frame in root
1912 * window coordinates.
1916 gdk_window_get_root_origin (GdkWindow *window,
1922 g_return_if_fail (GDK_IS_WINDOW (window));
1924 gdk_window_get_frame_extents (window, &rect);
1934 * gdk_window_get_frame_extents:
1935 * @window: a #GdkWindow
1936 * @rect: rectangle to fill with bounding box of the window frame
1938 * Obtains the bounding box of the window, including window manager
1939 * titlebar/borders if any. The frame position is given in root window
1940 * coordinates. To get the position of the window itself (rather than
1941 * the frame) in root window coordinates, use gdk_window_get_origin().
1945 gdk_window_get_frame_extents (GdkWindow *window,
1948 GdkWindowObject *private;
1953 unsigned int nchildren;
1955 g_return_if_fail (GDK_IS_WINDOW (window));
1956 g_return_if_fail (rect != NULL);
1958 private = (GdkWindowObject*) window;
1965 if (GDK_WINDOW_DESTROYED (window))
1968 while (private->parent && ((GdkWindowObject*) private->parent)->parent)
1969 private = (GdkWindowObject*) private->parent;
1970 if (GDK_WINDOW_DESTROYED (window))
1973 xparent = GDK_WINDOW_XID (window);
1977 if (!XQueryTree (GDK_WINDOW_XDISPLAY (window), xwindow,
1979 &children, &nchildren))
1985 while (xparent != root);
1987 if (xparent == root)
1989 unsigned int ww, wh, wb, wd;
1992 if (XGetGeometry (GDK_WINDOW_XDISPLAY (window), xwindow, &root, &wx, &wy, &ww, &wh, &wb, &wd))
2003 _gdk_windowing_window_get_pointer (GdkWindow *window,
2006 GdkModifierType *mask)
2008 GdkWindow *return_val;
2014 unsigned int xmask = 0;
2015 gint xoffset, yoffset;
2017 g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
2020 window = gdk_parent_root;
2022 _gdk_windowing_window_get_offsets (window, &xoffset, &yoffset);
2025 if (!GDK_WINDOW_DESTROYED (window) &&
2026 XQueryPointer (GDK_WINDOW_XDISPLAY (window),
2027 GDK_WINDOW_XID (window),
2028 &root, &child, &rootx, &rooty, &winx, &winy, &xmask))
2031 return_val = gdk_window_lookup (child);
2035 *x = winx + xoffset;
2037 *y = winy + yoffset;
2045 _gdk_windowing_window_at_pointer (gint *win_x,
2051 Window xwindow_last = 0;
2053 int rootx = -1, rooty = -1;
2057 xwindow = GDK_ROOT_WINDOW ();
2058 xdisplay = GDK_DISPLAY ();
2060 gdk_x11_grab_server ();
2063 xwindow_last = xwindow;
2064 XQueryPointer (xdisplay, xwindow,
2070 gdk_x11_ungrab_server ();
2072 window = gdk_window_lookup (xwindow_last);
2075 *win_x = window ? winx : -1;
2077 *win_y = window ? winy : -1;
2083 gdk_window_get_events (GdkWindow *window)
2085 XWindowAttributes attrs;
2086 GdkEventMask event_mask;
2089 g_return_val_if_fail (window != NULL, 0);
2090 g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
2092 if (GDK_WINDOW_DESTROYED (window))
2096 XGetWindowAttributes (GDK_WINDOW_XDISPLAY (window),
2097 GDK_WINDOW_XID (window),
2101 for (i = 0; i < gdk_nevent_masks; i++)
2103 if (attrs.your_event_mask & gdk_event_mask_table[i])
2104 event_mask |= 1 << (i + 1);
2112 gdk_window_set_events (GdkWindow *window,
2113 GdkEventMask event_mask)
2118 g_return_if_fail (window != NULL);
2119 g_return_if_fail (GDK_IS_WINDOW (window));
2121 if (!GDK_WINDOW_DESTROYED (window))
2123 xevent_mask = StructureNotifyMask;
2124 for (i = 0; i < gdk_nevent_masks; i++)
2126 if (event_mask & (1 << (i + 1)))
2127 xevent_mask |= gdk_event_mask_table[i];
2130 XSelectInput (GDK_WINDOW_XDISPLAY (window),
2131 GDK_WINDOW_XID (window),
2137 gdk_window_add_colormap_windows (GdkWindow *window)
2139 GdkWindow *toplevel;
2140 Window *old_windows;
2141 Window *new_windows;
2144 g_return_if_fail (window != NULL);
2145 g_return_if_fail (GDK_IS_WINDOW (window));
2147 toplevel = gdk_window_get_toplevel (window);
2148 if (GDK_WINDOW_DESTROYED (toplevel))
2152 if (!XGetWMColormapWindows (GDK_WINDOW_XDISPLAY (toplevel),
2153 GDK_WINDOW_XID (toplevel),
2154 &old_windows, &count))
2159 for (i = 0; i < count; i++)
2160 if (old_windows[i] == GDK_WINDOW_XID (window))
2162 XFree (old_windows);
2166 new_windows = g_new (Window, count + 1);
2168 for (i = 0; i < count; i++)
2169 new_windows[i] = old_windows[i];
2170 new_windows[count] = GDK_WINDOW_XID (window);
2172 XSetWMColormapWindows (GDK_WINDOW_XDISPLAY (toplevel),
2173 GDK_WINDOW_XID (toplevel),
2174 new_windows, count + 1);
2176 g_free (new_windows);
2178 XFree (old_windows);
2182 gdk_window_have_shape_ext (void)
2184 enum { UNKNOWN, NO, YES };
2185 static gint have_shape = UNKNOWN;
2187 if (have_shape == UNKNOWN)
2190 if (XQueryExtension (gdk_display, "SHAPE", &ignore, &ignore, &ignore))
2196 return (have_shape == YES);
2199 #define WARN_SHAPE_TOO_BIG() g_warning ("GdkWindow is too large to allow the use of shape masks or shape regions.")
2202 * This needs the X11 shape extension.
2203 * If not available, shaped windows will look
2204 * ugly, but programs still work. Stefan Wille
2207 gdk_window_shape_combine_mask (GdkWindow *window,
2212 gint xoffset, yoffset;
2214 g_return_if_fail (window != NULL);
2215 g_return_if_fail (GDK_IS_WINDOW (window));
2217 #ifdef HAVE_SHAPE_EXT
2218 if (GDK_WINDOW_DESTROYED (window))
2221 _gdk_windowing_window_get_offsets (window, &xoffset, &yoffset);
2223 if (xoffset != 0 || yoffset != 0)
2225 WARN_SHAPE_TOO_BIG ();
2229 if (gdk_window_have_shape_ext ())
2233 pixmap = GDK_PIXMAP_XID (mask);
2242 XShapeCombineMask (GDK_WINDOW_XDISPLAY (window),
2243 GDK_WINDOW_XID (window),
2249 #endif /* HAVE_SHAPE_EXT */
2253 gdk_window_shape_combine_region (GdkWindow *window,
2254 GdkRegion *shape_region,
2258 gint xoffset, yoffset;
2260 g_return_if_fail (GDK_IS_WINDOW (window));
2262 #ifdef HAVE_SHAPE_EXT
2263 if (GDK_WINDOW_DESTROYED (window))
2266 _gdk_windowing_window_get_offsets (window, &xoffset, &yoffset);
2268 if (xoffset != 0 || yoffset != 0)
2270 WARN_SHAPE_TOO_BIG ();
2274 if (shape_region == NULL)
2276 /* Use NULL mask to unset the shape */
2277 gdk_window_shape_combine_mask (window, NULL, 0, 0);
2281 if (gdk_window_have_shape_ext ())
2284 XRectangle *xrects = NULL;
2286 _gdk_region_get_xrectangles (shape_region,
2290 XShapeCombineRectangles (GDK_WINDOW_XDISPLAY (window),
2291 GDK_WINDOW_XID (window),
2300 #endif /* HAVE_SHAPE_EXT */
2305 gdk_window_set_override_redirect (GdkWindow *window,
2306 gboolean override_redirect)
2308 XSetWindowAttributes attr;
2310 g_return_if_fail (window != NULL);
2311 g_return_if_fail (GDK_IS_WINDOW (window));
2313 if (GDK_WINDOW_DESTROYED (window))
2315 attr.override_redirect = (override_redirect == FALSE)?False:True;
2316 XChangeWindowAttributes (GDK_WINDOW_XDISPLAY (window),
2317 GDK_WINDOW_XID (window),
2325 * gdk_window_set_icon_list:
2326 * @window: The #GdkWindow toplevel window to set the icon of.
2327 * @pixbufs: A list of pixbufs, of different sizes.
2329 * Sets a list of icons for the window. One of these will be used
2330 * to represent the window when it has been iconified. The icon is
2331 * usually shown in an icon box or some sort of task bar. Which icon
2332 * size is shown depends on the window manager. The window manager
2333 * can scale the icon but setting several size icons can give better
2334 * image quality since the window manager may only need to scale the
2335 * icon by a small amount or not at all.
2339 gdk_window_set_icon_list (GdkWindow *window,
2348 gint width, height, stride;
2352 g_return_if_fail (GDK_IS_WINDOW (window));
2354 if (GDK_WINDOW_DESTROYED (window))
2363 g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), FALSE);
2365 width = gdk_pixbuf_get_width (pixbuf);
2366 height = gdk_pixbuf_get_height (pixbuf);
2368 size += 2 + width * height;
2370 l = g_list_next (l);
2373 data = g_malloc (size*4);
2381 width = gdk_pixbuf_get_width (pixbuf);
2382 height = gdk_pixbuf_get_height (pixbuf);
2383 stride = gdk_pixbuf_get_rowstride (pixbuf);
2384 n_channels = gdk_pixbuf_get_n_channels (pixbuf);
2389 pixels = gdk_pixbuf_get_pixels (pixbuf);
2391 for (y = 0; y < height; y++)
2393 for (x = 0; x < width; x++)
2397 r = pixels[y*stride + x*n_channels + 0];
2398 g = pixels[y*stride + x*n_channels + 1];
2399 b = pixels[y*stride + x*n_channels + 2];
2400 if (n_channels >= 4)
2401 a = pixels[y*stride + x*n_channels + 3];
2405 *p++ = a << 24 | r << 16 | g << 8 | b ;
2409 l = g_list_next (l);
2414 XChangeProperty (GDK_WINDOW_XDISPLAY (window),
2415 GDK_WINDOW_XID (window),
2416 gdk_atom_intern ("_NET_WM_ICON", FALSE),
2419 (guchar*) data, size);
2423 XDeleteProperty (GDK_WINDOW_XDISPLAY (window),
2424 GDK_WINDOW_XID (window),
2425 gdk_atom_intern ("_NET_WM_ICON", FALSE));
2430 gdk_window_set_icon (GdkWindow *window,
2431 GdkWindow *icon_window,
2437 g_return_if_fail (window != NULL);
2438 g_return_if_fail (GDK_IS_WINDOW (window));
2440 if (GDK_WINDOW_DESTROYED (window))
2443 wm_hints = XGetWMHints (GDK_WINDOW_XDISPLAY (window),
2444 GDK_WINDOW_XID (window));
2446 wm_hints = XAllocWMHints ();
2448 if (icon_window != NULL)
2450 wm_hints->flags |= IconWindowHint;
2451 wm_hints->icon_window = GDK_WINDOW_XID (icon_window);
2456 wm_hints->flags |= IconPixmapHint;
2457 wm_hints->icon_pixmap = GDK_PIXMAP_XID (pixmap);
2462 wm_hints->flags |= IconMaskHint;
2463 wm_hints->icon_mask = GDK_PIXMAP_XID (mask);
2466 XSetWMHints (GDK_WINDOW_XDISPLAY (window),
2467 GDK_WINDOW_XID (window), wm_hints);
2472 gdk_window_icon_name_set (GdkWindow *window)
2474 return GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (window),
2475 g_quark_from_static_string ("gdk-icon-name-set")));
2479 gdk_window_set_icon_name (GdkWindow *window,
2482 g_return_if_fail (window != NULL);
2483 g_return_if_fail (GDK_IS_WINDOW (window));
2485 if (GDK_WINDOW_DESTROYED (window))
2488 g_object_set_qdata (G_OBJECT (window), g_quark_from_static_string ("gdk-icon-name-set"),
2489 GUINT_TO_POINTER (TRUE));
2491 XChangeProperty (GDK_WINDOW_XDISPLAY (window),
2492 GDK_WINDOW_XID (window),
2493 gdk_atom_intern ("_NET_WM_ICON_NAME", FALSE),
2494 gdk_atom_intern ("UTF8_STRING", FALSE), 8,
2495 PropModeReplace, name,
2497 set_text_property (window, gdk_atom_intern ("WM_ICON_NAME", FALSE), name);
2501 gdk_window_iconify (GdkWindow *window)
2504 GdkWindowObject *private;
2506 g_return_if_fail (window != NULL);
2507 g_return_if_fail (GDK_IS_WINDOW (window));
2509 if (GDK_WINDOW_DESTROYED (window))
2512 display = GDK_WINDOW_XDISPLAY (window);
2514 private = (GdkWindowObject*) window;
2516 if (GDK_WINDOW_IS_MAPPED (window))
2518 XIconifyWindow (display, GDK_WINDOW_XWINDOW (window), DefaultScreen (display));
2523 /* Flip our client side flag, the real work happens on map. */
2524 gdk_synthesize_window_state (window,
2526 GDK_WINDOW_STATE_ICONIFIED);
2531 gdk_window_deiconify (GdkWindow *window)
2534 GdkWindowObject *private;
2536 g_return_if_fail (window != NULL);
2537 g_return_if_fail (GDK_IS_WINDOW (window));
2539 if (GDK_WINDOW_DESTROYED (window))
2542 display = GDK_WINDOW_XDISPLAY (window);
2544 private = (GdkWindowObject*) window;
2546 if (GDK_WINDOW_IS_MAPPED (window))
2548 gdk_window_show (window);
2552 /* Flip our client side flag, the real work happens on map. */
2553 gdk_synthesize_window_state (window,
2554 GDK_WINDOW_STATE_ICONIFIED,
2560 gdk_window_stick (GdkWindow *window)
2562 g_return_if_fail (GDK_IS_WINDOW (window));
2564 if (GDK_WINDOW_DESTROYED (window))
2567 if (GDK_WINDOW_IS_MAPPED (window))
2569 /* "stick" means stick to all desktops _and_ do not scroll with the
2570 * viewport. i.e. glue to the monitor glass in all cases.
2575 /* Request stick during viewport scroll */
2576 gdk_wmspec_change_state (TRUE, window,
2577 gdk_atom_intern ("_NET_WM_STATE_STICKY", FALSE),
2580 /* Request desktop 0xFFFFFFFF */
2581 xev.xclient.type = ClientMessage;
2582 xev.xclient.serial = 0;
2583 xev.xclient.send_event = True;
2584 xev.xclient.window = GDK_WINDOW_XWINDOW (window);
2585 xev.xclient.display = gdk_display;
2586 xev.xclient.message_type = gdk_atom_intern ("_NET_WM_DESKTOP", FALSE);
2587 xev.xclient.format = 32;
2589 xev.xclient.data.l[0] = 0xFFFFFFFF;
2591 XSendEvent (gdk_display, gdk_root_window, False,
2592 SubstructureRedirectMask | SubstructureNotifyMask,
2597 /* Flip our client side flag, the real work happens on map. */
2598 gdk_synthesize_window_state (window,
2600 GDK_WINDOW_STATE_STICKY);
2605 gdk_window_unstick (GdkWindow *window)
2607 g_return_if_fail (GDK_IS_WINDOW (window));
2609 if (GDK_WINDOW_DESTROYED (window))
2612 if (GDK_WINDOW_IS_MAPPED (window))
2619 gulong *current_desktop;
2621 /* Request unstick from viewport */
2622 gdk_wmspec_change_state (FALSE, window,
2623 gdk_atom_intern ("_NET_WM_STATE_STICKY", FALSE),
2626 /* Get current desktop, then set it; this is a race, but not
2627 * one that matters much in practice.
2629 XGetWindowProperty (gdk_display, gdk_root_window,
2630 gdk_atom_intern ("_NET_CURRENT_DESKTOP", FALSE),
2632 False, XA_CARDINAL, &type, &format, &nitems,
2633 &bytes_after, (guchar **)¤t_desktop);
2635 if (type == XA_CARDINAL)
2637 xev.xclient.type = ClientMessage;
2638 xev.xclient.serial = 0;
2639 xev.xclient.send_event = True;
2640 xev.xclient.window = GDK_WINDOW_XWINDOW (window);
2641 xev.xclient.display = gdk_display;
2642 xev.xclient.message_type = gdk_atom_intern ("_NET_WM_DESKTOP", FALSE);
2643 xev.xclient.format = 32;
2645 xev.xclient.data.l[0] = *current_desktop;
2647 XSendEvent (gdk_display, gdk_root_window, False,
2648 SubstructureRedirectMask | SubstructureNotifyMask,
2651 XFree (current_desktop);
2656 /* Flip our client side flag, the real work happens on map. */
2657 gdk_synthesize_window_state (window,
2658 GDK_WINDOW_STATE_STICKY,
2665 gdk_window_maximize (GdkWindow *window)
2667 g_return_if_fail (GDK_IS_WINDOW (window));
2669 if (GDK_WINDOW_DESTROYED (window))
2672 if (GDK_WINDOW_IS_MAPPED (window))
2673 gdk_wmspec_change_state (TRUE, window,
2674 gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_VERT", FALSE),
2675 gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_HORZ", FALSE));
2677 gdk_synthesize_window_state (window,
2679 GDK_WINDOW_STATE_MAXIMIZED);
2683 gdk_window_unmaximize (GdkWindow *window)
2685 g_return_if_fail (GDK_IS_WINDOW (window));
2687 if (GDK_WINDOW_DESTROYED (window))
2690 if (GDK_WINDOW_IS_MAPPED (window))
2691 gdk_wmspec_change_state (FALSE, window,
2692 gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_VERT", FALSE),
2693 gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_HORZ", FALSE));
2695 gdk_synthesize_window_state (window,
2696 GDK_WINDOW_STATE_MAXIMIZED,
2701 gdk_window_set_group (GdkWindow *window,
2706 g_return_if_fail (window != NULL);
2707 g_return_if_fail (GDK_IS_WINDOW (window));
2708 g_return_if_fail (leader != NULL);
2709 g_return_if_fail (GDK_IS_WINDOW (leader));
2711 if (GDK_WINDOW_DESTROYED (window) || GDK_WINDOW_DESTROYED (leader))
2714 wm_hints = XGetWMHints (GDK_WINDOW_XDISPLAY (window),
2715 GDK_WINDOW_XID (window));
2717 wm_hints = XAllocWMHints ();
2719 wm_hints->flags |= WindowGroupHint;
2720 wm_hints->window_group = GDK_WINDOW_XID (leader);
2722 XSetWMHints (GDK_WINDOW_XDISPLAY (window),
2723 GDK_WINDOW_XID (window), wm_hints);
2727 static MotifWmHints *
2728 gdk_window_get_mwm_hints (GdkWindow *window)
2730 static Atom hints_atom = None;
2731 MotifWmHints *hints;
2737 if (GDK_WINDOW_DESTROYED (window))
2741 hints_atom = XInternAtom (GDK_WINDOW_XDISPLAY (window),
2742 _XA_MOTIF_WM_HINTS, FALSE);
2744 XGetWindowProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
2745 hints_atom, 0, sizeof (MotifWmHints)/sizeof (long),
2746 False, AnyPropertyType, &type, &format, &nitems,
2747 &bytes_after, (guchar **)&hints);
2756 gdk_window_set_mwm_hints (GdkWindow *window,
2757 MotifWmHints *new_hints)
2759 static Atom hints_atom = None;
2760 MotifWmHints *hints;
2766 if (GDK_WINDOW_DESTROYED (window))
2770 hints_atom = XInternAtom (GDK_WINDOW_XDISPLAY (window),
2771 _XA_MOTIF_WM_HINTS, FALSE);
2773 XGetWindowProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
2774 hints_atom, 0, sizeof (MotifWmHints)/sizeof (long),
2775 False, AnyPropertyType, &type, &format, &nitems,
2776 &bytes_after, (guchar **)&hints);
2782 if (new_hints->flags & MWM_HINTS_FUNCTIONS)
2784 hints->flags |= MWM_HINTS_FUNCTIONS;
2785 hints->functions = new_hints->functions;
2787 if (new_hints->flags & MWM_HINTS_DECORATIONS)
2789 hints->flags |= MWM_HINTS_DECORATIONS;
2790 hints->decorations = new_hints->decorations;
2794 XChangeProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
2795 hints_atom, hints_atom, 32, PropModeReplace,
2796 (guchar *)hints, sizeof (MotifWmHints)/sizeof (long));
2798 if (hints != new_hints)
2803 gdk_window_set_decorations (GdkWindow *window,
2804 GdkWMDecoration decorations)
2808 g_return_if_fail (window != NULL);
2809 g_return_if_fail (GDK_IS_WINDOW (window));
2811 hints.flags = MWM_HINTS_DECORATIONS;
2812 hints.decorations = decorations;
2814 gdk_window_set_mwm_hints (window, &hints);
2818 * gdk_window_get_decorations:
2819 * @window: The #GdkWindow to get the decorations from
2820 * @decorations: The window decorations will be written here
2822 * Returns the decorations set on the GdkWindow with #gdk_window_set_decorations
2823 * Returns: TRUE if the window has decorations set, FALSE otherwise.
2826 gdk_window_get_decorations(GdkWindow *window,
2827 GdkWMDecoration *decorations)
2829 MotifWmHints *hints;
2830 gboolean result = FALSE;
2832 hints = gdk_window_get_mwm_hints (window);
2836 if (hints->flags & MWM_HINTS_DECORATIONS)
2838 *decorations = hints->decorations;
2849 gdk_window_set_functions (GdkWindow *window,
2850 GdkWMFunction functions)
2854 g_return_if_fail (window != NULL);
2855 g_return_if_fail (GDK_IS_WINDOW (window));
2857 hints.flags = MWM_HINTS_FUNCTIONS;
2858 hints.functions = functions;
2860 gdk_window_set_mwm_hints (window, &hints);
2863 #ifdef HAVE_SHAPE_EXT
2866 * propagate the shapes from all child windows of a GDK window to the parent
2867 * window. Shamelessly ripped from Enlightenment's code
2875 struct _gdk_span *next;
2879 gdk_add_to_span (struct _gdk_span **s,
2883 struct _gdk_span *ptr1, *ptr2, *noo, *ss;
2890 /* scan the spans for this line */
2893 /* -- -> new span */
2894 /* == -> existing span */
2895 /* ## -> spans intersect */
2896 /* if we are in the middle of spanning the span into the line */
2899 /* case: ---- ==== */
2900 if (xx < ptr1->start - 1)
2902 /* ends before next span - extend to here */
2906 /* case: ----##=== */
2907 else if (xx <= ptr1->end)
2909 /* crosses into next span - delete next span and append */
2910 ss->end = ptr1->end;
2911 ss->next = ptr1->next;
2915 /* case: ---###--- */
2918 /* overlaps next span - delete and keep checking */
2919 ss->next = ptr1->next;
2924 /* otherwise havent started spanning it in yet */
2927 /* case: ---- ==== */
2928 if (xx < ptr1->start - 1)
2930 /* insert span here in list */
2931 noo = g_malloc (sizeof (struct _gdk_span));
2945 /* case: ----##=== */
2946 else if ((x < ptr1->start) && (xx <= ptr1->end))
2948 /* expand this span to the left point of the new one */
2952 /* case: ===###=== */
2953 else if ((x >= ptr1->start) && (xx <= ptr1->end))
2955 /* throw the span away */
2958 /* case: ---###--- */
2959 else if ((x < ptr1->start) && (xx > ptr1->end))
2966 /* case: ===##---- */
2967 else if ((x >= ptr1->start) && (x <= ptr1->end + 1) && (xx > ptr1->end))
2973 /* case: ==== ---- */
2974 /* case handled by next loop iteration - first case */
2979 /* it started in the middle but spans beyond your current list */
2985 /* it does not start inside a span or in the middle, so add it to the end */
2986 noo = g_malloc (sizeof (struct _gdk_span));
2994 noo->next = ptr2->next;
3007 gdk_add_rectangles (Display *disp,
3009 struct _gdk_span **spans,
3016 gint x1, y1, x2, y2;
3020 rl = XShapeGetRectangles (disp, win, ShapeBounding, &rn, &ord);
3023 /* go through all clip rects in this window's shape */
3024 for (k = 0; k < rn; k++)
3026 /* for each clip rect, add it to each line's spans */
3028 x2 = x + rl[k].x + (rl[k].width - 1);
3030 y2 = y + rl[k].y + (rl[k].height - 1);
3039 for (a = y1; a <= y2; a++)
3042 gdk_add_to_span (&spans[a], x1, x2);
3050 gdk_propagate_shapes (Display *disp,
3054 Window rt, par, *list = NULL;
3055 gint i, j, num = 0, num_rects = 0;
3059 XRectangle *rects = NULL;
3060 struct _gdk_span **spans = NULL, *ptr1, *ptr2, *ptr3;
3061 XWindowAttributes xatt;
3063 XGetGeometry (disp, win, &rt, &x, &y, &w, &h, &d, &d);
3068 spans = g_malloc (sizeof (struct _gdk_span *) * h);
3070 for (i = 0; i < h; i++)
3072 XQueryTree (disp, win, &rt, &par, &list, (unsigned int *)&num);
3075 /* go through all child windows and create/insert spans */
3076 for (i = 0; i < num; i++)
3078 if (XGetWindowAttributes (disp, list[i], &xatt) && (xatt.map_state != IsUnmapped))
3079 if (XGetGeometry (disp, list[i], &rt, &x, &y, &w, &h, &d, &d))
3080 gdk_add_rectangles (disp, list[i], spans, basew, baseh, x, y);
3083 gdk_add_rectangles (disp, win, spans, basew, baseh, x, y);
3085 /* go through the spans list and build a list of rects */
3086 rects = g_malloc (sizeof (XRectangle) * 256);
3088 for (i = 0; i < baseh; i++)
3091 /* go through the line for all spans */
3094 rects[num_rects].x = ptr1->start;
3095 rects[num_rects].y = i;
3096 rects[num_rects].width = ptr1->end - ptr1->start + 1;
3097 rects[num_rects].height = 1;
3099 /* if there are more lines */
3101 /* while contigous rects (same start/end coords) exist */
3102 while ((contig) && (j < baseh))
3104 /* search next line for spans matching this one */
3110 /* if we have an exact span match set contig */
3111 if ((ptr2->start == ptr1->start) &&
3112 (ptr2->end == ptr1->end))
3115 /* remove the span - not needed */
3118 ptr3->next = ptr2->next;
3124 spans[j] = ptr2->next;
3130 /* gone past the span point no point looking */
3131 else if (ptr2->start < ptr1->start)
3139 /* if a contiguous span was found increase the rect h */
3142 rects[num_rects].height++;
3146 /* up the rect count */
3148 /* every 256 new rects increase the rect array */
3149 if ((num_rects % 256) == 0)
3150 rects = g_realloc (rects, sizeof (XRectangle) * (num_rects + 256));
3154 /* set the rects as the shape mask */
3157 XShapeCombineRectangles (disp, win, ShapeBounding, 0, 0, rects, num_rects,
3158 ShapeSet, YXSorted);
3163 /* free up all the spans we made */
3164 for (i = 0; i < baseh; i++)
3177 #endif /* HAVE_SHAPE_EXT */
3180 gdk_window_set_child_shapes (GdkWindow *window)
3182 g_return_if_fail (window != NULL);
3183 g_return_if_fail (GDK_IS_WINDOW (window));
3185 #ifdef HAVE_SHAPE_EXT
3186 if (!GDK_WINDOW_DESTROYED (window) &&
3187 gdk_window_have_shape_ext ())
3188 gdk_propagate_shapes (GDK_WINDOW_XDISPLAY (window),
3189 GDK_WINDOW_XID (window), FALSE);
3194 gdk_window_merge_child_shapes (GdkWindow *window)
3196 g_return_if_fail (window != NULL);
3197 g_return_if_fail (GDK_IS_WINDOW (window));
3199 #ifdef HAVE_SHAPE_EXT
3200 if (!GDK_WINDOW_DESTROYED (window) &&
3201 gdk_window_have_shape_ext ())
3202 gdk_propagate_shapes (GDK_WINDOW_XDISPLAY (window),
3203 GDK_WINDOW_XID (window), TRUE);
3207 /* Support for windows that can be guffaw-scrolled
3208 * (See http://www.gtk.org/~otaylor/whitepapers/guffaw-scrolling.txt)
3212 gdk_window_gravity_works (void)
3214 enum { UNKNOWN, NO, YES };
3215 static gint gravity_works = UNKNOWN;
3217 if (gravity_works == UNKNOWN)
3224 /* This particular server apparently has a bug so that the test
3225 * works but the actual code crashes it
3227 if ((!strcmp (XServerVendor (gdk_display), "Sun Microsystems, Inc.")) &&
3228 (VendorRelease (gdk_display) == 3400))
3234 attr.window_type = GDK_WINDOW_TEMP;
3235 attr.wclass = GDK_INPUT_OUTPUT;
3240 attr.event_mask = 0;
3242 parent = gdk_window_new (NULL, &attr, GDK_WA_X | GDK_WA_Y);
3244 attr.window_type = GDK_WINDOW_CHILD;
3245 child = gdk_window_new (parent, &attr, GDK_WA_X | GDK_WA_Y);
3247 gdk_window_set_static_win_gravity (child, TRUE);
3249 gdk_window_resize (parent, 100, 110);
3250 gdk_window_move (parent, 0, -10);
3251 gdk_window_move_resize (parent, 0, 0, 100, 100);
3253 gdk_window_resize (parent, 100, 110);
3254 gdk_window_move (parent, 0, -10);
3255 gdk_window_move_resize (parent, 0, 0, 100, 100);
3257 gdk_window_get_geometry (child, NULL, &y, NULL, NULL, NULL);
3259 gdk_window_destroy (parent);
3260 gdk_window_destroy (child);
3262 gravity_works = ((y == -20) ? YES : NO);
3265 return (gravity_works == YES);
3269 gdk_window_set_static_bit_gravity (GdkWindow *window, gboolean on)
3271 XSetWindowAttributes xattributes;
3272 guint xattributes_mask = 0;
3274 g_return_if_fail (window != NULL);
3276 xattributes.bit_gravity = StaticGravity;
3277 xattributes_mask |= CWBitGravity;
3278 xattributes.bit_gravity = on ? StaticGravity : ForgetGravity;
3279 XChangeWindowAttributes (GDK_WINDOW_XDISPLAY (window),
3280 GDK_WINDOW_XID (window),
3281 CWBitGravity, &xattributes);
3285 gdk_window_set_static_win_gravity (GdkWindow *window, gboolean on)
3287 XSetWindowAttributes xattributes;
3289 g_return_if_fail (window != NULL);
3291 xattributes.win_gravity = on ? StaticGravity : NorthWestGravity;
3293 XChangeWindowAttributes (GDK_WINDOW_XDISPLAY (window),
3294 GDK_WINDOW_XID (window),
3295 CWWinGravity, &xattributes);
3298 /*************************************************************
3299 * gdk_window_set_static_gravities:
3300 * Set the bit gravity of the given window to static,
3301 * and flag it so all children get static subwindow
3304 * window: window for which to set static gravity
3305 * use_static: Whether to turn static gravity on or off.
3307 * Does the XServer support static gravity?
3308 *************************************************************/
3311 gdk_window_set_static_gravities (GdkWindow *window,
3312 gboolean use_static)
3314 GdkWindowObject *private = (GdkWindowObject *)window;
3317 g_return_val_if_fail (window != NULL, FALSE);
3318 g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
3320 if (!use_static == !private->guffaw_gravity)
3323 if (use_static && !gdk_window_gravity_works ())
3326 private->guffaw_gravity = use_static;
3328 if (!GDK_WINDOW_DESTROYED (window))
3330 gdk_window_set_static_bit_gravity (window, use_static);
3332 tmp_list = private->children;
3335 gdk_window_set_static_win_gravity (window, use_static);
3337 tmp_list = tmp_list->next;
3344 /* internal function created for and used by gdk_window_xid_at_coords */
3346 gdk_window_xid_at (Window base,
3352 gboolean excl_child)
3355 Window *list = NULL;
3356 Window child = 0, parent_win = 0, root_win = 0;
3358 unsigned int ww, wh, wb, wd, num;
3361 xdisplay = GDK_DISPLAY ();
3362 if (!XGetGeometry (xdisplay, base, &root_win, &wx, &wy, &ww, &wh, &wb, &wd))
3369 (x < (int) (wx + ww)) &&
3370 (y < (int) (wy + wh))))
3373 if (!XQueryTree (xdisplay, base, &root_win, &parent_win, &list, &num))
3378 for (i = num - 1; ; i--)
3380 if ((!excl_child) || (!g_list_find (excludes, (gpointer *) list[i])))
3382 if ((child = gdk_window_xid_at (list[i], wx, wy, x, y, excludes, excl_child)) != 0)
3397 * The following fucntion by The Rasterman <raster@redhat.com>
3398 * This function returns the X Window ID in which the x y location is in
3399 * (x and y being relative to the root window), excluding any windows listed
3400 * in the GList excludes (this is a list of X Window ID's - gpointer being
3403 * This is primarily designed for internal gdk use - for DND for example
3404 * when using a shaped icon window as the drag object - you exclude the
3405 * X Window ID of the "icon" (perhaps more if excludes may be needed) and
3406 * You can get back an X Window ID as to what X Window ID is infact under
3407 * those X,Y co-ordinates.
3410 gdk_window_xid_at_coords (gint x,
3413 gboolean excl_child)
3417 Window *list = NULL;
3418 Window root, child = 0, parent_win = 0, root_win = 0;
3422 window = gdk_parent_root;
3423 xdisplay = GDK_WINDOW_XDISPLAY (window);
3424 root = GDK_WINDOW_XID (window);
3425 num = g_list_length (excludes);
3427 gdk_x11_grab_server ();
3428 if (!XQueryTree (xdisplay, root, &root_win, &parent_win, &list, &num))
3430 gdk_x11_ungrab_server ();
3438 XWindowAttributes xwa;
3440 XGetWindowAttributes (xdisplay, list [i], &xwa);
3442 if (xwa.map_state != IsViewable)
3445 if (excl_child && g_list_find (excludes, (gpointer *) list[i]))
3448 if ((child = gdk_window_xid_at (list[i], 0, 0, x, y, excludes, excl_child)) == 0)
3453 if (!g_list_find (excludes, (gpointer *) child))
3456 gdk_x11_ungrab_server ();
3463 gdk_x11_ungrab_server ();
3469 gdk_x11_ungrab_server ();
3474 wmspec_moveresize (GdkWindow *window,
3482 /* Release passive grab */
3483 gdk_pointer_ungrab (timestamp);
3485 xev.xclient.type = ClientMessage;
3486 xev.xclient.serial = 0;
3487 xev.xclient.send_event = True;
3488 xev.xclient.display = gdk_display;
3489 xev.xclient.window = GDK_WINDOW_XID (window);
3490 xev.xclient.message_type = gdk_atom_intern ("_NET_WM_MOVERESIZE", FALSE);
3491 xev.xclient.format = 32;
3492 xev.xclient.data.l[0] = root_x;
3493 xev.xclient.data.l[1] = root_y;
3494 xev.xclient.data.l[2] = direction;
3495 xev.xclient.data.l[3] = 0;
3496 xev.xclient.data.l[4] = 0;
3498 XSendEvent (gdk_display, gdk_root_window, False,
3499 SubstructureRedirectMask | SubstructureNotifyMask,
3503 /* From the WM spec */
3504 #define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0
3505 #define _NET_WM_MOVERESIZE_SIZE_TOP 1
3506 #define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT 2
3507 #define _NET_WM_MOVERESIZE_SIZE_RIGHT 3
3508 #define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4
3509 #define _NET_WM_MOVERESIZE_SIZE_BOTTOM 5
3510 #define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT 6
3511 #define _NET_WM_MOVERESIZE_SIZE_LEFT 7
3512 #define _NET_WM_MOVERESIZE_MOVE 8
3515 wmspec_resize_drag (GdkWindow *window,
3524 /* Let the compiler turn a switch into a table, instead
3525 * of doing the table manually, this way is easier to verify.
3529 case GDK_WINDOW_EDGE_NORTH_WEST:
3530 direction = _NET_WM_MOVERESIZE_SIZE_TOPLEFT;
3533 case GDK_WINDOW_EDGE_NORTH:
3534 direction = _NET_WM_MOVERESIZE_SIZE_TOP;
3537 case GDK_WINDOW_EDGE_NORTH_EAST:
3538 direction = _NET_WM_MOVERESIZE_SIZE_TOPRIGHT;
3541 case GDK_WINDOW_EDGE_WEST:
3542 direction = _NET_WM_MOVERESIZE_SIZE_LEFT;
3545 case GDK_WINDOW_EDGE_EAST:
3546 direction = _NET_WM_MOVERESIZE_SIZE_RIGHT;
3549 case GDK_WINDOW_EDGE_SOUTH_WEST:
3550 direction = _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT;
3553 case GDK_WINDOW_EDGE_SOUTH:
3554 direction = _NET_WM_MOVERESIZE_SIZE_BOTTOM;
3557 case GDK_WINDOW_EDGE_SOUTH_EAST:
3558 direction = _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT;
3562 g_warning ("gdk_window_begin_resize_drag: bad resize edge %d!",
3568 wmspec_moveresize (window, direction, root_x, root_y, timestamp);
3571 /* This is global for use in gdkevents-x11.c */
3572 GdkWindow *_gdk_moveresize_window;
3574 static GdkWindow *moveresize_emulation_window = NULL;
3575 static gboolean is_resize = FALSE;
3576 static GdkWindowEdge resize_edge;
3577 static gint moveresize_button;
3578 static gint moveresize_x;
3579 static gint moveresize_y;
3580 static gint moveresize_orig_x;
3581 static gint moveresize_orig_y;
3582 static gint moveresize_orig_width;
3583 static gint moveresize_orig_height;
3584 static GdkWindowHints moveresize_geom_mask = 0;
3585 static GdkGeometry moveresize_geometry;
3586 static Time moveresize_process_time;
3588 static XEvent *moveresize_pending_event;
3591 update_pos (gint new_root_x,
3596 dx = new_root_x - moveresize_x;
3597 dy = new_root_y - moveresize_y;
3603 w = moveresize_orig_width;
3604 h = moveresize_orig_height;
3606 switch (resize_edge)
3608 case GDK_WINDOW_EDGE_SOUTH_EAST:
3617 if (moveresize_geom_mask)
3619 gdk_window_constrain_size (&moveresize_geometry,
3620 moveresize_geom_mask,
3625 gdk_window_resize (_gdk_moveresize_window, w, h);
3631 x = moveresize_orig_x + dx;
3632 y = moveresize_orig_y + dy;
3634 gdk_window_move (_gdk_moveresize_window, x, y);
3641 gdk_window_destroy (moveresize_emulation_window);
3642 moveresize_emulation_window = NULL;
3643 _gdk_moveresize_window = NULL;
3645 if (moveresize_pending_event)
3647 g_free (moveresize_pending_event);
3648 moveresize_pending_event = NULL;
3653 lookahead_motion_predicate (Display *display,
3657 gboolean *seen_release = (gboolean *)arg;
3662 switch (event->xany.type)
3665 *seen_release = TRUE;
3668 moveresize_process_time = event->xmotion.time;
3678 moveresize_lookahead (XEvent *event)
3681 gboolean seen_release = FALSE;
3683 if (moveresize_process_time)
3685 if (event->xmotion.time == moveresize_process_time)
3687 moveresize_process_time = 0;
3694 XCheckIfEvent (gdk_display, &tmp_event,
3695 lookahead_motion_predicate, (XPointer)&seen_release);
3697 return moveresize_process_time == 0;
3701 _gdk_moveresize_handle_event (XEvent *event)
3703 guint button_mask = 0;
3704 GdkWindowObject *window_private = (GdkWindowObject *) _gdk_moveresize_window;
3706 button_mask = GDK_BUTTON1_MASK << (moveresize_button - 1);
3708 switch (event->xany.type)
3711 if (window_private->resize_count > 0)
3713 if (moveresize_pending_event)
3714 *moveresize_pending_event = *event;
3716 moveresize_pending_event = g_memdup (event, sizeof (XEvent));
3720 if (!moveresize_lookahead (event))
3723 update_pos (event->xmotion.x_root,
3724 event->xmotion.y_root);
3726 /* This should never be triggered in normal cases, but in the
3727 * case where the drag started without an implicit grab being
3728 * in effect, we could miss the release if it occurs before
3729 * we grab the pointer; this ensures that we will never
3730 * get a permanently stuck grab.
3732 if ((event->xmotion.state & button_mask) == 0)
3737 update_pos (event->xbutton.x_root,
3738 event->xbutton.y_root);
3740 if (event->xbutton.button == moveresize_button)
3747 _gdk_moveresize_configure_done (void)
3751 if (moveresize_pending_event)
3753 tmp_event = moveresize_pending_event;
3754 moveresize_pending_event = NULL;
3755 _gdk_moveresize_handle_event (tmp_event);
3761 create_moveresize_window (guint32 timestamp)
3763 GdkWindowAttr attributes;
3764 gint attributes_mask;
3765 GdkGrabStatus status;
3767 g_assert (moveresize_emulation_window == NULL);
3769 attributes.x = -100;
3770 attributes.y = -100;
3771 attributes.width = 10;
3772 attributes.height = 10;
3773 attributes.window_type = GDK_WINDOW_TEMP;
3774 attributes.wclass = GDK_INPUT_ONLY;
3775 attributes.override_redirect = TRUE;
3776 attributes.event_mask = 0;
3778 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_NOREDIR;
3780 moveresize_emulation_window =
3781 gdk_window_new (NULL, &attributes, attributes_mask);
3783 gdk_window_show (moveresize_emulation_window);
3785 status = gdk_pointer_grab (moveresize_emulation_window,
3787 GDK_BUTTON_RELEASE_MASK |
3788 GDK_POINTER_MOTION_MASK,
3793 if (status != GDK_GRAB_SUCCESS)
3795 /* If this fails, some other client has grabbed the window
3798 gdk_window_destroy (moveresize_emulation_window);
3799 moveresize_emulation_window = NULL;
3802 moveresize_process_time = 0;
3806 emulate_resize_drag (GdkWindow *window,
3814 moveresize_button = button;
3816 moveresize_x = root_x;
3817 moveresize_y = root_y;
3818 _gdk_moveresize_window = GDK_WINDOW (g_object_ref (G_OBJECT (window)));
3820 gdk_window_get_size (window, &moveresize_orig_width, &moveresize_orig_height);
3822 moveresize_geom_mask = 0;
3823 gdk_window_get_geometry_hints (window,
3824 &moveresize_geometry,
3825 &moveresize_geom_mask);
3827 create_moveresize_window (timestamp);
3831 emulate_move_drag (GdkWindow *window,
3838 moveresize_button = button;
3839 moveresize_x = root_x;
3840 moveresize_y = root_y;
3841 _gdk_moveresize_window = GDK_WINDOW (g_object_ref (G_OBJECT (window)));
3843 gdk_window_get_deskrelative_origin (_gdk_moveresize_window,
3845 &moveresize_orig_y);
3847 create_moveresize_window (timestamp);
3851 gdk_window_begin_resize_drag (GdkWindow *window,
3858 g_return_if_fail (GDK_IS_WINDOW (window));
3859 g_return_if_fail (moveresize_emulation_window == NULL);
3861 if (GDK_WINDOW_DESTROYED (window))
3864 if (gdk_net_wm_supports (gdk_atom_intern ("_NET_WM_MOVERESIZE", FALSE)))
3865 wmspec_resize_drag (window, edge, button, root_x, root_y, timestamp);
3867 emulate_resize_drag (window, edge, button, root_x, root_y, timestamp);
3871 gdk_window_begin_move_drag (GdkWindow *window,
3877 g_return_if_fail (GDK_IS_WINDOW (window));
3878 g_return_if_fail (moveresize_emulation_window == NULL);
3880 if (GDK_WINDOW_DESTROYED (window))
3883 if (gdk_net_wm_supports (gdk_atom_intern ("_NET_WM_MOVERESIZE", FALSE)))
3884 wmspec_moveresize (window, _NET_WM_MOVERESIZE_MOVE,
3885 root_x, root_y, timestamp);
3887 emulate_move_drag (window, button, root_x, root_y, timestamp);