1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 1995-2007 Peter Mattis, Spencer Kimball,
3 * Josh MacDonald, Ryan Lortie
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
22 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
23 * file for a list of people on the GTK+ Team. See the ChangeLog
24 * files for a list of changes. These files are distributed with
25 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
30 #include "gdkwindow-x11.h"
33 #include "gdkwindow.h"
34 #include "gdkwindowimpl.h"
36 #include "gdkdisplay-x11.h"
37 #include "gdkprivate-x11.h"
38 #include "gdkinternals.h"
39 #include "gdkdeviceprivate.h"
40 #include "gdkeventsource.h"
45 #include <netinet/in.h>
48 #include <cairo-xlib.h>
53 #include <X11/Xutil.h>
54 #include <X11/Xatom.h>
56 #include <X11/extensions/shape.h>
59 #include <X11/XKBlib.h>
62 #ifdef HAVE_XCOMPOSITE
63 #include <X11/extensions/Xcomposite.h>
67 #include <X11/extensions/Xfixes.h>
71 #include <X11/extensions/Xdamage.h>
74 const int _gdk_event_mask_table[21] =
78 PointerMotionHintMask,
95 SubstructureNotifyMask,
96 ButtonPressMask /* SCROLL; on X mouse wheel events is treated as mouse button 4/5 */
98 const int _gdk_nenvent_masks = sizeof (_gdk_event_mask_table) / sizeof (int);
100 /* Forward declarations */
101 static void gdk_window_set_static_win_gravity (GdkWindow *window,
103 static gboolean gdk_window_icon_name_set (GdkWindow *window);
104 static void set_wm_name (GdkDisplay *display,
107 static void move_to_current_desktop (GdkWindow *window);
108 static void gdk_window_x11_set_background (GdkWindow *window,
109 cairo_pattern_t *pattern);
111 static void gdk_window_impl_x11_finalize (GObject *object);
113 #define WINDOW_IS_TOPLEVEL_OR_FOREIGN(window) \
114 (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \
115 GDK_WINDOW_TYPE (window) != GDK_WINDOW_OFFSCREEN)
117 #define WINDOW_IS_TOPLEVEL(window) \
118 (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \
119 GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN && \
120 GDK_WINDOW_TYPE (window) != GDK_WINDOW_OFFSCREEN)
122 /* Return whether time1 is considered later than time2 as far as xserver
123 * time is concerned. Accounts for wraparound.
125 #define XSERVER_TIME_IS_LATER(time1, time2) \
126 ( (( time1 > time2 ) && ( time1 - time2 < ((guint32)-1)/2 )) || \
127 (( time1 < time2 ) && ( time2 - time1 > ((guint32)-1)/2 )) \
130 G_DEFINE_TYPE (GdkWindowImplX11, gdk_window_impl_x11, GDK_TYPE_WINDOW_IMPL)
133 gdk_window_impl_x11_init (GdkWindowImplX11 *impl)
135 impl->toplevel_window_type = -1;
136 impl->device_cursor = g_hash_table_new_full (NULL, NULL, NULL,
137 (GDestroyNotify) gdk_cursor_unref);
141 _gdk_x11_window_get_toplevel (GdkWindow *window)
143 GdkWindowImplX11 *impl;
145 g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
147 if (!WINDOW_IS_TOPLEVEL (window))
150 impl = GDK_WINDOW_IMPL_X11 (window->impl);
153 impl->toplevel = g_new0 (GdkToplevelX11, 1);
155 return impl->toplevel;
158 static const cairo_user_data_key_t gdk_x11_cairo_key;
161 * _gdk_x11_window_update_size:
162 * @impl: a #GdkWindowImplX11.
164 * Updates the state of the window (in particular the drawable's
165 * cairo surface) when its size has changed.
168 _gdk_x11_window_update_size (GdkWindowImplX11 *impl)
170 if (impl->cairo_surface)
172 cairo_xlib_surface_set_size (impl->cairo_surface,
173 gdk_window_get_width (impl->wrapper),
174 gdk_window_get_height (impl->wrapper));
178 /*****************************************************
179 * X11 specific implementations of generic functions *
180 *****************************************************/
183 gdk_x11_cairo_surface_destroy (void *data)
185 GdkWindowImplX11 *impl = data;
187 impl->cairo_surface = NULL;
190 static cairo_surface_t *
191 gdk_x11_create_cairo_surface (GdkWindowImplX11 *impl,
197 visual = gdk_window_get_visual (impl->wrapper);
198 return cairo_xlib_surface_create (GDK_WINDOW_XDISPLAY (impl->wrapper),
199 GDK_WINDOW_IMPL_X11 (impl)->xid,
200 GDK_VISUAL_XVISUAL (visual),
204 static cairo_surface_t *
205 gdk_x11_ref_cairo_surface (GdkWindow *window)
207 GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
209 if (GDK_WINDOW_DESTROYED (window))
212 if (!impl->cairo_surface)
214 impl->cairo_surface = gdk_x11_create_cairo_surface (impl,
215 gdk_window_get_width (window),
216 gdk_window_get_height (window));
218 if (impl->cairo_surface)
219 cairo_surface_set_user_data (impl->cairo_surface, &gdk_x11_cairo_key,
220 impl, gdk_x11_cairo_surface_destroy);
223 cairo_surface_reference (impl->cairo_surface);
225 return impl->cairo_surface;
229 gdk_window_impl_x11_finalize (GObject *object)
232 GdkWindowImplX11 *impl;
234 g_return_if_fail (GDK_IS_WINDOW_IMPL_X11 (object));
236 impl = GDK_WINDOW_IMPL_X11 (object);
238 wrapper = impl->wrapper;
240 _gdk_xgrab_check_destroy (wrapper);
242 if (!GDK_WINDOW_DESTROYED (wrapper))
244 GdkDisplay *display = GDK_WINDOW_DISPLAY (wrapper);
246 _gdk_xid_table_remove (display, impl->xid);
247 if (impl->toplevel && impl->toplevel->focus_window)
248 _gdk_xid_table_remove (display, impl->toplevel->focus_window);
251 g_free (impl->toplevel);
254 gdk_cursor_unref (impl->cursor);
256 g_hash_table_destroy (impl->device_cursor);
258 G_OBJECT_CLASS (gdk_window_impl_x11_parent_class)->finalize (object);
267 free_pixmap (gpointer datap)
269 FreePixmapData *data = datap;
271 if (!gdk_display_is_closed (data->display))
273 XFreePixmap (GDK_DISPLAY_XDISPLAY (data->display),
277 g_object_unref (data->display);
278 g_slice_free (FreePixmapData, data);
282 attach_free_pixmap_handler (cairo_surface_t *surface,
286 static const cairo_user_data_key_t key;
287 FreePixmapData *data;
289 data = g_slice_new (FreePixmapData);
290 data->display = g_object_ref (display);
291 data->pixmap = pixmap;
293 cairo_surface_set_user_data (surface, &key, data, free_pixmap);
296 /* Cairo does not guarantee we get an xlib surface if we call
297 * cairo_surface_create_similar(). In some cases however, we must use a
298 * pixmap or bitmap in the X11 API.
299 * These functions ensure an Xlib surface.
302 _gdk_x11_window_create_bitmap_surface (GdkWindow *window,
306 cairo_surface_t *surface;
309 pixmap = XCreatePixmap (GDK_WINDOW_XDISPLAY (window),
310 GDK_WINDOW_XID (window),
312 surface = cairo_xlib_surface_create_for_bitmap (GDK_WINDOW_XDISPLAY (window),
314 GDK_SCREEN_XSCREEN (GDK_WINDOW_SCREEN (window)),
316 attach_free_pixmap_handler (surface, GDK_WINDOW_DISPLAY (window), pixmap);
321 /* Create a surface backed with a pixmap without alpha on the same screen as window */
322 static cairo_surface_t *
323 gdk_x11_window_create_pixmap_surface (GdkWindow *window,
327 GdkScreen *screen = gdk_window_get_screen (window);
328 GdkVisual *visual = gdk_screen_get_system_visual (screen);
329 cairo_surface_t *surface;
332 pixmap = XCreatePixmap (GDK_WINDOW_XDISPLAY (window),
333 GDK_WINDOW_XID (window),
335 gdk_visual_get_depth (visual));
336 surface = cairo_xlib_surface_create (GDK_WINDOW_XDISPLAY (window),
338 GDK_VISUAL_XVISUAL (visual),
340 attach_free_pixmap_handler (surface, GDK_WINDOW_DISPLAY (window), pixmap);
346 tmp_unset_bg (GdkWindow *window)
348 GdkWindowImplX11 *impl;
350 impl = GDK_WINDOW_IMPL_X11 (window->impl);
354 XSetWindowBackgroundPixmap (GDK_WINDOW_XDISPLAY (window),
355 GDK_WINDOW_XID (window), None);
359 tmp_reset_bg (GdkWindow *window)
361 GdkWindowImplX11 *impl;
363 impl = GDK_WINDOW_IMPL_X11 (window->impl);
367 gdk_window_x11_set_background (window, window->background);
370 /* Unsetting and resetting window backgrounds.
372 * In many cases it is possible to avoid flicker by unsetting the
373 * background of windows. For example if the background of the
374 * parent window is unset when a window is unmapped, a brief flicker
375 * of background painting is avoided.
378 _gdk_x11_window_tmp_unset_bg (GdkWindow *window,
381 g_return_if_fail (GDK_IS_WINDOW (window));
383 if (window->input_only || window->destroyed ||
384 (window->window_type != GDK_WINDOW_ROOT &&
385 !GDK_WINDOW_IS_MAPPED (window)))
388 if (_gdk_window_has_impl (window) &&
389 GDK_WINDOW_IS_X11 (window) &&
390 window->window_type != GDK_WINDOW_ROOT &&
391 window->window_type != GDK_WINDOW_FOREIGN)
392 tmp_unset_bg (window);
398 for (l = window->children; l != NULL; l = l->next)
399 _gdk_x11_window_tmp_unset_bg (l->data, TRUE);
404 _gdk_x11_window_tmp_unset_parent_bg (GdkWindow *window)
406 if (GDK_WINDOW_TYPE (window->parent) == GDK_WINDOW_ROOT)
409 window = _gdk_window_get_impl_window (window->parent);
410 _gdk_x11_window_tmp_unset_bg (window, FALSE);
414 _gdk_x11_window_tmp_reset_bg (GdkWindow *window,
417 g_return_if_fail (GDK_IS_WINDOW (window));
419 if (window->input_only || window->destroyed ||
420 (window->window_type != GDK_WINDOW_ROOT &&
421 !GDK_WINDOW_IS_MAPPED (window)))
425 if (_gdk_window_has_impl (window) &&
426 GDK_WINDOW_IS_X11 (window) &&
427 window->window_type != GDK_WINDOW_ROOT &&
428 window->window_type != GDK_WINDOW_FOREIGN)
429 tmp_reset_bg (window);
435 for (l = window->children; l != NULL; l = l->next)
436 _gdk_x11_window_tmp_reset_bg (l->data, TRUE);
441 _gdk_x11_window_tmp_reset_parent_bg (GdkWindow *window)
443 if (GDK_WINDOW_TYPE (window->parent) == GDK_WINDOW_ROOT)
446 window = _gdk_window_get_impl_window (window->parent);
448 _gdk_x11_window_tmp_reset_bg (window, FALSE);
452 _gdk_windowing_window_init (GdkScreen * screen)
455 GdkWindowImplX11 *impl;
456 GdkScreenX11 *screen_x11;
458 screen_x11 = GDK_SCREEN_X11 (screen);
460 g_assert (screen_x11->root_window == NULL);
462 window = screen_x11->root_window = g_object_new (GDK_TYPE_WINDOW, NULL);
464 window->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_X11, NULL);
465 window->impl_window = window;
466 window->visual = gdk_screen_get_system_visual (screen);
468 impl = GDK_WINDOW_IMPL_X11 (window->impl);
470 impl->xid = screen_x11->xroot_window;
471 impl->wrapper = window;
473 window->window_type = GDK_WINDOW_ROOT;
474 window->depth = DefaultDepthOfScreen (screen_x11->xscreen);
480 window->width = WidthOfScreen (screen_x11->xscreen);
481 window->height = HeightOfScreen (screen_x11->xscreen);
482 window->viewable = TRUE;
484 /* see init_randr_support() in gdkscreen-x11.c */
485 window->event_mask = GDK_STRUCTURE_MASK;
487 _gdk_window_update_size (screen_x11->root_window);
489 _gdk_xid_table_insert (screen_x11->display,
490 &screen_x11->xroot_window,
491 screen_x11->root_window);
495 set_wm_protocols (GdkWindow *window)
497 GdkDisplay *display = gdk_window_get_display (window);
501 protocols[n++] = gdk_x11_get_xatom_by_name_for_display (display, "WM_DELETE_WINDOW");
502 protocols[n++] = gdk_x11_get_xatom_by_name_for_display (display, "WM_TAKE_FOCUS");
503 protocols[n++] = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_PING");
506 if (GDK_DISPLAY_X11 (display)->use_sync)
507 protocols[n++] = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_SYNC_REQUEST");
510 XSetWMProtocols (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window), protocols, n);
514 get_default_title (void)
518 title = g_get_application_name ();
520 title = g_get_prgname ();
528 check_leader_window_title (GdkDisplay *display)
530 GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
532 if (display_x11->leader_window && !display_x11->leader_window_title_set)
534 set_wm_name (display,
535 display_x11->leader_window,
536 get_default_title ());
538 display_x11->leader_window_title_set = TRUE;
543 create_focus_window (GdkDisplay *display,
546 GdkDisplayX11 *display_x11;
547 GdkEventMask event_mask;
551 xdisplay = GDK_DISPLAY_XDISPLAY (display);
552 display_x11 = GDK_DISPLAY_X11 (display);
554 focus_window = XCreateSimpleWindow (xdisplay, parent,
558 /* FIXME: probably better to actually track the requested event mask for the toplevel
560 event_mask = (GDK_KEY_PRESS_MASK |
561 GDK_KEY_RELEASE_MASK |
562 GDK_FOCUS_CHANGE_MASK);
564 gdk_event_source_select_events ((GdkEventSource *) display_x11->event_source,
568 XMapWindow (xdisplay, focus_window);
574 ensure_sync_counter (GdkWindow *window)
577 if (!GDK_WINDOW_DESTROYED (window))
579 GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
580 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
581 GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
583 if (toplevel && impl->use_synchronized_configure &&
584 toplevel->update_counter == None &&
585 GDK_DISPLAY_X11 (display)->use_sync)
587 Display *xdisplay = GDK_DISPLAY_XDISPLAY (display);
591 XSyncIntToValue (&value, 0);
593 toplevel->update_counter = XSyncCreateCounter (xdisplay, value);
595 atom = gdk_x11_get_xatom_by_name_for_display (display,
596 "_NET_WM_SYNC_REQUEST_COUNTER");
598 XChangeProperty (xdisplay, GDK_WINDOW_XID (window),
601 (guchar *)&toplevel->update_counter, 1);
603 XSyncIntToValue (&toplevel->current_counter_value, 0);
610 setup_toplevel_window (GdkWindow *window,
613 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
614 GdkDisplay *display = gdk_window_get_display (window);
615 Display *xdisplay = GDK_WINDOW_XDISPLAY (window);
616 XID xid = GDK_WINDOW_XID (window);
617 GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (GDK_WINDOW_SCREEN (parent));
618 XSizeHints size_hints;
620 Window leader_window;
622 set_wm_protocols (window);
624 if (!window->input_only)
626 /* The focus window is off the visible area, and serves to receive key
627 * press events so they don't get sent to child windows.
629 toplevel->focus_window = create_focus_window (display, xid);
630 _gdk_xid_table_insert (screen_x11->display, &toplevel->focus_window, window);
633 check_leader_window_title (screen_x11->display);
635 /* FIXME: Is there any point in doing this? Do any WM's pay
636 * attention to PSize, and even if they do, is this the
639 size_hints.flags = PSize;
640 size_hints.width = window->width;
641 size_hints.height = window->height;
643 XSetWMNormalHints (xdisplay, xid, &size_hints);
645 /* This will set WM_CLIENT_MACHINE and WM_LOCALE_NAME */
646 XSetWMProperties (xdisplay, xid, NULL, NULL, NULL, 0, NULL, NULL, NULL);
649 XChangeProperty (xdisplay, xid,
650 gdk_x11_get_xatom_by_name_for_display (screen_x11->display, "_NET_WM_PID"),
655 leader_window = GDK_DISPLAY_X11 (screen_x11->display)->leader_window;
658 XChangeProperty (xdisplay, xid,
659 gdk_x11_get_xatom_by_name_for_display (screen_x11->display, "WM_CLIENT_LEADER"),
660 XA_WINDOW, 32, PropModeReplace,
661 (guchar *) &leader_window, 1);
663 if (toplevel->focus_window != None)
664 XChangeProperty (xdisplay, xid,
665 gdk_x11_get_xatom_by_name_for_display (screen_x11->display, "_NET_WM_USER_TIME_WINDOW"),
666 XA_WINDOW, 32, PropModeReplace,
667 (guchar *) &toplevel->focus_window, 1);
669 if (!window->focus_on_map)
670 gdk_x11_window_set_user_time (window, 0);
671 else if (GDK_DISPLAY_X11 (screen_x11->display)->user_time != 0)
672 gdk_x11_window_set_user_time (window, GDK_DISPLAY_X11 (screen_x11->display)->user_time);
674 ensure_sync_counter (window);
678 _gdk_window_impl_new (GdkWindow *window,
679 GdkWindow *real_parent,
681 GdkEventMask event_mask,
682 GdkWindowAttr *attributes,
683 gint attributes_mask)
685 GdkWindowImplX11 *impl;
686 GdkScreenX11 *screen_x11;
687 GdkDisplayX11 *display_x11;
693 XSetWindowAttributes xattributes;
694 long xattributes_mask;
695 XClassHint *class_hint;
700 screen_x11 = GDK_SCREEN_X11 (screen);
701 xparent = GDK_WINDOW_XID (real_parent);
702 display_x11 = GDK_DISPLAY_X11 (GDK_SCREEN_DISPLAY (screen));
704 impl = g_object_new (GDK_TYPE_WINDOW_IMPL_X11, NULL);
705 window->impl = GDK_WINDOW_IMPL (impl);
706 impl->wrapper = GDK_WINDOW (window);
708 xdisplay = screen_x11->xdisplay;
710 xattributes_mask = 0;
712 xvisual = gdk_x11_visual_get_xvisual (window->visual);
714 if (attributes_mask & GDK_WA_NOREDIR)
716 xattributes.override_redirect =
717 (attributes->override_redirect == FALSE)?False:True;
718 xattributes_mask |= CWOverrideRedirect;
721 xattributes.override_redirect = False;
723 impl->override_redirect = xattributes.override_redirect;
725 if (window->parent && window->parent->guffaw_gravity)
727 xattributes.win_gravity = StaticGravity;
728 xattributes_mask |= CWWinGravity;
732 switch (window->window_type)
734 case GDK_WINDOW_TOPLEVEL:
735 case GDK_WINDOW_TEMP:
736 if (GDK_WINDOW_TYPE (window->parent) != GDK_WINDOW_ROOT)
738 /* The common code warns for this case */
739 xparent = GDK_SCREEN_XROOTWIN (screen);
743 if (!window->input_only)
747 xattributes.background_pixel = BlackPixel (xdisplay, screen_x11->screen_num);
749 xattributes.border_pixel = BlackPixel (xdisplay, screen_x11->screen_num);
750 xattributes_mask |= CWBorderPixel | CWBackPixel;
752 if (window->guffaw_gravity)
753 xattributes.bit_gravity = StaticGravity;
755 xattributes.bit_gravity = NorthWestGravity;
757 xattributes_mask |= CWBitGravity;
759 xattributes.colormap = _gdk_visual_get_x11_colormap (window->visual);
760 xattributes_mask |= CWColormap;
762 if (window->window_type == GDK_WINDOW_TEMP)
764 xattributes.save_under = True;
765 xattributes.override_redirect = True;
766 xattributes.cursor = None;
767 xattributes_mask |= CWSaveUnder | CWOverrideRedirect;
769 impl->override_redirect = TRUE;
777 if (window->width > 65535 ||
778 window->height > 65535)
780 g_warning ("Native Windows wider or taller than 65535 pixels are not supported");
782 if (window->width > 65535)
783 window->width = 65535;
784 if (window->height > 65535)
785 window->height = 65535;
788 impl->xid = XCreateWindow (xdisplay, xparent,
789 window->x + window->parent->abs_x,
790 window->y + window->parent->abs_y,
791 window->width, window->height,
792 0, window->depth, class, xvisual,
793 xattributes_mask, &xattributes);
795 g_object_ref (window);
796 _gdk_xid_table_insert (screen_x11->display, &impl->xid, window);
798 switch (GDK_WINDOW_TYPE (window))
800 case GDK_WINDOW_TOPLEVEL:
801 case GDK_WINDOW_TEMP:
802 if (attributes_mask & GDK_WA_TITLE)
803 title = attributes->title;
805 title = get_default_title ();
807 gdk_window_set_title (window, title);
809 if (attributes_mask & GDK_WA_WMCLASS)
811 class_hint = XAllocClassHint ();
812 class_hint->res_name = attributes->wmclass_name;
813 class_hint->res_class = attributes->wmclass_class;
814 XSetClassHint (xdisplay, impl->xid, class_hint);
818 setup_toplevel_window (window, window->parent);
821 case GDK_WINDOW_CHILD:
826 if (attributes_mask & GDK_WA_TYPE_HINT)
827 gdk_window_set_type_hint (window, attributes->type_hint);
829 gdk_event_source_select_events ((GdkEventSource *) display_x11->event_source,
830 GDK_WINDOW_XID (window), event_mask,
831 StructureNotifyMask | PropertyChangeMask);
835 x_event_mask_to_gdk_event_mask (long mask)
837 GdkEventMask event_mask = 0;
840 for (i = 0; i < _gdk_nenvent_masks; i++)
842 if (mask & _gdk_event_mask_table[i])
843 event_mask |= 1 << (i + 1);
850 * gdk_window_foreign_new_for_display:
851 * @display: the #GdkDisplay where the window handle comes from.
852 * @anid: a native window handle.
854 * Wraps a native window in a #GdkWindow.
855 * This may fail if the window has been destroyed. If the window
856 * was already known to GDK, a new reference to the existing
857 * #GdkWindow is returned.
859 * For example in the X backend, a native window handle is an Xlib
862 * Return value: (transfer full): a #GdkWindow wrapper for the native
863 * window, or %NULL if the window has been destroyed. The wrapper
864 * will be newly created, if one doesn't exist already.
869 gdk_window_foreign_new_for_display (GdkDisplay *display,
870 GdkNativeWindow anid)
874 GdkWindowImplX11 *impl;
875 GdkDisplayX11 *display_x11;
876 XWindowAttributes attrs;
878 Window *children = NULL;
882 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
884 display_x11 = GDK_DISPLAY_X11 (display);
886 if ((window = gdk_xid_table_lookup_for_display (display, anid)) != NULL)
887 return g_object_ref (window);
889 gdk_error_trap_push ();
890 result = XGetWindowAttributes (display_x11->xdisplay, anid, &attrs);
891 if (gdk_error_trap_pop () || !result)
894 /* FIXME: This is pretty expensive. Maybe the caller should supply
896 gdk_error_trap_push ();
897 result = XQueryTree (display_x11->xdisplay, anid, &root, &parent, &children, &nchildren);
898 if (gdk_error_trap_pop () || !result)
904 screen = _gdk_x11_display_screen_for_xrootwin (display, root);
906 window = g_object_new (GDK_TYPE_WINDOW, NULL);
908 window->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_X11, NULL);
909 window->impl_window = window;
910 window->visual = gdk_x11_screen_lookup_visual (screen,
911 XVisualIDFromVisual (attrs.visual));
913 impl = GDK_WINDOW_IMPL_X11 (window->impl);
914 impl->wrapper = window;
916 window->parent = gdk_xid_table_lookup_for_display (display, parent);
918 if (!window->parent || GDK_WINDOW_TYPE (window->parent) == GDK_WINDOW_FOREIGN)
919 window->parent = gdk_screen_get_root_window (screen);
921 window->parent->children = g_list_prepend (window->parent->children, window);
927 window->width = attrs.width;
928 window->height = attrs.height;
929 window->window_type = GDK_WINDOW_FOREIGN;
930 window->destroyed = FALSE;
932 window->event_mask = x_event_mask_to_gdk_event_mask (attrs.your_event_mask);
934 if (attrs.map_state == IsUnmapped)
935 window->state = GDK_WINDOW_STATE_WITHDRAWN;
938 window->viewable = TRUE;
940 window->depth = attrs.depth;
942 g_object_ref (window);
943 _gdk_xid_table_insert (display, &GDK_WINDOW_XID (window), window);
945 /* Update the clip region, etc */
946 _gdk_window_update_size (window);
952 * gdk_window_lookup_for_display:
953 * @display: the #GdkDisplay corresponding to the window handle
954 * @anid: a native window handle.
956 * Looks up the #GdkWindow that wraps the given native window handle.
958 * For example in the X backend, a native window handle is an Xlib
961 * Return value: (transfer none): the #GdkWindow wrapper for the native
962 * window, or %NULL if there is none.
967 gdk_window_lookup_for_display (GdkDisplay *display, GdkNativeWindow anid)
969 return (GdkWindow*) gdk_xid_table_lookup_for_display (display, anid);
973 gdk_toplevel_x11_free_contents (GdkDisplay *display,
974 GdkToplevelX11 *toplevel)
976 if (toplevel->icon_pixmap)
978 cairo_surface_destroy (toplevel->icon_pixmap);
979 toplevel->icon_pixmap = NULL;
981 if (toplevel->icon_mask)
983 cairo_surface_destroy (toplevel->icon_mask);
984 toplevel->icon_mask = NULL;
986 if (toplevel->group_leader)
988 g_object_unref (toplevel->group_leader);
989 toplevel->group_leader = NULL;
992 if (toplevel->update_counter != None)
994 XSyncDestroyCounter (GDK_DISPLAY_XDISPLAY (display),
995 toplevel->update_counter);
996 toplevel->update_counter = None;
998 XSyncIntToValue (&toplevel->current_counter_value, 0);
1004 _gdk_x11_window_destroy (GdkWindow *window,
1006 gboolean foreign_destroy)
1008 GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
1009 GdkToplevelX11 *toplevel;
1011 g_return_if_fail (GDK_IS_WINDOW (window));
1013 _gdk_selection_window_destroyed (window);
1015 toplevel = _gdk_x11_window_get_toplevel (window);
1017 gdk_toplevel_x11_free_contents (GDK_WINDOW_DISPLAY (window), toplevel);
1019 if (impl->cairo_surface)
1021 cairo_surface_finish (impl->cairo_surface);
1022 cairo_surface_set_user_data (impl->cairo_surface, &gdk_x11_cairo_key,
1026 if (!recursing && !foreign_destroy)
1028 XDestroyWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
1032 static cairo_surface_t *
1033 gdk_window_x11_resize_cairo_surface (GdkWindow *window,
1034 cairo_surface_t *surface,
1038 cairo_xlib_surface_set_size (surface, width, height);
1044 _gdk_windowing_window_destroy_foreign (GdkWindow *window)
1046 /* It's somebody else's window, but in our hierarchy,
1047 * so reparent it to the root window, and then send
1048 * it a delete event, as if we were a WM
1050 XClientMessageEvent xclient;
1052 gdk_error_trap_push ();
1053 gdk_window_hide (window);
1054 gdk_window_reparent (window, NULL, 0, 0);
1056 memset (&xclient, 0, sizeof (xclient));
1057 xclient.type = ClientMessage;
1058 xclient.window = GDK_WINDOW_XID (window);
1059 xclient.message_type = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
1061 xclient.format = 32;
1062 xclient.data.l[0] = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
1063 "WM_DELETE_WINDOW");
1064 xclient.data.l[1] = CurrentTime;
1065 xclient.data.l[2] = 0;
1066 xclient.data.l[3] = 0;
1067 xclient.data.l[4] = 0;
1069 XSendEvent (GDK_WINDOW_XDISPLAY (window),
1070 GDK_WINDOW_XID (window),
1071 False, 0, (XEvent *)&xclient);
1072 gdk_error_trap_pop_ignored ();
1076 get_root (GdkWindow *window)
1078 GdkScreen *screen = gdk_window_get_screen (window);
1080 return gdk_screen_get_root_window (screen);
1083 /* This function is called when the XWindow is really gone.
1086 gdk_x11_window_destroy_notify (GdkWindow *window)
1088 GdkWindowImplX11 *window_impl;
1090 window_impl = GDK_WINDOW_IMPL_X11 ((window)->impl);
1092 if (!GDK_WINDOW_DESTROYED (window))
1094 if (GDK_WINDOW_TYPE(window) != GDK_WINDOW_FOREIGN)
1095 g_warning ("GdkWindow %#lx unexpectedly destroyed", GDK_WINDOW_XID (window));
1097 _gdk_window_destroy (window, TRUE);
1100 _gdk_xid_table_remove (GDK_WINDOW_DISPLAY (window), GDK_WINDOW_XID (window));
1101 if (window_impl->toplevel && window_impl->toplevel->focus_window)
1102 _gdk_xid_table_remove (GDK_WINDOW_DISPLAY (window), window_impl->toplevel->focus_window);
1104 _gdk_xgrab_check_destroy (window);
1106 g_object_unref (window);
1110 update_wm_hints (GdkWindow *window,
1113 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
1114 GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
1118 !toplevel->is_leader &&
1119 window->state & GDK_WINDOW_STATE_WITHDRAWN)
1122 wm_hints.flags = StateHint | InputHint;
1123 wm_hints.input = window->accept_focus ? True : False;
1124 wm_hints.initial_state = NormalState;
1126 if (window->state & GDK_WINDOW_STATE_ICONIFIED)
1128 wm_hints.flags |= StateHint;
1129 wm_hints.initial_state = IconicState;
1132 if (toplevel->icon_pixmap)
1134 wm_hints.flags |= IconPixmapHint;
1135 wm_hints.icon_pixmap = cairo_xlib_surface_get_drawable (toplevel->icon_pixmap);
1138 if (toplevel->icon_mask)
1140 wm_hints.flags |= IconMaskHint;
1141 wm_hints.icon_mask = cairo_xlib_surface_get_drawable (toplevel->icon_mask);
1144 wm_hints.flags |= WindowGroupHint;
1145 if (toplevel->group_leader && !GDK_WINDOW_DESTROYED (toplevel->group_leader))
1147 wm_hints.flags |= WindowGroupHint;
1148 wm_hints.window_group = GDK_WINDOW_XID (toplevel->group_leader);
1151 wm_hints.window_group = GDK_DISPLAY_X11 (display)->leader_window;
1153 if (toplevel->urgency_hint)
1154 wm_hints.flags |= XUrgencyHint;
1156 XSetWMHints (GDK_WINDOW_XDISPLAY (window),
1157 GDK_WINDOW_XID (window),
1162 set_initial_hints (GdkWindow *window)
1164 GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
1165 Display *xdisplay = GDK_DISPLAY_XDISPLAY (display);
1166 Window xwindow = GDK_WINDOW_XID (window);
1167 GdkToplevelX11 *toplevel;
1171 toplevel = _gdk_x11_window_get_toplevel (window);
1176 update_wm_hints (window, TRUE);
1178 /* We set the spec hints regardless of whether the spec is supported,
1179 * since it can't hurt and it's kind of expensive to check whether
1185 if (window->state & GDK_WINDOW_STATE_MAXIMIZED)
1187 atoms[i] = gdk_x11_get_xatom_by_name_for_display (display,
1188 "_NET_WM_STATE_MAXIMIZED_VERT");
1190 atoms[i] = gdk_x11_get_xatom_by_name_for_display (display,
1191 "_NET_WM_STATE_MAXIMIZED_HORZ");
1193 toplevel->have_maxhorz = toplevel->have_maxvert = TRUE;
1196 if (window->state & GDK_WINDOW_STATE_ABOVE)
1198 atoms[i] = gdk_x11_get_xatom_by_name_for_display (display,
1199 "_NET_WM_STATE_ABOVE");
1203 if (window->state & GDK_WINDOW_STATE_BELOW)
1205 atoms[i] = gdk_x11_get_xatom_by_name_for_display (display,
1206 "_NET_WM_STATE_BELOW");
1210 if (window->state & GDK_WINDOW_STATE_STICKY)
1212 atoms[i] = gdk_x11_get_xatom_by_name_for_display (display,
1213 "_NET_WM_STATE_STICKY");
1215 toplevel->have_sticky = TRUE;
1218 if (window->state & GDK_WINDOW_STATE_FULLSCREEN)
1220 atoms[i] = gdk_x11_get_xatom_by_name_for_display (display,
1221 "_NET_WM_STATE_FULLSCREEN");
1223 toplevel->have_fullscreen = TRUE;
1226 if (window->modal_hint)
1228 atoms[i] = gdk_x11_get_xatom_by_name_for_display (display,
1229 "_NET_WM_STATE_MODAL");
1233 if (toplevel->skip_taskbar_hint)
1235 atoms[i] = gdk_x11_get_xatom_by_name_for_display (display,
1236 "_NET_WM_STATE_SKIP_TASKBAR");
1240 if (toplevel->skip_pager_hint)
1242 atoms[i] = gdk_x11_get_xatom_by_name_for_display (display,
1243 "_NET_WM_STATE_SKIP_PAGER");
1249 XChangeProperty (xdisplay,
1251 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE"),
1252 XA_ATOM, 32, PropModeReplace,
1253 (guchar*) atoms, i);
1257 XDeleteProperty (xdisplay,
1259 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE"));
1262 if (window->state & GDK_WINDOW_STATE_STICKY)
1264 atoms[0] = 0xFFFFFFFF;
1265 XChangeProperty (xdisplay,
1267 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"),
1268 XA_CARDINAL, 32, PropModeReplace,
1269 (guchar*) atoms, 1);
1270 toplevel->on_all_desktops = TRUE;
1274 XDeleteProperty (xdisplay,
1276 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"));
1279 toplevel->map_serial = NextRequest (xdisplay);
1283 gdk_window_x11_show (GdkWindow *window, gboolean already_mapped)
1285 GdkDisplay *display;
1286 GdkDisplayX11 *display_x11;
1287 GdkToplevelX11 *toplevel;
1288 GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
1289 Display *xdisplay = GDK_WINDOW_XDISPLAY (window);
1290 Window xwindow = GDK_WINDOW_XID (window);
1293 if (!already_mapped)
1294 set_initial_hints (window);
1296 if (WINDOW_IS_TOPLEVEL (window))
1298 display = gdk_window_get_display (window);
1299 display_x11 = GDK_DISPLAY_X11 (display);
1300 toplevel = _gdk_x11_window_get_toplevel (window);
1302 if (toplevel->user_time != 0 &&
1303 display_x11->user_time != 0 &&
1304 XSERVER_TIME_IS_LATER (display_x11->user_time, toplevel->user_time))
1305 gdk_x11_window_set_user_time (window, display_x11->user_time);
1308 unset_bg = !window->input_only &&
1309 (window->window_type == GDK_WINDOW_CHILD ||
1310 impl->override_redirect) &&
1311 gdk_window_is_viewable (window);
1314 _gdk_x11_window_tmp_unset_bg (window, TRUE);
1316 XMapWindow (xdisplay, xwindow);
1319 _gdk_x11_window_tmp_reset_bg (window, TRUE);
1323 pre_unmap (GdkWindow *window)
1325 GdkWindow *start_window = NULL;
1327 if (window->input_only)
1330 if (window->window_type == GDK_WINDOW_CHILD)
1331 start_window = _gdk_window_get_impl_window ((GdkWindow *)window->parent);
1332 else if (window->window_type == GDK_WINDOW_TEMP)
1333 start_window = get_root (window);
1336 _gdk_x11_window_tmp_unset_bg (start_window, TRUE);
1340 post_unmap (GdkWindow *window)
1342 GdkWindow *start_window = NULL;
1344 if (window->input_only)
1347 if (window->window_type == GDK_WINDOW_CHILD)
1348 start_window = _gdk_window_get_impl_window ((GdkWindow *)window->parent);
1349 else if (window->window_type == GDK_WINDOW_TEMP)
1350 start_window = get_root (window);
1354 _gdk_x11_window_tmp_reset_bg (start_window, TRUE);
1356 if (window->window_type == GDK_WINDOW_CHILD && window->parent)
1358 GdkRectangle invalid_rect;
1360 gdk_window_get_position (window, &invalid_rect.x, &invalid_rect.y);
1361 invalid_rect.width = gdk_window_get_width (window);
1362 invalid_rect.height = gdk_window_get_height (window);
1363 gdk_window_invalidate_rect ((GdkWindow *)window->parent,
1364 &invalid_rect, TRUE);
1370 gdk_window_x11_hide (GdkWindow *window)
1372 /* We'll get the unmap notify eventually, and handle it then,
1373 * but checking here makes things more consistent if we are
1374 * just doing stuff ourself.
1376 _gdk_xgrab_check_unmap (window,
1377 NextRequest (GDK_WINDOW_XDISPLAY (window)));
1379 /* You can't simply unmap toplevel windows. */
1380 switch (window->window_type)
1382 case GDK_WINDOW_TOPLEVEL:
1383 case GDK_WINDOW_TEMP: /* ? */
1384 gdk_window_withdraw (window);
1387 case GDK_WINDOW_FOREIGN:
1388 case GDK_WINDOW_ROOT:
1389 case GDK_WINDOW_CHILD:
1393 _gdk_window_clear_update_area (window);
1396 XUnmapWindow (GDK_WINDOW_XDISPLAY (window),
1397 GDK_WINDOW_XID (window));
1398 post_unmap (window);
1402 gdk_window_x11_withdraw (GdkWindow *window)
1404 if (!window->destroyed)
1406 if (GDK_WINDOW_IS_MAPPED (window))
1407 gdk_synthesize_window_state (window,
1409 GDK_WINDOW_STATE_WITHDRAWN);
1411 g_assert (!GDK_WINDOW_IS_MAPPED (window));
1415 XWithdrawWindow (GDK_WINDOW_XDISPLAY (window),
1416 GDK_WINDOW_XID (window), 0);
1418 post_unmap (window);
1423 window_x11_move (GdkWindow *window,
1427 GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
1429 if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD)
1431 _gdk_window_move_resize_child (window,
1433 window->width, window->height);
1437 XMoveWindow (GDK_WINDOW_XDISPLAY (window),
1438 GDK_WINDOW_XID (window),
1441 if (impl->override_redirect)
1450 window_x11_resize (GdkWindow *window,
1460 if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD)
1462 _gdk_window_move_resize_child (window,
1463 window->x, window->y,
1468 GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
1470 XResizeWindow (GDK_WINDOW_XDISPLAY (window),
1471 GDK_WINDOW_XID (window),
1474 if (impl->override_redirect)
1476 window->width = width;
1477 window->height = height;
1478 _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl));
1482 if (width != window->width || height != window->height)
1483 window->resize_count += 1;
1487 _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl));
1491 window_x11_move_resize (GdkWindow *window,
1503 if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD)
1505 _gdk_window_move_resize_child (window, x, y, width, height);
1506 _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl));
1510 GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
1512 XMoveResizeWindow (GDK_WINDOW_XDISPLAY (window),
1513 GDK_WINDOW_XID (window),
1514 x, y, width, height);
1516 if (impl->override_redirect)
1521 window->width = width;
1522 window->height = height;
1524 _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl));
1528 if (width != window->width || height != window->height)
1529 window->resize_count += 1;
1535 gdk_window_x11_move_resize (GdkWindow *window,
1542 if (with_move && (width < 0 && height < 0))
1543 window_x11_move (window, x, y);
1547 window_x11_move_resize (window, x, y, width, height);
1549 window_x11_resize (window, width, height);
1554 gdk_window_x11_reparent (GdkWindow *window,
1555 GdkWindow *new_parent,
1559 GdkWindowImplX11 *impl;
1561 impl = GDK_WINDOW_IMPL_X11 (window->impl);
1563 _gdk_x11_window_tmp_unset_bg (window, TRUE);
1564 _gdk_x11_window_tmp_unset_parent_bg (window);
1565 XReparentWindow (GDK_WINDOW_XDISPLAY (window),
1566 GDK_WINDOW_XID (window),
1567 GDK_WINDOW_XID (new_parent),
1568 new_parent->abs_x + x, new_parent->abs_y + y);
1569 _gdk_x11_window_tmp_reset_parent_bg (window);
1570 _gdk_x11_window_tmp_reset_bg (window, TRUE);
1572 if (GDK_WINDOW_TYPE (new_parent) == GDK_WINDOW_FOREIGN)
1573 new_parent = gdk_screen_get_root_window (GDK_WINDOW_SCREEN (window));
1575 window->parent = new_parent;
1577 /* Switch the window type as appropriate */
1579 switch (GDK_WINDOW_TYPE (new_parent))
1581 case GDK_WINDOW_ROOT:
1582 case GDK_WINDOW_FOREIGN:
1583 /* Reparenting to toplevel */
1585 if (!WINDOW_IS_TOPLEVEL (window) &&
1586 GDK_WINDOW_TYPE (new_parent) == GDK_WINDOW_FOREIGN)
1588 /* This is also done in common code at a later stage, but we
1589 need it in setup_toplevel, so do it here too */
1590 if (window->toplevel_window_type != -1)
1591 GDK_WINDOW_TYPE (window) = window->toplevel_window_type;
1592 else if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD)
1593 GDK_WINDOW_TYPE (window) = GDK_WINDOW_TOPLEVEL;
1595 /* Wasn't a toplevel, set up */
1596 setup_toplevel_window (window, new_parent);
1601 case GDK_WINDOW_TOPLEVEL:
1602 case GDK_WINDOW_CHILD:
1603 case GDK_WINDOW_TEMP:
1604 if (WINDOW_IS_TOPLEVEL (window) &&
1607 if (impl->toplevel->focus_window)
1609 XDestroyWindow (GDK_WINDOW_XDISPLAY (window), impl->toplevel->focus_window);
1610 _gdk_xid_table_remove (GDK_WINDOW_DISPLAY (window), impl->toplevel->focus_window);
1613 gdk_toplevel_x11_free_contents (GDK_WINDOW_DISPLAY (window),
1615 g_free (impl->toplevel);
1616 impl->toplevel = NULL;
1624 gdk_window_x11_raise (GdkWindow *window)
1626 XRaiseWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
1630 gdk_window_x11_restack_under (GdkWindow *window,
1631 GList *native_siblings /* in requested order, first is bottom-most */)
1637 n_windows = g_list_length (native_siblings) + 1;
1638 windows = g_new (Window, n_windows);
1640 windows[0] = GDK_WINDOW_XID (window);
1641 /* Reverse order, as input order is bottom-most first */
1643 for (l = native_siblings; l != NULL; l = l->next)
1644 windows[i--] = GDK_WINDOW_XID (l->data);
1646 XRestackWindows (GDK_WINDOW_XDISPLAY (window), windows, n_windows);
1652 gdk_window_x11_restack_toplevel (GdkWindow *window,
1656 XWindowChanges changes;
1658 changes.sibling = GDK_WINDOW_XID (sibling);
1659 changes.stack_mode = above ? Above : Below;
1660 XReconfigureWMWindow (GDK_WINDOW_XDISPLAY (window),
1661 GDK_WINDOW_XID (window),
1662 gdk_screen_get_number (GDK_WINDOW_SCREEN (window)),
1663 CWStackMode | CWSibling, &changes);
1667 gdk_window_x11_lower (GdkWindow *window)
1669 XLowerWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
1673 * gdk_x11_window_move_to_current_desktop:
1674 * @window: a #GdkWindow
1676 * Moves the window to the correct workspace when running under a
1677 * window manager that supports multiple workspaces, as described
1678 * in the <ulink url="http://www.freedesktop.org/Standards/wm-spec">Extended
1679 * Window Manager Hints</ulink>. Will not do anything if the
1680 * window is already on all workspaces.
1685 gdk_x11_window_move_to_current_desktop (GdkWindow *window)
1687 GdkToplevelX11 *toplevel;
1689 g_return_if_fail (GDK_IS_WINDOW (window));
1690 g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD);
1692 toplevel = _gdk_x11_window_get_toplevel (window);
1694 if (toplevel->on_all_desktops)
1697 move_to_current_desktop (window);
1701 move_to_current_desktop (GdkWindow *window)
1703 if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
1704 gdk_atom_intern_static_string ("_NET_WM_DESKTOP")))
1711 gulong *current_desktop;
1712 GdkDisplay *display;
1714 display = gdk_window_get_display (window);
1716 /* Get current desktop, then set it; this is a race, but not
1717 * one that matters much in practice.
1719 XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display),
1720 GDK_WINDOW_XROOTWIN (window),
1721 gdk_x11_get_xatom_by_name_for_display (display, "_NET_CURRENT_DESKTOP"),
1723 False, XA_CARDINAL, &type, &format, &nitems,
1724 &bytes_after, &data);
1726 if (type == XA_CARDINAL)
1728 XClientMessageEvent xclient;
1729 current_desktop = (gulong *)data;
1731 memset (&xclient, 0, sizeof (xclient));
1732 xclient.type = ClientMessage;
1734 xclient.send_event = True;
1735 xclient.window = GDK_WINDOW_XID (window);
1736 xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP");
1737 xclient.format = 32;
1739 xclient.data.l[0] = *current_desktop;
1740 xclient.data.l[1] = 0;
1741 xclient.data.l[2] = 0;
1742 xclient.data.l[3] = 0;
1743 xclient.data.l[4] = 0;
1745 XSendEvent (GDK_DISPLAY_XDISPLAY (display),
1746 GDK_WINDOW_XROOTWIN (window),
1748 SubstructureRedirectMask | SubstructureNotifyMask,
1749 (XEvent *)&xclient);
1751 XFree (current_desktop);
1757 gdk_x11_window_focus (GdkWindow *window,
1760 GdkDisplay *display;
1762 g_return_if_fail (GDK_IS_WINDOW (window));
1764 if (GDK_WINDOW_DESTROYED (window) ||
1765 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
1768 display = GDK_WINDOW_DISPLAY (window);
1770 if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
1771 gdk_atom_intern_static_string ("_NET_ACTIVE_WINDOW")))
1773 XClientMessageEvent xclient;
1775 memset (&xclient, 0, sizeof (xclient));
1776 xclient.type = ClientMessage;
1777 xclient.window = GDK_WINDOW_XID (window);
1778 xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display,
1779 "_NET_ACTIVE_WINDOW");
1780 xclient.format = 32;
1781 xclient.data.l[0] = 1; /* requestor type; we're an app */
1782 xclient.data.l[1] = timestamp;
1783 xclient.data.l[2] = None; /* currently active window */
1784 xclient.data.l[3] = 0;
1785 xclient.data.l[4] = 0;
1787 XSendEvent (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XROOTWIN (window), False,
1788 SubstructureRedirectMask | SubstructureNotifyMask,
1789 (XEvent *)&xclient);
1793 XRaiseWindow (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window));
1795 /* There is no way of knowing reliably whether we are viewable;
1796 * _gdk_x11_set_input_focus_safe() traps errors asynchronously.
1798 _gdk_x11_set_input_focus_safe (display, GDK_WINDOW_XID (window),
1805 gdk_x11_window_set_type_hint (GdkWindow *window,
1806 GdkWindowTypeHint hint)
1808 GdkDisplay *display;
1811 if (GDK_WINDOW_DESTROYED (window) ||
1812 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
1815 display = gdk_window_get_display (window);
1819 case GDK_WINDOW_TYPE_HINT_DIALOG:
1820 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DIALOG");
1822 case GDK_WINDOW_TYPE_HINT_MENU:
1823 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_MENU");
1825 case GDK_WINDOW_TYPE_HINT_TOOLBAR:
1826 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_TOOLBAR");
1828 case GDK_WINDOW_TYPE_HINT_UTILITY:
1829 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_UTILITY");
1831 case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
1832 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_SPLASH");
1834 case GDK_WINDOW_TYPE_HINT_DOCK:
1835 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DOCK");
1837 case GDK_WINDOW_TYPE_HINT_DESKTOP:
1838 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DESKTOP");
1840 case GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU:
1841 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU");
1843 case GDK_WINDOW_TYPE_HINT_POPUP_MENU:
1844 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_POPUP_MENU");
1846 case GDK_WINDOW_TYPE_HINT_TOOLTIP:
1847 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_TOOLTIP");
1849 case GDK_WINDOW_TYPE_HINT_NOTIFICATION:
1850 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_NOTIFICATION");
1852 case GDK_WINDOW_TYPE_HINT_COMBO:
1853 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_COMBO");
1855 case GDK_WINDOW_TYPE_HINT_DND:
1856 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DND");
1859 g_warning ("Unknown hint %d passed to gdk_window_set_type_hint", hint);
1861 case GDK_WINDOW_TYPE_HINT_NORMAL:
1862 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_NORMAL");
1866 XChangeProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
1867 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE"),
1868 XA_ATOM, 32, PropModeReplace,
1869 (guchar *)&atom, 1);
1872 static GdkWindowTypeHint
1873 gdk_x11_window_get_type_hint (GdkWindow *window)
1875 GdkDisplay *display;
1876 GdkWindowTypeHint type;
1879 gulong nitems_return;
1880 gulong bytes_after_return;
1881 guchar *data = NULL;
1883 g_return_val_if_fail (GDK_IS_WINDOW (window), GDK_WINDOW_TYPE_HINT_NORMAL);
1885 if (GDK_WINDOW_DESTROYED (window) ||
1886 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
1887 return GDK_WINDOW_TYPE_HINT_NORMAL;
1889 type = GDK_WINDOW_TYPE_HINT_NORMAL;
1891 display = gdk_window_get_display (window);
1893 if (XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
1894 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE"),
1895 0, G_MAXLONG, False, XA_ATOM, &type_return,
1896 &format_return, &nitems_return, &bytes_after_return,
1899 if ((type_return == XA_ATOM) && (format_return == 32) &&
1900 (data) && (nitems_return == 1))
1902 Atom atom = *(Atom*)data;
1904 if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DIALOG"))
1905 type = GDK_WINDOW_TYPE_HINT_DIALOG;
1906 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_MENU"))
1907 type = GDK_WINDOW_TYPE_HINT_MENU;
1908 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_TOOLBAR"))
1909 type = GDK_WINDOW_TYPE_HINT_TOOLBAR;
1910 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_UTILITY"))
1911 type = GDK_WINDOW_TYPE_HINT_UTILITY;
1912 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_SPLASH"))
1913 type = GDK_WINDOW_TYPE_HINT_SPLASHSCREEN;
1914 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DOCK"))
1915 type = GDK_WINDOW_TYPE_HINT_DOCK;
1916 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DESKTOP"))
1917 type = GDK_WINDOW_TYPE_HINT_DESKTOP;
1918 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU"))
1919 type = GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU;
1920 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_POPUP_MENU"))
1921 type = GDK_WINDOW_TYPE_HINT_POPUP_MENU;
1922 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_TOOLTIP"))
1923 type = GDK_WINDOW_TYPE_HINT_TOOLTIP;
1924 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_NOTIFICATION"))
1925 type = GDK_WINDOW_TYPE_HINT_NOTIFICATION;
1926 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_COMBO"))
1927 type = GDK_WINDOW_TYPE_HINT_COMBO;
1928 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DND"))
1929 type = GDK_WINDOW_TYPE_HINT_DND;
1932 if (type_return != None && data != NULL)
1940 gdk_wmspec_change_state (gboolean add,
1945 GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
1946 XClientMessageEvent xclient;
1948 #define _NET_WM_STATE_REMOVE 0 /* remove/unset property */
1949 #define _NET_WM_STATE_ADD 1 /* add/set property */
1950 #define _NET_WM_STATE_TOGGLE 2 /* toggle property */
1952 memset (&xclient, 0, sizeof (xclient));
1953 xclient.type = ClientMessage;
1954 xclient.window = GDK_WINDOW_XID (window);
1955 xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE");
1956 xclient.format = 32;
1957 xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
1958 xclient.data.l[1] = gdk_x11_atom_to_xatom_for_display (display, state1);
1959 xclient.data.l[2] = gdk_x11_atom_to_xatom_for_display (display, state2);
1960 xclient.data.l[3] = 0;
1961 xclient.data.l[4] = 0;
1963 XSendEvent (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XROOTWIN (window), False,
1964 SubstructureRedirectMask | SubstructureNotifyMask,
1965 (XEvent *)&xclient);
1969 gdk_x11_window_set_modal_hint (GdkWindow *window,
1972 if (GDK_WINDOW_DESTROYED (window) ||
1973 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
1976 window->modal_hint = modal;
1978 if (GDK_WINDOW_IS_MAPPED (window))
1979 gdk_wmspec_change_state (modal, window,
1980 gdk_atom_intern_static_string ("_NET_WM_STATE_MODAL"),
1985 gdk_x11_window_set_skip_taskbar_hint (GdkWindow *window,
1986 gboolean skips_taskbar)
1988 GdkToplevelX11 *toplevel;
1990 g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD);
1992 if (GDK_WINDOW_DESTROYED (window) ||
1993 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
1996 toplevel = _gdk_x11_window_get_toplevel (window);
1997 toplevel->skip_taskbar_hint = skips_taskbar;
1999 if (GDK_WINDOW_IS_MAPPED (window))
2000 gdk_wmspec_change_state (skips_taskbar, window,
2001 gdk_atom_intern_static_string ("_NET_WM_STATE_SKIP_TASKBAR"),
2006 gdk_x11_window_set_skip_pager_hint (GdkWindow *window,
2007 gboolean skips_pager)
2009 GdkToplevelX11 *toplevel;
2011 g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD);
2013 if (GDK_WINDOW_DESTROYED (window) ||
2014 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
2017 toplevel = _gdk_x11_window_get_toplevel (window);
2018 toplevel->skip_pager_hint = skips_pager;
2020 if (GDK_WINDOW_IS_MAPPED (window))
2021 gdk_wmspec_change_state (skips_pager, window,
2022 gdk_atom_intern_static_string ("_NET_WM_STATE_SKIP_PAGER"),
2027 gdk_x11_window_set_urgency_hint (GdkWindow *window,
2030 GdkToplevelX11 *toplevel;
2032 g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD);
2034 if (GDK_WINDOW_DESTROYED (window) ||
2035 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
2038 toplevel = _gdk_x11_window_get_toplevel (window);
2039 toplevel->urgency_hint = urgent;
2041 update_wm_hints (window, FALSE);
2045 gdk_x11_window_set_geometry_hints (GdkWindow *window,
2046 const GdkGeometry *geometry,
2047 GdkWindowHints geom_mask)
2049 XSizeHints size_hints;
2051 if (GDK_WINDOW_DESTROYED (window) ||
2052 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
2055 size_hints.flags = 0;
2057 if (geom_mask & GDK_HINT_POS)
2059 size_hints.flags |= PPosition;
2060 /* We need to initialize the following obsolete fields because KWM
2061 * apparently uses these fields if they are non-zero.
2068 if (geom_mask & GDK_HINT_USER_POS)
2070 size_hints.flags |= USPosition;
2073 if (geom_mask & GDK_HINT_USER_SIZE)
2075 size_hints.flags |= USSize;
2078 if (geom_mask & GDK_HINT_MIN_SIZE)
2080 size_hints.flags |= PMinSize;
2081 size_hints.min_width = geometry->min_width;
2082 size_hints.min_height = geometry->min_height;
2085 if (geom_mask & GDK_HINT_MAX_SIZE)
2087 size_hints.flags |= PMaxSize;
2088 size_hints.max_width = MAX (geometry->max_width, 1);
2089 size_hints.max_height = MAX (geometry->max_height, 1);
2092 if (geom_mask & GDK_HINT_BASE_SIZE)
2094 size_hints.flags |= PBaseSize;
2095 size_hints.base_width = geometry->base_width;
2096 size_hints.base_height = geometry->base_height;
2099 if (geom_mask & GDK_HINT_RESIZE_INC)
2101 size_hints.flags |= PResizeInc;
2102 size_hints.width_inc = geometry->width_inc;
2103 size_hints.height_inc = geometry->height_inc;
2106 if (geom_mask & GDK_HINT_ASPECT)
2108 size_hints.flags |= PAspect;
2109 if (geometry->min_aspect <= 1)
2111 size_hints.min_aspect.x = 65536 * geometry->min_aspect;
2112 size_hints.min_aspect.y = 65536;
2116 size_hints.min_aspect.x = 65536;
2117 size_hints.min_aspect.y = 65536 / geometry->min_aspect;;
2119 if (geometry->max_aspect <= 1)
2121 size_hints.max_aspect.x = 65536 * geometry->max_aspect;
2122 size_hints.max_aspect.y = 65536;
2126 size_hints.max_aspect.x = 65536;
2127 size_hints.max_aspect.y = 65536 / geometry->max_aspect;;
2131 if (geom_mask & GDK_HINT_WIN_GRAVITY)
2133 size_hints.flags |= PWinGravity;
2134 size_hints.win_gravity = geometry->win_gravity;
2137 /* FIXME: Would it be better to delete this property if
2138 * geom_mask == 0? It would save space on the server
2140 XSetWMNormalHints (GDK_WINDOW_XDISPLAY (window),
2141 GDK_WINDOW_XID (window),
2146 gdk_window_get_geometry_hints (GdkWindow *window,
2147 GdkGeometry *geometry,
2148 GdkWindowHints *geom_mask)
2150 XSizeHints *size_hints;
2151 glong junk_supplied_mask = 0;
2153 g_return_if_fail (GDK_IS_WINDOW (window));
2154 g_return_if_fail (geometry != NULL);
2155 g_return_if_fail (geom_mask != NULL);
2159 if (GDK_WINDOW_DESTROYED (window) ||
2160 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
2163 size_hints = XAllocSizeHints ();
2167 if (!XGetWMNormalHints (GDK_WINDOW_XDISPLAY (window),
2168 GDK_WINDOW_XID (window),
2170 &junk_supplied_mask))
2171 size_hints->flags = 0;
2173 if (size_hints->flags & PMinSize)
2175 *geom_mask |= GDK_HINT_MIN_SIZE;
2176 geometry->min_width = size_hints->min_width;
2177 geometry->min_height = size_hints->min_height;
2180 if (size_hints->flags & PMaxSize)
2182 *geom_mask |= GDK_HINT_MAX_SIZE;
2183 geometry->max_width = MAX (size_hints->max_width, 1);
2184 geometry->max_height = MAX (size_hints->max_height, 1);
2187 if (size_hints->flags & PResizeInc)
2189 *geom_mask |= GDK_HINT_RESIZE_INC;
2190 geometry->width_inc = size_hints->width_inc;
2191 geometry->height_inc = size_hints->height_inc;
2194 if (size_hints->flags & PAspect)
2196 *geom_mask |= GDK_HINT_ASPECT;
2198 geometry->min_aspect = (gdouble) size_hints->min_aspect.x / (gdouble) size_hints->min_aspect.y;
2199 geometry->max_aspect = (gdouble) size_hints->max_aspect.x / (gdouble) size_hints->max_aspect.y;
2202 if (size_hints->flags & PWinGravity)
2204 *geom_mask |= GDK_HINT_WIN_GRAVITY;
2205 geometry->win_gravity = size_hints->win_gravity;
2212 utf8_is_latin1 (const gchar *str)
2214 const char *p = str;
2218 gunichar ch = g_utf8_get_char (p);
2223 p = g_utf8_next_char (p);
2229 /* Set the property to @utf8_str as STRING if the @utf8_str is fully
2230 * convertable to STRING, otherwise, set it as compound text
2233 set_text_property (GdkDisplay *display,
2236 const gchar *utf8_str)
2238 gchar *prop_text = NULL;
2242 gboolean is_compound_text;
2244 if (utf8_is_latin1 (utf8_str))
2246 prop_type = XA_STRING;
2247 prop_text = gdk_utf8_to_string_target (utf8_str);
2248 prop_length = prop_text ? strlen (prop_text) : 0;
2250 is_compound_text = FALSE;
2256 gdk_utf8_to_compound_text_for_display (display,
2257 utf8_str, &gdk_type, &prop_format,
2258 (guchar **)&prop_text, &prop_length);
2259 prop_type = gdk_x11_atom_to_xatom_for_display (display, gdk_type);
2260 is_compound_text = TRUE;
2265 XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
2268 prop_type, prop_format,
2269 PropModeReplace, (guchar *)prop_text,
2272 if (is_compound_text)
2273 gdk_free_compound_text ((guchar *)prop_text);
2279 /* Set WM_NAME and _NET_WM_NAME
2282 set_wm_name (GdkDisplay *display,
2286 XChangeProperty (GDK_DISPLAY_XDISPLAY (display), xwindow,
2287 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_NAME"),
2288 gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
2289 PropModeReplace, (guchar *)name, strlen (name));
2291 set_text_property (display, xwindow,
2292 gdk_x11_get_xatom_by_name_for_display (display, "WM_NAME"),
2297 gdk_x11_window_set_title (GdkWindow *window,
2300 GdkDisplay *display;
2304 g_return_if_fail (title != NULL);
2306 if (GDK_WINDOW_DESTROYED (window) ||
2307 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
2310 display = gdk_window_get_display (window);
2311 xdisplay = GDK_DISPLAY_XDISPLAY (display);
2312 xwindow = GDK_WINDOW_XID (window);
2314 set_wm_name (display, xwindow, title);
2316 if (!gdk_window_icon_name_set (window))
2318 XChangeProperty (xdisplay, xwindow,
2319 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON_NAME"),
2320 gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
2321 PropModeReplace, (guchar *)title, strlen (title));
2323 set_text_property (display, xwindow,
2324 gdk_x11_get_xatom_by_name_for_display (display, "WM_ICON_NAME"),
2330 gdk_x11_window_set_role (GdkWindow *window,
2333 GdkDisplay *display;
2335 display = gdk_window_get_display (window);
2337 if (GDK_WINDOW_DESTROYED (window) ||
2338 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
2342 XChangeProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
2343 gdk_x11_get_xatom_by_name_for_display (display, "WM_WINDOW_ROLE"),
2344 XA_STRING, 8, PropModeReplace, (guchar *)role, strlen (role));
2346 XDeleteProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
2347 gdk_x11_get_xatom_by_name_for_display (display, "WM_WINDOW_ROLE"));
2351 gdk_x11_window_set_startup_id (GdkWindow *window,
2352 const gchar *startup_id)
2354 GdkDisplay *display;
2356 g_return_if_fail (GDK_IS_WINDOW (window));
2358 display = gdk_window_get_display (window);
2360 if (GDK_WINDOW_DESTROYED (window) ||
2361 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
2365 XChangeProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
2366 gdk_x11_get_xatom_by_name_for_display (display, "_NET_STARTUP_ID"),
2367 gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
2368 PropModeReplace, (unsigned char *)startup_id, strlen (startup_id));
2370 XDeleteProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
2371 gdk_x11_get_xatom_by_name_for_display (display, "_NET_STARTUP_ID"));
2375 gdk_x11_window_set_transient_for (GdkWindow *window,
2378 if (!GDK_WINDOW_DESTROYED (window) && !GDK_WINDOW_DESTROYED (parent) &&
2379 WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
2380 XSetTransientForHint (GDK_WINDOW_XDISPLAY (window),
2381 GDK_WINDOW_XID (window),
2382 GDK_WINDOW_XID (parent));
2386 gdk_window_x11_set_back_color (GdkWindow *window,
2392 GdkVisual *visual = gdk_window_get_visual (window);
2394 /* I suppose we could handle these, but that'd require fiddling with
2395 * xrender formats... */
2399 switch (visual->type)
2401 case GDK_VISUAL_DIRECT_COLOR:
2402 case GDK_VISUAL_TRUE_COLOR:
2404 /* If bits not used for color are used for something other than padding,
2405 * it's likely alpha, so we set them to 1s.
2407 guint padding, pixel;
2409 /* Shifting by >= width-of-type isn't defined in C */
2410 if (visual->depth >= 32)
2413 padding = ((~(guint32)0)) << visual->depth;
2415 pixel = ~ (visual->red_mask | visual->green_mask | visual->blue_mask | padding);
2417 pixel += (((int) (red * ((1 << visual->red_prec ) - 1))) << visual->red_shift ) +
2418 (((int) (green * ((1 << visual->green_prec) - 1))) << visual->green_shift) +
2419 (((int) (blue * ((1 << visual->blue_prec ) - 1))) << visual->blue_shift );
2421 XSetWindowBackground (GDK_WINDOW_XDISPLAY (window),
2422 GDK_WINDOW_XID (window), pixel);
2426 /* These require fiddling with the colormap, and as they're essentially unused
2427 * we're just gonna skip them for now.
2429 case GDK_VISUAL_PSEUDO_COLOR:
2430 case GDK_VISUAL_GRAYSCALE:
2431 case GDK_VISUAL_STATIC_GRAY:
2432 case GDK_VISUAL_STATIC_COLOR:
2441 matrix_is_identity (cairo_matrix_t *matrix)
2443 return matrix->xx == 1.0 && matrix->yy == 1.0 &&
2444 matrix->yx == 0.0 && matrix->xy == 0.0 &&
2445 matrix->x0 == 0.0 && matrix->y0 == 0.0;
2449 gdk_window_x11_set_background (GdkWindow *window,
2450 cairo_pattern_t *pattern)
2453 cairo_surface_t *surface;
2454 cairo_matrix_t matrix;
2456 if (GDK_WINDOW_DESTROYED (window))
2459 if (pattern == NULL)
2463 /* X throws BadMatch if the parent has a different visual when
2464 * using ParentRelative */
2465 parent = gdk_window_get_parent (window);
2466 if (parent && gdk_window_get_visual (parent) == gdk_window_get_visual (window))
2467 XSetWindowBackgroundPixmap (GDK_WINDOW_XDISPLAY (window),
2468 GDK_WINDOW_XID (window), ParentRelative);
2470 XSetWindowBackgroundPixmap (GDK_WINDOW_XDISPLAY (window),
2471 GDK_WINDOW_XID (window), None);
2475 switch (cairo_pattern_get_type (pattern))
2477 case CAIRO_PATTERN_TYPE_SOLID:
2478 cairo_pattern_get_rgba (pattern, &r, &g, &b, &a);
2479 if (gdk_window_x11_set_back_color (window, r, g, b, a))
2482 case CAIRO_PATTERN_TYPE_SURFACE:
2483 cairo_pattern_get_matrix (pattern, &matrix);
2484 if (cairo_pattern_get_surface (pattern, &surface) == CAIRO_STATUS_SUCCESS &&
2485 matrix_is_identity (&matrix) &&
2486 cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_XLIB &&
2487 cairo_xlib_surface_get_visual (surface) == GDK_VISUAL_XVISUAL (gdk_window_get_visual ((window))) &&
2488 cairo_xlib_surface_get_display (surface) == GDK_WINDOW_XDISPLAY (window))
2492 cairo_surface_get_device_offset (surface, &x, &y);
2493 /* XXX: This still bombs for non-pixmaps, but there's no way to
2494 * detect we're not a pixmap in Cairo... */
2495 if (x == 0.0 && y == 0.0)
2497 XSetWindowBackgroundPixmap (GDK_WINDOW_XDISPLAY (window),
2498 GDK_WINDOW_XID (window),
2499 cairo_xlib_surface_get_drawable (surface));
2504 case CAIRO_PATTERN_TYPE_LINEAR:
2505 case CAIRO_PATTERN_TYPE_RADIAL:
2507 /* fallback: just use black */
2511 XSetWindowBackgroundPixmap (GDK_WINDOW_XDISPLAY (window),
2512 GDK_WINDOW_XID (window), None);
2516 gdk_window_x11_set_device_cursor (GdkWindow *window,
2520 GdkWindowImplX11 *impl;
2522 g_return_if_fail (GDK_IS_WINDOW (window));
2523 g_return_if_fail (GDK_IS_DEVICE (device));
2525 impl = GDK_WINDOW_IMPL_X11 (window->impl);
2528 g_hash_table_remove (impl->device_cursor, device);
2531 _gdk_x11_cursor_update_theme (cursor);
2532 g_hash_table_replace (impl->device_cursor,
2533 device, gdk_cursor_ref (cursor));
2536 if (!GDK_WINDOW_DESTROYED (window))
2537 GDK_DEVICE_GET_CLASS (device)->set_window_cursor (device, window, cursor);
2541 _gdk_x11_window_get_cursor (GdkWindow *window)
2543 GdkWindowImplX11 *impl;
2545 g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
2547 impl = GDK_WINDOW_IMPL_X11 (window->impl);
2549 return impl->cursor;
2553 gdk_window_x11_get_geometry (GdkWindow *window,
2564 guint tborder_width;
2567 if (!GDK_WINDOW_DESTROYED (window))
2569 XGetGeometry (GDK_WINDOW_XDISPLAY (window),
2570 GDK_WINDOW_XID (window),
2571 &root, &tx, &ty, &twidth, &theight, &tborder_width, &tdepth);
2585 gdk_window_x11_get_root_coords (GdkWindow *window,
2596 return_val = XTranslateCoordinates (GDK_WINDOW_XDISPLAY (window),
2597 GDK_WINDOW_XID (window),
2598 GDK_WINDOW_XROOTWIN (window),
2611 gdk_x11_window_get_root_origin (GdkWindow *window,
2617 gdk_window_get_frame_extents (window, &rect);
2627 gdk_x11_window_get_frame_extents (GdkWindow *window,
2630 GdkDisplay *display;
2631 GdkWindowImplX11 *impl;
2642 gulong nitems_return;
2643 gulong bytes_after_return;
2646 guint ww, wh, wb, wd;
2648 gboolean got_frame_extents = FALSE;
2650 g_return_if_fail (rect != NULL);
2657 while (window->parent && (window->parent)->parent)
2658 window = window->parent;
2660 /* Refine our fallback answer a bit using local information */
2661 rect->x = window->x;
2662 rect->y = window->y;
2663 rect->width = window->width;
2664 rect->height = window->height;
2666 impl = GDK_WINDOW_IMPL_X11 (window->impl);
2667 if (GDK_WINDOW_DESTROYED (window) || impl->override_redirect)
2673 gdk_error_trap_push();
2675 display = gdk_window_get_display (window);
2676 xwindow = GDK_WINDOW_XID (window);
2678 /* first try: use _NET_FRAME_EXTENTS */
2679 if (XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), xwindow,
2680 gdk_x11_get_xatom_by_name_for_display (display,
2681 "_NET_FRAME_EXTENTS"),
2682 0, G_MAXLONG, False, XA_CARDINAL, &type_return,
2683 &format_return, &nitems_return, &bytes_after_return,
2687 if ((type_return == XA_CARDINAL) && (format_return == 32) &&
2688 (nitems_return == 4) && (data))
2690 gulong *ldata = (gulong *) data;
2691 got_frame_extents = TRUE;
2693 /* try to get the real client window geometry */
2694 if (XGetGeometry (GDK_DISPLAY_XDISPLAY (display), xwindow,
2695 &root, &wx, &wy, &ww, &wh, &wb, &wd) &&
2696 XTranslateCoordinates (GDK_DISPLAY_XDISPLAY (display),
2697 xwindow, root, 0, 0, &wx, &wy, &child))
2705 /* _NET_FRAME_EXTENTS format is left, right, top, bottom */
2706 rect->x -= ldata[0];
2707 rect->y -= ldata[2];
2708 rect->width += ldata[0] + ldata[1];
2709 rect->height += ldata[2] + ldata[3];
2716 if (got_frame_extents)
2719 /* no frame extents property available, which means we either have a WM that
2720 is not EWMH compliant or is broken - try fallback and walk up the window
2721 tree to get our window's parent which hopefully is the window frame */
2723 /* use NETWM_VIRTUAL_ROOTS if available */
2724 root = GDK_WINDOW_XROOTWIN (window);
2726 if (XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), root,
2727 gdk_x11_get_xatom_by_name_for_display (display,
2728 "_NET_VIRTUAL_ROOTS"),
2729 0, G_MAXLONG, False, XA_WINDOW, &type_return,
2730 &format_return, &nitems_return, &bytes_after_return,
2734 if ((type_return == XA_WINDOW) && (format_return == 32) && (data))
2736 nvroots = nitems_return;
2737 vroots = (Window *)data;
2741 xparent = GDK_WINDOW_XID (window);
2747 if (!XQueryTree (GDK_DISPLAY_XDISPLAY (display), xwindow,
2749 &children, &nchildren))
2755 /* check virtual roots */
2756 for (i = 0; i < nvroots; i++)
2758 if (xparent == vroots[i])
2765 while (xparent != root);
2767 if (XGetGeometry (GDK_DISPLAY_XDISPLAY (display), xwindow,
2768 &root, &wx, &wy, &ww, &wh, &wb, &wd))
2780 gdk_error_trap_pop_ignored ();
2784 _gdk_windowing_get_device_state (GdkDisplay *display,
2789 GdkModifierType *mask)
2791 GdkScreen *default_screen;
2793 if (display->closed)
2796 default_screen = gdk_display_get_default_screen (display);
2799 if (G_LIKELY (GDK_DISPLAY_X11 (display)->trusted_client))
2803 GDK_DEVICE_GET_CLASS (device)->query_state (device,
2804 gdk_screen_get_root_window (default_screen),
2809 *screen = gdk_window_get_screen (root);
2813 XSetWindowAttributes attributes;
2815 Window xwindow, w, root, child;
2816 int rootx, rooty, winx, winy;
2819 /* FIXME: untrusted clients not multidevice-safe */
2821 xdisplay = GDK_SCREEN_XDISPLAY (default_screen);
2822 xwindow = GDK_SCREEN_XROOTWIN (default_screen);
2824 w = XCreateWindow (xdisplay, xwindow, 0, 0, 1, 1, 0,
2825 CopyFromParent, InputOnly, CopyFromParent,
2827 XQueryPointer (xdisplay, w,
2828 &root, &child, &rootx, &rooty, &winx, &winy, &xmask);
2829 XDestroyWindow (xdisplay, w);
2833 GdkWindow *gdk_root = gdk_window_lookup_for_display (display, root);
2834 *screen = gdk_window_get_screen (gdk_root);
2844 gdk_window_x11_get_device_state (GdkWindow *window,
2848 GdkModifierType *mask)
2850 GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
2851 gboolean return_val;
2853 g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), FALSE);
2857 if (!GDK_WINDOW_DESTROYED (window))
2859 if (G_LIKELY (GDK_DISPLAY_X11 (display)->trusted_client))
2863 GDK_DEVICE_GET_CLASS (device)->query_state (device, window,
2867 return_val = (child != NULL);
2872 int originx, originy;
2876 unsigned int xmask = 0;
2878 _gdk_windowing_get_device_state (gdk_window_get_display (window), device,
2879 &screen, &rootx, &rooty, &xmask);
2880 gdk_window_get_origin (window, &originx, &originy);
2881 winx = rootx - originx;
2882 winy = rooty - originy;
2894 * gdk_display_warp_pointer:
2895 * @display: a #GdkDisplay
2896 * @screen: the screen of @display to warp the pointer to
2897 * @x: the x coordinate of the destination
2898 * @y: the y coordinate of the destination
2900 * Warps the pointer of @display to the point @x,@y on
2901 * the screen @screen, unless the pointer is confined
2902 * to a window by a grab, in which case it will be moved
2903 * as far as allowed by the grab. Warping the pointer
2904 * creates events as if the user had moved the mouse
2905 * instantaneously to the destination.
2907 * Note that the pointer should normally be under the
2908 * control of the user. This function was added to cover
2909 * some rare use cases like keyboard navigation support
2910 * for the color picker in the #GtkColorSelectionDialog.
2914 * Deprecated: 3.0: Use gdk_display_warp_device() instead.
2917 gdk_display_warp_pointer (GdkDisplay *display,
2924 g_return_if_fail (GDK_IS_DISPLAY (display));
2925 g_return_if_fail (GDK_IS_SCREEN (screen));
2927 device = display->core_pointer;
2928 GDK_DEVICE_GET_CLASS (device)->warp (device, screen, x, y);
2932 * gdk_display_warp_device:
2933 * @display: a #GdkDisplay.
2934 * @device: a #GdkDevice.
2935 * @screen: the screen of @display to warp @device to.
2936 * @x: the X coordinate of the destination.
2937 * @y: the Y coordinate of the destination.
2939 * Warps @device in @display to the point @x,@y on
2940 * the screen @screen, unless the device is confined
2941 * to a window by a grab, in which case it will be moved
2942 * as far as allowed by the grab. Warping the pointer
2943 * creates events as if the user had moved the mouse
2944 * instantaneously to the destination.
2946 * Note that the pointer should normally be under the
2947 * control of the user. This function was added to cover
2948 * some rare use cases like keyboard navigation support
2949 * for the color picker in the #GtkColorSelectionDialog.
2954 gdk_display_warp_device (GdkDisplay *display,
2960 g_return_if_fail (GDK_IS_DISPLAY (display));
2961 g_return_if_fail (GDK_IS_DEVICE (device));
2962 g_return_if_fail (GDK_IS_SCREEN (screen));
2963 g_return_if_fail (display == gdk_device_get_display (device));
2965 GDK_DEVICE_GET_CLASS (device)->warp (device, screen, x, y);
2969 _gdk_windowing_window_at_device_position (GdkDisplay *display,
2973 GdkModifierType *mask,
2974 gboolean get_toplevel)
2979 screen = gdk_display_get_default_screen (display);
2981 /* This function really only works if the mouse pointer is held still
2982 * during its operation. If it moves from one leaf window to another
2983 * than we'll end up with inaccurate values for win_x, win_y
2986 gdk_x11_display_grab (display);
2987 if (G_LIKELY (GDK_DISPLAY_X11 (display)->trusted_client))
2988 window = GDK_DEVICE_GET_CLASS (device)->window_at_position (device, win_x, win_y, mask, get_toplevel);
2991 gint i, screens, width, height;
2992 GList *toplevels, *list;
2993 Window pointer_window, root, xwindow, child;
2994 Window xwindow_last = 0;
2996 int rootx = -1, rooty = -1;
3000 /* FIXME: untrusted clients case not multidevice-safe */
3002 xwindow = GDK_SCREEN_XROOTWIN (screen);
3003 xdisplay = GDK_SCREEN_XDISPLAY (screen);
3005 pointer_window = None;
3006 screens = gdk_display_get_n_screens (display);
3007 for (i = 0; i < screens; ++i) {
3008 screen = gdk_display_get_screen (display, i);
3009 toplevels = gdk_screen_get_toplevel_windows (screen);
3010 for (list = toplevels; list != NULL; list = g_list_next (list)) {
3011 window = GDK_WINDOW (list->data);
3012 xwindow = GDK_WINDOW_XID (window);
3013 gdk_error_trap_push ();
3014 XQueryPointer (xdisplay, xwindow,
3015 &root, &child, &rootx, &rooty, &winx, &winy, &xmask);
3016 if (gdk_error_trap_pop ())
3020 pointer_window = child;
3023 gdk_window_get_geometry (window, NULL, NULL, &width, &height);
3024 if (winx >= 0 && winy >= 0 && winx < width && winy < height)
3026 /* A childless toplevel, or below another window? */
3027 XSetWindowAttributes attributes;
3030 w = XCreateWindow (xdisplay, xwindow, winx, winy, 1, 1, 0,
3031 CopyFromParent, InputOnly, CopyFromParent,
3033 XMapWindow (xdisplay, w);
3034 XQueryPointer (xdisplay, xwindow,
3035 &root, &child, &rootx, &rooty, &winx, &winy, &xmask);
3036 XDestroyWindow (xdisplay, w);
3039 pointer_window = xwindow;
3044 g_list_free (toplevels);
3045 if (pointer_window != None)
3048 xwindow = pointer_window;
3052 xwindow_last = xwindow;
3053 gdk_error_trap_push ();
3054 XQueryPointer (xdisplay, xwindow,
3055 &root, &xwindow, &rootx, &rooty, &winx, &winy, &xmask);
3056 if (gdk_error_trap_pop ())
3058 if (get_toplevel && xwindow_last != root &&
3059 (window = gdk_window_lookup_for_display (display, xwindow_last)) != NULL &&
3060 GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN)
3064 window = gdk_window_lookup_for_display (display, xwindow_last);
3066 *win_x = window ? winx : -1;
3067 *win_y = window ? winy : -1;
3072 gdk_x11_display_ungrab (display);
3078 gdk_window_x11_get_events (GdkWindow *window)
3080 XWindowAttributes attrs;
3081 GdkEventMask event_mask;
3082 GdkEventMask filtered;
3084 if (GDK_WINDOW_DESTROYED (window))
3088 XGetWindowAttributes (GDK_WINDOW_XDISPLAY (window),
3089 GDK_WINDOW_XID (window),
3091 event_mask = x_event_mask_to_gdk_event_mask (attrs.your_event_mask);
3092 /* if property change was filtered out before, keep it filtered out */
3093 filtered = GDK_STRUCTURE_MASK | GDK_PROPERTY_CHANGE_MASK;
3094 window->event_mask = event_mask & ((window->event_mask & filtered) | ~filtered);
3100 gdk_window_x11_set_events (GdkWindow *window,
3101 GdkEventMask event_mask)
3103 long xevent_mask = 0;
3105 if (!GDK_WINDOW_DESTROYED (window))
3107 GdkDisplayX11 *display_x11;
3109 if (GDK_WINDOW_XID (window) != GDK_WINDOW_XROOTWIN (window))
3110 xevent_mask = StructureNotifyMask | PropertyChangeMask;
3112 display_x11 = GDK_DISPLAY_X11 (gdk_window_get_display (window));
3113 gdk_event_source_select_events ((GdkEventSource *) display_x11->event_source,
3114 GDK_WINDOW_XID (window), event_mask,
3120 do_shape_combine_region (GdkWindow *window,
3121 const cairo_region_t *shape_region,
3126 if (GDK_WINDOW_DESTROYED (window))
3129 if (shape_region == NULL)
3131 /* Use NULL mask to unset the shape */
3132 if (shape == ShapeBounding
3133 ? gdk_display_supports_shapes (GDK_WINDOW_DISPLAY (window))
3134 : gdk_display_supports_input_shapes (GDK_WINDOW_DISPLAY (window)))
3136 if (shape == ShapeBounding)
3138 _gdk_x11_window_tmp_unset_parent_bg (window);
3139 _gdk_x11_window_tmp_unset_bg (window, TRUE);
3141 XShapeCombineMask (GDK_WINDOW_XDISPLAY (window),
3142 GDK_WINDOW_XID (window),
3147 if (shape == ShapeBounding)
3149 _gdk_x11_window_tmp_reset_parent_bg (window);
3150 _gdk_x11_window_tmp_reset_bg (window, TRUE);
3156 if (shape == ShapeBounding
3157 ? gdk_display_supports_shapes (GDK_WINDOW_DISPLAY (window))
3158 : gdk_display_supports_input_shapes (GDK_WINDOW_DISPLAY (window)))
3161 XRectangle *xrects = NULL;
3163 _gdk_region_get_xrectangles (shape_region,
3167 if (shape == ShapeBounding)
3169 _gdk_x11_window_tmp_unset_parent_bg (window);
3170 _gdk_x11_window_tmp_unset_bg (window, TRUE);
3172 XShapeCombineRectangles (GDK_WINDOW_XDISPLAY (window),
3173 GDK_WINDOW_XID (window),
3180 if (shape == ShapeBounding)
3182 _gdk_x11_window_tmp_reset_parent_bg (window);
3183 _gdk_x11_window_tmp_reset_bg (window, TRUE);
3191 gdk_window_x11_shape_combine_region (GdkWindow *window,
3192 const cairo_region_t *shape_region,
3196 do_shape_combine_region (window, shape_region, offset_x, offset_y, ShapeBounding);
3200 gdk_window_x11_input_shape_combine_region (GdkWindow *window,
3201 const cairo_region_t *shape_region,
3206 do_shape_combine_region (window, shape_region, offset_x, offset_y, ShapeInput);
3212 gdk_x11_window_set_override_redirect (GdkWindow *window,
3213 gboolean override_redirect)
3215 XSetWindowAttributes attr;
3217 if (!GDK_WINDOW_DESTROYED (window) &&
3218 WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3220 GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
3222 attr.override_redirect = (override_redirect? True : False);
3223 XChangeWindowAttributes (GDK_WINDOW_XDISPLAY (window),
3224 GDK_WINDOW_XID (window),
3228 impl->override_redirect = attr.override_redirect;
3233 gdk_x11_window_set_accept_focus (GdkWindow *window,
3234 gboolean accept_focus)
3236 accept_focus = accept_focus != FALSE;
3238 if (window->accept_focus != accept_focus)
3240 window->accept_focus = accept_focus;
3242 if (!GDK_WINDOW_DESTROYED (window) &&
3243 WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3244 update_wm_hints (window, FALSE);
3249 gdk_x11_window_set_focus_on_map (GdkWindow *window,
3250 gboolean focus_on_map)
3252 focus_on_map = focus_on_map != FALSE;
3254 if (window->focus_on_map != focus_on_map)
3256 window->focus_on_map = focus_on_map;
3258 if ((!GDK_WINDOW_DESTROYED (window)) &&
3259 (!window->focus_on_map) &&
3260 WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3261 gdk_x11_window_set_user_time (window, 0);
3266 * gdk_x11_window_set_user_time:
3267 * @window: A toplevel #GdkWindow
3268 * @timestamp: An XServer timestamp to which the property should be set
3270 * The application can use this call to update the _NET_WM_USER_TIME
3271 * property on a toplevel window. This property stores an Xserver
3272 * time which represents the time of the last user input event
3273 * received for this window. This property may be used by the window
3274 * manager to alter the focus, stacking, and/or placement behavior of
3275 * windows when they are mapped depending on whether the new window
3276 * was created by a user action or is a "pop-up" window activated by a
3277 * timer or some other event.
3279 * Note that this property is automatically updated by GDK, so this
3280 * function should only be used by applications which handle input
3281 * events bypassing GDK.
3286 gdk_x11_window_set_user_time (GdkWindow *window,
3289 GdkDisplay *display;
3290 GdkDisplayX11 *display_x11;
3291 GdkToplevelX11 *toplevel;
3292 glong timestamp_long = (glong)timestamp;
3295 if (GDK_WINDOW_DESTROYED (window) ||
3296 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3299 display = gdk_window_get_display (window);
3300 display_x11 = GDK_DISPLAY_X11 (display);
3301 toplevel = _gdk_x11_window_get_toplevel (window);
3305 g_warning ("gdk_window_set_user_time called on non-toplevel\n");
3309 if (toplevel->focus_window != None &&
3310 gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
3311 gdk_atom_intern_static_string ("_NET_WM_USER_TIME_WINDOW")))
3312 xid = toplevel->focus_window;
3314 xid = GDK_WINDOW_XID (window);
3316 XChangeProperty (GDK_DISPLAY_XDISPLAY (display), xid,
3317 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_USER_TIME"),
3318 XA_CARDINAL, 32, PropModeReplace,
3319 (guchar *)×tamp_long, 1);
3321 if (timestamp_long != GDK_CURRENT_TIME &&
3322 (display_x11->user_time == GDK_CURRENT_TIME ||
3323 XSERVER_TIME_IS_LATER (timestamp_long, display_x11->user_time)))
3324 display_x11->user_time = timestamp_long;
3327 toplevel->user_time = timestamp_long;
3330 #define GDK_SELECTION_MAX_SIZE(display) \
3332 XExtendedMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) == 0 \
3333 ? XMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) - 100 \
3334 : XExtendedMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) - 100)
3337 gdk_window_update_icon (GdkWindow *window,
3340 GdkToplevelX11 *toplevel;
3341 GdkPixbuf *best_icon;
3345 toplevel = _gdk_x11_window_get_toplevel (window);
3347 if (toplevel->icon_pixmap != NULL)
3349 cairo_surface_destroy (toplevel->icon_pixmap);
3350 toplevel->icon_pixmap = NULL;
3353 if (toplevel->icon_mask != NULL)
3355 cairo_surface_destroy (toplevel->icon_mask);
3356 toplevel->icon_mask = NULL;
3359 #define IDEAL_SIZE 48
3361 best_size = G_MAXINT;
3363 for (tmp_list = icon_list; tmp_list; tmp_list = tmp_list->next)
3365 GdkPixbuf *pixbuf = tmp_list->data;
3368 /* average width and height - if someone passes in a rectangular
3369 * icon they deserve what they get.
3371 this = gdk_pixbuf_get_width (pixbuf) + gdk_pixbuf_get_height (pixbuf);
3374 if (best_icon == NULL)
3381 /* icon is better if it's 32 pixels or larger, and closer to
3382 * the ideal size than the current best.
3385 (ABS (best_size - IDEAL_SIZE) <
3386 ABS (this - IDEAL_SIZE)))
3396 int width = gdk_pixbuf_get_width (best_icon);
3397 int height = gdk_pixbuf_get_height (best_icon);
3400 toplevel->icon_pixmap = gdk_x11_window_create_pixmap_surface (window,
3404 cr = cairo_create (toplevel->icon_pixmap);
3405 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
3406 gdk_cairo_set_source_pixbuf (cr, best_icon, 0, 0);
3407 if (gdk_pixbuf_get_has_alpha (best_icon))
3409 /* Saturate the image, so it has bilevel alpha */
3410 cairo_push_group_with_content (cr, CAIRO_CONTENT_COLOR_ALPHA);
3412 cairo_set_operator (cr, CAIRO_OPERATOR_SATURATE);
3414 cairo_pop_group_to_source (cr);
3419 if (gdk_pixbuf_get_has_alpha (best_icon))
3421 toplevel->icon_mask = _gdk_x11_window_create_bitmap_surface (window,
3425 cr = cairo_create (toplevel->icon_mask);
3426 gdk_cairo_set_source_pixbuf (cr, best_icon, 0, 0);
3427 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
3433 update_wm_hints (window, FALSE);
3437 gdk_x11_window_set_icon_list (GdkWindow *window,
3446 gint width, height, stride;
3449 GdkDisplay *display;
3452 if (GDK_WINDOW_DESTROYED (window) ||
3453 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3456 display = gdk_window_get_display (window);
3464 g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
3466 width = gdk_pixbuf_get_width (pixbuf);
3467 height = gdk_pixbuf_get_height (pixbuf);
3469 /* silently ignore overlarge icons */
3470 if (size + 2 + width * height > GDK_SELECTION_MAX_SIZE(display))
3472 g_warning ("gdk_window_set_icon_list: icons too large");
3477 size += 2 + width * height;
3479 l = g_list_next (l);
3482 data = g_malloc (size * sizeof (gulong));
3490 width = gdk_pixbuf_get_width (pixbuf);
3491 height = gdk_pixbuf_get_height (pixbuf);
3492 stride = gdk_pixbuf_get_rowstride (pixbuf);
3493 n_channels = gdk_pixbuf_get_n_channels (pixbuf);
3498 pixels = gdk_pixbuf_get_pixels (pixbuf);
3500 for (y = 0; y < height; y++)
3502 for (x = 0; x < width; x++)
3506 r = pixels[y*stride + x*n_channels + 0];
3507 g = pixels[y*stride + x*n_channels + 1];
3508 b = pixels[y*stride + x*n_channels + 2];
3509 if (n_channels >= 4)
3510 a = pixels[y*stride + x*n_channels + 3];
3514 *p++ = a << 24 | r << 16 | g << 8 | b ;
3518 l = g_list_next (l);
3524 XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
3525 GDK_WINDOW_XID (window),
3526 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON"),
3529 (guchar*) data, size);
3533 XDeleteProperty (GDK_DISPLAY_XDISPLAY (display),
3534 GDK_WINDOW_XID (window),
3535 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON"));
3540 gdk_window_update_icon (window, pixbufs);
3544 gdk_window_icon_name_set (GdkWindow *window)
3546 return GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (window),
3547 g_quark_from_static_string ("gdk-icon-name-set")));
3551 gdk_x11_window_set_icon_name (GdkWindow *window,
3554 GdkDisplay *display;
3556 if (GDK_WINDOW_DESTROYED (window) ||
3557 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3560 display = gdk_window_get_display (window);
3562 g_object_set_qdata (G_OBJECT (window), g_quark_from_static_string ("gdk-icon-name-set"),
3563 GUINT_TO_POINTER (name != NULL));
3567 XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
3568 GDK_WINDOW_XID (window),
3569 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON_NAME"),
3570 gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
3571 PropModeReplace, (guchar *)name, strlen (name));
3573 set_text_property (display, GDK_WINDOW_XID (window),
3574 gdk_x11_get_xatom_by_name_for_display (display, "WM_ICON_NAME"),
3579 XDeleteProperty (GDK_DISPLAY_XDISPLAY (display),
3580 GDK_WINDOW_XID (window),
3581 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON_NAME"));
3582 XDeleteProperty (GDK_DISPLAY_XDISPLAY (display),
3583 GDK_WINDOW_XID (window),
3584 gdk_x11_get_xatom_by_name_for_display (display, "WM_ICON_NAME"));
3589 gdk_x11_window_iconify (GdkWindow *window)
3591 if (GDK_WINDOW_DESTROYED (window) ||
3592 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3595 if (GDK_WINDOW_IS_MAPPED (window))
3597 XIconifyWindow (GDK_WINDOW_XDISPLAY (window),
3598 GDK_WINDOW_XID (window),
3599 gdk_screen_get_number (GDK_WINDOW_SCREEN (window)));
3603 /* Flip our client side flag, the real work happens on map. */
3604 gdk_synthesize_window_state (window,
3606 GDK_WINDOW_STATE_ICONIFIED);
3611 gdk_x11_window_deiconify (GdkWindow *window)
3613 if (GDK_WINDOW_DESTROYED (window) ||
3614 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3617 if (GDK_WINDOW_IS_MAPPED (window))
3619 gdk_window_show (window);
3623 /* Flip our client side flag, the real work happens on map. */
3624 gdk_synthesize_window_state (window,
3625 GDK_WINDOW_STATE_ICONIFIED,
3631 gdk_x11_window_stick (GdkWindow *window)
3633 if (GDK_WINDOW_DESTROYED (window) ||
3634 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3637 if (GDK_WINDOW_IS_MAPPED (window))
3639 /* "stick" means stick to all desktops _and_ do not scroll with the
3640 * viewport. i.e. glue to the monitor glass in all cases.
3643 XClientMessageEvent xclient;
3645 /* Request stick during viewport scroll */
3646 gdk_wmspec_change_state (TRUE, window,
3647 gdk_atom_intern_static_string ("_NET_WM_STATE_STICKY"),
3650 /* Request desktop 0xFFFFFFFF */
3651 memset (&xclient, 0, sizeof (xclient));
3652 xclient.type = ClientMessage;
3653 xclient.window = GDK_WINDOW_XID (window);
3654 xclient.display = GDK_WINDOW_XDISPLAY (window);
3655 xclient.message_type = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
3657 xclient.format = 32;
3659 xclient.data.l[0] = 0xFFFFFFFF;
3660 xclient.data.l[1] = 0;
3661 xclient.data.l[2] = 0;
3662 xclient.data.l[3] = 0;
3663 xclient.data.l[4] = 0;
3665 XSendEvent (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XROOTWIN (window), False,
3666 SubstructureRedirectMask | SubstructureNotifyMask,
3667 (XEvent *)&xclient);
3671 /* Flip our client side flag, the real work happens on map. */
3672 gdk_synthesize_window_state (window,
3674 GDK_WINDOW_STATE_STICKY);
3679 gdk_x11_window_unstick (GdkWindow *window)
3681 if (GDK_WINDOW_DESTROYED (window) ||
3682 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3685 if (GDK_WINDOW_IS_MAPPED (window))
3687 /* Request unstick from viewport */
3688 gdk_wmspec_change_state (FALSE, window,
3689 gdk_atom_intern_static_string ("_NET_WM_STATE_STICKY"),
3692 move_to_current_desktop (window);
3696 /* Flip our client side flag, the real work happens on map. */
3697 gdk_synthesize_window_state (window,
3698 GDK_WINDOW_STATE_STICKY,
3705 gdk_x11_window_maximize (GdkWindow *window)
3707 if (GDK_WINDOW_DESTROYED (window) ||
3708 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3711 if (GDK_WINDOW_IS_MAPPED (window))
3712 gdk_wmspec_change_state (TRUE, window,
3713 gdk_atom_intern_static_string ("_NET_WM_STATE_MAXIMIZED_VERT"),
3714 gdk_atom_intern_static_string ("_NET_WM_STATE_MAXIMIZED_HORZ"));
3716 gdk_synthesize_window_state (window,
3718 GDK_WINDOW_STATE_MAXIMIZED);
3722 gdk_x11_window_unmaximize (GdkWindow *window)
3724 if (GDK_WINDOW_DESTROYED (window) ||
3725 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3728 if (GDK_WINDOW_IS_MAPPED (window))
3729 gdk_wmspec_change_state (FALSE, window,
3730 gdk_atom_intern_static_string ("_NET_WM_STATE_MAXIMIZED_VERT"),
3731 gdk_atom_intern_static_string ("_NET_WM_STATE_MAXIMIZED_HORZ"));
3733 gdk_synthesize_window_state (window,
3734 GDK_WINDOW_STATE_MAXIMIZED,
3739 gdk_x11_window_fullscreen (GdkWindow *window)
3741 if (GDK_WINDOW_DESTROYED (window) ||
3742 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3745 if (GDK_WINDOW_IS_MAPPED (window))
3746 gdk_wmspec_change_state (TRUE, window,
3747 gdk_atom_intern_static_string ("_NET_WM_STATE_FULLSCREEN"),
3751 gdk_synthesize_window_state (window,
3753 GDK_WINDOW_STATE_FULLSCREEN);
3757 gdk_x11_window_unfullscreen (GdkWindow *window)
3759 if (GDK_WINDOW_DESTROYED (window) ||
3760 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3763 if (GDK_WINDOW_IS_MAPPED (window))
3764 gdk_wmspec_change_state (FALSE, window,
3765 gdk_atom_intern_static_string ("_NET_WM_STATE_FULLSCREEN"),
3769 gdk_synthesize_window_state (window,
3770 GDK_WINDOW_STATE_FULLSCREEN,
3775 gdk_x11_window_set_keep_above (GdkWindow *window,
3778 g_return_if_fail (GDK_IS_WINDOW (window));
3780 if (GDK_WINDOW_DESTROYED (window) ||
3781 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3784 if (GDK_WINDOW_IS_MAPPED (window))
3787 gdk_wmspec_change_state (FALSE, window,
3788 gdk_atom_intern_static_string ("_NET_WM_STATE_BELOW"),
3790 gdk_wmspec_change_state (setting, window,
3791 gdk_atom_intern_static_string ("_NET_WM_STATE_ABOVE"),
3795 gdk_synthesize_window_state (window,
3796 setting ? GDK_WINDOW_STATE_BELOW : GDK_WINDOW_STATE_ABOVE,
3797 setting ? GDK_WINDOW_STATE_ABOVE : 0);
3801 gdk_x11_window_set_keep_below (GdkWindow *window, gboolean setting)
3803 g_return_if_fail (GDK_IS_WINDOW (window));
3805 if (GDK_WINDOW_DESTROYED (window) ||
3806 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3809 if (GDK_WINDOW_IS_MAPPED (window))
3812 gdk_wmspec_change_state (FALSE, window,
3813 gdk_atom_intern_static_string ("_NET_WM_STATE_ABOVE"),
3815 gdk_wmspec_change_state (setting, window,
3816 gdk_atom_intern_static_string ("_NET_WM_STATE_BELOW"),
3820 gdk_synthesize_window_state (window,
3821 setting ? GDK_WINDOW_STATE_ABOVE : GDK_WINDOW_STATE_BELOW,
3822 setting ? GDK_WINDOW_STATE_BELOW : 0);
3826 gdk_x11_window_get_group (GdkWindow *window)
3828 GdkToplevelX11 *toplevel;
3830 if (GDK_WINDOW_DESTROYED (window) ||
3831 !WINDOW_IS_TOPLEVEL (window))
3834 toplevel = _gdk_x11_window_get_toplevel (window);
3836 return toplevel->group_leader;
3840 gdk_x11_window_set_group (GdkWindow *window,
3843 GdkToplevelX11 *toplevel;
3845 g_return_if_fail (GDK_IS_WINDOW (window));
3846 g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD);
3847 g_return_if_fail (leader == NULL || GDK_IS_WINDOW (leader));
3849 if (GDK_WINDOW_DESTROYED (window) ||
3850 (leader != NULL && GDK_WINDOW_DESTROYED (leader)) ||
3851 !WINDOW_IS_TOPLEVEL (window))
3854 toplevel = _gdk_x11_window_get_toplevel (window);
3857 leader = gdk_display_get_default_group (gdk_window_get_display (window));
3859 if (toplevel->group_leader != leader)
3861 if (toplevel->group_leader)
3862 g_object_unref (toplevel->group_leader);
3863 toplevel->group_leader = g_object_ref (leader);
3864 (_gdk_x11_window_get_toplevel (leader))->is_leader = TRUE;
3867 update_wm_hints (window, FALSE);
3870 static MotifWmHints *
3871 gdk_window_get_mwm_hints (GdkWindow *window)
3873 GdkDisplay *display;
3874 Atom hints_atom = None;
3881 if (GDK_WINDOW_DESTROYED (window))
3884 display = gdk_window_get_display (window);
3886 hints_atom = gdk_x11_get_xatom_by_name_for_display (display, _XA_MOTIF_WM_HINTS);
3888 XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
3889 hints_atom, 0, sizeof (MotifWmHints)/sizeof (long),
3890 False, AnyPropertyType, &type, &format, &nitems,
3891 &bytes_after, &data);
3896 return (MotifWmHints *)data;
3900 gdk_window_set_mwm_hints (GdkWindow *window,
3901 MotifWmHints *new_hints)
3903 GdkDisplay *display;
3904 Atom hints_atom = None;
3906 MotifWmHints *hints;
3912 if (GDK_WINDOW_DESTROYED (window))
3915 display = gdk_window_get_display (window);
3917 hints_atom = gdk_x11_get_xatom_by_name_for_display (display, _XA_MOTIF_WM_HINTS);
3919 XGetWindowProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
3920 hints_atom, 0, sizeof (MotifWmHints)/sizeof (long),
3921 False, AnyPropertyType, &type, &format, &nitems,
3922 &bytes_after, &data);
3928 hints = (MotifWmHints *)data;
3930 if (new_hints->flags & MWM_HINTS_FUNCTIONS)
3932 hints->flags |= MWM_HINTS_FUNCTIONS;
3933 hints->functions = new_hints->functions;
3935 if (new_hints->flags & MWM_HINTS_DECORATIONS)
3937 hints->flags |= MWM_HINTS_DECORATIONS;
3938 hints->decorations = new_hints->decorations;
3942 XChangeProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
3943 hints_atom, hints_atom, 32, PropModeReplace,
3944 (guchar *)hints, sizeof (MotifWmHints)/sizeof (long));
3946 if (hints != new_hints)
3951 gdk_x11_window_set_decorations (GdkWindow *window,
3952 GdkWMDecoration decorations)
3956 if (GDK_WINDOW_DESTROYED (window) ||
3957 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3960 /* initialize to zero to avoid writing uninitialized data to socket */
3961 memset(&hints, 0, sizeof(hints));
3962 hints.flags = MWM_HINTS_DECORATIONS;
3963 hints.decorations = decorations;
3965 gdk_window_set_mwm_hints (window, &hints);
3969 gdk_x11_window_get_decorations(GdkWindow *window,
3970 GdkWMDecoration *decorations)
3972 MotifWmHints *hints;
3973 gboolean result = FALSE;
3975 if (GDK_WINDOW_DESTROYED (window) ||
3976 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3979 hints = gdk_window_get_mwm_hints (window);
3983 if (hints->flags & MWM_HINTS_DECORATIONS)
3986 *decorations = hints->decorations;
3997 gdk_x11_window_set_functions (GdkWindow *window,
3998 GdkWMFunction functions)
4002 g_return_if_fail (GDK_IS_WINDOW (window));
4004 if (GDK_WINDOW_DESTROYED (window) ||
4005 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
4008 /* initialize to zero to avoid writing uninitialized data to socket */
4009 memset(&hints, 0, sizeof(hints));
4010 hints.flags = MWM_HINTS_FUNCTIONS;
4011 hints.functions = functions;
4013 gdk_window_set_mwm_hints (window, &hints);
4017 _xwindow_get_shape (Display *xdisplay,
4021 cairo_region_t *shape;
4029 xrl = XShapeGetRectangles (xdisplay,
4031 shape_type, &rn, &ord);
4033 if (xrl == NULL || rn == 0)
4034 return cairo_region_create (); /* Empty */
4036 if (ord != YXBanded)
4038 /* This really shouldn't happen with any xserver, as they
4039 generally convert regions to YXBanded internally */
4040 g_warning ("non YXBanded shape masks not supported");
4045 rl = g_new (GdkRectangle, rn);
4046 for (i = 0; i < rn; i++)
4050 rl[i].width = xrl[i].width;
4051 rl[i].height = xrl[i].height;
4055 shape = cairo_region_create_rectangles (rl, rn);
4062 static cairo_region_t *
4063 gdk_x11_window_get_shape (GdkWindow *window)
4065 if (!GDK_WINDOW_DESTROYED (window) &&
4066 gdk_display_supports_shapes (GDK_WINDOW_DISPLAY (window)))
4067 return _xwindow_get_shape (GDK_WINDOW_XDISPLAY (window),
4068 GDK_WINDOW_XID (window), ShapeBounding);
4073 static cairo_region_t *
4074 gdk_x11_window_get_input_shape (GdkWindow *window)
4076 #if defined(ShapeInput)
4077 if (!GDK_WINDOW_DESTROYED (window) &&
4078 gdk_display_supports_shapes (GDK_WINDOW_DISPLAY (window)))
4079 return _xwindow_get_shape (GDK_WINDOW_XDISPLAY (window),
4080 GDK_WINDOW_XID (window),
4088 gdk_window_set_static_bit_gravity (GdkWindow *window,
4091 XSetWindowAttributes xattributes;
4092 guint xattributes_mask = 0;
4094 g_return_if_fail (GDK_IS_WINDOW (window));
4096 if (window->input_only)
4099 xattributes.bit_gravity = StaticGravity;
4100 xattributes_mask |= CWBitGravity;
4101 xattributes.bit_gravity = on ? StaticGravity : ForgetGravity;
4102 XChangeWindowAttributes (GDK_WINDOW_XDISPLAY (window),
4103 GDK_WINDOW_XID (window),
4104 CWBitGravity, &xattributes);
4108 gdk_window_set_static_win_gravity (GdkWindow *window,
4111 XSetWindowAttributes xattributes;
4113 g_return_if_fail (GDK_IS_WINDOW (window));
4115 xattributes.win_gravity = on ? StaticGravity : NorthWestGravity;
4117 XChangeWindowAttributes (GDK_WINDOW_XDISPLAY (window),
4118 GDK_WINDOW_XID (window),
4119 CWWinGravity, &xattributes);
4123 gdk_window_x11_set_static_gravities (GdkWindow *window,
4124 gboolean use_static)
4128 if (!use_static == !window->guffaw_gravity)
4131 window->guffaw_gravity = use_static;
4133 if (!GDK_WINDOW_DESTROYED (window))
4135 gdk_window_set_static_bit_gravity (window, use_static);
4137 tmp_list = window->children;
4140 gdk_window_set_static_win_gravity (tmp_list->data, use_static);
4142 tmp_list = tmp_list->next;
4150 wmspec_moveresize (GdkWindow *window,
4156 GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
4158 XClientMessageEvent xclient;
4160 /* Release passive grab */
4161 gdk_display_pointer_ungrab (display, timestamp);
4163 memset (&xclient, 0, sizeof (xclient));
4164 xclient.type = ClientMessage;
4165 xclient.window = GDK_WINDOW_XID (window);
4166 xclient.message_type =
4167 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_MOVERESIZE");
4168 xclient.format = 32;
4169 xclient.data.l[0] = root_x;
4170 xclient.data.l[1] = root_y;
4171 xclient.data.l[2] = direction;
4172 xclient.data.l[3] = 0;
4173 xclient.data.l[4] = 0;
4175 XSendEvent (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XROOTWIN (window), False,
4176 SubstructureRedirectMask | SubstructureNotifyMask,
4177 (XEvent *)&xclient);
4180 typedef struct _MoveResizeData MoveResizeData;
4182 struct _MoveResizeData
4184 GdkDisplay *display;
4186 GdkWindow *moveresize_window;
4187 GdkWindow *moveresize_emulation_window;
4189 GdkWindowEdge resize_edge;
4190 gint moveresize_button;
4193 gint moveresize_orig_x;
4194 gint moveresize_orig_y;
4195 gint moveresize_orig_width;
4196 gint moveresize_orig_height;
4197 GdkWindowHints moveresize_geom_mask;
4198 GdkGeometry moveresize_geometry;
4199 Time moveresize_process_time;
4200 XEvent *moveresize_pending_event;
4203 /* From the WM spec */
4204 #define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0
4205 #define _NET_WM_MOVERESIZE_SIZE_TOP 1
4206 #define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT 2
4207 #define _NET_WM_MOVERESIZE_SIZE_RIGHT 3
4208 #define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4
4209 #define _NET_WM_MOVERESIZE_SIZE_BOTTOM 5
4210 #define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT 6
4211 #define _NET_WM_MOVERESIZE_SIZE_LEFT 7
4212 #define _NET_WM_MOVERESIZE_MOVE 8
4215 wmspec_resize_drag (GdkWindow *window,
4224 /* Let the compiler turn a switch into a table, instead
4225 * of doing the table manually, this way is easier to verify.
4229 case GDK_WINDOW_EDGE_NORTH_WEST:
4230 direction = _NET_WM_MOVERESIZE_SIZE_TOPLEFT;
4233 case GDK_WINDOW_EDGE_NORTH:
4234 direction = _NET_WM_MOVERESIZE_SIZE_TOP;
4237 case GDK_WINDOW_EDGE_NORTH_EAST:
4238 direction = _NET_WM_MOVERESIZE_SIZE_TOPRIGHT;
4241 case GDK_WINDOW_EDGE_WEST:
4242 direction = _NET_WM_MOVERESIZE_SIZE_LEFT;
4245 case GDK_WINDOW_EDGE_EAST:
4246 direction = _NET_WM_MOVERESIZE_SIZE_RIGHT;
4249 case GDK_WINDOW_EDGE_SOUTH_WEST:
4250 direction = _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT;
4253 case GDK_WINDOW_EDGE_SOUTH:
4254 direction = _NET_WM_MOVERESIZE_SIZE_BOTTOM;
4257 case GDK_WINDOW_EDGE_SOUTH_EAST:
4258 direction = _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT;
4262 g_warning ("gdk_window_begin_resize_drag: bad resize edge %d!",
4267 wmspec_moveresize (window, direction, root_x, root_y, timestamp);
4270 static MoveResizeData *
4271 get_move_resize_data (GdkDisplay *display,
4274 MoveResizeData *mv_resize;
4275 static GQuark move_resize_quark = 0;
4277 if (!move_resize_quark)
4278 move_resize_quark = g_quark_from_static_string ("gdk-window-moveresize");
4280 mv_resize = g_object_get_qdata (G_OBJECT (display), move_resize_quark);
4282 if (!mv_resize && create)
4284 mv_resize = g_new0 (MoveResizeData, 1);
4285 mv_resize->display = display;
4287 g_object_set_qdata (G_OBJECT (display), move_resize_quark, mv_resize);
4294 update_pos (MoveResizeData *mv_resize,
4300 dx = new_root_x - mv_resize->moveresize_x;
4301 dy = new_root_y - mv_resize->moveresize_y;
4303 if (mv_resize->is_resize)
4307 x = mv_resize->moveresize_orig_x;
4308 y = mv_resize->moveresize_orig_y;
4310 w = mv_resize->moveresize_orig_width;
4311 h = mv_resize->moveresize_orig_height;
4313 switch (mv_resize->resize_edge)
4315 case GDK_WINDOW_EDGE_NORTH_WEST:
4321 case GDK_WINDOW_EDGE_NORTH:
4325 case GDK_WINDOW_EDGE_NORTH_EAST:
4330 case GDK_WINDOW_EDGE_SOUTH_WEST:
4335 case GDK_WINDOW_EDGE_SOUTH_EAST:
4339 case GDK_WINDOW_EDGE_SOUTH:
4342 case GDK_WINDOW_EDGE_EAST:
4345 case GDK_WINDOW_EDGE_WEST:
4356 if (mv_resize->moveresize_geom_mask)
4358 gdk_window_constrain_size (&mv_resize->moveresize_geometry,
4359 mv_resize->moveresize_geom_mask,
4363 gdk_window_move_resize (mv_resize->moveresize_window, x, y, w, h);
4369 x = mv_resize->moveresize_orig_x + dx;
4370 y = mv_resize->moveresize_orig_y + dy;
4372 gdk_window_move (mv_resize->moveresize_window, x, y);
4377 finish_drag (MoveResizeData *mv_resize)
4379 gdk_window_destroy (mv_resize->moveresize_emulation_window);
4380 mv_resize->moveresize_emulation_window = NULL;
4381 g_object_unref (mv_resize->moveresize_window);
4382 mv_resize->moveresize_window = NULL;
4384 if (mv_resize->moveresize_pending_event)
4386 g_free (mv_resize->moveresize_pending_event);
4387 mv_resize->moveresize_pending_event = NULL;
4392 lookahead_motion_predicate (Display *xdisplay,
4396 gboolean *seen_release = (gboolean *)arg;
4397 GdkDisplay *display = gdk_x11_lookup_xdisplay (xdisplay);
4398 MoveResizeData *mv_resize = get_move_resize_data (display, FALSE);
4403 switch (event->xany.type)
4406 *seen_release = TRUE;
4409 mv_resize->moveresize_process_time = event->xmotion.time;
4419 moveresize_lookahead (MoveResizeData *mv_resize,
4423 gboolean seen_release = FALSE;
4425 if (mv_resize->moveresize_process_time)
4427 if (event->xmotion.time == mv_resize->moveresize_process_time)
4429 mv_resize->moveresize_process_time = 0;
4436 XCheckIfEvent (event->xany.display, &tmp_event,
4437 lookahead_motion_predicate, (XPointer) & seen_release);
4439 return mv_resize->moveresize_process_time == 0;
4443 _gdk_moveresize_handle_event (XEvent *event)
4445 guint button_mask = 0;
4446 GdkDisplay *display = gdk_x11_lookup_xdisplay (event->xany.display);
4447 MoveResizeData *mv_resize = get_move_resize_data (display, FALSE);
4449 if (!mv_resize || !mv_resize->moveresize_window)
4452 button_mask = GDK_BUTTON1_MASK << (mv_resize->moveresize_button - 1);
4454 switch (event->xany.type)
4457 if (mv_resize->moveresize_window->resize_count > 0)
4459 if (mv_resize->moveresize_pending_event)
4460 *mv_resize->moveresize_pending_event = *event;
4462 mv_resize->moveresize_pending_event =
4463 g_memdup (event, sizeof (XEvent));
4467 if (!moveresize_lookahead (mv_resize, event))
4470 update_pos (mv_resize,
4471 event->xmotion.x_root,
4472 event->xmotion.y_root);
4474 /* This should never be triggered in normal cases, but in the
4475 * case where the drag started without an implicit grab being
4476 * in effect, we could miss the release if it occurs before
4477 * we grab the pointer; this ensures that we will never
4478 * get a permanently stuck grab.
4480 if ((event->xmotion.state & button_mask) == 0)
4481 finish_drag (mv_resize);
4485 update_pos (mv_resize,
4486 event->xbutton.x_root,
4487 event->xbutton.y_root);
4489 if (event->xbutton.button == mv_resize->moveresize_button)
4490 finish_drag (mv_resize);
4497 _gdk_moveresize_configure_done (GdkDisplay *display,
4501 MoveResizeData *mv_resize = get_move_resize_data (display, FALSE);
4503 if (!mv_resize || window != mv_resize->moveresize_window)
4506 if (mv_resize->moveresize_pending_event)
4508 tmp_event = mv_resize->moveresize_pending_event;
4509 mv_resize->moveresize_pending_event = NULL;
4510 _gdk_moveresize_handle_event (tmp_event);
4518 create_moveresize_window (MoveResizeData *mv_resize,
4521 GdkWindowAttr attributes;
4522 gint attributes_mask;
4523 GdkGrabStatus status;
4525 g_assert (mv_resize->moveresize_emulation_window == NULL);
4527 attributes.x = -100;
4528 attributes.y = -100;
4529 attributes.width = 10;
4530 attributes.height = 10;
4531 attributes.window_type = GDK_WINDOW_TEMP;
4532 attributes.wclass = GDK_INPUT_ONLY;
4533 attributes.override_redirect = TRUE;
4534 attributes.event_mask = 0;
4536 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_NOREDIR;
4538 mv_resize->moveresize_emulation_window =
4539 gdk_window_new (gdk_screen_get_root_window (gdk_display_get_default_screen (mv_resize->display)),
4543 gdk_window_show (mv_resize->moveresize_emulation_window);
4545 status = gdk_pointer_grab (mv_resize->moveresize_emulation_window,
4547 GDK_BUTTON_RELEASE_MASK |
4548 GDK_POINTER_MOTION_MASK,
4553 if (status != GDK_GRAB_SUCCESS)
4555 /* If this fails, some other client has grabbed the window
4558 finish_drag (mv_resize);
4561 mv_resize->moveresize_process_time = 0;
4565 Calculate mv_resize->moveresize_orig_x and mv_resize->moveresize_orig_y
4566 so that calling XMoveWindow with these coordinates will not move the
4568 Note that this depends on the WM to implement ICCCM-compliant reference
4572 calculate_unmoving_origin (MoveResizeData *mv_resize)
4577 if (mv_resize->moveresize_geom_mask & GDK_HINT_WIN_GRAVITY &&
4578 mv_resize->moveresize_geometry.win_gravity == GDK_GRAVITY_STATIC)
4580 gdk_window_get_origin (mv_resize->moveresize_window,
4581 &mv_resize->moveresize_orig_x,
4582 &mv_resize->moveresize_orig_y);
4586 gdk_window_get_frame_extents (mv_resize->moveresize_window, &rect);
4587 gdk_window_get_geometry (mv_resize->moveresize_window,
4588 NULL, NULL, &width, &height);
4590 switch (mv_resize->moveresize_geometry.win_gravity)
4592 case GDK_GRAVITY_NORTH_WEST:
4593 mv_resize->moveresize_orig_x = rect.x;
4594 mv_resize->moveresize_orig_y = rect.y;
4596 case GDK_GRAVITY_NORTH:
4597 mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2;
4598 mv_resize->moveresize_orig_y = rect.y;
4600 case GDK_GRAVITY_NORTH_EAST:
4601 mv_resize->moveresize_orig_x = rect.x + rect.width - width;
4602 mv_resize->moveresize_orig_y = rect.y;
4604 case GDK_GRAVITY_WEST:
4605 mv_resize->moveresize_orig_x = rect.x;
4606 mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2;
4608 case GDK_GRAVITY_CENTER:
4609 mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2;
4610 mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2;
4612 case GDK_GRAVITY_EAST:
4613 mv_resize->moveresize_orig_x = rect.x + rect.width - width;
4614 mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2;
4616 case GDK_GRAVITY_SOUTH_WEST:
4617 mv_resize->moveresize_orig_x = rect.x;
4618 mv_resize->moveresize_orig_y = rect.y + rect.height - height;
4620 case GDK_GRAVITY_SOUTH:
4621 mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2;
4622 mv_resize->moveresize_orig_y = rect.y + rect.height - height;
4624 case GDK_GRAVITY_SOUTH_EAST:
4625 mv_resize->moveresize_orig_x = rect.x + rect.width - width;
4626 mv_resize->moveresize_orig_y = rect.y + rect.height - height;
4629 mv_resize->moveresize_orig_x = rect.x;
4630 mv_resize->moveresize_orig_y = rect.y;
4637 emulate_resize_drag (GdkWindow *window,
4644 MoveResizeData *mv_resize = get_move_resize_data (GDK_WINDOW_DISPLAY (window), TRUE);
4646 mv_resize->is_resize = TRUE;
4647 mv_resize->moveresize_button = button;
4648 mv_resize->resize_edge = edge;
4649 mv_resize->moveresize_x = root_x;
4650 mv_resize->moveresize_y = root_y;
4651 mv_resize->moveresize_window = g_object_ref (window);
4653 mv_resize->moveresize_orig_width = gdk_window_get_width (window);
4654 mv_resize->moveresize_orig_height = gdk_window_get_height (window);
4656 mv_resize->moveresize_geom_mask = 0;
4657 gdk_window_get_geometry_hints (window,
4658 &mv_resize->moveresize_geometry,
4659 &mv_resize->moveresize_geom_mask);
4661 calculate_unmoving_origin (mv_resize);
4663 create_moveresize_window (mv_resize, timestamp);
4667 emulate_move_drag (GdkWindow *window,
4673 MoveResizeData *mv_resize = get_move_resize_data (GDK_WINDOW_DISPLAY (window), TRUE);
4675 mv_resize->is_resize = FALSE;
4676 mv_resize->moveresize_button = button;
4677 mv_resize->moveresize_x = root_x;
4678 mv_resize->moveresize_y = root_y;
4680 mv_resize->moveresize_window = g_object_ref (window);
4682 calculate_unmoving_origin (mv_resize);
4684 create_moveresize_window (mv_resize, timestamp);
4688 gdk_x11_window_begin_resize_drag (GdkWindow *window,
4695 if (GDK_WINDOW_DESTROYED (window) ||
4696 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
4699 if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
4700 gdk_atom_intern_static_string ("_NET_WM_MOVERESIZE")))
4701 wmspec_resize_drag (window, edge, button, root_x, root_y, timestamp);
4703 emulate_resize_drag (window, edge, button, root_x, root_y, timestamp);
4707 gdk_x11_window_begin_move_drag (GdkWindow *window,
4713 if (GDK_WINDOW_DESTROYED (window) ||
4714 !WINDOW_IS_TOPLEVEL (window))
4717 if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
4718 gdk_atom_intern_static_string ("_NET_WM_MOVERESIZE")))
4719 wmspec_moveresize (window, _NET_WM_MOVERESIZE_MOVE, root_x, root_y,
4722 emulate_move_drag (window, button, root_x, root_y, timestamp);
4726 gdk_x11_window_enable_synchronized_configure (GdkWindow *window)
4728 GdkWindowImplX11 *impl;
4730 if (!GDK_IS_WINDOW_IMPL_X11 (window->impl))
4733 impl = GDK_WINDOW_IMPL_X11 (window->impl);
4735 if (!impl->use_synchronized_configure)
4737 /* This basically means you want to do fancy X specific stuff, so
4738 ensure we have a native window */
4739 gdk_window_ensure_native (window);
4741 impl->use_synchronized_configure = TRUE;
4742 ensure_sync_counter (window);
4747 gdk_x11_window_configure_finished (GdkWindow *window)
4749 GdkWindowImplX11 *impl;
4751 if (!WINDOW_IS_TOPLEVEL (window))
4754 impl = GDK_WINDOW_IMPL_X11 (window->impl);
4755 if (!impl->use_synchronized_configure)
4759 if (!GDK_WINDOW_DESTROYED (window))
4761 GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
4762 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
4764 if (toplevel && toplevel->update_counter != None &&
4765 GDK_DISPLAY_X11 (display)->use_sync &&
4766 !XSyncValueIsZero (toplevel->current_counter_value))
4768 XSyncSetCounter (GDK_WINDOW_XDISPLAY (window),
4769 toplevel->update_counter,
4770 toplevel->current_counter_value);
4772 XSyncIntToValue (&toplevel->current_counter_value, 0);
4779 gdk_x11_window_beep (GdkWindow *window)
4781 GdkDisplay *display;
4783 display = GDK_WINDOW_DISPLAY (window);
4786 if (GDK_DISPLAY_X11 (display)->use_xkb)
4788 XkbBell (GDK_DISPLAY_XDISPLAY (display),
4789 GDK_WINDOW_XID (window),
4800 gdk_x11_window_set_opacity (GdkWindow *window,
4803 GdkDisplay *display;
4806 g_return_if_fail (GDK_IS_WINDOW (window));
4808 if (GDK_WINDOW_DESTROYED (window) ||
4809 !WINDOW_IS_TOPLEVEL (window))
4812 display = gdk_window_get_display (window);
4816 else if (opacity > 1)
4819 cardinal = opacity * 0xffffffff;
4821 if (cardinal == 0xffffffff)
4822 XDeleteProperty (GDK_DISPLAY_XDISPLAY (display),
4823 GDK_WINDOW_XID (window),
4824 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_OPACITY"));
4826 XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
4827 GDK_WINDOW_XID (window),
4828 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_OPACITY"),
4831 (guchar *) &cardinal, 1);
4835 _gdk_windowing_window_set_composited (GdkWindow *window,
4836 gboolean composited)
4838 #if defined(HAVE_XCOMPOSITE) && defined(HAVE_XDAMAGE) && defined (HAVE_XFIXES)
4839 GdkWindowImplX11 *impl;
4840 GdkDisplay *display;
4844 impl = GDK_WINDOW_IMPL_X11 (window->impl);
4846 display = gdk_window_get_display (window);
4847 dpy = GDK_DISPLAY_XDISPLAY (display);
4848 xid = GDK_WINDOW_XID (window);
4852 XCompositeRedirectWindow (dpy, xid, CompositeRedirectManual);
4853 impl->damage = XDamageCreate (dpy, xid, XDamageReportBoundingBox);
4857 XCompositeUnredirectWindow (dpy, xid, CompositeRedirectManual);
4858 XDamageDestroy (dpy, impl->damage);
4859 impl->damage = None;
4865 _gdk_windowing_window_process_updates_recurse (GdkWindow *window,
4866 cairo_region_t *region)
4868 _gdk_window_process_updates_recurse (window, region);
4872 _gdk_windowing_before_process_all_updates (void)
4877 _gdk_windowing_after_process_all_updates (void)
4882 timestamp_predicate (Display *display,
4886 Window xwindow = GPOINTER_TO_UINT (arg);
4887 GdkDisplay *gdk_display = gdk_x11_lookup_xdisplay (display);
4889 if (xevent->type == PropertyNotify &&
4890 xevent->xproperty.window == xwindow &&
4891 xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (gdk_display,
4892 "GDK_TIMESTAMP_PROP"))
4899 * gdk_x11_get_server_time:
4900 * @window: a #GdkWindow, used for communication with the server.
4901 * The window must have GDK_PROPERTY_CHANGE_MASK in its
4902 * events mask or a hang will result.
4904 * Routine to get the current X server time stamp.
4906 * Return value: the time stamp.
4909 gdk_x11_get_server_time (GdkWindow *window)
4915 Atom timestamp_prop_atom;
4917 g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
4918 g_return_val_if_fail (!GDK_WINDOW_DESTROYED (window), 0);
4920 xdisplay = GDK_WINDOW_XDISPLAY (window);
4921 xwindow = GDK_WINDOW_XID (window);
4922 timestamp_prop_atom =
4923 gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
4924 "GDK_TIMESTAMP_PROP");
4926 XChangeProperty (xdisplay, xwindow, timestamp_prop_atom,
4927 timestamp_prop_atom,
4928 8, PropModeReplace, &c, 1);
4930 XIfEvent (xdisplay, &xevent,
4931 timestamp_predicate, GUINT_TO_POINTER(xwindow));
4933 return xevent.xproperty.time;
4937 * gdk_x11_window_get_xid:
4938 * @window: a native #GdkWindow.
4940 * Returns the X resource (window) belonging to a #GdkWindow.
4942 * Return value: the ID of @drawable's X resource.
4945 gdk_x11_window_get_xid (GdkWindow *window)
4947 /* Try to ensure the window has a native window */
4948 if (!_gdk_window_has_impl (window))
4950 gdk_window_ensure_native (window);
4952 /* We sync here to ensure the window is created in the Xserver when
4953 * this function returns. This is required because the returned XID
4954 * for this window must be valid immediately, even with another
4955 * connection to the Xserver */
4956 gdk_display_sync (gdk_window_get_display (window));
4959 if (!GDK_WINDOW_IS_X11 (window))
4961 g_warning (G_STRLOC " drawable is not a native X11 window");
4965 return GDK_WINDOW_IMPL_X11 (window->impl)->xid;
4968 extern GdkDragContext * _gdk_x11_window_drag_begin (GdkWindow *window,
4973 gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass)
4975 GObjectClass *object_class = G_OBJECT_CLASS (klass);
4976 GdkWindowImplClass *impl_class = GDK_WINDOW_IMPL_CLASS (klass);
4978 object_class->finalize = gdk_window_impl_x11_finalize;
4980 impl_class->ref_cairo_surface = gdk_x11_ref_cairo_surface;
4981 impl_class->show = gdk_window_x11_show;
4982 impl_class->hide = gdk_window_x11_hide;
4983 impl_class->withdraw = gdk_window_x11_withdraw;
4984 impl_class->set_events = gdk_window_x11_set_events;
4985 impl_class->get_events = gdk_window_x11_get_events;
4986 impl_class->raise = gdk_window_x11_raise;
4987 impl_class->lower = gdk_window_x11_lower;
4988 impl_class->restack_under = gdk_window_x11_restack_under;
4989 impl_class->restack_toplevel = gdk_window_x11_restack_toplevel;
4990 impl_class->move_resize = gdk_window_x11_move_resize;
4991 impl_class->set_background = gdk_window_x11_set_background;
4992 impl_class->reparent = gdk_window_x11_reparent;
4993 impl_class->set_device_cursor = gdk_window_x11_set_device_cursor;
4994 impl_class->get_geometry = gdk_window_x11_get_geometry;
4995 impl_class->get_root_coords = gdk_window_x11_get_root_coords;
4996 impl_class->get_device_state = gdk_window_x11_get_device_state;
4997 impl_class->shape_combine_region = gdk_window_x11_shape_combine_region;
4998 impl_class->input_shape_combine_region = gdk_window_x11_input_shape_combine_region;
4999 impl_class->set_static_gravities = gdk_window_x11_set_static_gravities;
5000 impl_class->queue_antiexpose = _gdk_x11_window_queue_antiexpose;
5001 impl_class->translate = _gdk_x11_window_translate;
5002 impl_class->destroy = _gdk_x11_window_destroy;
5003 impl_class->resize_cairo_surface = gdk_window_x11_resize_cairo_surface;
5004 impl_class->get_shape = gdk_x11_window_get_shape;
5005 impl_class->get_input_shape = gdk_x11_window_get_input_shape;
5006 impl_class->beep = gdk_x11_window_beep;
5008 impl_class->focus = gdk_x11_window_focus;
5009 impl_class->set_type_hint = gdk_x11_window_set_type_hint;
5010 impl_class->get_type_hint = gdk_x11_window_get_type_hint;
5011 impl_class->set_modal_hint = gdk_x11_window_set_modal_hint;
5012 impl_class->set_skip_taskbar_hint = gdk_x11_window_set_skip_taskbar_hint;
5013 impl_class->set_skip_pager_hint = gdk_x11_window_set_skip_pager_hint;
5014 impl_class->set_urgency_hint = gdk_x11_window_set_urgency_hint;
5015 impl_class->set_geometry_hints = gdk_x11_window_set_geometry_hints;
5016 impl_class->set_title = gdk_x11_window_set_title;
5017 impl_class->set_role = gdk_x11_window_set_role;
5018 impl_class->set_startup_id = gdk_x11_window_set_startup_id;
5019 impl_class->set_transient_for = gdk_x11_window_set_transient_for;
5020 impl_class->get_root_origin = gdk_x11_window_get_root_origin;
5021 impl_class->get_frame_extents = gdk_x11_window_get_frame_extents;
5022 impl_class->set_override_redirect = gdk_x11_window_set_override_redirect;
5023 impl_class->set_accept_focus = gdk_x11_window_set_accept_focus;
5024 impl_class->set_focus_on_map = gdk_x11_window_set_focus_on_map;
5025 impl_class->set_icon_list = gdk_x11_window_set_icon_list;
5026 impl_class->set_icon_name = gdk_x11_window_set_icon_name;
5027 impl_class->iconify = gdk_x11_window_iconify;
5028 impl_class->deiconify = gdk_x11_window_deiconify;
5029 impl_class->stick = gdk_x11_window_stick;
5030 impl_class->unstick = gdk_x11_window_unstick;
5031 impl_class->maximize = gdk_x11_window_maximize;
5032 impl_class->unmaximize = gdk_x11_window_unmaximize;
5033 impl_class->fullscreen = gdk_x11_window_fullscreen;
5034 impl_class->unfullscreen = gdk_x11_window_unfullscreen;
5035 impl_class->set_keep_above = gdk_x11_window_set_keep_above;
5036 impl_class->set_keep_below = gdk_x11_window_set_keep_below;
5037 impl_class->get_group = gdk_x11_window_get_group;
5038 impl_class->set_group = gdk_x11_window_set_group;
5039 impl_class->set_decorations = gdk_x11_window_set_decorations;
5040 impl_class->get_decorations = gdk_x11_window_get_decorations;
5041 impl_class->set_functions = gdk_x11_window_set_functions;
5042 impl_class->set_functions = gdk_x11_window_set_functions;
5043 impl_class->begin_resize_drag = gdk_x11_window_begin_resize_drag;
5044 impl_class->begin_move_drag = gdk_x11_window_begin_move_drag;
5045 impl_class->enable_synchronized_configure = gdk_x11_window_enable_synchronized_configure;
5046 impl_class->configure_finished = gdk_x11_window_configure_finished;
5047 impl_class->set_opacity = gdk_x11_window_set_opacity;
5048 impl_class->destroy_notify = gdk_x11_window_destroy_notify;
5049 impl_class->register_dnd = _gdk_x11_window_register_dnd;
5050 impl_class->drag_begin = _gdk_x11_window_drag_begin;