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.
3102 gdk_x11_window_set_utf8_property (GdkWindow *window,
3106 GdkDisplay *display;
3108 if (!WINDOW_IS_TOPLEVEL (window))
3111 display = gdk_window_get_display (window);
3115 XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
3116 GDK_WINDOW_XID (window),
3117 gdk_x11_get_xatom_by_name_for_display (display, name),
3118 gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
3119 PropModeReplace, (guchar *)value, strlen (value));
3123 XDeleteProperty (GDK_DISPLAY_XDISPLAY (display),
3124 GDK_WINDOW_XID (window),
3125 gdk_x11_get_xatom_by_name_for_display (display, name));
3130 * gdk_x11_window_set_hide_titlebar_when_maximized:
3131 * @window: (type GdkX11Window): a #GdkWindow
3132 * @hide_titlebar_when_maximized: whether to hide the titlebar when
3135 * Set a hint for the window manager, requesting that the titlebar
3136 * should be hidden when the window is maximized.
3138 * Note that this property is automatically updated by GTK+, so this
3139 * function should only be used by applications which do not use GTK+
3140 * to create toplevel windows.
3145 gdk_x11_window_set_hide_titlebar_when_maximized (GdkWindow *window,
3146 gboolean hide_titlebar_when_maximized)
3148 GdkDisplay *display;
3150 if (!WINDOW_IS_TOPLEVEL (window))
3153 display = gdk_window_get_display (window);
3155 if (hide_titlebar_when_maximized)
3158 XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
3159 GDK_WINDOW_XID (window),
3160 gdk_x11_get_xatom_by_name_for_display (display, "_GTK_HIDE_TITLEBAR_WHEN_MAXIMIZED"),
3162 PropModeReplace, (guchar *)&hide, 1);
3166 XDeleteProperty (GDK_DISPLAY_XDISPLAY (display),
3167 GDK_WINDOW_XID (window),
3168 gdk_x11_get_xatom_by_name_for_display (display, "_GTK_HIDE_TITLEBAR_WHEN_MAXIMIZED"));
3173 * gdk_x11_window_set_theme_variant:
3174 * @window: (type GdkX11Window): a #GdkWindow
3175 * @variant: the theme variant to export
3177 * GTK+ applications can request a dark theme variant. In order to
3178 * make other applications - namely window managers using GTK+ for
3179 * themeing - aware of this choice, GTK+ uses this function to
3180 * export the requested theme variant as _GTK_THEME_VARIANT property
3181 * on toplevel windows.
3183 * Note that this property is automatically updated by GTK+, so this
3184 * function should only be used by applications which do not use GTK+
3185 * to create toplevel windows.
3190 gdk_x11_window_set_theme_variant (GdkWindow *window,
3193 return gdk_x11_window_set_utf8_property (window, "_GTK_THEME_VARIANT", variant);
3196 #define GDK_SELECTION_MAX_SIZE(display) \
3198 XExtendedMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) == 0 \
3199 ? XMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) - 100 \
3200 : XExtendedMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) - 100)
3203 gdk_window_update_icon (GdkWindow *window,
3206 GdkToplevelX11 *toplevel;
3207 GdkPixbuf *best_icon;
3211 toplevel = _gdk_x11_window_get_toplevel (window);
3213 if (toplevel->icon_pixmap != NULL)
3215 cairo_surface_destroy (toplevel->icon_pixmap);
3216 toplevel->icon_pixmap = NULL;
3219 if (toplevel->icon_mask != NULL)
3221 cairo_surface_destroy (toplevel->icon_mask);
3222 toplevel->icon_mask = NULL;
3225 #define IDEAL_SIZE 48
3227 best_size = G_MAXINT;
3229 for (tmp_list = icon_list; tmp_list; tmp_list = tmp_list->next)
3231 GdkPixbuf *pixbuf = tmp_list->data;
3234 /* average width and height - if someone passes in a rectangular
3235 * icon they deserve what they get.
3237 this = gdk_pixbuf_get_width (pixbuf) + gdk_pixbuf_get_height (pixbuf);
3240 if (best_icon == NULL)
3247 /* icon is better if it's 32 pixels or larger, and closer to
3248 * the ideal size than the current best.
3251 (ABS (best_size - IDEAL_SIZE) <
3252 ABS (this - IDEAL_SIZE)))
3262 int width = gdk_pixbuf_get_width (best_icon);
3263 int height = gdk_pixbuf_get_height (best_icon);
3266 toplevel->icon_pixmap = gdk_x11_window_create_pixmap_surface (window,
3270 cr = cairo_create (toplevel->icon_pixmap);
3271 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
3272 gdk_cairo_set_source_pixbuf (cr, best_icon, 0, 0);
3273 if (gdk_pixbuf_get_has_alpha (best_icon))
3275 /* Saturate the image, so it has bilevel alpha */
3276 cairo_push_group_with_content (cr, CAIRO_CONTENT_COLOR_ALPHA);
3278 cairo_set_operator (cr, CAIRO_OPERATOR_SATURATE);
3280 cairo_pop_group_to_source (cr);
3285 if (gdk_pixbuf_get_has_alpha (best_icon))
3287 toplevel->icon_mask = _gdk_x11_window_create_bitmap_surface (window,
3291 cr = cairo_create (toplevel->icon_mask);
3292 gdk_cairo_set_source_pixbuf (cr, best_icon, 0, 0);
3293 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
3299 update_wm_hints (window, FALSE);
3303 gdk_x11_window_set_icon_list (GdkWindow *window,
3312 gint width, height, stride;
3315 GdkDisplay *display;
3318 if (GDK_WINDOW_DESTROYED (window) ||
3319 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3322 display = gdk_window_get_display (window);
3330 g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
3332 width = gdk_pixbuf_get_width (pixbuf);
3333 height = gdk_pixbuf_get_height (pixbuf);
3335 /* silently ignore overlarge icons */
3336 if (size + 2 + width * height > GDK_SELECTION_MAX_SIZE(display))
3338 g_warning ("gdk_window_set_icon_list: icons too large");
3343 size += 2 + width * height;
3345 l = g_list_next (l);
3348 data = g_malloc (size * sizeof (gulong));
3356 width = gdk_pixbuf_get_width (pixbuf);
3357 height = gdk_pixbuf_get_height (pixbuf);
3358 stride = gdk_pixbuf_get_rowstride (pixbuf);
3359 n_channels = gdk_pixbuf_get_n_channels (pixbuf);
3364 pixels = gdk_pixbuf_get_pixels (pixbuf);
3366 for (y = 0; y < height; y++)
3368 for (x = 0; x < width; x++)
3372 r = pixels[y*stride + x*n_channels + 0];
3373 g = pixels[y*stride + x*n_channels + 1];
3374 b = pixels[y*stride + x*n_channels + 2];
3375 if (n_channels >= 4)
3376 a = pixels[y*stride + x*n_channels + 3];
3380 *p++ = a << 24 | r << 16 | g << 8 | b ;
3384 l = g_list_next (l);
3390 XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
3391 GDK_WINDOW_XID (window),
3392 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON"),
3395 (guchar*) data, size);
3399 XDeleteProperty (GDK_DISPLAY_XDISPLAY (display),
3400 GDK_WINDOW_XID (window),
3401 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON"));
3406 gdk_window_update_icon (window, pixbufs);
3410 gdk_window_icon_name_set (GdkWindow *window)
3412 return GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (window),
3413 g_quark_from_static_string ("gdk-icon-name-set")));
3417 gdk_x11_window_set_icon_name (GdkWindow *window,
3420 GdkDisplay *display;
3422 if (GDK_WINDOW_DESTROYED (window) ||
3423 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3426 display = gdk_window_get_display (window);
3428 g_object_set_qdata (G_OBJECT (window), g_quark_from_static_string ("gdk-icon-name-set"),
3429 GUINT_TO_POINTER (name != NULL));
3433 XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
3434 GDK_WINDOW_XID (window),
3435 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON_NAME"),
3436 gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
3437 PropModeReplace, (guchar *)name, strlen (name));
3439 set_text_property (display, GDK_WINDOW_XID (window),
3440 gdk_x11_get_xatom_by_name_for_display (display, "WM_ICON_NAME"),
3445 XDeleteProperty (GDK_DISPLAY_XDISPLAY (display),
3446 GDK_WINDOW_XID (window),
3447 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON_NAME"));
3448 XDeleteProperty (GDK_DISPLAY_XDISPLAY (display),
3449 GDK_WINDOW_XID (window),
3450 gdk_x11_get_xatom_by_name_for_display (display, "WM_ICON_NAME"));
3455 gdk_x11_window_iconify (GdkWindow *window)
3457 if (GDK_WINDOW_DESTROYED (window) ||
3458 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3461 if (GDK_WINDOW_IS_MAPPED (window))
3463 XIconifyWindow (GDK_WINDOW_XDISPLAY (window),
3464 GDK_WINDOW_XID (window),
3465 gdk_screen_get_number (GDK_WINDOW_SCREEN (window)));
3469 /* Flip our client side flag, the real work happens on map. */
3470 gdk_synthesize_window_state (window,
3472 GDK_WINDOW_STATE_ICONIFIED);
3477 gdk_x11_window_deiconify (GdkWindow *window)
3479 if (GDK_WINDOW_DESTROYED (window) ||
3480 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3483 if (GDK_WINDOW_IS_MAPPED (window))
3485 gdk_window_show (window);
3489 /* Flip our client side flag, the real work happens on map. */
3490 gdk_synthesize_window_state (window,
3491 GDK_WINDOW_STATE_ICONIFIED,
3497 gdk_x11_window_stick (GdkWindow *window)
3499 if (GDK_WINDOW_DESTROYED (window) ||
3500 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3503 if (GDK_WINDOW_IS_MAPPED (window))
3505 /* "stick" means stick to all desktops _and_ do not scroll with the
3506 * viewport. i.e. glue to the monitor glass in all cases.
3509 XClientMessageEvent xclient;
3511 /* Request stick during viewport scroll */
3512 gdk_wmspec_change_state (TRUE, window,
3513 gdk_atom_intern_static_string ("_NET_WM_STATE_STICKY"),
3516 /* Request desktop 0xFFFFFFFF */
3517 memset (&xclient, 0, sizeof (xclient));
3518 xclient.type = ClientMessage;
3519 xclient.window = GDK_WINDOW_XID (window);
3520 xclient.display = GDK_WINDOW_XDISPLAY (window);
3521 xclient.message_type = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
3523 xclient.format = 32;
3525 xclient.data.l[0] = 0xFFFFFFFF;
3526 xclient.data.l[1] = 0;
3527 xclient.data.l[2] = 0;
3528 xclient.data.l[3] = 0;
3529 xclient.data.l[4] = 0;
3531 XSendEvent (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XROOTWIN (window), False,
3532 SubstructureRedirectMask | SubstructureNotifyMask,
3533 (XEvent *)&xclient);
3537 /* Flip our client side flag, the real work happens on map. */
3538 gdk_synthesize_window_state (window,
3540 GDK_WINDOW_STATE_STICKY);
3545 gdk_x11_window_unstick (GdkWindow *window)
3547 if (GDK_WINDOW_DESTROYED (window) ||
3548 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3551 if (GDK_WINDOW_IS_MAPPED (window))
3553 /* Request unstick from viewport */
3554 gdk_wmspec_change_state (FALSE, window,
3555 gdk_atom_intern_static_string ("_NET_WM_STATE_STICKY"),
3558 move_to_current_desktop (window);
3562 /* Flip our client side flag, the real work happens on map. */
3563 gdk_synthesize_window_state (window,
3564 GDK_WINDOW_STATE_STICKY,
3571 gdk_x11_window_maximize (GdkWindow *window)
3573 if (GDK_WINDOW_DESTROYED (window) ||
3574 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3577 if (GDK_WINDOW_IS_MAPPED (window))
3578 gdk_wmspec_change_state (TRUE, window,
3579 gdk_atom_intern_static_string ("_NET_WM_STATE_MAXIMIZED_VERT"),
3580 gdk_atom_intern_static_string ("_NET_WM_STATE_MAXIMIZED_HORZ"));
3582 gdk_synthesize_window_state (window,
3584 GDK_WINDOW_STATE_MAXIMIZED);
3588 gdk_x11_window_unmaximize (GdkWindow *window)
3590 if (GDK_WINDOW_DESTROYED (window) ||
3591 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3594 if (GDK_WINDOW_IS_MAPPED (window))
3595 gdk_wmspec_change_state (FALSE, window,
3596 gdk_atom_intern_static_string ("_NET_WM_STATE_MAXIMIZED_VERT"),
3597 gdk_atom_intern_static_string ("_NET_WM_STATE_MAXIMIZED_HORZ"));
3599 gdk_synthesize_window_state (window,
3600 GDK_WINDOW_STATE_MAXIMIZED,
3605 gdk_x11_window_fullscreen (GdkWindow *window)
3607 if (GDK_WINDOW_DESTROYED (window) ||
3608 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3611 if (GDK_WINDOW_IS_MAPPED (window))
3612 gdk_wmspec_change_state (TRUE, window,
3613 gdk_atom_intern_static_string ("_NET_WM_STATE_FULLSCREEN"),
3617 gdk_synthesize_window_state (window,
3619 GDK_WINDOW_STATE_FULLSCREEN);
3623 gdk_x11_window_unfullscreen (GdkWindow *window)
3625 if (GDK_WINDOW_DESTROYED (window) ||
3626 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3629 if (GDK_WINDOW_IS_MAPPED (window))
3630 gdk_wmspec_change_state (FALSE, window,
3631 gdk_atom_intern_static_string ("_NET_WM_STATE_FULLSCREEN"),
3635 gdk_synthesize_window_state (window,
3636 GDK_WINDOW_STATE_FULLSCREEN,
3641 gdk_x11_window_set_keep_above (GdkWindow *window,
3644 g_return_if_fail (GDK_IS_WINDOW (window));
3646 if (GDK_WINDOW_DESTROYED (window) ||
3647 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3650 if (GDK_WINDOW_IS_MAPPED (window))
3653 gdk_wmspec_change_state (FALSE, window,
3654 gdk_atom_intern_static_string ("_NET_WM_STATE_BELOW"),
3656 gdk_wmspec_change_state (setting, window,
3657 gdk_atom_intern_static_string ("_NET_WM_STATE_ABOVE"),
3661 gdk_synthesize_window_state (window,
3662 setting ? GDK_WINDOW_STATE_BELOW : GDK_WINDOW_STATE_ABOVE,
3663 setting ? GDK_WINDOW_STATE_ABOVE : 0);
3667 gdk_x11_window_set_keep_below (GdkWindow *window, gboolean setting)
3669 g_return_if_fail (GDK_IS_WINDOW (window));
3671 if (GDK_WINDOW_DESTROYED (window) ||
3672 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3675 if (GDK_WINDOW_IS_MAPPED (window))
3678 gdk_wmspec_change_state (FALSE, window,
3679 gdk_atom_intern_static_string ("_NET_WM_STATE_ABOVE"),
3681 gdk_wmspec_change_state (setting, window,
3682 gdk_atom_intern_static_string ("_NET_WM_STATE_BELOW"),
3686 gdk_synthesize_window_state (window,
3687 setting ? GDK_WINDOW_STATE_ABOVE : GDK_WINDOW_STATE_BELOW,
3688 setting ? GDK_WINDOW_STATE_BELOW : 0);
3692 gdk_x11_window_get_group (GdkWindow *window)
3694 GdkToplevelX11 *toplevel;
3696 if (GDK_WINDOW_DESTROYED (window) ||
3697 !WINDOW_IS_TOPLEVEL (window))
3700 toplevel = _gdk_x11_window_get_toplevel (window);
3702 return toplevel->group_leader;
3706 gdk_x11_window_set_group (GdkWindow *window,
3709 GdkToplevelX11 *toplevel;
3711 g_return_if_fail (GDK_IS_WINDOW (window));
3712 g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD);
3713 g_return_if_fail (leader == NULL || GDK_IS_WINDOW (leader));
3715 if (GDK_WINDOW_DESTROYED (window) ||
3716 (leader != NULL && GDK_WINDOW_DESTROYED (leader)) ||
3717 !WINDOW_IS_TOPLEVEL (window))
3720 toplevel = _gdk_x11_window_get_toplevel (window);
3723 leader = gdk_display_get_default_group (gdk_window_get_display (window));
3725 if (toplevel->group_leader != leader)
3727 if (toplevel->group_leader)
3728 g_object_unref (toplevel->group_leader);
3729 toplevel->group_leader = g_object_ref (leader);
3730 (_gdk_x11_window_get_toplevel (leader))->is_leader = TRUE;
3733 update_wm_hints (window, FALSE);
3736 static MotifWmHints *
3737 gdk_window_get_mwm_hints (GdkWindow *window)
3739 GdkDisplay *display;
3740 Atom hints_atom = None;
3747 if (GDK_WINDOW_DESTROYED (window))
3750 display = gdk_window_get_display (window);
3752 hints_atom = gdk_x11_get_xatom_by_name_for_display (display, _XA_MOTIF_WM_HINTS);
3754 XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
3755 hints_atom, 0, sizeof (MotifWmHints)/sizeof (long),
3756 False, AnyPropertyType, &type, &format, &nitems,
3757 &bytes_after, &data);
3762 return (MotifWmHints *)data;
3766 gdk_window_set_mwm_hints (GdkWindow *window,
3767 MotifWmHints *new_hints)
3769 GdkDisplay *display;
3770 Atom hints_atom = None;
3772 MotifWmHints *hints;
3778 if (GDK_WINDOW_DESTROYED (window))
3781 display = gdk_window_get_display (window);
3783 hints_atom = gdk_x11_get_xatom_by_name_for_display (display, _XA_MOTIF_WM_HINTS);
3785 XGetWindowProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
3786 hints_atom, 0, sizeof (MotifWmHints)/sizeof (long),
3787 False, AnyPropertyType, &type, &format, &nitems,
3788 &bytes_after, &data);
3794 hints = (MotifWmHints *)data;
3796 if (new_hints->flags & MWM_HINTS_FUNCTIONS)
3798 hints->flags |= MWM_HINTS_FUNCTIONS;
3799 hints->functions = new_hints->functions;
3801 if (new_hints->flags & MWM_HINTS_DECORATIONS)
3803 hints->flags |= MWM_HINTS_DECORATIONS;
3804 hints->decorations = new_hints->decorations;
3808 XChangeProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
3809 hints_atom, hints_atom, 32, PropModeReplace,
3810 (guchar *)hints, sizeof (MotifWmHints)/sizeof (long));
3812 if (hints != new_hints)
3817 gdk_x11_window_set_decorations (GdkWindow *window,
3818 GdkWMDecoration decorations)
3822 if (GDK_WINDOW_DESTROYED (window) ||
3823 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3826 /* initialize to zero to avoid writing uninitialized data to socket */
3827 memset(&hints, 0, sizeof(hints));
3828 hints.flags = MWM_HINTS_DECORATIONS;
3829 hints.decorations = decorations;
3831 gdk_window_set_mwm_hints (window, &hints);
3835 gdk_x11_window_get_decorations(GdkWindow *window,
3836 GdkWMDecoration *decorations)
3838 MotifWmHints *hints;
3839 gboolean result = FALSE;
3841 if (GDK_WINDOW_DESTROYED (window) ||
3842 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3845 hints = gdk_window_get_mwm_hints (window);
3849 if (hints->flags & MWM_HINTS_DECORATIONS)
3852 *decorations = hints->decorations;
3863 gdk_x11_window_set_functions (GdkWindow *window,
3864 GdkWMFunction functions)
3868 g_return_if_fail (GDK_IS_WINDOW (window));
3870 if (GDK_WINDOW_DESTROYED (window) ||
3871 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
3874 /* initialize to zero to avoid writing uninitialized data to socket */
3875 memset(&hints, 0, sizeof(hints));
3876 hints.flags = MWM_HINTS_FUNCTIONS;
3877 hints.functions = functions;
3879 gdk_window_set_mwm_hints (window, &hints);
3883 _gdk_x11_xwindow_get_shape (Display *xdisplay,
3887 cairo_region_t *shape;
3895 /* Note that XShapeGetRectangles returns NULL in two situations:
3896 * - the server doesn't support the SHAPE extension
3897 * - the shape is empty
3899 * Since we can't discriminate these here, we always return
3900 * an empty shape. It is the callers responsibility to check
3901 * whether the server supports the SHAPE extensions beforehand.
3903 xrl = XShapeGetRectangles (xdisplay, window, shape_type, &rn, &ord);
3906 return cairo_region_create (); /* Empty */
3908 if (ord != YXBanded)
3910 /* This really shouldn't happen with any xserver, as they
3911 * generally convert regions to YXBanded internally
3913 g_warning ("non YXBanded shape masks not supported");
3918 rl = g_new (GdkRectangle, rn);
3919 for (i = 0; i < rn; i++)
3923 rl[i].width = xrl[i].width;
3924 rl[i].height = xrl[i].height;
3928 shape = cairo_region_create_rectangles (rl, rn);
3935 static cairo_region_t *
3936 gdk_x11_window_get_shape (GdkWindow *window)
3938 if (!GDK_WINDOW_DESTROYED (window) &&
3939 gdk_display_supports_shapes (GDK_WINDOW_DISPLAY (window)))
3940 return _gdk_x11_xwindow_get_shape (GDK_WINDOW_XDISPLAY (window),
3941 GDK_WINDOW_XID (window),
3947 static cairo_region_t *
3948 gdk_x11_window_get_input_shape (GdkWindow *window)
3950 #if defined(ShapeInput)
3951 if (!GDK_WINDOW_DESTROYED (window) &&
3952 gdk_display_supports_input_shapes (GDK_WINDOW_DISPLAY (window)))
3953 return _gdk_x11_xwindow_get_shape (GDK_WINDOW_XDISPLAY (window),
3954 GDK_WINDOW_XID (window),
3962 gdk_window_set_static_bit_gravity (GdkWindow *window,
3965 XSetWindowAttributes xattributes;
3966 guint xattributes_mask = 0;
3968 g_return_if_fail (GDK_IS_WINDOW (window));
3970 if (window->input_only)
3973 xattributes.bit_gravity = StaticGravity;
3974 xattributes_mask |= CWBitGravity;
3975 xattributes.bit_gravity = on ? StaticGravity : ForgetGravity;
3976 XChangeWindowAttributes (GDK_WINDOW_XDISPLAY (window),
3977 GDK_WINDOW_XID (window),
3978 CWBitGravity, &xattributes);
3982 gdk_window_set_static_win_gravity (GdkWindow *window,
3985 XSetWindowAttributes xattributes;
3987 g_return_if_fail (GDK_IS_WINDOW (window));
3989 xattributes.win_gravity = on ? StaticGravity : NorthWestGravity;
3991 XChangeWindowAttributes (GDK_WINDOW_XDISPLAY (window),
3992 GDK_WINDOW_XID (window),
3993 CWWinGravity, &xattributes);
3997 gdk_window_x11_set_static_gravities (GdkWindow *window,
3998 gboolean use_static)
4002 if (!use_static == !window->guffaw_gravity)
4005 window->guffaw_gravity = use_static;
4007 if (!GDK_WINDOW_DESTROYED (window))
4009 gdk_window_set_static_bit_gravity (window, use_static);
4011 tmp_list = window->children;
4014 gdk_window_set_static_win_gravity (tmp_list->data, use_static);
4016 tmp_list = tmp_list->next;
4023 /* From the WM spec */
4024 #define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0
4025 #define _NET_WM_MOVERESIZE_SIZE_TOP 1
4026 #define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT 2
4027 #define _NET_WM_MOVERESIZE_SIZE_RIGHT 3
4028 #define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4
4029 #define _NET_WM_MOVERESIZE_SIZE_BOTTOM 5
4030 #define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT 6
4031 #define _NET_WM_MOVERESIZE_SIZE_LEFT 7
4032 #define _NET_WM_MOVERESIZE_MOVE 8 /* movement only */
4033 #define _NET_WM_MOVERESIZE_SIZE_KEYBOARD 9 /* size via keyboard */
4034 #define _NET_WM_MOVERESIZE_MOVE_KEYBOARD 10 /* move via keyboard */
4035 #define _NET_WM_MOVERESIZE_CANCEL 11 /* cancel operation */
4038 wmspec_send_message (GdkDisplay *display,
4045 XClientMessageEvent xclient;
4047 memset (&xclient, 0, sizeof (xclient));
4048 xclient.type = ClientMessage;
4049 xclient.window = GDK_WINDOW_XID (window);
4050 xclient.message_type =
4051 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_MOVERESIZE");
4052 xclient.format = 32;
4053 xclient.data.l[0] = root_x;
4054 xclient.data.l[1] = root_y;
4055 xclient.data.l[2] = action;
4056 xclient.data.l[3] = button;
4057 xclient.data.l[4] = 1; /* source indication */
4059 XSendEvent (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XROOTWIN (window), False,
4060 SubstructureRedirectMask | SubstructureNotifyMask,
4061 (XEvent *)&xclient);
4065 handle_wmspec_button_release (GdkDisplay *display,
4068 GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
4071 #if defined (HAVE_XGENERICEVENTS) && defined (XINPUT_2)
4072 XIEvent *xiev = (XIEvent *) xevent->xcookie.data;
4073 XIDeviceEvent *xidev = (XIDeviceEvent *) xiev;
4075 if (xevent->xany.type == GenericEvent)
4076 window = gdk_x11_window_lookup_for_display (display, xidev->event);
4079 window = gdk_x11_window_lookup_for_display (display, xevent->xany.window);
4081 if (display_x11->wm_moveresize_button != 0 && window != NULL)
4083 if ((xevent->xany.type == ButtonRelease &&
4084 xevent->xbutton.button == display_x11->wm_moveresize_button)
4085 #if defined (HAVE_XGENERICEVENTS) && defined (XINPUT_2)
4087 (xevent->xany.type == GenericEvent &&
4088 xiev->evtype == XI_ButtonRelease &&
4089 xidev->detail == display_x11->wm_moveresize_button)
4093 display_x11->wm_moveresize_button = 0;
4094 wmspec_send_message (display, window, 0, 0, _NET_WM_MOVERESIZE_CANCEL, 0);
4103 wmspec_moveresize (GdkWindow *window,
4111 GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
4113 /* Release passive grab */
4114 gdk_device_ungrab (device, timestamp);
4115 GDK_X11_DISPLAY (display)->wm_moveresize_button = button;
4117 wmspec_send_message (display, window, root_x, root_y, direction, button);
4121 wmspec_resize_drag (GdkWindow *window,
4131 /* Let the compiler turn a switch into a table, instead
4132 * of doing the table manually, this way is easier to verify.
4136 case GDK_WINDOW_EDGE_NORTH_WEST:
4137 direction = _NET_WM_MOVERESIZE_SIZE_TOPLEFT;
4140 case GDK_WINDOW_EDGE_NORTH:
4141 direction = _NET_WM_MOVERESIZE_SIZE_TOP;
4144 case GDK_WINDOW_EDGE_NORTH_EAST:
4145 direction = _NET_WM_MOVERESIZE_SIZE_TOPRIGHT;
4148 case GDK_WINDOW_EDGE_WEST:
4149 direction = _NET_WM_MOVERESIZE_SIZE_LEFT;
4152 case GDK_WINDOW_EDGE_EAST:
4153 direction = _NET_WM_MOVERESIZE_SIZE_RIGHT;
4156 case GDK_WINDOW_EDGE_SOUTH_WEST:
4157 direction = _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT;
4160 case GDK_WINDOW_EDGE_SOUTH:
4161 direction = _NET_WM_MOVERESIZE_SIZE_BOTTOM;
4164 case GDK_WINDOW_EDGE_SOUTH_EAST:
4165 direction = _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT;
4169 g_warning ("gdk_window_begin_resize_drag: bad resize edge %d!",
4174 wmspec_moveresize (window, direction, device, button, root_x, root_y, timestamp);
4177 typedef struct _MoveResizeData MoveResizeData;
4179 struct _MoveResizeData
4181 GdkDisplay *display;
4183 GdkWindow *moveresize_window;
4184 GdkWindow *moveresize_emulation_window;
4186 GdkWindowEdge resize_edge;
4188 gint moveresize_button;
4191 gint moveresize_orig_x;
4192 gint moveresize_orig_y;
4193 gint moveresize_orig_width;
4194 gint moveresize_orig_height;
4195 GdkWindowHints moveresize_geom_mask;
4196 GdkGeometry moveresize_geometry;
4197 Time moveresize_process_time;
4198 XEvent *moveresize_pending_event;
4201 static MoveResizeData *
4202 get_move_resize_data (GdkDisplay *display,
4205 MoveResizeData *mv_resize;
4206 static GQuark move_resize_quark = 0;
4208 if (!move_resize_quark)
4209 move_resize_quark = g_quark_from_static_string ("gdk-window-moveresize");
4211 mv_resize = g_object_get_qdata (G_OBJECT (display), move_resize_quark);
4213 if (!mv_resize && create)
4215 mv_resize = g_new0 (MoveResizeData, 1);
4216 mv_resize->display = display;
4218 g_object_set_qdata (G_OBJECT (display), move_resize_quark, mv_resize);
4225 update_pos (MoveResizeData *mv_resize,
4231 dx = new_root_x - mv_resize->moveresize_x;
4232 dy = new_root_y - mv_resize->moveresize_y;
4234 if (mv_resize->is_resize)
4238 x = mv_resize->moveresize_orig_x;
4239 y = mv_resize->moveresize_orig_y;
4241 w = mv_resize->moveresize_orig_width;
4242 h = mv_resize->moveresize_orig_height;
4244 switch (mv_resize->resize_edge)
4246 case GDK_WINDOW_EDGE_NORTH_WEST:
4252 case GDK_WINDOW_EDGE_NORTH:
4256 case GDK_WINDOW_EDGE_NORTH_EAST:
4261 case GDK_WINDOW_EDGE_SOUTH_WEST:
4266 case GDK_WINDOW_EDGE_SOUTH_EAST:
4270 case GDK_WINDOW_EDGE_SOUTH:
4273 case GDK_WINDOW_EDGE_EAST:
4276 case GDK_WINDOW_EDGE_WEST:
4287 if (mv_resize->moveresize_geom_mask)
4289 gdk_window_constrain_size (&mv_resize->moveresize_geometry,
4290 mv_resize->moveresize_geom_mask,
4294 gdk_window_move_resize (mv_resize->moveresize_window, x, y, w, h);
4300 x = mv_resize->moveresize_orig_x + dx;
4301 y = mv_resize->moveresize_orig_y + dy;
4303 gdk_window_move (mv_resize->moveresize_window, x, y);
4308 finish_drag (MoveResizeData *mv_resize)
4310 gdk_window_destroy (mv_resize->moveresize_emulation_window);
4311 mv_resize->moveresize_emulation_window = NULL;
4312 g_object_unref (mv_resize->moveresize_window);
4313 mv_resize->moveresize_window = NULL;
4315 if (mv_resize->moveresize_pending_event)
4317 g_free (mv_resize->moveresize_pending_event);
4318 mv_resize->moveresize_pending_event = NULL;
4323 lookahead_motion_predicate (Display *xdisplay,
4327 gboolean *seen_release = (gboolean *)arg;
4328 GdkDisplay *display = gdk_x11_lookup_xdisplay (xdisplay);
4329 MoveResizeData *mv_resize = get_move_resize_data (display, FALSE);
4334 switch (event->xany.type)
4337 *seen_release = TRUE;
4340 mv_resize->moveresize_process_time = event->xmotion.time;
4350 moveresize_lookahead (MoveResizeData *mv_resize,
4354 gboolean seen_release = FALSE;
4356 if (mv_resize->moveresize_process_time)
4358 if (event->xmotion.time == mv_resize->moveresize_process_time)
4360 mv_resize->moveresize_process_time = 0;
4367 XCheckIfEvent (event->xany.display, &tmp_event,
4368 lookahead_motion_predicate, (XPointer) & seen_release);
4370 return mv_resize->moveresize_process_time == 0;
4374 _gdk_x11_moveresize_handle_event (XEvent *event)
4376 guint button_mask = 0;
4377 GdkDisplay *display = gdk_x11_lookup_xdisplay (event->xany.display);
4378 MoveResizeData *mv_resize = get_move_resize_data (display, FALSE);
4380 if (handle_wmspec_button_release (display, event))
4383 if (!mv_resize || !mv_resize->moveresize_window)
4386 button_mask = GDK_BUTTON1_MASK << (mv_resize->moveresize_button - 1);
4388 switch (event->xany.type)
4391 if (mv_resize->moveresize_window->resize_count > 0)
4393 if (mv_resize->moveresize_pending_event)
4394 *mv_resize->moveresize_pending_event = *event;
4396 mv_resize->moveresize_pending_event =
4397 g_memdup (event, sizeof (XEvent));
4401 if (!moveresize_lookahead (mv_resize, event))
4404 update_pos (mv_resize,
4405 event->xmotion.x_root,
4406 event->xmotion.y_root);
4408 /* This should never be triggered in normal cases, but in the
4409 * case where the drag started without an implicit grab being
4410 * in effect, we could miss the release if it occurs before
4411 * we grab the pointer; this ensures that we will never
4412 * get a permanently stuck grab.
4414 if ((event->xmotion.state & button_mask) == 0)
4415 finish_drag (mv_resize);
4419 update_pos (mv_resize,
4420 event->xbutton.x_root,
4421 event->xbutton.y_root);
4423 if (event->xbutton.button == mv_resize->moveresize_button)
4424 finish_drag (mv_resize);
4427 #if defined (HAVE_XGENERICEVENTS) && defined (XINPUT_2)
4430 /* we just assume this is an XI2 event */
4431 XIEvent *ev = (XIEvent *) event->xcookie.data;
4432 XIDeviceEvent *xev = (XIDeviceEvent *)ev;
4437 update_pos (mv_resize, xev->root_x, xev->root_y);
4438 state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group);
4439 if ((state & button_mask) == 0)
4440 finish_drag (mv_resize);
4443 case XI_ButtonRelease:
4444 update_pos (mv_resize, xev->root_x, xev->root_y);
4445 if (xev->detail == mv_resize->moveresize_button)
4446 finish_drag (mv_resize);
4458 _gdk_x11_moveresize_configure_done (GdkDisplay *display,
4462 MoveResizeData *mv_resize = get_move_resize_data (display, FALSE);
4464 GDK_X11_DISPLAY (display)->wm_moveresize_button = 0;
4466 if (!mv_resize || window != mv_resize->moveresize_window)
4469 if (mv_resize->moveresize_pending_event)
4471 tmp_event = mv_resize->moveresize_pending_event;
4472 mv_resize->moveresize_pending_event = NULL;
4473 _gdk_x11_moveresize_handle_event (tmp_event);
4481 create_moveresize_window (MoveResizeData *mv_resize,
4484 GdkWindowAttr attributes;
4485 gint attributes_mask;
4486 GdkGrabStatus status;
4488 g_assert (mv_resize->moveresize_emulation_window == NULL);
4490 attributes.x = -100;
4491 attributes.y = -100;
4492 attributes.width = 10;
4493 attributes.height = 10;
4494 attributes.window_type = GDK_WINDOW_TEMP;
4495 attributes.wclass = GDK_INPUT_ONLY;
4496 attributes.override_redirect = TRUE;
4497 attributes.event_mask = 0;
4499 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_NOREDIR;
4501 mv_resize->moveresize_emulation_window =
4502 gdk_window_new (gdk_screen_get_root_window (gdk_display_get_default_screen (mv_resize->display)),
4506 gdk_window_show (mv_resize->moveresize_emulation_window);
4508 status = gdk_device_grab (mv_resize->device,
4509 mv_resize->moveresize_emulation_window,
4512 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK,
4516 if (status != GDK_GRAB_SUCCESS)
4518 /* If this fails, some other client has grabbed the window
4521 finish_drag (mv_resize);
4524 mv_resize->moveresize_process_time = 0;
4528 Calculate mv_resize->moveresize_orig_x and mv_resize->moveresize_orig_y
4529 so that calling XMoveWindow with these coordinates will not move the
4531 Note that this depends on the WM to implement ICCCM-compliant reference
4535 calculate_unmoving_origin (MoveResizeData *mv_resize)
4540 if (mv_resize->moveresize_geom_mask & GDK_HINT_WIN_GRAVITY &&
4541 mv_resize->moveresize_geometry.win_gravity == GDK_GRAVITY_STATIC)
4543 gdk_window_get_origin (mv_resize->moveresize_window,
4544 &mv_resize->moveresize_orig_x,
4545 &mv_resize->moveresize_orig_y);
4549 gdk_window_get_frame_extents (mv_resize->moveresize_window, &rect);
4550 gdk_window_get_geometry (mv_resize->moveresize_window,
4551 NULL, NULL, &width, &height);
4553 switch (mv_resize->moveresize_geometry.win_gravity)
4555 case GDK_GRAVITY_NORTH_WEST:
4556 mv_resize->moveresize_orig_x = rect.x;
4557 mv_resize->moveresize_orig_y = rect.y;
4559 case GDK_GRAVITY_NORTH:
4560 mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2;
4561 mv_resize->moveresize_orig_y = rect.y;
4563 case GDK_GRAVITY_NORTH_EAST:
4564 mv_resize->moveresize_orig_x = rect.x + rect.width - width;
4565 mv_resize->moveresize_orig_y = rect.y;
4567 case GDK_GRAVITY_WEST:
4568 mv_resize->moveresize_orig_x = rect.x;
4569 mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2;
4571 case GDK_GRAVITY_CENTER:
4572 mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2;
4573 mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2;
4575 case GDK_GRAVITY_EAST:
4576 mv_resize->moveresize_orig_x = rect.x + rect.width - width;
4577 mv_resize->moveresize_orig_y = rect.y + rect.height / 2 - height / 2;
4579 case GDK_GRAVITY_SOUTH_WEST:
4580 mv_resize->moveresize_orig_x = rect.x;
4581 mv_resize->moveresize_orig_y = rect.y + rect.height - height;
4583 case GDK_GRAVITY_SOUTH:
4584 mv_resize->moveresize_orig_x = rect.x + rect.width / 2 - width / 2;
4585 mv_resize->moveresize_orig_y = rect.y + rect.height - height;
4587 case GDK_GRAVITY_SOUTH_EAST:
4588 mv_resize->moveresize_orig_x = rect.x + rect.width - width;
4589 mv_resize->moveresize_orig_y = rect.y + rect.height - height;
4592 mv_resize->moveresize_orig_x = rect.x;
4593 mv_resize->moveresize_orig_y = rect.y;
4600 emulate_resize_drag (GdkWindow *window,
4608 MoveResizeData *mv_resize = get_move_resize_data (GDK_WINDOW_DISPLAY (window), TRUE);
4610 mv_resize->is_resize = TRUE;
4611 mv_resize->moveresize_button = button;
4612 mv_resize->resize_edge = edge;
4613 mv_resize->device = device;
4614 mv_resize->moveresize_x = root_x;
4615 mv_resize->moveresize_y = root_y;
4616 mv_resize->moveresize_window = g_object_ref (window);
4618 mv_resize->moveresize_orig_width = gdk_window_get_width (window);
4619 mv_resize->moveresize_orig_height = gdk_window_get_height (window);
4621 mv_resize->moveresize_geom_mask = 0;
4622 gdk_window_get_geometry_hints (window,
4623 &mv_resize->moveresize_geometry,
4624 &mv_resize->moveresize_geom_mask);
4626 calculate_unmoving_origin (mv_resize);
4628 create_moveresize_window (mv_resize, timestamp);
4632 emulate_move_drag (GdkWindow *window,
4639 MoveResizeData *mv_resize = get_move_resize_data (GDK_WINDOW_DISPLAY (window), TRUE);
4641 mv_resize->is_resize = FALSE;
4642 mv_resize->device = device;
4643 mv_resize->moveresize_button = button;
4644 mv_resize->moveresize_x = root_x;
4645 mv_resize->moveresize_y = root_y;
4647 mv_resize->moveresize_window = g_object_ref (window);
4649 calculate_unmoving_origin (mv_resize);
4651 create_moveresize_window (mv_resize, timestamp);
4655 gdk_x11_window_begin_resize_drag (GdkWindow *window,
4663 if (GDK_WINDOW_DESTROYED (window) ||
4664 !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
4667 if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
4668 gdk_atom_intern_static_string ("_NET_WM_MOVERESIZE")))
4669 wmspec_resize_drag (window, edge, device, button, root_x, root_y, timestamp);
4671 emulate_resize_drag (window, edge, device, button, root_x, root_y, timestamp);
4675 gdk_x11_window_begin_move_drag (GdkWindow *window,
4682 if (GDK_WINDOW_DESTROYED (window) ||
4683 !WINDOW_IS_TOPLEVEL (window))
4686 if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
4687 gdk_atom_intern_static_string ("_NET_WM_MOVERESIZE")))
4688 wmspec_moveresize (window, _NET_WM_MOVERESIZE_MOVE,
4689 device, button, root_x, root_y, timestamp);
4691 emulate_move_drag (window, device, button, root_x, root_y, timestamp);
4695 gdk_x11_window_enable_synchronized_configure (GdkWindow *window)
4697 GdkWindowImplX11 *impl;
4699 if (!GDK_IS_WINDOW_IMPL_X11 (window->impl))
4702 impl = GDK_WINDOW_IMPL_X11 (window->impl);
4704 if (!impl->use_synchronized_configure)
4706 /* This basically means you want to do fancy X specific stuff, so
4707 ensure we have a native window */
4708 gdk_window_ensure_native (window);
4710 impl->use_synchronized_configure = TRUE;
4711 ensure_sync_counter (window);
4716 gdk_x11_window_configure_finished (GdkWindow *window)
4718 GdkWindowImplX11 *impl;
4720 if (!WINDOW_IS_TOPLEVEL (window))
4723 impl = GDK_WINDOW_IMPL_X11 (window->impl);
4724 if (!impl->use_synchronized_configure)
4728 if (!GDK_WINDOW_DESTROYED (window))
4730 GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
4731 GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
4733 if (toplevel && toplevel->update_counter != None &&
4734 GDK_X11_DISPLAY (display)->use_sync &&
4735 !XSyncValueIsZero (toplevel->current_counter_value))
4737 XSyncSetCounter (GDK_WINDOW_XDISPLAY (window),
4738 toplevel->update_counter,
4739 toplevel->current_counter_value);
4741 XSyncIntToValue (&toplevel->current_counter_value, 0);
4748 gdk_x11_window_beep (GdkWindow *window)
4750 GdkDisplay *display;
4752 display = GDK_WINDOW_DISPLAY (window);
4755 if (GDK_X11_DISPLAY (display)->use_xkb)
4757 XkbBell (GDK_DISPLAY_XDISPLAY (display),
4758 GDK_WINDOW_XID (window),
4769 gdk_x11_window_set_opacity (GdkWindow *window,
4772 GdkDisplay *display;
4775 g_return_if_fail (GDK_IS_WINDOW (window));
4777 if (GDK_WINDOW_DESTROYED (window) ||
4778 !WINDOW_IS_TOPLEVEL (window))
4781 display = gdk_window_get_display (window);
4785 else if (opacity > 1)
4788 cardinal = opacity * 0xffffffff;
4790 if (cardinal == 0xffffffff)
4791 XDeleteProperty (GDK_DISPLAY_XDISPLAY (display),
4792 GDK_WINDOW_XID (window),
4793 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_OPACITY"));
4795 XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
4796 GDK_WINDOW_XID (window),
4797 gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_OPACITY"),
4800 (guchar *) &cardinal, 1);
4804 gdk_x11_window_set_composited (GdkWindow *window,
4805 gboolean composited)
4807 #if defined(HAVE_XCOMPOSITE) && defined(HAVE_XDAMAGE) && defined (HAVE_XFIXES)
4808 GdkWindowImplX11 *impl;
4809 GdkDisplay *display;
4813 impl = GDK_WINDOW_IMPL_X11 (window->impl);
4815 display = gdk_window_get_display (window);
4816 dpy = GDK_DISPLAY_XDISPLAY (display);
4817 xid = GDK_WINDOW_XID (window);
4821 XCompositeRedirectWindow (dpy, xid, CompositeRedirectManual);
4822 impl->damage = XDamageCreate (dpy, xid, XDamageReportBoundingBox);
4826 XCompositeUnredirectWindow (dpy, xid, CompositeRedirectManual);
4827 XDamageDestroy (dpy, impl->damage);
4828 impl->damage = None;
4834 gdk_x11_window_process_updates_recurse (GdkWindow *window,
4835 cairo_region_t *region)
4837 _gdk_window_process_updates_recurse (window, region);
4841 _gdk_x11_display_before_process_all_updates (GdkDisplay *display)
4846 _gdk_x11_display_after_process_all_updates (GdkDisplay *display)
4851 timestamp_predicate (Display *display,
4855 Window xwindow = GPOINTER_TO_UINT (arg);
4856 GdkDisplay *gdk_display = gdk_x11_lookup_xdisplay (display);
4858 if (xevent->type == PropertyNotify &&
4859 xevent->xproperty.window == xwindow &&
4860 xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (gdk_display,
4861 "GDK_TIMESTAMP_PROP"))
4868 * gdk_x11_get_server_time:
4869 * @window: (type GdkX11Window): a #GdkWindow, used for communication
4870 * with the server. The window must have
4871 * GDK_PROPERTY_CHANGE_MASK in its events mask or a hang will
4874 * Routine to get the current X server time stamp.
4876 * Return value: the time stamp.
4879 gdk_x11_get_server_time (GdkWindow *window)
4885 Atom timestamp_prop_atom;
4887 g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
4888 g_return_val_if_fail (!GDK_WINDOW_DESTROYED (window), 0);
4890 xdisplay = GDK_WINDOW_XDISPLAY (window);
4891 xwindow = GDK_WINDOW_XID (window);
4892 timestamp_prop_atom =
4893 gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
4894 "GDK_TIMESTAMP_PROP");
4896 XChangeProperty (xdisplay, xwindow, timestamp_prop_atom,
4897 timestamp_prop_atom,
4898 8, PropModeReplace, &c, 1);
4900 XIfEvent (xdisplay, &xevent,
4901 timestamp_predicate, GUINT_TO_POINTER(xwindow));
4903 return xevent.xproperty.time;
4907 * gdk_x11_window_get_xid:
4908 * @window: (type GdkX11Window): a native #GdkWindow.
4910 * Returns the X resource (window) belonging to a #GdkWindow.
4912 * Return value: the ID of @drawable's X resource.
4915 gdk_x11_window_get_xid (GdkWindow *window)
4917 /* Try to ensure the window has a native window */
4918 if (!_gdk_window_has_impl (window))
4920 gdk_window_ensure_native (window);
4922 /* We sync here to ensure the window is created in the Xserver when
4923 * this function returns. This is required because the returned XID
4924 * for this window must be valid immediately, even with another
4925 * connection to the Xserver */
4926 gdk_display_sync (gdk_window_get_display (window));
4929 if (!GDK_WINDOW_IS_X11 (window))
4931 g_warning (G_STRLOC " drawable is not a native X11 window");
4935 return GDK_WINDOW_IMPL_X11 (window->impl)->xid;
4938 extern GdkDragContext * _gdk_x11_window_drag_begin (GdkWindow *window,
4943 gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass)
4945 GObjectClass *object_class = G_OBJECT_CLASS (klass);
4946 GdkWindowImplClass *impl_class = GDK_WINDOW_IMPL_CLASS (klass);
4948 object_class->finalize = gdk_window_impl_x11_finalize;
4950 impl_class->ref_cairo_surface = gdk_x11_ref_cairo_surface;
4951 impl_class->show = gdk_window_x11_show;
4952 impl_class->hide = gdk_window_x11_hide;
4953 impl_class->withdraw = gdk_window_x11_withdraw;
4954 impl_class->set_events = gdk_window_x11_set_events;
4955 impl_class->get_events = gdk_window_x11_get_events;
4956 impl_class->raise = gdk_window_x11_raise;
4957 impl_class->lower = gdk_window_x11_lower;
4958 impl_class->restack_under = gdk_window_x11_restack_under;
4959 impl_class->restack_toplevel = gdk_window_x11_restack_toplevel;
4960 impl_class->move_resize = gdk_window_x11_move_resize;
4961 impl_class->set_background = gdk_window_x11_set_background;
4962 impl_class->reparent = gdk_window_x11_reparent;
4963 impl_class->set_device_cursor = gdk_window_x11_set_device_cursor;
4964 impl_class->get_geometry = gdk_window_x11_get_geometry;
4965 impl_class->get_root_coords = gdk_window_x11_get_root_coords;
4966 impl_class->get_device_state = gdk_window_x11_get_device_state;
4967 impl_class->shape_combine_region = gdk_window_x11_shape_combine_region;
4968 impl_class->input_shape_combine_region = gdk_window_x11_input_shape_combine_region;
4969 impl_class->set_static_gravities = gdk_window_x11_set_static_gravities;
4970 impl_class->queue_antiexpose = _gdk_x11_window_queue_antiexpose;
4971 impl_class->translate = _gdk_x11_window_translate;
4972 impl_class->destroy = gdk_x11_window_destroy;
4973 impl_class->destroy_foreign = gdk_x11_window_destroy_foreign;
4974 impl_class->resize_cairo_surface = gdk_window_x11_resize_cairo_surface;
4975 impl_class->get_shape = gdk_x11_window_get_shape;
4976 impl_class->get_input_shape = gdk_x11_window_get_input_shape;
4977 impl_class->beep = gdk_x11_window_beep;
4979 impl_class->focus = gdk_x11_window_focus;
4980 impl_class->set_type_hint = gdk_x11_window_set_type_hint;
4981 impl_class->get_type_hint = gdk_x11_window_get_type_hint;
4982 impl_class->set_modal_hint = gdk_x11_window_set_modal_hint;
4983 impl_class->set_skip_taskbar_hint = gdk_x11_window_set_skip_taskbar_hint;
4984 impl_class->set_skip_pager_hint = gdk_x11_window_set_skip_pager_hint;
4985 impl_class->set_urgency_hint = gdk_x11_window_set_urgency_hint;
4986 impl_class->set_geometry_hints = gdk_x11_window_set_geometry_hints;
4987 impl_class->set_title = gdk_x11_window_set_title;
4988 impl_class->set_role = gdk_x11_window_set_role;
4989 impl_class->set_startup_id = gdk_x11_window_set_startup_id;
4990 impl_class->set_transient_for = gdk_x11_window_set_transient_for;
4991 impl_class->get_root_origin = gdk_x11_window_get_root_origin;
4992 impl_class->get_frame_extents = gdk_x11_window_get_frame_extents;
4993 impl_class->set_override_redirect = gdk_x11_window_set_override_redirect;
4994 impl_class->set_accept_focus = gdk_x11_window_set_accept_focus;
4995 impl_class->set_focus_on_map = gdk_x11_window_set_focus_on_map;
4996 impl_class->set_icon_list = gdk_x11_window_set_icon_list;
4997 impl_class->set_icon_name = gdk_x11_window_set_icon_name;
4998 impl_class->iconify = gdk_x11_window_iconify;
4999 impl_class->deiconify = gdk_x11_window_deiconify;
5000 impl_class->stick = gdk_x11_window_stick;
5001 impl_class->unstick = gdk_x11_window_unstick;
5002 impl_class->maximize = gdk_x11_window_maximize;
5003 impl_class->unmaximize = gdk_x11_window_unmaximize;
5004 impl_class->fullscreen = gdk_x11_window_fullscreen;
5005 impl_class->unfullscreen = gdk_x11_window_unfullscreen;
5006 impl_class->set_keep_above = gdk_x11_window_set_keep_above;
5007 impl_class->set_keep_below = gdk_x11_window_set_keep_below;
5008 impl_class->get_group = gdk_x11_window_get_group;
5009 impl_class->set_group = gdk_x11_window_set_group;
5010 impl_class->set_decorations = gdk_x11_window_set_decorations;
5011 impl_class->get_decorations = gdk_x11_window_get_decorations;
5012 impl_class->set_functions = gdk_x11_window_set_functions;
5013 impl_class->set_functions = gdk_x11_window_set_functions;
5014 impl_class->begin_resize_drag = gdk_x11_window_begin_resize_drag;
5015 impl_class->begin_move_drag = gdk_x11_window_begin_move_drag;
5016 impl_class->enable_synchronized_configure = gdk_x11_window_enable_synchronized_configure;
5017 impl_class->configure_finished = gdk_x11_window_configure_finished;
5018 impl_class->set_opacity = gdk_x11_window_set_opacity;
5019 impl_class->set_composited = gdk_x11_window_set_composited;
5020 impl_class->destroy_notify = gdk_x11_window_destroy_notify;
5021 impl_class->get_drag_protocol = gdk_x11_window_get_drag_protocol;
5022 impl_class->register_dnd = _gdk_x11_window_register_dnd;
5023 impl_class->drag_begin = _gdk_x11_window_drag_begin;
5024 impl_class->process_updates_recurse = gdk_x11_window_process_updates_recurse;
5025 impl_class->sync_rendering = _gdk_x11_window_sync_rendering;
5026 impl_class->simulate_key = _gdk_x11_window_simulate_key;
5027 impl_class->simulate_button = _gdk_x11_window_simulate_button;
5028 impl_class->get_property = _gdk_x11_window_get_property;
5029 impl_class->change_property = _gdk_x11_window_change_property;
5030 impl_class->delete_property = _gdk_x11_window_delete_property;