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>
35 #include "gdkwindow.h"
36 #include "gdkinputprivate.h"
37 #include "gdkprivate-x11.h"
38 #include "gdkregion.h"
39 #include "gdkinternals.h"
41 #include "gdkwindow-x11.h"
49 #include <X11/extensions/shape.h>
52 const int _gdk_event_mask_table[21] =
56 PointerMotionHintMask,
73 SubstructureNotifyMask,
74 ButtonPressMask /* SCROLL; on X mouse wheel events is treated as mouse button 4/5 */
76 const int _gdk_nenvent_masks = sizeof (_gdk_event_mask_table) / sizeof (int);
78 /* Forward declarations */
79 static gboolean gdk_window_gravity_works (void);
80 static void gdk_window_set_static_win_gravity (GdkWindow *window,
82 static gboolean gdk_window_have_shape_ext (void);
83 static gboolean gdk_window_icon_name_set (GdkWindow *window);
85 static GdkColormap* gdk_window_impl_x11_get_colormap (GdkDrawable *drawable);
86 static void gdk_window_impl_x11_set_colormap (GdkDrawable *drawable,
88 static void gdk_window_impl_x11_get_size (GdkDrawable *drawable,
91 static GdkRegion* gdk_window_impl_x11_get_visible_region (GdkDrawable *drawable);
92 static void gdk_window_impl_x11_init (GdkWindowImplX11 *window);
93 static void gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass);
94 static void gdk_window_impl_x11_finalize (GObject *object);
96 static gpointer parent_class = NULL;
99 gdk_window_impl_x11_get_type (void)
101 static GType object_type = 0;
105 static const GTypeInfo object_info =
107 sizeof (GdkWindowImplX11Class),
108 (GBaseInitFunc) NULL,
109 (GBaseFinalizeFunc) NULL,
110 (GClassInitFunc) gdk_window_impl_x11_class_init,
111 NULL, /* class_finalize */
112 NULL, /* class_data */
113 sizeof (GdkWindowImplX11),
115 (GInstanceInitFunc) gdk_window_impl_x11_init,
118 object_type = g_type_register_static (GDK_TYPE_DRAWABLE_IMPL_X11,
127 _gdk_window_impl_get_type (void)
129 return gdk_window_impl_x11_get_type ();
133 gdk_window_impl_x11_init (GdkWindowImplX11 *impl)
140 gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass)
142 GObjectClass *object_class = G_OBJECT_CLASS (klass);
143 GdkDrawableClass *drawable_class = GDK_DRAWABLE_CLASS (klass);
145 parent_class = g_type_class_peek_parent (klass);
147 object_class->finalize = gdk_window_impl_x11_finalize;
149 drawable_class->set_colormap = gdk_window_impl_x11_set_colormap;
150 drawable_class->get_colormap = gdk_window_impl_x11_get_colormap;
151 drawable_class->get_size = gdk_window_impl_x11_get_size;
153 /* Visible and clip regions are the same */
154 drawable_class->get_clip_region = gdk_window_impl_x11_get_visible_region;
155 drawable_class->get_visible_region = gdk_window_impl_x11_get_visible_region;
159 gdk_window_impl_x11_finalize (GObject *object)
161 GdkWindowObject *wrapper;
162 GdkDrawableImplX11 *draw_impl;
163 GdkWindowImplX11 *window_impl;
165 g_return_if_fail (GDK_IS_WINDOW_IMPL_X11 (object));
167 draw_impl = GDK_DRAWABLE_IMPL_X11 (object);
168 window_impl = GDK_WINDOW_IMPL_X11 (object);
170 wrapper = (GdkWindowObject*) draw_impl->wrapper;
172 if (!GDK_WINDOW_DESTROYED (wrapper))
174 gdk_xid_table_remove (draw_impl->xid);
175 if (window_impl->focus_window)
176 gdk_xid_table_remove (window_impl->focus_window);
179 G_OBJECT_CLASS (parent_class)->finalize (object);
183 gdk_window_impl_x11_get_colormap (GdkDrawable *drawable)
185 GdkDrawableImplX11 *drawable_impl;
186 GdkWindowImplX11 *window_impl;
188 g_return_val_if_fail (GDK_IS_WINDOW_IMPL_X11 (drawable), NULL);
190 drawable_impl = GDK_DRAWABLE_IMPL_X11 (drawable);
191 window_impl = GDK_WINDOW_IMPL_X11 (drawable);
193 if (!((GdkWindowObject *) drawable_impl->wrapper)->input_only &&
194 drawable_impl->colormap == NULL)
196 XWindowAttributes window_attributes;
198 XGetWindowAttributes (drawable_impl->xdisplay,
201 drawable_impl->colormap =
202 gdk_colormap_lookup (window_attributes.colormap);
205 return drawable_impl->colormap;
209 gdk_window_impl_x11_set_colormap (GdkDrawable *drawable,
212 GdkWindowImplX11 *impl;
213 GdkDrawableImplX11 *draw_impl;
215 g_return_if_fail (GDK_IS_WINDOW_IMPL_X11 (drawable));
217 impl = GDK_WINDOW_IMPL_X11 (drawable);
218 draw_impl = GDK_DRAWABLE_IMPL_X11 (drawable);
221 GDK_DRAWABLE_CLASS (parent_class)->set_colormap (drawable, cmap);
225 XSetWindowColormap (draw_impl->xdisplay,
227 GDK_COLORMAP_XCOLORMAP (cmap));
229 if (((GdkWindowObject*)draw_impl->wrapper)->window_type !=
231 gdk_window_add_colormap_windows (GDK_WINDOW (draw_impl->wrapper));
237 gdk_window_impl_x11_get_size (GdkDrawable *drawable,
241 g_return_if_fail (GDK_IS_WINDOW_IMPL_X11 (drawable));
244 *width = GDK_WINDOW_IMPL_X11 (drawable)->width;
246 *height = GDK_WINDOW_IMPL_X11 (drawable)->height;
250 gdk_window_impl_x11_get_visible_region (GdkDrawable *drawable)
252 GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (drawable);
253 GdkRectangle result_rect;
257 result_rect.width = impl->width;
258 result_rect.height = impl->height;
260 gdk_rectangle_intersect (&result_rect, &impl->position_info.clip_rect, &result_rect);
262 return gdk_region_rectangle (&result_rect);
266 _gdk_windowing_window_init (void)
268 GdkWindowObject *private;
269 GdkWindowImplX11 *impl;
270 GdkDrawableImplX11 *draw_impl;
271 XWindowAttributes xattributes;
274 unsigned int border_width;
278 g_assert (_gdk_parent_root == NULL);
280 XGetGeometry (gdk_display, _gdk_root_window, &_gdk_root_window,
281 &x, &y, &width, &height, &border_width, &depth);
282 XGetWindowAttributes (gdk_display, _gdk_root_window, &xattributes);
284 _gdk_parent_root = g_object_new (GDK_TYPE_WINDOW, NULL);
285 private = (GdkWindowObject *)_gdk_parent_root;
286 impl = GDK_WINDOW_IMPL_X11 (private->impl);
287 draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl);
289 draw_impl->xdisplay = gdk_display;
290 draw_impl->xid = _gdk_root_window;
291 draw_impl->wrapper = GDK_DRAWABLE (private);
293 private->window_type = GDK_WINDOW_ROOT;
294 private->depth = depth;
296 impl->height = height;
298 gdk_xid_table_insert (&_gdk_root_window, _gdk_parent_root);
301 static GdkAtom wm_client_leader_atom = GDK_NONE;
304 gdk_window_new (GdkWindow *parent,
305 GdkWindowAttr *attributes,
306 gint attributes_mask)
309 GdkWindowObject *private;
310 GdkWindowObject *parent_private;
311 GdkWindowImplX11 *impl;
312 GdkDrawableImplX11 *draw_impl;
320 XSetWindowAttributes xattributes;
321 long xattributes_mask;
322 XSizeHints size_hints;
324 XClassHint *class_hint;
332 g_return_val_if_fail (attributes != NULL, NULL);
335 parent = _gdk_parent_root;
337 g_return_val_if_fail (GDK_IS_WINDOW (parent), NULL);
339 parent_private = (GdkWindowObject*) parent;
340 if (GDK_WINDOW_DESTROYED (parent))
343 xparent = GDK_WINDOW_XID (parent);
345 window = g_object_new (GDK_TYPE_WINDOW, NULL);
346 private = (GdkWindowObject *)window;
347 impl = GDK_WINDOW_IMPL_X11 (private->impl);
348 draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl);
349 draw_impl->wrapper = GDK_DRAWABLE (window);
351 xdisplay = draw_impl->xdisplay = GDK_WINDOW_XDISPLAY (parent);
353 private->parent = (GdkWindowObject *)parent;
355 xattributes_mask = 0;
357 if (attributes_mask & GDK_WA_X)
362 if (attributes_mask & GDK_WA_Y)
369 impl->width = (attributes->width > 1) ? (attributes->width) : (1);
370 impl->height = (attributes->height > 1) ? (attributes->height) : (1);
372 if (attributes->wclass == GDK_INPUT_ONLY)
374 /* Backwards compatiblity - we've always ignored
375 * attributes->window_type for input-only windows
378 if (GDK_WINDOW_TYPE (parent) == GDK_WINDOW_ROOT &&
379 GDK_WINDOW_TYPE (parent) == GDK_WINDOW_FOREIGN)
380 private->window_type = GDK_WINDOW_TEMP;
382 private->window_type = GDK_WINDOW_CHILD;
385 private->window_type = attributes->window_type;
387 _gdk_window_init_position (GDK_WINDOW (private));
388 if (impl->position_info.big)
389 private->guffaw_gravity = TRUE;
391 if (attributes_mask & GDK_WA_VISUAL)
392 visual = attributes->visual;
394 visual = gdk_visual_get_system ();
395 xvisual = ((GdkVisualPrivate*) visual)->xvisual;
397 xattributes.event_mask = StructureNotifyMask;
398 for (i = 0; i < _gdk_nenvent_masks; i++)
400 if (attributes->event_mask & (1 << (i + 1)))
401 xattributes.event_mask |= _gdk_event_mask_table[i];
404 if (xattributes.event_mask)
405 xattributes_mask |= CWEventMask;
407 if (attributes_mask & GDK_WA_NOREDIR)
409 xattributes.override_redirect =
410 (attributes->override_redirect == FALSE)?False:True;
411 xattributes_mask |= CWOverrideRedirect;
414 xattributes.override_redirect = False;
416 if (parent_private && parent_private->guffaw_gravity)
418 xattributes.win_gravity = StaticGravity;
419 xattributes_mask |= CWWinGravity;
423 switch (private->window_type)
425 case GDK_WINDOW_TOPLEVEL:
426 case GDK_WINDOW_DIALOG:
427 case GDK_WINDOW_TEMP:
428 if (GDK_WINDOW_TYPE (parent) != GDK_WINDOW_ROOT &&
429 GDK_WINDOW_TYPE (parent) != GDK_WINDOW_FOREIGN)
431 g_warning (G_STRLOC "Toplevel windows must be created as children of\n"
432 "of a window of type GDK_WINDOW_ROOT or GDK_WINDOW_FOREIGN");
433 xparent = _gdk_root_window;
435 case GDK_WINDOW_CHILD:
438 g_warning (G_STRLOC "cannot make windows of type %d", private->window_type);
442 if (attributes->wclass == GDK_INPUT_OUTPUT)
445 depth = visual->depth;
447 private->input_only = FALSE;
448 private->depth = depth;
450 if (attributes_mask & GDK_WA_COLORMAP)
452 draw_impl->colormap = attributes->colormap;
453 gdk_colormap_ref (attributes->colormap);
457 if ((((GdkVisualPrivate*)gdk_visual_get_system ())->xvisual) == xvisual)
459 draw_impl->colormap =
460 gdk_colormap_get_system ();
461 gdk_colormap_ref (draw_impl->colormap);
465 draw_impl->colormap =
466 gdk_colormap_new (visual, FALSE);
470 private->bg_color.pixel = BlackPixel (gdk_display, _gdk_screen);
471 xattributes.background_pixel = private->bg_color.pixel;
473 private->bg_pixmap = NULL;
475 xattributes.border_pixel = BlackPixel (gdk_display, _gdk_screen);
476 xattributes_mask |= CWBorderPixel | CWBackPixel;
478 if (private->guffaw_gravity)
479 xattributes.bit_gravity = StaticGravity;
481 xattributes.bit_gravity = NorthWestGravity;
483 xattributes_mask |= CWBitGravity;
485 xattributes.colormap = GDK_COLORMAP_XCOLORMAP (draw_impl->colormap);
486 xattributes_mask |= CWColormap;
488 if (private->window_type == GDK_WINDOW_TEMP)
490 xattributes.save_under = True;
491 xattributes.override_redirect = True;
492 xattributes.cursor = None;
493 xattributes_mask |= CWSaveUnder | CWOverrideRedirect;
501 private->input_only = TRUE;
502 draw_impl->colormap = gdk_colormap_get_system ();
503 gdk_colormap_ref (draw_impl->colormap);
506 xid = draw_impl->xid = XCreateWindow (xdisplay, xparent,
507 impl->position_info.x, impl->position_info.y,
508 impl->position_info.width, impl->position_info.height,
509 0, depth, class, xvisual,
510 xattributes_mask, &xattributes);
512 gdk_drawable_ref (window);
513 gdk_xid_table_insert (&draw_impl->xid, window);
515 gdk_window_set_cursor (window, ((attributes_mask & GDK_WA_CURSOR) ?
516 (attributes->cursor) :
520 parent_private->children = g_list_prepend (parent_private->children, window);
522 switch (GDK_WINDOW_TYPE (private))
524 case GDK_WINDOW_DIALOG:
525 XSetTransientForHint (xdisplay, xid, xparent);
526 case GDK_WINDOW_TOPLEVEL:
527 case GDK_WINDOW_TEMP:
528 XSetWMProtocols (xdisplay, xid,
529 _gdk_wm_window_protocols, 3);
531 case GDK_WINDOW_CHILD:
532 if ((attributes->wclass == GDK_INPUT_OUTPUT) &&
533 (draw_impl->colormap != gdk_colormap_get_system ()) &&
534 (draw_impl->colormap != gdk_window_get_colormap (gdk_window_get_toplevel (window))))
536 GDK_NOTE (MISC, g_message ("adding colormap window\n"));
537 gdk_window_add_colormap_windows (window);
546 if (class != InputOnly)
548 /* The focus window is off the visible area, and serves to receive key
549 * press events so they don't get sent to child windows.
551 impl->focus_window = XCreateSimpleWindow (xdisplay, xid,
553 xattributes.background_pixel,
554 xattributes.background_pixel);
555 /* FIXME: probably better to actually track the requested event mask for the toplevel
557 XSelectInput (xdisplay, impl->focus_window,
558 KeyPressMask | KeyReleaseMask | FocusChangeMask);
560 XMapWindow (xdisplay, impl->focus_window);
561 gdk_xid_table_insert (&impl->focus_window, window);
564 size_hints.flags = PSize;
565 size_hints.width = impl->width;
566 size_hints.height = impl->height;
568 wm_hints.flags = StateHint | WindowGroupHint;
569 wm_hints.window_group = _gdk_leader_window;
570 wm_hints.input = True;
571 wm_hints.initial_state = NormalState;
573 /* FIXME: Is there any point in doing this? Do any WM's pay
574 * attention to PSize, and even if they do, is this the
577 XSetWMNormalHints (xdisplay, xid, &size_hints);
579 XSetWMHints (xdisplay, xid, &wm_hints);
581 if (!wm_client_leader_atom)
582 wm_client_leader_atom = gdk_atom_intern ("WM_CLIENT_LEADER", FALSE);
584 /* This will set WM_CLIENT_MACHINE and WM_LOCALE_NAME */
585 XSetWMProperties (xdisplay, xid, NULL, NULL, NULL, 0, NULL, NULL, NULL);
588 XChangeProperty (xdisplay, xid,
589 gdk_atom_intern ("_NET_WM_PID", FALSE),
594 XChangeProperty (xdisplay, xid,
595 wm_client_leader_atom,
596 XA_WINDOW, 32, PropModeReplace,
597 (guchar*) &_gdk_leader_window, 1);
599 if (attributes_mask & GDK_WA_TITLE)
600 title = attributes->title;
602 title = g_get_prgname ();
604 gdk_window_set_title (window, title);
606 if (attributes_mask & GDK_WA_WMCLASS)
608 class_hint = XAllocClassHint ();
609 class_hint->res_name = attributes->wmclass_name;
610 class_hint->res_class = attributes->wmclass_class;
611 XSetClassHint (xdisplay, xid, class_hint);
619 gdk_window_foreign_new (GdkNativeWindow anid)
622 GdkWindowObject *private;
623 GdkWindowObject *parent_private;
624 GdkWindowImplX11 *impl;
625 GdkDrawableImplX11 *draw_impl;
626 XWindowAttributes attrs;
628 Window *children = NULL;
632 gdk_error_trap_push ();
633 result = XGetWindowAttributes (gdk_display, anid, &attrs);
634 if (gdk_error_trap_pop () || !result)
637 /* FIXME: This is pretty expensive. Maybe the caller should supply
639 gdk_error_trap_push ();
640 result = XQueryTree (gdk_display, anid, &root, &parent, &children, &nchildren);
641 if (gdk_error_trap_pop () || !result)
647 window = g_object_new (GDK_TYPE_WINDOW, NULL);
648 private = (GdkWindowObject *)window;
649 impl = GDK_WINDOW_IMPL_X11 (private->impl);
650 draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl);
651 draw_impl->wrapper = GDK_DRAWABLE (window);
653 private->parent = gdk_xid_table_lookup (parent);
655 parent_private = (GdkWindowObject *)private->parent;
658 parent_private->children = g_list_prepend (parent_private->children, window);
660 draw_impl->xid = anid;
661 draw_impl->xdisplay = gdk_display;
663 private->x = attrs.x;
664 private->y = attrs.y;
665 impl->width = attrs.width;
666 impl->height = attrs.height;
667 private->window_type = GDK_WINDOW_FOREIGN;
668 private->destroyed = FALSE;
670 if (attrs.map_state == IsUnmapped)
671 private->state = GDK_WINDOW_STATE_WITHDRAWN;
675 private->depth = attrs.depth;
677 _gdk_window_init_position (GDK_WINDOW (private));
679 gdk_drawable_ref (window);
680 gdk_xid_table_insert (&GDK_WINDOW_XID (window), window);
686 _gdk_windowing_window_destroy (GdkWindow *window,
688 gboolean foreign_destroy)
690 GdkWindowObject *private = (GdkWindowObject *)window;
692 g_return_if_fail (GDK_IS_WINDOW (window));
694 _gdk_selection_window_destroyed (window);
696 if (private->extension_events != 0)
697 gdk_input_window_destroy (window);
699 if (private->window_type == GDK_WINDOW_FOREIGN)
701 if (!foreign_destroy && (private->parent != NULL))
703 /* It's somebody else's window, but in our heirarchy,
704 * so reparent it to the root window, and then send
705 * it a delete event, as if we were a WM
707 XClientMessageEvent xevent;
709 gdk_error_trap_push ();
710 gdk_window_hide (window);
711 gdk_window_reparent (window, NULL, 0, 0);
713 xevent.type = ClientMessage;
714 xevent.window = GDK_WINDOW_XID (window);
715 xevent.message_type = gdk_atom_intern ("WM_PROTOCOLS", FALSE);
717 xevent.data.l[0] = gdk_atom_intern ("WM_DELETE_WINDOW", FALSE);
718 xevent.data.l[1] = CurrentTime;
720 XSendEvent (GDK_WINDOW_XDISPLAY (window),
721 GDK_WINDOW_XID (window),
722 False, 0, (XEvent *)&xevent);
724 gdk_error_trap_pop ();
727 else if (!recursing && !foreign_destroy)
728 XDestroyWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
731 /* This function is called when the XWindow is really gone.
734 gdk_window_destroy_notify (GdkWindow *window)
736 GdkWindowImplX11 *window_impl;
738 g_return_if_fail (window != NULL);
740 window_impl = GDK_WINDOW_IMPL_X11 (((GdkWindowObject *)window)->impl);
742 if (!GDK_WINDOW_DESTROYED (window))
744 if (GDK_WINDOW_TYPE(window) != GDK_WINDOW_FOREIGN)
745 g_warning ("GdkWindow %#lx unexpectedly destroyed", GDK_WINDOW_XID (window));
747 _gdk_window_destroy (window, TRUE);
750 gdk_xid_table_remove (GDK_WINDOW_XID (window));
751 if (window_impl->focus_window)
752 gdk_xid_table_remove (window_impl->focus_window);
754 gdk_drawable_unref (window);
758 set_initial_hints (GdkWindow *window)
760 GdkWindowObject *private;
764 private = (GdkWindowObject*) window;
766 if (private->state & GDK_WINDOW_STATE_ICONIFIED)
770 wm_hints = XGetWMHints (GDK_WINDOW_XDISPLAY (window),
771 GDK_WINDOW_XID (window));
773 wm_hints = XAllocWMHints ();
775 wm_hints->flags |= StateHint;
776 wm_hints->initial_state = IconicState;
778 XSetWMHints (GDK_WINDOW_XDISPLAY (window),
779 GDK_WINDOW_XID (window), wm_hints);
783 /* We set the spec hints regardless of whether the spec is supported,
784 * since it can't hurt and it's kind of expensive to check whether
790 if (private->state & GDK_WINDOW_STATE_MAXIMIZED)
792 atoms[i] = gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_VERT", FALSE);
794 atoms[i] = gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_HORZ", FALSE);
798 if (private->state & GDK_WINDOW_STATE_STICKY)
800 atoms[i] = gdk_atom_intern ("_NET_WM_STATE_STICKY", FALSE);
804 if (private->modal_hint)
806 atoms[i] = gdk_atom_intern ("_NET_WM_STATE_MODAL", FALSE);
812 XChangeProperty (GDK_WINDOW_XDISPLAY (window),
813 GDK_WINDOW_XID (window),
814 gdk_atom_intern ("_NET_WM_STATE", FALSE),
815 XA_ATOM, 32, PropModeReplace,
819 if (private->state & GDK_WINDOW_STATE_STICKY)
821 atoms[0] = 0xFFFFFFFF;
822 XChangeProperty (GDK_WINDOW_XDISPLAY (window),
823 GDK_WINDOW_XID (window),
824 gdk_atom_intern ("_NET_WM_DESKTOP", FALSE),
825 XA_CARDINAL, 32, PropModeReplace,
831 show_window_internal (GdkWindow *window,
834 GdkWindowObject *private;
836 g_return_if_fail (GDK_IS_WINDOW (window));
838 private = (GdkWindowObject*) window;
839 if (!private->destroyed)
842 XRaiseWindow (GDK_WINDOW_XDISPLAY (window),
843 GDK_WINDOW_XID (window));
845 if (!GDK_WINDOW_IS_MAPPED (window))
847 set_initial_hints (window);
849 gdk_synthesize_window_state (window,
850 GDK_WINDOW_STATE_WITHDRAWN,
854 g_assert (GDK_WINDOW_IS_MAPPED (window));
856 if (GDK_WINDOW_IMPL_X11 (private->impl)->position_info.mapped)
857 XMapWindow (GDK_WINDOW_XDISPLAY (window),
858 GDK_WINDOW_XID (window));
863 * gdk_window_show_unraised:
864 * @window: a #GdkWindow
866 * Shows a #GdkWindow onscreen, but does not modify its stacking
867 * order. In contrast, gdk_window_show() will raise the window
868 * to the top of the window stack.
872 gdk_window_show_unraised (GdkWindow *window)
874 g_return_if_fail (GDK_IS_WINDOW (window));
876 show_window_internal (window, FALSE);
880 gdk_window_show (GdkWindow *window)
882 g_return_if_fail (GDK_IS_WINDOW (window));
884 show_window_internal (window, TRUE);
888 gdk_window_hide (GdkWindow *window)
890 GdkWindowObject *private;
892 g_return_if_fail (window != NULL);
894 private = (GdkWindowObject*) window;
896 /* You can't simply unmap toplevel windows. */
897 switch (private->window_type)
899 case GDK_WINDOW_TOPLEVEL:
900 case GDK_WINDOW_DIALOG:
901 case GDK_WINDOW_TEMP: /* ? */
902 gdk_window_withdraw (window);
906 case GDK_WINDOW_FOREIGN:
907 case GDK_WINDOW_ROOT:
908 case GDK_WINDOW_CHILD:
912 if (!private->destroyed)
914 if (GDK_WINDOW_IS_MAPPED (window))
915 gdk_synthesize_window_state (window,
917 GDK_WINDOW_STATE_WITHDRAWN);
919 g_assert (!GDK_WINDOW_IS_MAPPED (window));
921 _gdk_window_clear_update_area (window);
923 XUnmapWindow (GDK_WINDOW_XDISPLAY (window),
924 GDK_WINDOW_XID (window));
929 gdk_window_withdraw (GdkWindow *window)
931 GdkWindowObject *private;
933 g_return_if_fail (window != NULL);
935 private = (GdkWindowObject*) window;
936 if (!private->destroyed)
938 if (GDK_WINDOW_IS_MAPPED (window))
939 gdk_synthesize_window_state (window,
941 GDK_WINDOW_STATE_WITHDRAWN);
943 g_assert (!GDK_WINDOW_IS_MAPPED (window));
945 XWithdrawWindow (GDK_WINDOW_XDISPLAY (window),
946 GDK_WINDOW_XID (window), 0);
951 gdk_window_move (GdkWindow *window,
955 GdkWindowObject *private = (GdkWindowObject *)window;
956 GdkWindowImplX11 *impl;
958 g_return_if_fail (window != NULL);
959 g_return_if_fail (GDK_IS_WINDOW (window));
961 impl = GDK_WINDOW_IMPL_X11 (private->impl);
963 if (!GDK_WINDOW_DESTROYED (window))
965 if (GDK_WINDOW_TYPE (private) == GDK_WINDOW_CHILD)
966 _gdk_window_move_resize_child (window, x, y,
967 impl->width, impl->height);
970 XMoveWindow (GDK_WINDOW_XDISPLAY (window),
971 GDK_WINDOW_XID (window),
978 gdk_window_resize (GdkWindow *window,
982 GdkWindowObject *private;
984 g_return_if_fail (window != NULL);
985 g_return_if_fail (GDK_IS_WINDOW (window));
992 private = (GdkWindowObject*) window;
994 if (!GDK_WINDOW_DESTROYED (window))
996 if (GDK_WINDOW_TYPE (private) == GDK_WINDOW_CHILD)
997 _gdk_window_move_resize_child (window, private->x, private->y,
1001 GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (private->impl);
1003 if (width != impl->width || height != impl->height)
1004 private->resize_count += 1;
1006 XResizeWindow (GDK_WINDOW_XDISPLAY (window),
1007 GDK_WINDOW_XID (window),
1014 gdk_window_move_resize (GdkWindow *window,
1020 GdkWindowObject *private;
1022 g_return_if_fail (window != NULL);
1023 g_return_if_fail (GDK_IS_WINDOW (window));
1030 private = (GdkWindowObject*) window;
1032 if (!GDK_WINDOW_DESTROYED (window))
1034 if (GDK_WINDOW_TYPE (private) == GDK_WINDOW_CHILD)
1035 _gdk_window_move_resize_child (window, x, y, width, height);
1038 GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (private->impl);
1040 if (width != impl->width || height != impl->height)
1041 private->resize_count += 1;
1043 XMoveResizeWindow (GDK_WINDOW_XDISPLAY (window),
1044 GDK_WINDOW_XID (window),
1045 x, y, width, height);
1051 gdk_window_reparent (GdkWindow *window,
1052 GdkWindow *new_parent,
1056 GdkWindowObject *window_private;
1057 GdkWindowObject *parent_private;
1058 GdkWindowObject *old_parent_private;
1060 g_return_if_fail (window != NULL);
1061 g_return_if_fail (GDK_IS_WINDOW (window));
1062 g_return_if_fail (new_parent == NULL || GDK_IS_WINDOW (new_parent));
1063 g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_ROOT);
1066 new_parent = _gdk_parent_root;
1068 window_private = (GdkWindowObject*) window;
1069 old_parent_private = (GdkWindowObject*)window_private->parent;
1070 parent_private = (GdkWindowObject*) new_parent;
1072 if (!GDK_WINDOW_DESTROYED (window) && !GDK_WINDOW_DESTROYED (new_parent))
1073 XReparentWindow (GDK_WINDOW_XDISPLAY (window),
1074 GDK_WINDOW_XID (window),
1075 GDK_WINDOW_XID (new_parent),
1078 window_private->parent = (GdkWindowObject *)new_parent;
1080 /* Switch the window type as appropriate */
1082 switch (GDK_WINDOW_TYPE (new_parent))
1084 case GDK_WINDOW_ROOT:
1085 case GDK_WINDOW_FOREIGN:
1086 /* Now a toplevel */
1087 if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD)
1089 GDK_WINDOW_TYPE (window) = GDK_WINDOW_TOPLEVEL;
1090 XSetWMProtocols (GDK_WINDOW_XDISPLAY (window),
1091 GDK_WINDOW_XID (window),
1092 _gdk_wm_window_protocols, 3);
1094 case GDK_WINDOW_TOPLEVEL:
1095 case GDK_WINDOW_CHILD:
1096 case GDK_WINDOW_DIALOG:
1097 case GDK_WINDOW_TEMP:
1098 if (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD &&
1099 GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN)
1101 /* If we were being sophisticated, we'd save the old window type
1102 * here, and restore it if we were reparented back to the
1103 * toplevel. However, the difference between different types
1104 * of toplevels only really matters on creation anyways.
1106 GDK_WINDOW_TYPE (window) = GDK_WINDOW_CHILD;
1110 if (old_parent_private)
1111 old_parent_private->children = g_list_remove (old_parent_private->children, window);
1113 if ((old_parent_private &&
1114 (!old_parent_private->guffaw_gravity != !parent_private->guffaw_gravity)) ||
1115 (!old_parent_private && parent_private->guffaw_gravity))
1116 gdk_window_set_static_win_gravity (window, parent_private->guffaw_gravity);
1118 parent_private->children = g_list_prepend (parent_private->children, window);
1119 _gdk_window_init_position (GDK_WINDOW (window_private));
1123 _gdk_windowing_window_clear_area (GdkWindow *window,
1129 g_return_if_fail (window != NULL);
1130 g_return_if_fail (GDK_IS_WINDOW (window));
1132 if (!GDK_WINDOW_DESTROYED (window))
1133 XClearArea (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
1134 x, y, width, height, False);
1138 _gdk_windowing_window_clear_area_e (GdkWindow *window,
1144 g_return_if_fail (window != NULL);
1145 g_return_if_fail (GDK_IS_WINDOW (window));
1147 if (!GDK_WINDOW_DESTROYED (window))
1148 XClearArea (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
1149 x, y, width, height, True);
1153 gdk_window_raise (GdkWindow *window)
1155 g_return_if_fail (window != NULL);
1156 g_return_if_fail (GDK_IS_WINDOW (window));
1158 if (!GDK_WINDOW_DESTROYED (window))
1159 XRaiseWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
1163 gdk_window_lower (GdkWindow *window)
1165 g_return_if_fail (window != NULL);
1166 g_return_if_fail (GDK_IS_WINDOW (window));
1168 if (!GDK_WINDOW_DESTROYED (window))
1169 XLowerWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
1173 gdk_window_focus (GdkWindow *window,
1176 g_return_if_fail (GDK_IS_WINDOW (window));
1178 if (GDK_WINDOW_DESTROYED (window))
1181 if (gdk_net_wm_supports (gdk_atom_intern ("_NET_ACTIVE_WINDOW", FALSE)))
1185 xev.xclient.type = ClientMessage;
1186 xev.xclient.serial = 0;
1187 xev.xclient.send_event = True;
1188 xev.xclient.window = GDK_WINDOW_XWINDOW (window);
1189 xev.xclient.display = gdk_display;
1190 xev.xclient.message_type = gdk_atom_intern ("_NET_ACTIVE_WINDOW", FALSE);
1191 xev.xclient.format = 32;
1192 xev.xclient.data.l[0] = 0;
1194 XSendEvent (gdk_display, _gdk_root_window, False,
1195 SubstructureRedirectMask | SubstructureNotifyMask,
1200 XRaiseWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
1202 /* There is no way of knowing reliably whether we are viewable so we need
1203 * to trap errors so we don't cause a BadMatch.
1205 gdk_error_trap_push ();
1206 XSetInputFocus (GDK_WINDOW_XDISPLAY (window),
1207 GDK_WINDOW_XWINDOW (window),
1210 XSync (GDK_WINDOW_XDISPLAY (window), False);
1211 gdk_error_trap_pop ();
1216 gdk_window_set_hints (GdkWindow *window,
1225 XSizeHints size_hints;
1227 g_return_if_fail (window != NULL);
1228 g_return_if_fail (GDK_IS_WINDOW (window));
1230 if (GDK_WINDOW_DESTROYED (window))
1233 size_hints.flags = 0;
1235 if (flags & GDK_HINT_POS)
1237 size_hints.flags |= PPosition;
1242 if (flags & GDK_HINT_MIN_SIZE)
1244 size_hints.flags |= PMinSize;
1245 size_hints.min_width = min_width;
1246 size_hints.min_height = min_height;
1249 if (flags & GDK_HINT_MAX_SIZE)
1251 size_hints.flags |= PMaxSize;
1252 size_hints.max_width = max_width;
1253 size_hints.max_height = max_height;
1256 /* FIXME: Would it be better to delete this property if
1257 * flags == 0? It would save space on the server
1259 XSetWMNormalHints (GDK_WINDOW_XDISPLAY (window),
1260 GDK_WINDOW_XID (window),
1265 * gdk_window_set_type_hint:
1266 * @window: A #GdkWindow
1267 * @hint: A hint of the function this window will have
1269 * The application can use this call to provide a hint to the window
1270 * manager about the functionality of a window. The window manager
1271 * can use this information when determining the decoration and behaviour
1274 * The hint must be set before the window is mapped.
1277 gdk_window_set_type_hint (GdkWindow *window,
1278 GdkWindowTypeHint hint)
1282 g_return_if_fail (window != NULL);
1283 g_return_if_fail (GDK_IS_WINDOW (window));
1285 if (GDK_WINDOW_DESTROYED (window))
1290 case GDK_WINDOW_TYPE_HINT_DIALOG:
1291 atom = gdk_atom_intern ("_NET_WM_WINDOW_TYPE_DIALOG", FALSE);
1293 case GDK_WINDOW_TYPE_HINT_MENU:
1294 atom = gdk_atom_intern ("_NET_WM_WINDOW_TYPE_MENU", FALSE);
1296 case GDK_WINDOW_TYPE_HINT_TOOLBAR:
1297 atom = gdk_atom_intern ("_NET_WM_WINDOW_TYPE_TOOLBAR", FALSE);
1300 g_warning ("Unknown hint %d passed to gdk_window_set_type_hint", hint);
1302 case GDK_WINDOW_TYPE_HINT_NORMAL:
1303 atom = gdk_atom_intern ("_NET_WM_WINDOW_TYPE_NORMAL", FALSE);
1307 XChangeProperty (GDK_WINDOW_XDISPLAY (window),
1308 GDK_WINDOW_XID (window),
1309 gdk_atom_intern ("_NET_WM_WINDOW_TYPE", FALSE),
1310 XA_ATOM, 32, PropModeReplace,
1311 (guchar *)&atom, 1);
1316 gdk_wmspec_change_state (gboolean add,
1323 #define _NET_WM_STATE_REMOVE 0 /* remove/unset property */
1324 #define _NET_WM_STATE_ADD 1 /* add/set property */
1325 #define _NET_WM_STATE_TOGGLE 2 /* toggle property */
1327 xev.xclient.type = ClientMessage;
1328 xev.xclient.serial = 0;
1329 xev.xclient.send_event = True;
1330 xev.xclient.display = gdk_display;
1331 xev.xclient.window = GDK_WINDOW_XID (window);
1332 xev.xclient.message_type = gdk_atom_intern ("_NET_WM_STATE", FALSE);
1333 xev.xclient.format = 32;
1334 xev.xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
1335 xev.xclient.data.l[1] = state1;
1336 xev.xclient.data.l[2] = state2;
1338 XSendEvent (gdk_display, _gdk_root_window, False,
1339 SubstructureRedirectMask | SubstructureNotifyMask,
1343 * gdk_window_set_modal_hint:
1344 * @window: A #GdkWindow
1345 * @modal: TRUE if the window is modal, FALSE otherwise.
1347 * The application can use this hint to tell the window manager
1348 * that a certain window has modal behaviour. The window manager
1349 * can use this information to handle modal windows in a special
1352 * You should only use this on windows for which you have
1353 * previously called #gdk_window_set_transient_for()
1356 gdk_window_set_modal_hint (GdkWindow *window,
1359 GdkWindowObject *private;
1361 g_return_if_fail (window != NULL);
1362 g_return_if_fail (GDK_IS_WINDOW (window));
1364 if (GDK_WINDOW_DESTROYED (window))
1367 private = (GdkWindowObject*) window;
1369 private->modal_hint = modal;
1371 if (GDK_WINDOW_IS_MAPPED (window))
1372 gdk_wmspec_change_state (modal, window,
1373 gdk_atom_intern ("_NET_WM_STATE_MODAL", FALSE),
1378 gdk_window_set_geometry_hints (GdkWindow *window,
1379 GdkGeometry *geometry,
1380 GdkWindowHints geom_mask)
1382 XSizeHints size_hints;
1384 g_return_if_fail (window != NULL);
1385 g_return_if_fail (GDK_IS_WINDOW (window));
1387 if (GDK_WINDOW_DESTROYED (window))
1390 size_hints.flags = 0;
1392 if (geom_mask & GDK_HINT_POS)
1394 size_hints.flags |= PPosition;
1395 /* We need to initialize the following obsolete fields because KWM
1396 * apparently uses these fields if they are non-zero.
1403 if (geom_mask & GDK_HINT_USER_POS)
1405 size_hints.flags |= USPosition;
1408 if (geom_mask & GDK_HINT_USER_SIZE)
1410 size_hints.flags |= USSize;
1413 if (geom_mask & GDK_HINT_MIN_SIZE)
1415 size_hints.flags |= PMinSize;
1416 size_hints.min_width = geometry->min_width;
1417 size_hints.min_height = geometry->min_height;
1420 if (geom_mask & GDK_HINT_MAX_SIZE)
1422 size_hints.flags |= PMaxSize;
1423 size_hints.max_width = MAX (geometry->max_width, 1);
1424 size_hints.max_height = MAX (geometry->max_height, 1);
1427 if (geom_mask & GDK_HINT_BASE_SIZE)
1429 size_hints.flags |= PBaseSize;
1430 size_hints.base_width = geometry->base_width;
1431 size_hints.base_height = geometry->base_height;
1434 if (geom_mask & GDK_HINT_RESIZE_INC)
1436 size_hints.flags |= PResizeInc;
1437 size_hints.width_inc = geometry->width_inc;
1438 size_hints.height_inc = geometry->height_inc;
1441 if (geom_mask & GDK_HINT_ASPECT)
1443 size_hints.flags |= PAspect;
1444 if (geometry->min_aspect <= 1)
1446 size_hints.min_aspect.x = 65536 * geometry->min_aspect;
1447 size_hints.min_aspect.y = 65536;
1451 size_hints.min_aspect.x = 65536;
1452 size_hints.min_aspect.y = 65536 / geometry->min_aspect;;
1454 if (geometry->max_aspect <= 1)
1456 size_hints.max_aspect.x = 65536 * geometry->max_aspect;
1457 size_hints.max_aspect.y = 65536;
1461 size_hints.max_aspect.x = 65536;
1462 size_hints.max_aspect.y = 65536 / geometry->max_aspect;;
1466 if (geom_mask & GDK_HINT_WIN_GRAVITY)
1468 size_hints.flags |= PWinGravity;
1469 size_hints.win_gravity = geometry->win_gravity;
1472 /* FIXME: Would it be better to delete this property if
1473 * geom_mask == 0? It would save space on the server
1475 XSetWMNormalHints (GDK_WINDOW_XDISPLAY (window),
1476 GDK_WINDOW_XID (window),
1481 gdk_window_get_geometry_hints (GdkWindow *window,
1482 GdkGeometry *geometry,
1483 GdkWindowHints *geom_mask)
1485 XSizeHints size_hints;
1486 glong junk_size_mask = 0;
1488 g_return_if_fail (GDK_IS_WINDOW (window));
1489 g_return_if_fail (geometry != NULL);
1490 g_return_if_fail (geom_mask != NULL);
1494 if (GDK_WINDOW_DESTROYED (window))
1497 if (!XGetWMNormalHints (GDK_WINDOW_XDISPLAY (window),
1498 GDK_WINDOW_XID (window),
1503 if (size_hints.flags & PMinSize)
1505 *geom_mask |= GDK_HINT_MIN_SIZE;
1506 geometry->min_width = size_hints.min_width;
1507 geometry->min_height = size_hints.min_height;
1510 if (size_hints.flags & PMaxSize)
1512 *geom_mask |= GDK_HINT_MAX_SIZE;
1513 geometry->max_width = MAX (size_hints.max_width, 1);
1514 geometry->max_height = MAX (size_hints.max_height, 1);
1517 if (size_hints.flags & PResizeInc)
1519 *geom_mask |= GDK_HINT_RESIZE_INC;
1520 geometry->width_inc = size_hints.width_inc;
1521 geometry->height_inc = size_hints.height_inc;
1524 if (size_hints.flags & PAspect)
1526 *geom_mask |= GDK_HINT_ASPECT;
1528 geometry->min_aspect = (gdouble) size_hints.min_aspect.x / (gdouble) size_hints.min_aspect.y;
1529 geometry->max_aspect = (gdouble) size_hints.max_aspect.x / (gdouble) size_hints.max_aspect.y;
1532 if (size_hints.flags & PWinGravity)
1534 *geom_mask |= GDK_HINT_WIN_GRAVITY;
1535 geometry->win_gravity = size_hints.win_gravity;
1540 utf8_is_latin1 (const gchar *str)
1542 const char *p = str;
1546 gunichar ch = g_utf8_get_char (p);
1551 p = g_utf8_next_char (p);
1557 /* Set the property to @utf8_str as STRING if the @utf8_str is fully
1558 * convertable to STRING, otherwise, set it as compound text
1561 set_text_property (GdkWindow *window,
1563 const gchar *utf8_str)
1565 guchar *prop_text = NULL;
1570 if (utf8_is_latin1 (utf8_str))
1572 prop_type = GDK_TARGET_STRING;
1573 prop_text = gdk_utf8_to_string_target (utf8_str);
1574 prop_length = strlen (prop_text);
1579 gdk_utf8_to_compound_text (utf8_str, &prop_type, &prop_format,
1580 &prop_text, &prop_length);
1585 XChangeProperty (GDK_WINDOW_XDISPLAY (window),
1586 GDK_WINDOW_XID (window),
1588 prop_type, prop_format,
1589 PropModeReplace, prop_text,
1597 gdk_window_set_title (GdkWindow *window,
1600 g_return_if_fail (window != NULL);
1601 g_return_if_fail (GDK_IS_WINDOW (window));
1603 if (GDK_WINDOW_DESTROYED (window))
1606 XChangeProperty (GDK_WINDOW_XDISPLAY (window),
1607 GDK_WINDOW_XID (window),
1608 gdk_atom_intern ("_NET_WM_NAME", FALSE),
1609 gdk_atom_intern ("UTF8_STRING", FALSE), 8,
1610 PropModeReplace, title,
1613 set_text_property (window, gdk_atom_intern ("WM_NAME", FALSE), title);
1614 if (!gdk_window_icon_name_set (window))
1616 XChangeProperty (GDK_WINDOW_XDISPLAY (window),
1617 GDK_WINDOW_XID (window),
1618 gdk_atom_intern ("_NET_WM_ICON_NAME", FALSE),
1619 gdk_atom_intern ("UTF8_STRING", FALSE), 8,
1620 PropModeReplace, title,
1622 set_text_property (window, gdk_atom_intern ("WM_ICON_NAME", FALSE), title);
1627 gdk_window_set_role (GdkWindow *window,
1630 g_return_if_fail (window != NULL);
1631 g_return_if_fail (GDK_IS_WINDOW (window));
1633 if (!GDK_WINDOW_DESTROYED (window))
1636 XChangeProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
1637 gdk_atom_intern ("WM_WINDOW_ROLE", FALSE), XA_STRING,
1638 8, PropModeReplace, role, strlen (role));
1640 XDeleteProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
1641 gdk_atom_intern ("WM_WINDOW_ROLE", FALSE));
1646 gdk_window_set_transient_for (GdkWindow *window,
1649 GdkWindowObject *private;
1650 GdkWindowObject *parent_private;
1652 g_return_if_fail (window != NULL);
1653 g_return_if_fail (GDK_IS_WINDOW (window));
1655 private = (GdkWindowObject*) window;
1656 parent_private = (GdkWindowObject*) parent;
1658 if (!GDK_WINDOW_DESTROYED (window) && !GDK_WINDOW_DESTROYED (parent))
1659 XSetTransientForHint (GDK_WINDOW_XDISPLAY (window),
1660 GDK_WINDOW_XID (window),
1661 GDK_WINDOW_XID (parent));
1665 gdk_window_set_background (GdkWindow *window,
1668 GdkWindowObject *private = (GdkWindowObject *)window;
1670 g_return_if_fail (window != NULL);
1671 g_return_if_fail (GDK_IS_WINDOW (window));
1673 if (!GDK_WINDOW_DESTROYED (window))
1674 XSetWindowBackground (GDK_WINDOW_XDISPLAY (window),
1675 GDK_WINDOW_XID (window), color->pixel);
1677 private->bg_color = *color;
1679 if (private->bg_pixmap &&
1680 private->bg_pixmap != GDK_PARENT_RELATIVE_BG &&
1681 private->bg_pixmap != GDK_NO_BG)
1683 gdk_pixmap_unref (private->bg_pixmap);
1684 private->bg_pixmap = NULL;
1689 gdk_window_set_back_pixmap (GdkWindow *window,
1691 gboolean parent_relative)
1693 GdkWindowObject *private = (GdkWindowObject *)window;
1696 g_return_if_fail (window != NULL);
1697 g_return_if_fail (GDK_IS_WINDOW (window));
1698 g_return_if_fail (pixmap == NULL || !parent_relative);
1700 if (private->bg_pixmap &&
1701 private->bg_pixmap != GDK_PARENT_RELATIVE_BG &&
1702 private->bg_pixmap != GDK_NO_BG)
1703 gdk_pixmap_unref (private->bg_pixmap);
1705 if (parent_relative)
1707 xpixmap = ParentRelative;
1708 private->bg_pixmap = GDK_PARENT_RELATIVE_BG;
1714 gdk_pixmap_ref (pixmap);
1715 private->bg_pixmap = pixmap;
1716 xpixmap = GDK_PIXMAP_XID (pixmap);
1721 private->bg_pixmap = GDK_NO_BG;
1725 if (!GDK_WINDOW_DESTROYED (window))
1726 XSetWindowBackgroundPixmap (GDK_WINDOW_XDISPLAY (window),
1727 GDK_WINDOW_XID (window), xpixmap);
1731 gdk_window_set_cursor (GdkWindow *window,
1734 GdkCursorPrivate *cursor_private;
1737 g_return_if_fail (window != NULL);
1738 g_return_if_fail (GDK_IS_WINDOW (window));
1740 cursor_private = (GdkCursorPrivate*) cursor;
1745 xcursor = cursor_private->xcursor;
1747 if (!GDK_WINDOW_DESTROYED (window))
1748 XDefineCursor (GDK_WINDOW_XDISPLAY (window),
1749 GDK_WINDOW_XID (window),
1754 gdk_window_get_geometry (GdkWindow *window,
1766 guint tborder_width;
1769 g_return_if_fail (window == NULL || GDK_IS_WINDOW (window));
1772 window = _gdk_parent_root;
1774 if (!GDK_WINDOW_DESTROYED (window))
1776 XGetGeometry (GDK_WINDOW_XDISPLAY (window),
1777 GDK_WINDOW_XID (window),
1778 &root, &tx, &ty, &twidth, &theight, &tborder_width, &tdepth);
1794 * gdk_window_get_origin:
1795 * @window: a #GdkWindow
1796 * @x: return location for X coordinate
1797 * @y: return location for Y coordinate
1799 * Obtains the position of a window in root window coordinates.
1800 * (Compare with gdk_window_get_position() and
1801 * gdk_window_get_geometry() which return the position of a window
1802 * relative to its parent window.)
1804 * Return value: not meaningful, ignore
1807 gdk_window_get_origin (GdkWindow *window,
1816 g_return_val_if_fail (window != NULL, 0);
1818 if (!GDK_WINDOW_DESTROYED (window))
1820 return_val = XTranslateCoordinates (GDK_WINDOW_XDISPLAY (window),
1821 GDK_WINDOW_XID (window),
1839 * gdk_window_get_deskrelative_origin:
1840 * @window: a #GdkWindow
1841 * @x: return location for X coordinate
1842 * @y: return location for Y coordinate
1844 * This gets the origin of a #GdkWindow relative to
1845 * an Enlightenment-window-manager desktop. As long as you don't
1846 * assume that the user's desktop/workspace covers the entire
1847 * root window (i.e. you don't assume that the desktop begins
1848 * at root window coordinate 0,0) this function is not necessary.
1849 * It's deprecated for that reason.
1851 * Return value: not meaningful
1854 gdk_window_get_deskrelative_origin (GdkWindow *window,
1858 gboolean return_val = FALSE;
1859 gint num_children, format_return;
1860 Window win, *child, parent, root;
1864 static Atom atom = 0;
1865 gulong number_return, bytes_after_return;
1866 guchar *data_return;
1868 g_return_val_if_fail (window != NULL, 0);
1869 g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
1871 if (!GDK_WINDOW_DESTROYED (window))
1874 atom = gdk_atom_intern ("ENLIGHTENMENT_DESKTOP", FALSE);
1875 win = GDK_WINDOW_XID (window);
1877 while (XQueryTree (GDK_WINDOW_XDISPLAY (window), win, &root, &parent,
1878 &child, (unsigned int *)&num_children))
1880 if ((child) && (num_children > 0))
1892 XGetWindowProperty (GDK_WINDOW_XDISPLAY (window), win, atom, 0, 0,
1893 False, XA_CARDINAL, &type_return, &format_return,
1894 &number_return, &bytes_after_return, &data_return);
1895 if (type_return == XA_CARDINAL)
1897 XFree (data_return);
1902 return_val = XTranslateCoordinates (GDK_WINDOW_XDISPLAY (window),
1903 GDK_WINDOW_XID (window),
1918 * gdk_window_get_root_origin:
1919 * @window: a #GdkWindow
1920 * @x: return location for X position of window frame
1921 * @y: return location for Y position of window frame
1923 * Obtains the top-left corner of the window manager frame in root
1924 * window coordinates.
1928 gdk_window_get_root_origin (GdkWindow *window,
1934 g_return_if_fail (GDK_IS_WINDOW (window));
1936 gdk_window_get_frame_extents (window, &rect);
1946 * gdk_window_get_frame_extents:
1947 * @window: a #GdkWindow
1948 * @rect: rectangle to fill with bounding box of the window frame
1950 * Obtains the bounding box of the window, including window manager
1951 * titlebar/borders if any. The frame position is given in root window
1952 * coordinates. To get the position of the window itself (rather than
1953 * the frame) in root window coordinates, use gdk_window_get_origin().
1957 gdk_window_get_frame_extents (GdkWindow *window,
1960 GdkWindowObject *private;
1965 unsigned int nchildren;
1967 g_return_if_fail (GDK_IS_WINDOW (window));
1968 g_return_if_fail (rect != NULL);
1970 private = (GdkWindowObject*) window;
1977 if (GDK_WINDOW_DESTROYED (window))
1980 while (private->parent && ((GdkWindowObject*) private->parent)->parent)
1981 private = (GdkWindowObject*) private->parent;
1982 if (GDK_WINDOW_DESTROYED (window))
1985 xparent = GDK_WINDOW_XID (window);
1989 if (!XQueryTree (GDK_WINDOW_XDISPLAY (window), xwindow,
1991 &children, &nchildren))
1997 while (xparent != root);
1999 if (xparent == root)
2001 unsigned int ww, wh, wb, wd;
2004 if (XGetGeometry (GDK_WINDOW_XDISPLAY (window), xwindow, &root, &wx, &wy, &ww, &wh, &wb, &wd))
2015 _gdk_windowing_window_get_pointer (GdkWindow *window,
2018 GdkModifierType *mask)
2020 GdkWindow *return_val;
2026 unsigned int xmask = 0;
2027 gint xoffset, yoffset;
2029 g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
2032 window = _gdk_parent_root;
2034 _gdk_windowing_window_get_offsets (window, &xoffset, &yoffset);
2037 if (!GDK_WINDOW_DESTROYED (window) &&
2038 XQueryPointer (GDK_WINDOW_XDISPLAY (window),
2039 GDK_WINDOW_XID (window),
2040 &root, &child, &rootx, &rooty, &winx, &winy, &xmask))
2043 return_val = gdk_window_lookup (child);
2047 *x = winx + xoffset;
2049 *y = winy + yoffset;
2057 _gdk_windowing_window_at_pointer (gint *win_x,
2063 Window xwindow_last = 0;
2065 int rootx = -1, rooty = -1;
2069 xwindow = GDK_ROOT_WINDOW ();
2070 xdisplay = GDK_DISPLAY ();
2072 gdk_x11_grab_server ();
2075 xwindow_last = xwindow;
2076 XQueryPointer (xdisplay, xwindow,
2082 gdk_x11_ungrab_server ();
2084 window = gdk_window_lookup (xwindow_last);
2087 *win_x = window ? winx : -1;
2089 *win_y = window ? winy : -1;
2095 gdk_window_get_events (GdkWindow *window)
2097 XWindowAttributes attrs;
2098 GdkEventMask event_mask;
2101 g_return_val_if_fail (window != NULL, 0);
2102 g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
2104 if (GDK_WINDOW_DESTROYED (window))
2108 XGetWindowAttributes (GDK_WINDOW_XDISPLAY (window),
2109 GDK_WINDOW_XID (window),
2113 for (i = 0; i < _gdk_nenvent_masks; i++)
2115 if (attrs.your_event_mask & _gdk_event_mask_table[i])
2116 event_mask |= 1 << (i + 1);
2124 gdk_window_set_events (GdkWindow *window,
2125 GdkEventMask event_mask)
2130 g_return_if_fail (window != NULL);
2131 g_return_if_fail (GDK_IS_WINDOW (window));
2133 if (!GDK_WINDOW_DESTROYED (window))
2135 xevent_mask = StructureNotifyMask;
2136 for (i = 0; i < _gdk_nenvent_masks; i++)
2138 if (event_mask & (1 << (i + 1)))
2139 xevent_mask |= _gdk_event_mask_table[i];
2142 XSelectInput (GDK_WINDOW_XDISPLAY (window),
2143 GDK_WINDOW_XID (window),
2149 gdk_window_add_colormap_windows (GdkWindow *window)
2151 GdkWindow *toplevel;
2152 Window *old_windows;
2153 Window *new_windows;
2156 g_return_if_fail (window != NULL);
2157 g_return_if_fail (GDK_IS_WINDOW (window));
2159 toplevel = gdk_window_get_toplevel (window);
2160 if (GDK_WINDOW_DESTROYED (toplevel))
2164 if (!XGetWMColormapWindows (GDK_WINDOW_XDISPLAY (toplevel),
2165 GDK_WINDOW_XID (toplevel),
2166 &old_windows, &count))
2171 for (i = 0; i < count; i++)
2172 if (old_windows[i] == GDK_WINDOW_XID (window))
2174 XFree (old_windows);
2178 new_windows = g_new (Window, count + 1);
2180 for (i = 0; i < count; i++)
2181 new_windows[i] = old_windows[i];
2182 new_windows[count] = GDK_WINDOW_XID (window);
2184 XSetWMColormapWindows (GDK_WINDOW_XDISPLAY (toplevel),
2185 GDK_WINDOW_XID (toplevel),
2186 new_windows, count + 1);
2188 g_free (new_windows);
2190 XFree (old_windows);
2194 gdk_window_have_shape_ext (void)
2196 enum { UNKNOWN, NO, YES };
2197 static gint have_shape = UNKNOWN;
2199 if (have_shape == UNKNOWN)
2202 if (XQueryExtension (gdk_display, "SHAPE", &ignore, &ignore, &ignore))
2208 return (have_shape == YES);
2211 #define WARN_SHAPE_TOO_BIG() g_warning ("GdkWindow is too large to allow the use of shape masks or shape regions.")
2214 * This needs the X11 shape extension.
2215 * If not available, shaped windows will look
2216 * ugly, but programs still work. Stefan Wille
2219 gdk_window_shape_combine_mask (GdkWindow *window,
2224 gint xoffset, yoffset;
2226 g_return_if_fail (window != NULL);
2227 g_return_if_fail (GDK_IS_WINDOW (window));
2229 #ifdef HAVE_SHAPE_EXT
2230 if (GDK_WINDOW_DESTROYED (window))
2233 _gdk_windowing_window_get_offsets (window, &xoffset, &yoffset);
2235 if (xoffset != 0 || yoffset != 0)
2237 WARN_SHAPE_TOO_BIG ();
2241 if (gdk_window_have_shape_ext ())
2245 pixmap = GDK_PIXMAP_XID (mask);
2254 XShapeCombineMask (GDK_WINDOW_XDISPLAY (window),
2255 GDK_WINDOW_XID (window),
2261 #endif /* HAVE_SHAPE_EXT */
2265 gdk_window_shape_combine_region (GdkWindow *window,
2266 GdkRegion *shape_region,
2270 gint xoffset, yoffset;
2272 g_return_if_fail (GDK_IS_WINDOW (window));
2274 #ifdef HAVE_SHAPE_EXT
2275 if (GDK_WINDOW_DESTROYED (window))
2278 _gdk_windowing_window_get_offsets (window, &xoffset, &yoffset);
2280 if (xoffset != 0 || yoffset != 0)
2282 WARN_SHAPE_TOO_BIG ();
2286 if (shape_region == NULL)
2288 /* Use NULL mask to unset the shape */
2289 gdk_window_shape_combine_mask (window, NULL, 0, 0);
2293 if (gdk_window_have_shape_ext ())
2296 XRectangle *xrects = NULL;
2298 _gdk_region_get_xrectangles (shape_region,
2302 XShapeCombineRectangles (GDK_WINDOW_XDISPLAY (window),
2303 GDK_WINDOW_XID (window),
2312 #endif /* HAVE_SHAPE_EXT */
2317 gdk_window_set_override_redirect (GdkWindow *window,
2318 gboolean override_redirect)
2320 XSetWindowAttributes attr;
2322 g_return_if_fail (window != NULL);
2323 g_return_if_fail (GDK_IS_WINDOW (window));
2325 if (GDK_WINDOW_DESTROYED (window))
2327 attr.override_redirect = (override_redirect == FALSE)?False:True;
2328 XChangeWindowAttributes (GDK_WINDOW_XDISPLAY (window),
2329 GDK_WINDOW_XID (window),
2337 * gdk_window_set_icon_list:
2338 * @window: The #GdkWindow toplevel window to set the icon of.
2339 * @pixbufs: A list of pixbufs, of different sizes.
2341 * Sets a list of icons for the window. One of these will be used
2342 * to represent the window when it has been iconified. The icon is
2343 * usually shown in an icon box or some sort of task bar. Which icon
2344 * size is shown depends on the window manager. The window manager
2345 * can scale the icon but setting several size icons can give better
2346 * image quality since the window manager may only need to scale the
2347 * icon by a small amount or not at all.
2351 gdk_window_set_icon_list (GdkWindow *window,
2360 gint width, height, stride;
2364 g_return_if_fail (GDK_IS_WINDOW (window));
2366 if (GDK_WINDOW_DESTROYED (window))
2375 g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
2377 width = gdk_pixbuf_get_width (pixbuf);
2378 height = gdk_pixbuf_get_height (pixbuf);
2380 size += 2 + width * height;
2382 l = g_list_next (l);
2385 data = g_malloc (size*4);
2393 width = gdk_pixbuf_get_width (pixbuf);
2394 height = gdk_pixbuf_get_height (pixbuf);
2395 stride = gdk_pixbuf_get_rowstride (pixbuf);
2396 n_channels = gdk_pixbuf_get_n_channels (pixbuf);
2401 pixels = gdk_pixbuf_get_pixels (pixbuf);
2403 for (y = 0; y < height; y++)
2405 for (x = 0; x < width; x++)
2409 r = pixels[y*stride + x*n_channels + 0];
2410 g = pixels[y*stride + x*n_channels + 1];
2411 b = pixels[y*stride + x*n_channels + 2];
2412 if (n_channels >= 4)
2413 a = pixels[y*stride + x*n_channels + 3];
2417 *p++ = a << 24 | r << 16 | g << 8 | b ;
2421 l = g_list_next (l);
2426 XChangeProperty (GDK_WINDOW_XDISPLAY (window),
2427 GDK_WINDOW_XID (window),
2428 gdk_atom_intern ("_NET_WM_ICON", FALSE),
2431 (guchar*) data, size);
2435 XDeleteProperty (GDK_WINDOW_XDISPLAY (window),
2436 GDK_WINDOW_XID (window),
2437 gdk_atom_intern ("_NET_WM_ICON", FALSE));
2442 gdk_window_set_icon (GdkWindow *window,
2443 GdkWindow *icon_window,
2449 g_return_if_fail (window != NULL);
2450 g_return_if_fail (GDK_IS_WINDOW (window));
2452 if (GDK_WINDOW_DESTROYED (window))
2455 wm_hints = XGetWMHints (GDK_WINDOW_XDISPLAY (window),
2456 GDK_WINDOW_XID (window));
2458 wm_hints = XAllocWMHints ();
2460 if (icon_window != NULL)
2462 wm_hints->flags |= IconWindowHint;
2463 wm_hints->icon_window = GDK_WINDOW_XID (icon_window);
2468 wm_hints->flags |= IconPixmapHint;
2469 wm_hints->icon_pixmap = GDK_PIXMAP_XID (pixmap);
2474 wm_hints->flags |= IconMaskHint;
2475 wm_hints->icon_mask = GDK_PIXMAP_XID (mask);
2478 XSetWMHints (GDK_WINDOW_XDISPLAY (window),
2479 GDK_WINDOW_XID (window), wm_hints);
2484 gdk_window_icon_name_set (GdkWindow *window)
2486 return GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (window),
2487 g_quark_from_static_string ("gdk-icon-name-set")));
2491 gdk_window_set_icon_name (GdkWindow *window,
2494 g_return_if_fail (window != NULL);
2495 g_return_if_fail (GDK_IS_WINDOW (window));
2497 if (GDK_WINDOW_DESTROYED (window))
2500 g_object_set_qdata (G_OBJECT (window), g_quark_from_static_string ("gdk-icon-name-set"),
2501 GUINT_TO_POINTER (TRUE));
2503 XChangeProperty (GDK_WINDOW_XDISPLAY (window),
2504 GDK_WINDOW_XID (window),
2505 gdk_atom_intern ("_NET_WM_ICON_NAME", FALSE),
2506 gdk_atom_intern ("UTF8_STRING", FALSE), 8,
2507 PropModeReplace, name,
2509 set_text_property (window, gdk_atom_intern ("WM_ICON_NAME", FALSE), name);
2513 gdk_window_iconify (GdkWindow *window)
2516 GdkWindowObject *private;
2518 g_return_if_fail (window != NULL);
2519 g_return_if_fail (GDK_IS_WINDOW (window));
2521 if (GDK_WINDOW_DESTROYED (window))
2524 display = GDK_WINDOW_XDISPLAY (window);
2526 private = (GdkWindowObject*) window;
2528 if (GDK_WINDOW_IS_MAPPED (window))
2530 XIconifyWindow (display, GDK_WINDOW_XWINDOW (window), DefaultScreen (display));
2535 /* Flip our client side flag, the real work happens on map. */
2536 gdk_synthesize_window_state (window,
2538 GDK_WINDOW_STATE_ICONIFIED);
2543 gdk_window_deiconify (GdkWindow *window)
2546 GdkWindowObject *private;
2548 g_return_if_fail (window != NULL);
2549 g_return_if_fail (GDK_IS_WINDOW (window));
2551 if (GDK_WINDOW_DESTROYED (window))
2554 display = GDK_WINDOW_XDISPLAY (window);
2556 private = (GdkWindowObject*) window;
2558 if (GDK_WINDOW_IS_MAPPED (window))
2560 gdk_window_show (window);
2564 /* Flip our client side flag, the real work happens on map. */
2565 gdk_synthesize_window_state (window,
2566 GDK_WINDOW_STATE_ICONIFIED,
2572 gdk_window_stick (GdkWindow *window)
2574 g_return_if_fail (GDK_IS_WINDOW (window));
2576 if (GDK_WINDOW_DESTROYED (window))
2579 if (GDK_WINDOW_IS_MAPPED (window))
2581 /* "stick" means stick to all desktops _and_ do not scroll with the
2582 * viewport. i.e. glue to the monitor glass in all cases.
2587 /* Request stick during viewport scroll */
2588 gdk_wmspec_change_state (TRUE, window,
2589 gdk_atom_intern ("_NET_WM_STATE_STICKY", FALSE),
2592 /* Request desktop 0xFFFFFFFF */
2593 xev.xclient.type = ClientMessage;
2594 xev.xclient.serial = 0;
2595 xev.xclient.send_event = True;
2596 xev.xclient.window = GDK_WINDOW_XWINDOW (window);
2597 xev.xclient.display = gdk_display;
2598 xev.xclient.message_type = gdk_atom_intern ("_NET_WM_DESKTOP", FALSE);
2599 xev.xclient.format = 32;
2601 xev.xclient.data.l[0] = 0xFFFFFFFF;
2603 XSendEvent (gdk_display, _gdk_root_window, False,
2604 SubstructureRedirectMask | SubstructureNotifyMask,
2609 /* Flip our client side flag, the real work happens on map. */
2610 gdk_synthesize_window_state (window,
2612 GDK_WINDOW_STATE_STICKY);
2617 gdk_window_unstick (GdkWindow *window)
2619 g_return_if_fail (GDK_IS_WINDOW (window));
2621 if (GDK_WINDOW_DESTROYED (window))
2624 if (GDK_WINDOW_IS_MAPPED (window))
2631 gulong *current_desktop;
2633 /* Request unstick from viewport */
2634 gdk_wmspec_change_state (FALSE, window,
2635 gdk_atom_intern ("_NET_WM_STATE_STICKY", FALSE),
2638 /* Get current desktop, then set it; this is a race, but not
2639 * one that matters much in practice.
2641 XGetWindowProperty (gdk_display, _gdk_root_window,
2642 gdk_atom_intern ("_NET_CURRENT_DESKTOP", FALSE),
2644 False, XA_CARDINAL, &type, &format, &nitems,
2645 &bytes_after, (guchar **)¤t_desktop);
2647 if (type == XA_CARDINAL)
2649 xev.xclient.type = ClientMessage;
2650 xev.xclient.serial = 0;
2651 xev.xclient.send_event = True;
2652 xev.xclient.window = GDK_WINDOW_XWINDOW (window);
2653 xev.xclient.display = gdk_display;
2654 xev.xclient.message_type = gdk_atom_intern ("_NET_WM_DESKTOP", FALSE);
2655 xev.xclient.format = 32;
2657 xev.xclient.data.l[0] = *current_desktop;
2659 XSendEvent (gdk_display, _gdk_root_window, False,
2660 SubstructureRedirectMask | SubstructureNotifyMask,
2663 XFree (current_desktop);
2668 /* Flip our client side flag, the real work happens on map. */
2669 gdk_synthesize_window_state (window,
2670 GDK_WINDOW_STATE_STICKY,
2677 gdk_window_maximize (GdkWindow *window)
2679 g_return_if_fail (GDK_IS_WINDOW (window));
2681 if (GDK_WINDOW_DESTROYED (window))
2684 if (GDK_WINDOW_IS_MAPPED (window))
2685 gdk_wmspec_change_state (TRUE, window,
2686 gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_VERT", FALSE),
2687 gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_HORZ", FALSE));
2689 gdk_synthesize_window_state (window,
2691 GDK_WINDOW_STATE_MAXIMIZED);
2695 gdk_window_unmaximize (GdkWindow *window)
2697 g_return_if_fail (GDK_IS_WINDOW (window));
2699 if (GDK_WINDOW_DESTROYED (window))
2702 if (GDK_WINDOW_IS_MAPPED (window))
2703 gdk_wmspec_change_state (FALSE, window,
2704 gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_VERT", FALSE),
2705 gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_HORZ", FALSE));
2707 gdk_synthesize_window_state (window,
2708 GDK_WINDOW_STATE_MAXIMIZED,
2713 gdk_window_set_group (GdkWindow *window,
2718 g_return_if_fail (window != NULL);
2719 g_return_if_fail (GDK_IS_WINDOW (window));
2720 g_return_if_fail (leader != NULL);
2721 g_return_if_fail (GDK_IS_WINDOW (leader));
2723 if (GDK_WINDOW_DESTROYED (window) || GDK_WINDOW_DESTROYED (leader))
2726 wm_hints = XGetWMHints (GDK_WINDOW_XDISPLAY (window),
2727 GDK_WINDOW_XID (window));
2729 wm_hints = XAllocWMHints ();
2731 wm_hints->flags |= WindowGroupHint;
2732 wm_hints->window_group = GDK_WINDOW_XID (leader);
2734 XSetWMHints (GDK_WINDOW_XDISPLAY (window),
2735 GDK_WINDOW_XID (window), wm_hints);
2739 static MotifWmHints *
2740 gdk_window_get_mwm_hints (GdkWindow *window)
2742 static Atom hints_atom = None;
2743 MotifWmHints *hints;
2749 if (GDK_WINDOW_DESTROYED (window))
2753 hints_atom = XInternAtom (GDK_WINDOW_XDISPLAY (window),
2754 _XA_MOTIF_WM_HINTS, FALSE);
2756 XGetWindowProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
2757 hints_atom, 0, sizeof (MotifWmHints)/sizeof (long),
2758 False, AnyPropertyType, &type, &format, &nitems,
2759 &bytes_after, (guchar **)&hints);
2768 gdk_window_set_mwm_hints (GdkWindow *window,
2769 MotifWmHints *new_hints)
2771 static Atom hints_atom = None;
2772 MotifWmHints *hints;
2778 if (GDK_WINDOW_DESTROYED (window))
2782 hints_atom = XInternAtom (GDK_WINDOW_XDISPLAY (window),
2783 _XA_MOTIF_WM_HINTS, FALSE);
2785 XGetWindowProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
2786 hints_atom, 0, sizeof (MotifWmHints)/sizeof (long),
2787 False, AnyPropertyType, &type, &format, &nitems,
2788 &bytes_after, (guchar **)&hints);
2794 if (new_hints->flags & MWM_HINTS_FUNCTIONS)
2796 hints->flags |= MWM_HINTS_FUNCTIONS;
2797 hints->functions = new_hints->functions;
2799 if (new_hints->flags & MWM_HINTS_DECORATIONS)
2801 hints->flags |= MWM_HINTS_DECORATIONS;
2802 hints->decorations = new_hints->decorations;
2806 XChangeProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
2807 hints_atom, hints_atom, 32, PropModeReplace,
2808 (guchar *)hints, sizeof (MotifWmHints)/sizeof (long));
2810 if (hints != new_hints)
2815 gdk_window_set_decorations (GdkWindow *window,
2816 GdkWMDecoration decorations)
2820 g_return_if_fail (window != NULL);
2821 g_return_if_fail (GDK_IS_WINDOW (window));
2823 hints.flags = MWM_HINTS_DECORATIONS;
2824 hints.decorations = decorations;
2826 gdk_window_set_mwm_hints (window, &hints);
2830 * gdk_window_get_decorations:
2831 * @window: The #GdkWindow to get the decorations from
2832 * @decorations: The window decorations will be written here
2834 * Returns the decorations set on the GdkWindow with #gdk_window_set_decorations
2835 * Returns: TRUE if the window has decorations set, FALSE otherwise.
2838 gdk_window_get_decorations(GdkWindow *window,
2839 GdkWMDecoration *decorations)
2841 MotifWmHints *hints;
2842 gboolean result = FALSE;
2844 hints = gdk_window_get_mwm_hints (window);
2848 if (hints->flags & MWM_HINTS_DECORATIONS)
2850 *decorations = hints->decorations;
2861 gdk_window_set_functions (GdkWindow *window,
2862 GdkWMFunction functions)
2866 g_return_if_fail (window != NULL);
2867 g_return_if_fail (GDK_IS_WINDOW (window));
2869 hints.flags = MWM_HINTS_FUNCTIONS;
2870 hints.functions = functions;
2872 gdk_window_set_mwm_hints (window, &hints);
2875 #ifdef HAVE_SHAPE_EXT
2878 * propagate the shapes from all child windows of a GDK window to the parent
2879 * window. Shamelessly ripped from Enlightenment's code
2887 struct _gdk_span *next;
2891 gdk_add_to_span (struct _gdk_span **s,
2895 struct _gdk_span *ptr1, *ptr2, *noo, *ss;
2902 /* scan the spans for this line */
2905 /* -- -> new span */
2906 /* == -> existing span */
2907 /* ## -> spans intersect */
2908 /* if we are in the middle of spanning the span into the line */
2911 /* case: ---- ==== */
2912 if (xx < ptr1->start - 1)
2914 /* ends before next span - extend to here */
2918 /* case: ----##=== */
2919 else if (xx <= ptr1->end)
2921 /* crosses into next span - delete next span and append */
2922 ss->end = ptr1->end;
2923 ss->next = ptr1->next;
2927 /* case: ---###--- */
2930 /* overlaps next span - delete and keep checking */
2931 ss->next = ptr1->next;
2936 /* otherwise havent started spanning it in yet */
2939 /* case: ---- ==== */
2940 if (xx < ptr1->start - 1)
2942 /* insert span here in list */
2943 noo = g_malloc (sizeof (struct _gdk_span));
2957 /* case: ----##=== */
2958 else if ((x < ptr1->start) && (xx <= ptr1->end))
2960 /* expand this span to the left point of the new one */
2964 /* case: ===###=== */
2965 else if ((x >= ptr1->start) && (xx <= ptr1->end))
2967 /* throw the span away */
2970 /* case: ---###--- */
2971 else if ((x < ptr1->start) && (xx > ptr1->end))
2978 /* case: ===##---- */
2979 else if ((x >= ptr1->start) && (x <= ptr1->end + 1) && (xx > ptr1->end))
2985 /* case: ==== ---- */
2986 /* case handled by next loop iteration - first case */
2991 /* it started in the middle but spans beyond your current list */
2997 /* it does not start inside a span or in the middle, so add it to the end */
2998 noo = g_malloc (sizeof (struct _gdk_span));
3006 noo->next = ptr2->next;
3019 gdk_add_rectangles (Display *disp,
3021 struct _gdk_span **spans,
3028 gint x1, y1, x2, y2;
3032 rl = XShapeGetRectangles (disp, win, ShapeBounding, &rn, &ord);
3035 /* go through all clip rects in this window's shape */
3036 for (k = 0; k < rn; k++)
3038 /* for each clip rect, add it to each line's spans */
3040 x2 = x + rl[k].x + (rl[k].width - 1);
3042 y2 = y + rl[k].y + (rl[k].height - 1);
3051 for (a = y1; a <= y2; a++)
3054 gdk_add_to_span (&spans[a], x1, x2);
3062 gdk_propagate_shapes (Display *disp,
3066 Window rt, par, *list = NULL;
3067 gint i, j, num = 0, num_rects = 0;
3071 XRectangle *rects = NULL;
3072 struct _gdk_span **spans = NULL, *ptr1, *ptr2, *ptr3;
3073 XWindowAttributes xatt;
3075 XGetGeometry (disp, win, &rt, &x, &y, &w, &h, &d, &d);
3080 spans = g_malloc (sizeof (struct _gdk_span *) * h);
3082 for (i = 0; i < h; i++)
3084 XQueryTree (disp, win, &rt, &par, &list, (unsigned int *)&num);
3087 /* go through all child windows and create/insert spans */
3088 for (i = 0; i < num; i++)
3090 if (XGetWindowAttributes (disp, list[i], &xatt) && (xatt.map_state != IsUnmapped))
3091 if (XGetGeometry (disp, list[i], &rt, &x, &y, &w, &h, &d, &d))
3092 gdk_add_rectangles (disp, list[i], spans, basew, baseh, x, y);
3095 gdk_add_rectangles (disp, win, spans, basew, baseh, x, y);
3097 /* go through the spans list and build a list of rects */
3098 rects = g_malloc (sizeof (XRectangle) * 256);
3100 for (i = 0; i < baseh; i++)
3103 /* go through the line for all spans */
3106 rects[num_rects].x = ptr1->start;
3107 rects[num_rects].y = i;
3108 rects[num_rects].width = ptr1->end - ptr1->start + 1;
3109 rects[num_rects].height = 1;
3111 /* if there are more lines */
3113 /* while contigous rects (same start/end coords) exist */
3114 while ((contig) && (j < baseh))
3116 /* search next line for spans matching this one */
3122 /* if we have an exact span match set contig */
3123 if ((ptr2->start == ptr1->start) &&
3124 (ptr2->end == ptr1->end))
3127 /* remove the span - not needed */
3130 ptr3->next = ptr2->next;
3136 spans[j] = ptr2->next;
3142 /* gone past the span point no point looking */
3143 else if (ptr2->start < ptr1->start)
3151 /* if a contiguous span was found increase the rect h */
3154 rects[num_rects].height++;
3158 /* up the rect count */
3160 /* every 256 new rects increase the rect array */
3161 if ((num_rects % 256) == 0)
3162 rects = g_realloc (rects, sizeof (XRectangle) * (num_rects + 256));
3166 /* set the rects as the shape mask */
3169 XShapeCombineRectangles (disp, win, ShapeBounding, 0, 0, rects, num_rects,
3170 ShapeSet, YXSorted);
3175 /* free up all the spans we made */
3176 for (i = 0; i < baseh; i++)
3189 #endif /* HAVE_SHAPE_EXT */
3192 gdk_window_set_child_shapes (GdkWindow *window)
3194 g_return_if_fail (window != NULL);
3195 g_return_if_fail (GDK_IS_WINDOW (window));
3197 #ifdef HAVE_SHAPE_EXT
3198 if (!GDK_WINDOW_DESTROYED (window) &&
3199 gdk_window_have_shape_ext ())
3200 gdk_propagate_shapes (GDK_WINDOW_XDISPLAY (window),
3201 GDK_WINDOW_XID (window), FALSE);
3206 gdk_window_merge_child_shapes (GdkWindow *window)
3208 g_return_if_fail (window != NULL);
3209 g_return_if_fail (GDK_IS_WINDOW (window));
3211 #ifdef HAVE_SHAPE_EXT
3212 if (!GDK_WINDOW_DESTROYED (window) &&
3213 gdk_window_have_shape_ext ())
3214 gdk_propagate_shapes (GDK_WINDOW_XDISPLAY (window),
3215 GDK_WINDOW_XID (window), TRUE);
3219 /* Support for windows that can be guffaw-scrolled
3220 * (See http://www.gtk.org/~otaylor/whitepapers/guffaw-scrolling.txt)
3224 gdk_window_gravity_works (void)
3226 enum { UNKNOWN, NO, YES };
3227 static gint gravity_works = UNKNOWN;
3229 if (gravity_works == UNKNOWN)
3236 /* This particular server apparently has a bug so that the test
3237 * works but the actual code crashes it
3239 if ((!strcmp (XServerVendor (gdk_display), "Sun Microsystems, Inc.")) &&
3240 (VendorRelease (gdk_display) == 3400))
3246 attr.window_type = GDK_WINDOW_TEMP;
3247 attr.wclass = GDK_INPUT_OUTPUT;
3252 attr.event_mask = 0;
3254 parent = gdk_window_new (NULL, &attr, GDK_WA_X | GDK_WA_Y);
3256 attr.window_type = GDK_WINDOW_CHILD;
3257 child = gdk_window_new (parent, &attr, GDK_WA_X | GDK_WA_Y);
3259 gdk_window_set_static_win_gravity (child, TRUE);
3261 gdk_window_resize (parent, 100, 110);
3262 gdk_window_move (parent, 0, -10);
3263 gdk_window_move_resize (parent, 0, 0, 100, 100);
3265 gdk_window_resize (parent, 100, 110);
3266 gdk_window_move (parent, 0, -10);
3267 gdk_window_move_resize (parent, 0, 0, 100, 100);
3269 gdk_window_get_geometry (child, NULL, &y, NULL, NULL, NULL);
3271 gdk_window_destroy (parent);
3272 gdk_window_destroy (child);
3274 gravity_works = ((y == -20) ? YES : NO);
3277 return (gravity_works == YES);
3281 gdk_window_set_static_bit_gravity (GdkWindow *window, gboolean on)
3283 XSetWindowAttributes xattributes;
3284 guint xattributes_mask = 0;
3286 g_return_if_fail (window != NULL);
3288 xattributes.bit_gravity = StaticGravity;
3289 xattributes_mask |= CWBitGravity;
3290 xattributes.bit_gravity = on ? StaticGravity : ForgetGravity;
3291 XChangeWindowAttributes (GDK_WINDOW_XDISPLAY (window),
3292 GDK_WINDOW_XID (window),
3293 CWBitGravity, &xattributes);
3297 gdk_window_set_static_win_gravity (GdkWindow *window, gboolean on)
3299 XSetWindowAttributes xattributes;
3301 g_return_if_fail (window != NULL);
3303 xattributes.win_gravity = on ? StaticGravity : NorthWestGravity;
3305 XChangeWindowAttributes (GDK_WINDOW_XDISPLAY (window),
3306 GDK_WINDOW_XID (window),
3307 CWWinGravity, &xattributes);
3310 /*************************************************************
3311 * gdk_window_set_static_gravities:
3312 * Set the bit gravity of the given window to static,
3313 * and flag it so all children get static subwindow
3316 * window: window for which to set static gravity
3317 * use_static: Whether to turn static gravity on or off.
3319 * Does the XServer support static gravity?
3320 *************************************************************/
3323 gdk_window_set_static_gravities (GdkWindow *window,
3324 gboolean use_static)
3326 GdkWindowObject *private = (GdkWindowObject *)window;
3329 g_return_val_if_fail (window != NULL, FALSE);
3330 g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
3332 if (!use_static == !private->guffaw_gravity)
3335 if (use_static && !gdk_window_gravity_works ())
3338 private->guffaw_gravity = use_static;
3340 if (!GDK_WINDOW_DESTROYED (window))
3342 gdk_window_set_static_bit_gravity (window, use_static);
3344 tmp_list = private->children;
3347 gdk_window_set_static_win_gravity (window, use_static);
3349 tmp_list = tmp_list->next;
3356 /* internal function created for and used by gdk_window_xid_at_coords */
3358 gdk_window_xid_at (Window base,
3364 gboolean excl_child)
3367 Window *list = NULL;
3368 Window child = 0, parent_win = 0, root_win = 0;
3370 unsigned int ww, wh, wb, wd, num;
3373 xdisplay = GDK_DISPLAY ();
3374 if (!XGetGeometry (xdisplay, base, &root_win, &wx, &wy, &ww, &wh, &wb, &wd))
3381 (x < (int) (wx + ww)) &&
3382 (y < (int) (wy + wh))))
3385 if (!XQueryTree (xdisplay, base, &root_win, &parent_win, &list, &num))
3390 for (i = num - 1; ; i--)
3392 if ((!excl_child) || (!g_list_find (excludes, (gpointer *) list[i])))
3394 if ((child = gdk_window_xid_at (list[i], wx, wy, x, y, excludes, excl_child)) != 0)
3409 * The following fucntion by The Rasterman <raster@redhat.com>
3410 * This function returns the X Window ID in which the x y location is in
3411 * (x and y being relative to the root window), excluding any windows listed
3412 * in the GList excludes (this is a list of X Window ID's - gpointer being
3415 * This is primarily designed for internal gdk use - for DND for example
3416 * when using a shaped icon window as the drag object - you exclude the
3417 * X Window ID of the "icon" (perhaps more if excludes may be needed) and
3418 * You can get back an X Window ID as to what X Window ID is infact under
3419 * those X,Y co-ordinates.
3422 gdk_window_xid_at_coords (gint x,
3425 gboolean excl_child)
3429 Window *list = NULL;
3430 Window root, child = 0, parent_win = 0, root_win = 0;
3434 window = _gdk_parent_root;
3435 xdisplay = GDK_WINDOW_XDISPLAY (window);
3436 root = GDK_WINDOW_XID (window);
3437 num = g_list_length (excludes);
3439 gdk_x11_grab_server ();
3440 if (!XQueryTree (xdisplay, root, &root_win, &parent_win, &list, &num))
3442 gdk_x11_ungrab_server ();
3450 XWindowAttributes xwa;
3452 XGetWindowAttributes (xdisplay, list [i], &xwa);
3454 if (xwa.map_state != IsViewable)
3457 if (excl_child && g_list_find (excludes, (gpointer *) list[i]))
3460 if ((child = gdk_window_xid_at (list[i], 0, 0, x, y, excludes, excl_child)) == 0)
3465 if (!g_list_find (excludes, (gpointer *) child))
3468 gdk_x11_ungrab_server ();
3475 gdk_x11_ungrab_server ();
3481 gdk_x11_ungrab_server ();
3486 wmspec_moveresize (GdkWindow *window,
3494 /* Release passive grab */
3495 gdk_pointer_ungrab (timestamp);
3497 xev.xclient.type = ClientMessage;
3498 xev.xclient.serial = 0;
3499 xev.xclient.send_event = True;
3500 xev.xclient.display = gdk_display;
3501 xev.xclient.window = GDK_WINDOW_XID (window);
3502 xev.xclient.message_type = gdk_atom_intern ("_NET_WM_MOVERESIZE", FALSE);
3503 xev.xclient.format = 32;
3504 xev.xclient.data.l[0] = root_x;
3505 xev.xclient.data.l[1] = root_y;
3506 xev.xclient.data.l[2] = direction;
3507 xev.xclient.data.l[3] = 0;
3508 xev.xclient.data.l[4] = 0;
3510 XSendEvent (gdk_display, _gdk_root_window, False,
3511 SubstructureRedirectMask | SubstructureNotifyMask,
3515 /* From the WM spec */
3516 #define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0
3517 #define _NET_WM_MOVERESIZE_SIZE_TOP 1
3518 #define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT 2
3519 #define _NET_WM_MOVERESIZE_SIZE_RIGHT 3
3520 #define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4
3521 #define _NET_WM_MOVERESIZE_SIZE_BOTTOM 5
3522 #define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT 6
3523 #define _NET_WM_MOVERESIZE_SIZE_LEFT 7
3524 #define _NET_WM_MOVERESIZE_MOVE 8
3527 wmspec_resize_drag (GdkWindow *window,
3536 /* Let the compiler turn a switch into a table, instead
3537 * of doing the table manually, this way is easier to verify.
3541 case GDK_WINDOW_EDGE_NORTH_WEST:
3542 direction = _NET_WM_MOVERESIZE_SIZE_TOPLEFT;
3545 case GDK_WINDOW_EDGE_NORTH:
3546 direction = _NET_WM_MOVERESIZE_SIZE_TOP;
3549 case GDK_WINDOW_EDGE_NORTH_EAST:
3550 direction = _NET_WM_MOVERESIZE_SIZE_TOPRIGHT;
3553 case GDK_WINDOW_EDGE_WEST:
3554 direction = _NET_WM_MOVERESIZE_SIZE_LEFT;
3557 case GDK_WINDOW_EDGE_EAST:
3558 direction = _NET_WM_MOVERESIZE_SIZE_RIGHT;
3561 case GDK_WINDOW_EDGE_SOUTH_WEST:
3562 direction = _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT;
3565 case GDK_WINDOW_EDGE_SOUTH:
3566 direction = _NET_WM_MOVERESIZE_SIZE_BOTTOM;
3569 case GDK_WINDOW_EDGE_SOUTH_EAST:
3570 direction = _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT;
3574 g_warning ("gdk_window_begin_resize_drag: bad resize edge %d!",
3580 wmspec_moveresize (window, direction, root_x, root_y, timestamp);
3583 /* This is global for use in gdkevents-x11.c */
3584 GdkWindow *_gdk_moveresize_window;
3586 static GdkWindow *moveresize_emulation_window = NULL;
3587 static gboolean is_resize = FALSE;
3588 static GdkWindowEdge resize_edge;
3589 static gint moveresize_button;
3590 static gint moveresize_x;
3591 static gint moveresize_y;
3592 static gint moveresize_orig_x;
3593 static gint moveresize_orig_y;
3594 static gint moveresize_orig_width;
3595 static gint moveresize_orig_height;
3596 static GdkWindowHints moveresize_geom_mask = 0;
3597 static GdkGeometry moveresize_geometry;
3598 static Time moveresize_process_time;
3600 static XEvent *moveresize_pending_event;
3603 update_pos (gint new_root_x,
3608 dx = new_root_x - moveresize_x;
3609 dy = new_root_y - moveresize_y;
3615 w = moveresize_orig_width;
3616 h = moveresize_orig_height;
3618 switch (resize_edge)
3620 case GDK_WINDOW_EDGE_SOUTH_EAST:
3629 if (moveresize_geom_mask)
3631 gdk_window_constrain_size (&moveresize_geometry,
3632 moveresize_geom_mask,
3637 gdk_window_resize (_gdk_moveresize_window, w, h);
3643 x = moveresize_orig_x + dx;
3644 y = moveresize_orig_y + dy;
3646 gdk_window_move (_gdk_moveresize_window, x, y);
3653 gdk_window_destroy (moveresize_emulation_window);
3654 moveresize_emulation_window = NULL;
3655 _gdk_moveresize_window = NULL;
3657 if (moveresize_pending_event)
3659 g_free (moveresize_pending_event);
3660 moveresize_pending_event = NULL;
3665 lookahead_motion_predicate (Display *display,
3669 gboolean *seen_release = (gboolean *)arg;
3674 switch (event->xany.type)
3677 *seen_release = TRUE;
3680 moveresize_process_time = event->xmotion.time;
3690 moveresize_lookahead (XEvent *event)
3693 gboolean seen_release = FALSE;
3695 if (moveresize_process_time)
3697 if (event->xmotion.time == moveresize_process_time)
3699 moveresize_process_time = 0;
3706 XCheckIfEvent (gdk_display, &tmp_event,
3707 lookahead_motion_predicate, (XPointer)&seen_release);
3709 return moveresize_process_time == 0;
3713 _gdk_moveresize_handle_event (XEvent *event)
3715 guint button_mask = 0;
3716 GdkWindowObject *window_private = (GdkWindowObject *) _gdk_moveresize_window;
3718 button_mask = GDK_BUTTON1_MASK << (moveresize_button - 1);
3720 switch (event->xany.type)
3723 if (window_private->resize_count > 0)
3725 if (moveresize_pending_event)
3726 *moveresize_pending_event = *event;
3728 moveresize_pending_event = g_memdup (event, sizeof (XEvent));
3732 if (!moveresize_lookahead (event))
3735 update_pos (event->xmotion.x_root,
3736 event->xmotion.y_root);
3738 /* This should never be triggered in normal cases, but in the
3739 * case where the drag started without an implicit grab being
3740 * in effect, we could miss the release if it occurs before
3741 * we grab the pointer; this ensures that we will never
3742 * get a permanently stuck grab.
3744 if ((event->xmotion.state & button_mask) == 0)
3749 update_pos (event->xbutton.x_root,
3750 event->xbutton.y_root);
3752 if (event->xbutton.button == moveresize_button)
3759 _gdk_moveresize_configure_done (void)
3763 if (moveresize_pending_event)
3765 tmp_event = moveresize_pending_event;
3766 moveresize_pending_event = NULL;
3767 _gdk_moveresize_handle_event (tmp_event);
3773 create_moveresize_window (guint32 timestamp)
3775 GdkWindowAttr attributes;
3776 gint attributes_mask;
3777 GdkGrabStatus status;
3779 g_assert (moveresize_emulation_window == NULL);
3781 attributes.x = -100;
3782 attributes.y = -100;
3783 attributes.width = 10;
3784 attributes.height = 10;
3785 attributes.window_type = GDK_WINDOW_TEMP;
3786 attributes.wclass = GDK_INPUT_ONLY;
3787 attributes.override_redirect = TRUE;
3788 attributes.event_mask = 0;
3790 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_NOREDIR;
3792 moveresize_emulation_window =
3793 gdk_window_new (NULL, &attributes, attributes_mask);
3795 gdk_window_show (moveresize_emulation_window);
3797 status = gdk_pointer_grab (moveresize_emulation_window,
3799 GDK_BUTTON_RELEASE_MASK |
3800 GDK_POINTER_MOTION_MASK,
3805 if (status != GDK_GRAB_SUCCESS)
3807 /* If this fails, some other client has grabbed the window
3810 gdk_window_destroy (moveresize_emulation_window);
3811 moveresize_emulation_window = NULL;
3814 moveresize_process_time = 0;
3818 emulate_resize_drag (GdkWindow *window,
3826 moveresize_button = button;
3828 moveresize_x = root_x;
3829 moveresize_y = root_y;
3830 _gdk_moveresize_window = GDK_WINDOW (g_object_ref (G_OBJECT (window)));
3832 gdk_window_get_size (window, &moveresize_orig_width, &moveresize_orig_height);
3834 moveresize_geom_mask = 0;
3835 gdk_window_get_geometry_hints (window,
3836 &moveresize_geometry,
3837 &moveresize_geom_mask);
3839 create_moveresize_window (timestamp);
3843 emulate_move_drag (GdkWindow *window,
3850 moveresize_button = button;
3851 moveresize_x = root_x;
3852 moveresize_y = root_y;
3853 _gdk_moveresize_window = GDK_WINDOW (g_object_ref (G_OBJECT (window)));
3855 gdk_window_get_deskrelative_origin (_gdk_moveresize_window,
3857 &moveresize_orig_y);
3859 create_moveresize_window (timestamp);
3863 gdk_window_begin_resize_drag (GdkWindow *window,
3870 g_return_if_fail (GDK_IS_WINDOW (window));
3871 g_return_if_fail (moveresize_emulation_window == NULL);
3873 if (GDK_WINDOW_DESTROYED (window))
3876 if (gdk_net_wm_supports (gdk_atom_intern ("_NET_WM_MOVERESIZE", FALSE)))
3877 wmspec_resize_drag (window, edge, button, root_x, root_y, timestamp);
3879 emulate_resize_drag (window, edge, button, root_x, root_y, timestamp);
3883 gdk_window_begin_move_drag (GdkWindow *window,
3889 g_return_if_fail (GDK_IS_WINDOW (window));
3890 g_return_if_fail (moveresize_emulation_window == NULL);
3892 if (GDK_WINDOW_DESTROYED (window))
3895 if (gdk_net_wm_supports (gdk_atom_intern ("_NET_WM_MOVERESIZE", FALSE)))
3896 wmspec_moveresize (window, _NET_WM_MOVERESIZE_MOVE,
3897 root_x, root_y, timestamp);
3899 emulate_move_drag (window, button, root_x, root_y, timestamp);