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/.
30 #include <X11/Xutil.h>
31 #include <X11/Xatom.h>
32 #include <netinet/in.h>
36 #include "gdkwindow.h"
38 #include "gdkinputprivate.h"
39 #include "gdkdisplay-x11.h"
40 #include "gdkprivate-x11.h"
41 #include "gdkregion.h"
42 #include "gdkinternals.h"
44 #include "gdkwindow-x11.h"
52 #include <X11/extensions/shape.h>
55 const int _gdk_event_mask_table[21] =
59 PointerMotionHintMask,
76 SubstructureNotifyMask,
77 ButtonPressMask /* SCROLL; on X mouse wheel events is treated as mouse button 4/5 */
79 const int _gdk_nenvent_masks = sizeof (_gdk_event_mask_table) / sizeof (int);
81 /* Forward declarations */
82 static void gdk_window_set_static_win_gravity (GdkWindow *window,
84 static gboolean gdk_window_have_shape_ext (GdkDisplay *display);
85 static gboolean gdk_window_icon_name_set (GdkWindow *window);
86 static void gdk_window_add_colormap_windows (GdkWindow *window);
87 static void set_wm_name (GdkDisplay *display,
91 static GdkColormap* gdk_window_impl_x11_get_colormap (GdkDrawable *drawable);
92 static void gdk_window_impl_x11_set_colormap (GdkDrawable *drawable,
94 static void gdk_window_impl_x11_get_size (GdkDrawable *drawable,
97 static GdkRegion* gdk_window_impl_x11_get_visible_region (GdkDrawable *drawable);
98 static void gdk_window_impl_x11_init (GdkWindowImplX11 *window);
99 static void gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass);
100 static void gdk_window_impl_x11_finalize (GObject *object);
102 static gpointer parent_class = NULL;
104 #define WINDOW_IS_TOPLEVEL(window) \
105 (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \
106 GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN)
109 gdk_window_impl_x11_get_type (void)
111 static GType object_type = 0;
115 static const GTypeInfo object_info =
117 sizeof (GdkWindowImplX11Class),
118 (GBaseInitFunc) NULL,
119 (GBaseFinalizeFunc) NULL,
120 (GClassInitFunc) gdk_window_impl_x11_class_init,
121 NULL, /* class_finalize */
122 NULL, /* class_data */
123 sizeof (GdkWindowImplX11),
125 (GInstanceInitFunc) gdk_window_impl_x11_init,
128 object_type = g_type_register_static (GDK_TYPE_DRAWABLE_IMPL_X11,
137 _gdk_window_impl_get_type (void)
139 return gdk_window_impl_x11_get_type ();
143 gdk_window_impl_x11_init (GdkWindowImplX11 *impl)
147 impl->toplevel_window_type = -1;
151 _gdk_x11_window_get_toplevel (GdkWindow *window)
153 GdkWindowObject *private;
154 GdkWindowImplX11 *impl;
156 g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
158 if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD)
161 private = (GdkWindowObject *)window;
162 impl = GDK_WINDOW_IMPL_X11 (private->impl);
165 impl->toplevel = g_new0 (GdkToplevelX11, 1);
167 return impl->toplevel;
171 gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass)
173 GObjectClass *object_class = G_OBJECT_CLASS (klass);
174 GdkDrawableClass *drawable_class = GDK_DRAWABLE_CLASS (klass);
176 parent_class = g_type_class_peek_parent (klass);
178 object_class->finalize = gdk_window_impl_x11_finalize;
180 drawable_class->set_colormap = gdk_window_impl_x11_set_colormap;
181 drawable_class->get_colormap = gdk_window_impl_x11_get_colormap;
182 drawable_class->get_size = gdk_window_impl_x11_get_size;
184 /* Visible and clip regions are the same */
185 drawable_class->get_clip_region = gdk_window_impl_x11_get_visible_region;
186 drawable_class->get_visible_region = gdk_window_impl_x11_get_visible_region;
190 gdk_window_impl_x11_finalize (GObject *object)
192 GdkWindowObject *wrapper;
193 GdkDrawableImplX11 *draw_impl;
194 GdkWindowImplX11 *window_impl;
196 g_return_if_fail (GDK_IS_WINDOW_IMPL_X11 (object));
198 draw_impl = GDK_DRAWABLE_IMPL_X11 (object);
199 window_impl = GDK_WINDOW_IMPL_X11 (object);
201 wrapper = (GdkWindowObject*) draw_impl->wrapper;
203 _gdk_xgrab_check_destroy (GDK_WINDOW (wrapper));
205 if (!GDK_WINDOW_DESTROYED (wrapper))
207 _gdk_xid_table_remove (GDK_WINDOW_DISPLAY (object), draw_impl->xid);
208 if (window_impl->toplevel && window_impl->toplevel->focus_window)
209 _gdk_xid_table_remove (GDK_WINDOW_DISPLAY (object), window_impl->toplevel->focus_window);
212 if (window_impl->toplevel)
213 g_free (window_impl->toplevel);
215 G_OBJECT_CLASS (parent_class)->finalize (object);
219 gdk_window_impl_x11_get_colormap (GdkDrawable *drawable)
221 GdkDrawableImplX11 *drawable_impl;
222 GdkWindowImplX11 *window_impl;
224 g_return_val_if_fail (GDK_IS_WINDOW_IMPL_X11 (drawable), NULL);
226 drawable_impl = GDK_DRAWABLE_IMPL_X11 (drawable);
227 window_impl = GDK_WINDOW_IMPL_X11 (drawable);
229 if (!((GdkWindowObject *) drawable_impl->wrapper)->input_only &&
230 drawable_impl->colormap == NULL)
232 XWindowAttributes window_attributes;
235 XGetWindowAttributes (GDK_SCREEN_XDISPLAY (drawable_impl->screen),
239 visual = gdk_x11_screen_lookup_visual (drawable_impl->screen,
240 window_attributes.visual->visualid);
241 drawable_impl->colormap = gdk_x11_colormap_foreign_new (visual,
242 window_attributes.colormap);
245 return drawable_impl->colormap;
249 gdk_window_impl_x11_set_colormap (GdkDrawable *drawable,
252 GdkWindowImplX11 *impl;
253 GdkDrawableImplX11 *draw_impl;
255 g_return_if_fail (GDK_IS_WINDOW_IMPL_X11 (drawable));
257 impl = GDK_WINDOW_IMPL_X11 (drawable);
258 draw_impl = GDK_DRAWABLE_IMPL_X11 (drawable);
260 if (cmap && GDK_WINDOW_DESTROYED (draw_impl->wrapper))
264 GDK_DRAWABLE_CLASS (parent_class)->set_colormap (drawable, cmap);
268 XSetWindowColormap (GDK_SCREEN_XDISPLAY (draw_impl->screen),
270 GDK_COLORMAP_XCOLORMAP (cmap));
272 if (((GdkWindowObject*)draw_impl->wrapper)->window_type !=
274 gdk_window_add_colormap_windows (GDK_WINDOW (draw_impl->wrapper));
280 gdk_window_impl_x11_get_size (GdkDrawable *drawable,
284 g_return_if_fail (GDK_IS_WINDOW_IMPL_X11 (drawable));
287 *width = GDK_WINDOW_IMPL_X11 (drawable)->width;
289 *height = GDK_WINDOW_IMPL_X11 (drawable)->height;
293 gdk_window_impl_x11_get_visible_region (GdkDrawable *drawable)
295 GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (drawable);
296 GdkRectangle result_rect;
300 result_rect.width = impl->width;
301 result_rect.height = impl->height;
303 gdk_rectangle_intersect (&result_rect, &impl->position_info.clip_rect, &result_rect);
305 return gdk_region_rectangle (&result_rect);
309 _gdk_windowing_window_init (GdkScreen * screen)
311 GdkWindowObject *private;
312 GdkWindowImplX11 *impl;
313 GdkDrawableImplX11 *draw_impl;
314 GdkScreenX11 *screen_x11;
316 screen_x11 = GDK_SCREEN_X11 (screen);
318 g_assert (screen_x11->root_window == NULL);
320 gdk_screen_set_default_colormap (screen,
321 gdk_screen_get_system_colormap (screen));
323 screen_x11->root_window = g_object_new (GDK_TYPE_WINDOW, NULL);
324 private = (GdkWindowObject *)screen_x11->root_window;
325 impl = GDK_WINDOW_IMPL_X11 (private->impl);
326 draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl);
328 draw_impl->screen = screen;
329 draw_impl->xid = screen_x11->xroot_window;
330 draw_impl->wrapper = GDK_DRAWABLE (private);
331 draw_impl->colormap = gdk_screen_get_system_colormap (screen);
332 g_object_ref (draw_impl->colormap);
334 private->window_type = GDK_WINDOW_ROOT;
335 private->depth = DefaultDepthOfScreen (screen_x11->xscreen);
337 impl->width = WidthOfScreen (screen_x11->xscreen);
338 impl->height = HeightOfScreen (screen_x11->xscreen);
340 _gdk_window_init_position (GDK_WINDOW (private));
342 _gdk_xid_table_insert (screen_x11->display,
343 &screen_x11->xroot_window,
344 screen_x11->root_window);
348 set_wm_protocols (GdkWindow *window)
350 GdkDisplay *display = gdk_drawable_get_display (window);
353 protocols[0] = gdk_x11_get_xatom_by_name_for_display (display, "WM_DELETE_WINDOW");
354 protocols[1] = gdk_x11_get_xatom_by_name_for_display (display, "WM_TAKE_FOCUS");
355 protocols[2] = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_PING");
357 XSetWMProtocols (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window), protocols, 3);
361 get_default_title (void)
365 title = g_get_application_name ();
367 title = g_get_prgname ();
373 check_leader_window_title (GdkDisplay *display)
375 GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
377 if (display_x11->leader_window && !display_x11->leader_window_title_set)
379 set_wm_name (display,
380 display_x11->leader_window,
381 get_default_title ());
383 display_x11->leader_window_title_set = TRUE;
388 create_focus_window (Display *xdisplay,
391 Window focus_window = XCreateSimpleWindow (xdisplay, parent,
395 /* FIXME: probably better to actually track the requested event mask for the toplevel
397 XSelectInput (xdisplay, focus_window,
398 KeyPressMask | KeyReleaseMask | FocusChangeMask);
400 XMapWindow (xdisplay, focus_window);
406 setup_toplevel_window (GdkWindow *window, GdkWindow *parent)
408 GdkWindowObject *obj = (GdkWindowObject *)window;
409 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
410 GdkWindowImplX11 *impl = (GdkWindowImplX11 *)obj->impl;
411 Display *xdisplay = GDK_WINDOW_XDISPLAY (window);
412 XID xid = GDK_WINDOW_XID (window);
413 XID xparent = GDK_WINDOW_XID (parent);
414 GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (GDK_WINDOW_SCREEN (parent));
415 XSizeHints size_hints;
418 if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_DIALOG)
419 XSetTransientForHint (xdisplay, xid, xparent);
421 set_wm_protocols (window);
423 if (!obj->input_only)
425 /* The focus window is off the visible area, and serves to receive key
426 * press events so they don't get sent to child windows.
428 toplevel->focus_window = create_focus_window (xdisplay, xid);
429 _gdk_xid_table_insert (screen_x11->display, &toplevel->focus_window, window);
432 check_leader_window_title (screen_x11->display);
434 /* FIXME: Is there any point in doing this? Do any WM's pay
435 * attention to PSize, and even if they do, is this the
438 size_hints.flags = PSize;
439 size_hints.width = impl->width;
440 size_hints.height = impl->height;
442 XSetWMNormalHints (xdisplay, xid, &size_hints);
444 /* This will set WM_CLIENT_MACHINE and WM_LOCALE_NAME */
445 XSetWMProperties (xdisplay, xid, NULL, NULL, NULL, 0, NULL, NULL, NULL);
448 XChangeProperty (xdisplay, xid,
449 gdk_x11_get_xatom_by_name_for_display (screen_x11->display, "_NET_WM_PID"),
454 XChangeProperty (xdisplay, xid,
455 gdk_x11_get_xatom_by_name_for_display (screen_x11->display, "WM_CLIENT_LEADER"),
456 XA_WINDOW, 32, PropModeReplace,
457 (guchar *) &GDK_DISPLAY_X11 (screen_x11->display)->leader_window, 1);
462 * @parent: a #GdkWindow, or %NULL to create the window as a child of
463 * the default root window for the default display.
464 * @attributes: attributes of the new window
465 * @attributes_mask: mask indicating which fields in @attributes are valid
467 * Creates a new #GdkWindow using the attributes from
468 * @attributes. See #GdkWindowAttr and #GdkWindowAttributesType for
469 * more details. Note: to use this on displays other than the default
470 * display, @parent must be specified.
472 * Return value: the new #GdkWindow
475 gdk_window_new (GdkWindow *parent,
476 GdkWindowAttr *attributes,
477 gint attributes_mask)
480 GdkWindowObject *private;
481 GdkWindowImplX11 *impl;
482 GdkDrawableImplX11 *draw_impl;
483 GdkScreenX11 *screen_x11;
492 XSetWindowAttributes xattributes;
493 long xattributes_mask;
494 XClassHint *class_hint;
501 g_return_val_if_fail (attributes != NULL, NULL);
506 g_warning ("gdk_window_new(): no parent specified reverting to parent = default root window"));
508 screen = gdk_screen_get_default ();
509 parent = gdk_screen_get_root_window (screen);
512 screen = gdk_drawable_get_screen (parent);
514 screen_x11 = GDK_SCREEN_X11 (screen);
516 g_return_val_if_fail (GDK_IS_WINDOW (parent), NULL);
518 if (GDK_WINDOW_DESTROYED (parent))
521 xparent = GDK_WINDOW_XID (parent);
523 window = g_object_new (GDK_TYPE_WINDOW, NULL);
524 private = (GdkWindowObject *)window;
525 impl = GDK_WINDOW_IMPL_X11 (private->impl);
526 draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl);
527 draw_impl->wrapper = GDK_DRAWABLE (window);
529 draw_impl->screen = screen;
530 xdisplay = screen_x11->xdisplay;
532 /* Windows with a foreign parent are treated as if they are children
533 * of the root window, except for actual creation.
535 if (GDK_WINDOW_TYPE (parent) == GDK_WINDOW_FOREIGN)
536 parent = gdk_screen_get_root_window (screen);
538 private->parent = (GdkWindowObject *)parent;
540 private->accept_focus = TRUE;
542 xattributes_mask = 0;
544 if (attributes_mask & GDK_WA_X)
549 if (attributes_mask & GDK_WA_Y)
556 impl->width = (attributes->width > 1) ? (attributes->width) : (1);
557 impl->height = (attributes->height > 1) ? (attributes->height) : (1);
559 if (attributes->wclass == GDK_INPUT_ONLY)
561 /* Backwards compatiblity - we've always ignored
562 * attributes->window_type for input-only windows
565 if (GDK_WINDOW_TYPE (parent) == GDK_WINDOW_ROOT)
566 private->window_type = GDK_WINDOW_TEMP;
568 private->window_type = GDK_WINDOW_CHILD;
571 private->window_type = attributes->window_type;
573 _gdk_window_init_position (GDK_WINDOW (private));
574 if (impl->position_info.big)
575 private->guffaw_gravity = TRUE;
577 if (attributes_mask & GDK_WA_VISUAL)
578 visual = attributes->visual;
580 visual = gdk_screen_get_system_visual (screen);
581 xvisual = ((GdkVisualPrivate*) visual)->xvisual;
583 xattributes.event_mask = StructureNotifyMask | PropertyChangeMask;
584 for (i = 0; i < _gdk_nenvent_masks; i++)
586 if (attributes->event_mask & (1 << (i + 1)))
587 xattributes.event_mask |= _gdk_event_mask_table[i];
589 private->event_mask = attributes->event_mask;
591 if (xattributes.event_mask)
592 xattributes_mask |= CWEventMask;
594 if (attributes_mask & GDK_WA_NOREDIR)
596 xattributes.override_redirect =
597 (attributes->override_redirect == FALSE)?False:True;
598 xattributes_mask |= CWOverrideRedirect;
601 xattributes.override_redirect = False;
603 if (private->parent && private->parent->guffaw_gravity)
605 xattributes.win_gravity = StaticGravity;
606 xattributes_mask |= CWWinGravity;
610 switch (private->window_type)
612 case GDK_WINDOW_TOPLEVEL:
613 case GDK_WINDOW_DIALOG:
614 case GDK_WINDOW_TEMP:
615 if (GDK_WINDOW_TYPE (parent) != GDK_WINDOW_ROOT)
617 g_warning (G_STRLOC "Toplevel windows must be created as children of\n"
618 "of a window of type GDK_WINDOW_ROOT or GDK_WINDOW_FOREIGN");
619 xparent = GDK_SCREEN_XROOTWIN (screen);
621 case GDK_WINDOW_CHILD:
624 g_warning (G_STRLOC "cannot make windows of type %d", private->window_type);
628 if (attributes->wclass == GDK_INPUT_OUTPUT)
631 depth = visual->depth;
633 private->input_only = FALSE;
634 private->depth = depth;
636 if (attributes_mask & GDK_WA_COLORMAP)
638 draw_impl->colormap = attributes->colormap;
639 g_object_ref (attributes->colormap);
643 if ((((GdkVisualPrivate *)gdk_screen_get_system_visual (screen))->xvisual) == xvisual)
645 draw_impl->colormap = gdk_screen_get_system_colormap (screen);
646 g_object_ref (draw_impl->colormap);
650 draw_impl->colormap = gdk_colormap_new (visual, FALSE);
654 private->bg_color.pixel = BlackPixel (xdisplay, screen_x11->screen_num);
655 xattributes.background_pixel = private->bg_color.pixel;
657 private->bg_pixmap = NULL;
659 xattributes.border_pixel = BlackPixel (xdisplay, screen_x11->screen_num);
660 xattributes_mask |= CWBorderPixel | CWBackPixel;
662 if (private->guffaw_gravity)
663 xattributes.bit_gravity = StaticGravity;
665 xattributes.bit_gravity = NorthWestGravity;
667 xattributes_mask |= CWBitGravity;
669 xattributes.colormap = GDK_COLORMAP_XCOLORMAP (draw_impl->colormap);
670 xattributes_mask |= CWColormap;
672 if (private->window_type == GDK_WINDOW_TEMP)
674 xattributes.save_under = True;
675 xattributes.override_redirect = True;
676 xattributes.cursor = None;
677 xattributes_mask |= CWSaveUnder | CWOverrideRedirect;
685 private->input_only = TRUE;
686 draw_impl->colormap = gdk_screen_get_system_colormap (screen);
687 g_object_ref (draw_impl->colormap);
690 xid = draw_impl->xid = XCreateWindow (xdisplay, xparent,
691 impl->position_info.x, impl->position_info.y,
692 impl->position_info.width, impl->position_info.height,
693 0, depth, class, xvisual,
694 xattributes_mask, &xattributes);
696 g_object_ref (window);
697 _gdk_xid_table_insert (screen_x11->display, &draw_impl->xid, window);
699 gdk_window_set_cursor (window, ((attributes_mask & GDK_WA_CURSOR) ?
700 (attributes->cursor) :
704 private->parent->children = g_list_prepend (private->parent->children, window);
706 switch (GDK_WINDOW_TYPE (private))
708 case GDK_WINDOW_DIALOG:
709 case GDK_WINDOW_TOPLEVEL:
710 case GDK_WINDOW_TEMP:
711 if (attributes_mask & GDK_WA_TITLE)
712 title = attributes->title;
714 title = get_default_title ();
716 gdk_window_set_title (window, title);
718 if (attributes_mask & GDK_WA_WMCLASS)
720 class_hint = XAllocClassHint ();
721 class_hint->res_name = attributes->wmclass_name;
722 class_hint->res_class = attributes->wmclass_class;
723 XSetClassHint (xdisplay, xid, class_hint);
727 setup_toplevel_window (window, parent);
730 case GDK_WINDOW_CHILD:
731 if ((attributes->wclass == GDK_INPUT_OUTPUT) &&
732 (draw_impl->colormap != gdk_screen_get_system_colormap (screen)) &&
733 (draw_impl->colormap != gdk_drawable_get_colormap (gdk_window_get_toplevel (window))))
735 GDK_NOTE (MISC, g_message ("adding colormap window\n"));
736 gdk_window_add_colormap_windows (window);
748 x_event_mask_to_gdk_event_mask (long mask)
750 GdkEventMask event_mask = 0;
753 for (i = 0; i < _gdk_nenvent_masks; i++)
755 if (mask & _gdk_event_mask_table[i])
756 event_mask |= 1 << (i + 1);
763 * gdk_window_foreign_new_for_display:
764 * @display: the #GdkDisplay where the window handle comes from.
765 * @anid: a native window handle.
767 * Wraps a native window in a #GdkWindow.
768 * This may fail if the window has been destroyed.
770 * For example in the X backend, a native window handle is an Xlib
773 * Return value: the newly-created #GdkWindow wrapper for the
774 * native window or %NULL if the window has been destroyed.
779 gdk_window_foreign_new_for_display (GdkDisplay *display,
780 GdkNativeWindow anid)
783 GdkWindowObject *private;
784 GdkWindowImplX11 *impl;
785 GdkDrawableImplX11 *draw_impl;
786 GdkDisplayX11 *display_x11;
787 XWindowAttributes attrs;
789 Window *children = NULL;
793 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
795 display_x11 = GDK_DISPLAY_X11 (display);
797 gdk_error_trap_push ();
798 result = XGetWindowAttributes (display_x11->xdisplay, anid, &attrs);
799 if (gdk_error_trap_pop () || !result)
802 /* FIXME: This is pretty expensive. Maybe the caller should supply
804 gdk_error_trap_push ();
805 result = XQueryTree (display_x11->xdisplay, anid, &root, &parent, &children, &nchildren);
806 if (gdk_error_trap_pop () || !result)
812 window = g_object_new (GDK_TYPE_WINDOW, NULL);
813 private = (GdkWindowObject *)window;
814 impl = GDK_WINDOW_IMPL_X11 (private->impl);
815 draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl);
816 draw_impl->wrapper = GDK_DRAWABLE (window);
817 draw_impl->screen = _gdk_x11_display_screen_for_xrootwin (display, root);
819 private->parent = gdk_xid_table_lookup_for_display (display, parent);
821 if (!private->parent || GDK_WINDOW_TYPE (private->parent) == GDK_WINDOW_FOREIGN)
822 private->parent = (GdkWindowObject *) gdk_screen_get_root_window (draw_impl->screen);
824 private->parent->children = g_list_prepend (private->parent->children, window);
826 draw_impl->xid = anid;
828 private->x = attrs.x;
829 private->y = attrs.y;
830 impl->width = attrs.width;
831 impl->height = attrs.height;
832 private->window_type = GDK_WINDOW_FOREIGN;
833 private->destroyed = FALSE;
835 private->event_mask = x_event_mask_to_gdk_event_mask (attrs.your_event_mask);
837 if (attrs.map_state == IsUnmapped)
838 private->state = GDK_WINDOW_STATE_WITHDRAWN;
842 private->depth = attrs.depth;
844 _gdk_window_init_position (GDK_WINDOW (private));
846 g_object_ref (window);
847 _gdk_xid_table_insert (display, &GDK_WINDOW_XID (window), window);
852 * gdk_window_lookup_for_display:
853 * @display: the #GdkDisplay corresponding to the window handle
854 * @anid: a native window handle.
856 * Looks up the #GdkWindow that wraps the given native window handle.
858 * For example in the X backend, a native window handle is an Xlib
861 * Return value: the #GdkWindow wrapper for the native window,
862 * or %NULL if there is none.
867 gdk_window_lookup_for_display (GdkDisplay *display, GdkNativeWindow anid)
869 return (GdkWindow*) gdk_xid_table_lookup_for_display (display, anid);
874 * @anid: a native window handle.
876 * Looks up the #GdkWindow that wraps the given native window handle.
878 * For example in the X backend, a native window handle is an Xlib
881 * Return value: the #GdkWindow wrapper for the native window,
882 * or %NULL if there is none.
885 gdk_window_lookup (GdkNativeWindow anid)
887 return (GdkWindow*) gdk_xid_table_lookup (anid);
891 gdk_toplevel_x11_free_contents (GdkToplevelX11 *toplevel)
893 if (toplevel->icon_window)
895 g_object_unref (toplevel->icon_window);
896 toplevel->icon_window = NULL;
898 if (toplevel->icon_pixmap)
900 g_object_unref (toplevel->icon_pixmap);
901 toplevel->icon_pixmap = NULL;
903 if (toplevel->icon_mask)
905 g_object_unref (toplevel->icon_mask);
906 toplevel->icon_mask = NULL;
908 if (toplevel->group_leader)
910 g_object_unref (toplevel->group_leader);
911 toplevel->group_leader = NULL;
916 _gdk_windowing_window_destroy (GdkWindow *window,
918 gboolean foreign_destroy)
920 GdkWindowObject *private = (GdkWindowObject *)window;
921 GdkToplevelX11 *toplevel;
922 GdkDrawableImplX11 *draw_impl;
924 g_return_if_fail (GDK_IS_WINDOW (window));
926 _gdk_selection_window_destroyed (window);
928 if (private->extension_events != 0)
929 _gdk_input_window_destroy (window);
931 toplevel = _gdk_x11_window_get_toplevel (window);
933 gdk_toplevel_x11_free_contents (toplevel);
935 draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl);
937 if (draw_impl->xft_draw)
938 XftDrawDestroy (draw_impl->xft_draw);
940 if (private->window_type == GDK_WINDOW_FOREIGN)
942 if (!foreign_destroy && (private->parent != NULL))
944 /* It's somebody else's window, but in our heirarchy,
945 * so reparent it to the root window, and then send
946 * it a delete event, as if we were a WM
948 XClientMessageEvent xevent;
950 gdk_error_trap_push ();
951 gdk_window_hide (window);
952 gdk_window_reparent (window, NULL, 0, 0);
954 xevent.type = ClientMessage;
955 xevent.window = GDK_WINDOW_XID (window);
956 xevent.message_type = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
959 xevent.data.l[0] = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
961 xevent.data.l[1] = CurrentTime;
962 xevent.data.l[2] = 0;
963 xevent.data.l[3] = 0;
964 xevent.data.l[4] = 0;
966 XSendEvent (GDK_WINDOW_XDISPLAY (window),
967 GDK_WINDOW_XID (window),
968 False, 0, (XEvent *)&xevent);
969 gdk_display_sync (GDK_WINDOW_DISPLAY (window));
970 gdk_error_trap_pop ();
973 else if (!recursing && !foreign_destroy)
975 XDestroyWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
979 /* This function is called when the XWindow is really gone.
982 gdk_window_destroy_notify (GdkWindow *window)
984 GdkWindowImplX11 *window_impl;
986 g_return_if_fail (window != NULL);
988 window_impl = GDK_WINDOW_IMPL_X11 (((GdkWindowObject *)window)->impl);
990 if (!GDK_WINDOW_DESTROYED (window))
992 if (GDK_WINDOW_TYPE(window) != GDK_WINDOW_FOREIGN)
993 g_warning ("GdkWindow %#lx unexpectedly destroyed", GDK_WINDOW_XID (window));
995 _gdk_window_destroy (window, TRUE);
998 _gdk_xid_table_remove (GDK_WINDOW_DISPLAY (window), GDK_WINDOW_XID (window));
999 if (window_impl->toplevel && window_impl->toplevel->focus_window)
1000 _gdk_xid_table_remove (GDK_WINDOW_DISPLAY (window), window_impl->toplevel->focus_window);
1002 _gdk_xgrab_check_destroy (window);
1004 g_object_unref (window);
1008 update_wm_hints (GdkWindow *window,
1011 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
1012 GdkWindowObject *private = (GdkWindowObject *)window;
1013 GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
1017 private->state & GDK_WINDOW_STATE_WITHDRAWN)
1020 wm_hints.flags = StateHint | InputHint;
1021 wm_hints.input = private->accept_focus ? True : False;
1022 wm_hints.initial_state = NormalState;
1024 if (private->state & GDK_WINDOW_STATE_ICONIFIED)
1026 wm_hints.flags |= StateHint;
1027 wm_hints.initial_state = IconicState;
1030 if (toplevel->icon_window && !GDK_WINDOW_DESTROYED (toplevel->icon_window))
1032 wm_hints.flags |= IconWindowHint;
1033 wm_hints.icon_window = GDK_WINDOW_XID (toplevel->icon_window);
1036 if (toplevel->icon_pixmap)
1038 wm_hints.flags |= IconPixmapHint;
1039 wm_hints.icon_pixmap = GDK_PIXMAP_XID (toplevel->icon_pixmap);
1042 if (toplevel->icon_mask)
1044 wm_hints.flags |= IconMaskHint;
1045 wm_hints.icon_mask = GDK_PIXMAP_XID (toplevel->icon_mask);
1048 wm_hints.flags |= WindowGroupHint;
1049 if (toplevel->group_leader && !GDK_WINDOW_DESTROYED (toplevel->group_leader))
1051 wm_hints.flags |= WindowGroupHint;
1052 wm_hints.window_group = GDK_WINDOW_XID (toplevel->group_leader);
1055 wm_hints.window_group = GDK_DISPLAY_X11 (display)->leader_window;
1057 XSetWMHints (GDK_WINDOW_XDISPLAY (window),
1058 GDK_WINDOW_XID (window),
1063 set_initial_hints (GdkWindow *window)
1065 GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
1066 Display *xdisplay = GDK_DISPLAY_XDISPLAY (display);
1067 Window xwindow = GDK_WINDOW_XID (window);
1068 GdkWindowObject *private;
1069 GdkToplevelX11 *toplevel;
1073 private = (GdkWindowObject*) window;
1074 toplevel = _gdk_x11_window_get_toplevel (window);
1079 update_wm_hints (window, TRUE);
1081 /* We set the spec hints regardless of whether the spec is supported,
1082 * since it can't hurt and it's kind of expensive to check whether
1088 if (private->state & GDK_WINDOW_STATE_MAXIMIZED)
1090 atoms[i] = gdk_x11_get_xatom_by_name_for_display (display,
1091 "_NET_WM_STATE_MAXIMIZED_VERT");
1093 atoms[i] = gdk_x11_get_xatom_by_name_for_display (display,
1094 "_NET_WM_STATE_MAXIMIZED_HORZ");
1098 if (private->state & GDK_WINDOW_STATE_STICKY)
1100 atoms[i] = gdk_x11_get_xatom_by_name_for_display (display,
1101 "_NET_WM_STATE_STICKY");
1105 if (private->state & GDK_WINDOW_STATE_FULLSCREEN)
1107 atoms[i] = gdk_x11_get_xatom_by_name_for_display (display,
1108 "_NET_WM_STATE_FULLSCREEN");
1112 if (private->modal_hint)
1114 atoms[i] = gdk_x11_get_xatom_by_name_for_display (display,
1115 "_NET_WM_STATE_MODAL");
1119 if (toplevel->skip_taskbar_hint)
1121 atoms[i] = gdk_x11_get_xatom_by_name_for_display (display,
1122 "_NET_WM_STATE_SKIP_TASKBAR");
1126 if (toplevel->skip_pager_hint)
1128 atoms[i] = gdk_x11_get_xatom_by_name_for_display (display,
1129 "_NET_WM_STATE_SKIP_PAGER");
1135 XChangeProperty (xdisplay,
1137 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE"),
1138 XA_ATOM, 32, PropModeReplace,
1139 (guchar*) atoms, i);
1143 XDeleteProperty (xdisplay,
1145 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE"));
1148 if (private->state & GDK_WINDOW_STATE_STICKY)
1150 atoms[0] = 0xFFFFFFFF;
1151 XChangeProperty (xdisplay,
1153 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"),
1154 XA_CARDINAL, 32, PropModeReplace,
1155 (guchar*) atoms, 1);
1159 XDeleteProperty (xdisplay,
1161 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"));
1164 toplevel->map_serial = NextRequest (xdisplay);
1168 show_window_internal (GdkWindow *window,
1171 GdkWindowObject *private;
1173 g_return_if_fail (GDK_IS_WINDOW (window));
1175 private = (GdkWindowObject*) window;
1176 if (!private->destroyed)
1178 GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (private->impl);
1179 Display *xdisplay = GDK_WINDOW_XDISPLAY (window);
1180 Window xwindow = GDK_WINDOW_XID (window);
1183 XRaiseWindow (xdisplay, xwindow);
1185 if (!GDK_WINDOW_IS_MAPPED (window))
1187 set_initial_hints (window);
1189 gdk_synthesize_window_state (window,
1190 GDK_WINDOW_STATE_WITHDRAWN,
1194 g_assert (GDK_WINDOW_IS_MAPPED (window));
1196 if (impl->position_info.mapped)
1197 XMapWindow (xdisplay, xwindow);
1202 * gdk_window_show_unraised:
1203 * @window: a #GdkWindow
1205 * Shows a #GdkWindow onscreen, but does not modify its stacking
1206 * order. In contrast, gdk_window_show() will raise the window
1207 * to the top of the window stack.
1209 * On the X11 platform, in Xlib terms, this function calls
1210 * XMapWindow() (it also updates some internal GDK state, which means
1211 * that you can't really use XMapWindow() directly on a GDK window).
1215 gdk_window_show_unraised (GdkWindow *window)
1217 g_return_if_fail (GDK_IS_WINDOW (window));
1219 show_window_internal (window, FALSE);
1224 * @window: a #GdkWindow
1226 * Like gdk_window_show_unraised(), but also raises the window to the
1227 * top of the window stack (moves the window to the front of the
1230 * This function maps a window so it's visible onscreen. Its opposite
1231 * is gdk_window_hide().
1233 * When implementing a #GtkWidget, you should call this function on the widget's
1234 * #GdkWindow as part of the "map" method.
1238 gdk_window_show (GdkWindow *window)
1240 g_return_if_fail (GDK_IS_WINDOW (window));
1242 show_window_internal (window, TRUE);
1247 * @window: a #GdkWindow
1249 * For toplevel windows, withdraws them, so they will no longer be
1250 * known to the window manager; for all windows, unmaps them, so
1251 * they won't be displayed. Normally done automatically as
1252 * part of gtk_widget_hide().
1256 gdk_window_hide (GdkWindow *window)
1258 GdkWindowObject *private;
1260 g_return_if_fail (window != NULL);
1262 private = (GdkWindowObject*) window;
1264 /* We'll get the unmap notify eventually, and handle it then,
1265 * but checking here makes things more consistent if we are
1266 * just doing stuff ourself.
1268 _gdk_xgrab_check_unmap (window,
1269 NextRequest (GDK_WINDOW_XDISPLAY (window)));
1271 /* You can't simply unmap toplevel windows. */
1272 switch (private->window_type)
1274 case GDK_WINDOW_TOPLEVEL:
1275 case GDK_WINDOW_DIALOG:
1276 case GDK_WINDOW_TEMP: /* ? */
1277 gdk_window_withdraw (window);
1281 case GDK_WINDOW_FOREIGN:
1282 case GDK_WINDOW_ROOT:
1283 case GDK_WINDOW_CHILD:
1287 if (!private->destroyed)
1289 if (GDK_WINDOW_IS_MAPPED (window))
1290 gdk_synthesize_window_state (window,
1292 GDK_WINDOW_STATE_WITHDRAWN);
1294 g_assert (!GDK_WINDOW_IS_MAPPED (window));
1296 _gdk_window_clear_update_area (window);
1298 XUnmapWindow (GDK_WINDOW_XDISPLAY (window),
1299 GDK_WINDOW_XID (window));
1304 * gdk_window_withdraw:
1305 * @window: a toplevel #GdkWindow
1307 * Withdraws a window (unmaps it and asks the window manager to forget about it).
1308 * This function is not really useful as gdk_window_hide() automatically
1309 * withdraws toplevel windows before hiding them.
1313 gdk_window_withdraw (GdkWindow *window)
1315 GdkWindowObject *private;
1317 g_return_if_fail (window != NULL);
1319 private = (GdkWindowObject*) window;
1320 if (!private->destroyed)
1322 if (GDK_WINDOW_IS_MAPPED (window))
1323 gdk_synthesize_window_state (window,
1325 GDK_WINDOW_STATE_WITHDRAWN);
1327 g_assert (!GDK_WINDOW_IS_MAPPED (window));
1329 XWithdrawWindow (GDK_WINDOW_XDISPLAY (window),
1330 GDK_WINDOW_XID (window), 0);
1336 * @window: a #GdkWindow
1337 * @x: X coordinate relative to window's parent
1338 * @y: Y coordinate relative to window's parent
1340 * Repositions a window relative to its parent window.
1341 * For toplevel windows, window managers may ignore or modify the move;
1342 * you should probably use gtk_window_move() on a #GtkWindow widget
1343 * anyway, instead of using GDK functions. For child windows,
1344 * the move will reliably succeed.
1346 * If you're also planning to resize the window, use gdk_window_move_resize()
1347 * to both move and resize simultaneously, for a nicer visual effect.
1350 gdk_window_move (GdkWindow *window,
1354 GdkWindowObject *private = (GdkWindowObject *)window;
1355 GdkWindowImplX11 *impl;
1357 g_return_if_fail (window != NULL);
1358 g_return_if_fail (GDK_IS_WINDOW (window));
1360 impl = GDK_WINDOW_IMPL_X11 (private->impl);
1362 if (!GDK_WINDOW_DESTROYED (window))
1364 if (GDK_WINDOW_TYPE (private) == GDK_WINDOW_CHILD)
1365 _gdk_window_move_resize_child (window, x, y,
1366 impl->width, impl->height);
1369 XMoveWindow (GDK_WINDOW_XDISPLAY (window),
1370 GDK_WINDOW_XID (window),
1377 * gdk_window_resize:
1378 * @window: a #GdkWindow
1379 * @width: new width of the window
1380 * @height: new height of the window
1382 * Resizes @window; for toplevel windows, asks the window manager to resize
1383 * the window. The window manager may not allow the resize. When using GTK+,
1384 * use gtk_window_resize() instead of this low-level GDK function.
1386 * Windows may not be resized below 1x1.
1388 * If you're also planning to move the window, use gdk_window_move_resize()
1389 * to both move and resize simultaneously, for a nicer visual effect.
1392 gdk_window_resize (GdkWindow *window,
1396 GdkWindowObject *private;
1398 g_return_if_fail (window != NULL);
1399 g_return_if_fail (GDK_IS_WINDOW (window));
1406 private = (GdkWindowObject*) window;
1408 if (!GDK_WINDOW_DESTROYED (window))
1410 if (GDK_WINDOW_TYPE (private) == GDK_WINDOW_CHILD)
1411 _gdk_window_move_resize_child (window, private->x, private->y,
1415 GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (private->impl);
1417 if (width != impl->width || height != impl->height)
1418 private->resize_count += 1;
1420 XResizeWindow (GDK_WINDOW_XDISPLAY (window),
1421 GDK_WINDOW_XID (window),
1428 * gdk_window_move_resize:
1429 * @window: a #GdkWindow
1430 * @x: new X position relative to window's parent
1431 * @y: new Y position relative to window's parent
1433 * @height: new height
1435 * Equivalent to calling gdk_window_move() and gdk_window_resize(),
1436 * except that both operations are performed at once, avoiding strange
1437 * visual effects. (i.e. the user may be able to see the window first
1438 * move, then resize, if you don't use gdk_window_move_resize().)
1441 gdk_window_move_resize (GdkWindow *window,
1447 GdkWindowObject *private;
1449 g_return_if_fail (window != NULL);
1450 g_return_if_fail (GDK_IS_WINDOW (window));
1457 private = (GdkWindowObject*) window;
1459 if (!GDK_WINDOW_DESTROYED (window))
1461 if (GDK_WINDOW_TYPE (private) == GDK_WINDOW_CHILD)
1462 _gdk_window_move_resize_child (window, x, y, width, height);
1465 GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (private->impl);
1467 if (width != impl->width || height != impl->height)
1468 private->resize_count += 1;
1470 XMoveResizeWindow (GDK_WINDOW_XDISPLAY (window),
1471 GDK_WINDOW_XID (window),
1472 x, y, width, height);
1478 * gdk_window_reparent:
1479 * @window: a #GdkWindow
1480 * @new_parent: new parent to move @window into
1481 * @x: X location inside the new parent
1482 * @y: Y location inside the new parent
1484 * Reparents @window into the given @new_parent. The window being
1485 * reparented will be unmapped as a side effect.
1489 gdk_window_reparent (GdkWindow *window,
1490 GdkWindow *new_parent,
1494 GdkDisplay *display;
1495 GdkWindowObject *window_private;
1496 GdkWindowObject *parent_private;
1497 GdkWindowObject *old_parent_private;
1498 GdkWindowImplX11 *impl;
1499 gboolean was_toplevel;
1501 g_return_if_fail (window != NULL);
1502 g_return_if_fail (GDK_IS_WINDOW (window));
1503 g_return_if_fail (new_parent == NULL || GDK_IS_WINDOW (new_parent));
1504 g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_ROOT);
1507 new_parent = gdk_screen_get_root_window (GDK_WINDOW_SCREEN (window));
1509 display = GDK_WINDOW_DISPLAY (window);
1511 window_private = (GdkWindowObject*) window;
1512 old_parent_private = (GdkWindowObject*)window_private->parent;
1513 parent_private = (GdkWindowObject*) new_parent;
1514 impl = GDK_WINDOW_IMPL_X11 (window_private->impl);
1516 if (!GDK_WINDOW_DESTROYED (window) && !GDK_WINDOW_DESTROYED (new_parent))
1517 XReparentWindow (GDK_WINDOW_XDISPLAY (window),
1518 GDK_WINDOW_XID (window),
1519 GDK_WINDOW_XID (new_parent),
1522 window_private->x = x;
1523 window_private->y = y;
1525 /* From here on, we treat parents of type GDK_WINDOW_FOREIGN like
1528 if (GDK_WINDOW_TYPE (new_parent) == GDK_WINDOW_FOREIGN)
1529 new_parent = gdk_screen_get_root_window (GDK_WINDOW_SCREEN (window));
1531 window_private->parent = (GdkWindowObject *)new_parent;
1533 /* Switch the window type as appropriate */
1535 switch (GDK_WINDOW_TYPE (new_parent))
1537 case GDK_WINDOW_ROOT:
1538 case GDK_WINDOW_FOREIGN:
1539 was_toplevel = WINDOW_IS_TOPLEVEL (window);
1541 if (impl->toplevel_window_type != -1)
1542 GDK_WINDOW_TYPE (window) = impl->toplevel_window_type;
1543 else if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD)
1544 GDK_WINDOW_TYPE (window) = GDK_WINDOW_TOPLEVEL;
1546 if (WINDOW_IS_TOPLEVEL (window) && !was_toplevel)
1547 setup_toplevel_window (window, new_parent);
1549 case GDK_WINDOW_TOPLEVEL:
1550 case GDK_WINDOW_CHILD:
1551 case GDK_WINDOW_DIALOG:
1552 case GDK_WINDOW_TEMP:
1553 if (WINDOW_IS_TOPLEVEL (window))
1555 /* Save the original window type so we can restore it if the
1556 * window is reparented back to be a toplevel
1558 impl->toplevel_window_type = GDK_WINDOW_TYPE (window);
1559 GDK_WINDOW_TYPE (window) = GDK_WINDOW_CHILD;
1562 if (impl->toplevel->focus_window)
1564 XDestroyWindow (GDK_WINDOW_XDISPLAY (window), impl->toplevel->focus_window);
1565 _gdk_xid_table_remove (GDK_WINDOW_DISPLAY (window), impl->toplevel->focus_window);
1568 gdk_toplevel_x11_free_contents (impl->toplevel);
1569 g_free (impl->toplevel);
1570 impl->toplevel = NULL;
1575 if (old_parent_private)
1576 old_parent_private->children = g_list_remove (old_parent_private->children, window);
1578 if ((old_parent_private &&
1579 (!old_parent_private->guffaw_gravity != !parent_private->guffaw_gravity)) ||
1580 (!old_parent_private && parent_private->guffaw_gravity))
1581 gdk_window_set_static_win_gravity (window, parent_private->guffaw_gravity);
1583 parent_private->children = g_list_prepend (parent_private->children, window);
1584 _gdk_window_init_position (GDK_WINDOW (window_private));
1588 _gdk_windowing_window_clear_area (GdkWindow *window,
1594 g_return_if_fail (window != NULL);
1595 g_return_if_fail (GDK_IS_WINDOW (window));
1597 if (!GDK_WINDOW_DESTROYED (window))
1598 XClearArea (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
1599 x, y, width, height, False);
1603 _gdk_windowing_window_clear_area_e (GdkWindow *window,
1609 g_return_if_fail (window != NULL);
1610 g_return_if_fail (GDK_IS_WINDOW (window));
1612 if (!GDK_WINDOW_DESTROYED (window))
1613 XClearArea (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
1614 x, y, width, height, True);
1620 * @window: a #GdkWindow
1622 * Raises @window to the top of the Z-order (stacking order), so that
1623 * other windows with the same parent window appear below @window.
1624 * This is true whether or not the windows are visible.
1626 * If @window is a toplevel, the window manager may choose to deny the
1627 * request to move the window in the Z-order, gdk_window_raise() only
1628 * requests the restack, does not guarantee it.
1632 gdk_window_raise (GdkWindow *window)
1634 g_return_if_fail (window != NULL);
1635 g_return_if_fail (GDK_IS_WINDOW (window));
1637 if (!GDK_WINDOW_DESTROYED (window))
1638 XRaiseWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
1643 * @window: a #GdkWindow
1645 * Lowers @window to the bottom of the Z-order (stacking order), so that
1646 * other windows with the same parent window appear above @window.
1647 * This is true whether or not the other windows are visible.
1649 * If @window is a toplevel, the window manager may choose to deny the
1650 * request to move the window in the Z-order, gdk_window_lower() only
1651 * requests the restack, does not guarantee it.
1653 * Note that gdk_window_show() raises the window again, so don't call this
1654 * function before gdk_window_show(). (Try gdk_window_show_unraised().)
1658 gdk_window_lower (GdkWindow *window)
1660 g_return_if_fail (window != NULL);
1661 g_return_if_fail (GDK_IS_WINDOW (window));
1663 if (!GDK_WINDOW_DESTROYED (window))
1664 XLowerWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
1669 * @window: a #GdkWindow
1670 * @timestamp: timestamp of the event triggering the window focus
1672 * Sets keyboard focus to @window. If @window is not onscreen this
1673 * will not work. In most cases, gtk_window_present() should be used on
1674 * a #GtkWindow, rather than calling this function.
1678 gdk_window_focus (GdkWindow *window,
1681 GdkDisplay *display;
1683 g_return_if_fail (GDK_IS_WINDOW (window));
1685 if (GDK_WINDOW_DESTROYED (window))
1688 display = GDK_WINDOW_DISPLAY (window);
1690 if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
1691 gdk_atom_intern ("_NET_ACTIVE_WINDOW", FALSE)))
1695 xev.xclient.type = ClientMessage;
1696 xev.xclient.serial = 0;
1697 xev.xclient.send_event = True;
1698 xev.xclient.window = GDK_WINDOW_XWINDOW (window);
1699 xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display,
1700 "_NET_ACTIVE_WINDOW");
1701 xev.xclient.format = 32;
1702 xev.xclient.data.l[0] = 0;
1703 xev.xclient.data.l[1] = 0;
1704 xev.xclient.data.l[2] = 0;
1705 xev.xclient.data.l[3] = 0;
1706 xev.xclient.data.l[4] = 0;
1708 XSendEvent (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XROOTWIN (window), False,
1709 SubstructureRedirectMask | SubstructureNotifyMask,
1714 XRaiseWindow (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window));
1716 /* There is no way of knowing reliably whether we are viewable;
1717 * _gdk_x11_set_input_focus_safe() traps errors asynchronously.
1719 _gdk_x11_set_input_focus_safe (display, GDK_WINDOW_XID (window),
1726 * gdk_window_set_hints:
1727 * @window: a #GdkWindow
1728 * @x: ignored field, does not matter
1729 * @y: ignored field, does not matter
1730 * @min_width: minimum width hint
1731 * @min_height: minimum height hint
1732 * @max_width: max width hint
1733 * @max_height: max height hint
1734 * @flags: logical OR of GDK_HINT_POS, GDK_HINT_MIN_SIZE, and/or GDK_HINT_MAX_SIZE
1736 * This function is broken and useless and you should ignore it.
1737 * If using GTK+, use functions such as gtk_window_resize(), gtk_window_set_size_request(),
1738 * gtk_window_move(), gtk_window_parse_geometry(), and gtk_window_set_geometry_hints(),
1739 * depending on what you're trying to do.
1741 * If using GDK directly, use gdk_window_set_geometry_hints().
1745 gdk_window_set_hints (GdkWindow *window,
1754 XSizeHints size_hints;
1756 g_return_if_fail (window != NULL);
1757 g_return_if_fail (GDK_IS_WINDOW (window));
1759 if (GDK_WINDOW_DESTROYED (window))
1762 size_hints.flags = 0;
1764 if (flags & GDK_HINT_POS)
1766 size_hints.flags |= PPosition;
1771 if (flags & GDK_HINT_MIN_SIZE)
1773 size_hints.flags |= PMinSize;
1774 size_hints.min_width = min_width;
1775 size_hints.min_height = min_height;
1778 if (flags & GDK_HINT_MAX_SIZE)
1780 size_hints.flags |= PMaxSize;
1781 size_hints.max_width = max_width;
1782 size_hints.max_height = max_height;
1785 /* FIXME: Would it be better to delete this property if
1786 * flags == 0? It would save space on the server
1788 XSetWMNormalHints (GDK_WINDOW_XDISPLAY (window),
1789 GDK_WINDOW_XID (window),
1794 * gdk_window_set_type_hint:
1795 * @window: A toplevel #GdkWindow
1796 * @hint: A hint of the function this window will have
1798 * The application can use this call to provide a hint to the window
1799 * manager about the functionality of a window. The window manager
1800 * can use this information when determining the decoration and behaviour
1803 * The hint must be set before the window is mapped.
1806 gdk_window_set_type_hint (GdkWindow *window,
1807 GdkWindowTypeHint hint)
1809 GdkDisplay *display;
1812 g_return_if_fail (window != NULL);
1813 g_return_if_fail (GDK_IS_WINDOW (window));
1815 if (GDK_WINDOW_DESTROYED (window))
1818 display = gdk_drawable_get_display (window);
1822 case GDK_WINDOW_TYPE_HINT_DIALOG:
1823 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DIALOG");
1825 case GDK_WINDOW_TYPE_HINT_MENU:
1826 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_MENU");
1828 case GDK_WINDOW_TYPE_HINT_TOOLBAR:
1829 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_TOOLBAR");
1831 case GDK_WINDOW_TYPE_HINT_UTILITY:
1832 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_UTILITY");
1834 case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
1835 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_SPLASH");
1837 case GDK_WINDOW_TYPE_HINT_DOCK:
1838 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DOCK");
1840 case GDK_WINDOW_TYPE_HINT_DESKTOP:
1841 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DESKTOP");
1844 g_warning ("Unknown hint %d passed to gdk_window_set_type_hint", hint);
1846 case GDK_WINDOW_TYPE_HINT_NORMAL:
1847 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_NORMAL");
1851 XChangeProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
1852 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE"),
1853 XA_ATOM, 32, PropModeReplace,
1854 (guchar *)&atom, 1);
1859 gdk_wmspec_change_state (gboolean add,
1864 GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
1867 #define _NET_WM_STATE_REMOVE 0 /* remove/unset property */
1868 #define _NET_WM_STATE_ADD 1 /* add/set property */
1869 #define _NET_WM_STATE_TOGGLE 2 /* toggle property */
1871 xev.xclient.type = ClientMessage;
1872 xev.xclient.serial = 0;
1873 xev.xclient.send_event = True;
1874 xev.xclient.window = GDK_WINDOW_XID (window);
1875 xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE");
1876 xev.xclient.format = 32;
1877 xev.xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
1878 xev.xclient.data.l[1] = gdk_x11_atom_to_xatom_for_display (display, state1);
1879 xev.xclient.data.l[2] = gdk_x11_atom_to_xatom_for_display (display, state2);
1880 xev.xclient.data.l[3] = 0;
1881 xev.xclient.data.l[4] = 0;
1883 XSendEvent (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XROOTWIN (window), False,
1884 SubstructureRedirectMask | SubstructureNotifyMask,
1889 * gdk_window_set_modal_hint:
1890 * @window: A toplevel #GdkWindow
1891 * @modal: TRUE if the window is modal, FALSE otherwise.
1893 * The application can use this hint to tell the window manager
1894 * that a certain window has modal behaviour. The window manager
1895 * can use this information to handle modal windows in a special
1898 * You should only use this on windows for which you have
1899 * previously called #gdk_window_set_transient_for()
1902 gdk_window_set_modal_hint (GdkWindow *window,
1905 GdkWindowObject *private;
1907 g_return_if_fail (window != NULL);
1908 g_return_if_fail (GDK_IS_WINDOW (window));
1910 if (GDK_WINDOW_DESTROYED (window))
1913 private = (GdkWindowObject*) window;
1915 private->modal_hint = modal;
1917 if (GDK_WINDOW_IS_MAPPED (window))
1918 gdk_wmspec_change_state (modal, window,
1919 gdk_atom_intern ("_NET_WM_STATE_MODAL", FALSE),
1924 * gdk_window_set_skip_taskbar_hint:
1925 * @window: a toplevel #GdkWindow
1926 * @skips_taskbar: %TRUE to skip the taskbar
1928 * Toggles whether a window should appear in a task list or window
1929 * list. If a window's semantic type as specified with
1930 * gdk_window_set_type_hint() already fully describes the window, this
1931 * function should NOT be called in addition, instead you should allow
1932 * the window to be treated according to standard policy for its
1938 gdk_window_set_skip_taskbar_hint (GdkWindow *window,
1939 gboolean skips_taskbar)
1941 GdkToplevelX11 *toplevel;
1943 g_return_if_fail (window != NULL);
1944 g_return_if_fail (GDK_IS_WINDOW (window));
1945 g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD);
1947 if (GDK_WINDOW_DESTROYED (window))
1950 toplevel = _gdk_x11_window_get_toplevel (window);
1951 toplevel->skip_taskbar_hint = skips_taskbar;
1953 if (GDK_WINDOW_IS_MAPPED (window))
1954 gdk_wmspec_change_state (skips_taskbar, window,
1955 gdk_atom_intern ("_NET_WM_STATE_SKIP_TASKBAR", FALSE),
1960 * gdk_window_set_skip_pager_hint:
1961 * @window: a toplevel #GdkWindow
1962 * @skips_pager: %TRUE to skip the pager
1964 * Toggles whether a window should appear in a pager (workspace
1965 * switcher, or other desktop utility program that displays a small
1966 * thumbnail representation of the windows on the desktop). If a
1967 * window's semantic type as specified with gdk_window_set_type_hint()
1968 * already fully describes the window, this function should NOT be
1969 * called in addition, instead you should allow the window to be
1970 * treated according to standard policy for its semantic type.
1975 gdk_window_set_skip_pager_hint (GdkWindow *window,
1976 gboolean skips_pager)
1978 GdkToplevelX11 *toplevel;
1980 g_return_if_fail (window != NULL);
1981 g_return_if_fail (GDK_IS_WINDOW (window));
1982 g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD);
1984 if (GDK_WINDOW_DESTROYED (window))
1987 toplevel = _gdk_x11_window_get_toplevel (window);
1988 toplevel->skip_pager_hint = skips_pager;
1990 if (GDK_WINDOW_IS_MAPPED (window))
1991 gdk_wmspec_change_state (skips_pager, window,
1992 gdk_atom_intern ("_NET_WM_STATE_SKIP_PAGER", FALSE),
1997 * gdk_window_set_geometry_hints:
1998 * @window: a toplevel #GdkWindow
1999 * @geometry: geometry hints
2000 * @geom_mask: bitmask indicating fields of @geometry to pay attention to
2002 * Sets the geometry hints for @window. Hints flagged in @geom_mask
2003 * are set, hints not flagged in @geom_mask are unset.
2004 * To unset all hints, use a @geom_mask of 0 and a @geometry of %NULL.
2006 * This function provides hints to the windowing system about
2007 * acceptable sizes for a toplevel window. The purpose of
2008 * this is to constrain user resizing, but the windowing system
2009 * will typically (but is not required to) also constrain the
2010 * current size of the window to the provided values and
2011 * constrain programatic resizing via gdk_window_resize() or
2012 * gdk_window_move_resize().
2014 * Note that on X11, this effect has no effect on windows
2015 * of type GDK_WINDOW_TEMP or windows where override_redirect
2016 * has been turned on via gdk_window_set_override_redirect()
2017 * since these windows are not resizable by the user.
2019 * Since you can't count on the windowing system doing the
2020 * constraints for programmatic resizes, you should generally
2021 * call gdk_window_constrain_size() yourself to determine
2022 * appropriate sizes.
2026 gdk_window_set_geometry_hints (GdkWindow *window,
2027 GdkGeometry *geometry,
2028 GdkWindowHints geom_mask)
2030 XSizeHints size_hints;
2032 g_return_if_fail (window != NULL);
2033 g_return_if_fail (GDK_IS_WINDOW (window));
2035 if (GDK_WINDOW_DESTROYED (window))
2038 size_hints.flags = 0;
2040 if (geom_mask & GDK_HINT_POS)
2042 size_hints.flags |= PPosition;
2043 /* We need to initialize the following obsolete fields because KWM
2044 * apparently uses these fields if they are non-zero.
2051 if (geom_mask & GDK_HINT_USER_POS)
2053 size_hints.flags |= USPosition;
2056 if (geom_mask & GDK_HINT_USER_SIZE)
2058 size_hints.flags |= USSize;
2061 if (geom_mask & GDK_HINT_MIN_SIZE)
2063 size_hints.flags |= PMinSize;
2064 size_hints.min_width = geometry->min_width;
2065 size_hints.min_height = geometry->min_height;
2068 if (geom_mask & GDK_HINT_MAX_SIZE)
2070 size_hints.flags |= PMaxSize;
2071 size_hints.max_width = MAX (geometry->max_width, 1);
2072 size_hints.max_height = MAX (geometry->max_height, 1);
2075 if (geom_mask & GDK_HINT_BASE_SIZE)
2077 size_hints.flags |= PBaseSize;
2078 size_hints.base_width = geometry->base_width;
2079 size_hints.base_height = geometry->base_height;
2082 if (geom_mask & GDK_HINT_RESIZE_INC)
2084 size_hints.flags |= PResizeInc;
2085 size_hints.width_inc = geometry->width_inc;
2086 size_hints.height_inc = geometry->height_inc;
2089 if (geom_mask & GDK_HINT_ASPECT)
2091 size_hints.flags |= PAspect;
2092 if (geometry->min_aspect <= 1)
2094 size_hints.min_aspect.x = 65536 * geometry->min_aspect;
2095 size_hints.min_aspect.y = 65536;
2099 size_hints.min_aspect.x = 65536;
2100 size_hints.min_aspect.y = 65536 / geometry->min_aspect;;
2102 if (geometry->max_aspect <= 1)
2104 size_hints.max_aspect.x = 65536 * geometry->max_aspect;
2105 size_hints.max_aspect.y = 65536;
2109 size_hints.max_aspect.x = 65536;
2110 size_hints.max_aspect.y = 65536 / geometry->max_aspect;;
2114 if (geom_mask & GDK_HINT_WIN_GRAVITY)
2116 size_hints.flags |= PWinGravity;
2117 size_hints.win_gravity = geometry->win_gravity;
2120 /* FIXME: Would it be better to delete this property if
2121 * geom_mask == 0? It would save space on the server
2123 XSetWMNormalHints (GDK_WINDOW_XDISPLAY (window),
2124 GDK_WINDOW_XID (window),
2129 gdk_window_get_geometry_hints (GdkWindow *window,
2130 GdkGeometry *geometry,
2131 GdkWindowHints *geom_mask)
2133 XSizeHints size_hints;
2134 glong junk_size_mask = 0;
2136 g_return_if_fail (GDK_IS_WINDOW (window));
2137 g_return_if_fail (geometry != NULL);
2138 g_return_if_fail (geom_mask != NULL);
2142 if (GDK_WINDOW_DESTROYED (window))
2145 if (!XGetWMNormalHints (GDK_WINDOW_XDISPLAY (window),
2146 GDK_WINDOW_XID (window),
2151 if (size_hints.flags & PMinSize)
2153 *geom_mask |= GDK_HINT_MIN_SIZE;
2154 geometry->min_width = size_hints.min_width;
2155 geometry->min_height = size_hints.min_height;
2158 if (size_hints.flags & PMaxSize)
2160 *geom_mask |= GDK_HINT_MAX_SIZE;
2161 geometry->max_width = MAX (size_hints.max_width, 1);
2162 geometry->max_height = MAX (size_hints.max_height, 1);
2165 if (size_hints.flags & PResizeInc)
2167 *geom_mask |= GDK_HINT_RESIZE_INC;
2168 geometry->width_inc = size_hints.width_inc;
2169 geometry->height_inc = size_hints.height_inc;
2172 if (size_hints.flags & PAspect)
2174 *geom_mask |= GDK_HINT_ASPECT;
2176 geometry->min_aspect = (gdouble) size_hints.min_aspect.x / (gdouble) size_hints.min_aspect.y;
2177 geometry->max_aspect = (gdouble) size_hints.max_aspect.x / (gdouble) size_hints.max_aspect.y;
2180 if (size_hints.flags & PWinGravity)
2182 *geom_mask |= GDK_HINT_WIN_GRAVITY;
2183 geometry->win_gravity = size_hints.win_gravity;
2188 utf8_is_latin1 (const gchar *str)
2190 const char *p = str;
2194 gunichar ch = g_utf8_get_char (p);
2199 p = g_utf8_next_char (p);
2205 /* Set the property to @utf8_str as STRING if the @utf8_str is fully
2206 * convertable to STRING, otherwise, set it as compound text
2209 set_text_property (GdkDisplay *display,
2212 const gchar *utf8_str)
2214 guchar *prop_text = NULL;
2218 gboolean is_compound_text;
2220 if (utf8_is_latin1 (utf8_str))
2222 prop_type = XA_STRING;
2223 prop_text = gdk_utf8_to_string_target (utf8_str);
2224 prop_length = prop_text ? strlen (prop_text) : 0;
2226 is_compound_text = FALSE;
2232 gdk_utf8_to_compound_text_for_display (display,
2233 utf8_str, &gdk_type, &prop_format,
2234 &prop_text, &prop_length);
2235 prop_type = gdk_x11_atom_to_xatom_for_display (display, gdk_type);
2236 is_compound_text = TRUE;
2241 XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
2244 prop_type, prop_format,
2245 PropModeReplace, prop_text,
2248 if (is_compound_text)
2249 gdk_free_compound_text (prop_text);
2255 /* Set WM_NAME and _NET_WM_NAME
2258 set_wm_name (GdkDisplay *display,
2262 XChangeProperty (GDK_DISPLAY_XDISPLAY (display), xwindow,
2263 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_NAME"),
2264 gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
2265 PropModeReplace, name, strlen (name));
2267 set_text_property (display, xwindow,
2268 gdk_x11_get_xatom_by_name_for_display (display, "WM_NAME"),
2273 * gdk_window_set_title:
2274 * @window: a toplevel #GdkWindow
2275 * @title: title of @window
2277 * Sets the title of a toplevel window, to be displayed in the titlebar.
2278 * If you haven't explicitly set the icon name for the window
2279 * (using gdk_window_set_icon_name()), the icon name will be set to
2280 * @title as well. @title must be in UTF-8 encoding (as with all
2281 * user-readable strings in GDK/GTK+). @title may not be %NULL.
2284 gdk_window_set_title (GdkWindow *window,
2287 GdkDisplay *display;
2291 g_return_if_fail (window != NULL);
2292 g_return_if_fail (GDK_IS_WINDOW (window));
2293 g_return_if_fail (title != NULL);
2295 if (GDK_WINDOW_DESTROYED (window))
2298 display = gdk_drawable_get_display (window);
2299 xdisplay = GDK_DISPLAY_XDISPLAY (display);
2300 xwindow = GDK_WINDOW_XID (window);
2302 set_wm_name (display, xwindow, title);
2304 if (!gdk_window_icon_name_set (window))
2306 XChangeProperty (xdisplay, xwindow,
2307 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON_NAME"),
2308 gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
2309 PropModeReplace, title, strlen (title));
2311 set_text_property (display, xwindow,
2312 gdk_x11_get_xatom_by_name_for_display (display, "WM_ICON_NAME"),
2318 * gdk_window_set_role:
2319 * @window: a toplevel #GdkWindow
2320 * @role: a string indicating its role
2322 * When using GTK+, typically you should use gtk_window_set_role() instead
2323 * of this low-level function.
2325 * The window manager and session manager use a window's role to
2326 * distinguish it from other kinds of window in the same application.
2327 * When an application is restarted after being saved in a previous
2328 * session, all windows with the same title and role are treated as
2329 * interchangeable. So if you have two windows with the same title
2330 * that should be distinguished for session management purposes, you
2331 * should set the role on those windows. It doesn't matter what string
2332 * you use for the role, as long as you have a different role for each
2333 * non-interchangeable kind of window.
2337 gdk_window_set_role (GdkWindow *window,
2340 GdkDisplay *display;
2342 g_return_if_fail (window != NULL);
2343 g_return_if_fail (GDK_IS_WINDOW (window));
2345 display = gdk_drawable_get_display (window);
2347 if (!GDK_WINDOW_DESTROYED (window))
2350 XChangeProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
2351 gdk_x11_get_xatom_by_name_for_display (display, "WM_WINDOW_ROLE"),
2352 XA_STRING, 8, PropModeReplace, role, strlen (role));
2354 XDeleteProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
2355 gdk_x11_get_xatom_by_name_for_display (display, "WM_WINDOW_ROLE"));
2360 * gdk_window_set_transient_for:
2361 * @window: a toplevel #GdkWindow
2362 * @parent: another toplevel #GdkWindow
2364 * Indicates to the window manager that @window is a transient dialog
2365 * associated with the application window @parent. This allows the
2366 * window manager to do things like center @window on @parent and
2367 * keep @window above @parent.
2369 * See gtk_window_set_transient_for() if you're using #GtkWindow or
2374 gdk_window_set_transient_for (GdkWindow *window,
2377 GdkWindowObject *private;
2378 GdkWindowObject *parent_private;
2380 g_return_if_fail (window != NULL);
2381 g_return_if_fail (GDK_IS_WINDOW (window));
2383 private = (GdkWindowObject*) window;
2384 parent_private = (GdkWindowObject*) parent;
2386 if (!GDK_WINDOW_DESTROYED (window) && !GDK_WINDOW_DESTROYED (parent))
2387 XSetTransientForHint (GDK_WINDOW_XDISPLAY (window),
2388 GDK_WINDOW_XID (window),
2389 GDK_WINDOW_XID (parent));
2393 * gdk_window_set_background:
2394 * @window: a #GdkWindow
2395 * @color: an allocated #GdkColor
2397 * Sets the background color of @window. (However, when using GTK+,
2398 * set the background of a widget with gtk_widget_modify_bg() - if
2399 * you're an application - or gtk_style_set_background() - if you're
2400 * implementing a custom widget.)
2402 * The @color must be allocated; gdk_rgb_find_color() is the best way
2403 * to allocate a color.
2405 * See also gdk_window_set_back_pixmap().
2409 gdk_window_set_background (GdkWindow *window,
2410 const GdkColor *color)
2412 GdkWindowObject *private = (GdkWindowObject *)window;
2414 g_return_if_fail (window != NULL);
2415 g_return_if_fail (GDK_IS_WINDOW (window));
2417 if (!GDK_WINDOW_DESTROYED (window))
2418 XSetWindowBackground (GDK_WINDOW_XDISPLAY (window),
2419 GDK_WINDOW_XID (window), color->pixel);
2421 private->bg_color = *color;
2423 if (private->bg_pixmap &&
2424 private->bg_pixmap != GDK_PARENT_RELATIVE_BG &&
2425 private->bg_pixmap != GDK_NO_BG)
2426 g_object_unref (private->bg_pixmap);
2428 private->bg_pixmap = NULL;
2432 * gdk_window_set_back_pixmap:
2433 * @window: a #GdkWindow
2434 * @pixmap: a #GdkPixmap, or %NULL
2435 * @parent_relative: whether the tiling origin is at the origin of @window's parent
2437 * Sets the background pixmap of @window. May also be used to set a background of
2438 * "None" on @window, by setting a background pixmap of %NULL.
2439 * A background pixmap will be tiled, positioning the first tile at the origin of
2440 * @window, or if @parent_relative is %TRUE, the tiling will be done based on the
2441 * origin of the parent window (useful to align tiles in a parent with tiles
2444 * A background pixmap of %NULL means that the window will have no
2445 * background. A window with no background will never have its
2446 * background filled by the windowing system, instead the window will
2447 * contain whatever pixels were already in the corresponding area of
2450 * The windowing system will normally fill a window with its background
2451 * when the window is obscured then exposed, and when you call
2452 * gdk_window_clear().
2456 gdk_window_set_back_pixmap (GdkWindow *window,
2458 gboolean parent_relative)
2460 GdkWindowObject *private = (GdkWindowObject *)window;
2463 g_return_if_fail (window != NULL);
2464 g_return_if_fail (GDK_IS_WINDOW (window));
2465 g_return_if_fail (pixmap == NULL || !parent_relative);
2466 g_return_if_fail (pixmap == NULL || gdk_drawable_get_depth (window) == gdk_drawable_get_depth (pixmap));
2468 if (private->bg_pixmap &&
2469 private->bg_pixmap != GDK_PARENT_RELATIVE_BG &&
2470 private->bg_pixmap != GDK_NO_BG)
2471 g_object_unref (private->bg_pixmap);
2473 if (parent_relative)
2475 xpixmap = ParentRelative;
2476 private->bg_pixmap = GDK_PARENT_RELATIVE_BG;
2482 g_object_ref (pixmap);
2483 private->bg_pixmap = pixmap;
2484 xpixmap = GDK_PIXMAP_XID (pixmap);
2489 private->bg_pixmap = GDK_NO_BG;
2493 if (!GDK_WINDOW_DESTROYED (window))
2494 XSetWindowBackgroundPixmap (GDK_WINDOW_XDISPLAY (window),
2495 GDK_WINDOW_XID (window), xpixmap);
2499 * gdk_window_set_cursor:
2500 * @window: a #GdkWindow
2503 * Sets the mouse pointer for a #GdkWindow. Use gdk_cursor_new() or
2504 * gdk_cursor_new_from_pixmap() to create the cursor.
2505 * To make the cursor invisible, use gdk_cursor_new_from_pixmap() to create
2506 * a cursor with no pixels in it. Passing %NULL for the @cursor argument
2507 * to gdk_window_set_cursor() means that @window will use the cursor of
2508 * its parent window. Most windows should use this default.
2512 gdk_window_set_cursor (GdkWindow *window,
2515 GdkCursorPrivate *cursor_private;
2518 g_return_if_fail (window != NULL);
2519 g_return_if_fail (GDK_IS_WINDOW (window));
2521 cursor_private = (GdkCursorPrivate*) cursor;
2526 xcursor = cursor_private->xcursor;
2528 if (!GDK_WINDOW_DESTROYED (window))
2529 XDefineCursor (GDK_WINDOW_XDISPLAY (window),
2530 GDK_WINDOW_XID (window),
2535 * gdk_window_get_geometry:
2536 * @window: a #GdkWindow
2537 * @x: return location for X coordinate of window (relative to its parent)
2538 * @y: return location for Y coordinate of window (relative to its parent)
2539 * @width: return location for width of window
2540 * @height: return location for height of window
2541 * @depth: return location for bit depth of window
2543 * Any of the return location arguments to this function may be %NULL,
2544 * if you aren't interested in getting the value of that field.
2546 * The X and Y coordinates returned are relative to the parent window
2547 * of @window, which for toplevels usually means relative to the
2548 * window decorations (titlebar, etc.) rather than relative to the
2549 * root window (screen-size background window).
2551 * On the X11 platform, the geometry is obtained from the X server,
2552 * so reflects the latest position of @window; this may be out-of-sync
2553 * with the position of @window delivered in the most-recently-processed
2554 * #GdkEventConfigure. gdk_window_get_position() in contrast gets the
2555 * position from the most recent configure event.
2559 gdk_window_get_geometry (GdkWindow *window,
2571 guint tborder_width;
2574 g_return_if_fail (window == NULL || GDK_IS_WINDOW (window));
2578 GDK_NOTE (MULTIHEAD,
2579 g_message ("gdk_window_get_geometry(): Window needs to be non-NULL to be multi head safe"));
2580 window = gdk_screen_get_root_window ((gdk_screen_get_default ()));
2583 if (!GDK_WINDOW_DESTROYED (window))
2585 XGetGeometry (GDK_WINDOW_XDISPLAY (window),
2586 GDK_WINDOW_XID (window),
2587 &root, &tx, &ty, &twidth, &theight, &tborder_width, &tdepth);
2603 * gdk_window_get_origin:
2604 * @window: a #GdkWindow
2605 * @x: return location for X coordinate
2606 * @y: return location for Y coordinate
2608 * Obtains the position of a window in root window coordinates.
2609 * (Compare with gdk_window_get_position() and
2610 * gdk_window_get_geometry() which return the position of a window
2611 * relative to its parent window.)
2613 * Return value: not meaningful, ignore
2616 gdk_window_get_origin (GdkWindow *window,
2625 g_return_val_if_fail (window != NULL, 0);
2627 if (!GDK_WINDOW_DESTROYED (window))
2629 return_val = XTranslateCoordinates (GDK_WINDOW_XDISPLAY (window),
2630 GDK_WINDOW_XID (window),
2631 GDK_WINDOW_XROOTWIN (window),
2647 * gdk_window_get_deskrelative_origin:
2648 * @window: a toplevel #GdkWindow
2649 * @x: return location for X coordinate
2650 * @y: return location for Y coordinate
2652 * This gets the origin of a #GdkWindow relative to
2653 * an Enlightenment-window-manager desktop. As long as you don't
2654 * assume that the user's desktop/workspace covers the entire
2655 * root window (i.e. you don't assume that the desktop begins
2656 * at root window coordinate 0,0) this function is not necessary.
2657 * It's deprecated for that reason.
2659 * Return value: not meaningful
2662 gdk_window_get_deskrelative_origin (GdkWindow *window,
2666 gboolean return_val = FALSE;
2667 gint num_children, format_return;
2668 Window win, *child, parent, root;
2673 gulong number_return, bytes_after_return;
2674 guchar *data_return;
2676 g_return_val_if_fail (window != NULL, FALSE);
2677 g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
2679 if (!GDK_WINDOW_DESTROYED (window))
2681 atom = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
2682 "ENLIGHTENMENT_DESKTOP");
2683 win = GDK_WINDOW_XID (window);
2685 while (XQueryTree (GDK_WINDOW_XDISPLAY (window), win, &root, &parent,
2686 &child, (unsigned int *)&num_children))
2688 if ((child) && (num_children > 0))
2700 XGetWindowProperty (GDK_WINDOW_XDISPLAY (window), win, atom, 0, 0,
2701 False, XA_CARDINAL, &type_return, &format_return,
2702 &number_return, &bytes_after_return, &data_return);
2704 if (type_return == XA_CARDINAL)
2706 XFree (data_return);
2711 return_val = XTranslateCoordinates (GDK_WINDOW_XDISPLAY (window),
2712 GDK_WINDOW_XID (window),
2727 * gdk_window_get_root_origin:
2728 * @window: a toplevel #GdkWindow
2729 * @x: return location for X position of window frame
2730 * @y: return location for Y position of window frame
2732 * Obtains the top-left corner of the window manager frame in root
2733 * window coordinates.
2737 gdk_window_get_root_origin (GdkWindow *window,
2743 g_return_if_fail (GDK_IS_WINDOW (window));
2745 gdk_window_get_frame_extents (window, &rect);
2755 * gdk_window_get_frame_extents:
2756 * @window: a toplevel #GdkWindow
2757 * @rect: rectangle to fill with bounding box of the window frame
2759 * Obtains the bounding box of the window, including window manager
2760 * titlebar/borders if any. The frame position is given in root window
2761 * coordinates. To get the position of the window itself (rather than
2762 * the frame) in root window coordinates, use gdk_window_get_origin().
2766 gdk_window_get_frame_extents (GdkWindow *window,
2769 GdkWindowObject *private;
2774 unsigned int nchildren;
2776 g_return_if_fail (GDK_IS_WINDOW (window));
2777 g_return_if_fail (rect != NULL);
2779 private = (GdkWindowObject*) window;
2786 if (GDK_WINDOW_DESTROYED (window))
2789 while (private->parent && ((GdkWindowObject*) private->parent)->parent)
2790 private = (GdkWindowObject*) private->parent;
2792 /* Refine our fallback answer a bit using local information */
2793 rect->x = private->x;
2794 rect->y = private->y;
2795 gdk_drawable_get_size ((GdkDrawable *)private, &rect->width, &rect->height);
2797 if (GDK_WINDOW_DESTROYED (private))
2800 gdk_error_trap_push();
2802 xparent = GDK_WINDOW_XID (window);
2806 if (!XQueryTree (GDK_WINDOW_XDISPLAY (window), xwindow,
2808 &children, &nchildren))
2814 while (xparent != root);
2816 if (xparent == root)
2818 unsigned int ww, wh, wb, wd;
2821 if (XGetGeometry (GDK_WINDOW_XDISPLAY (window), xwindow, &root, &wx, &wy, &ww, &wh, &wb, &wd))
2831 gdk_error_trap_pop ();
2835 _gdk_windowing_get_pointer (GdkDisplay *display,
2839 GdkModifierType *mask)
2841 GdkScreen *default_screen;
2849 if (display->closed)
2852 default_screen = gdk_display_get_default_screen (display);
2854 XQueryPointer (GDK_SCREEN_XDISPLAY (default_screen),
2855 GDK_SCREEN_XROOTWIN (default_screen),
2856 &root, &child, &rootx, &rooty, &winx, &winy, &xmask);
2860 GdkWindow *gdk_root = gdk_window_lookup_for_display (display, root);
2861 *screen = gdk_drawable_get_screen (gdk_root);
2870 _gdk_windowing_window_get_pointer (GdkDisplay *display,
2874 GdkModifierType *mask)
2876 GdkWindow *return_val;
2882 unsigned int xmask = 0;
2883 gint xoffset, yoffset;
2885 g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
2887 _gdk_windowing_window_get_offsets (window, &xoffset, &yoffset);
2890 if (!GDK_WINDOW_DESTROYED (window) &&
2891 XQueryPointer (GDK_WINDOW_XDISPLAY (window),
2892 GDK_WINDOW_XID (window),
2893 &root, &child, &rootx, &rooty, &winx, &winy, &xmask))
2896 return_val = gdk_window_lookup_for_display (GDK_WINDOW_DISPLAY (window), child);
2899 *x = winx + xoffset;
2900 *y = winy + yoffset;
2907 _gdk_windowing_window_at_pointer (GdkDisplay *display,
2916 Window xwindow_last = 0;
2918 int rootx = -1, rooty = -1;
2922 screen = gdk_display_get_default_screen (display);
2924 xwindow = GDK_SCREEN_XROOTWIN (screen);
2925 xdisplay = GDK_SCREEN_XDISPLAY (screen);
2927 /* This function really only works if the mouse pointer is held still
2928 * during its operation. If it moves from one leaf window to another
2929 * than we'll end up with inaccurate values for win_x, win_y
2932 gdk_x11_display_grab (display);
2933 XQueryPointer (xdisplay, xwindow,
2934 &root, &child, &rootx, &rooty, &winx, &winy, &xmask);
2936 if (root == xwindow)
2943 xwindow_last = xwindow;
2944 XQueryPointer (xdisplay, xwindow,
2945 &root, &xwindow, &rootx, &rooty, &winx, &winy, &xmask);
2947 gdk_x11_display_ungrab (display);
2949 window = gdk_window_lookup_for_display (GDK_SCREEN_DISPLAY(screen),
2951 *win_x = window ? winx : -1;
2952 *win_y = window ? winy : -1;
2958 * gdk_window_get_events:
2959 * @window: a #GdkWindow
2961 * Gets the event mask for @window. See gdk_window_set_events().
2963 * Return value: event mask for @window
2966 gdk_window_get_events (GdkWindow *window)
2968 XWindowAttributes attrs;
2969 GdkEventMask event_mask;
2971 g_return_val_if_fail (window != NULL, 0);
2972 g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
2974 if (GDK_WINDOW_DESTROYED (window))
2978 XGetWindowAttributes (GDK_WINDOW_XDISPLAY (window),
2979 GDK_WINDOW_XID (window),
2982 event_mask = x_event_mask_to_gdk_event_mask (attrs.your_event_mask);
2983 GDK_WINDOW_OBJECT (window)->event_mask = event_mask;
2990 * gdk_window_set_events:
2991 * @window: a #GdkWindow
2992 * @event_mask: event mask for @window
2994 * The event mask for a window determines which events will be reported
2995 * for that window. For example, an event mask including #GDK_BUTTON_PRESS_MASK
2996 * means the window should report button press events. The event mask
2997 * is the bitwise OR of values from the #GdkEventMask enumeration.
3001 gdk_window_set_events (GdkWindow *window,
3002 GdkEventMask event_mask)
3007 g_return_if_fail (window != NULL);
3008 g_return_if_fail (GDK_IS_WINDOW (window));
3010 if (!GDK_WINDOW_DESTROYED (window))
3012 GDK_WINDOW_OBJECT (window)->event_mask = event_mask;
3013 xevent_mask = StructureNotifyMask | PropertyChangeMask;
3014 for (i = 0; i < _gdk_nenvent_masks; i++)
3016 if (event_mask & (1 << (i + 1)))
3017 xevent_mask |= _gdk_event_mask_table[i];
3020 XSelectInput (GDK_WINDOW_XDISPLAY (window),
3021 GDK_WINDOW_XID (window),
3027 gdk_window_add_colormap_windows (GdkWindow *window)
3029 GdkWindow *toplevel;
3030 Window *old_windows;
3031 Window *new_windows;
3034 g_return_if_fail (window != NULL);
3035 g_return_if_fail (GDK_IS_WINDOW (window));
3037 if (GDK_WINDOW_DESTROYED (window))
3039 toplevel = gdk_window_get_toplevel (window);
3042 if (!XGetWMColormapWindows (GDK_WINDOW_XDISPLAY (toplevel),
3043 GDK_WINDOW_XID (toplevel),
3044 &old_windows, &count))
3049 for (i = 0; i < count; i++)
3050 if (old_windows[i] == GDK_WINDOW_XID (window))
3052 XFree (old_windows);
3056 new_windows = g_new (Window, count + 1);
3058 for (i = 0; i < count; i++)
3059 new_windows[i] = old_windows[i];
3060 new_windows[count] = GDK_WINDOW_XID (window);
3062 XSetWMColormapWindows (GDK_WINDOW_XDISPLAY (toplevel),
3063 GDK_WINDOW_XID (toplevel),
3064 new_windows, count + 1);
3066 g_free (new_windows);
3068 XFree (old_windows);
3072 gdk_window_have_shape_ext (GdkDisplay *display)
3074 #ifdef HAVE_SHAPE_EXT
3077 return XShapeQueryExtension (GDK_DISPLAY_XDISPLAY (display),
3084 #define WARN_SHAPE_TOO_BIG() g_warning ("GdkWindow is too large to allow the use of shape masks or shape regions.")
3087 * This needs the X11 shape extension.
3088 * If not available, shaped windows will look
3089 * ugly, but programs still work. Stefan Wille
3092 * gdk_window_shape_combine_mask:
3093 * @window: a #GdkWindow
3095 * @x: X position of shape mask with respect to @window
3096 * @y: Y position of shape mask with respect to @window
3098 * Applies a shape mask to @window. Pixels in @window corresponding to
3099 * set bits in the @mask will be visible; pixels in @window
3100 * corresponding to unset bits in the @mask will be transparent. This
3101 * gives a non-rectangular window.
3103 * If @mask is %NULL, the shape mask will be unset, and the @x/@y
3104 * parameters are not used.
3106 * On the X11 platform, this uses an X server extension which is
3107 * widely available on most common platforms, but not available on
3108 * very old X servers, and occasionally the implementation will be
3109 * buggy. On servers without the shape extension, this function
3112 * This function works on both toplevel and child windows.
3116 gdk_window_shape_combine_mask (GdkWindow *window,
3121 gint xoffset, yoffset;
3123 g_return_if_fail (window != NULL);
3124 g_return_if_fail (GDK_IS_WINDOW (window));
3126 #ifdef HAVE_SHAPE_EXT
3127 if (GDK_WINDOW_DESTROYED (window))
3130 _gdk_windowing_window_get_offsets (window, &xoffset, &yoffset);
3132 if (xoffset != 0 || yoffset != 0)
3134 WARN_SHAPE_TOO_BIG ();
3138 if (gdk_window_have_shape_ext (GDK_WINDOW_DISPLAY (window)))
3142 pixmap = GDK_PIXMAP_XID (mask);
3151 XShapeCombineMask (GDK_WINDOW_XDISPLAY (window),
3152 GDK_WINDOW_XID (window),
3158 #endif /* HAVE_SHAPE_EXT */
3162 * gdk_window_shape_combine_region:
3163 * @window: a #GdkWindow
3164 * @shape_region: region of window to be non-transparent
3165 * @offset_x: X position of @shape_region in @window coordinates
3166 * @offset_y: Y position of @shape_region in @window coordinates
3168 * Makes pixels in @window outside @shape_region be transparent,
3169 * so that the window may be nonrectangular. See also
3170 * gdk_window_shape_combine_mask() to use a bitmap as the mask.
3172 * If @shape_region is %NULL, the shape will be unset, so the whole
3173 * window will be opaque again. @offset_x and @offset_y are ignored
3174 * if @shape_region is %NULL.
3176 * On the X11 platform, this uses an X server extension which is
3177 * widely available on most common platforms, but not available on
3178 * very old X servers, and occasionally the implementation will be
3179 * buggy. On servers without the shape extension, this function
3182 * This function works on both toplevel and child windows.
3186 gdk_window_shape_combine_region (GdkWindow *window,
3187 GdkRegion *shape_region,
3191 gint xoffset, yoffset;
3193 g_return_if_fail (GDK_IS_WINDOW (window));
3195 #ifdef HAVE_SHAPE_EXT
3196 if (GDK_WINDOW_DESTROYED (window))
3199 _gdk_windowing_window_get_offsets (window, &xoffset, &yoffset);
3201 if (xoffset != 0 || yoffset != 0)
3203 WARN_SHAPE_TOO_BIG ();
3207 if (shape_region == NULL)
3209 /* Use NULL mask to unset the shape */
3210 gdk_window_shape_combine_mask (window, NULL, 0, 0);
3214 if (gdk_window_have_shape_ext (GDK_WINDOW_DISPLAY (window)))
3217 XRectangle *xrects = NULL;
3219 _gdk_region_get_xrectangles (shape_region,
3223 XShapeCombineRectangles (GDK_WINDOW_XDISPLAY (window),
3224 GDK_WINDOW_XID (window),
3233 #endif /* HAVE_SHAPE_EXT */
3238 * gdk_window_set_override_redirect:
3239 * @window: a toplevel #GdkWindow
3240 * @override_redirect: %TRUE if window should be override redirect
3242 * An override redirect window is not under the control of the window manager.
3243 * This means it won't have a titlebar, won't be minimizable, etc. - it will
3244 * be entirely under the control of the application. The window manager
3245 * can't see the override redirect window at all.
3247 * Override redirect should only be used for short-lived temporary
3248 * windows, such as popup menus. #GtkMenu uses an override redirect
3249 * window in its implementation, for example.
3253 gdk_window_set_override_redirect (GdkWindow *window,
3254 gboolean override_redirect)
3256 XSetWindowAttributes attr;
3258 g_return_if_fail (window != NULL);
3259 g_return_if_fail (GDK_IS_WINDOW (window));
3261 if (!GDK_WINDOW_DESTROYED (window))
3263 attr.override_redirect = (override_redirect == FALSE)?False:True;
3264 XChangeWindowAttributes (GDK_WINDOW_XDISPLAY (window),
3265 GDK_WINDOW_XID (window),
3272 * gdk_window_set_accept_focus:
3273 * @window: a toplevel #GdkWindow
3274 * @accept_focus: %TRUE if the window should receive input focus
3276 * Setting @accept_focus to %FALSE hints the desktop environment that the
3277 * window doesn't want to receive input focus.
3279 * On X, it is the responsibility of the window manager to interpret this
3280 * hint. ICCCM-compliant window manager usually respect it.
3285 gdk_window_set_accept_focus (GdkWindow *window,
3286 gboolean accept_focus)
3288 GdkWindowObject *private;
3289 g_return_if_fail (window != NULL);
3290 g_return_if_fail (GDK_IS_WINDOW (window));
3292 private = (GdkWindowObject *)window;
3294 accept_focus = accept_focus != FALSE;
3296 if (private->accept_focus != accept_focus)
3298 private->accept_focus = accept_focus;
3300 if (!GDK_WINDOW_DESTROYED (window))
3301 update_wm_hints (window, FALSE);
3307 * gdk_window_set_icon_list:
3308 * @window: The #GdkWindow toplevel window to set the icon of.
3309 * @pixbufs: A list of pixbufs, of different sizes.
3311 * Sets a list of icons for the window. One of these will be used
3312 * to represent the window when it has been iconified. The icon is
3313 * usually shown in an icon box or some sort of task bar. Which icon
3314 * size is shown depends on the window manager. The window manager
3315 * can scale the icon but setting several size icons can give better
3316 * image quality since the window manager may only need to scale the
3317 * icon by a small amount or not at all.
3321 gdk_window_set_icon_list (GdkWindow *window,
3330 gint width, height, stride;
3333 GdkDisplay *display;
3335 g_return_if_fail (GDK_IS_WINDOW (window));
3337 if (GDK_WINDOW_DESTROYED (window))
3340 display = gdk_drawable_get_display (window);
3348 g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
3350 width = gdk_pixbuf_get_width (pixbuf);
3351 height = gdk_pixbuf_get_height (pixbuf);
3353 size += 2 + width * height;
3355 l = g_list_next (l);
3358 data = g_malloc (size * sizeof (gulong));
3366 width = gdk_pixbuf_get_width (pixbuf);
3367 height = gdk_pixbuf_get_height (pixbuf);
3368 stride = gdk_pixbuf_get_rowstride (pixbuf);
3369 n_channels = gdk_pixbuf_get_n_channels (pixbuf);
3374 pixels = gdk_pixbuf_get_pixels (pixbuf);
3376 for (y = 0; y < height; y++)
3378 for (x = 0; x < width; x++)
3382 r = pixels[y*stride + x*n_channels + 0];
3383 g = pixels[y*stride + x*n_channels + 1];
3384 b = pixels[y*stride + x*n_channels + 2];
3385 if (n_channels >= 4)
3386 a = pixels[y*stride + x*n_channels + 3];
3390 *p++ = a << 24 | r << 16 | g << 8 | b ;
3394 l = g_list_next (l);
3399 XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
3400 GDK_WINDOW_XID (window),
3401 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON"),
3404 (guchar*) data, size);
3408 XDeleteProperty (GDK_DISPLAY_XDISPLAY (display),
3409 GDK_WINDOW_XID (window),
3410 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON"));
3417 * gdk_window_set_icon:
3418 * @window: a toplevel #GdkWindow
3419 * @icon_window: a #GdkWindow to use for the icon, or %NULL to unset
3420 * @pixmap: a #GdkPixmap to use as the icon, or %NULL to unset
3421 * @mask: a 1-bit pixmap (#GdkBitmap) to use as mask for @pixmap, or %NULL to have none
3423 * Sets the icon of @window as a pixmap or window. If using GTK+, investigate
3424 * gtk_window_set_default_icon_list() first, and then gtk_window_set_icon_list()
3425 * and gtk_window_set_icon(). If those don't meet your needs, look at
3426 * gdk_window_set_icon_list(). Only if all those are too high-level do you
3427 * want to fall back to gdk_window_set_icon().
3431 gdk_window_set_icon (GdkWindow *window,
3432 GdkWindow *icon_window,
3436 GdkToplevelX11 *toplevel;
3438 g_return_if_fail (window != NULL);
3439 g_return_if_fail (GDK_IS_WINDOW (window));
3440 g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD);
3442 if (GDK_WINDOW_DESTROYED (window))
3445 toplevel = _gdk_x11_window_get_toplevel (window);
3447 if (toplevel->icon_window != icon_window)
3449 if (toplevel->icon_window)
3450 g_object_unref (toplevel->icon_window);
3451 toplevel->icon_window = g_object_ref (icon_window);
3454 if (toplevel->icon_pixmap != pixmap)
3457 g_object_ref (pixmap);
3458 if (toplevel->icon_pixmap)
3459 g_object_unref (toplevel->icon_pixmap);
3460 toplevel->icon_pixmap = pixmap;
3463 if (toplevel->icon_mask != mask)
3466 g_object_ref (mask);
3467 if (toplevel->icon_mask)
3468 g_object_unref (toplevel->icon_mask);
3469 toplevel->icon_mask = mask;
3472 update_wm_hints (window, FALSE);
3476 gdk_window_icon_name_set (GdkWindow *window)
3478 return GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (window),
3479 g_quark_from_static_string ("gdk-icon-name-set")));
3483 * gdk_window_set_icon_name:
3484 * @window: a toplevel #GdkWindow
3485 * @name: name of window while iconified (minimized)
3487 * Windows may have a name used while minimized, distinct from the
3488 * name they display in their titlebar. Most of the time this is a bad
3489 * idea from a user interface standpoint. But you can set such a name
3490 * with this function, if you like.
3494 gdk_window_set_icon_name (GdkWindow *window,
3497 GdkDisplay *display;
3499 g_return_if_fail (window != NULL);
3500 g_return_if_fail (GDK_IS_WINDOW (window));
3502 if (GDK_WINDOW_DESTROYED (window))
3505 display = gdk_drawable_get_display (window);
3507 g_object_set_qdata (G_OBJECT (window), g_quark_from_static_string ("gdk-icon-name-set"),
3508 GUINT_TO_POINTER (TRUE));
3510 XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
3511 GDK_WINDOW_XID (window),
3512 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON_NAME"),
3513 gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
3514 PropModeReplace, name, strlen (name));
3516 set_text_property (display, GDK_WINDOW_XID (window),
3517 gdk_x11_get_xatom_by_name_for_display (display, "WM_ICON_NAME"),
3522 * gdk_window_iconify:
3523 * @window: a toplevel #GdkWindow
3525 * Asks to iconify (minimize) @window. The window manager may choose
3526 * to ignore the request, but normally will honor it. Using
3527 * gtk_window_iconify() is preferred, if you have a #GtkWindow widget.
3529 * This function only makes sense when @window is a toplevel window.
3533 gdk_window_iconify (GdkWindow *window)
3535 GdkWindowObject *private;
3537 g_return_if_fail (window != NULL);
3538 g_return_if_fail (GDK_IS_WINDOW (window));
3540 if (GDK_WINDOW_DESTROYED (window))
3543 private = (GdkWindowObject*) window;
3545 if (GDK_WINDOW_IS_MAPPED (window))
3547 XIconifyWindow (GDK_WINDOW_XDISPLAY (window),
3548 GDK_WINDOW_XWINDOW (window),
3549 gdk_screen_get_number (GDK_WINDOW_SCREEN (window)));
3553 /* Flip our client side flag, the real work happens on map. */
3554 gdk_synthesize_window_state (window,
3556 GDK_WINDOW_STATE_ICONIFIED);
3561 * gdk_window_deiconify:
3562 * @window: a toplevel #GdkWindow
3564 * Attempt to deiconify (unminimize) @window. On X11 the window manager may
3565 * choose to ignore the request to deiconify. When using GTK+,
3566 * use gtk_window_deiconify() instead of the #GdkWindow variant. Or better yet,
3567 * you probably want to use gtk_window_present(), which raises the window, focuses it,
3568 * unminimizes it, and puts it on the current desktop.
3572 gdk_window_deiconify (GdkWindow *window)
3574 GdkWindowObject *private;
3576 g_return_if_fail (window != NULL);
3577 g_return_if_fail (GDK_IS_WINDOW (window));
3579 if (GDK_WINDOW_DESTROYED (window))
3582 private = (GdkWindowObject*) window;
3584 if (GDK_WINDOW_IS_MAPPED (window))
3586 gdk_window_show (window);
3590 /* Flip our client side flag, the real work happens on map. */
3591 gdk_synthesize_window_state (window,
3592 GDK_WINDOW_STATE_ICONIFIED,
3599 * @window: a toplevel #GdkWindow
3601 * "Pins" a window such that it's on all workspaces and does not scroll
3602 * with viewports, for window managers that have scrollable viewports.
3603 * (When using #GtkWindow, gtk_window_stick() may be more useful.)
3605 * On the X11 platform, this function depends on window manager
3606 * support, so may have no effect with many window managers. However,
3607 * GDK will do the best it can to convince the window manager to stick
3608 * the window. For window managers that don't support this operation,
3609 * there's nothing you can do to force it to happen.
3613 gdk_window_stick (GdkWindow *window)
3615 g_return_if_fail (GDK_IS_WINDOW (window));
3617 if (GDK_WINDOW_DESTROYED (window))
3620 if (GDK_WINDOW_IS_MAPPED (window))
3622 /* "stick" means stick to all desktops _and_ do not scroll with the
3623 * viewport. i.e. glue to the monitor glass in all cases.
3628 /* Request stick during viewport scroll */
3629 gdk_wmspec_change_state (TRUE, window,
3630 gdk_atom_intern ("_NET_WM_STATE_STICKY", FALSE),
3633 /* Request desktop 0xFFFFFFFF */
3634 xev.xclient.type = ClientMessage;
3635 xev.xclient.serial = 0;
3636 xev.xclient.send_event = True;
3637 xev.xclient.window = GDK_WINDOW_XWINDOW (window);
3638 xev.xclient.display = GDK_WINDOW_XDISPLAY (window);
3639 xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
3641 xev.xclient.format = 32;
3643 xev.xclient.data.l[0] = 0xFFFFFFFF;
3644 xev.xclient.data.l[1] = 0;
3645 xev.xclient.data.l[2] = 0;
3646 xev.xclient.data.l[3] = 0;
3647 xev.xclient.data.l[4] = 0;
3649 XSendEvent (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XROOTWIN (window), False,
3650 SubstructureRedirectMask | SubstructureNotifyMask,
3655 /* Flip our client side flag, the real work happens on map. */
3656 gdk_synthesize_window_state (window,
3658 GDK_WINDOW_STATE_STICKY);
3663 * gdk_window_unstick:
3664 * @window: a toplevel #GdkWindow
3666 * Reverse operation for gdk_window_stick(); see gdk_window_stick(),
3667 * and gtk_window_unstick().
3671 gdk_window_unstick (GdkWindow *window)
3673 g_return_if_fail (GDK_IS_WINDOW (window));
3675 if (GDK_WINDOW_DESTROYED (window))
3678 if (GDK_WINDOW_IS_MAPPED (window))
3685 gulong *current_desktop;
3686 GdkDisplay *display = gdk_drawable_get_display (window);
3688 /* Request unstick from viewport */
3689 gdk_wmspec_change_state (FALSE, window,
3690 gdk_atom_intern ("_NET_WM_STATE_STICKY", FALSE),
3693 /* Get current desktop, then set it; this is a race, but not
3694 * one that matters much in practice.
3696 XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XROOTWIN (window),
3697 gdk_x11_get_xatom_by_name_for_display (display, "_NET_CURRENT_DESKTOP"),
3699 False, XA_CARDINAL, &type, &format, &nitems,
3700 &bytes_after, (guchar **)¤t_desktop);
3702 if (type == XA_CARDINAL)
3704 xev.xclient.type = ClientMessage;
3705 xev.xclient.serial = 0;
3706 xev.xclient.send_event = True;
3707 xev.xclient.window = GDK_WINDOW_XWINDOW (window);
3708 xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP");
3709 xev.xclient.format = 32;
3711 xev.xclient.data.l[0] = *current_desktop;
3712 xev.xclient.data.l[1] = 0;
3713 xev.xclient.data.l[2] = 0;
3714 xev.xclient.data.l[3] = 0;
3715 xev.xclient.data.l[4] = 0;
3717 XSendEvent (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XROOTWIN (window), False,
3718 SubstructureRedirectMask | SubstructureNotifyMask,
3721 XFree (current_desktop);
3726 /* Flip our client side flag, the real work happens on map. */
3727 gdk_synthesize_window_state (window,
3728 GDK_WINDOW_STATE_STICKY,
3735 * gdk_window_maximize:
3736 * @window: a toplevel #GdkWindow
3738 * Maximizes the window. If the window was already maximized, then
3739 * this function does nothing.
3741 * On X11, asks the window manager to maximize @window, if the window
3742 * manager supports this operation. Not all window managers support
3743 * this, and some deliberately ignore it or don't have a concept of
3744 * "maximized"; so you can't rely on the maximization actually
3745 * happening. But it will happen with most standard window managers,
3746 * and GDK makes a best effort to get it to happen.
3748 * On Windows, reliably maximizes the window.
3752 gdk_window_maximize (GdkWindow *window)
3754 g_return_if_fail (GDK_IS_WINDOW (window));
3756 if (GDK_WINDOW_DESTROYED (window))
3759 if (GDK_WINDOW_IS_MAPPED (window))
3760 gdk_wmspec_change_state (TRUE, window,
3761 gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_VERT", FALSE),
3762 gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_HORZ", FALSE));
3764 gdk_synthesize_window_state (window,
3766 GDK_WINDOW_STATE_MAXIMIZED);
3770 * gdk_window_unmaximize:
3771 * @window: a toplevel #GdkWindow
3773 * Unmaximizes the window. If the window wasn't maximized, then this
3774 * function does nothing.
3776 * On X11, asks the window manager to unmaximize @window, if the
3777 * window manager supports this operation. Not all window managers
3778 * support this, and some deliberately ignore it or don't have a
3779 * concept of "maximized"; so you can't rely on the unmaximization
3780 * actually happening. But it will happen with most standard window
3781 * managers, and GDK makes a best effort to get it to happen.
3783 * On Windows, reliably unmaximizes the window.
3787 gdk_window_unmaximize (GdkWindow *window)
3789 g_return_if_fail (GDK_IS_WINDOW (window));
3791 if (GDK_WINDOW_DESTROYED (window))
3794 if (GDK_WINDOW_IS_MAPPED (window))
3795 gdk_wmspec_change_state (FALSE, window,
3796 gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_VERT", FALSE),
3797 gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_HORZ", FALSE));
3799 gdk_synthesize_window_state (window,
3800 GDK_WINDOW_STATE_MAXIMIZED,
3805 * gdk_window_fullscreen:
3806 * @window: a toplevel #GdkWindow
3808 * Moves the window into fullscreen mode. This means the
3809 * window covers the entire screen and is above any panels
3812 * If the window was already fullscreen, then this function does nothing.
3814 * On X11, asks the window manager to put @window in a fullscreen
3815 * state, if the window manager supports this operation. Not all
3816 * window managers support this, and some deliberately ignore it or
3817 * don't have a concept of "fullscreen"; so you can't rely on the
3818 * fullscreenification actually happening. But it will happen with
3819 * most standard window managers, and GDK makes a best effort to get
3825 gdk_window_fullscreen (GdkWindow *window)
3827 g_return_if_fail (GDK_IS_WINDOW (window));
3829 if (GDK_WINDOW_DESTROYED (window))
3832 if (GDK_WINDOW_IS_MAPPED (window))
3833 gdk_wmspec_change_state (TRUE, window,
3834 gdk_atom_intern ("_NET_WM_STATE_FULLSCREEN", FALSE),
3838 gdk_synthesize_window_state (window,
3840 GDK_WINDOW_STATE_FULLSCREEN);
3844 * gdk_window_unfullscreen:
3845 * @window: a toplevel #GdkWindow
3847 * Moves the window out of fullscreen mode. If the window was not
3848 * fullscreen, does nothing.
3850 * On X11, asks the window manager to move @window out of the fullscreen
3851 * state, if the window manager supports this operation. Not all
3852 * window managers support this, and some deliberately ignore it or
3853 * don't have a concept of "fullscreen"; so you can't rely on the
3854 * unfullscreenification actually happening. But it will happen with
3855 * most standard window managers, and GDK makes a best effort to get
3861 gdk_window_unfullscreen (GdkWindow *window)
3863 g_return_if_fail (GDK_IS_WINDOW (window));
3865 if (GDK_WINDOW_DESTROYED (window))
3868 if (GDK_WINDOW_IS_MAPPED (window))
3869 gdk_wmspec_change_state (FALSE, window,
3870 gdk_atom_intern ("_NET_WM_STATE_FULLSCREEN", FALSE),
3874 gdk_synthesize_window_state (window,
3875 GDK_WINDOW_STATE_FULLSCREEN,
3880 * gdk_window_set_keep_above:
3881 * @window: a toplevel #GdkWindow
3882 * @setting: whether to keep @window above other windows
3884 * Set if @window must be kept above other windows. If the
3885 * window was already above, then this function does nothing.
3887 * On X11, asks the window manager to keep @window above, if the window
3888 * manager supports this operation. Not all window managers support
3889 * this, and some deliberately ignore it or don't have a concept of
3890 * "keep above"; so you can't rely on the window being kept above.
3891 * But it will happen with most standard window managers,
3892 * and GDK makes a best effort to get it to happen.
3897 gdk_window_set_keep_above (GdkWindow *window, gboolean setting)
3899 g_return_if_fail (GDK_IS_WINDOW (window));
3901 if (GDK_WINDOW_DESTROYED (window))
3904 if (GDK_WINDOW_IS_MAPPED (window))
3905 gdk_wmspec_change_state (setting, window,
3906 gdk_atom_intern ("_NET_WM_STATE_ABOVE", setting),
3907 setting ? gdk_atom_intern ("_NET_WM_STATE_BELOW", FALSE)
3910 gdk_synthesize_window_state (window,
3911 setting ? GDK_WINDOW_STATE_BELOW : GDK_WINDOW_STATE_ABOVE,
3912 setting ? GDK_WINDOW_STATE_ABOVE : 0);
3916 * gdk_window_set_keep_below:
3917 * @window: a toplevel #GdkWindow
3918 * @setting: whether to keep @window below other windows
3920 * Set if @window must be kept below other windows. If the
3921 * window was already below, then this function does nothing.
3923 * On X11, asks the window manager to keep @window below, if the window
3924 * manager supports this operation. Not all window managers support
3925 * this, and some deliberately ignore it or don't have a concept of
3926 * "keep below"; so you can't rely on the window being kept below.
3927 * But it will happen with most standard window managers,
3928 * and GDK makes a best effort to get it to happen.
3933 gdk_window_set_keep_below (GdkWindow *window, gboolean setting)
3935 g_return_if_fail (GDK_IS_WINDOW (window));
3937 if (GDK_WINDOW_DESTROYED (window))
3940 if (GDK_WINDOW_IS_MAPPED (window))
3941 gdk_wmspec_change_state (setting, window,
3942 gdk_atom_intern ("_NET_WM_STATE_BELOW", setting),
3943 setting ? gdk_atom_intern ("_NET_WM_STATE_ABOVE", FALSE)
3946 gdk_synthesize_window_state (window,
3947 setting ? GDK_WINDOW_STATE_ABOVE : GDK_WINDOW_STATE_BELOW,
3948 setting ? GDK_WINDOW_STATE_BELOW : 0);
3952 * gdk_window_get_group:
3953 * @window: a toplevel #GdkWindow
3955 * Returns the group leader window for @window. See gdk_window_set_group().
3957 * Return value: the group leader window for @window
3962 gdk_window_get_group (GdkWindow *window)
3964 GdkToplevelX11 *toplevel;
3966 g_return_val_if_fail (window != NULL, NULL);
3967 g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
3968 g_return_val_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD, NULL);
3970 if (GDK_WINDOW_DESTROYED (window))
3973 toplevel = _gdk_x11_window_get_toplevel (window);
3975 return toplevel->group_leader;
3979 * gdk_window_set_group:
3980 * @window: a toplevel #GdkWindow
3981 * @leader: group leader window, or %NULL to restore the default group leader window
3983 * Sets the group leader window for @window. By default,
3984 * GDK sets the group leader for all toplevel windows
3985 * to a global window implicitly created by GDK. With this function
3986 * you can override this default.
3988 * The group leader window allows the window manager to distinguish
3989 * all windows that belong to a single application. It may for example
3990 * allow users to minimize/unminimize all windows belonging to an
3991 * application at once. You should only set a non-default group window
3992 * if your application pretends to be multiple applications.
3995 gdk_window_set_group (GdkWindow *window,
3998 GdkToplevelX11 *toplevel;
4000 g_return_if_fail (window != NULL);
4001 g_return_if_fail (GDK_IS_WINDOW (window));
4002 g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD);
4003 g_return_if_fail (leader == NULL || GDK_IS_WINDOW (leader));
4005 if (GDK_WINDOW_DESTROYED (window) || (leader != NULL && GDK_WINDOW_DESTROYED (leader)))
4008 toplevel = _gdk_x11_window_get_toplevel (window);
4011 leader = gdk_display_get_default_group (gdk_drawable_get_display (window));
4013 if (toplevel->group_leader != leader)
4015 if (toplevel->group_leader)
4016 g_object_unref (toplevel->group_leader);
4017 toplevel->group_leader = g_object_ref (leader);
4020 update_wm_hints (window, FALSE);
4023 static MotifWmHints *
4024 gdk_window_get_mwm_hints (GdkWindow *window)
4026 GdkDisplay *display;
4027 Atom hints_atom = None;
4028 MotifWmHints *hints;
4034 if (GDK_WINDOW_DESTROYED (window))
4037 display = gdk_drawable_get_display (window);
4039 hints_atom = gdk_x11_get_xatom_by_name_for_display (display, _XA_MOTIF_WM_HINTS);
4041 XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
4042 hints_atom, 0, sizeof (MotifWmHints)/sizeof (long),
4043 False, AnyPropertyType, &type, &format, &nitems,
4044 &bytes_after, (guchar **)&hints);
4053 gdk_window_set_mwm_hints (GdkWindow *window,
4054 MotifWmHints *new_hints)
4056 GdkDisplay *display;
4057 Atom hints_atom = None;
4058 MotifWmHints *hints;
4064 if (GDK_WINDOW_DESTROYED (window))
4067 display = gdk_drawable_get_display (window);
4069 hints_atom = gdk_x11_get_xatom_by_name_for_display (display, _XA_MOTIF_WM_HINTS);
4071 XGetWindowProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
4072 hints_atom, 0, sizeof (MotifWmHints)/sizeof (long),
4073 False, AnyPropertyType, &type, &format, &nitems,
4074 &bytes_after, (guchar **)&hints);
4080 if (new_hints->flags & MWM_HINTS_FUNCTIONS)
4082 hints->flags |= MWM_HINTS_FUNCTIONS;
4083 hints->functions = new_hints->functions;
4085 if (new_hints->flags & MWM_HINTS_DECORATIONS)
4087 hints->flags |= MWM_HINTS_DECORATIONS;
4088 hints->decorations = new_hints->decorations;
4092 XChangeProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
4093 hints_atom, hints_atom, 32, PropModeReplace,
4094 (guchar *)hints, sizeof (MotifWmHints)/sizeof (long));
4096 if (hints != new_hints)
4101 * gdk_window_set_decorations:
4102 * @window: a toplevel #GdkWindow
4103 * @decorations: decoration hint mask
4105 * "Decorations" are the features the window manager adds to a toplevel #GdkWindow.
4106 * This function sets the traditional Motif window manager hints that tell the
4107 * window manager which decorations you would like your window to have.
4108 * Usually you should use gtk_window_set_decorated() on a #GtkWindow instead of
4109 * using the GDK function directly.
4111 * The @decorations argument is the logical OR of the fields in
4112 * the #GdkWMDecoration enumeration. If #GDK_DECOR_ALL is included in the
4113 * mask, the other bits indicate which decorations should be turned off.
4114 * If #GDK_DECOR_ALL is not included, then the other bits indicate
4115 * which decorations should be turned on.
4117 * Most window managers honor a decorations hint of 0 to disable all decorations,
4118 * but very few honor all possible combinations of bits.
4122 gdk_window_set_decorations (GdkWindow *window,
4123 GdkWMDecoration decorations)
4127 g_return_if_fail (window != NULL);
4128 g_return_if_fail (GDK_IS_WINDOW (window));
4130 hints.flags = MWM_HINTS_DECORATIONS;
4131 hints.decorations = decorations;
4133 gdk_window_set_mwm_hints (window, &hints);
4137 * gdk_window_get_decorations:
4138 * @window: The toplevel #GdkWindow to get the decorations from
4139 * @decorations: The window decorations will be written here
4141 * Returns the decorations set on the GdkWindow with #gdk_window_set_decorations
4142 * Returns: TRUE if the window has decorations set, FALSE otherwise.
4145 gdk_window_get_decorations(GdkWindow *window,
4146 GdkWMDecoration *decorations)
4148 MotifWmHints *hints;
4149 gboolean result = FALSE;
4151 g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
4153 hints = gdk_window_get_mwm_hints (window);
4157 if (hints->flags & MWM_HINTS_DECORATIONS)
4160 *decorations = hints->decorations;
4171 * gdk_window_set_functions:
4172 * @window: a toplevel #GdkWindow
4173 * @functions: bitmask of operations to allow on @window
4175 * This function isn't really good for much. It sets the traditional
4176 * Motif window manager hint for which operations the window manager
4177 * should allow on a toplevel window. However, few window managers do
4178 * anything reliable or interesting with this hint. Many ignore it
4181 * The @functions argument is the logical OR of values from the
4182 * #GdkWMFunction enumeration. If the bitmask includes #GDK_FUNC_ALL,
4183 * then the other bits indicate which functions to disable; if
4184 * it doesn't include #GDK_FUNC_ALL, it indicates which functions to
4189 gdk_window_set_functions (GdkWindow *window,
4190 GdkWMFunction functions)
4194 g_return_if_fail (window != NULL);
4195 g_return_if_fail (GDK_IS_WINDOW (window));
4197 hints.flags = MWM_HINTS_FUNCTIONS;
4198 hints.functions = functions;
4200 gdk_window_set_mwm_hints (window, &hints);
4203 #ifdef HAVE_SHAPE_EXT
4206 * propagate the shapes from all child windows of a GDK window to the parent
4207 * window. Shamelessly ripped from Enlightenment's code
4215 struct _gdk_span *next;
4219 gdk_add_to_span (struct _gdk_span **s,
4223 struct _gdk_span *ptr1, *ptr2, *noo, *ss;
4230 /* scan the spans for this line */
4233 /* -- -> new span */
4234 /* == -> existing span */
4235 /* ## -> spans intersect */
4236 /* if we are in the middle of spanning the span into the line */
4239 /* case: ---- ==== */
4240 if (xx < ptr1->start - 1)
4242 /* ends before next span - extend to here */
4246 /* case: ----##=== */
4247 else if (xx <= ptr1->end)
4249 /* crosses into next span - delete next span and append */
4250 ss->end = ptr1->end;
4251 ss->next = ptr1->next;
4255 /* case: ---###--- */
4258 /* overlaps next span - delete and keep checking */
4259 ss->next = ptr1->next;
4264 /* otherwise havent started spanning it in yet */
4267 /* case: ---- ==== */
4268 if (xx < ptr1->start - 1)
4270 /* insert span here in list */
4271 noo = g_malloc (sizeof (struct _gdk_span));
4285 /* case: ----##=== */
4286 else if ((x < ptr1->start) && (xx <= ptr1->end))
4288 /* expand this span to the left point of the new one */
4292 /* case: ===###=== */
4293 else if ((x >= ptr1->start) && (xx <= ptr1->end))
4295 /* throw the span away */
4298 /* case: ---###--- */
4299 else if ((x < ptr1->start) && (xx > ptr1->end))
4306 /* case: ===##---- */
4307 else if ((x >= ptr1->start) && (x <= ptr1->end + 1) && (xx > ptr1->end))
4313 /* case: ==== ---- */
4314 /* case handled by next loop iteration - first case */
4319 /* it started in the middle but spans beyond your current list */
4325 /* it does not start inside a span or in the middle, so add it to the end */
4326 noo = g_malloc (sizeof (struct _gdk_span));
4334 noo->next = ptr2->next;
4347 gdk_add_rectangles (Display *disp,
4349 struct _gdk_span **spans,
4356 gint x1, y1, x2, y2;
4360 rl = XShapeGetRectangles (disp, win, ShapeBounding, &rn, &ord);
4363 /* go through all clip rects in this window's shape */
4364 for (k = 0; k < rn; k++)
4366 /* for each clip rect, add it to each line's spans */
4368 x2 = x + rl[k].x + (rl[k].width - 1);
4370 y2 = y + rl[k].y + (rl[k].height - 1);
4379 for (a = y1; a <= y2; a++)
4382 gdk_add_to_span (&spans[a], x1, x2);
4390 gdk_propagate_shapes (Display *disp,
4394 Window rt, par, *list = NULL;
4395 gint i, j, num = 0, num_rects = 0;
4399 XRectangle *rects = NULL;
4400 struct _gdk_span **spans = NULL, *ptr1, *ptr2, *ptr3;
4401 XWindowAttributes xatt;
4403 XGetGeometry (disp, win, &rt, &x, &y, &w, &h, &d, &d);
4408 spans = g_malloc (sizeof (struct _gdk_span *) * h);
4410 for (i = 0; i < h; i++)
4412 XQueryTree (disp, win, &rt, &par, &list, (unsigned int *)&num);
4415 /* go through all child windows and create/insert spans */
4416 for (i = 0; i < num; i++)
4418 if (XGetWindowAttributes (disp, list[i], &xatt) && (xatt.map_state != IsUnmapped))
4419 if (XGetGeometry (disp, list[i], &rt, &x, &y, &w, &h, &d, &d))
4420 gdk_add_rectangles (disp, list[i], spans, basew, baseh, x, y);
4423 gdk_add_rectangles (disp, win, spans, basew, baseh, x, y);
4425 /* go through the spans list and build a list of rects */
4426 rects = g_malloc (sizeof (XRectangle) * 256);
4428 for (i = 0; i < baseh; i++)
4431 /* go through the line for all spans */
4434 rects[num_rects].x = ptr1->start;
4435 rects[num_rects].y = i;
4436 rects[num_rects].width = ptr1->end - ptr1->start + 1;
4437 rects[num_rects].height = 1;
4439 /* if there are more lines */
4441 /* while contigous rects (same start/end coords) exist */
4442 while ((contig) && (j < baseh))
4444 /* search next line for spans matching this one */
4450 /* if we have an exact span match set contig */
4451 if ((ptr2->start == ptr1->start) &&
4452 (ptr2->end == ptr1->end))
4455 /* remove the span - not needed */
4458 ptr3->next = ptr2->next;
4464 spans[j] = ptr2->next;
4470 /* gone past the span point no point looking */
4471 else if (ptr2->start < ptr1->start)
4479 /* if a contiguous span was found increase the rect h */
4482 rects[num_rects].height++;
4486 /* up the rect count */
4488 /* every 256 new rects increase the rect array */
4489 if ((num_rects % 256) == 0)
4490 rects = g_realloc (rects, sizeof (XRectangle) * (num_rects + 256));
4494 /* set the rects as the shape mask */
4497 XShapeCombineRectangles (disp, win, ShapeBounding, 0, 0, rects, num_rects,
4498 ShapeSet, YXSorted);
4503 /* free up all the spans we made */
4504 for (i = 0; i < baseh; i++)
4517 #endif /* HAVE_SHAPE_EXT */
4520 * gdk_window_set_child_shapes:
4521 * @window: a #GdkWindow
4523 * Sets the shape mask of @window to the union of shape masks
4524 * for all children of @window, ignoring the shape mask of @window
4525 * itself. Contrast with gdk_window_merge_child_shapes() which includes
4526 * the shape mask of @window in the masks to be merged.
4529 gdk_window_set_child_shapes (GdkWindow *window)
4531 g_return_if_fail (window != NULL);
4532 g_return_if_fail (GDK_IS_WINDOW (window));
4534 #ifdef HAVE_SHAPE_EXT
4535 if (!GDK_WINDOW_DESTROYED (window) &&
4536 gdk_window_have_shape_ext (GDK_WINDOW_DISPLAY (window)))
4537 gdk_propagate_shapes (GDK_WINDOW_XDISPLAY (window),
4538 GDK_WINDOW_XID (window), FALSE);
4543 * gdk_window_merge_child_shapes:
4544 * @window: a #GdkWindow
4546 * Merges the shape masks for any child windows into the
4547 * shape mask for @window. i.e. the union of all masks
4548 * for @window and its children will become the new mask
4549 * for @window. See gdk_window_shape_combine_mask().
4551 * This function is distinct from gdk_window_set_child_shapes()
4552 * because it includes @window's shape mask in the set of shapes to
4557 gdk_window_merge_child_shapes (GdkWindow *window)
4559 g_return_if_fail (window != NULL);
4560 g_return_if_fail (GDK_IS_WINDOW (window));
4562 #ifdef HAVE_SHAPE_EXT
4563 if (!GDK_WINDOW_DESTROYED (window) &&
4564 gdk_window_have_shape_ext (GDK_WINDOW_DISPLAY (window)))
4565 gdk_propagate_shapes (GDK_WINDOW_XDISPLAY (window),
4566 GDK_WINDOW_XID (window), TRUE);
4571 gdk_window_set_static_bit_gravity (GdkWindow *window, gboolean on)
4573 XSetWindowAttributes xattributes;
4574 GdkWindowObject *private;
4575 guint xattributes_mask = 0;
4577 g_return_if_fail (window != NULL);
4579 private = GDK_WINDOW_OBJECT (window);
4580 if (private->input_only)
4583 xattributes.bit_gravity = StaticGravity;
4584 xattributes_mask |= CWBitGravity;
4585 xattributes.bit_gravity = on ? StaticGravity : ForgetGravity;
4586 XChangeWindowAttributes (GDK_WINDOW_XDISPLAY (window),
4587 GDK_WINDOW_XID (window),
4588 CWBitGravity, &xattributes);
4592 gdk_window_set_static_win_gravity (GdkWindow *window, gboolean on)
4594 XSetWindowAttributes xattributes;
4596 g_return_if_fail (window != NULL);
4598 xattributes.win_gravity = on ? StaticGravity : NorthWestGravity;
4600 XChangeWindowAttributes (GDK_WINDOW_XDISPLAY (window),
4601 GDK_WINDOW_XID (window),
4602 CWWinGravity, &xattributes);
4606 * gdk_window_set_static_gravities:
4607 * @window: a #GdkWindow
4608 * @use_static: %TRUE to turn on static gravity
4610 * Set the bit gravity of the given window to static, and flag it so
4611 * all children get static subwindow gravity. This is used if you are
4612 * implementing scary features that involve deep knowledge of the
4613 * windowing system. Don't worry about it unless you have to.
4615 * Return value: %TRUE if the server supports static gravity
4618 gdk_window_set_static_gravities (GdkWindow *window,
4619 gboolean use_static)
4621 GdkWindowObject *private = (GdkWindowObject *)window;
4624 g_return_val_if_fail (window != NULL, FALSE);
4625 g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
4627 if (!use_static == !private->guffaw_gravity)
4630 private->guffaw_gravity = use_static;
4632 if (!GDK_WINDOW_DESTROYED (window))
4634 gdk_window_set_static_bit_gravity (window, use_static);
4636 tmp_list = private->children;
4639 gdk_window_set_static_win_gravity (tmp_list->data, use_static);
4641 tmp_list = tmp_list->next;
4649 wmspec_moveresize (GdkWindow *window,
4655 GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
4659 /* Release passive grab */
4660 gdk_display_pointer_ungrab (display, timestamp);
4662 xev.xclient.type = ClientMessage;
4663 xev.xclient.serial = 0;
4664 xev.xclient.send_event = True;
4665 xev.xclient.window = GDK_WINDOW_XID (window);
4666 xev.xclient.message_type =
4667 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_MOVERESIZE");
4668 xev.xclient.format = 32;
4669 xev.xclient.data.l[0] = root_x;
4670 xev.xclient.data.l[1] = root_y;
4671 xev.xclient.data.l[2] = direction;
4672 xev.xclient.data.l[3] = 0;
4673 xev.xclient.data.l[4] = 0;
4675 XSendEvent (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XROOTWIN (window), False,
4676 SubstructureRedirectMask | SubstructureNotifyMask,
4680 typedef struct _MoveResizeData MoveResizeData;
4682 struct _MoveResizeData
4684 GdkDisplay *display;
4686 GdkWindow *moveresize_window;
4687 GdkWindow *moveresize_emulation_window;
4689 GdkWindowEdge resize_edge;
4690 gint moveresize_button;
4693 gint moveresize_orig_x;
4694 gint moveresize_orig_y;
4695 gint moveresize_orig_width;
4696 gint moveresize_orig_height;
4697 GdkWindowHints moveresize_geom_mask;
4698 GdkGeometry moveresize_geometry;
4699 Time moveresize_process_time;
4700 XEvent *moveresize_pending_event;
4703 /* From the WM spec */
4704 #define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0
4705 #define _NET_WM_MOVERESIZE_SIZE_TOP 1
4706 #define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT 2
4707 #define _NET_WM_MOVERESIZE_SIZE_RIGHT 3
4708 #define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4
4709 #define _NET_WM_MOVERESIZE_SIZE_BOTTOM 5
4710 #define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT 6
4711 #define _NET_WM_MOVERESIZE_SIZE_LEFT 7
4712 #define _NET_WM_MOVERESIZE_MOVE 8
4715 wmspec_resize_drag (GdkWindow *window,
4724 /* Let the compiler turn a switch into a table, instead
4725 * of doing the table manually, this way is easier to verify.
4729 case GDK_WINDOW_EDGE_NORTH_WEST:
4730 direction = _NET_WM_MOVERESIZE_SIZE_TOPLEFT;
4733 case GDK_WINDOW_EDGE_NORTH:
4734 direction = _NET_WM_MOVERESIZE_SIZE_TOP;
4737 case GDK_WINDOW_EDGE_NORTH_EAST:
4738 direction = _NET_WM_MOVERESIZE_SIZE_TOPRIGHT;
4741 case GDK_WINDOW_EDGE_WEST:
4742 direction = _NET_WM_MOVERESIZE_SIZE_LEFT;
4745 case GDK_WINDOW_EDGE_EAST:
4746 direction = _NET_WM_MOVERESIZE_SIZE_RIGHT;
4749 case GDK_WINDOW_EDGE_SOUTH_WEST:
4750 direction = _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT;
4753 case GDK_WINDOW_EDGE_SOUTH:
4754 direction = _NET_WM_MOVERESIZE_SIZE_BOTTOM;
4757 case GDK_WINDOW_EDGE_SOUTH_EAST:
4758 direction = _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT;
4762 g_warning ("gdk_window_begin_resize_drag: bad resize edge %d!",
4768 wmspec_moveresize (window, direction, root_x, root_y, timestamp);
4771 static MoveResizeData *
4772 get_move_resize_data (GdkDisplay *display,
4775 MoveResizeData *mv_resize;
4776 static GQuark move_resize_quark = 0;
4778 if (!move_resize_quark)
4779 move_resize_quark = g_quark_from_static_string ("gdk-window-moveresize");
4781 mv_resize = g_object_get_qdata (G_OBJECT (display), move_resize_quark);
4783 if (!mv_resize && create)
4785 mv_resize = g_new0 (MoveResizeData, 1);
4786 mv_resize->display = display;
4788 g_object_set_qdata (G_OBJECT (display), move_resize_quark, mv_resize);
4795 update_pos (MoveResizeData *mv_resize,
4801 dx = new_root_x - mv_resize->moveresize_x;
4802 dy = new_root_y - mv_resize->moveresize_y;
4804 if (mv_resize->is_resize)
4808 x = mv_resize->moveresize_orig_x;
4809 y = mv_resize->moveresize_orig_y;
4811 w = mv_resize->moveresize_orig_width;
4812 h = mv_resize->moveresize_orig_height;
4814 switch (mv_resize->resize_edge)
4816 case GDK_WINDOW_EDGE_NORTH_WEST:
4822 case GDK_WINDOW_EDGE_NORTH:
4826 case GDK_WINDOW_EDGE_NORTH_EAST:
4831 case GDK_WINDOW_EDGE_SOUTH_WEST:
4836 case GDK_WINDOW_EDGE_SOUTH_EAST:
4840 case GDK_WINDOW_EDGE_SOUTH:
4843 case GDK_WINDOW_EDGE_EAST:
4846 case GDK_WINDOW_EDGE_WEST:
4857 if (mv_resize->moveresize_geom_mask)
4859 gdk_window_constrain_size (&mv_resize->moveresize_geometry,
4860 mv_resize->moveresize_geom_mask,
4864 gdk_window_move_resize (mv_resize->moveresize_window, x, y, w, h);
4870 x = mv_resize->moveresize_orig_x + dx;
4871 y = mv_resize->moveresize_orig_y + dy;
4873 gdk_window_move (mv_resize->moveresize_window, x, y);
4878 finish_drag (MoveResizeData *mv_resize)
4880 gdk_window_destroy (mv_resize->moveresize_emulation_window);
4881 mv_resize->moveresize_emulation_window = NULL;
4882 mv_resize->moveresize_window = NULL;
4884 if (mv_resize->moveresize_pending_event)
4886 g_free (mv_resize->moveresize_pending_event);
4887 mv_resize->moveresize_pending_event = NULL;
4892 lookahead_motion_predicate (Display *xdisplay,
4896 gboolean *seen_release = (gboolean *)arg;
4897 GdkDisplay *display = gdk_x11_lookup_xdisplay (xdisplay);
4898 MoveResizeData *mv_resize = get_move_resize_data (display, FALSE);
4903 switch (event->xany.type)
4906 *seen_release = TRUE;
4909 mv_resize->moveresize_process_time = event->xmotion.time;
4919 moveresize_lookahead (MoveResizeData *mv_resize,
4923 gboolean seen_release = FALSE;
4925 if (mv_resize->moveresize_process_time)
4927 if (event->xmotion.time == mv_resize->moveresize_process_time)
4929 mv_resize->moveresize_process_time = 0;
4936 XCheckIfEvent (event->xany.display, &tmp_event,
4937 lookahead_motion_predicate, (XPointer) & seen_release);
4939 return mv_resize->moveresize_process_time == 0;
4943 _gdk_moveresize_handle_event (XEvent *event)
4945 guint button_mask = 0;
4946 GdkWindowObject *window_private;
4947 GdkDisplay *display = gdk_x11_lookup_xdisplay (event->xany.display);
4948 MoveResizeData *mv_resize = get_move_resize_data (display, FALSE);
4950 if (!mv_resize || !mv_resize->moveresize_window)
4953 window_private = (GdkWindowObject *) mv_resize->moveresize_window;
4955 button_mask = GDK_BUTTON1_MASK << (mv_resize->moveresize_button - 1);
4957 switch (event->xany.type)
4960 if (window_private->resize_count > 0)
4962 if (mv_resize->moveresize_pending_event)
4963 *mv_resize->moveresize_pending_event = *event;
4965 mv_resize->moveresize_pending_event =
4966 g_memdup (event, sizeof (XEvent));
4970 if (!moveresize_lookahead (mv_resize, event))
4973 update_pos (mv_resize,
4974 event->xmotion.x_root,
4975 event->xmotion.y_root);
4977 /* This should never be triggered in normal cases, but in the
4978 * case where the drag started without an implicit grab being
4979 * in effect, we could miss the release if it occurs before
4980 * we grab the pointer; this ensures that we will never
4981 * get a permanently stuck grab.
4983 if ((event->xmotion.state & button_mask) == 0)
4984 finish_drag (mv_resize);
4988 update_pos (mv_resize,
4989 event->xbutton.x_root,
4990 event->xbutton.y_root);
4992 if (event->xbutton.button == mv_resize->moveresize_button)
4993 finish_drag (mv_resize);
5000 _gdk_moveresize_configure_done (GdkDisplay *display,
5004 MoveResizeData *mv_resize = get_move_resize_data (display, FALSE);
5006 if (!mv_resize || window != mv_resize->moveresize_window)
5009 if (mv_resize->moveresize_pending_event)
5011 tmp_event = mv_resize->moveresize_pending_event;
5012 mv_resize->moveresize_pending_event = NULL;
5013 _gdk_moveresize_handle_event (tmp_event);
5021 create_moveresize_window (MoveResizeData *mv_resize,
5024 GdkWindowAttr attributes;
5025 gint attributes_mask;
5026 GdkGrabStatus status;
5028 g_assert (mv_resize->moveresize_emulation_window == NULL);
5030 attributes.x = -100;
5031 attributes.y = -100;
5032 attributes.width = 10;
5033 attributes.height = 10;
5034 attributes.window_type = GDK_WINDOW_TEMP;
5035 attributes.wclass = GDK_INPUT_ONLY;
5036 attributes.override_redirect = TRUE;
5037 attributes.event_mask = 0;
5039 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_NOREDIR;
5041 mv_resize->moveresize_emulation_window =
5042 gdk_window_new (gdk_screen_get_root_window (gdk_display_get_default_screen (mv_resize->display)),
5046 gdk_window_show (mv_resize->moveresize_emulation_window);
5048 status = gdk_pointer_grab (mv_resize->moveresize_emulation_window,
5050 GDK_BUTTON_RELEASE_MASK |
5051 GDK_POINTER_MOTION_MASK,
5056 if (status != GDK_GRAB_SUCCESS)
5058 /* If this fails, some other client has grabbed the window
5061 gdk_window_destroy (mv_resize->moveresize_emulation_window);
5062 mv_resize->moveresize_emulation_window = NULL;
5065 mv_resize->moveresize_process_time = 0;
5069 Calculate mv_resize->moveresize_orig_x and mv_resize->moveresize_orig_y
5070 so that calling XMoveWindow with these coordinates will not move the
5072 Note that this depends on the WM to implement ICCCM-compliant reference
5076 calculate_unmoving_origin (MoveResizeData *mv_resize)
5081 if (mv_resize->moveresize_geom_mask & GDK_HINT_WIN_GRAVITY &&
5082 mv_resize->moveresize_geometry.win_gravity == GDK_GRAVITY_STATIC)
5084 gdk_window_get_origin (mv_resize->moveresize_window,
5085 &mv_resize->moveresize_orig_x,
5086 &mv_resize->moveresize_orig_y);
5090 gdk_window_get_frame_extents (mv_resize->moveresize_window, &rect);
5091 gdk_window_get_geometry (mv_resize->moveresize_window,
5092 NULL, NULL, &width, &height, NULL);
5094 switch (mv_resize->moveresize_geometry.win_gravity)
5096 case GDK_GRAVITY_NORTH_WEST:
5097 mv_resize->moveresize_orig_x = rect.x;
5098 mv_resize->moveresize_orig_y = rect.y;
5100 case GDK_GRAVITY_NORTH:
5101 mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2;
5102 mv_resize->moveresize_orig_y = rect.y;
5104 case GDK_GRAVITY_NORTH_EAST:
5105 mv_resize->moveresize_orig_x = rect.x + rect.width - width;
5106 mv_resize->moveresize_orig_y = rect.y;
5108 case GDK_GRAVITY_WEST:
5109 mv_resize->moveresize_orig_x = rect.x;
5110 mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2;
5112 case GDK_GRAVITY_CENTER:
5113 mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2;
5114 mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2;
5116 case GDK_GRAVITY_EAST:
5117 mv_resize->moveresize_orig_x = rect.x + rect.width - width;
5118 mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2;
5120 case GDK_GRAVITY_SOUTH_WEST:
5121 mv_resize->moveresize_orig_x = rect.x;
5122 mv_resize->moveresize_orig_y = rect.y + rect.height - height;
5124 case GDK_GRAVITY_SOUTH:
5125 mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2;
5126 mv_resize->moveresize_orig_y = rect.y + rect.height - height;
5128 case GDK_GRAVITY_SOUTH_EAST:
5129 mv_resize->moveresize_orig_x = rect.x + rect.width - width;
5130 mv_resize->moveresize_orig_y = rect.y + rect.height - height;
5133 mv_resize->moveresize_orig_x = rect.x;
5134 mv_resize->moveresize_orig_y = rect.y;
5141 emulate_resize_drag (GdkWindow *window,
5148 MoveResizeData *mv_resize = get_move_resize_data (GDK_WINDOW_DISPLAY (window), TRUE);
5150 mv_resize->is_resize = TRUE;
5151 mv_resize->moveresize_button = button;
5152 mv_resize->resize_edge = edge;
5153 mv_resize->moveresize_x = root_x;
5154 mv_resize->moveresize_y = root_y;
5155 mv_resize->moveresize_window = g_object_ref (window);
5157 gdk_drawable_get_size (window,
5158 &mv_resize->moveresize_orig_width,
5159 &mv_resize->moveresize_orig_height);
5161 mv_resize->moveresize_geom_mask = 0;
5162 gdk_window_get_geometry_hints (window,
5163 &mv_resize->moveresize_geometry,
5164 &mv_resize->moveresize_geom_mask);
5166 calculate_unmoving_origin (mv_resize);
5168 create_moveresize_window (mv_resize, timestamp);
5172 emulate_move_drag (GdkWindow *window,
5178 MoveResizeData *mv_resize = get_move_resize_data (GDK_WINDOW_DISPLAY (window), TRUE);
5180 mv_resize->is_resize = FALSE;
5181 mv_resize->moveresize_button = button;
5182 mv_resize->moveresize_x = root_x;
5183 mv_resize->moveresize_y = root_y;
5185 mv_resize->moveresize_window = g_object_ref (window);
5187 calculate_unmoving_origin (mv_resize);
5189 create_moveresize_window (mv_resize, timestamp);
5193 * gdk_window_begin_resize_drag:
5194 * @window: a toplevel #GdkWindow
5195 * @edge: the edge or corner from which the drag is started
5196 * @button: the button being used to drag
5197 * @root_x: root window X coordinate of mouse click that began the drag
5198 * @root_y: root window Y coordinate of mouse click that began the drag
5199 * @timestamp: timestamp of mouse click that began the drag (use gdk_event_get_time())
5201 * Begins a window resize operation (for a toplevel window).
5202 * You might use this function to implement a "window resize grip," for
5203 * example; in fact #GtkStatusbar uses it. The function works best
5204 * with window managers that support the Extended Window Manager Hints spec
5205 * (see http://www.freedesktop.org), but has a fallback implementation
5206 * for other window managers.
5210 gdk_window_begin_resize_drag (GdkWindow *window,
5217 g_return_if_fail (GDK_IS_WINDOW (window));
5219 if (GDK_WINDOW_DESTROYED (window))
5222 if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
5223 gdk_atom_intern ("_NET_WM_MOVERESIZE", FALSE)))
5224 wmspec_resize_drag (window, edge, button, root_x, root_y, timestamp);
5226 emulate_resize_drag (window, edge, button, root_x, root_y, timestamp);
5230 * gdk_window_begin_move_drag:
5231 * @window: a toplevel #GdkWindow
5232 * @button: the button being used to drag
5233 * @root_x: root window X coordinate of mouse click that began the drag
5234 * @root_y: root window Y coordinate of mouse click that began the drag
5235 * @timestamp: timestamp of mouse click that began the drag
5237 * Begins a window move operation (for a toplevel window). You might
5238 * use this function to implement a "window move grip," for
5239 * example. The function works best with window managers that support
5240 * the Extended Window Manager Hints spec (see
5241 * http://www.freedesktop.org), but has a fallback implementation for
5242 * other window managers.
5246 gdk_window_begin_move_drag (GdkWindow *window,
5252 g_return_if_fail (GDK_IS_WINDOW (window));
5254 if (GDK_WINDOW_DESTROYED (window))
5257 if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
5258 gdk_atom_intern ("_NET_WM_MOVERESIZE", FALSE)))
5259 wmspec_moveresize (window, _NET_WM_MOVERESIZE_MOVE, root_x, root_y,
5262 emulate_move_drag (window, button, root_x, root_y, timestamp);