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"
32 #include "gdkwindow.h"
33 #include "gdkwindowimpl.h"
34 #include "gdkvisualprivate.h"
35 #include "gdkinternals.h"
36 #include "gdkdeviceprivate.h"
38 #include "gdkeventsource.h"
39 #include "gdkdisplay-x11.h"
40 #include "gdkprivate-x11.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_x11_event_mask_table[21] =
78 PointerMotionHintMask,
95 SubstructureNotifyMask,
96 ButtonPressMask /* SCROLL; on X mouse wheel events is treated as mouse button 4/5 */
99 const gint _gdk_x11_event_mask_table_size = G_N_ELEMENTS (_gdk_x11_event_mask_table);
101 /* Forward declarations */
102 static void gdk_window_set_static_win_gravity (GdkWindow *window,
104 static gboolean gdk_window_icon_name_set (GdkWindow *window);
105 static void set_wm_name (GdkDisplay *display,
108 static void move_to_current_desktop (GdkWindow *window);
109 static void gdk_window_x11_set_background (GdkWindow *window,
110 cairo_pattern_t *pattern);
112 static void gdk_window_impl_x11_finalize (GObject *object);
114 #define WINDOW_IS_TOPLEVEL_OR_FOREIGN(window) \
115 (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \
116 GDK_WINDOW_TYPE (window) != GDK_WINDOW_OFFSCREEN)
118 #define WINDOW_IS_TOPLEVEL(window) \
119 (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \
120 GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN && \
121 GDK_WINDOW_TYPE (window) != GDK_WINDOW_OFFSCREEN)
123 /* Return whether time1 is considered later than time2 as far as xserver
124 * time is concerned. Accounts for wraparound.
126 #define XSERVER_TIME_IS_LATER(time1, time2) \
127 ( (( time1 > time2 ) && ( time1 - time2 < ((guint32)-1)/2 )) || \
128 (( time1 < time2 ) && ( time2 - time1 > ((guint32)-1)/2 )) \
131 struct _GdkX11Window {
135 struct _GdkX11WindowClass {
136 GdkWindowClass parent_class;
139 G_DEFINE_TYPE (GdkX11Window, gdk_x11_window, GDK_TYPE_WINDOW)
142 gdk_x11_window_class_init (GdkX11WindowClass *x11_window_class)
147 gdk_x11_window_init (GdkX11Window *x11_window)
152 G_DEFINE_TYPE (GdkWindowImplX11, gdk_window_impl_x11, GDK_TYPE_WINDOW_IMPL)
155 gdk_window_impl_x11_init (GdkWindowImplX11 *impl)
157 impl->toplevel_window_type = -1;
158 impl->device_cursor = g_hash_table_new_full (NULL, NULL,
159 NULL, g_object_unref);
163 _gdk_x11_window_get_toplevel (GdkWindow *window)
165 GdkWindowImplX11 *impl;
167 g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
169 if (!WINDOW_IS_TOPLEVEL (window))
172 impl = GDK_WINDOW_IMPL_X11 (window->impl);
175 impl->toplevel = g_new0 (GdkToplevelX11, 1);
177 return impl->toplevel;
180 static const cairo_user_data_key_t gdk_x11_cairo_key;
183 * _gdk_x11_window_update_size:
184 * @impl: a #GdkWindowImplX11.
186 * Updates the state of the window (in particular the drawable's
187 * cairo surface) when its size has changed.
190 _gdk_x11_window_update_size (GdkWindowImplX11 *impl)
192 if (impl->cairo_surface)
194 cairo_xlib_surface_set_size (impl->cairo_surface,
195 gdk_window_get_width (impl->wrapper),
196 gdk_window_get_height (impl->wrapper));
200 /*****************************************************
201 * X11 specific implementations of generic functions *
202 *****************************************************/
205 gdk_x11_cairo_surface_destroy (void *data)
207 GdkWindowImplX11 *impl = data;
209 impl->cairo_surface = NULL;
212 static cairo_surface_t *
213 gdk_x11_create_cairo_surface (GdkWindowImplX11 *impl,
219 visual = gdk_window_get_visual (impl->wrapper);
220 return cairo_xlib_surface_create (GDK_WINDOW_XDISPLAY (impl->wrapper),
221 GDK_WINDOW_IMPL_X11 (impl)->xid,
222 GDK_VISUAL_XVISUAL (visual),
226 static cairo_surface_t *
227 gdk_x11_ref_cairo_surface (GdkWindow *window)
229 GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
231 if (GDK_WINDOW_DESTROYED (window))
234 if (!impl->cairo_surface)
236 impl->cairo_surface = gdk_x11_create_cairo_surface (impl,
237 gdk_window_get_width (window),
238 gdk_window_get_height (window));
240 if (impl->cairo_surface)
241 cairo_surface_set_user_data (impl->cairo_surface, &gdk_x11_cairo_key,
242 impl, gdk_x11_cairo_surface_destroy);
245 cairo_surface_reference (impl->cairo_surface);
247 return impl->cairo_surface;
251 gdk_window_impl_x11_finalize (GObject *object)
254 GdkWindowImplX11 *impl;
256 g_return_if_fail (GDK_IS_WINDOW_IMPL_X11 (object));
258 impl = GDK_WINDOW_IMPL_X11 (object);
260 wrapper = impl->wrapper;
262 _gdk_x11_window_grab_check_destroy (wrapper);
264 if (!GDK_WINDOW_DESTROYED (wrapper))
266 GdkDisplay *display = GDK_WINDOW_DISPLAY (wrapper);
268 _gdk_x11_display_remove_window (display, impl->xid);
269 if (impl->toplevel && impl->toplevel->focus_window)
270 _gdk_x11_display_remove_window (display, impl->toplevel->focus_window);
273 g_free (impl->toplevel);
276 g_object_unref (impl->cursor);
278 g_hash_table_destroy (impl->device_cursor);
280 G_OBJECT_CLASS (gdk_window_impl_x11_parent_class)->finalize (object);
289 free_pixmap (gpointer datap)
291 FreePixmapData *data = datap;
293 if (!gdk_display_is_closed (data->display))
295 XFreePixmap (GDK_DISPLAY_XDISPLAY (data->display),
299 g_object_unref (data->display);
300 g_slice_free (FreePixmapData, data);
304 attach_free_pixmap_handler (cairo_surface_t *surface,
308 static const cairo_user_data_key_t key;
309 FreePixmapData *data;
311 data = g_slice_new (FreePixmapData);
312 data->display = g_object_ref (display);
313 data->pixmap = pixmap;
315 cairo_surface_set_user_data (surface, &key, data, free_pixmap);
318 /* Cairo does not guarantee we get an xlib surface if we call
319 * cairo_surface_create_similar(). In some cases however, we must use a
320 * pixmap or bitmap in the X11 API.
321 * These functions ensure an Xlib surface.
324 _gdk_x11_window_create_bitmap_surface (GdkWindow *window,
328 cairo_surface_t *surface;
331 pixmap = XCreatePixmap (GDK_WINDOW_XDISPLAY (window),
332 GDK_WINDOW_XID (window),
334 surface = cairo_xlib_surface_create_for_bitmap (GDK_WINDOW_XDISPLAY (window),
336 GDK_X11_SCREEN (GDK_WINDOW_SCREEN (window))->xscreen,
338 attach_free_pixmap_handler (surface, GDK_WINDOW_DISPLAY (window), pixmap);
343 /* Create a surface backed with a pixmap without alpha on the same screen as window */
344 static cairo_surface_t *
345 gdk_x11_window_create_pixmap_surface (GdkWindow *window,
349 GdkScreen *screen = gdk_window_get_screen (window);
350 GdkVisual *visual = gdk_screen_get_system_visual (screen);
351 cairo_surface_t *surface;
354 pixmap = XCreatePixmap (GDK_WINDOW_XDISPLAY (window),
355 GDK_WINDOW_XID (window),
357 gdk_visual_get_depth (visual));
358 surface = cairo_xlib_surface_create (GDK_WINDOW_XDISPLAY (window),
360 GDK_VISUAL_XVISUAL (visual),
362 attach_free_pixmap_handler (surface, GDK_WINDOW_DISPLAY (window), pixmap);
368 tmp_unset_bg (GdkWindow *window)
370 GdkWindowImplX11 *impl;
372 impl = GDK_WINDOW_IMPL_X11 (window->impl);
376 XSetWindowBackgroundPixmap (GDK_WINDOW_XDISPLAY (window),
377 GDK_WINDOW_XID (window), None);
381 tmp_reset_bg (GdkWindow *window)
383 GdkWindowImplX11 *impl;
385 impl = GDK_WINDOW_IMPL_X11 (window->impl);
389 gdk_window_x11_set_background (window, window->background);
392 /* Unsetting and resetting window backgrounds.
394 * In many cases it is possible to avoid flicker by unsetting the
395 * background of windows. For example if the background of the
396 * parent window is unset when a window is unmapped, a brief flicker
397 * of background painting is avoided.
400 _gdk_x11_window_tmp_unset_bg (GdkWindow *window,
403 g_return_if_fail (GDK_IS_WINDOW (window));
405 if (window->input_only || window->destroyed ||
406 (window->window_type != GDK_WINDOW_ROOT &&
407 !GDK_WINDOW_IS_MAPPED (window)))
410 if (_gdk_window_has_impl (window) &&
411 GDK_WINDOW_IS_X11 (window) &&
412 window->window_type != GDK_WINDOW_ROOT &&
413 window->window_type != GDK_WINDOW_FOREIGN)
414 tmp_unset_bg (window);
420 for (l = window->children; l != NULL; l = l->next)
421 _gdk_x11_window_tmp_unset_bg (l->data, TRUE);
426 _gdk_x11_window_tmp_unset_parent_bg (GdkWindow *window)
428 if (GDK_WINDOW_TYPE (window->parent) == GDK_WINDOW_ROOT)
431 window = _gdk_window_get_impl_window (window->parent);
432 _gdk_x11_window_tmp_unset_bg (window, FALSE);
436 _gdk_x11_window_tmp_reset_bg (GdkWindow *window,
439 g_return_if_fail (GDK_IS_WINDOW (window));
441 if (window->input_only || window->destroyed ||
442 (window->window_type != GDK_WINDOW_ROOT &&
443 !GDK_WINDOW_IS_MAPPED (window)))
447 if (_gdk_window_has_impl (window) &&
448 GDK_WINDOW_IS_X11 (window) &&
449 window->window_type != GDK_WINDOW_ROOT &&
450 window->window_type != GDK_WINDOW_FOREIGN)
451 tmp_reset_bg (window);
457 for (l = window->children; l != NULL; l = l->next)
458 _gdk_x11_window_tmp_reset_bg (l->data, TRUE);
463 _gdk_x11_window_tmp_reset_parent_bg (GdkWindow *window)
465 if (GDK_WINDOW_TYPE (window->parent) == GDK_WINDOW_ROOT)
468 window = _gdk_window_get_impl_window (window->parent);
470 _gdk_x11_window_tmp_reset_bg (window, FALSE);
474 _gdk_x11_screen_init_root_window (GdkScreen *screen)
477 GdkWindowImplX11 *impl;
478 GdkX11Screen *x11_screen;
480 x11_screen = GDK_X11_SCREEN (screen);
482 g_assert (x11_screen->root_window == NULL);
484 window = x11_screen->root_window = _gdk_display_create_window (gdk_screen_get_display (screen));
486 window->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_X11, NULL);
487 window->impl_window = window;
488 window->visual = gdk_screen_get_system_visual (screen);
490 impl = GDK_WINDOW_IMPL_X11 (window->impl);
492 impl->xid = x11_screen->xroot_window;
493 impl->wrapper = window;
495 window->window_type = GDK_WINDOW_ROOT;
496 window->depth = DefaultDepthOfScreen (x11_screen->xscreen);
502 window->width = WidthOfScreen (x11_screen->xscreen);
503 window->height = HeightOfScreen (x11_screen->xscreen);
504 window->viewable = TRUE;
506 /* see init_randr_support() in gdkscreen-x11.c */
507 window->event_mask = GDK_STRUCTURE_MASK;
509 _gdk_window_update_size (x11_screen->root_window);
511 _gdk_x11_display_add_window (x11_screen->display,
512 &x11_screen->xroot_window,
513 x11_screen->root_window);
517 set_wm_protocols (GdkWindow *window)
519 GdkDisplay *display = gdk_window_get_display (window);
523 protocols[n++] = gdk_x11_get_xatom_by_name_for_display (display, "WM_DELETE_WINDOW");
524 protocols[n++] = gdk_x11_get_xatom_by_name_for_display (display, "WM_TAKE_FOCUS");
525 protocols[n++] = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_PING");
528 if (GDK_X11_DISPLAY (display)->use_sync)
529 protocols[n++] = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_SYNC_REQUEST");
532 XSetWMProtocols (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window), protocols, n);
536 get_default_title (void)
540 title = g_get_application_name ();
542 title = g_get_prgname ();
550 check_leader_window_title (GdkDisplay *display)
552 GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
554 if (display_x11->leader_window && !display_x11->leader_window_title_set)
556 set_wm_name (display,
557 display_x11->leader_window,
558 get_default_title ());
560 display_x11->leader_window_title_set = TRUE;
565 create_focus_window (GdkDisplay *display,
568 GdkX11Display *display_x11;
569 GdkEventMask event_mask;
573 xdisplay = GDK_DISPLAY_XDISPLAY (display);
574 display_x11 = GDK_X11_DISPLAY (display);
576 focus_window = XCreateSimpleWindow (xdisplay, parent,
580 /* FIXME: probably better to actually track the requested event mask for the toplevel
582 event_mask = (GDK_KEY_PRESS_MASK |
583 GDK_KEY_RELEASE_MASK |
584 GDK_FOCUS_CHANGE_MASK);
586 gdk_x11_event_source_select_events ((GdkEventSource *) display_x11->event_source,
590 XMapWindow (xdisplay, focus_window);
596 ensure_sync_counter (GdkWindow *window)
599 if (!GDK_WINDOW_DESTROYED (window))
601 GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
602 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
603 GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
605 if (toplevel && impl->use_synchronized_configure &&
606 toplevel->update_counter == None &&
607 GDK_X11_DISPLAY (display)->use_sync)
609 Display *xdisplay = GDK_DISPLAY_XDISPLAY (display);
613 XSyncIntToValue (&value, 0);
615 toplevel->update_counter = XSyncCreateCounter (xdisplay, value);
617 atom = gdk_x11_get_xatom_by_name_for_display (display,
618 "_NET_WM_SYNC_REQUEST_COUNTER");
620 XChangeProperty (xdisplay, GDK_WINDOW_XID (window),
623 (guchar *)&toplevel->update_counter, 1);
625 XSyncIntToValue (&toplevel->current_counter_value, 0);
632 setup_toplevel_window (GdkWindow *window,
635 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
636 GdkDisplay *display = gdk_window_get_display (window);
637 Display *xdisplay = GDK_WINDOW_XDISPLAY (window);
638 XID xid = GDK_WINDOW_XID (window);
639 GdkX11Screen *x11_screen = GDK_X11_SCREEN (GDK_WINDOW_SCREEN (parent));
640 XSizeHints size_hints;
642 Window leader_window;
644 set_wm_protocols (window);
646 if (!window->input_only)
648 /* The focus window is off the visible area, and serves to receive key
649 * press events so they don't get sent to child windows.
651 toplevel->focus_window = create_focus_window (display, xid);
652 _gdk_x11_display_add_window (x11_screen->display,
653 &toplevel->focus_window,
657 check_leader_window_title (x11_screen->display);
659 /* FIXME: Is there any point in doing this? Do any WM's pay
660 * attention to PSize, and even if they do, is this the
663 size_hints.flags = PSize;
664 size_hints.width = window->width;
665 size_hints.height = window->height;
667 XSetWMNormalHints (xdisplay, xid, &size_hints);
669 /* This will set WM_CLIENT_MACHINE and WM_LOCALE_NAME */
670 XSetWMProperties (xdisplay, xid, NULL, NULL, NULL, 0, NULL, NULL, NULL);
673 XChangeProperty (xdisplay, xid,
674 gdk_x11_get_xatom_by_name_for_display (x11_screen->display, "_NET_WM_PID"),
679 leader_window = GDK_X11_DISPLAY (x11_screen->display)->leader_window;
682 XChangeProperty (xdisplay, xid,
683 gdk_x11_get_xatom_by_name_for_display (x11_screen->display, "WM_CLIENT_LEADER"),
684 XA_WINDOW, 32, PropModeReplace,
685 (guchar *) &leader_window, 1);
687 if (toplevel->focus_window != None)
688 XChangeProperty (xdisplay, xid,
689 gdk_x11_get_xatom_by_name_for_display (x11_screen->display, "_NET_WM_USER_TIME_WINDOW"),
690 XA_WINDOW, 32, PropModeReplace,
691 (guchar *) &toplevel->focus_window, 1);
693 if (!window->focus_on_map)
694 gdk_x11_window_set_user_time (window, 0);
695 else if (GDK_X11_DISPLAY (x11_screen->display)->user_time != 0)
696 gdk_x11_window_set_user_time (window, GDK_X11_DISPLAY (x11_screen->display)->user_time);
698 ensure_sync_counter (window);
702 _gdk_x11_display_create_window_impl (GdkDisplay *display,
704 GdkWindow *real_parent,
706 GdkEventMask event_mask,
707 GdkWindowAttr *attributes,
708 gint attributes_mask)
710 GdkWindowImplX11 *impl;
711 GdkX11Screen *x11_screen;
712 GdkX11Display *display_x11;
718 XSetWindowAttributes xattributes;
719 long xattributes_mask;
720 XClassHint *class_hint;
725 display_x11 = GDK_X11_DISPLAY (display);
726 xparent = GDK_WINDOW_XID (real_parent);
727 x11_screen = GDK_X11_SCREEN (screen);
729 impl = g_object_new (GDK_TYPE_WINDOW_IMPL_X11, NULL);
730 window->impl = GDK_WINDOW_IMPL (impl);
731 impl->wrapper = GDK_WINDOW (window);
733 xdisplay = x11_screen->xdisplay;
735 xattributes_mask = 0;
737 xvisual = gdk_x11_visual_get_xvisual (window->visual);
739 if (attributes_mask & GDK_WA_NOREDIR)
741 xattributes.override_redirect =
742 (attributes->override_redirect == FALSE)?False:True;
743 xattributes_mask |= CWOverrideRedirect;
746 xattributes.override_redirect = False;
748 impl->override_redirect = xattributes.override_redirect;
750 if (window->parent && window->parent->guffaw_gravity)
752 xattributes.win_gravity = StaticGravity;
753 xattributes_mask |= CWWinGravity;
757 switch (window->window_type)
759 case GDK_WINDOW_TOPLEVEL:
760 case GDK_WINDOW_TEMP:
761 if (GDK_WINDOW_TYPE (window->parent) != GDK_WINDOW_ROOT)
763 /* The common code warns for this case */
764 xparent = GDK_SCREEN_XROOTWIN (screen);
768 if (!window->input_only)
772 xattributes.background_pixel = BlackPixel (xdisplay, x11_screen->screen_num);
774 xattributes.border_pixel = BlackPixel (xdisplay, x11_screen->screen_num);
775 xattributes_mask |= CWBorderPixel | CWBackPixel;
777 if (window->guffaw_gravity)
778 xattributes.bit_gravity = StaticGravity;
780 xattributes.bit_gravity = NorthWestGravity;
782 xattributes_mask |= CWBitGravity;
784 xattributes.colormap = _gdk_visual_get_x11_colormap (window->visual);
785 xattributes_mask |= CWColormap;
787 if (window->window_type == GDK_WINDOW_TEMP)
789 xattributes.save_under = True;
790 xattributes.override_redirect = True;
791 xattributes.cursor = None;
792 xattributes_mask |= CWSaveUnder | CWOverrideRedirect;
794 impl->override_redirect = TRUE;
802 if (window->width > 65535 ||
803 window->height > 65535)
805 g_warning ("Native Windows wider or taller than 65535 pixels are not supported");
807 if (window->width > 65535)
808 window->width = 65535;
809 if (window->height > 65535)
810 window->height = 65535;
813 impl->xid = XCreateWindow (xdisplay, xparent,
814 window->x + window->parent->abs_x,
815 window->y + window->parent->abs_y,
816 window->width, window->height,
817 0, window->depth, class, xvisual,
818 xattributes_mask, &xattributes);
820 g_object_ref (window);
821 _gdk_x11_display_add_window (x11_screen->display, &impl->xid, window);
823 switch (GDK_WINDOW_TYPE (window))
825 case GDK_WINDOW_TOPLEVEL:
826 case GDK_WINDOW_TEMP:
827 if (attributes_mask & GDK_WA_TITLE)
828 title = attributes->title;
830 title = get_default_title ();
832 gdk_window_set_title (window, title);
834 if (attributes_mask & GDK_WA_WMCLASS)
836 class_hint = XAllocClassHint ();
837 class_hint->res_name = attributes->wmclass_name;
838 class_hint->res_class = attributes->wmclass_class;
839 XSetClassHint (xdisplay, impl->xid, class_hint);
843 setup_toplevel_window (window, window->parent);
846 case GDK_WINDOW_CHILD:
851 if (attributes_mask & GDK_WA_TYPE_HINT)
852 gdk_window_set_type_hint (window, attributes->type_hint);
854 gdk_x11_event_source_select_events ((GdkEventSource *) display_x11->event_source,
855 GDK_WINDOW_XID (window), event_mask,
856 StructureNotifyMask | PropertyChangeMask);
860 x_event_mask_to_gdk_event_mask (long mask)
862 GdkEventMask event_mask = 0;
865 for (i = 0; i < _gdk_x11_event_mask_table_size; i++)
867 if (mask & _gdk_x11_event_mask_table[i])
868 event_mask |= 1 << (i + 1);
875 * gdk_x11_window_foreign_new_for_display:
876 * @display: the #GdkDisplay where the window handle comes from.
877 * @window: an XLib <type>Window</type>
879 * Wraps a native window in a #GdkWindow. The function will try to
880 * look up the window using gdk_x11_window_lookup_for_display() first.
881 * If it does not find it there, it will create a new window.
883 * This may fail if the window has been destroyed. If the window
884 * was already known to GDK, a new reference to the existing
885 * #GdkWindow is returned.
887 * Return value: (transfer full): a #GdkWindow wrapper for the native
888 * window, or %NULL if the window has been destroyed. The wrapper
889 * will be newly created, if one doesn't exist already.
894 gdk_x11_window_foreign_new_for_display (GdkDisplay *display,
899 GdkWindowImplX11 *impl;
900 GdkX11Display *display_x11;
901 XWindowAttributes attrs;
903 Window *children = NULL;
907 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
909 display_x11 = GDK_X11_DISPLAY (display);
911 if ((win = gdk_x11_window_lookup_for_display (display, window)) != NULL)
912 return g_object_ref (win);
914 gdk_x11_display_error_trap_push (display);
915 result = XGetWindowAttributes (display_x11->xdisplay, window, &attrs);
916 if (gdk_x11_display_error_trap_pop (display) || !result)
919 /* FIXME: This is pretty expensive.
920 * Maybe the caller should supply the parent
922 gdk_x11_display_error_trap_push (display);
923 result = XQueryTree (display_x11->xdisplay, window, &root, &parent, &children, &nchildren);
924 if (gdk_x11_display_error_trap_pop (display) || !result)
930 screen = _gdk_x11_display_screen_for_xrootwin (display, root);
932 win = _gdk_display_create_window (display);
933 win->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_X11, NULL);
934 win->impl_window = win;
935 win->visual = gdk_x11_screen_lookup_visual (screen,
936 XVisualIDFromVisual (attrs.visual));
938 impl = GDK_WINDOW_IMPL_X11 (win->impl);
941 win->parent = gdk_x11_window_lookup_for_display (display, parent);
943 if (!win->parent || GDK_WINDOW_TYPE (win->parent) == GDK_WINDOW_FOREIGN)
944 win->parent = gdk_screen_get_root_window (screen);
946 win->parent->children = g_list_prepend (win->parent->children, win);
952 win->width = attrs.width;
953 win->height = attrs.height;
954 win->window_type = GDK_WINDOW_FOREIGN;
955 win->destroyed = FALSE;
957 win->event_mask = x_event_mask_to_gdk_event_mask (attrs.your_event_mask);
959 if (attrs.map_state == IsUnmapped)
960 win->state = GDK_WINDOW_STATE_WITHDRAWN;
963 win->viewable = TRUE;
965 win->depth = attrs.depth;
968 _gdk_x11_display_add_window (display, &GDK_WINDOW_XID (win), win);
970 /* Update the clip region, etc */
971 _gdk_window_update_size (win);
977 gdk_toplevel_x11_free_contents (GdkDisplay *display,
978 GdkToplevelX11 *toplevel)
980 if (toplevel->icon_pixmap)
982 cairo_surface_destroy (toplevel->icon_pixmap);
983 toplevel->icon_pixmap = NULL;
985 if (toplevel->icon_mask)
987 cairo_surface_destroy (toplevel->icon_mask);
988 toplevel->icon_mask = NULL;
990 if (toplevel->group_leader)
992 g_object_unref (toplevel->group_leader);
993 toplevel->group_leader = NULL;
996 if (toplevel->update_counter != None)
998 XSyncDestroyCounter (GDK_DISPLAY_XDISPLAY (display),
999 toplevel->update_counter);
1000 toplevel->update_counter = None;
1002 XSyncIntToValue (&toplevel->current_counter_value, 0);
1008 gdk_x11_window_destroy (GdkWindow *window,
1010 gboolean foreign_destroy)
1012 GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
1013 GdkToplevelX11 *toplevel;
1015 g_return_if_fail (GDK_IS_WINDOW (window));
1017 _gdk_x11_selection_window_destroyed (window);
1019 toplevel = _gdk_x11_window_get_toplevel (window);
1021 gdk_toplevel_x11_free_contents (GDK_WINDOW_DISPLAY (window), toplevel);
1023 if (impl->cairo_surface)
1025 cairo_surface_finish (impl->cairo_surface);
1026 cairo_surface_set_user_data (impl->cairo_surface, &gdk_x11_cairo_key,
1030 if (!recursing && !foreign_destroy)
1031 XDestroyWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
1034 static cairo_surface_t *
1035 gdk_window_x11_resize_cairo_surface (GdkWindow *window,
1036 cairo_surface_t *surface,
1040 cairo_xlib_surface_set_size (surface, width, height);
1046 gdk_x11_window_destroy_foreign (GdkWindow *window)
1048 /* It's somebody else's window, but in our hierarchy,
1049 * so reparent it to the root window, and then send
1050 * it a delete event, as if we were a WM
1052 XClientMessageEvent xclient;
1053 GdkDisplay *display;
1055 display = GDK_WINDOW_DISPLAY (window);
1056 gdk_x11_display_error_trap_push (display);
1057 gdk_window_hide (window);
1058 gdk_window_reparent (window, NULL, 0, 0);
1060 memset (&xclient, 0, sizeof (xclient));
1061 xclient.type = ClientMessage;
1062 xclient.window = GDK_WINDOW_XID (window);
1063 xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "WM_PROTOCOLS");
1064 xclient.format = 32;
1065 xclient.data.l[0] = gdk_x11_get_xatom_by_name_for_display (display, "WM_DELETE_WINDOW");
1066 xclient.data.l[1] = CurrentTime;
1067 xclient.data.l[2] = 0;
1068 xclient.data.l[3] = 0;
1069 xclient.data.l[4] = 0;
1071 XSendEvent (GDK_WINDOW_XDISPLAY (window),
1072 GDK_WINDOW_XID (window),
1073 False, 0, (XEvent *)&xclient);
1074 gdk_x11_display_error_trap_pop_ignored (display);
1078 get_root (GdkWindow *window)
1080 GdkScreen *screen = gdk_window_get_screen (window);
1082 return gdk_screen_get_root_window (screen);
1085 /* This function is called when the XWindow is really gone.
1088 gdk_x11_window_destroy_notify (GdkWindow *window)
1090 GdkWindowImplX11 *window_impl;
1092 window_impl = GDK_WINDOW_IMPL_X11 ((window)->impl);
1094 if (!GDK_WINDOW_DESTROYED (window))
1096 if (GDK_WINDOW_TYPE(window) != GDK_WINDOW_FOREIGN)
1097 g_warning ("GdkWindow %#lx unexpectedly destroyed", GDK_WINDOW_XID (window));
1099 _gdk_window_destroy (window, TRUE);
1102 _gdk_x11_display_remove_window (GDK_WINDOW_DISPLAY (window), GDK_WINDOW_XID (window));
1103 if (window_impl->toplevel && window_impl->toplevel->focus_window)
1104 _gdk_x11_display_remove_window (GDK_WINDOW_DISPLAY (window), window_impl->toplevel->focus_window);
1106 _gdk_x11_window_grab_check_destroy (window);
1108 g_object_unref (window);
1111 static GdkDragProtocol
1112 gdk_x11_window_get_drag_protocol (GdkWindow *window,
1115 GdkDragProtocol protocol;
1116 GdkDisplay *display;
1120 display = gdk_window_get_display (window);
1121 xid = _gdk_x11_display_get_drag_protocol (display,
1122 GDK_WINDOW_XID (window->impl_window),
1129 *target = gdk_x11_window_foreign_new_for_display (display, xid);
1138 update_wm_hints (GdkWindow *window,
1141 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
1142 GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
1146 !toplevel->is_leader &&
1147 window->state & GDK_WINDOW_STATE_WITHDRAWN)
1150 wm_hints.flags = StateHint | InputHint;
1151 wm_hints.input = window->accept_focus ? True : False;
1152 wm_hints.initial_state = NormalState;
1154 if (window->state & GDK_WINDOW_STATE_ICONIFIED)
1156 wm_hints.flags |= StateHint;
1157 wm_hints.initial_state = IconicState;
1160 if (toplevel->icon_pixmap)
1162 wm_hints.flags |= IconPixmapHint;
1163 wm_hints.icon_pixmap = cairo_xlib_surface_get_drawable (toplevel->icon_pixmap);
1166 if (toplevel->icon_mask)
1168 wm_hints.flags |= IconMaskHint;
1169 wm_hints.icon_mask = cairo_xlib_surface_get_drawable (toplevel->icon_mask);
1172 wm_hints.flags |= WindowGroupHint;
1173 if (toplevel->group_leader && !GDK_WINDOW_DESTROYED (toplevel->group_leader))
1175 wm_hints.flags |= WindowGroupHint;
1176 wm_hints.window_group = GDK_WINDOW_XID (toplevel->group_leader);
1179 wm_hints.window_group = GDK_X11_DISPLAY (display)->leader_window;
1181 if (toplevel->urgency_hint)
1182 wm_hints.flags |= XUrgencyHint;
1184 XSetWMHints (GDK_WINDOW_XDISPLAY (window),
1185 GDK_WINDOW_XID (window),
1190 set_initial_hints (GdkWindow *window)
1192 GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
1193 Display *xdisplay = GDK_DISPLAY_XDISPLAY (display);
1194 Window xwindow = GDK_WINDOW_XID (window);
1195 GdkToplevelX11 *toplevel;
1199 toplevel = _gdk_x11_window_get_toplevel (window);
1204 update_wm_hints (window, TRUE);
1206 /* We set the spec hints regardless of whether the spec is supported,
1207 * since it can't hurt and it's kind of expensive to check whether
1213 if (window->state & GDK_WINDOW_STATE_MAXIMIZED)
1215 atoms[i] = gdk_x11_get_xatom_by_name_for_display (display,
1216 "_NET_WM_STATE_MAXIMIZED_VERT");
1218 atoms[i] = gdk_x11_get_xatom_by_name_for_display (display,
1219 "_NET_WM_STATE_MAXIMIZED_HORZ");
1221 toplevel->have_maxhorz = toplevel->have_maxvert = TRUE;
1224 if (window->state & GDK_WINDOW_STATE_ABOVE)
1226 atoms[i] = gdk_x11_get_xatom_by_name_for_display (display,
1227 "_NET_WM_STATE_ABOVE");
1231 if (window->state & GDK_WINDOW_STATE_BELOW)
1233 atoms[i] = gdk_x11_get_xatom_by_name_for_display (display,
1234 "_NET_WM_STATE_BELOW");
1238 if (window->state & GDK_WINDOW_STATE_STICKY)
1240 atoms[i] = gdk_x11_get_xatom_by_name_for_display (display,
1241 "_NET_WM_STATE_STICKY");
1243 toplevel->have_sticky = TRUE;
1246 if (window->state & GDK_WINDOW_STATE_FULLSCREEN)
1248 atoms[i] = gdk_x11_get_xatom_by_name_for_display (display,
1249 "_NET_WM_STATE_FULLSCREEN");
1251 toplevel->have_fullscreen = TRUE;
1254 if (window->modal_hint)
1256 atoms[i] = gdk_x11_get_xatom_by_name_for_display (display,
1257 "_NET_WM_STATE_MODAL");
1261 if (toplevel->skip_taskbar_hint)
1263 atoms[i] = gdk_x11_get_xatom_by_name_for_display (display,
1264 "_NET_WM_STATE_SKIP_TASKBAR");
1268 if (toplevel->skip_pager_hint)
1270 atoms[i] = gdk_x11_get_xatom_by_name_for_display (display,
1271 "_NET_WM_STATE_SKIP_PAGER");
1277 XChangeProperty (xdisplay,
1279 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE"),
1280 XA_ATOM, 32, PropModeReplace,
1281 (guchar*) atoms, i);
1285 XDeleteProperty (xdisplay,
1287 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE"));
1290 if (window->state & GDK_WINDOW_STATE_STICKY)
1292 atoms[0] = 0xFFFFFFFF;
1293 XChangeProperty (xdisplay,
1295 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"),
1296 XA_CARDINAL, 32, PropModeReplace,
1297 (guchar*) atoms, 1);
1298 toplevel->on_all_desktops = TRUE;
1302 XDeleteProperty (xdisplay,
1304 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"));
1307 toplevel->map_serial = NextRequest (xdisplay);
1311 gdk_window_x11_show (GdkWindow *window, gboolean already_mapped)
1313 GdkDisplay *display;
1314 GdkX11Display *display_x11;
1315 GdkToplevelX11 *toplevel;
1316 GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
1317 Display *xdisplay = GDK_WINDOW_XDISPLAY (window);
1318 Window xwindow = GDK_WINDOW_XID (window);
1321 if (!already_mapped)
1322 set_initial_hints (window);
1324 if (WINDOW_IS_TOPLEVEL (window))
1326 display = gdk_window_get_display (window);
1327 display_x11 = GDK_X11_DISPLAY (display);
1328 toplevel = _gdk_x11_window_get_toplevel (window);
1330 if (toplevel->user_time != 0 &&
1331 display_x11->user_time != 0 &&
1332 XSERVER_TIME_IS_LATER (display_x11->user_time, toplevel->user_time))
1333 gdk_x11_window_set_user_time (window, display_x11->user_time);
1336 unset_bg = !window->input_only &&
1337 (window->window_type == GDK_WINDOW_CHILD ||
1338 impl->override_redirect) &&
1339 gdk_window_is_viewable (window);
1342 _gdk_x11_window_tmp_unset_bg (window, TRUE);
1344 XMapWindow (xdisplay, xwindow);
1347 _gdk_x11_window_tmp_reset_bg (window, TRUE);
1351 pre_unmap (GdkWindow *window)
1353 GdkWindow *start_window = NULL;
1355 if (window->input_only)
1358 if (window->window_type == GDK_WINDOW_CHILD)
1359 start_window = _gdk_window_get_impl_window ((GdkWindow *)window->parent);
1360 else if (window->window_type == GDK_WINDOW_TEMP)
1361 start_window = get_root (window);
1364 _gdk_x11_window_tmp_unset_bg (start_window, TRUE);
1368 post_unmap (GdkWindow *window)
1370 GdkWindow *start_window = NULL;
1372 if (window->input_only)
1375 if (window->window_type == GDK_WINDOW_CHILD)
1376 start_window = _gdk_window_get_impl_window ((GdkWindow *)window->parent);
1377 else if (window->window_type == GDK_WINDOW_TEMP)
1378 start_window = get_root (window);
1382 _gdk_x11_window_tmp_reset_bg (start_window, TRUE);
1384 if (window->window_type == GDK_WINDOW_CHILD && window->parent)
1386 GdkRectangle invalid_rect;
1388 gdk_window_get_position (window, &invalid_rect.x, &invalid_rect.y);
1389 invalid_rect.width = gdk_window_get_width (window);
1390 invalid_rect.height = gdk_window_get_height (window);
1391 gdk_window_invalidate_rect ((GdkWindow *)window->parent,
1392 &invalid_rect, TRUE);
1398 gdk_window_x11_hide (GdkWindow *window)
1400 /* We'll get the unmap notify eventually, and handle it then,
1401 * but checking here makes things more consistent if we are
1402 * just doing stuff ourself.
1404 _gdk_x11_window_grab_check_unmap (window,
1405 NextRequest (GDK_WINDOW_XDISPLAY (window)));
1407 /* You can't simply unmap toplevel windows. */
1408 switch (window->window_type)
1410 case GDK_WINDOW_TOPLEVEL:
1411 case GDK_WINDOW_TEMP: /* ? */
1412 gdk_window_withdraw (window);
1415 case GDK_WINDOW_FOREIGN:
1416 case GDK_WINDOW_ROOT:
1417 case GDK_WINDOW_CHILD:
1421 _gdk_window_clear_update_area (window);
1424 XUnmapWindow (GDK_WINDOW_XDISPLAY (window),
1425 GDK_WINDOW_XID (window));
1426 post_unmap (window);
1430 gdk_window_x11_withdraw (GdkWindow *window)
1432 if (!window->destroyed)
1434 if (GDK_WINDOW_IS_MAPPED (window))
1435 gdk_synthesize_window_state (window,
1437 GDK_WINDOW_STATE_WITHDRAWN);
1439 g_assert (!GDK_WINDOW_IS_MAPPED (window));
1443 XWithdrawWindow (GDK_WINDOW_XDISPLAY (window),
1444 GDK_WINDOW_XID (window), 0);
1446 post_unmap (window);
1451 window_x11_move (GdkWindow *window,
1455 GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
1457 if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD)
1459 _gdk_x11_window_move_resize_child (window,
1461 window->width, window->height);
1465 XMoveWindow (GDK_WINDOW_XDISPLAY (window),
1466 GDK_WINDOW_XID (window),
1469 if (impl->override_redirect)
1478 window_x11_resize (GdkWindow *window,
1488 if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD)
1490 _gdk_x11_window_move_resize_child (window,
1491 window->x, window->y,
1496 GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
1498 XResizeWindow (GDK_WINDOW_XDISPLAY (window),
1499 GDK_WINDOW_XID (window),
1502 if (impl->override_redirect)
1504 window->width = width;
1505 window->height = height;
1506 _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl));
1510 if (width != window->width || height != window->height)
1511 window->resize_count += 1;
1515 _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl));
1519 window_x11_move_resize (GdkWindow *window,
1531 if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD)
1533 _gdk_x11_window_move_resize_child (window, x, y, width, height);
1534 _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl));
1538 GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
1540 XMoveResizeWindow (GDK_WINDOW_XDISPLAY (window),
1541 GDK_WINDOW_XID (window),
1542 x, y, width, height);
1544 if (impl->override_redirect)
1549 window->width = width;
1550 window->height = height;
1552 _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl));
1556 if (width != window->width || height != window->height)
1557 window->resize_count += 1;
1563 gdk_window_x11_move_resize (GdkWindow *window,
1570 if (with_move && (width < 0 && height < 0))
1571 window_x11_move (window, x, y);
1575 window_x11_move_resize (window, x, y, width, height);
1577 window_x11_resize (window, width, height);
1582 gdk_window_x11_reparent (GdkWindow *window,
1583 GdkWindow *new_parent,
1587 GdkWindowImplX11 *impl;
1589 impl = GDK_WINDOW_IMPL_X11 (window->impl);
1591 _gdk_x11_window_tmp_unset_bg (window, TRUE);
1592 _gdk_x11_window_tmp_unset_parent_bg (window);
1593 XReparentWindow (GDK_WINDOW_XDISPLAY (window),
1594 GDK_WINDOW_XID (window),
1595 GDK_WINDOW_XID (new_parent),
1596 new_parent->abs_x + x, new_parent->abs_y + y);
1597 _gdk_x11_window_tmp_reset_parent_bg (window);
1598 _gdk_x11_window_tmp_reset_bg (window, TRUE);
1600 if (GDK_WINDOW_TYPE (new_parent) == GDK_WINDOW_FOREIGN)
1601 new_parent = gdk_screen_get_root_window (GDK_WINDOW_SCREEN (window));
1603 window->parent = new_parent;
1605 /* Switch the window type as appropriate */
1607 switch (GDK_WINDOW_TYPE (new_parent))
1609 case GDK_WINDOW_ROOT:
1610 case GDK_WINDOW_FOREIGN:
1611 /* Reparenting to toplevel */
1613 if (!WINDOW_IS_TOPLEVEL (window) &&
1614 GDK_WINDOW_TYPE (new_parent) == GDK_WINDOW_FOREIGN)
1616 /* This is also done in common code at a later stage, but we
1617 need it in setup_toplevel, so do it here too */
1618 if (window->toplevel_window_type != -1)
1619 GDK_WINDOW_TYPE (window) = window->toplevel_window_type;
1620 else if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD)
1621 GDK_WINDOW_TYPE (window) = GDK_WINDOW_TOPLEVEL;
1623 /* Wasn't a toplevel, set up */
1624 setup_toplevel_window (window, new_parent);
1629 case GDK_WINDOW_TOPLEVEL:
1630 case GDK_WINDOW_CHILD:
1631 case GDK_WINDOW_TEMP:
1632 if (WINDOW_IS_TOPLEVEL (window) &&
1635 if (impl->toplevel->focus_window)
1637 XDestroyWindow (GDK_WINDOW_XDISPLAY (window), impl->toplevel->focus_window);
1638 _gdk_x11_display_remove_window (GDK_WINDOW_DISPLAY (window), impl->toplevel->focus_window);
1641 gdk_toplevel_x11_free_contents (GDK_WINDOW_DISPLAY (window),
1643 g_free (impl->toplevel);
1644 impl->toplevel = NULL;
1652 gdk_window_x11_raise (GdkWindow *window)
1654 XRaiseWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
1658 gdk_window_x11_restack_under (GdkWindow *window,
1659 GList *native_siblings /* in requested order, first is bottom-most */)
1665 n_windows = g_list_length (native_siblings) + 1;
1666 windows = g_new (Window, n_windows);
1668 windows[0] = GDK_WINDOW_XID (window);
1669 /* Reverse order, as input order is bottom-most first */
1671 for (l = native_siblings; l != NULL; l = l->next)
1672 windows[i--] = GDK_WINDOW_XID (l->data);
1674 XRestackWindows (GDK_WINDOW_XDISPLAY (window), windows, n_windows);
1680 gdk_window_x11_restack_toplevel (GdkWindow *window,
1684 XWindowChanges changes;
1686 changes.sibling = GDK_WINDOW_XID (sibling);
1687 changes.stack_mode = above ? Above : Below;
1688 XReconfigureWMWindow (GDK_WINDOW_XDISPLAY (window),
1689 GDK_WINDOW_XID (window),
1690 gdk_screen_get_number (GDK_WINDOW_SCREEN (window)),
1691 CWStackMode | CWSibling, &changes);
1695 gdk_window_x11_lower (GdkWindow *window)
1697 XLowerWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
1701 * gdk_x11_window_move_to_current_desktop:
1702 * @window: (type GdkX11Window): a #GdkWindow
1704 * Moves the window to the correct workspace when running under a
1705 * window manager that supports multiple workspaces, as described
1706 * in the <ulink url="http://www.freedesktop.org/Standards/wm-spec">Extended
1707 * Window Manager Hints</ulink>. Will not do anything if the
1708 * window is already on all workspaces.
1713 gdk_x11_window_move_to_current_desktop (GdkWindow *window)
1715 GdkToplevelX11 *toplevel;
1717 g_return_if_fail (GDK_IS_WINDOW (window));
1718 g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD);
1720 toplevel = _gdk_x11_window_get_toplevel (window);
1722 if (toplevel->on_all_desktops)
1725 move_to_current_desktop (window);
1729 move_to_current_desktop (GdkWindow *window)
1731 if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
1732 gdk_atom_intern_static_string ("_NET_WM_DESKTOP")))
1739 gulong *current_desktop;
1740 GdkDisplay *display;
1742 display = gdk_window_get_display (window);
1744 /* Get current desktop, then set it; this is a race, but not
1745 * one that matters much in practice.
1747 XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display),
1748 GDK_WINDOW_XROOTWIN (window),
1749 gdk_x11_get_xatom_by_name_for_display (display, "_NET_CURRENT_DESKTOP"),
1751 False, XA_CARDINAL, &type, &format, &nitems,
1752 &bytes_after, &data);
1754 if (type == XA_CARDINAL)
1756 XClientMessageEvent xclient;
1757 current_desktop = (gulong *)data;
1759 memset (&xclient, 0, sizeof (xclient));
1760 xclient.type = ClientMessage;
1762 xclient.send_event = True;
1763 xclient.window = GDK_WINDOW_XID (window);
1764 xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP");
1765 xclient.format = 32;
1767 xclient.data.l[0] = *current_desktop;
1768 xclient.data.l[1] = 1; /* source indication */
1769 xclient.data.l[2] = 0;
1770 xclient.data.l[3] = 0;
1771 xclient.data.l[4] = 0;
1773 XSendEvent (GDK_DISPLAY_XDISPLAY (display),
1774 GDK_WINDOW_XROOTWIN (window),
1776 SubstructureRedirectMask | SubstructureNotifyMask,
1777 (XEvent *)&xclient);
1779 XFree (current_desktop);
1785 gdk_x11_window_focus (GdkWindow *window,
1788 GdkDisplay *display;
1790 g_return_if_fail (GDK_IS_WINDOW (window));
1792 if (GDK_WINDOW_DESTROYED (window) ||
1793 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
1796 display = GDK_WINDOW_DISPLAY (window);
1798 if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
1799 gdk_atom_intern_static_string ("_NET_ACTIVE_WINDOW")))
1801 XClientMessageEvent xclient;
1803 memset (&xclient, 0, sizeof (xclient));
1804 xclient.type = ClientMessage;
1805 xclient.window = GDK_WINDOW_XID (window);
1806 xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display,
1807 "_NET_ACTIVE_WINDOW");
1808 xclient.format = 32;
1809 xclient.data.l[0] = 1; /* requestor type; we're an app */
1810 xclient.data.l[1] = timestamp;
1811 xclient.data.l[2] = None; /* currently active window */
1812 xclient.data.l[3] = 0;
1813 xclient.data.l[4] = 0;
1815 XSendEvent (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XROOTWIN (window), False,
1816 SubstructureRedirectMask | SubstructureNotifyMask,
1817 (XEvent *)&xclient);
1821 XRaiseWindow (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window));
1823 /* There is no way of knowing reliably whether we are viewable;
1824 * so trap errors asynchronously around the XSetInputFocus call
1826 gdk_x11_display_error_trap_push (display);
1827 XSetInputFocus (GDK_DISPLAY_XDISPLAY (display),
1828 GDK_WINDOW_XID (window),
1831 gdk_x11_display_error_trap_pop_ignored (display);
1836 gdk_x11_window_set_type_hint (GdkWindow *window,
1837 GdkWindowTypeHint hint)
1839 GdkDisplay *display;
1842 if (GDK_WINDOW_DESTROYED (window) ||
1843 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
1846 display = gdk_window_get_display (window);
1850 case GDK_WINDOW_TYPE_HINT_DIALOG:
1851 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DIALOG");
1853 case GDK_WINDOW_TYPE_HINT_MENU:
1854 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_MENU");
1856 case GDK_WINDOW_TYPE_HINT_TOOLBAR:
1857 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_TOOLBAR");
1859 case GDK_WINDOW_TYPE_HINT_UTILITY:
1860 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_UTILITY");
1862 case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
1863 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_SPLASH");
1865 case GDK_WINDOW_TYPE_HINT_DOCK:
1866 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DOCK");
1868 case GDK_WINDOW_TYPE_HINT_DESKTOP:
1869 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DESKTOP");
1871 case GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU:
1872 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU");
1874 case GDK_WINDOW_TYPE_HINT_POPUP_MENU:
1875 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_POPUP_MENU");
1877 case GDK_WINDOW_TYPE_HINT_TOOLTIP:
1878 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_TOOLTIP");
1880 case GDK_WINDOW_TYPE_HINT_NOTIFICATION:
1881 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_NOTIFICATION");
1883 case GDK_WINDOW_TYPE_HINT_COMBO:
1884 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_COMBO");
1886 case GDK_WINDOW_TYPE_HINT_DND:
1887 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DND");
1890 g_warning ("Unknown hint %d passed to gdk_window_set_type_hint", hint);
1892 case GDK_WINDOW_TYPE_HINT_NORMAL:
1893 atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_NORMAL");
1897 XChangeProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
1898 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE"),
1899 XA_ATOM, 32, PropModeReplace,
1900 (guchar *)&atom, 1);
1903 static GdkWindowTypeHint
1904 gdk_x11_window_get_type_hint (GdkWindow *window)
1906 GdkDisplay *display;
1907 GdkWindowTypeHint type;
1910 gulong nitems_return;
1911 gulong bytes_after_return;
1912 guchar *data = NULL;
1914 g_return_val_if_fail (GDK_IS_WINDOW (window), GDK_WINDOW_TYPE_HINT_NORMAL);
1916 if (GDK_WINDOW_DESTROYED (window) ||
1917 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
1918 return GDK_WINDOW_TYPE_HINT_NORMAL;
1920 type = GDK_WINDOW_TYPE_HINT_NORMAL;
1922 display = gdk_window_get_display (window);
1924 if (XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
1925 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE"),
1926 0, G_MAXLONG, False, XA_ATOM, &type_return,
1927 &format_return, &nitems_return, &bytes_after_return,
1930 if ((type_return == XA_ATOM) && (format_return == 32) &&
1931 (data) && (nitems_return == 1))
1933 Atom atom = *(Atom*)data;
1935 if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DIALOG"))
1936 type = GDK_WINDOW_TYPE_HINT_DIALOG;
1937 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_MENU"))
1938 type = GDK_WINDOW_TYPE_HINT_MENU;
1939 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_TOOLBAR"))
1940 type = GDK_WINDOW_TYPE_HINT_TOOLBAR;
1941 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_UTILITY"))
1942 type = GDK_WINDOW_TYPE_HINT_UTILITY;
1943 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_SPLASH"))
1944 type = GDK_WINDOW_TYPE_HINT_SPLASHSCREEN;
1945 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DOCK"))
1946 type = GDK_WINDOW_TYPE_HINT_DOCK;
1947 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DESKTOP"))
1948 type = GDK_WINDOW_TYPE_HINT_DESKTOP;
1949 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU"))
1950 type = GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU;
1951 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_POPUP_MENU"))
1952 type = GDK_WINDOW_TYPE_HINT_POPUP_MENU;
1953 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_TOOLTIP"))
1954 type = GDK_WINDOW_TYPE_HINT_TOOLTIP;
1955 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_NOTIFICATION"))
1956 type = GDK_WINDOW_TYPE_HINT_NOTIFICATION;
1957 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_COMBO"))
1958 type = GDK_WINDOW_TYPE_HINT_COMBO;
1959 else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DND"))
1960 type = GDK_WINDOW_TYPE_HINT_DND;
1963 if (type_return != None && data != NULL)
1971 gdk_wmspec_change_state (gboolean add,
1976 GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
1977 XClientMessageEvent xclient;
1979 #define _NET_WM_STATE_REMOVE 0 /* remove/unset property */
1980 #define _NET_WM_STATE_ADD 1 /* add/set property */
1981 #define _NET_WM_STATE_TOGGLE 2 /* toggle property */
1983 memset (&xclient, 0, sizeof (xclient));
1984 xclient.type = ClientMessage;
1985 xclient.window = GDK_WINDOW_XID (window);
1986 xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE");
1987 xclient.format = 32;
1988 xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
1989 xclient.data.l[1] = gdk_x11_atom_to_xatom_for_display (display, state1);
1990 xclient.data.l[2] = gdk_x11_atom_to_xatom_for_display (display, state2);
1991 xclient.data.l[3] = 1; /* source indication */
1992 xclient.data.l[4] = 0;
1994 XSendEvent (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XROOTWIN (window), False,
1995 SubstructureRedirectMask | SubstructureNotifyMask,
1996 (XEvent *)&xclient);
2000 gdk_x11_window_set_modal_hint (GdkWindow *window,
2003 if (GDK_WINDOW_DESTROYED (window) ||
2004 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
2007 window->modal_hint = modal;
2009 if (GDK_WINDOW_IS_MAPPED (window))
2010 gdk_wmspec_change_state (modal, window,
2011 gdk_atom_intern_static_string ("_NET_WM_STATE_MODAL"),
2016 gdk_x11_window_set_skip_taskbar_hint (GdkWindow *window,
2017 gboolean skips_taskbar)
2019 GdkToplevelX11 *toplevel;
2021 g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD);
2023 if (GDK_WINDOW_DESTROYED (window) ||
2024 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
2027 toplevel = _gdk_x11_window_get_toplevel (window);
2028 toplevel->skip_taskbar_hint = skips_taskbar;
2030 if (GDK_WINDOW_IS_MAPPED (window))
2031 gdk_wmspec_change_state (skips_taskbar, window,
2032 gdk_atom_intern_static_string ("_NET_WM_STATE_SKIP_TASKBAR"),
2037 gdk_x11_window_set_skip_pager_hint (GdkWindow *window,
2038 gboolean skips_pager)
2040 GdkToplevelX11 *toplevel;
2042 g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD);
2044 if (GDK_WINDOW_DESTROYED (window) ||
2045 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
2048 toplevel = _gdk_x11_window_get_toplevel (window);
2049 toplevel->skip_pager_hint = skips_pager;
2051 if (GDK_WINDOW_IS_MAPPED (window))
2052 gdk_wmspec_change_state (skips_pager, window,
2053 gdk_atom_intern_static_string ("_NET_WM_STATE_SKIP_PAGER"),
2058 gdk_x11_window_set_urgency_hint (GdkWindow *window,
2061 GdkToplevelX11 *toplevel;
2063 g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD);
2065 if (GDK_WINDOW_DESTROYED (window) ||
2066 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
2069 toplevel = _gdk_x11_window_get_toplevel (window);
2070 toplevel->urgency_hint = urgent;
2072 update_wm_hints (window, FALSE);
2076 gdk_x11_window_set_geometry_hints (GdkWindow *window,
2077 const GdkGeometry *geometry,
2078 GdkWindowHints geom_mask)
2080 XSizeHints size_hints;
2082 if (GDK_WINDOW_DESTROYED (window) ||
2083 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
2086 size_hints.flags = 0;
2088 if (geom_mask & GDK_HINT_POS)
2090 size_hints.flags |= PPosition;
2091 /* We need to initialize the following obsolete fields because KWM
2092 * apparently uses these fields if they are non-zero.
2099 if (geom_mask & GDK_HINT_USER_POS)
2101 size_hints.flags |= USPosition;
2104 if (geom_mask & GDK_HINT_USER_SIZE)
2106 size_hints.flags |= USSize;
2109 if (geom_mask & GDK_HINT_MIN_SIZE)
2111 size_hints.flags |= PMinSize;
2112 size_hints.min_width = geometry->min_width;
2113 size_hints.min_height = geometry->min_height;
2116 if (geom_mask & GDK_HINT_MAX_SIZE)
2118 size_hints.flags |= PMaxSize;
2119 size_hints.max_width = MAX (geometry->max_width, 1);
2120 size_hints.max_height = MAX (geometry->max_height, 1);
2123 if (geom_mask & GDK_HINT_BASE_SIZE)
2125 size_hints.flags |= PBaseSize;
2126 size_hints.base_width = geometry->base_width;
2127 size_hints.base_height = geometry->base_height;
2130 if (geom_mask & GDK_HINT_RESIZE_INC)
2132 size_hints.flags |= PResizeInc;
2133 size_hints.width_inc = geometry->width_inc;
2134 size_hints.height_inc = geometry->height_inc;
2137 if (geom_mask & GDK_HINT_ASPECT)
2139 size_hints.flags |= PAspect;
2140 if (geometry->min_aspect <= 1)
2142 size_hints.min_aspect.x = 65536 * geometry->min_aspect;
2143 size_hints.min_aspect.y = 65536;
2147 size_hints.min_aspect.x = 65536;
2148 size_hints.min_aspect.y = 65536 / geometry->min_aspect;;
2150 if (geometry->max_aspect <= 1)
2152 size_hints.max_aspect.x = 65536 * geometry->max_aspect;
2153 size_hints.max_aspect.y = 65536;
2157 size_hints.max_aspect.x = 65536;
2158 size_hints.max_aspect.y = 65536 / geometry->max_aspect;;
2162 if (geom_mask & GDK_HINT_WIN_GRAVITY)
2164 size_hints.flags |= PWinGravity;
2165 size_hints.win_gravity = geometry->win_gravity;
2168 /* FIXME: Would it be better to delete this property if
2169 * geom_mask == 0? It would save space on the server
2171 XSetWMNormalHints (GDK_WINDOW_XDISPLAY (window),
2172 GDK_WINDOW_XID (window),
2177 gdk_window_get_geometry_hints (GdkWindow *window,
2178 GdkGeometry *geometry,
2179 GdkWindowHints *geom_mask)
2181 XSizeHints *size_hints;
2182 glong junk_supplied_mask = 0;
2184 g_return_if_fail (GDK_IS_WINDOW (window));
2185 g_return_if_fail (geometry != NULL);
2186 g_return_if_fail (geom_mask != NULL);
2190 if (GDK_WINDOW_DESTROYED (window) ||
2191 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
2194 size_hints = XAllocSizeHints ();
2198 if (!XGetWMNormalHints (GDK_WINDOW_XDISPLAY (window),
2199 GDK_WINDOW_XID (window),
2201 &junk_supplied_mask))
2202 size_hints->flags = 0;
2204 if (size_hints->flags & PMinSize)
2206 *geom_mask |= GDK_HINT_MIN_SIZE;
2207 geometry->min_width = size_hints->min_width;
2208 geometry->min_height = size_hints->min_height;
2211 if (size_hints->flags & PMaxSize)
2213 *geom_mask |= GDK_HINT_MAX_SIZE;
2214 geometry->max_width = MAX (size_hints->max_width, 1);
2215 geometry->max_height = MAX (size_hints->max_height, 1);
2218 if (size_hints->flags & PResizeInc)
2220 *geom_mask |= GDK_HINT_RESIZE_INC;
2221 geometry->width_inc = size_hints->width_inc;
2222 geometry->height_inc = size_hints->height_inc;
2225 if (size_hints->flags & PAspect)
2227 *geom_mask |= GDK_HINT_ASPECT;
2229 geometry->min_aspect = (gdouble) size_hints->min_aspect.x / (gdouble) size_hints->min_aspect.y;
2230 geometry->max_aspect = (gdouble) size_hints->max_aspect.x / (gdouble) size_hints->max_aspect.y;
2233 if (size_hints->flags & PWinGravity)
2235 *geom_mask |= GDK_HINT_WIN_GRAVITY;
2236 geometry->win_gravity = size_hints->win_gravity;
2243 utf8_is_latin1 (const gchar *str)
2245 const char *p = str;
2249 gunichar ch = g_utf8_get_char (p);
2254 p = g_utf8_next_char (p);
2260 /* Set the property to @utf8_str as STRING if the @utf8_str is fully
2261 * convertable to STRING, otherwise, set it as compound text
2264 set_text_property (GdkDisplay *display,
2267 const gchar *utf8_str)
2269 gchar *prop_text = NULL;
2273 gboolean is_compound_text;
2275 if (utf8_is_latin1 (utf8_str))
2277 prop_type = XA_STRING;
2278 prop_text = _gdk_x11_display_utf8_to_string_target (display, utf8_str);
2279 prop_length = prop_text ? strlen (prop_text) : 0;
2281 is_compound_text = FALSE;
2287 gdk_x11_display_utf8_to_compound_text (display,
2288 utf8_str, &gdk_type, &prop_format,
2289 (guchar **)&prop_text, &prop_length);
2290 prop_type = gdk_x11_atom_to_xatom_for_display (display, gdk_type);
2291 is_compound_text = TRUE;
2296 XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
2299 prop_type, prop_format,
2300 PropModeReplace, (guchar *)prop_text,
2303 if (is_compound_text)
2304 gdk_x11_free_compound_text ((guchar *)prop_text);
2310 /* Set WM_NAME and _NET_WM_NAME
2313 set_wm_name (GdkDisplay *display,
2317 XChangeProperty (GDK_DISPLAY_XDISPLAY (display), xwindow,
2318 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_NAME"),
2319 gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
2320 PropModeReplace, (guchar *)name, strlen (name));
2322 set_text_property (display, xwindow,
2323 gdk_x11_get_xatom_by_name_for_display (display, "WM_NAME"),
2328 gdk_x11_window_set_title (GdkWindow *window,
2331 GdkDisplay *display;
2335 g_return_if_fail (title != NULL);
2337 if (GDK_WINDOW_DESTROYED (window) ||
2338 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
2341 display = gdk_window_get_display (window);
2342 xdisplay = GDK_DISPLAY_XDISPLAY (display);
2343 xwindow = GDK_WINDOW_XID (window);
2345 set_wm_name (display, xwindow, title);
2347 if (!gdk_window_icon_name_set (window))
2349 XChangeProperty (xdisplay, xwindow,
2350 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON_NAME"),
2351 gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
2352 PropModeReplace, (guchar *)title, strlen (title));
2354 set_text_property (display, xwindow,
2355 gdk_x11_get_xatom_by_name_for_display (display, "WM_ICON_NAME"),
2361 gdk_x11_window_set_role (GdkWindow *window,
2364 GdkDisplay *display;
2366 display = gdk_window_get_display (window);
2368 if (GDK_WINDOW_DESTROYED (window) ||
2369 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
2373 XChangeProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
2374 gdk_x11_get_xatom_by_name_for_display (display, "WM_WINDOW_ROLE"),
2375 XA_STRING, 8, PropModeReplace, (guchar *)role, strlen (role));
2377 XDeleteProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
2378 gdk_x11_get_xatom_by_name_for_display (display, "WM_WINDOW_ROLE"));
2382 gdk_x11_window_set_startup_id (GdkWindow *window,
2383 const gchar *startup_id)
2385 GdkDisplay *display;
2387 g_return_if_fail (GDK_IS_WINDOW (window));
2389 display = gdk_window_get_display (window);
2391 if (GDK_WINDOW_DESTROYED (window) ||
2392 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
2396 XChangeProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
2397 gdk_x11_get_xatom_by_name_for_display (display, "_NET_STARTUP_ID"),
2398 gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
2399 PropModeReplace, (unsigned char *)startup_id, strlen (startup_id));
2401 XDeleteProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
2402 gdk_x11_get_xatom_by_name_for_display (display, "_NET_STARTUP_ID"));
2406 gdk_x11_window_set_transient_for (GdkWindow *window,
2409 if (!GDK_WINDOW_DESTROYED (window) && !GDK_WINDOW_DESTROYED (parent) &&
2410 WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
2411 XSetTransientForHint (GDK_WINDOW_XDISPLAY (window),
2412 GDK_WINDOW_XID (window),
2413 GDK_WINDOW_XID (parent));
2417 gdk_window_x11_set_back_color (GdkWindow *window,
2423 GdkVisual *visual = gdk_window_get_visual (window);
2425 /* I suppose we could handle these, but that'd require fiddling with
2426 * xrender formats... */
2430 switch (visual->type)
2432 case GDK_VISUAL_DIRECT_COLOR:
2433 case GDK_VISUAL_TRUE_COLOR:
2435 /* If bits not used for color are used for something other than padding,
2436 * it's likely alpha, so we set them to 1s.
2438 guint padding, pixel;
2440 /* Shifting by >= width-of-type isn't defined in C */
2441 if (visual->depth >= 32)
2444 padding = ((~(guint32)0)) << visual->depth;
2446 pixel = ~ (visual->red_mask | visual->green_mask | visual->blue_mask | padding);
2448 pixel += (((int) (red * ((1 << visual->red_prec ) - 1))) << visual->red_shift ) +
2449 (((int) (green * ((1 << visual->green_prec) - 1))) << visual->green_shift) +
2450 (((int) (blue * ((1 << visual->blue_prec ) - 1))) << visual->blue_shift );
2452 XSetWindowBackground (GDK_WINDOW_XDISPLAY (window),
2453 GDK_WINDOW_XID (window), pixel);
2457 /* These require fiddling with the colormap, and as they're essentially unused
2458 * we're just gonna skip them for now.
2460 case GDK_VISUAL_PSEUDO_COLOR:
2461 case GDK_VISUAL_GRAYSCALE:
2462 case GDK_VISUAL_STATIC_GRAY:
2463 case GDK_VISUAL_STATIC_COLOR:
2472 matrix_is_identity (cairo_matrix_t *matrix)
2474 return matrix->xx == 1.0 && matrix->yy == 1.0 &&
2475 matrix->yx == 0.0 && matrix->xy == 0.0 &&
2476 matrix->x0 == 0.0 && matrix->y0 == 0.0;
2480 gdk_window_x11_set_background (GdkWindow *window,
2481 cairo_pattern_t *pattern)
2484 cairo_surface_t *surface;
2485 cairo_matrix_t matrix;
2487 if (GDK_WINDOW_DESTROYED (window))
2490 if (pattern == NULL)
2494 /* X throws BadMatch if the parent has a different visual when
2495 * using ParentRelative */
2496 parent = gdk_window_get_parent (window);
2497 if (parent && gdk_window_get_visual (parent) == gdk_window_get_visual (window))
2498 XSetWindowBackgroundPixmap (GDK_WINDOW_XDISPLAY (window),
2499 GDK_WINDOW_XID (window), ParentRelative);
2501 XSetWindowBackgroundPixmap (GDK_WINDOW_XDISPLAY (window),
2502 GDK_WINDOW_XID (window), None);
2506 switch (cairo_pattern_get_type (pattern))
2508 case CAIRO_PATTERN_TYPE_SOLID:
2509 cairo_pattern_get_rgba (pattern, &r, &g, &b, &a);
2510 if (gdk_window_x11_set_back_color (window, r, g, b, a))
2513 case CAIRO_PATTERN_TYPE_SURFACE:
2514 cairo_pattern_get_matrix (pattern, &matrix);
2515 if (cairo_pattern_get_surface (pattern, &surface) == CAIRO_STATUS_SUCCESS &&
2516 matrix_is_identity (&matrix) &&
2517 cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_XLIB &&
2518 cairo_xlib_surface_get_visual (surface) == GDK_VISUAL_XVISUAL (gdk_window_get_visual ((window))) &&
2519 cairo_xlib_surface_get_display (surface) == GDK_WINDOW_XDISPLAY (window))
2523 cairo_surface_get_device_offset (surface, &x, &y);
2524 /* XXX: This still bombs for non-pixmaps, but there's no way to
2525 * detect we're not a pixmap in Cairo... */
2526 if (x == 0.0 && y == 0.0)
2528 XSetWindowBackgroundPixmap (GDK_WINDOW_XDISPLAY (window),
2529 GDK_WINDOW_XID (window),
2530 cairo_xlib_surface_get_drawable (surface));
2535 case CAIRO_PATTERN_TYPE_LINEAR:
2536 case CAIRO_PATTERN_TYPE_RADIAL:
2538 /* fallback: just use black */
2542 XSetWindowBackgroundPixmap (GDK_WINDOW_XDISPLAY (window),
2543 GDK_WINDOW_XID (window), None);
2547 gdk_window_x11_set_device_cursor (GdkWindow *window,
2551 GdkWindowImplX11 *impl;
2553 g_return_if_fail (GDK_IS_WINDOW (window));
2554 g_return_if_fail (GDK_IS_DEVICE (device));
2556 impl = GDK_WINDOW_IMPL_X11 (window->impl);
2559 g_hash_table_remove (impl->device_cursor, device);
2562 _gdk_x11_cursor_update_theme (cursor);
2563 g_hash_table_replace (impl->device_cursor,
2564 device, g_object_ref (cursor));
2567 if (!GDK_WINDOW_DESTROYED (window))
2568 GDK_DEVICE_GET_CLASS (device)->set_window_cursor (device, window, cursor);
2572 _gdk_x11_window_get_cursor (GdkWindow *window)
2574 GdkWindowImplX11 *impl;
2576 g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
2578 impl = GDK_WINDOW_IMPL_X11 (window->impl);
2580 return impl->cursor;
2584 gdk_window_x11_get_geometry (GdkWindow *window,
2595 guint tborder_width;
2598 if (!GDK_WINDOW_DESTROYED (window))
2600 XGetGeometry (GDK_WINDOW_XDISPLAY (window),
2601 GDK_WINDOW_XID (window),
2602 &root, &tx, &ty, &twidth, &theight, &tborder_width, &tdepth);
2616 gdk_window_x11_get_root_coords (GdkWindow *window,
2627 return_val = XTranslateCoordinates (GDK_WINDOW_XDISPLAY (window),
2628 GDK_WINDOW_XID (window),
2629 GDK_WINDOW_XROOTWIN (window),
2642 gdk_x11_window_get_root_origin (GdkWindow *window,
2648 gdk_window_get_frame_extents (window, &rect);
2658 gdk_x11_window_get_frame_extents (GdkWindow *window,
2661 GdkDisplay *display;
2662 GdkWindowImplX11 *impl;
2673 gulong nitems_return;
2674 gulong bytes_after_return;
2677 guint ww, wh, wb, wd;
2679 gboolean got_frame_extents = FALSE;
2681 g_return_if_fail (rect != NULL);
2688 while (window->parent && (window->parent)->parent)
2689 window = window->parent;
2691 /* Refine our fallback answer a bit using local information */
2692 rect->x = window->x;
2693 rect->y = window->y;
2694 rect->width = window->width;
2695 rect->height = window->height;
2697 impl = GDK_WINDOW_IMPL_X11 (window->impl);
2698 if (GDK_WINDOW_DESTROYED (window) || impl->override_redirect)
2704 display = gdk_window_get_display (window);
2706 gdk_x11_display_error_trap_push (display);
2708 xwindow = GDK_WINDOW_XID (window);
2710 /* first try: use _NET_FRAME_EXTENTS */
2711 if (XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), xwindow,
2712 gdk_x11_get_xatom_by_name_for_display (display,
2713 "_NET_FRAME_EXTENTS"),
2714 0, G_MAXLONG, False, XA_CARDINAL, &type_return,
2715 &format_return, &nitems_return, &bytes_after_return,
2719 if ((type_return == XA_CARDINAL) && (format_return == 32) &&
2720 (nitems_return == 4) && (data))
2722 gulong *ldata = (gulong *) data;
2723 got_frame_extents = TRUE;
2725 /* try to get the real client window geometry */
2726 if (XGetGeometry (GDK_DISPLAY_XDISPLAY (display), xwindow,
2727 &root, &wx, &wy, &ww, &wh, &wb, &wd) &&
2728 XTranslateCoordinates (GDK_DISPLAY_XDISPLAY (display),
2729 xwindow, root, 0, 0, &wx, &wy, &child))
2737 /* _NET_FRAME_EXTENTS format is left, right, top, bottom */
2738 rect->x -= ldata[0];
2739 rect->y -= ldata[2];
2740 rect->width += ldata[0] + ldata[1];
2741 rect->height += ldata[2] + ldata[3];
2748 if (got_frame_extents)
2751 /* no frame extents property available, which means we either have a WM that
2752 is not EWMH compliant or is broken - try fallback and walk up the window
2753 tree to get our window's parent which hopefully is the window frame */
2755 /* use NETWM_VIRTUAL_ROOTS if available */
2756 root = GDK_WINDOW_XROOTWIN (window);
2758 if (XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), root,
2759 gdk_x11_get_xatom_by_name_for_display (display,
2760 "_NET_VIRTUAL_ROOTS"),
2761 0, G_MAXLONG, False, XA_WINDOW, &type_return,
2762 &format_return, &nitems_return, &bytes_after_return,
2766 if ((type_return == XA_WINDOW) && (format_return == 32) && (data))
2768 nvroots = nitems_return;
2769 vroots = (Window *)data;
2773 xparent = GDK_WINDOW_XID (window);
2779 if (!XQueryTree (GDK_DISPLAY_XDISPLAY (display), xwindow,
2781 &children, &nchildren))
2787 /* check virtual roots */
2788 for (i = 0; i < nvroots; i++)
2790 if (xparent == vroots[i])
2797 while (xparent != root);
2799 if (XGetGeometry (GDK_DISPLAY_XDISPLAY (display), xwindow,
2800 &root, &wx, &wy, &ww, &wh, &wb, &wd))
2812 gdk_x11_display_error_trap_pop_ignored (display);
2816 gdk_window_x11_get_device_state (GdkWindow *window,
2820 GdkModifierType *mask)
2824 g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), FALSE);
2826 if (GDK_WINDOW_DESTROYED (window))
2829 GDK_DEVICE_GET_CLASS (device)->query_state (device, window,
2833 return child != NULL;
2837 gdk_window_x11_get_events (GdkWindow *window)
2839 XWindowAttributes attrs;
2840 GdkEventMask event_mask;
2841 GdkEventMask filtered;
2843 if (GDK_WINDOW_DESTROYED (window))
2847 XGetWindowAttributes (GDK_WINDOW_XDISPLAY (window),
2848 GDK_WINDOW_XID (window),
2850 event_mask = x_event_mask_to_gdk_event_mask (attrs.your_event_mask);
2851 /* if property change was filtered out before, keep it filtered out */
2852 filtered = GDK_STRUCTURE_MASK | GDK_PROPERTY_CHANGE_MASK;
2853 window->event_mask = event_mask & ((window->event_mask & filtered) | ~filtered);
2859 gdk_window_x11_set_events (GdkWindow *window,
2860 GdkEventMask event_mask)
2862 long xevent_mask = 0;
2864 if (!GDK_WINDOW_DESTROYED (window))
2866 GdkX11Display *display_x11;
2868 if (GDK_WINDOW_XID (window) != GDK_WINDOW_XROOTWIN (window))
2869 xevent_mask = StructureNotifyMask | PropertyChangeMask;
2871 display_x11 = GDK_X11_DISPLAY (gdk_window_get_display (window));
2872 gdk_x11_event_source_select_events ((GdkEventSource *) display_x11->event_source,
2873 GDK_WINDOW_XID (window), event_mask,
2879 do_shape_combine_region (GdkWindow *window,
2880 const cairo_region_t *shape_region,
2885 if (GDK_WINDOW_DESTROYED (window))
2888 if (shape_region == NULL)
2890 /* Use NULL mask to unset the shape */
2891 if (shape == ShapeBounding
2892 ? gdk_display_supports_shapes (GDK_WINDOW_DISPLAY (window))
2893 : gdk_display_supports_input_shapes (GDK_WINDOW_DISPLAY (window)))
2895 if (shape == ShapeBounding)
2897 _gdk_x11_window_tmp_unset_parent_bg (window);
2898 _gdk_x11_window_tmp_unset_bg (window, TRUE);
2900 XShapeCombineMask (GDK_WINDOW_XDISPLAY (window),
2901 GDK_WINDOW_XID (window),
2906 if (shape == ShapeBounding)
2908 _gdk_x11_window_tmp_reset_parent_bg (window);
2909 _gdk_x11_window_tmp_reset_bg (window, TRUE);
2915 if (shape == ShapeBounding
2916 ? gdk_display_supports_shapes (GDK_WINDOW_DISPLAY (window))
2917 : gdk_display_supports_input_shapes (GDK_WINDOW_DISPLAY (window)))
2920 XRectangle *xrects = NULL;
2922 _gdk_x11_region_get_xrectangles (shape_region,
2926 if (shape == ShapeBounding)
2928 _gdk_x11_window_tmp_unset_parent_bg (window);
2929 _gdk_x11_window_tmp_unset_bg (window, TRUE);
2931 XShapeCombineRectangles (GDK_WINDOW_XDISPLAY (window),
2932 GDK_WINDOW_XID (window),
2939 if (shape == ShapeBounding)
2941 _gdk_x11_window_tmp_reset_parent_bg (window);
2942 _gdk_x11_window_tmp_reset_bg (window, TRUE);
2950 gdk_window_x11_shape_combine_region (GdkWindow *window,
2951 const cairo_region_t *shape_region,
2955 do_shape_combine_region (window, shape_region, offset_x, offset_y, ShapeBounding);
2959 gdk_window_x11_input_shape_combine_region (GdkWindow *window,
2960 const cairo_region_t *shape_region,
2965 do_shape_combine_region (window, shape_region, offset_x, offset_y, ShapeInput);
2971 gdk_x11_window_set_override_redirect (GdkWindow *window,
2972 gboolean override_redirect)
2974 XSetWindowAttributes attr;
2976 if (!GDK_WINDOW_DESTROYED (window) &&
2977 WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
2979 GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
2981 attr.override_redirect = (override_redirect? True : False);
2982 XChangeWindowAttributes (GDK_WINDOW_XDISPLAY (window),
2983 GDK_WINDOW_XID (window),
2987 impl->override_redirect = attr.override_redirect;
2992 gdk_x11_window_set_accept_focus (GdkWindow *window,
2993 gboolean accept_focus)
2995 accept_focus = accept_focus != FALSE;
2997 if (window->accept_focus != accept_focus)
2999 window->accept_focus = accept_focus;
3001 if (!GDK_WINDOW_DESTROYED (window) &&
3002 WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3003 update_wm_hints (window, FALSE);
3008 gdk_x11_window_set_focus_on_map (GdkWindow *window,
3009 gboolean focus_on_map)
3011 focus_on_map = focus_on_map != FALSE;
3013 if (window->focus_on_map != focus_on_map)
3015 window->focus_on_map = focus_on_map;
3017 if ((!GDK_WINDOW_DESTROYED (window)) &&
3018 (!window->focus_on_map) &&
3019 WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3020 gdk_x11_window_set_user_time (window, 0);
3025 * gdk_x11_window_set_user_time:
3026 * @window: (type GdkX11Window): A toplevel #GdkWindow
3027 * @timestamp: An XServer timestamp to which the property should be set
3029 * The application can use this call to update the _NET_WM_USER_TIME
3030 * property on a toplevel window. This property stores an Xserver
3031 * time which represents the time of the last user input event
3032 * received for this window. This property may be used by the window
3033 * manager to alter the focus, stacking, and/or placement behavior of
3034 * windows when they are mapped depending on whether the new window
3035 * was created by a user action or is a "pop-up" window activated by a
3036 * timer or some other event.
3038 * Note that this property is automatically updated by GDK, so this
3039 * function should only be used by applications which handle input
3040 * events bypassing GDK.
3045 gdk_x11_window_set_user_time (GdkWindow *window,
3048 GdkDisplay *display;
3049 GdkX11Display *display_x11;
3050 GdkToplevelX11 *toplevel;
3051 glong timestamp_long = (glong)timestamp;
3054 if (GDK_WINDOW_DESTROYED (window) ||
3055 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3058 display = gdk_window_get_display (window);
3059 display_x11 = GDK_X11_DISPLAY (display);
3060 toplevel = _gdk_x11_window_get_toplevel (window);
3064 g_warning ("gdk_window_set_user_time called on non-toplevel\n");
3068 if (toplevel->focus_window != None &&
3069 gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
3070 gdk_atom_intern_static_string ("_NET_WM_USER_TIME_WINDOW")))
3071 xid = toplevel->focus_window;
3073 xid = GDK_WINDOW_XID (window);
3075 XChangeProperty (GDK_DISPLAY_XDISPLAY (display), xid,
3076 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_USER_TIME"),
3077 XA_CARDINAL, 32, PropModeReplace,
3078 (guchar *)×tamp_long, 1);
3080 if (timestamp_long != GDK_CURRENT_TIME &&
3081 (display_x11->user_time == GDK_CURRENT_TIME ||
3082 XSERVER_TIME_IS_LATER (timestamp_long, display_x11->user_time)))
3083 display_x11->user_time = timestamp_long;
3086 toplevel->user_time = timestamp_long;
3090 * gdk_x11_window_set_utf8_property:
3091 * @window: (type GdkX11Window): a #GdkWindow
3092 * @name: Property name, will be interned as an X atom
3093 * @value: (allow-none): Property value, or %NULL to delete
3095 * This function modifies or removes an arbitrary X11 window
3096 * property of type UTF8_STRING. If the given @window is
3097 * not a toplevel window, it is ignored.
3100 gdk_x11_window_set_utf8_property (GdkWindow *window,
3104 GdkDisplay *display;
3106 if (!WINDOW_IS_TOPLEVEL (window))
3109 display = gdk_window_get_display (window);
3113 XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
3114 GDK_WINDOW_XID (window),
3115 gdk_x11_get_xatom_by_name_for_display (display, name),
3116 gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
3117 PropModeReplace, (guchar *)value, strlen (value));
3121 XDeleteProperty (GDK_DISPLAY_XDISPLAY (display),
3122 GDK_WINDOW_XID (window),
3123 gdk_x11_get_xatom_by_name_for_display (display, name));
3128 * gdk_x11_window_set_hide_titlebar_when_maximized:
3129 * @window: (type GdkX11Window): a #GdkWindow
3130 * @hide_titlebar_when_maximized: whether to hide the titlebar when
3133 * Set a hint for the window manager, requesting that the titlebar
3134 * should be hidden when the window is maximized.
3136 * Note that this property is automatically updated by GTK+, so this
3137 * function should only be used by applications which do not use GTK+
3138 * to create toplevel windows.
3143 gdk_x11_window_set_hide_titlebar_when_maximized (GdkWindow *window,
3144 gboolean hide_titlebar_when_maximized)
3146 GdkDisplay *display;
3148 if (!WINDOW_IS_TOPLEVEL (window))
3151 display = gdk_window_get_display (window);
3153 if (hide_titlebar_when_maximized)
3156 XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
3157 GDK_WINDOW_XID (window),
3158 gdk_x11_get_xatom_by_name_for_display (display, "_GTK_HIDE_TITLEBAR_WHEN_MAXIMIZED"),
3160 PropModeReplace, (guchar *)&hide, 1);
3164 XDeleteProperty (GDK_DISPLAY_XDISPLAY (display),
3165 GDK_WINDOW_XID (window),
3166 gdk_x11_get_xatom_by_name_for_display (display, "_GTK_HIDE_TITLEBAR_WHEN_MAXIMIZED"));
3171 * gdk_x11_window_set_theme_variant:
3172 * @window: (type GdkX11Window): a #GdkWindow
3173 * @variant: the theme variant to export
3175 * GTK+ applications can request a dark theme variant. In order to
3176 * make other applications - namely window managers using GTK+ for
3177 * themeing - aware of this choice, GTK+ uses this function to
3178 * export the requested theme variant as _GTK_THEME_VARIANT property
3179 * on toplevel windows.
3181 * Note that this property is automatically updated by GTK+, so this
3182 * function should only be used by applications which do not use GTK+
3183 * to create toplevel windows.
3188 gdk_x11_window_set_theme_variant (GdkWindow *window,
3191 return gdk_x11_window_set_utf8_property (window, "_GTK_THEME_VARIANT", variant);
3194 #define GDK_SELECTION_MAX_SIZE(display) \
3196 XExtendedMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) == 0 \
3197 ? XMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) - 100 \
3198 : XExtendedMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) - 100)
3201 gdk_window_update_icon (GdkWindow *window,
3204 GdkToplevelX11 *toplevel;
3205 GdkPixbuf *best_icon;
3209 toplevel = _gdk_x11_window_get_toplevel (window);
3211 if (toplevel->icon_pixmap != NULL)
3213 cairo_surface_destroy (toplevel->icon_pixmap);
3214 toplevel->icon_pixmap = NULL;
3217 if (toplevel->icon_mask != NULL)
3219 cairo_surface_destroy (toplevel->icon_mask);
3220 toplevel->icon_mask = NULL;
3223 #define IDEAL_SIZE 48
3225 best_size = G_MAXINT;
3227 for (tmp_list = icon_list; tmp_list; tmp_list = tmp_list->next)
3229 GdkPixbuf *pixbuf = tmp_list->data;
3232 /* average width and height - if someone passes in a rectangular
3233 * icon they deserve what they get.
3235 this = gdk_pixbuf_get_width (pixbuf) + gdk_pixbuf_get_height (pixbuf);
3238 if (best_icon == NULL)
3245 /* icon is better if it's 32 pixels or larger, and closer to
3246 * the ideal size than the current best.
3249 (ABS (best_size - IDEAL_SIZE) <
3250 ABS (this - IDEAL_SIZE)))
3260 int width = gdk_pixbuf_get_width (best_icon);
3261 int height = gdk_pixbuf_get_height (best_icon);
3264 toplevel->icon_pixmap = gdk_x11_window_create_pixmap_surface (window,
3268 cr = cairo_create (toplevel->icon_pixmap);
3269 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
3270 gdk_cairo_set_source_pixbuf (cr, best_icon, 0, 0);
3271 if (gdk_pixbuf_get_has_alpha (best_icon))
3273 /* Saturate the image, so it has bilevel alpha */
3274 cairo_push_group_with_content (cr, CAIRO_CONTENT_COLOR_ALPHA);
3276 cairo_set_operator (cr, CAIRO_OPERATOR_SATURATE);
3278 cairo_pop_group_to_source (cr);
3283 if (gdk_pixbuf_get_has_alpha (best_icon))
3285 toplevel->icon_mask = _gdk_x11_window_create_bitmap_surface (window,
3289 cr = cairo_create (toplevel->icon_mask);
3290 gdk_cairo_set_source_pixbuf (cr, best_icon, 0, 0);
3291 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
3297 update_wm_hints (window, FALSE);
3301 gdk_x11_window_set_icon_list (GdkWindow *window,
3310 gint width, height, stride;
3313 GdkDisplay *display;
3316 if (GDK_WINDOW_DESTROYED (window) ||
3317 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3320 display = gdk_window_get_display (window);
3328 g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
3330 width = gdk_pixbuf_get_width (pixbuf);
3331 height = gdk_pixbuf_get_height (pixbuf);
3333 /* silently ignore overlarge icons */
3334 if (size + 2 + width * height > GDK_SELECTION_MAX_SIZE(display))
3336 g_warning ("gdk_window_set_icon_list: icons too large");
3341 size += 2 + width * height;
3343 l = g_list_next (l);
3346 data = g_malloc (size * sizeof (gulong));
3354 width = gdk_pixbuf_get_width (pixbuf);
3355 height = gdk_pixbuf_get_height (pixbuf);
3356 stride = gdk_pixbuf_get_rowstride (pixbuf);
3357 n_channels = gdk_pixbuf_get_n_channels (pixbuf);
3362 pixels = gdk_pixbuf_get_pixels (pixbuf);
3364 for (y = 0; y < height; y++)
3366 for (x = 0; x < width; x++)
3370 r = pixels[y*stride + x*n_channels + 0];
3371 g = pixels[y*stride + x*n_channels + 1];
3372 b = pixels[y*stride + x*n_channels + 2];
3373 if (n_channels >= 4)
3374 a = pixels[y*stride + x*n_channels + 3];
3378 *p++ = a << 24 | r << 16 | g << 8 | b ;
3382 l = g_list_next (l);
3388 XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
3389 GDK_WINDOW_XID (window),
3390 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON"),
3393 (guchar*) data, size);
3397 XDeleteProperty (GDK_DISPLAY_XDISPLAY (display),
3398 GDK_WINDOW_XID (window),
3399 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON"));
3404 gdk_window_update_icon (window, pixbufs);
3408 gdk_window_icon_name_set (GdkWindow *window)
3410 return GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (window),
3411 g_quark_from_static_string ("gdk-icon-name-set")));
3415 gdk_x11_window_set_icon_name (GdkWindow *window,
3418 GdkDisplay *display;
3420 if (GDK_WINDOW_DESTROYED (window) ||
3421 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3424 display = gdk_window_get_display (window);
3426 g_object_set_qdata (G_OBJECT (window), g_quark_from_static_string ("gdk-icon-name-set"),
3427 GUINT_TO_POINTER (name != NULL));
3431 XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
3432 GDK_WINDOW_XID (window),
3433 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON_NAME"),
3434 gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
3435 PropModeReplace, (guchar *)name, strlen (name));
3437 set_text_property (display, GDK_WINDOW_XID (window),
3438 gdk_x11_get_xatom_by_name_for_display (display, "WM_ICON_NAME"),
3443 XDeleteProperty (GDK_DISPLAY_XDISPLAY (display),
3444 GDK_WINDOW_XID (window),
3445 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON_NAME"));
3446 XDeleteProperty (GDK_DISPLAY_XDISPLAY (display),
3447 GDK_WINDOW_XID (window),
3448 gdk_x11_get_xatom_by_name_for_display (display, "WM_ICON_NAME"));
3453 gdk_x11_window_iconify (GdkWindow *window)
3455 if (GDK_WINDOW_DESTROYED (window) ||
3456 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3459 if (GDK_WINDOW_IS_MAPPED (window))
3461 XIconifyWindow (GDK_WINDOW_XDISPLAY (window),
3462 GDK_WINDOW_XID (window),
3463 gdk_screen_get_number (GDK_WINDOW_SCREEN (window)));
3467 /* Flip our client side flag, the real work happens on map. */
3468 gdk_synthesize_window_state (window,
3470 GDK_WINDOW_STATE_ICONIFIED);
3475 gdk_x11_window_deiconify (GdkWindow *window)
3477 if (GDK_WINDOW_DESTROYED (window) ||
3478 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3481 if (GDK_WINDOW_IS_MAPPED (window))
3483 gdk_window_show (window);
3487 /* Flip our client side flag, the real work happens on map. */
3488 gdk_synthesize_window_state (window,
3489 GDK_WINDOW_STATE_ICONIFIED,
3495 gdk_x11_window_stick (GdkWindow *window)
3497 if (GDK_WINDOW_DESTROYED (window) ||
3498 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3501 if (GDK_WINDOW_IS_MAPPED (window))
3503 /* "stick" means stick to all desktops _and_ do not scroll with the
3504 * viewport. i.e. glue to the monitor glass in all cases.
3507 XClientMessageEvent xclient;
3509 /* Request stick during viewport scroll */
3510 gdk_wmspec_change_state (TRUE, window,
3511 gdk_atom_intern_static_string ("_NET_WM_STATE_STICKY"),
3514 /* Request desktop 0xFFFFFFFF */
3515 memset (&xclient, 0, sizeof (xclient));
3516 xclient.type = ClientMessage;
3517 xclient.window = GDK_WINDOW_XID (window);
3518 xclient.display = GDK_WINDOW_XDISPLAY (window);
3519 xclient.message_type = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
3521 xclient.format = 32;
3523 xclient.data.l[0] = 0xFFFFFFFF;
3524 xclient.data.l[1] = 0;
3525 xclient.data.l[2] = 0;
3526 xclient.data.l[3] = 0;
3527 xclient.data.l[4] = 0;
3529 XSendEvent (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XROOTWIN (window), False,
3530 SubstructureRedirectMask | SubstructureNotifyMask,
3531 (XEvent *)&xclient);
3535 /* Flip our client side flag, the real work happens on map. */
3536 gdk_synthesize_window_state (window,
3538 GDK_WINDOW_STATE_STICKY);
3543 gdk_x11_window_unstick (GdkWindow *window)
3545 if (GDK_WINDOW_DESTROYED (window) ||
3546 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3549 if (GDK_WINDOW_IS_MAPPED (window))
3551 /* Request unstick from viewport */
3552 gdk_wmspec_change_state (FALSE, window,
3553 gdk_atom_intern_static_string ("_NET_WM_STATE_STICKY"),
3556 move_to_current_desktop (window);
3560 /* Flip our client side flag, the real work happens on map. */
3561 gdk_synthesize_window_state (window,
3562 GDK_WINDOW_STATE_STICKY,
3569 gdk_x11_window_maximize (GdkWindow *window)
3571 if (GDK_WINDOW_DESTROYED (window) ||
3572 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3575 if (GDK_WINDOW_IS_MAPPED (window))
3576 gdk_wmspec_change_state (TRUE, window,
3577 gdk_atom_intern_static_string ("_NET_WM_STATE_MAXIMIZED_VERT"),
3578 gdk_atom_intern_static_string ("_NET_WM_STATE_MAXIMIZED_HORZ"));
3580 gdk_synthesize_window_state (window,
3582 GDK_WINDOW_STATE_MAXIMIZED);
3586 gdk_x11_window_unmaximize (GdkWindow *window)
3588 if (GDK_WINDOW_DESTROYED (window) ||
3589 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3592 if (GDK_WINDOW_IS_MAPPED (window))
3593 gdk_wmspec_change_state (FALSE, window,
3594 gdk_atom_intern_static_string ("_NET_WM_STATE_MAXIMIZED_VERT"),
3595 gdk_atom_intern_static_string ("_NET_WM_STATE_MAXIMIZED_HORZ"));
3597 gdk_synthesize_window_state (window,
3598 GDK_WINDOW_STATE_MAXIMIZED,
3603 gdk_x11_window_fullscreen (GdkWindow *window)
3605 if (GDK_WINDOW_DESTROYED (window) ||
3606 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3609 if (GDK_WINDOW_IS_MAPPED (window))
3610 gdk_wmspec_change_state (TRUE, window,
3611 gdk_atom_intern_static_string ("_NET_WM_STATE_FULLSCREEN"),
3615 gdk_synthesize_window_state (window,
3617 GDK_WINDOW_STATE_FULLSCREEN);
3621 gdk_x11_window_unfullscreen (GdkWindow *window)
3623 if (GDK_WINDOW_DESTROYED (window) ||
3624 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3627 if (GDK_WINDOW_IS_MAPPED (window))
3628 gdk_wmspec_change_state (FALSE, window,
3629 gdk_atom_intern_static_string ("_NET_WM_STATE_FULLSCREEN"),
3633 gdk_synthesize_window_state (window,
3634 GDK_WINDOW_STATE_FULLSCREEN,
3639 gdk_x11_window_set_keep_above (GdkWindow *window,
3642 g_return_if_fail (GDK_IS_WINDOW (window));
3644 if (GDK_WINDOW_DESTROYED (window) ||
3645 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3648 if (GDK_WINDOW_IS_MAPPED (window))
3651 gdk_wmspec_change_state (FALSE, window,
3652 gdk_atom_intern_static_string ("_NET_WM_STATE_BELOW"),
3654 gdk_wmspec_change_state (setting, window,
3655 gdk_atom_intern_static_string ("_NET_WM_STATE_ABOVE"),
3659 gdk_synthesize_window_state (window,
3660 setting ? GDK_WINDOW_STATE_BELOW : GDK_WINDOW_STATE_ABOVE,
3661 setting ? GDK_WINDOW_STATE_ABOVE : 0);
3665 gdk_x11_window_set_keep_below (GdkWindow *window, gboolean setting)
3667 g_return_if_fail (GDK_IS_WINDOW (window));
3669 if (GDK_WINDOW_DESTROYED (window) ||
3670 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3673 if (GDK_WINDOW_IS_MAPPED (window))
3676 gdk_wmspec_change_state (FALSE, window,
3677 gdk_atom_intern_static_string ("_NET_WM_STATE_ABOVE"),
3679 gdk_wmspec_change_state (setting, window,
3680 gdk_atom_intern_static_string ("_NET_WM_STATE_BELOW"),
3684 gdk_synthesize_window_state (window,
3685 setting ? GDK_WINDOW_STATE_ABOVE : GDK_WINDOW_STATE_BELOW,
3686 setting ? GDK_WINDOW_STATE_BELOW : 0);
3690 gdk_x11_window_get_group (GdkWindow *window)
3692 GdkToplevelX11 *toplevel;
3694 if (GDK_WINDOW_DESTROYED (window) ||
3695 !WINDOW_IS_TOPLEVEL (window))
3698 toplevel = _gdk_x11_window_get_toplevel (window);
3700 return toplevel->group_leader;
3704 gdk_x11_window_set_group (GdkWindow *window,
3707 GdkToplevelX11 *toplevel;
3709 g_return_if_fail (GDK_IS_WINDOW (window));
3710 g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD);
3711 g_return_if_fail (leader == NULL || GDK_IS_WINDOW (leader));
3713 if (GDK_WINDOW_DESTROYED (window) ||
3714 (leader != NULL && GDK_WINDOW_DESTROYED (leader)) ||
3715 !WINDOW_IS_TOPLEVEL (window))
3718 toplevel = _gdk_x11_window_get_toplevel (window);
3721 leader = gdk_display_get_default_group (gdk_window_get_display (window));
3723 if (toplevel->group_leader != leader)
3725 if (toplevel->group_leader)
3726 g_object_unref (toplevel->group_leader);
3727 toplevel->group_leader = g_object_ref (leader);
3728 (_gdk_x11_window_get_toplevel (leader))->is_leader = TRUE;
3731 update_wm_hints (window, FALSE);
3734 static MotifWmHints *
3735 gdk_window_get_mwm_hints (GdkWindow *window)
3737 GdkDisplay *display;
3738 Atom hints_atom = None;
3745 if (GDK_WINDOW_DESTROYED (window))
3748 display = gdk_window_get_display (window);
3750 hints_atom = gdk_x11_get_xatom_by_name_for_display (display, _XA_MOTIF_WM_HINTS);
3752 XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
3753 hints_atom, 0, sizeof (MotifWmHints)/sizeof (long),
3754 False, AnyPropertyType, &type, &format, &nitems,
3755 &bytes_after, &data);
3760 return (MotifWmHints *)data;
3764 gdk_window_set_mwm_hints (GdkWindow *window,
3765 MotifWmHints *new_hints)
3767 GdkDisplay *display;
3768 Atom hints_atom = None;
3770 MotifWmHints *hints;
3776 if (GDK_WINDOW_DESTROYED (window))
3779 display = gdk_window_get_display (window);
3781 hints_atom = gdk_x11_get_xatom_by_name_for_display (display, _XA_MOTIF_WM_HINTS);
3783 XGetWindowProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
3784 hints_atom, 0, sizeof (MotifWmHints)/sizeof (long),
3785 False, AnyPropertyType, &type, &format, &nitems,
3786 &bytes_after, &data);
3792 hints = (MotifWmHints *)data;
3794 if (new_hints->flags & MWM_HINTS_FUNCTIONS)
3796 hints->flags |= MWM_HINTS_FUNCTIONS;
3797 hints->functions = new_hints->functions;
3799 if (new_hints->flags & MWM_HINTS_DECORATIONS)
3801 hints->flags |= MWM_HINTS_DECORATIONS;
3802 hints->decorations = new_hints->decorations;
3806 XChangeProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
3807 hints_atom, hints_atom, 32, PropModeReplace,
3808 (guchar *)hints, sizeof (MotifWmHints)/sizeof (long));
3810 if (hints != new_hints)
3815 gdk_x11_window_set_decorations (GdkWindow *window,
3816 GdkWMDecoration decorations)
3820 if (GDK_WINDOW_DESTROYED (window) ||
3821 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3824 /* initialize to zero to avoid writing uninitialized data to socket */
3825 memset(&hints, 0, sizeof(hints));
3826 hints.flags = MWM_HINTS_DECORATIONS;
3827 hints.decorations = decorations;
3829 gdk_window_set_mwm_hints (window, &hints);
3833 gdk_x11_window_get_decorations(GdkWindow *window,
3834 GdkWMDecoration *decorations)
3836 MotifWmHints *hints;
3837 gboolean result = FALSE;
3839 if (GDK_WINDOW_DESTROYED (window) ||
3840 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3843 hints = gdk_window_get_mwm_hints (window);
3847 if (hints->flags & MWM_HINTS_DECORATIONS)
3850 *decorations = hints->decorations;
3861 gdk_x11_window_set_functions (GdkWindow *window,
3862 GdkWMFunction functions)
3866 g_return_if_fail (GDK_IS_WINDOW (window));
3868 if (GDK_WINDOW_DESTROYED (window) ||
3869 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3872 /* initialize to zero to avoid writing uninitialized data to socket */
3873 memset(&hints, 0, sizeof(hints));
3874 hints.flags = MWM_HINTS_FUNCTIONS;
3875 hints.functions = functions;
3877 gdk_window_set_mwm_hints (window, &hints);
3881 _gdk_x11_xwindow_get_shape (Display *xdisplay,
3885 cairo_region_t *shape;
3893 /* Note that XShapeGetRectangles returns NULL in two situations:
3894 * - the server doesn't support the SHAPE extension
3895 * - the shape is empty
3897 * Since we can't discriminate these here, we always return
3898 * an empty shape. It is the callers responsibility to check
3899 * whether the server supports the SHAPE extensions beforehand.
3901 xrl = XShapeGetRectangles (xdisplay, window, shape_type, &rn, &ord);
3904 return cairo_region_create (); /* Empty */
3906 if (ord != YXBanded)
3908 /* This really shouldn't happen with any xserver, as they
3909 * generally convert regions to YXBanded internally
3911 g_warning ("non YXBanded shape masks not supported");
3916 rl = g_new (GdkRectangle, rn);
3917 for (i = 0; i < rn; i++)
3921 rl[i].width = xrl[i].width;
3922 rl[i].height = xrl[i].height;
3926 shape = cairo_region_create_rectangles (rl, rn);
3933 static cairo_region_t *
3934 gdk_x11_window_get_shape (GdkWindow *window)
3936 if (!GDK_WINDOW_DESTROYED (window) &&
3937 gdk_display_supports_shapes (GDK_WINDOW_DISPLAY (window)))
3938 return _gdk_x11_xwindow_get_shape (GDK_WINDOW_XDISPLAY (window),
3939 GDK_WINDOW_XID (window),
3945 static cairo_region_t *
3946 gdk_x11_window_get_input_shape (GdkWindow *window)
3948 #if defined(ShapeInput)
3949 if (!GDK_WINDOW_DESTROYED (window) &&
3950 gdk_display_supports_input_shapes (GDK_WINDOW_DISPLAY (window)))
3951 return _gdk_x11_xwindow_get_shape (GDK_WINDOW_XDISPLAY (window),
3952 GDK_WINDOW_XID (window),
3960 gdk_window_set_static_bit_gravity (GdkWindow *window,
3963 XSetWindowAttributes xattributes;
3964 guint xattributes_mask = 0;
3966 g_return_if_fail (GDK_IS_WINDOW (window));
3968 if (window->input_only)
3971 xattributes.bit_gravity = StaticGravity;
3972 xattributes_mask |= CWBitGravity;
3973 xattributes.bit_gravity = on ? StaticGravity : ForgetGravity;
3974 XChangeWindowAttributes (GDK_WINDOW_XDISPLAY (window),
3975 GDK_WINDOW_XID (window),
3976 CWBitGravity, &xattributes);
3980 gdk_window_set_static_win_gravity (GdkWindow *window,
3983 XSetWindowAttributes xattributes;
3985 g_return_if_fail (GDK_IS_WINDOW (window));
3987 xattributes.win_gravity = on ? StaticGravity : NorthWestGravity;
3989 XChangeWindowAttributes (GDK_WINDOW_XDISPLAY (window),
3990 GDK_WINDOW_XID (window),
3991 CWWinGravity, &xattributes);
3995 gdk_window_x11_set_static_gravities (GdkWindow *window,
3996 gboolean use_static)
4000 if (!use_static == !window->guffaw_gravity)
4003 window->guffaw_gravity = use_static;
4005 if (!GDK_WINDOW_DESTROYED (window))
4007 gdk_window_set_static_bit_gravity (window, use_static);
4009 tmp_list = window->children;
4012 gdk_window_set_static_win_gravity (tmp_list->data, use_static);
4014 tmp_list = tmp_list->next;
4022 wmspec_moveresize (GdkWindow *window,
4030 GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
4032 XClientMessageEvent xclient;
4034 /* Release passive grab */
4035 gdk_device_ungrab (device, timestamp);
4037 memset (&xclient, 0, sizeof (xclient));
4038 xclient.type = ClientMessage;
4039 xclient.window = GDK_WINDOW_XID (window);
4040 xclient.message_type =
4041 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_MOVERESIZE");
4042 xclient.format = 32;
4043 xclient.data.l[0] = root_x;
4044 xclient.data.l[1] = root_y;
4045 xclient.data.l[2] = direction;
4046 xclient.data.l[3] = button;
4047 xclient.data.l[4] = 1; /* source indication */
4049 XSendEvent (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XROOTWIN (window), False,
4050 SubstructureRedirectMask | SubstructureNotifyMask,
4051 (XEvent *)&xclient);
4054 typedef struct _MoveResizeData MoveResizeData;
4056 struct _MoveResizeData
4058 GdkDisplay *display;
4060 GdkWindow *moveresize_window;
4061 GdkWindow *moveresize_emulation_window;
4063 GdkWindowEdge resize_edge;
4065 gint moveresize_button;
4068 gint moveresize_orig_x;
4069 gint moveresize_orig_y;
4070 gint moveresize_orig_width;
4071 gint moveresize_orig_height;
4072 GdkWindowHints moveresize_geom_mask;
4073 GdkGeometry moveresize_geometry;
4074 Time moveresize_process_time;
4075 XEvent *moveresize_pending_event;
4078 /* From the WM spec */
4079 #define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0
4080 #define _NET_WM_MOVERESIZE_SIZE_TOP 1
4081 #define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT 2
4082 #define _NET_WM_MOVERESIZE_SIZE_RIGHT 3
4083 #define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4
4084 #define _NET_WM_MOVERESIZE_SIZE_BOTTOM 5
4085 #define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT 6
4086 #define _NET_WM_MOVERESIZE_SIZE_LEFT 7
4087 #define _NET_WM_MOVERESIZE_MOVE 8
4090 wmspec_resize_drag (GdkWindow *window,
4100 /* Let the compiler turn a switch into a table, instead
4101 * of doing the table manually, this way is easier to verify.
4105 case GDK_WINDOW_EDGE_NORTH_WEST:
4106 direction = _NET_WM_MOVERESIZE_SIZE_TOPLEFT;
4109 case GDK_WINDOW_EDGE_NORTH:
4110 direction = _NET_WM_MOVERESIZE_SIZE_TOP;
4113 case GDK_WINDOW_EDGE_NORTH_EAST:
4114 direction = _NET_WM_MOVERESIZE_SIZE_TOPRIGHT;
4117 case GDK_WINDOW_EDGE_WEST:
4118 direction = _NET_WM_MOVERESIZE_SIZE_LEFT;
4121 case GDK_WINDOW_EDGE_EAST:
4122 direction = _NET_WM_MOVERESIZE_SIZE_RIGHT;
4125 case GDK_WINDOW_EDGE_SOUTH_WEST:
4126 direction = _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT;
4129 case GDK_WINDOW_EDGE_SOUTH:
4130 direction = _NET_WM_MOVERESIZE_SIZE_BOTTOM;
4133 case GDK_WINDOW_EDGE_SOUTH_EAST:
4134 direction = _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT;
4138 g_warning ("gdk_window_begin_resize_drag: bad resize edge %d!",
4143 wmspec_moveresize (window, direction, device, button, root_x, root_y, timestamp);
4146 static MoveResizeData *
4147 get_move_resize_data (GdkDisplay *display,
4150 MoveResizeData *mv_resize;
4151 static GQuark move_resize_quark = 0;
4153 if (!move_resize_quark)
4154 move_resize_quark = g_quark_from_static_string ("gdk-window-moveresize");
4156 mv_resize = g_object_get_qdata (G_OBJECT (display), move_resize_quark);
4158 if (!mv_resize && create)
4160 mv_resize = g_new0 (MoveResizeData, 1);
4161 mv_resize->display = display;
4163 g_object_set_qdata (G_OBJECT (display), move_resize_quark, mv_resize);
4170 update_pos (MoveResizeData *mv_resize,
4176 dx = new_root_x - mv_resize->moveresize_x;
4177 dy = new_root_y - mv_resize->moveresize_y;
4179 if (mv_resize->is_resize)
4183 x = mv_resize->moveresize_orig_x;
4184 y = mv_resize->moveresize_orig_y;
4186 w = mv_resize->moveresize_orig_width;
4187 h = mv_resize->moveresize_orig_height;
4189 switch (mv_resize->resize_edge)
4191 case GDK_WINDOW_EDGE_NORTH_WEST:
4197 case GDK_WINDOW_EDGE_NORTH:
4201 case GDK_WINDOW_EDGE_NORTH_EAST:
4206 case GDK_WINDOW_EDGE_SOUTH_WEST:
4211 case GDK_WINDOW_EDGE_SOUTH_EAST:
4215 case GDK_WINDOW_EDGE_SOUTH:
4218 case GDK_WINDOW_EDGE_EAST:
4221 case GDK_WINDOW_EDGE_WEST:
4232 if (mv_resize->moveresize_geom_mask)
4234 gdk_window_constrain_size (&mv_resize->moveresize_geometry,
4235 mv_resize->moveresize_geom_mask,
4239 gdk_window_move_resize (mv_resize->moveresize_window, x, y, w, h);
4245 x = mv_resize->moveresize_orig_x + dx;
4246 y = mv_resize->moveresize_orig_y + dy;
4248 gdk_window_move (mv_resize->moveresize_window, x, y);
4253 finish_drag (MoveResizeData *mv_resize)
4255 gdk_window_destroy (mv_resize->moveresize_emulation_window);
4256 mv_resize->moveresize_emulation_window = NULL;
4257 g_object_unref (mv_resize->moveresize_window);
4258 mv_resize->moveresize_window = NULL;
4260 if (mv_resize->moveresize_pending_event)
4262 g_free (mv_resize->moveresize_pending_event);
4263 mv_resize->moveresize_pending_event = NULL;
4268 lookahead_motion_predicate (Display *xdisplay,
4272 gboolean *seen_release = (gboolean *)arg;
4273 GdkDisplay *display = gdk_x11_lookup_xdisplay (xdisplay);
4274 MoveResizeData *mv_resize = get_move_resize_data (display, FALSE);
4279 switch (event->xany.type)
4282 *seen_release = TRUE;
4285 mv_resize->moveresize_process_time = event->xmotion.time;
4295 moveresize_lookahead (MoveResizeData *mv_resize,
4299 gboolean seen_release = FALSE;
4301 if (mv_resize->moveresize_process_time)
4303 if (event->xmotion.time == mv_resize->moveresize_process_time)
4305 mv_resize->moveresize_process_time = 0;
4312 XCheckIfEvent (event->xany.display, &tmp_event,
4313 lookahead_motion_predicate, (XPointer) & seen_release);
4315 return mv_resize->moveresize_process_time == 0;
4319 _gdk_x11_moveresize_handle_event (XEvent *event)
4321 guint button_mask = 0;
4322 GdkDisplay *display = gdk_x11_lookup_xdisplay (event->xany.display);
4323 MoveResizeData *mv_resize = get_move_resize_data (display, FALSE);
4325 if (!mv_resize || !mv_resize->moveresize_window)
4328 button_mask = GDK_BUTTON1_MASK << (mv_resize->moveresize_button - 1);
4330 switch (event->xany.type)
4333 if (mv_resize->moveresize_window->resize_count > 0)
4335 if (mv_resize->moveresize_pending_event)
4336 *mv_resize->moveresize_pending_event = *event;
4338 mv_resize->moveresize_pending_event =
4339 g_memdup (event, sizeof (XEvent));
4343 if (!moveresize_lookahead (mv_resize, event))
4346 update_pos (mv_resize,
4347 event->xmotion.x_root,
4348 event->xmotion.y_root);
4350 /* This should never be triggered in normal cases, but in the
4351 * case where the drag started without an implicit grab being
4352 * in effect, we could miss the release if it occurs before
4353 * we grab the pointer; this ensures that we will never
4354 * get a permanently stuck grab.
4356 if ((event->xmotion.state & button_mask) == 0)
4357 finish_drag (mv_resize);
4361 update_pos (mv_resize,
4362 event->xbutton.x_root,
4363 event->xbutton.y_root);
4365 if (event->xbutton.button == mv_resize->moveresize_button)
4366 finish_drag (mv_resize);
4369 #ifdef HAVE_XGENERICEVENTS
4372 /* we just assume this is an XI2 event */
4373 XIEvent *ev = (XIEvent *) event->xcookie.data;
4374 XIDeviceEvent *xev = (XIDeviceEvent *)ev;
4379 update_pos (mv_resize, xev->root_x, xev->root_y);
4380 state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group);
4381 if ((state & button_mask) == 0)
4382 finish_drag (mv_resize);
4385 case XI_ButtonRelease:
4386 update_pos (mv_resize, xev->root_x, xev->root_y);
4387 if (xev->detail == mv_resize->moveresize_button)
4388 finish_drag (mv_resize);
4400 _gdk_x11_moveresize_configure_done (GdkDisplay *display,
4404 MoveResizeData *mv_resize = get_move_resize_data (display, FALSE);
4406 if (!mv_resize || window != mv_resize->moveresize_window)
4409 if (mv_resize->moveresize_pending_event)
4411 tmp_event = mv_resize->moveresize_pending_event;
4412 mv_resize->moveresize_pending_event = NULL;
4413 _gdk_x11_moveresize_handle_event (tmp_event);
4421 create_moveresize_window (MoveResizeData *mv_resize,
4424 GdkWindowAttr attributes;
4425 gint attributes_mask;
4426 GdkGrabStatus status;
4428 g_assert (mv_resize->moveresize_emulation_window == NULL);
4430 attributes.x = -100;
4431 attributes.y = -100;
4432 attributes.width = 10;
4433 attributes.height = 10;
4434 attributes.window_type = GDK_WINDOW_TEMP;
4435 attributes.wclass = GDK_INPUT_ONLY;
4436 attributes.override_redirect = TRUE;
4437 attributes.event_mask = 0;
4439 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_NOREDIR;
4441 mv_resize->moveresize_emulation_window =
4442 gdk_window_new (gdk_screen_get_root_window (gdk_display_get_default_screen (mv_resize->display)),
4446 gdk_window_show (mv_resize->moveresize_emulation_window);
4448 status = gdk_device_grab (mv_resize->device,
4449 mv_resize->moveresize_emulation_window,
4452 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK,
4456 if (status != GDK_GRAB_SUCCESS)
4458 /* If this fails, some other client has grabbed the window
4461 finish_drag (mv_resize);
4464 mv_resize->moveresize_process_time = 0;
4468 Calculate mv_resize->moveresize_orig_x and mv_resize->moveresize_orig_y
4469 so that calling XMoveWindow with these coordinates will not move the
4471 Note that this depends on the WM to implement ICCCM-compliant reference
4475 calculate_unmoving_origin (MoveResizeData *mv_resize)
4480 if (mv_resize->moveresize_geom_mask & GDK_HINT_WIN_GRAVITY &&
4481 mv_resize->moveresize_geometry.win_gravity == GDK_GRAVITY_STATIC)
4483 gdk_window_get_origin (mv_resize->moveresize_window,
4484 &mv_resize->moveresize_orig_x,
4485 &mv_resize->moveresize_orig_y);
4489 gdk_window_get_frame_extents (mv_resize->moveresize_window, &rect);
4490 gdk_window_get_geometry (mv_resize->moveresize_window,
4491 NULL, NULL, &width, &height);
4493 switch (mv_resize->moveresize_geometry.win_gravity)
4495 case GDK_GRAVITY_NORTH_WEST:
4496 mv_resize->moveresize_orig_x = rect.x;
4497 mv_resize->moveresize_orig_y = rect.y;
4499 case GDK_GRAVITY_NORTH:
4500 mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2;
4501 mv_resize->moveresize_orig_y = rect.y;
4503 case GDK_GRAVITY_NORTH_EAST:
4504 mv_resize->moveresize_orig_x = rect.x + rect.width - width;
4505 mv_resize->moveresize_orig_y = rect.y;
4507 case GDK_GRAVITY_WEST:
4508 mv_resize->moveresize_orig_x = rect.x;
4509 mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2;
4511 case GDK_GRAVITY_CENTER:
4512 mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2;
4513 mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2;
4515 case GDK_GRAVITY_EAST:
4516 mv_resize->moveresize_orig_x = rect.x + rect.width - width;
4517 mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2;
4519 case GDK_GRAVITY_SOUTH_WEST:
4520 mv_resize->moveresize_orig_x = rect.x;
4521 mv_resize->moveresize_orig_y = rect.y + rect.height - height;
4523 case GDK_GRAVITY_SOUTH:
4524 mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2;
4525 mv_resize->moveresize_orig_y = rect.y + rect.height - height;
4527 case GDK_GRAVITY_SOUTH_EAST:
4528 mv_resize->moveresize_orig_x = rect.x + rect.width - width;
4529 mv_resize->moveresize_orig_y = rect.y + rect.height - height;
4532 mv_resize->moveresize_orig_x = rect.x;
4533 mv_resize->moveresize_orig_y = rect.y;
4540 emulate_resize_drag (GdkWindow *window,
4548 MoveResizeData *mv_resize = get_move_resize_data (GDK_WINDOW_DISPLAY (window), TRUE);
4550 mv_resize->is_resize = TRUE;
4551 mv_resize->moveresize_button = button;
4552 mv_resize->resize_edge = edge;
4553 mv_resize->device = device;
4554 mv_resize->moveresize_x = root_x;
4555 mv_resize->moveresize_y = root_y;
4556 mv_resize->moveresize_window = g_object_ref (window);
4558 mv_resize->moveresize_orig_width = gdk_window_get_width (window);
4559 mv_resize->moveresize_orig_height = gdk_window_get_height (window);
4561 mv_resize->moveresize_geom_mask = 0;
4562 gdk_window_get_geometry_hints (window,
4563 &mv_resize->moveresize_geometry,
4564 &mv_resize->moveresize_geom_mask);
4566 calculate_unmoving_origin (mv_resize);
4568 create_moveresize_window (mv_resize, timestamp);
4572 emulate_move_drag (GdkWindow *window,
4579 MoveResizeData *mv_resize = get_move_resize_data (GDK_WINDOW_DISPLAY (window), TRUE);
4581 mv_resize->is_resize = FALSE;
4582 mv_resize->device = device;
4583 mv_resize->moveresize_button = button;
4584 mv_resize->moveresize_x = root_x;
4585 mv_resize->moveresize_y = root_y;
4587 mv_resize->moveresize_window = g_object_ref (window);
4589 calculate_unmoving_origin (mv_resize);
4591 create_moveresize_window (mv_resize, timestamp);
4595 gdk_x11_window_begin_resize_drag (GdkWindow *window,
4603 if (GDK_WINDOW_DESTROYED (window) ||
4604 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
4607 if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
4608 gdk_atom_intern_static_string ("_NET_WM_MOVERESIZE")))
4609 wmspec_resize_drag (window, edge, device, button, root_x, root_y, timestamp);
4611 emulate_resize_drag (window, edge, device, button, root_x, root_y, timestamp);
4615 gdk_x11_window_begin_move_drag (GdkWindow *window,
4622 if (GDK_WINDOW_DESTROYED (window) ||
4623 !WINDOW_IS_TOPLEVEL (window))
4626 if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
4627 gdk_atom_intern_static_string ("_NET_WM_MOVERESIZE")))
4628 wmspec_moveresize (window, _NET_WM_MOVERESIZE_MOVE,
4629 device, button, root_x, root_y, timestamp);
4631 emulate_move_drag (window, device, button, root_x, root_y, timestamp);
4635 gdk_x11_window_enable_synchronized_configure (GdkWindow *window)
4637 GdkWindowImplX11 *impl;
4639 if (!GDK_IS_WINDOW_IMPL_X11 (window->impl))
4642 impl = GDK_WINDOW_IMPL_X11 (window->impl);
4644 if (!impl->use_synchronized_configure)
4646 /* This basically means you want to do fancy X specific stuff, so
4647 ensure we have a native window */
4648 gdk_window_ensure_native (window);
4650 impl->use_synchronized_configure = TRUE;
4651 ensure_sync_counter (window);
4656 gdk_x11_window_configure_finished (GdkWindow *window)
4658 GdkWindowImplX11 *impl;
4660 if (!WINDOW_IS_TOPLEVEL (window))
4663 impl = GDK_WINDOW_IMPL_X11 (window->impl);
4664 if (!impl->use_synchronized_configure)
4668 if (!GDK_WINDOW_DESTROYED (window))
4670 GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
4671 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
4673 if (toplevel && toplevel->update_counter != None &&
4674 GDK_X11_DISPLAY (display)->use_sync &&
4675 !XSyncValueIsZero (toplevel->current_counter_value))
4677 XSyncSetCounter (GDK_WINDOW_XDISPLAY (window),
4678 toplevel->update_counter,
4679 toplevel->current_counter_value);
4681 XSyncIntToValue (&toplevel->current_counter_value, 0);
4688 gdk_x11_window_beep (GdkWindow *window)
4690 GdkDisplay *display;
4692 display = GDK_WINDOW_DISPLAY (window);
4695 if (GDK_X11_DISPLAY (display)->use_xkb)
4697 XkbBell (GDK_DISPLAY_XDISPLAY (display),
4698 GDK_WINDOW_XID (window),
4709 gdk_x11_window_set_opacity (GdkWindow *window,
4712 GdkDisplay *display;
4715 g_return_if_fail (GDK_IS_WINDOW (window));
4717 if (GDK_WINDOW_DESTROYED (window) ||
4718 !WINDOW_IS_TOPLEVEL (window))
4721 display = gdk_window_get_display (window);
4725 else if (opacity > 1)
4728 cardinal = opacity * 0xffffffff;
4730 if (cardinal == 0xffffffff)
4731 XDeleteProperty (GDK_DISPLAY_XDISPLAY (display),
4732 GDK_WINDOW_XID (window),
4733 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_OPACITY"));
4735 XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
4736 GDK_WINDOW_XID (window),
4737 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_OPACITY"),
4740 (guchar *) &cardinal, 1);
4744 gdk_x11_window_set_composited (GdkWindow *window,
4745 gboolean composited)
4747 #if defined(HAVE_XCOMPOSITE) && defined(HAVE_XDAMAGE) && defined (HAVE_XFIXES)
4748 GdkWindowImplX11 *impl;
4749 GdkDisplay *display;
4753 impl = GDK_WINDOW_IMPL_X11 (window->impl);
4755 display = gdk_window_get_display (window);
4756 dpy = GDK_DISPLAY_XDISPLAY (display);
4757 xid = GDK_WINDOW_XID (window);
4761 XCompositeRedirectWindow (dpy, xid, CompositeRedirectManual);
4762 impl->damage = XDamageCreate (dpy, xid, XDamageReportBoundingBox);
4766 XCompositeUnredirectWindow (dpy, xid, CompositeRedirectManual);
4767 XDamageDestroy (dpy, impl->damage);
4768 impl->damage = None;
4774 gdk_x11_window_process_updates_recurse (GdkWindow *window,
4775 cairo_region_t *region)
4777 _gdk_window_process_updates_recurse (window, region);
4781 _gdk_x11_display_before_process_all_updates (GdkDisplay *display)
4786 _gdk_x11_display_after_process_all_updates (GdkDisplay *display)
4791 timestamp_predicate (Display *display,
4795 Window xwindow = GPOINTER_TO_UINT (arg);
4796 GdkDisplay *gdk_display = gdk_x11_lookup_xdisplay (display);
4798 if (xevent->type == PropertyNotify &&
4799 xevent->xproperty.window == xwindow &&
4800 xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (gdk_display,
4801 "GDK_TIMESTAMP_PROP"))
4808 * gdk_x11_get_server_time:
4809 * @window: (type GdkX11Window): a #GdkWindow, used for communication
4810 * with the server. The window must have
4811 * GDK_PROPERTY_CHANGE_MASK in its events mask or a hang will
4814 * Routine to get the current X server time stamp.
4816 * Return value: the time stamp.
4819 gdk_x11_get_server_time (GdkWindow *window)
4825 Atom timestamp_prop_atom;
4827 g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
4828 g_return_val_if_fail (!GDK_WINDOW_DESTROYED (window), 0);
4830 xdisplay = GDK_WINDOW_XDISPLAY (window);
4831 xwindow = GDK_WINDOW_XID (window);
4832 timestamp_prop_atom =
4833 gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
4834 "GDK_TIMESTAMP_PROP");
4836 XChangeProperty (xdisplay, xwindow, timestamp_prop_atom,
4837 timestamp_prop_atom,
4838 8, PropModeReplace, &c, 1);
4840 XIfEvent (xdisplay, &xevent,
4841 timestamp_predicate, GUINT_TO_POINTER(xwindow));
4843 return xevent.xproperty.time;
4847 * gdk_x11_window_get_xid:
4848 * @window: (type GdkX11Window): a native #GdkWindow.
4850 * Returns the X resource (window) belonging to a #GdkWindow.
4852 * Return value: the ID of @drawable's X resource.
4855 gdk_x11_window_get_xid (GdkWindow *window)
4857 /* Try to ensure the window has a native window */
4858 if (!_gdk_window_has_impl (window))
4860 gdk_window_ensure_native (window);
4862 /* We sync here to ensure the window is created in the Xserver when
4863 * this function returns. This is required because the returned XID
4864 * for this window must be valid immediately, even with another
4865 * connection to the Xserver */
4866 gdk_display_sync (gdk_window_get_display (window));
4869 if (!GDK_WINDOW_IS_X11 (window))
4871 g_warning (G_STRLOC " drawable is not a native X11 window");
4875 return GDK_WINDOW_IMPL_X11 (window->impl)->xid;
4878 extern GdkDragContext * _gdk_x11_window_drag_begin (GdkWindow *window,
4883 gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass)
4885 GObjectClass *object_class = G_OBJECT_CLASS (klass);
4886 GdkWindowImplClass *impl_class = GDK_WINDOW_IMPL_CLASS (klass);
4888 object_class->finalize = gdk_window_impl_x11_finalize;
4890 impl_class->ref_cairo_surface = gdk_x11_ref_cairo_surface;
4891 impl_class->show = gdk_window_x11_show;
4892 impl_class->hide = gdk_window_x11_hide;
4893 impl_class->withdraw = gdk_window_x11_withdraw;
4894 impl_class->set_events = gdk_window_x11_set_events;
4895 impl_class->get_events = gdk_window_x11_get_events;
4896 impl_class->raise = gdk_window_x11_raise;
4897 impl_class->lower = gdk_window_x11_lower;
4898 impl_class->restack_under = gdk_window_x11_restack_under;
4899 impl_class->restack_toplevel = gdk_window_x11_restack_toplevel;
4900 impl_class->move_resize = gdk_window_x11_move_resize;
4901 impl_class->set_background = gdk_window_x11_set_background;
4902 impl_class->reparent = gdk_window_x11_reparent;
4903 impl_class->set_device_cursor = gdk_window_x11_set_device_cursor;
4904 impl_class->get_geometry = gdk_window_x11_get_geometry;
4905 impl_class->get_root_coords = gdk_window_x11_get_root_coords;
4906 impl_class->get_device_state = gdk_window_x11_get_device_state;
4907 impl_class->shape_combine_region = gdk_window_x11_shape_combine_region;
4908 impl_class->input_shape_combine_region = gdk_window_x11_input_shape_combine_region;
4909 impl_class->set_static_gravities = gdk_window_x11_set_static_gravities;
4910 impl_class->queue_antiexpose = _gdk_x11_window_queue_antiexpose;
4911 impl_class->translate = _gdk_x11_window_translate;
4912 impl_class->destroy = gdk_x11_window_destroy;
4913 impl_class->destroy_foreign = gdk_x11_window_destroy_foreign;
4914 impl_class->resize_cairo_surface = gdk_window_x11_resize_cairo_surface;
4915 impl_class->get_shape = gdk_x11_window_get_shape;
4916 impl_class->get_input_shape = gdk_x11_window_get_input_shape;
4917 impl_class->beep = gdk_x11_window_beep;
4919 impl_class->focus = gdk_x11_window_focus;
4920 impl_class->set_type_hint = gdk_x11_window_set_type_hint;
4921 impl_class->get_type_hint = gdk_x11_window_get_type_hint;
4922 impl_class->set_modal_hint = gdk_x11_window_set_modal_hint;
4923 impl_class->set_skip_taskbar_hint = gdk_x11_window_set_skip_taskbar_hint;
4924 impl_class->set_skip_pager_hint = gdk_x11_window_set_skip_pager_hint;
4925 impl_class->set_urgency_hint = gdk_x11_window_set_urgency_hint;
4926 impl_class->set_geometry_hints = gdk_x11_window_set_geometry_hints;
4927 impl_class->set_title = gdk_x11_window_set_title;
4928 impl_class->set_role = gdk_x11_window_set_role;
4929 impl_class->set_startup_id = gdk_x11_window_set_startup_id;
4930 impl_class->set_transient_for = gdk_x11_window_set_transient_for;
4931 impl_class->get_root_origin = gdk_x11_window_get_root_origin;
4932 impl_class->get_frame_extents = gdk_x11_window_get_frame_extents;
4933 impl_class->set_override_redirect = gdk_x11_window_set_override_redirect;
4934 impl_class->set_accept_focus = gdk_x11_window_set_accept_focus;
4935 impl_class->set_focus_on_map = gdk_x11_window_set_focus_on_map;
4936 impl_class->set_icon_list = gdk_x11_window_set_icon_list;
4937 impl_class->set_icon_name = gdk_x11_window_set_icon_name;
4938 impl_class->iconify = gdk_x11_window_iconify;
4939 impl_class->deiconify = gdk_x11_window_deiconify;
4940 impl_class->stick = gdk_x11_window_stick;
4941 impl_class->unstick = gdk_x11_window_unstick;
4942 impl_class->maximize = gdk_x11_window_maximize;
4943 impl_class->unmaximize = gdk_x11_window_unmaximize;
4944 impl_class->fullscreen = gdk_x11_window_fullscreen;
4945 impl_class->unfullscreen = gdk_x11_window_unfullscreen;
4946 impl_class->set_keep_above = gdk_x11_window_set_keep_above;
4947 impl_class->set_keep_below = gdk_x11_window_set_keep_below;
4948 impl_class->get_group = gdk_x11_window_get_group;
4949 impl_class->set_group = gdk_x11_window_set_group;
4950 impl_class->set_decorations = gdk_x11_window_set_decorations;
4951 impl_class->get_decorations = gdk_x11_window_get_decorations;
4952 impl_class->set_functions = gdk_x11_window_set_functions;
4953 impl_class->set_functions = gdk_x11_window_set_functions;
4954 impl_class->begin_resize_drag = gdk_x11_window_begin_resize_drag;
4955 impl_class->begin_move_drag = gdk_x11_window_begin_move_drag;
4956 impl_class->enable_synchronized_configure = gdk_x11_window_enable_synchronized_configure;
4957 impl_class->configure_finished = gdk_x11_window_configure_finished;
4958 impl_class->set_opacity = gdk_x11_window_set_opacity;
4959 impl_class->set_composited = gdk_x11_window_set_composited;
4960 impl_class->destroy_notify = gdk_x11_window_destroy_notify;
4961 impl_class->get_drag_protocol = gdk_x11_window_get_drag_protocol;
4962 impl_class->register_dnd = _gdk_x11_window_register_dnd;
4963 impl_class->drag_begin = _gdk_x11_window_drag_begin;
4964 impl_class->process_updates_recurse = gdk_x11_window_process_updates_recurse;
4965 impl_class->sync_rendering = _gdk_x11_window_sync_rendering;
4966 impl_class->simulate_key = _gdk_x11_window_simulate_key;
4967 impl_class->simulate_button = _gdk_x11_window_simulate_button;
4968 impl_class->get_property = _gdk_x11_window_get_property;
4969 impl_class->change_property = _gdk_x11_window_change_property;
4970 impl_class->delete_property = _gdk_x11_window_delete_property;