#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <netinet/in.h>
+#include <unistd.h>
#include "gdk.h"
#include "config.h"
#include "gdkwindow.h"
#include "gdkinputprivate.h"
+#include "gdkdisplay-x11.h"
#include "gdkprivate-x11.h"
#include "gdkregion.h"
#include "gdkinternals.h"
#include <X11/extensions/shape.h>
#endif
-const int gdk_event_mask_table[21] =
+const int _gdk_event_mask_table[21] =
{
ExposureMask,
PointerMotionMask,
SubstructureNotifyMask,
ButtonPressMask /* SCROLL; on X mouse wheel events is treated as mouse button 4/5 */
};
-const int gdk_nevent_masks = sizeof (gdk_event_mask_table) / sizeof (int);
+const int _gdk_nenvent_masks = sizeof (_gdk_event_mask_table) / sizeof (int);
/* Forward declarations */
-static gboolean gdk_window_gravity_works (void);
-static void gdk_window_set_static_win_gravity (GdkWindow *window,
- gboolean on);
-static gboolean gdk_window_have_shape_ext (void);
-static gboolean gdk_window_icon_name_set (GdkWindow *window);
+static gboolean gdk_window_gravity_works (GdkWindow *window);
+static void gdk_window_set_static_win_gravity (GdkWindow *window,
+ gboolean on);
+static gboolean gdk_window_have_shape_ext (GdkDisplay *display);
+static gboolean gdk_window_icon_name_set (GdkWindow *window);
+static void gdk_window_add_colormap_windows (GdkWindow *window);
+static void set_wm_name (GdkDisplay *display,
+ Window xwindow,
+ const gchar *name);
static GdkColormap* gdk_window_impl_x11_get_colormap (GdkDrawable *drawable);
static void gdk_window_impl_x11_set_colormap (GdkDrawable *drawable,
static void
gdk_window_impl_x11_init (GdkWindowImplX11 *impl)
-{
+{
impl->width = 1;
impl->height = 1;
}
wrapper = (GdkWindowObject*) draw_impl->wrapper;
+ _gdk_xgrab_check_destroy (GDK_WINDOW (wrapper));
+
if (!GDK_WINDOW_DESTROYED (wrapper))
{
- gdk_xid_table_remove (draw_impl->xid);
+ _gdk_xid_table_remove (GDK_WINDOW_DISPLAY (object), draw_impl->xid);
if (window_impl->focus_window)
- gdk_xid_table_remove (window_impl->focus_window);
+ _gdk_xid_table_remove (GDK_WINDOW_DISPLAY (object), window_impl->focus_window);
}
G_OBJECT_CLASS (parent_class)->finalize (object);
drawable_impl->colormap == NULL)
{
XWindowAttributes window_attributes;
+ GdkVisual *visual;
- XGetWindowAttributes (drawable_impl->xdisplay,
+ XGetWindowAttributes (GDK_SCREEN_XDISPLAY (drawable_impl->screen),
drawable_impl->xid,
&window_attributes);
- drawable_impl->colormap =
- gdk_colormap_lookup (window_attributes.colormap);
+
+ visual = gdk_x11_screen_lookup_visual (drawable_impl->screen,
+ window_attributes.visual->visualid);
+ drawable_impl->colormap = gdk_x11_colormap_foreign_new (visual,
+ window_attributes.colormap);
}
return drawable_impl->colormap;
impl = GDK_WINDOW_IMPL_X11 (drawable);
draw_impl = GDK_DRAWABLE_IMPL_X11 (drawable);
+ if (cmap && GDK_WINDOW_DESTROYED (draw_impl->wrapper))
+ return;
+
/* chain up */
GDK_DRAWABLE_CLASS (parent_class)->set_colormap (drawable, cmap);
if (cmap)
{
- XSetWindowColormap (draw_impl->xdisplay,
+ XSetWindowColormap (GDK_SCREEN_XDISPLAY (draw_impl->screen),
draw_impl->xid,
GDK_COLORMAP_XCOLORMAP (cmap));
-
+
if (((GdkWindowObject*)draw_impl->wrapper)->window_type !=
GDK_WINDOW_TOPLEVEL)
gdk_window_add_colormap_windows (GDK_WINDOW (draw_impl->wrapper));
}
void
-_gdk_windowing_window_init (void)
+_gdk_windowing_window_init (GdkScreen * screen)
{
GdkWindowObject *private;
GdkWindowImplX11 *impl;
GdkDrawableImplX11 *draw_impl;
+ GdkScreenX11 *screen_x11;
XWindowAttributes xattributes;
unsigned int width;
unsigned int height;
unsigned int depth;
int x, y;
- g_assert (gdk_parent_root == NULL);
-
- XGetGeometry (gdk_display, gdk_root_window, &gdk_root_window,
- &x, &y, &width, &height, &border_width, &depth);
- XGetWindowAttributes (gdk_display, gdk_root_window, &xattributes);
+ screen_x11 = GDK_SCREEN_X11 (screen);
- gdk_parent_root = g_object_new (GDK_TYPE_WINDOW, NULL);
- private = (GdkWindowObject *)gdk_parent_root;
+ g_assert (screen_x11->root_window == NULL);
+
+ gdk_screen_set_default_colormap (screen,
+ gdk_screen_get_system_colormap (screen));
+
+ XGetGeometry (screen_x11->xdisplay, screen_x11->xroot_window,
+ &screen_x11->xroot_window, &x, &y, &width, &height, &border_width, &depth);
+ XGetWindowAttributes (screen_x11->xdisplay, screen_x11->xroot_window, &xattributes);
+
+ screen_x11->root_window = g_object_new (GDK_TYPE_WINDOW, NULL);
+ private = (GdkWindowObject *)screen_x11->root_window;
impl = GDK_WINDOW_IMPL_X11 (private->impl);
draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl);
- draw_impl->xdisplay = gdk_display;
- draw_impl->xid = gdk_root_window;
+ draw_impl->screen = screen;
+ draw_impl->xid = screen_x11->xroot_window;
draw_impl->wrapper = GDK_DRAWABLE (private);
+ draw_impl->colormap = gdk_screen_get_system_colormap (screen);
+ g_object_ref (draw_impl->colormap);
private->window_type = GDK_WINDOW_ROOT;
private->depth = depth;
+
impl->width = width;
impl->height = height;
- gdk_xid_table_insert (&gdk_root_window, gdk_parent_root);
+ _gdk_window_init_position (GDK_WINDOW (private));
+
+ _gdk_xid_table_insert (screen_x11->display,
+ &screen_x11->xroot_window,
+ screen_x11->root_window);
}
-static GdkAtom wm_client_leader_atom = GDK_NONE;
+static void
+set_wm_protocols (GdkWindow *window)
+{
+ GdkDisplay *display = gdk_drawable_get_display (window);
+ Atom protocols[3];
+
+ protocols[0] = gdk_x11_get_xatom_by_name_for_display (display, "WM_DELETE_WINDOW");
+ protocols[1] = gdk_x11_get_xatom_by_name_for_display (display, "WM_TAKE_FOCUS");
+ protocols[2] = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_PING");
+
+ XSetWMProtocols (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window), protocols, 3);
+}
+
+static const gchar *
+get_default_title (void)
+{
+ const char *title;
+
+ title = g_get_application_name ();
+ if (!title)
+ title = g_get_prgname ();
+
+ return title;
+}
+
+static void
+check_leader_window_title (GdkDisplay *display)
+{
+ GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
+
+ if (!display_x11->leader_window_title_set)
+ {
+ set_wm_name (display,
+ display_x11->leader_window,
+ get_default_title ());
+
+ display_x11->leader_window_title_set = TRUE;
+ }
+}
+/**
+ * gdk_window_new:
+ * @parent: a #GdkWindow, or %NULL to create the window as a child of
+ * the default root window for the default display.
+ * @attributes: attributes of the new window
+ * @attributes_mask: mask indicating which fields in @attributes are valid
+ *
+ * Creates a new #GdkWindow using the attributes from
+ * @attributes. See #GdkWindowAttr and #GdkWindowAttributesType for
+ * more details. Note: to use this on displays other than the default
+ * display, @parent must be specified.
+ *
+ * Return value: the new #GdkWindow
+ **/
GdkWindow*
gdk_window_new (GdkWindow *parent,
GdkWindowAttr *attributes,
{
GdkWindow *window;
GdkWindowObject *private;
- GdkWindowObject *parent_private;
GdkWindowImplX11 *impl;
GdkDrawableImplX11 *draw_impl;
+ GdkScreenX11 *screen_x11;
+ GdkScreen *screen;
GdkVisual *visual;
Window xparent;
int x, y, depth;
unsigned int class;
- char *title;
+ const char *title;
int i;
+ long pid;
g_return_val_if_fail (attributes != NULL, NULL);
if (!parent)
- parent = gdk_parent_root;
+ {
+ GDK_NOTE (MULTIHEAD,
+ g_warning ("gdk_window_new(): no parent specified reverting to parent = default root window"));
+
+ screen = gdk_screen_get_default ();
+ parent = gdk_screen_get_root_window (screen);
+ }
+ else
+ screen = gdk_drawable_get_screen (parent);
+
+ screen_x11 = GDK_SCREEN_X11 (screen);
g_return_val_if_fail (GDK_IS_WINDOW (parent), NULL);
- parent_private = (GdkWindowObject*) parent;
if (GDK_WINDOW_DESTROYED (parent))
return NULL;
draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl);
draw_impl->wrapper = GDK_DRAWABLE (window);
- xdisplay = draw_impl->xdisplay = GDK_WINDOW_XDISPLAY (parent);
+ draw_impl->screen = screen;
+ xdisplay = screen_x11->xdisplay;
+
+ /* Windows with a foreign parent are treated as if they are children
+ * of the root window, except for actual creation.
+ */
+ if (GDK_WINDOW_TYPE (parent) == GDK_WINDOW_FOREIGN)
+ parent = gdk_screen_get_root_window (screen);
private->parent = (GdkWindowObject *)parent;
private->y = y;
impl->width = (attributes->width > 1) ? (attributes->width) : (1);
impl->height = (attributes->height > 1) ? (attributes->height) : (1);
- private->window_type = attributes->window_type;
+
+ if (attributes->wclass == GDK_INPUT_ONLY)
+ {
+ /* Backwards compatiblity - we've always ignored
+ * attributes->window_type for input-only windows
+ * before
+ */
+ if (GDK_WINDOW_TYPE (parent) == GDK_WINDOW_ROOT)
+ private->window_type = GDK_WINDOW_TEMP;
+ else
+ private->window_type = GDK_WINDOW_CHILD;
+ }
+ else
+ private->window_type = attributes->window_type;
_gdk_window_init_position (GDK_WINDOW (private));
if (impl->position_info.big)
if (attributes_mask & GDK_WA_VISUAL)
visual = attributes->visual;
else
- visual = gdk_visual_get_system ();
+ visual = gdk_screen_get_system_visual (screen);
xvisual = ((GdkVisualPrivate*) visual)->xvisual;
- xattributes.event_mask = StructureNotifyMask;
- for (i = 0; i < gdk_nevent_masks; i++)
+ xattributes.event_mask = StructureNotifyMask | PropertyChangeMask;
+ for (i = 0; i < _gdk_nenvent_masks; i++)
{
if (attributes->event_mask & (1 << (i + 1)))
- xattributes.event_mask |= gdk_event_mask_table[i];
+ xattributes.event_mask |= _gdk_event_mask_table[i];
}
+ private->event_mask = attributes->event_mask;
if (xattributes.event_mask)
xattributes_mask |= CWEventMask;
else
xattributes.override_redirect = False;
- if (parent_private && parent_private->guffaw_gravity)
+ if (private->parent && private->parent->guffaw_gravity)
{
xattributes.win_gravity = StaticGravity;
xattributes_mask |= CWWinGravity;
}
+ /* Sanity checks */
+ switch (private->window_type)
+ {
+ case GDK_WINDOW_TOPLEVEL:
+ case GDK_WINDOW_DIALOG:
+ case GDK_WINDOW_TEMP:
+ if (GDK_WINDOW_TYPE (parent) != GDK_WINDOW_ROOT)
+ {
+ g_warning (G_STRLOC "Toplevel windows must be created as children of\n"
+ "of a window of type GDK_WINDOW_ROOT or GDK_WINDOW_FOREIGN");
+ xparent = GDK_SCREEN_XROOTWIN (screen);
+ }
+ case GDK_WINDOW_CHILD:
+ break;
+ default:
+ g_warning (G_STRLOC "cannot make windows of type %d", private->window_type);
+ return NULL;
+ }
+
if (attributes->wclass == GDK_INPUT_OUTPUT)
{
class = InputOutput;
if (attributes_mask & GDK_WA_COLORMAP)
{
draw_impl->colormap = attributes->colormap;
- gdk_colormap_ref (attributes->colormap);
+ g_object_ref (attributes->colormap);
}
else
{
- if ((((GdkVisualPrivate*)gdk_visual_get_system ())->xvisual) == xvisual)
+ if ((((GdkVisualPrivate *)gdk_screen_get_system_visual (screen))->xvisual) == xvisual)
{
- draw_impl->colormap =
- gdk_colormap_get_system ();
- gdk_colormap_ref (draw_impl->colormap);
+ draw_impl->colormap = gdk_screen_get_system_colormap (screen);
+ g_object_ref (draw_impl->colormap);
}
else
{
- draw_impl->colormap =
- gdk_colormap_new (visual, FALSE);
+ draw_impl->colormap = gdk_colormap_new (visual, FALSE);
}
}
- private->bg_color.pixel = BlackPixel (gdk_display, gdk_screen);
+ private->bg_color.pixel = BlackPixel (xdisplay, screen_x11->screen_num);
xattributes.background_pixel = private->bg_color.pixel;
private->bg_pixmap = NULL;
- xattributes.border_pixel = BlackPixel (gdk_display, gdk_screen);
+ xattributes.border_pixel = BlackPixel (xdisplay, screen_x11->screen_num);
xattributes_mask |= CWBorderPixel | CWBackPixel;
if (private->guffaw_gravity)
xattributes.bit_gravity = NorthWestGravity;
xattributes_mask |= CWBitGravity;
-
- switch (private->window_type)
+
+ xattributes.colormap = GDK_COLORMAP_XCOLORMAP (draw_impl->colormap);
+ xattributes_mask |= CWColormap;
+
+ if (private->window_type == GDK_WINDOW_TEMP)
{
- case GDK_WINDOW_TOPLEVEL:
- xattributes.colormap = GDK_COLORMAP_XCOLORMAP (draw_impl->colormap);
- xattributes_mask |= CWColormap;
-
- xparent = gdk_root_window;
- break;
-
- case GDK_WINDOW_CHILD:
- xattributes.colormap = GDK_COLORMAP_XCOLORMAP (draw_impl->colormap);
- xattributes_mask |= CWColormap;
- break;
-
- case GDK_WINDOW_DIALOG:
- xattributes.colormap = GDK_COLORMAP_XCOLORMAP (draw_impl->colormap);
- xattributes_mask |= CWColormap;
-
- xparent = gdk_root_window;
- break;
-
- case GDK_WINDOW_TEMP:
- xattributes.colormap = GDK_COLORMAP_XCOLORMAP (draw_impl->colormap);
- xattributes_mask |= CWColormap;
-
- xparent = gdk_root_window;
-
xattributes.save_under = True;
xattributes.override_redirect = True;
xattributes.cursor = None;
xattributes_mask |= CWSaveUnder | CWOverrideRedirect;
- break;
- case GDK_WINDOW_ROOT:
- g_error ("cannot make windows of type GDK_WINDOW_ROOT");
- break;
}
}
else
private->depth = 0;
class = InputOnly;
private->input_only = TRUE;
- draw_impl->colormap = gdk_colormap_get_system ();
- gdk_colormap_ref (draw_impl->colormap);
+ draw_impl->colormap = gdk_screen_get_system_colormap (screen);
+ g_object_ref (draw_impl->colormap);
}
xid = draw_impl->xid = XCreateWindow (xdisplay, xparent,
0, depth, class, xvisual,
xattributes_mask, &xattributes);
- gdk_drawable_ref (window);
- gdk_xid_table_insert (&draw_impl->xid, window);
+ g_object_ref (window);
+ _gdk_xid_table_insert (screen_x11->display, &draw_impl->xid, window);
gdk_window_set_cursor (window, ((attributes_mask & GDK_WA_CURSOR) ?
(attributes->cursor) :
NULL));
- if (parent_private)
- parent_private->children = g_list_prepend (parent_private->children, window);
+ if (private->parent)
+ private->parent->children = g_list_prepend (private->parent->children, window);
switch (GDK_WINDOW_TYPE (private))
{
XSetTransientForHint (xdisplay, xid, xparent);
case GDK_WINDOW_TOPLEVEL:
case GDK_WINDOW_TEMP:
- XSetWMProtocols (xdisplay, xid,
- gdk_wm_window_protocols, 3);
+ set_wm_protocols (window);
break;
case GDK_WINDOW_CHILD:
if ((attributes->wclass == GDK_INPUT_OUTPUT) &&
- (draw_impl->colormap != gdk_colormap_get_system ()) &&
- (draw_impl->colormap != gdk_window_get_colormap (gdk_window_get_toplevel (window))))
+ (draw_impl->colormap != gdk_screen_get_system_colormap (screen)) &&
+ (draw_impl->colormap != gdk_drawable_get_colormap (gdk_window_get_toplevel (window))))
{
GDK_NOTE (MISC, g_message ("adding colormap window\n"));
gdk_window_add_colormap_windows (window);
KeyPressMask | KeyReleaseMask | FocusChangeMask);
XMapWindow (xdisplay, impl->focus_window);
- gdk_xid_table_insert (&impl->focus_window, window);
+ _gdk_xid_table_insert (screen_x11->display, &impl->focus_window, window);
}
size_hints.flags = PSize;
size_hints.width = impl->width;
size_hints.height = impl->height;
+
+ check_leader_window_title (screen_x11->display);
wm_hints.flags = StateHint | WindowGroupHint;
- wm_hints.window_group = gdk_leader_window;
+ wm_hints.window_group = GDK_DISPLAY_X11 (screen_x11->display)->leader_window;
wm_hints.input = True;
wm_hints.initial_state = NormalState;
XSetWMHints (xdisplay, xid, &wm_hints);
- if (!wm_client_leader_atom)
- wm_client_leader_atom = gdk_atom_intern ("WM_CLIENT_LEADER", FALSE);
-
+ /* This will set WM_CLIENT_MACHINE and WM_LOCALE_NAME */
+ XSetWMProperties (xdisplay, xid, NULL, NULL, NULL, 0, NULL, NULL, NULL);
+
+ pid = getpid ();
XChangeProperty (xdisplay, xid,
- wm_client_leader_atom,
+ gdk_x11_get_xatom_by_name_for_display (screen_x11->display, "_NET_WM_PID"),
+ XA_CARDINAL, 32,
+ PropModeReplace,
+ (guchar *)&pid, 1);
+
+ XChangeProperty (xdisplay, xid,
+ gdk_x11_get_xatom_by_name_for_display (screen_x11->display, "WM_CLIENT_LEADER"),
XA_WINDOW, 32, PropModeReplace,
- (guchar*) &gdk_leader_window, 1);
+ (guchar *) &GDK_DISPLAY_X11 (screen_x11->display)->leader_window, 1);
if (attributes_mask & GDK_WA_TITLE)
title = attributes->title;
else
- title = g_get_prgname ();
+ title = get_default_title ();
gdk_window_set_title (window, title);
return window;
}
+static GdkEventMask
+x_event_mask_to_gdk_event_mask (long mask)
+{
+ GdkEventMask event_mask = 0;
+ int i;
+
+ for (i = 0; i < _gdk_nenvent_masks; i++)
+ {
+ if (mask & _gdk_event_mask_table[i])
+ event_mask |= 1 << (i + 1);
+ }
+
+ return event_mask;
+}
+
+/**
+ * gdk_window_foreign_new_for_display:
+ * @display: the #GdkDisplay where the window handle comes from.
+ * @anid: a native window handle.
+ *
+ * Wraps a native window in a #GdkWindow.
+ * This may fail if the window has been destroyed.
+ *
+ * For example in the X backend, a native window handle is an Xlib
+ * <type>XID</type>.
+ *
+ * Return value: the newly-created #GdkWindow wrapper for the
+ * native window or %NULL if the window has been destroyed.
+ **/
GdkWindow *
-gdk_window_foreign_new (GdkNativeWindow anid)
+gdk_window_foreign_new_for_display (GdkDisplay *display,
+ GdkNativeWindow anid)
{
GdkWindow *window;
GdkWindowObject *private;
- GdkWindowObject *parent_private;
GdkWindowImplX11 *impl;
GdkDrawableImplX11 *draw_impl;
+ GdkDisplayX11 *display_x11;
XWindowAttributes attrs;
Window root, parent;
Window *children = NULL;
guint nchildren;
gboolean result;
+ g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
+
+ display_x11 = GDK_DISPLAY_X11 (display);
+
gdk_error_trap_push ();
- result = XGetWindowAttributes (gdk_display, anid, &attrs);
+ result = XGetWindowAttributes (display_x11->xdisplay, anid, &attrs);
if (gdk_error_trap_pop () || !result)
return NULL;
/* FIXME: This is pretty expensive. Maybe the caller should supply
* the parent */
gdk_error_trap_push ();
- result = XQueryTree (gdk_display, anid, &root, &parent, &children, &nchildren);
+ result = XQueryTree (display_x11->xdisplay, anid, &root, &parent, &children, &nchildren);
if (gdk_error_trap_pop () || !result)
return NULL;
impl = GDK_WINDOW_IMPL_X11 (private->impl);
draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl);
draw_impl->wrapper = GDK_DRAWABLE (window);
+ draw_impl->screen = _gdk_x11_display_screen_for_xrootwin (display, root);
- private->parent = gdk_xid_table_lookup (parent);
+ private->parent = gdk_xid_table_lookup_for_display (display, parent);
- parent_private = (GdkWindowObject *)private->parent;
+ if (!private->parent || GDK_WINDOW_TYPE (private->parent) == GDK_WINDOW_FOREIGN)
+ private->parent = (GdkWindowObject *) gdk_screen_get_root_window (draw_impl->screen);
- if (parent_private)
- parent_private->children = g_list_prepend (parent_private->children, window);
+ private->parent->children = g_list_prepend (private->parent->children, window);
draw_impl->xid = anid;
- draw_impl->xdisplay = gdk_display;
private->x = attrs.x;
private->y = attrs.y;
private->window_type = GDK_WINDOW_FOREIGN;
private->destroyed = FALSE;
+ private->event_mask = x_event_mask_to_gdk_event_mask (attrs.your_event_mask);
+
if (attrs.map_state == IsUnmapped)
private->state = GDK_WINDOW_STATE_WITHDRAWN;
else
_gdk_window_init_position (GDK_WINDOW (private));
- gdk_drawable_ref (window);
- gdk_xid_table_insert (&GDK_WINDOW_XID (window), window);
-
+ g_object_ref (window);
+ _gdk_xid_table_insert (display, &GDK_WINDOW_XID (window), window);
return window;
}
+/**
+ * gdk_window_lookup_for_display:
+ * @display: the #GdkDisplay corresponding to the window handle
+ * @anid: a native window handle.
+ *
+ * Looks up the #GdkWindow that wraps the given native window handle.
+ *
+ * For example in the X backend, a native window handle is an Xlib
+ * <type>XID</type>.
+ *
+ * Return value: the #GdkWindow wrapper for the native window,
+ * or %NULL if there is none.
+ **/
+GdkWindow *
+gdk_window_lookup_for_display (GdkDisplay *display, GdkNativeWindow anid)
+{
+ return (GdkWindow*) gdk_xid_table_lookup_for_display (display, anid);
+}
+
+/**
+ * gdk_window_lookup:
+ * @anid: a native window handle.
+ *
+ * Looks up the #GdkWindow that wraps the given native window handle.
+ *
+ * For example in the X backend, a native window handle is an Xlib
+ * <type>XID</type>.
+ *
+ * Return value: the #GdkWindow wrapper for the native window,
+ * or %NULL if there is none.
+ **/
+GdkWindow *
+gdk_window_lookup (GdkNativeWindow anid)
+{
+ return (GdkWindow*) gdk_xid_table_lookup (anid);
+}
+
void
_gdk_windowing_window_destroy (GdkWindow *window,
gboolean recursing,
_gdk_selection_window_destroyed (window);
if (private->extension_events != 0)
- gdk_input_window_destroy (window);
+ _gdk_input_window_destroy (window);
+
+#ifdef HAVE_XFT
+ {
+ GdkDrawableImplX11 *draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl);
+
+#ifdef HAVE_XFT2
+ if (draw_impl->xft_draw)
+ XftDrawDestroy (draw_impl->xft_draw);
+#else /* !HAVE_XFT2 */
+ if (draw_impl->picture)
+ XRenderFreePicture (GDK_DRAWABLE_XDISPLAY (window), draw_impl->picture);
+#endif /* HAVE_XFT2 */
+ }
+#endif /* HAVE_XFT */
if (private->window_type == GDK_WINDOW_FOREIGN)
{
xevent.type = ClientMessage;
xevent.window = GDK_WINDOW_XID (window);
- xevent.message_type = gdk_wm_protocols;
+ xevent.message_type = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
+ "WM_PROTOCOLS");
xevent.format = 32;
- xevent.data.l[0] = gdk_wm_delete_window;
+ xevent.data.l[0] = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
+ "WM_DELETE_WINDOW");
xevent.data.l[1] = CurrentTime;
XSendEvent (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
False, 0, (XEvent *)&xevent);
- gdk_flush ();
+ gdk_display_sync (GDK_WINDOW_DISPLAY (window));
gdk_error_trap_pop ();
}
}
else if (!recursing && !foreign_destroy)
- XDestroyWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
+ {
+ XDestroyWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
+ }
}
/* This function is called when the XWindow is really gone.
_gdk_window_destroy (window, TRUE);
}
- gdk_xid_table_remove (GDK_WINDOW_XID (window));
+ _gdk_xid_table_remove (GDK_WINDOW_DISPLAY (window), GDK_WINDOW_XID (window));
if (window_impl->focus_window)
- gdk_xid_table_remove (window_impl->focus_window);
+ _gdk_xid_table_remove (GDK_WINDOW_DISPLAY (window), window_impl->focus_window);
+
+ _gdk_xgrab_check_destroy (window);
- gdk_drawable_unref (window);
+ g_object_unref (window);
}
static void
set_initial_hints (GdkWindow *window)
{
GdkWindowObject *private;
- GdkAtom atoms[5];
+ Atom atoms[6];
gint i;
private = (GdkWindowObject*) window;
if (private->state & GDK_WINDOW_STATE_MAXIMIZED)
{
- atoms[i] = gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_VERT", FALSE);
+ atoms[i] = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
+ "_NET_WM_STATE_MAXIMIZED_VERT");
++i;
- atoms[i] = gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_HORZ", FALSE);
+ atoms[i] = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
+ "_NET_WM_STATE_MAXIMIZED_HORZ");
++i;
}
if (private->state & GDK_WINDOW_STATE_STICKY)
{
- atoms[i] = gdk_atom_intern ("_NET_WM_STATE_STICKY", FALSE);
+ atoms[i] = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
+ "_NET_WM_STATE_STICKY");
++i;
}
+ if (private->state & GDK_WINDOW_STATE_FULLSCREEN)
+ {
+ atoms[i] = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
+ "_NET_WM_STATE_FULLSCREEN");
+ ++i;
+ }
+
if (private->modal_hint)
{
- atoms[i] = gdk_atom_intern ("_NET_WM_STATE_MODAL", FALSE);
+ atoms[i] = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
+ "_NET_WM_STATE_MODAL");
++i;
}
{
XChangeProperty (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
- gdk_atom_intern ("_NET_WM_STATE", FALSE),
+ gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window), "_NET_WM_STATE"),
XA_ATOM, 32, PropModeReplace,
(guchar*) atoms, i);
}
atoms[0] = 0xFFFFFFFF;
XChangeProperty (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
- gdk_atom_intern ("_NET_WM_DESKTOP", FALSE),
+ gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window), "_NET_WM_DESKTOP"),
XA_CARDINAL, 32, PropModeReplace,
(guchar*) atoms, 1);
}
* Shows a #GdkWindow onscreen, but does not modify its stacking
* order. In contrast, gdk_window_show() will raise the window
* to the top of the window stack.
+ *
+ * On the X11 platform, in Xlib terms, this function calls
+ * XMapWindow() (it also updates some internal GDK state, which means
+ * that you can't really use XMapWindow() directly on a GDK window).
*
**/
void
show_window_internal (window, FALSE);
}
+/**
+ * gdk_window_show:
+ * @window: a #GdkWindow
+ *
+ * Like gdk_window_show_unraised(), but also raises the window to the
+ * top of the window stack (moves the window to the front of the
+ * Z-order).
+ *
+ * This function maps a window so it's visible onscreen. Its opposite
+ * is gdk_window_hide().
+ *
+ * When implementing a #GtkWidget, you should call this function on the widget's
+ * #GdkWindow as part of the "map" method.
+ *
+ **/
void
gdk_window_show (GdkWindow *window)
{
show_window_internal (window, TRUE);
}
+/**
+ * gdk_window_hide:
+ * @window: a #GdkWindow
+ *
+ * For toplevel windows, withdraws them, so they will no longer be
+ * known to the window manager; for all windows, unmaps them, so
+ * they won't be displayed. Normally done automatically as
+ * part of gtk_widget_hide().
+ *
+ **/
void
gdk_window_hide (GdkWindow *window)
{
private = (GdkWindowObject*) window;
+ /* We'll get the unmap notify eventually, and handle it then,
+ * but checking here makes things more consistent if we are
+ * just doing stuff ourself.
+ */
+ _gdk_xgrab_check_unmap (window,
+ NextRequest (GDK_WINDOW_XDISPLAY (window)));
+
/* You can't simply unmap toplevel windows. */
switch (private->window_type)
{
}
}
+/**
+ * gdk_window_withdraw:
+ * @window: a toplevel #GdkWindow
+ *
+ * Withdraws a window (unmaps it and asks the window manager to forget about it).
+ * This function is not really useful as gdk_window_hide() automatically
+ * withdraws toplevel windows before hiding them.
+ *
+ **/
void
gdk_window_withdraw (GdkWindow *window)
{
}
}
+/**
+ * gdk_window_move:
+ * @window: a #GdkWindow
+ * @x: X coordinate relative to window's parent
+ * @y: Y coordinate relative to window's parent
+ *
+ * Repositions a window relative to its parent window.
+ * For toplevel windows, window managers may ignore or modify the move;
+ * you should probably use gtk_window_move() on a #GtkWindow widget
+ * anyway, instead of using GDK functions. For child windows,
+ * the move will reliably succeed.
+ *
+ * If you're also planning to resize the window, use gdk_window_move_resize()
+ * to both move and resize simultaneously, for a nicer visual effect.
+ **/
void
gdk_window_move (GdkWindow *window,
gint x,
}
}
+/**
+ * gdk_window_resize:
+ * @window: a #GdkWindow
+ * @width: new width of the window
+ * @height: new height of the window
+ *
+ * Resizes @window; for toplevel windows, asks the window manager to resize
+ * the window. The window manager may not allow the resize. When using GTK+,
+ * use gtk_window_resize() instead of this low-level GDK function.
+ *
+ * Windows may not be resized below 1x1.
+ *
+ * If you're also planning to move the window, use gdk_window_move_resize()
+ * to both move and resize simultaneously, for a nicer visual effect.
+ **/
void
gdk_window_resize (GdkWindow *window,
gint width,
}
}
+/**
+ * gdk_window_move_resize:
+ * @window: a #GdkWindow
+ * @x: new X position relative to window's parent
+ * @y: new Y position relative to window's parent
+ * @width: new width
+ * @height: new height
+ *
+ * Equivalent to calling gdk_window_move() and gdk_window_resize(),
+ * except that both operations are performed at once, avoiding strange
+ * visual effects. (i.e. the user may be able to see the window first
+ * move, then resize, if you don't use gdk_window_move_resize().)
+ **/
void
gdk_window_move_resize (GdkWindow *window,
gint x,
}
}
+/**
+ * gdk_window_reparent:
+ * @window: a #GdkWindow
+ * @new_parent: new parent to move @window into
+ * @x: X location inside the new parent
+ * @y: Y location inside the new parent
+ *
+ * Reparents @window into the given @new_parent. The window being
+ * reparented will be unmapped as a side effect.
+ *
+ **/
void
gdk_window_reparent (GdkWindow *window,
GdkWindow *new_parent,
gint x,
gint y)
{
+ GdkDisplay *display;
GdkWindowObject *window_private;
GdkWindowObject *parent_private;
GdkWindowObject *old_parent_private;
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
g_return_if_fail (new_parent == NULL || GDK_IS_WINDOW (new_parent));
+ g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_ROOT);
if (!new_parent)
- new_parent = gdk_parent_root;
+ new_parent = gdk_screen_get_root_window (GDK_WINDOW_SCREEN (window));
+
+ display = GDK_WINDOW_DISPLAY (window);
window_private = (GdkWindowObject*) window;
old_parent_private = (GdkWindowObject*)window_private->parent;
GDK_WINDOW_XID (window),
GDK_WINDOW_XID (new_parent),
x, y);
+
+ window_private->x = x;
+ window_private->y = y;
- window_private->parent = (GdkWindowObject *)new_parent;
+ /* From here on, we treat parents of type GDK_WINDOW_FOREIGN like
+ * the root window
+ */
+ if (GDK_WINDOW_TYPE (new_parent) == GDK_WINDOW_FOREIGN)
+ new_parent = gdk_screen_get_root_window (GDK_WINDOW_SCREEN (window));
+ window_private->parent = (GdkWindowObject *)new_parent;
+
+ /* Switch the window type as appropriate */
+
+ switch (GDK_WINDOW_TYPE (new_parent))
+ {
+ case GDK_WINDOW_ROOT:
+ case GDK_WINDOW_FOREIGN:
+ /* Now a toplevel */
+ if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD)
+ set_wm_protocols (window);
+ break;
+ case GDK_WINDOW_TOPLEVEL:
+ case GDK_WINDOW_CHILD:
+ case GDK_WINDOW_DIALOG:
+ case GDK_WINDOW_TEMP:
+ if (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD &&
+ GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN)
+ {
+ /* If we were being sophisticated, we'd save the old window type
+ * here, and restore it if we were reparented back to the
+ * toplevel. However, the difference between different types
+ * of toplevels only really matters on creation anyways.
+ */
+ GDK_WINDOW_TYPE (window) = GDK_WINDOW_CHILD;
+ }
+ }
+
if (old_parent_private)
old_parent_private->children = g_list_remove (old_parent_private->children, window);
x, y, width, height, True);
}
+
+/**
+ * gdk_window_raise:
+ * @window: a #GdkWindow
+ *
+ * Raises @window to the top of the Z-order (stacking order), so that
+ * other windows with the same parent window appear below @window.
+ * This is true whether or not the windows are visible.
+ *
+ * If @window is a toplevel, the window manager may choose to deny the
+ * request to move the window in the Z-order, gdk_window_raise() only
+ * requests the restack, does not guarantee it.
+ *
+ **/
void
gdk_window_raise (GdkWindow *window)
{
XRaiseWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
}
+/**
+ * gdk_window_lower:
+ * @window: a #GdkWindow
+ *
+ * Lowers @window to the bottom of the Z-order (stacking order), so that
+ * other windows with the same parent window appear above @window.
+ * This is true whether or not the other windows are visible.
+ *
+ * If @window is a toplevel, the window manager may choose to deny the
+ * request to move the window in the Z-order, gdk_window_lower() only
+ * requests the restack, does not guarantee it.
+ *
+ * Note that gdk_window_show() raises the window again, so don't call this
+ * function before gdk_window_show(). (Try gdk_window_show_unraised().)
+ *
+ **/
void
gdk_window_lower (GdkWindow *window)
{
XLowerWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
}
+/**
+ * gdk_window_focus:
+ * @window: a #GdkWindow
+ * @timestamp: timestamp of the event triggering the window focus
+ *
+ * Sets keyboard focus to @window. If @window is not onscreen this
+ * will not work. In most cases, gtk_window_present() should be used on
+ * a #GtkWindow, rather than calling this function.
+ *
+ **/
void
gdk_window_focus (GdkWindow *window,
guint32 timestamp)
if (GDK_WINDOW_DESTROYED (window))
return;
-
- if (gdk_net_wm_supports (gdk_atom_intern ("_NET_ACTIVE_WINDOW", FALSE)))
+
+ if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
+ gdk_atom_intern ("_NET_ACTIVE_WINDOW", FALSE)))
{
XEvent xev;
xev.xclient.serial = 0;
xev.xclient.send_event = True;
xev.xclient.window = GDK_WINDOW_XWINDOW (window);
- xev.xclient.display = gdk_display;
- xev.xclient.message_type = gdk_atom_intern ("_NET_ACTIVE_WINDOW", FALSE);
+ xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
+ "_NET_ACTIVE_WINDOW");
xev.xclient.format = 32;
xev.xclient.data.l[0] = 0;
- XSendEvent (gdk_display, gdk_root_window, False,
+ XSendEvent (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XROOTWIN (window), False,
SubstructureRedirectMask | SubstructureNotifyMask,
&xev);
}
gdk_error_trap_push ();
XSetInputFocus (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XWINDOW (window),
- RevertToNone,
+ RevertToParent,
timestamp);
XSync (GDK_WINDOW_XDISPLAY (window), False);
gdk_error_trap_pop ();
}
}
+/**
+ * gdk_window_set_hints:
+ * @window: a #GdkWindow
+ * @x: ignored field, does not matter
+ * @y: ignored field, does not matter
+ * @min_width: minimum width hint
+ * @min_height: minimum height hint
+ * @max_width: max width hint
+ * @max_height: max height hint
+ * @flags: logical OR of GDK_HINT_POS, GDK_HINT_MIN_SIZE, and/or GDK_HINT_MAX_SIZE
+ *
+ * This function is broken and useless and you should ignore it.
+ * If using GTK+, use functions such as gtk_window_resize(), gtk_window_set_size_request(),
+ * gtk_window_move(), gtk_window_parse_geometry(), and gtk_window_set_geometry_hints(),
+ * depending on what you're trying to do.
+ *
+ * If using GDK directly, use gdk_window_set_geometry_hints().
+ *
+ **/
void
gdk_window_set_hints (GdkWindow *window,
gint x,
/**
* gdk_window_set_type_hint:
- * @window: A #GdkWindow
+ * @window: A toplevel #GdkWindow
* @hint: A hint of the function this window will have
*
* The application can use this call to provide a hint to the window
gdk_window_set_type_hint (GdkWindow *window,
GdkWindowTypeHint hint)
{
- GdkAtom atom;
+ GdkDisplay *display;
+ Atom atom;
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
if (GDK_WINDOW_DESTROYED (window))
return;
+ display = gdk_drawable_get_display (window);
+
switch (hint)
{
case GDK_WINDOW_TYPE_HINT_DIALOG:
- atom = gdk_atom_intern ("_NET_WM_WINDOW_TYPE_DIALOG", FALSE);
+ atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DIALOG");
break;
case GDK_WINDOW_TYPE_HINT_MENU:
- atom = gdk_atom_intern ("_NET_WM_WINDOW_TYPE_MENU", FALSE);
+ atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_MENU");
break;
case GDK_WINDOW_TYPE_HINT_TOOLBAR:
- atom = gdk_atom_intern ("_NET_WM_WINDOW_TYPE_TOOLBAR", FALSE);
+ atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_TOOLBAR");
+ break;
+ case GDK_WINDOW_TYPE_HINT_UTILITY:
+ atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_UTILITY");
+ break;
+ case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
+ atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_SPLASH");
+ break;
+ case GDK_WINDOW_TYPE_HINT_DOCK:
+ atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DOCK");
+ break;
+ case GDK_WINDOW_TYPE_HINT_DESKTOP:
+ atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DESKTOP");
break;
default:
g_warning ("Unknown hint %d passed to gdk_window_set_type_hint", hint);
/* Fall thru */
case GDK_WINDOW_TYPE_HINT_NORMAL:
- atom = gdk_atom_intern ("_NET_WM_WINDOW_TYPE_NORMAL", FALSE);
+ atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_NORMAL");
break;
}
- XChangeProperty (GDK_WINDOW_XDISPLAY (window),
- GDK_WINDOW_XID (window),
- gdk_atom_intern ("_NET_WM_WINDOW_TYPE", FALSE),
+ XChangeProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
+ gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE"),
XA_ATOM, 32, PropModeReplace,
(guchar *)&atom, 1);
}
static void
-gdk_wmspec_change_state (gboolean add,
+gdk_wmspec_change_state (gboolean add,
GdkWindow *window,
- GdkAtom state1,
- GdkAtom state2)
+ GdkAtom state1,
+ GdkAtom state2)
{
+ GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
XEvent xev;
-
+
#define _NET_WM_STATE_REMOVE 0 /* remove/unset property */
#define _NET_WM_STATE_ADD 1 /* add/set property */
#define _NET_WM_STATE_TOGGLE 2 /* toggle property */
xev.xclient.type = ClientMessage;
xev.xclient.serial = 0;
xev.xclient.send_event = True;
- xev.xclient.display = gdk_display;
xev.xclient.window = GDK_WINDOW_XID (window);
- xev.xclient.message_type = gdk_atom_intern ("_NET_WM_STATE", FALSE);
+ xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE");
xev.xclient.format = 32;
xev.xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
- xev.xclient.data.l[1] = state1;
- xev.xclient.data.l[2] = state2;
+ xev.xclient.data.l[1] = gdk_x11_atom_to_xatom_for_display (display, state1);
+ xev.xclient.data.l[2] = gdk_x11_atom_to_xatom_for_display (display, state2);
- XSendEvent (gdk_display, gdk_root_window, False,
+ XSendEvent (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XROOTWIN (window), False,
SubstructureRedirectMask | SubstructureNotifyMask,
&xev);
}
+
/**
* gdk_window_set_modal_hint:
- * @window: A #GdkWindow
+ * @window: A toplevel #GdkWindow
* @modal: TRUE if the window is modal, FALSE otherwise.
*
* The application can use this hint to tell the window manager
if (GDK_WINDOW_IS_MAPPED (window))
gdk_wmspec_change_state (modal, window,
- gdk_atom_intern ("_NET_WM_STATE_MODAL", FALSE),
+ gdk_atom_intern ("_NET_WM_STATE_MODAL", FALSE),
+ 0);
+}
+
+/**
+ * gdk_window_set_skip_taskbar_hint:
+ * @window: a toplevel #GdkWindow
+ * @skips_taskbar: %TRUE to skip the taskbar
+ *
+ * Toggles whether a window should appear in a task list or window
+ * list. If a window's semantic type as specified with
+ * gdk_window_set_type_hint() already fully describes the window, this
+ * function should NOT be called in addition, instead you should allow
+ * the window to be treated according to standard policy for its
+ * semantic type.
+ **/
+void
+gdk_window_set_skip_taskbar_hint (GdkWindow *window,
+ gboolean skips_taskbar)
+{
+ GdkWindowObject *private;
+ GdkWindowImplX11 *impl;
+
+ g_return_if_fail (window != NULL);
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ if (GDK_WINDOW_DESTROYED (window))
+ return;
+
+ private = (GdkWindowObject*) window;
+ impl = GDK_WINDOW_IMPL_X11 (private->impl);
+
+ impl->skip_taskbar_hint = skips_taskbar;
+
+ if (GDK_WINDOW_IS_MAPPED (window))
+ gdk_wmspec_change_state (skips_taskbar, window,
+ gdk_atom_intern ("_NET_WM_STATE_SKIP_TASKBAR", FALSE),
+ 0);
+}
+
+/**
+ * gdk_window_set_skip_pager_hint:
+ * @window: a toplevel #GdkWindow
+ * @skips_pager: %TRUE to skip the pager
+ *
+ * Toggles whether a window should appear in a pager (workspace
+ * switcher, or other desktop utility program that displays a small
+ * thumbnail representation of the windows on the desktop). If a
+ * window's semantic type as specified with gdk_window_set_type_hint()
+ * already fully describes the window, this function should NOT be
+ * called in addition, instead you should allow the window to be
+ * treated according to standard policy for its semantic type.
+ **/
+void
+gdk_window_set_skip_pager_hint (GdkWindow *window,
+ gboolean skips_pager)
+{
+ GdkWindowObject *private;
+ GdkWindowImplX11 *impl;
+
+ g_return_if_fail (window != NULL);
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ if (GDK_WINDOW_DESTROYED (window))
+ return;
+
+ private = (GdkWindowObject*) window;
+ impl = GDK_WINDOW_IMPL_X11 (private->impl);
+
+ impl->skip_pager_hint = skips_pager;
+
+ if (GDK_WINDOW_IS_MAPPED (window))
+ gdk_wmspec_change_state (skips_pager, window,
+ gdk_atom_intern ("_NET_WM_STATE_SKIP_PAGER", FALSE),
0);
}
+/**
+ * gdk_window_set_geometry_hints:
+ * @window: a toplevel #GdkWindow
+ * @geometry: geometry hints
+ * @geom_mask: bitmask indicating fields of @geometry to pay attention to
+ *
+ * Sets the geometry hints for @window. Hints flagged in @geom_mask
+ * are set, hints not flagged in @geom_mask are unset.
+ * To unset all hints, use a @geom_mask of 0 and a @geometry of %NULL.
+ *
+ * This function provides hints to the windowing system about
+ * acceptable sizes for a toplevel window. The purpose of
+ * this is to constrain user resizing, but the windowing system
+ * will typically (but is not required to) also constrain the
+ * current size of the window to the provided values and
+ * constrain programatic resizing via gdk_window_resize() or
+ * gdk_window_move_resize().
+ *
+ * Note that on X11, this effect has no effect on windows
+ * of type GDK_WINDOW_TEMP or windows where override_redirect
+ * has been turned on via gdk_window_set_override_redirect()
+ * since these windows are not resizable by the user.
+ *
+ * Since you can't count on the windowing system doing the
+ * constraints for programmatic resizes, you should generally
+ * call gdk_window_constrain_size() yourself to determine
+ * appropriate sizes.
+ *
+ **/
void
gdk_window_set_geometry_hints (GdkWindow *window,
GdkGeometry *geometry,
size_hints.x = 0;
size_hints.y = 0;
}
+
+ if (geom_mask & GDK_HINT_USER_POS)
+ {
+ size_hints.flags |= USPosition;
+ }
+
+ if (geom_mask & GDK_HINT_USER_SIZE)
+ {
+ size_hints.flags |= USSize;
+ }
if (geom_mask & GDK_HINT_MIN_SIZE)
{
* convertable to STRING, otherwise, set it as compound text
*/
static void
-set_text_property (GdkWindow *window,
- GdkAtom property,
+set_text_property (GdkDisplay *display,
+ Window xwindow,
+ Atom property,
const gchar *utf8_str)
{
guchar *prop_text = NULL;
- GdkAtom prop_type;
+ Atom prop_type;
gint prop_length;
gint prop_format;
if (utf8_is_latin1 (utf8_str))
{
- prop_type = GDK_TARGET_STRING;
+ prop_type = XA_STRING;
prop_text = gdk_utf8_to_string_target (utf8_str);
- prop_length = strlen (prop_text);
+ prop_length = prop_text ? strlen (prop_text) : 0;
prop_format = 8;
}
else
{
- gdk_utf8_to_compound_text (utf8_str, &prop_type, &prop_format,
- &prop_text, &prop_length);
+ GdkAtom gdk_type;
+
+ gdk_utf8_to_compound_text_for_display (display,
+ utf8_str, &gdk_type, &prop_format,
+ &prop_text, &prop_length);
+ prop_type = gdk_x11_atom_to_xatom_for_display (display, gdk_type);
}
if (prop_text)
{
- XChangeProperty (GDK_WINDOW_XDISPLAY (window),
- GDK_WINDOW_XID (window),
+ XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
+ xwindow,
property,
prop_type, prop_format,
PropModeReplace, prop_text,
}
}
+/* Set WM_NAME and _NET_WM_NAME
+ */
+static void
+set_wm_name (GdkDisplay *display,
+ Window xwindow,
+ const gchar *name)
+{
+ XChangeProperty (GDK_DISPLAY_XDISPLAY (display), xwindow,
+ gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_NAME"),
+ gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
+ PropModeReplace, name, strlen (name));
+
+ set_text_property (display, xwindow,
+ gdk_x11_get_xatom_by_name_for_display (display, "WM_NAME"),
+ name);
+}
+
+/**
+ * gdk_window_set_title:
+ * @window: a toplevel #GdkWindow
+ * @title: title of @window
+ *
+ * Sets the title of a toplevel window, to be displayed in the titlebar.
+ * If you haven't explicitly set the icon name for the window
+ * (using gdk_window_set_icon_name()), the icon name will be set to
+ * @title as well. @title must be in UTF-8 encoding (as with all
+ * user-readable strings in GDK/GTK+). @title may not be %NULL.
+ **/
void
gdk_window_set_title (GdkWindow *window,
const gchar *title)
{
+ GdkDisplay *display;
+ Display *xdisplay;
+ Window xwindow;
+
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
+ g_return_if_fail (title != NULL);
if (GDK_WINDOW_DESTROYED (window))
return;
- XChangeProperty (GDK_WINDOW_XDISPLAY (window),
- GDK_WINDOW_XID (window),
- gdk_atom_intern ("_NET_WM_NAME", FALSE),
- gdk_atom_intern ("UTF8_STRING", FALSE), 8,
- PropModeReplace, title,
- strlen (title));
+ display = gdk_drawable_get_display (window);
+ xdisplay = GDK_DISPLAY_XDISPLAY (display);
+ xwindow = GDK_WINDOW_XID (window);
- set_text_property (window, gdk_atom_intern ("WM_NAME", FALSE), title);
+ set_wm_name (display, xwindow, title);
+
if (!gdk_window_icon_name_set (window))
{
- XChangeProperty (GDK_WINDOW_XDISPLAY (window),
- GDK_WINDOW_XID (window),
- gdk_atom_intern ("_NET_WM_ICON_NAME", FALSE),
- gdk_atom_intern ("UTF8_STRING", FALSE), 8,
- PropModeReplace, title,
- strlen (title));
- set_text_property (window, gdk_atom_intern ("WM_ICON_NAME", FALSE), title);
+ XChangeProperty (xdisplay, xwindow,
+ gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON_NAME"),
+ gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
+ PropModeReplace, title, strlen (title));
+
+ set_text_property (display, xwindow,
+ gdk_x11_get_xatom_by_name_for_display (display, "WM_ICON_NAME"),
+ title);
}
}
+/**
+ * gdk_window_set_role:
+ * @window: a toplevel #GdkWindow
+ * @role: a string indicating its role
+ *
+ * When using GTK+, typically you should use gtk_window_set_role() instead
+ * of this low-level function.
+ *
+ * The window manager and session manager use a window's role to
+ * distinguish it from other kinds of window in the same application.
+ * When an application is restarted after being saved in a previous
+ * session, all windows with the same title and role are treated as
+ * interchangeable. So if you have two windows with the same title
+ * that should be distinguished for session management purposes, you
+ * should set the role on those windows. It doesn't matter what string
+ * you use for the role, as long as you have a different role for each
+ * non-interchangeable kind of window.
+ *
+ **/
void
gdk_window_set_role (GdkWindow *window,
const gchar *role)
{
+ GdkDisplay *display;
+
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
+ display = gdk_drawable_get_display (window);
+
if (!GDK_WINDOW_DESTROYED (window))
{
if (role)
- XChangeProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
- gdk_atom_intern ("WM_WINDOW_ROLE", FALSE), XA_STRING,
- 8, PropModeReplace, role, strlen (role));
+ XChangeProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
+ gdk_x11_get_xatom_by_name_for_display (display, "WM_WINDOW_ROLE"),
+ XA_STRING, 8, PropModeReplace, role, strlen (role));
else
- XDeleteProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
- gdk_atom_intern ("WM_WINDOW_ROLE", FALSE));
+ XDeleteProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
+ gdk_x11_get_xatom_by_name_for_display (display, "WM_WINDOW_ROLE"));
}
}
+/**
+ * gdk_window_set_transient_for:
+ * @window: a toplevel #GdkWindow
+ * @parent: another toplevel #GdkWindow
+ *
+ * Indicates to the window manager that @window is a transient dialog
+ * associated with the application window @parent. This allows the
+ * window manager to do things like center @window on @parent and
+ * keep @window above @parent.
+ *
+ * See gtk_window_set_transient_for() if you're using #GtkWindow or
+ * #GtkDialog.
+ *
+ **/
void
gdk_window_set_transient_for (GdkWindow *window,
GdkWindow *parent)
GDK_WINDOW_XID (parent));
}
+/**
+ * gdk_window_set_background:
+ * @window: a #GdkWindow
+ * @color: an allocated #GdkColor
+ *
+ * Sets the background color of @window. (However, when using GTK+,
+ * set the background of a widget with gtk_widget_modify_bg() - if
+ * you're an application - or gtk_style_set_background() - if you're
+ * implementing a custom widget.)
+ *
+ * The @color must be allocated; gdk_rgb_find_color() is the best way
+ * to allocate a color.
+ *
+ * See also gdk_window_set_back_pixmap().
+ *
+ **/
void
gdk_window_set_background (GdkWindow *window,
GdkColor *color)
if (private->bg_pixmap &&
private->bg_pixmap != GDK_PARENT_RELATIVE_BG &&
private->bg_pixmap != GDK_NO_BG)
- {
- gdk_pixmap_unref (private->bg_pixmap);
- private->bg_pixmap = NULL;
- }
+ g_object_unref (private->bg_pixmap);
+
+ private->bg_pixmap = NULL;
}
+/**
+ * gdk_window_set_back_pixmap:
+ * @window: a #GdkWindow
+ * @pixmap: a #GdkPixmap, or %NULL
+ * @parent_relative: whether the tiling origin is at the origin of @window's parent
+ *
+ * Sets the background pixmap of @window. May also be used to set a background of
+ * "None" on @window, by setting a background pixmap of %NULL.
+ * A background pixmap will be tiled, positioning the first tile at the origin of
+ * @window, or if @parent_relative is %TRUE, the tiling will be done based on the
+ * origin of the parent window (useful to align tiles in a parent with tiles
+ * in a child).
+ *
+ * A background pixmap of %NULL means that the window will have no
+ * background. A window with no background will never have its
+ * background filled by the windowing system, instead the window will
+ * contain whatever pixels were already in the corresponding area of
+ * the display.
+ *
+ * The windowing system will normally fill a window with its background
+ * when the window is obscured then exposed, and when you call
+ * gdk_window_clear().
+ *
+ **/
void
gdk_window_set_back_pixmap (GdkWindow *window,
GdkPixmap *pixmap,
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
g_return_if_fail (pixmap == NULL || !parent_relative);
-
+ g_return_if_fail (pixmap == NULL || gdk_drawable_get_depth (window) == gdk_drawable_get_depth (pixmap));
+
if (private->bg_pixmap &&
private->bg_pixmap != GDK_PARENT_RELATIVE_BG &&
private->bg_pixmap != GDK_NO_BG)
- gdk_pixmap_unref (private->bg_pixmap);
+ g_object_unref (private->bg_pixmap);
if (parent_relative)
{
{
if (pixmap)
{
- gdk_pixmap_ref (pixmap);
+ g_object_ref (pixmap);
private->bg_pixmap = pixmap;
xpixmap = GDK_PIXMAP_XID (pixmap);
}
GDK_WINDOW_XID (window), xpixmap);
}
+/**
+ * gdk_window_set_cursor:
+ * @window: a #GdkWindow
+ * @cursor: a cursor
+ *
+ * Sets the mouse pointer for a #GdkWindow. Use gdk_cursor_new() or
+ * gdk_cursor_new_from_pixmap() to create the cursor.
+ * To make the cursor invisible, use gdk_cursor_new_from_pixmap() to create
+ * a cursor with no pixels in it. Passing %NULL for the @cursor argument
+ * to gdk_window_set_cursor() means that @window will use the cursor of
+ * its parent window. Most windows should use this default.
+ *
+ **/
void
gdk_window_set_cursor (GdkWindow *window,
GdkCursor *cursor)
xcursor);
}
+/**
+ * gdk_window_get_geometry:
+ * @window: a #GdkWindow
+ * @x: return location for X coordinate of window (relative to its parent)
+ * @y: return location for Y coordinate of window (relative to its parent)
+ * @width: return location for width of window
+ * @height: return location for height of window
+ * @depth: return location for bit depth of window
+ *
+ * Any of the return location arguments to this function may be %NULL,
+ * if you aren't interested in getting the value of that field.
+ *
+ * The X and Y coordinates returned are relative to the parent window
+ * of @window, which for toplevels usually means relative to the
+ * window decorations (titlebar, etc.) rather than relative to the
+ * root window (screen-size background window).
+ *
+ * On the X11 platform, the geometry is obtained from the X server,
+ * so reflects the latest position of @window; this may be out-of-sync
+ * with the position of @window delivered in the most-recently-processed
+ * #GdkEventConfigure. gdk_window_get_position() in contrast gets the
+ * position from the most recent configure event.
+ *
+ **/
void
gdk_window_get_geometry (GdkWindow *window,
gint *x,
g_return_if_fail (window == NULL || GDK_IS_WINDOW (window));
if (!window)
- window = gdk_parent_root;
-
+ {
+ GDK_NOTE (MULTIHEAD,
+ g_message ("gdk_window_get_geometry(): Window needs to be non-NULL to be multi head safe"));
+ window = gdk_screen_get_root_window ((gdk_screen_get_default ()));
+ }
+
if (!GDK_WINDOW_DESTROYED (window))
{
XGetGeometry (GDK_WINDOW_XDISPLAY (window),
{
return_val = XTranslateCoordinates (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
- gdk_root_window,
+ GDK_WINDOW_XROOTWIN (window),
0, 0, &tx, &ty,
&child);
-
}
else
return_val = 0;
/**
* gdk_window_get_deskrelative_origin:
- * @window: a #GdkWindow
+ * @window: a toplevel #GdkWindow
* @x: return location for X coordinate
* @y: return location for Y coordinate
*
gint tx = 0;
gint ty = 0;
Atom type_return;
- static Atom atom = 0;
+ Atom atom;
gulong number_return, bytes_after_return;
guchar *data_return;
if (!GDK_WINDOW_DESTROYED (window))
{
- if (!atom)
- atom = gdk_atom_intern ("ENLIGHTENMENT_DESKTOP", FALSE);
+ atom = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
+ "ENLIGHTENMENT_DESKTOP");
win = GDK_WINDOW_XID (window);
while (XQueryTree (GDK_WINDOW_XDISPLAY (window), win, &root, &parent,
XGetWindowProperty (GDK_WINDOW_XDISPLAY (window), win, atom, 0, 0,
False, XA_CARDINAL, &type_return, &format_return,
&number_return, &bytes_after_return, &data_return);
+
if (type_return == XA_CARDINAL)
{
XFree (data_return);
/**
* gdk_window_get_root_origin:
- * @window: a #GdkWindow
+ * @window: a toplevel #GdkWindow
* @x: return location for X position of window frame
* @y: return location for Y position of window frame
*
/**
* gdk_window_get_frame_extents:
- * @window: a #GdkWindow
+ * @window: a toplevel #GdkWindow
* @rect: rectangle to fill with bounding box of the window frame
*
* Obtains the bounding box of the window, including window manager
}
}
+void
+_gdk_windowing_get_pointer (GdkDisplay *display,
+ GdkScreen **screen,
+ gint *x,
+ gint *y,
+ GdkModifierType *mask)
+{
+ GdkScreen *default_screen;
+ Window root = None;
+ Window child;
+ int rootx, rooty;
+ int winx;
+ int winy;
+ unsigned int xmask;
+
+ if (display->closed)
+ return;
+
+ default_screen = gdk_display_get_default_screen (display);
+
+ XQueryPointer (GDK_SCREEN_XDISPLAY (default_screen),
+ GDK_SCREEN_XROOTWIN (default_screen),
+ &root, &child, &rootx, &rooty, &winx, &winy, &xmask);
+
+ if (root != None)
+ {
+ GdkWindow *gdk_root = gdk_window_lookup_for_display (display, root);
+ *screen = gdk_drawable_get_screen (gdk_root);
+ }
+
+ *x = rootx;
+ *y = rooty;
+ *mask = xmask;
+}
+
GdkWindow*
-gdk_window_get_pointer (GdkWindow *window,
- gint *x,
- gint *y,
- GdkModifierType *mask)
+_gdk_windowing_window_get_pointer (GdkDisplay *display,
+ GdkWindow *window,
+ gint *x,
+ gint *y,
+ GdkModifierType *mask)
{
GdkWindow *return_val;
Window root;
g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
- if (!window)
- window = gdk_parent_root;
-
_gdk_windowing_window_get_offsets (window, &xoffset, &yoffset);
return_val = NULL;
&root, &child, &rootx, &rooty, &winx, &winy, &xmask))
{
if (child)
- return_val = gdk_window_lookup (child);
+ return_val = gdk_window_lookup_for_display (GDK_WINDOW_DISPLAY (window), child);
}
- if (x)
- *x = winx + xoffset;
- if (y)
- *y = winy + yoffset;
- if (mask)
- *mask = xmask;
+ *x = winx + xoffset;
+ *y = winy + yoffset;
+ *mask = xmask;
return return_val;
}
GdkWindow*
-gdk_window_at_pointer (gint *win_x,
- gint *win_y)
+_gdk_windowing_window_at_pointer (GdkDisplay *display,
+ gint *win_x,
+ gint *win_y)
{
GdkWindow *window;
+ GdkScreen *screen;
Window root;
Window xwindow;
+ Window child;
Window xwindow_last = 0;
Display *xdisplay;
int rootx = -1, rooty = -1;
int winx, winy;
unsigned int xmask;
+
+ screen = gdk_display_get_default_screen (display);
- xwindow = GDK_ROOT_WINDOW ();
- xdisplay = GDK_DISPLAY ();
+ xwindow = GDK_SCREEN_XROOTWIN (screen);
+ xdisplay = GDK_SCREEN_XDISPLAY (screen);
+
+ /* This function really only works if the mouse pointer is held still
+ * during its operation. If it moves from one leaf window to another
+ * than we'll end up with inaccurate values for win_x, win_y
+ * and the result.
+ */
+ XGrabServer (xdisplay);
+ XQueryPointer (xdisplay, xwindow,
+ &root, &child, &rootx, &rooty, &winx, &winy, &xmask);
- gdk_x11_grab_server ();
+ if (root == xwindow)
+ xwindow = child;
+ else
+ xwindow = root;
+
while (xwindow)
{
xwindow_last = xwindow;
XQueryPointer (xdisplay, xwindow,
- &root, &xwindow,
- &rootx, &rooty,
- &winx, &winy,
- &xmask);
+ &root, &xwindow, &rootx, &rooty, &winx, &winy, &xmask);
}
- gdk_x11_ungrab_server ();
-
- window = gdk_window_lookup (xwindow_last);
-
- if (win_x)
- *win_x = window ? winx : -1;
- if (win_y)
- *win_y = window ? winy : -1;
-
+ XUngrabServer (xdisplay);
+
+ window = gdk_window_lookup_for_display (GDK_SCREEN_DISPLAY(screen),
+ xwindow_last);
+ *win_x = window ? winx : -1;
+ *win_y = window ? winy : -1;
+
return window;
}
+/**
+ * gdk_window_get_events:
+ * @window: a #GdkWindow
+ *
+ * Gets the event mask for @window. See gdk_window_set_events().
+ *
+ * Return value: event mask for @window
+ **/
GdkEventMask
gdk_window_get_events (GdkWindow *window)
{
XWindowAttributes attrs;
GdkEventMask event_mask;
- int i;
g_return_val_if_fail (window != NULL, 0);
g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
GDK_WINDOW_XID (window),
&attrs);
- event_mask = 0;
- for (i = 0; i < gdk_nevent_masks; i++)
- {
- if (attrs.your_event_mask & gdk_event_mask_table[i])
- event_mask |= 1 << (i + 1);
- }
+ event_mask = x_event_mask_to_gdk_event_mask (attrs.your_event_mask);
+ GDK_WINDOW_OBJECT (window)->event_mask = event_mask;
return event_mask;
}
}
+/**
+ * gdk_window_set_events:
+ * @window: a #GdkWindow
+ * @event_mask: event mask for @window
+ *
+ * The event mask for a window determines which events will be reported
+ * for that window. For example, an event mask including #GDK_BUTTON_PRESS_MASK
+ * means the window should report button press events. The event mask
+ * is the bitwise OR of values from the #GdkEventMask enumeration.
+ *
+ **/
void
gdk_window_set_events (GdkWindow *window,
GdkEventMask event_mask)
if (!GDK_WINDOW_DESTROYED (window))
{
- xevent_mask = StructureNotifyMask;
- for (i = 0; i < gdk_nevent_masks; i++)
+ GDK_WINDOW_OBJECT (window)->event_mask = event_mask;
+ xevent_mask = StructureNotifyMask | PropertyChangeMask;
+ for (i = 0; i < _gdk_nenvent_masks; i++)
{
if (event_mask & (1 << (i + 1)))
- xevent_mask |= gdk_event_mask_table[i];
+ xevent_mask |= _gdk_event_mask_table[i];
}
XSelectInput (GDK_WINDOW_XDISPLAY (window),
}
}
-void
+static void
gdk_window_add_colormap_windows (GdkWindow *window)
{
GdkWindow *toplevel;
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
-
- toplevel = gdk_window_get_toplevel (window);
- if (GDK_WINDOW_DESTROYED (toplevel))
+
+ if (GDK_WINDOW_DESTROYED (window))
return;
+ toplevel = gdk_window_get_toplevel (window);
old_windows = NULL;
if (!XGetWMColormapWindows (GDK_WINDOW_XDISPLAY (toplevel),
}
static gboolean
-gdk_window_have_shape_ext (void)
+gdk_window_have_shape_ext (GdkDisplay *display)
{
- enum { UNKNOWN, NO, YES };
- static gint have_shape = UNKNOWN;
+ GdkDisplayX11 *display_x11;
+
+ g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
+
+ display_x11 = GDK_DISPLAY_X11 (display);
- if (have_shape == UNKNOWN)
+ if (display_x11->have_shape == GDK_UNKNOWN)
{
int ignore;
- if (XQueryExtension (gdk_display, "SHAPE", &ignore, &ignore, &ignore))
- have_shape = YES;
+ if (XQueryExtension (display_x11->xdisplay, "SHAPE", &ignore, &ignore, &ignore))
+ display_x11->have_shape = GDK_YES;
else
- have_shape = NO;
+ display_x11->have_shape = GDK_NO;
}
- return (have_shape == YES);
+ return (display_x11->have_shape == GDK_YES);
}
#define WARN_SHAPE_TOO_BIG() g_warning ("GdkWindow is too large to allow the use of shape masks or shape regions.")
* If not available, shaped windows will look
* ugly, but programs still work. Stefan Wille
*/
+/**
+ * gdk_window_shape_combine_mask:
+ * @window: a #GdkWindow
+ * @mask: shape mask
+ * @x: X position of shape mask with respect to @window
+ * @y: Y position of shape mask with respect to @window
+ *
+ * Applies a shape mask to @window. Pixels in @window corresponding to
+ * set bits in the @mask will be visible; pixels in @window
+ * corresponding to unset bits in the @mask will be transparent. This
+ * gives a non-rectangular window.
+ *
+ * If @mask is %NULL, the shape mask will be unset, and the @x/@y
+ * parameters are not used.
+ *
+ * On the X11 platform, this uses an X server extension which is
+ * widely available on most common platforms, but not available on
+ * very old X servers, and occasionally the implementation will be
+ * buggy. On servers without the shape extension, this function
+ * will do nothing.
+ *
+ * This function works on both toplevel and child windows.
+ *
+ **/
void
gdk_window_shape_combine_mask (GdkWindow *window,
GdkBitmap *mask,
return;
}
- if (gdk_window_have_shape_ext ())
+ if (gdk_window_have_shape_ext (GDK_WINDOW_DISPLAY (window)))
{
if (mask)
{
#endif /* HAVE_SHAPE_EXT */
}
+/**
+ * gdk_window_shape_combine_region:
+ * @window: a #GdkWindow
+ * @shape_region: region of window to be non-transparent
+ * @offset_x: X position of @shape_region in @window coordinates
+ * @offset_y: Y position of @shape_region in @window coordinates
+ *
+ * Makes pixels in @window outside @shape_region be transparent,
+ * so that the window may be nonrectangular. See also
+ * gdk_window_shape_combine_mask() to use a bitmap as the mask.
+ *
+ * If @shape_region is %NULL, the shape will be unset, so the whole
+ * window will be opaque again. @offset_x and @offset_y are ignored
+ * if @shape_region is %NULL.
+ *
+ * On the X11 platform, this uses an X server extension which is
+ * widely available on most common platforms, but not available on
+ * very old X servers, and occasionally the implementation will be
+ * buggy. On servers without the shape extension, this function
+ * will do nothing.
+ *
+ * This function works on both toplevel and child windows.
+ *
+ **/
void
gdk_window_shape_combine_region (GdkWindow *window,
GdkRegion *shape_region,
return;
}
- if (gdk_window_have_shape_ext ())
+ if (gdk_window_have_shape_ext (GDK_WINDOW_DISPLAY (window)))
{
gint n_rects = 0;
XRectangle *xrects = NULL;
}
+/**
+ * gdk_window_set_override_redirect:
+ * @window: a toplevel #GdkWindow
+ * @override_redirect: %TRUE if window should be override redirect
+ *
+ * An override redirect window is not under the control of the window manager.
+ * This means it won't have a titlebar, won't be minimizable, etc. - it will
+ * be entirely under the control of the application. The window manager
+ * can't see the override redirect window at all.
+ *
+ * Override redirect should only be used for short-lived temporary
+ * windows, such as popup menus. #GtkMenu uses an override redirect
+ * window in its implementation, for example.
+ *
+ **/
void
gdk_window_set_override_redirect (GdkWindow *window,
gboolean override_redirect)
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
- if (GDK_WINDOW_DESTROYED (window))
+ if (!GDK_WINDOW_DESTROYED (window))
{
attr.override_redirect = (override_redirect == FALSE)?False:True;
XChangeWindowAttributes (GDK_WINDOW_XDISPLAY (window),
* gdk_window_set_icon_list:
* @window: The #GdkWindow toplevel window to set the icon of.
* @pixbufs: A list of pixbufs, of different sizes.
- * @Returns: %TRUE if the icons were set, false otherwise
*
* Sets a list of icons for the window. One of these will be used
* to represent the window when it has been iconified. The icon is
* image quality since the window manager may only need to scale the
* icon by a small amount or not at all.
*
- * On the X11 backend this call might fail if the window manager
- * doesn't support the Extended Window Manager Hints. Then this
- * function returns FALSE, and the application should fall back
- * to #gdk_window_set_icon().
**/
-gboolean
+void
gdk_window_set_icon_list (GdkWindow *window,
GList *pixbufs)
{
- guint *data;
+ gulong *data;
guchar *pixels;
- guint *p;
+ gulong *p;
gint size;
GList *l;
GdkPixbuf *pixbuf;
gint width, height, stride;
gint x, y;
gint n_channels;
+ GdkDisplay *display;
- g_return_val_if_fail (window != NULL, FALSE);
- g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
+ g_return_if_fail (GDK_IS_WINDOW (window));
if (GDK_WINDOW_DESTROYED (window))
- return FALSE;
+ return;
- if (!gdk_net_wm_supports (gdk_atom_intern ("_NET_WM_ICON", FALSE)))
- return FALSE;
+ display = gdk_drawable_get_display (window);
l = pixbufs;
size = 0;
while (l)
{
pixbuf = l->data;
- g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), FALSE);
+ g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
l = g_list_next (l);
}
- data = g_malloc (size*4);
+ data = g_malloc (size * sizeof (gulong));
l = pixbufs;
p = data;
l = g_list_next (l);
}
- XChangeProperty (GDK_WINDOW_XDISPLAY (window),
- GDK_WINDOW_XID (window),
- gdk_atom_intern ("_NET_WM_ICON", FALSE),
- XA_CARDINAL, 32,
- PropModeReplace,
- (guchar*) data, size);
-
- return TRUE;
+ if (size > 0)
+ {
+ XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
+ GDK_WINDOW_XID (window),
+ gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON"),
+ XA_CARDINAL, 32,
+ PropModeReplace,
+ (guchar*) data, size);
+ }
+ else
+ {
+ XDeleteProperty (GDK_DISPLAY_XDISPLAY (display),
+ GDK_WINDOW_XID (window),
+ gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON"));
+ }
+
+ g_free (data);
}
+/**
+ * gdk_window_set_icon:
+ * @window: a toplevel #GdkWindow
+ * @icon_window: a #GdkWindow to use for the icon, or %NULL to unset
+ * @pixmap: a #GdkPixmap to use as the icon, or %NULL to unset
+ * @mask: a 1-bit pixmap (#GdkBitmap) to use as mask for @pixmap, or %NULL to have none
+ *
+ * Sets the icon of @window as a pixmap or window. If using GTK+, investigate
+ * gtk_window_set_default_icon_list() first, and then gtk_window_set_icon_list()
+ * and gtk_window_set_icon(). If those don't meet your needs, look at
+ * gdk_window_set_icon_list(). Only if all those are too high-level do you
+ * want to fall back to gdk_window_set_icon().
+ *
+ **/
void
gdk_window_set_icon (GdkWindow *window,
GdkWindow *icon_window,
g_quark_from_static_string ("gdk-icon-name-set")));
}
+/**
+ * gdk_window_set_icon_name:
+ * @window: a toplevel #GdkWindow
+ * @name: name of window while iconified (minimized)
+ *
+ * Windows may have a name used while minimized, distinct from the
+ * name they display in their titlebar. Most of the time this is a bad
+ * idea from a user interface standpoint. But you can set such a name
+ * with this function, if you like.
+ *
+ **/
void
gdk_window_set_icon_name (GdkWindow *window,
const gchar *name)
{
+ GdkDisplay *display;
+
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
if (GDK_WINDOW_DESTROYED (window))
return;
+ display = gdk_drawable_get_display (window);
+
g_object_set_qdata (G_OBJECT (window), g_quark_from_static_string ("gdk-icon-name-set"),
GUINT_TO_POINTER (TRUE));
- XChangeProperty (GDK_WINDOW_XDISPLAY (window),
+ XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
GDK_WINDOW_XID (window),
- gdk_atom_intern ("_NET_WM_ICON_NAME", FALSE),
- gdk_atom_intern ("UTF8_STRING", FALSE), 8,
- PropModeReplace, name,
- strlen (name));
- set_text_property (window, gdk_atom_intern ("WM_ICON_NAME", FALSE), name);
+ gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_ICON_NAME"),
+ gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
+ PropModeReplace, name, strlen (name));
+
+ set_text_property (display, GDK_WINDOW_XID (window),
+ gdk_x11_get_xatom_by_name_for_display (display, "WM_ICON_NAME"),
+ name);
}
+/**
+ * gdk_window_iconify:
+ * @window: a toplevel #GdkWindow
+ *
+ * Asks to iconify (minimize) @window. The window manager may choose
+ * to ignore the request, but normally will honor it. Using
+ * gtk_window_iconify() is preferred, if you have a #GtkWindow widget.
+ *
+ * This function only makes sense when @window is a toplevel window.
+ *
+ **/
void
gdk_window_iconify (GdkWindow *window)
{
- Display *display;
GdkWindowObject *private;
g_return_if_fail (window != NULL);
if (GDK_WINDOW_DESTROYED (window))
return;
- display = GDK_WINDOW_XDISPLAY (window);
-
private = (GdkWindowObject*) window;
if (GDK_WINDOW_IS_MAPPED (window))
{
- XIconifyWindow (display, GDK_WINDOW_XWINDOW (window), DefaultScreen (display));
-
+ XIconifyWindow (GDK_WINDOW_XDISPLAY (window),
+ GDK_WINDOW_XWINDOW (window),
+ gdk_screen_get_number (GDK_WINDOW_SCREEN (window)));
}
else
{
}
}
+/**
+ * gdk_window_deiconify:
+ * @window: a toplevel #GdkWindow
+ *
+ * Attempt to deiconify (unminimize) @window. On X11 the window manager may
+ * choose to ignore the request to deiconify. When using GTK+,
+ * use gtk_window_deiconify() instead of the #GdkWindow variant. Or better yet,
+ * you probably want to use gtk_window_present(), which raises the window, focuses it,
+ * unminimizes it, and puts it on the current desktop.
+ *
+ **/
void
gdk_window_deiconify (GdkWindow *window)
{
- Display *display;
GdkWindowObject *private;
g_return_if_fail (window != NULL);
if (GDK_WINDOW_DESTROYED (window))
return;
- display = GDK_WINDOW_XDISPLAY (window);
-
private = (GdkWindowObject*) window;
if (GDK_WINDOW_IS_MAPPED (window))
}
}
+/**
+ * gdk_window_stick:
+ * @window: a toplevel #GdkWindow
+ *
+ * "Pins" a window such that it's on all workspaces and does not scroll
+ * with viewports, for window managers that have scrollable viewports.
+ * (When using #GtkWindow, gtk_window_stick() may be more useful.)
+ *
+ * On the X11 platform, this function depends on window manager
+ * support, so may have no effect with many window managers. However,
+ * GDK will do the best it can to convince the window manager to stick
+ * the window. For window managers that don't support this operation,
+ * there's nothing you can do to force it to happen.
+ *
+ **/
void
gdk_window_stick (GdkWindow *window)
{
xev.xclient.serial = 0;
xev.xclient.send_event = True;
xev.xclient.window = GDK_WINDOW_XWINDOW (window);
- xev.xclient.display = gdk_display;
- xev.xclient.message_type = gdk_atom_intern ("_NET_WM_DESKTOP", FALSE);
+ xev.xclient.display = GDK_WINDOW_XDISPLAY (window);
+ xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
+ "_NET_WM_DESKTOP");
xev.xclient.format = 32;
xev.xclient.data.l[0] = 0xFFFFFFFF;
-
- XSendEvent (gdk_display, gdk_root_window, False,
+
+ XSendEvent (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XROOTWIN (window), False,
SubstructureRedirectMask | SubstructureNotifyMask,
&xev);
}
}
}
+/**
+ * gdk_window_unstick:
+ * @window: a toplevel #GdkWindow
+ *
+ * Reverse operation for gdk_window_stick(); see gdk_window_stick(),
+ * and gtk_window_unstick().
+ *
+ **/
void
gdk_window_unstick (GdkWindow *window)
{
gulong nitems;
gulong bytes_after;
gulong *current_desktop;
+ GdkDisplay *display = gdk_drawable_get_display (window);
/* Request unstick from viewport */
gdk_wmspec_change_state (FALSE, window,
/* Get current desktop, then set it; this is a race, but not
* one that matters much in practice.
*/
- XGetWindowProperty (gdk_display, gdk_root_window,
- gdk_atom_intern ("_NET_CURRENT_DESKTOP", FALSE),
+ XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XROOTWIN (window),
+ gdk_x11_get_xatom_by_name_for_display (display, "_NET_CURRENT_DESKTOP"),
0, G_MAXLONG,
False, XA_CARDINAL, &type, &format, &nitems,
&bytes_after, (guchar **)¤t_desktop);
xev.xclient.serial = 0;
xev.xclient.send_event = True;
xev.xclient.window = GDK_WINDOW_XWINDOW (window);
- xev.xclient.display = gdk_display;
- xev.xclient.message_type = gdk_atom_intern ("_NET_WM_DESKTOP", FALSE);
+ xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP");
xev.xclient.format = 32;
xev.xclient.data.l[0] = *current_desktop;
- XSendEvent (gdk_display, gdk_root_window, False,
+ XSendEvent (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XROOTWIN (window), False,
SubstructureRedirectMask | SubstructureNotifyMask,
&xev);
}
}
+/**
+ * gdk_window_maximize:
+ * @window: a toplevel #GdkWindow
+ *
+ * Maximizes the window. If the window was already maximized, then
+ * this function does nothing.
+ *
+ * On X11, asks the window manager to maximize @window, if the window
+ * manager supports this operation. Not all window managers support
+ * this, and some deliberately ignore it or don't have a concept of
+ * "maximized"; so you can't rely on the maximization actually
+ * happening. But it will happen with most standard window managers,
+ * and GDK makes a best effort to get it to happen.
+ *
+ * On Windows, reliably maximizes the window.
+ *
+ **/
void
gdk_window_maximize (GdkWindow *window)
{
GDK_WINDOW_STATE_MAXIMIZED);
}
+/**
+ * gdk_window_unmaximize:
+ * @window: a toplevel #GdkWindow
+ *
+ * Unmaximizes the window. If the window wasn't maximized, then this
+ * function does nothing.
+ *
+ * On X11, asks the window manager to unmaximize @window, if the
+ * window manager supports this operation. Not all window managers
+ * support this, and some deliberately ignore it or don't have a
+ * concept of "maximized"; so you can't rely on the unmaximization
+ * actually happening. But it will happen with most standard window
+ * managers, and GDK makes a best effort to get it to happen.
+ *
+ * On Windows, reliably unmaximizes the window.
+ *
+ **/
void
gdk_window_unmaximize (GdkWindow *window)
{
0);
}
+/**
+ * gdk_window_fullscreen:
+ * @window: a toplevel #GdkWindow
+ *
+ * Moves the window into fullscreen mode. This means the
+ * window covers the entire screen and is above any panels
+ * or task bars.
+ *
+ * If the window was already fullscreen, then this function does nothing.
+ *
+ * On X11, asks the window manager to put @window in a fullscreen
+ * state, if the window manager supports this operation. Not all
+ * window managers support this, and some deliberately ignore it or
+ * don't have a concept of "fullscreen"; so you can't rely on the
+ * fullscreenification actually happening. But it will happen with
+ * most standard window managers, and GDK makes a best effort to get
+ * it to happen.
+ *
+ **/
+void
+gdk_window_fullscreen (GdkWindow *window)
+{
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ if (GDK_WINDOW_DESTROYED (window))
+ return;
+
+ if (GDK_WINDOW_IS_MAPPED (window))
+ gdk_wmspec_change_state (TRUE, window,
+ gdk_atom_intern ("_NET_WM_STATE_FULLSCREEN", FALSE),
+ GDK_NONE);
+
+ else
+ gdk_synthesize_window_state (window,
+ 0,
+ GDK_WINDOW_STATE_FULLSCREEN);
+}
+
+/**
+ * gdk_window_unfullscreen:
+ * @window: a toplevel #GdkWindow
+ *
+ * Moves the window out of fullscreen mode. If the window was not
+ * fullscreen, does nothing.
+ *
+ * On X11, asks the window manager to move @window out of the fullscreen
+ * state, if the window manager supports this operation. Not all
+ * window managers support this, and some deliberately ignore it or
+ * don't have a concept of "fullscreen"; so you can't rely on the
+ * unfullscreenification actually happening. But it will happen with
+ * most standard window managers, and GDK makes a best effort to get
+ * it to happen.
+ *
+ **/
+void
+gdk_window_unfullscreen (GdkWindow *window)
+{
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ if (GDK_WINDOW_DESTROYED (window))
+ return;
+
+ if (GDK_WINDOW_IS_MAPPED (window))
+ gdk_wmspec_change_state (FALSE, window,
+ gdk_atom_intern ("_NET_WM_STATE_FULLSCREEN", FALSE),
+ GDK_NONE);
+
+ else
+ gdk_synthesize_window_state (window,
+ GDK_WINDOW_STATE_FULLSCREEN,
+ 0);
+}
+
+
+/**
+ * gdk_window_set_group:
+ * @window: a toplevel #GdkWindow
+ * @leader: group leader window
+ *
+ * Sets the group leader window for @window. By default,
+ * GDK sets the group leader for all toplevel windows
+ * to a global window implicitly created by GDK. With this function
+ * you can override this default.
+ *
+ * The group leader window allows the window manager to distinguish
+ * all windows that belong to a single application. It may for example
+ * allow users to minimize/unminimize all windows belonging to an
+ * application at once. You should only set a non-default group window
+ * if your application pretends to be multiple applications.
+ * The group leader window may not be changed after a window has been
+ * mapped (with gdk_window_show() for example).
+ *
+ **/
void
gdk_window_set_group (GdkWindow *window,
GdkWindow *leader)
static MotifWmHints *
gdk_window_get_mwm_hints (GdkWindow *window)
{
- static Atom hints_atom = None;
+ GdkDisplay *display;
+ Atom hints_atom = None;
MotifWmHints *hints;
Atom type;
gint format;
if (GDK_WINDOW_DESTROYED (window))
return NULL;
+
+ display = gdk_drawable_get_display (window);
- if (!hints_atom)
- hints_atom = XInternAtom (GDK_WINDOW_XDISPLAY (window),
- _XA_MOTIF_WM_HINTS, FALSE);
-
- XGetWindowProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
+ hints_atom = gdk_x11_get_xatom_by_name_for_display (display, _XA_MOTIF_WM_HINTS);
+
+ XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
hints_atom, 0, sizeof (MotifWmHints)/sizeof (long),
False, AnyPropertyType, &type, &format, &nitems,
&bytes_after, (guchar **)&hints);
gdk_window_set_mwm_hints (GdkWindow *window,
MotifWmHints *new_hints)
{
- static Atom hints_atom = None;
+ GdkDisplay *display;
+ Atom hints_atom = None;
MotifWmHints *hints;
Atom type;
gint format;
if (GDK_WINDOW_DESTROYED (window))
return;
- if (!hints_atom)
- hints_atom = XInternAtom (GDK_WINDOW_XDISPLAY (window),
- _XA_MOTIF_WM_HINTS, FALSE);
+ display = gdk_drawable_get_display (window);
+ hints_atom = gdk_x11_get_xatom_by_name_for_display (display, _XA_MOTIF_WM_HINTS);
+
XGetWindowProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
hints_atom, 0, sizeof (MotifWmHints)/sizeof (long),
False, AnyPropertyType, &type, &format, &nitems,
XFree (hints);
}
+/**
+ * gdk_window_set_decorations:
+ * @window: a toplevel #GdkWindow
+ * @decorations: decoration hint mask
+ *
+ * "Decorations" are the features the window manager adds to a toplevel #GdkWindow.
+ * This function sets the traditional Motif window manager hints that tell the
+ * window manager which decorations you would like your window to have.
+ * Usually you should use gtk_window_set_decorated() on a #GtkWindow instead of
+ * using the GDK function directly.
+ *
+ * The @decorations argument is the logical OR of the fields in
+ * the #GdkWMDecoration enumeration. If #GDK_DECOR_ALL is included in the
+ * mask, the other bits indicate which decorations should be turned off.
+ * If #GDK_DECOR_ALL is not included, then the other bits indicate
+ * which decorations should be turned on.
+ *
+ * Most window managers honor a decorations hint of 0 to disable all decorations,
+ * but very few honor all possible combinations of bits.
+ *
+ **/
void
gdk_window_set_decorations (GdkWindow *window,
GdkWMDecoration decorations)
/**
* gdk_window_get_decorations:
- * @window: The #GdkWindow to get the decorations from
+ * @window: The toplevel #GdkWindow to get the decorations from
* @decorations: The window decorations will be written here
*
* Returns the decorations set on the GdkWindow with #gdk_window_set_decorations
* Returns: TRUE if the window has decorations set, FALSE otherwise.
**/
gboolean
-gdk_window_get_decorations(GdkWindow *window,
+gdk_window_get_decorations(GdkWindow *window,
GdkWMDecoration *decorations)
{
MotifWmHints *hints;
gboolean result = FALSE;
+ g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
+
hints = gdk_window_get_mwm_hints (window);
if (hints)
{
if (hints->flags & MWM_HINTS_DECORATIONS)
{
- *decorations = hints->decorations;
+ if (decorations)
+ *decorations = hints->decorations;
result = TRUE;
}
return result;
}
+/**
+ * gdk_window_set_functions:
+ * @window: a toplevel #GdkWindow
+ * @functions: bitmask of operations to allow on @window
+ *
+ * This function isn't really good for much. It sets the traditional
+ * Motif window manager hint for which operations the window manager
+ * should allow on a toplevel window. However, few window managers do
+ * anything reliable or interesting with this hint. Many ignore it
+ * entirely.
+ *
+ * The @functions argument is the logical OR of values from the
+ * #GdkWMFunction enumeration. If the bitmask includes #GDK_FUNC_ALL,
+ * then the other bits indicate which functions to disable; if
+ * it doesn't include #GDK_FUNC_ALL, it indicates which functions to
+ * enable.
+ *
+ **/
void
gdk_window_set_functions (GdkWindow *window,
GdkWMFunction functions)
#endif /* HAVE_SHAPE_EXT */
+/**
+ * gdk_window_set_child_shapes:
+ * @window: a #GdkWindow
+ *
+ * Sets the shape mask of @window to the union of shape masks
+ * for all children of @window, ignoring the shape mask of @window
+ * itself. Contrast with gdk_window_merge_child_shapes() which includes
+ * the shape mask of @window in the masks to be merged.
+ **/
void
gdk_window_set_child_shapes (GdkWindow *window)
{
#ifdef HAVE_SHAPE_EXT
if (!GDK_WINDOW_DESTROYED (window) &&
- gdk_window_have_shape_ext ())
+ gdk_window_have_shape_ext (GDK_WINDOW_DISPLAY (window)))
gdk_propagate_shapes (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window), FALSE);
#endif
}
+/**
+ * gdk_window_merge_child_shapes:
+ * @window: a #GdkWindow
+ *
+ * Merges the shape masks for any child windows into the
+ * shape mask for @window. i.e. the union of all masks
+ * for @window and its children will become the new mask
+ * for @window. See gdk_window_shape_combine_mask().
+ *
+ * This function is distinct from gdk_window_set_child_shapes()
+ * because it includes @window's shape mask in the set of shapes to
+ * be merged.
+ *
+ **/
void
gdk_window_merge_child_shapes (GdkWindow *window)
{
#ifdef HAVE_SHAPE_EXT
if (!GDK_WINDOW_DESTROYED (window) &&
- gdk_window_have_shape_ext ())
+ gdk_window_have_shape_ext (GDK_WINDOW_DISPLAY (window)))
gdk_propagate_shapes (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window), TRUE);
#endif
*/
static gboolean
-gdk_window_gravity_works (void)
+gdk_window_gravity_works (GdkWindow *window)
{
- enum { UNKNOWN, NO, YES };
- static gint gravity_works = UNKNOWN;
+ GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (GDK_DRAWABLE_DISPLAY (window));
- if (gravity_works == UNKNOWN)
+ if (display_x11->gravity_works == GDK_UNKNOWN)
{
GdkWindowAttr attr;
GdkWindow *parent;
/* This particular server apparently has a bug so that the test
* works but the actual code crashes it
*/
- if ((!strcmp (XServerVendor (gdk_display), "Sun Microsystems, Inc.")) &&
- (VendorRelease (gdk_display) == 3400))
+ if ((!strcmp (XServerVendor (display_x11->xdisplay),
+ "Sun Microsystems, Inc.")) &&
+ (VendorRelease (display_x11->xdisplay) == 3400))
{
- gravity_works = NO;
+ display_x11->gravity_works = GDK_NO;
return FALSE;
}
attr.height = 100;
attr.event_mask = 0;
- parent = gdk_window_new (NULL, &attr, GDK_WA_X | GDK_WA_Y);
+ parent = gdk_window_new (gdk_screen_get_root_window (GDK_DRAWABLE_SCREEN (window)),
+ &attr, GDK_WA_X | GDK_WA_Y);
attr.window_type = GDK_WINDOW_CHILD;
child = gdk_window_new (parent, &attr, GDK_WA_X | GDK_WA_Y);
gdk_window_set_static_win_gravity (child, TRUE);
gdk_window_resize (parent, 100, 110);
+
gdk_window_move (parent, 0, -10);
gdk_window_move_resize (parent, 0, 0, 100, 100);
gdk_window_destroy (parent);
gdk_window_destroy (child);
- gravity_works = ((y == -20) ? YES : NO);
+ display_x11->gravity_works = ((y == -20) ? GDK_YES : GDK_NO);
}
- return (gravity_works == YES);
+ return (display_x11->gravity_works == GDK_YES);
}
static void
gdk_window_set_static_bit_gravity (GdkWindow *window, gboolean on)
{
XSetWindowAttributes xattributes;
+ GdkWindowObject *private;
guint xattributes_mask = 0;
g_return_if_fail (window != NULL);
+
+ private = GDK_WINDOW_OBJECT (window);
+ if (private->input_only)
+ return;
xattributes.bit_gravity = StaticGravity;
xattributes_mask |= CWBitGravity;
CWWinGravity, &xattributes);
}
-/*************************************************************
+/**
* gdk_window_set_static_gravities:
- * Set the bit gravity of the given window to static,
- * and flag it so all children get static subwindow
- * gravity.
- * arguments:
- * window: window for which to set static gravity
- * use_static: Whether to turn static gravity on or off.
- * results:
- * Does the XServer support static gravity?
- *************************************************************/
-
+ * @window: a #GdkWindow
+ * @use_static: %TRUE to turn on static gravity
+ *
+ * Set the bit gravity of the given window to static, and flag it so
+ * all children get static subwindow gravity. This is used if you are
+ * implementing scary features that involve deep knowledge of the
+ * windowing system. Don't worry about it unless you have to.
+ *
+ * Return value: %TRUE if the server supports static gravity
+ **/
gboolean
gdk_window_set_static_gravities (GdkWindow *window,
gboolean use_static)
if (!use_static == !private->guffaw_gravity)
return TRUE;
- if (use_static && !gdk_window_gravity_works ())
+ if (use_static && !gdk_window_gravity_works (window))
return FALSE;
private->guffaw_gravity = use_static;
tmp_list = private->children;
while (tmp_list)
{
- gdk_window_set_static_win_gravity (window, use_static);
+ gdk_window_set_static_win_gravity (tmp_list->data, use_static);
tmp_list = tmp_list->next;
}
return TRUE;
}
-/* internal function created for and used by gdk_window_xid_at_coords */
-Window
-gdk_window_xid_at (Window base,
- gint bx,
- gint by,
- gint x,
- gint y,
- GList *excludes,
- gboolean excl_child)
-{
- Display *xdisplay;
- Window *list = NULL;
- Window child = 0, parent_win = 0, root_win = 0;
- int i;
- unsigned int ww, wh, wb, wd, num;
- int wx, wy;
-
- xdisplay = GDK_DISPLAY ();
- if (!XGetGeometry (xdisplay, base, &root_win, &wx, &wy, &ww, &wh, &wb, &wd))
- return 0;
- wx += bx;
- wy += by;
-
- if (!((x >= wx) &&
- (y >= wy) &&
- (x < (int) (wx + ww)) &&
- (y < (int) (wy + wh))))
- return 0;
-
- if (!XQueryTree (xdisplay, base, &root_win, &parent_win, &list, &num))
- return base;
-
- if (list)
- {
- for (i = num - 1; ; i--)
- {
- if ((!excl_child) || (!g_list_find (excludes, (gpointer *) list[i])))
- {
- if ((child = gdk_window_xid_at (list[i], wx, wy, x, y, excludes, excl_child)) != 0)
- {
- XFree (list);
- return child;
- }
- }
- if (!i)
- break;
- }
- XFree (list);
- }
- return base;
-}
-
-/*
- * The following fucntion by The Rasterman <raster@redhat.com>
- * This function returns the X Window ID in which the x y location is in
- * (x and y being relative to the root window), excluding any windows listed
- * in the GList excludes (this is a list of X Window ID's - gpointer being
- * the Window ID).
- *
- * This is primarily designed for internal gdk use - for DND for example
- * when using a shaped icon window as the drag object - you exclude the
- * X Window ID of the "icon" (perhaps more if excludes may be needed) and
- * You can get back an X Window ID as to what X Window ID is infact under
- * those X,Y co-ordinates.
- */
-Window
-gdk_window_xid_at_coords (gint x,
- gint y,
- GList *excludes,
- gboolean excl_child)
-{
- GdkWindow *window;
- Display *xdisplay;
- Window *list = NULL;
- Window root, child = 0, parent_win = 0, root_win = 0;
- unsigned int num;
- int i;
-
- window = gdk_parent_root;
- xdisplay = GDK_WINDOW_XDISPLAY (window);
- root = GDK_WINDOW_XID (window);
- num = g_list_length (excludes);
-
- gdk_x11_grab_server ();
- if (!XQueryTree (xdisplay, root, &root_win, &parent_win, &list, &num))
- {
- gdk_x11_ungrab_server ();
- return root;
- }
- if (list)
- {
- i = num - 1;
- do
- {
- XWindowAttributes xwa;
-
- XGetWindowAttributes (xdisplay, list [i], &xwa);
-
- if (xwa.map_state != IsViewable)
- continue;
-
- if (excl_child && g_list_find (excludes, (gpointer *) list[i]))
- continue;
-
- if ((child = gdk_window_xid_at (list[i], 0, 0, x, y, excludes, excl_child)) == 0)
- continue;
-
- if (excludes)
- {
- if (!g_list_find (excludes, (gpointer *) child))
- {
- XFree (list);
- gdk_x11_ungrab_server ();
- return child;
- }
- }
- else
- {
- XFree (list);
- gdk_x11_ungrab_server ();
- return child;
- }
- } while (--i > 0);
- XFree (list);
- }
- gdk_x11_ungrab_server ();
- return root;
-}
-
static void
wmspec_moveresize (GdkWindow *window,
gint direction,
gint root_y,
guint32 timestamp)
{
+ GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
+
XEvent xev;
/* Release passive grab */
- gdk_pointer_ungrab (timestamp);
-
+ gdk_display_pointer_ungrab (display, timestamp);
+
xev.xclient.type = ClientMessage;
xev.xclient.serial = 0;
xev.xclient.send_event = True;
- xev.xclient.display = gdk_display;
xev.xclient.window = GDK_WINDOW_XID (window);
- xev.xclient.message_type = gdk_atom_intern ("_NET_WM_MOVERESIZE", FALSE);
+ xev.xclient.message_type =
+ gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_MOVERESIZE");
xev.xclient.format = 32;
xev.xclient.data.l[0] = root_x;
xev.xclient.data.l[1] = root_y;
xev.xclient.data.l[3] = 0;
xev.xclient.data.l[4] = 0;
- XSendEvent (gdk_display, gdk_root_window, False,
+ XSendEvent (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XROOTWIN (window), False,
SubstructureRedirectMask | SubstructureNotifyMask,
&xev);
}
+typedef struct _MoveResizeData MoveResizeData;
+
+struct _MoveResizeData
+{
+ GdkDisplay *display;
+
+ GdkWindow *moveresize_window;
+ GdkWindow *moveresize_emulation_window;
+ gboolean is_resize;
+ GdkWindowEdge resize_edge;
+ gint moveresize_button;
+ gint moveresize_x;
+ gint moveresize_y;
+ gint moveresize_orig_x;
+ gint moveresize_orig_y;
+ gint moveresize_orig_width;
+ gint moveresize_orig_height;
+ GdkWindowHints moveresize_geom_mask;
+ GdkGeometry moveresize_geometry;
+ Time moveresize_process_time;
+ XEvent *moveresize_pending_event;
+};
+
/* From the WM spec */
#define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0
#define _NET_WM_MOVERESIZE_SIZE_TOP 1
wmspec_moveresize (window, direction, root_x, root_y, timestamp);
}
-/* This is global for use in gdkevents-x11.c */
-GdkWindow *_gdk_moveresize_window;
+static MoveResizeData *
+get_move_resize_data (GdkDisplay *display,
+ gboolean create)
+{
+ MoveResizeData *mv_resize;
+ static GQuark move_resize_quark = 0;
+
+ if (!move_resize_quark)
+ move_resize_quark = g_quark_from_static_string ("gdk-window-moveresize");
+
+ mv_resize = g_object_get_qdata (G_OBJECT (display), move_resize_quark);
-static GdkWindow *moveresize_emulation_window = NULL;
-static gboolean is_resize = FALSE;
-static GdkWindowEdge resize_edge;
-static gint moveresize_button;
-static gint moveresize_x;
-static gint moveresize_y;
-static gint moveresize_orig_x;
-static gint moveresize_orig_y;
-static gint moveresize_orig_width;
-static gint moveresize_orig_height;
-static GdkWindowHints moveresize_geom_mask = 0;
-static GdkGeometry moveresize_geometry;
-static Time moveresize_process_time;
+ if (!mv_resize && create)
+ {
+ mv_resize = g_new0 (MoveResizeData, 1);
+ mv_resize->display = display;
+
+ g_object_set_qdata (G_OBJECT (display), move_resize_quark, mv_resize);
+ }
-static XEvent *moveresize_pending_event;
+ return mv_resize;
+}
static void
-update_pos (gint new_root_x,
- gint new_root_y)
+update_pos (MoveResizeData *mv_resize,
+ gint new_root_x,
+ gint new_root_y)
{
gint dx, dy;
-
- dx = new_root_x - moveresize_x;
- dy = new_root_y - moveresize_y;
- if (is_resize)
+ dx = new_root_x - mv_resize->moveresize_x;
+ dy = new_root_y - mv_resize->moveresize_y;
+
+ if (mv_resize->is_resize)
{
gint w, h;
- w = moveresize_orig_width;
- h = moveresize_orig_height;
-
- switch (resize_edge)
- {
- case GDK_WINDOW_EDGE_SOUTH_EAST:
- w += dx;
- h += dy;
- break;
- }
+ w = mv_resize->moveresize_orig_width;
+ h = mv_resize->moveresize_orig_height;
+
+ switch (mv_resize->resize_edge)
+ {
+ case GDK_WINDOW_EDGE_SOUTH_EAST:
+ w += dx;
+ h += dy;
+ break;
+ }
w = MAX (w, 1);
h = MAX (h, 1);
-
- if (moveresize_geom_mask)
- {
- gdk_window_constrain_size (&moveresize_geometry,
- moveresize_geom_mask,
- w, h,
- &w, &h);
- }
-
- gdk_window_resize (_gdk_moveresize_window, w, h);
+
+ if (mv_resize->moveresize_geom_mask)
+ {
+ gdk_window_constrain_size (&mv_resize->moveresize_geometry,
+ mv_resize->moveresize_geom_mask,
+ w, h, &w, &h);
+ }
+
+ gdk_window_resize (mv_resize->moveresize_window, w, h);
}
else
{
gint x, y;
- x = moveresize_orig_x + dx;
- y = moveresize_orig_y + dy;
-
- gdk_window_move (_gdk_moveresize_window, x, y);
+ x = mv_resize->moveresize_orig_x + dx;
+ y = mv_resize->moveresize_orig_y + dy;
+
+ gdk_window_move (mv_resize->moveresize_window, x, y);
}
}
static void
-finish_drag (void)
+finish_drag (MoveResizeData *mv_resize)
{
- gdk_window_destroy (moveresize_emulation_window);
- moveresize_emulation_window = NULL;
- _gdk_moveresize_window = NULL;
+ gdk_window_destroy (mv_resize->moveresize_emulation_window);
+ mv_resize->moveresize_emulation_window = NULL;
+ mv_resize->moveresize_window = NULL;
- if (moveresize_pending_event)
+ if (mv_resize->moveresize_pending_event)
{
- g_free (moveresize_pending_event);
- moveresize_pending_event = NULL;
+ g_free (mv_resize->moveresize_pending_event);
+ mv_resize->moveresize_pending_event = NULL;
}
}
static int
-lookahead_motion_predicate (Display *display,
+lookahead_motion_predicate (Display *xdisplay,
XEvent *event,
XPointer arg)
{
gboolean *seen_release = (gboolean *)arg;
-
+ GdkDisplay *display = gdk_x11_lookup_xdisplay (xdisplay);
+ MoveResizeData *mv_resize = get_move_resize_data (display, FALSE);
+
if (*seen_release)
return False;
*seen_release = TRUE;
break;
case MotionNotify:
- moveresize_process_time = event->xmotion.time;
+ mv_resize->moveresize_process_time = event->xmotion.time;
break;
default:
break;
}
static gboolean
-moveresize_lookahead (XEvent *event)
+moveresize_lookahead (MoveResizeData *mv_resize,
+ XEvent *event)
{
XEvent tmp_event;
gboolean seen_release = FALSE;
- if (moveresize_process_time)
+ if (mv_resize->moveresize_process_time)
{
- if (event->xmotion.time == moveresize_process_time)
+ if (event->xmotion.time == mv_resize->moveresize_process_time)
{
- moveresize_process_time = 0;
+ mv_resize->moveresize_process_time = 0;
return TRUE;
}
else
return FALSE;
}
- XCheckIfEvent (gdk_display, &tmp_event,
- lookahead_motion_predicate, (XPointer)&seen_release);
+ XCheckIfEvent (event->xany.display, &tmp_event,
+ lookahead_motion_predicate, (XPointer) & seen_release);
- return moveresize_process_time == 0;
+ return mv_resize->moveresize_process_time == 0;
}
-void
+gboolean
_gdk_moveresize_handle_event (XEvent *event)
{
guint button_mask = 0;
- GdkWindowObject *window_private = (GdkWindowObject *) _gdk_moveresize_window;
-
- button_mask = GDK_BUTTON1_MASK << (moveresize_button - 1);
-
+ GdkWindowObject *window_private;
+ GdkDisplay *display= gdk_x11_lookup_xdisplay (event->xany.display);
+ MoveResizeData *mv_resize = get_move_resize_data (display, FALSE);
+
+ if (!mv_resize || !mv_resize->moveresize_window)
+ return FALSE;
+
+ window_private = (GdkWindowObject *) mv_resize->moveresize_window;
+
+ button_mask = GDK_BUTTON1_MASK << (mv_resize->moveresize_button - 1);
+
switch (event->xany.type)
{
case MotionNotify:
if (window_private->resize_count > 0)
{
- if (moveresize_pending_event)
- *moveresize_pending_event = *event;
+ if (mv_resize->moveresize_pending_event)
+ *mv_resize->moveresize_pending_event = *event;
else
- moveresize_pending_event = g_memdup (event, sizeof (XEvent));
+ mv_resize->moveresize_pending_event =
+ g_memdup (event, sizeof (XEvent));
break;
}
- if (!moveresize_lookahead (event))
+ if (!moveresize_lookahead (mv_resize, event))
break;
-
- update_pos (event->xmotion.x_root,
- event->xmotion.y_root);
-
+
+ update_pos (mv_resize,
+ event->xmotion.x_root,
+ event->xmotion.y_root);
+
/* This should never be triggered in normal cases, but in the
* case where the drag started without an implicit grab being
* in effect, we could miss the release if it occurs before
* get a permanently stuck grab.
*/
if ((event->xmotion.state & button_mask) == 0)
- finish_drag ();
+ finish_drag (mv_resize);
break;
case ButtonRelease:
- update_pos (event->xbutton.x_root,
- event->xbutton.y_root);
-
- if (event->xbutton.button == moveresize_button)
- finish_drag ();
+ update_pos (mv_resize,
+ event->xbutton.x_root,
+ event->xbutton.y_root);
+
+ if (event->xbutton.button == mv_resize->moveresize_button)
+ finish_drag (mv_resize);
break;
}
+ return TRUE;
}
-void
-_gdk_moveresize_configure_done (void)
+gboolean
+_gdk_moveresize_configure_done (GdkDisplay *display,
+ GdkWindow *window)
{
XEvent *tmp_event;
+ MoveResizeData *mv_resize = get_move_resize_data (display, FALSE);
- if (moveresize_pending_event)
+ if (!mv_resize || window != mv_resize->moveresize_window)
+ return FALSE;
+
+ if (mv_resize->moveresize_pending_event)
{
- tmp_event = moveresize_pending_event;
- moveresize_pending_event = NULL;
+ tmp_event = mv_resize->moveresize_pending_event;
+ mv_resize->moveresize_pending_event = NULL;
_gdk_moveresize_handle_event (tmp_event);
g_free (tmp_event);
}
+
+ return TRUE;
}
static void
-create_moveresize_window (guint32 timestamp)
+create_moveresize_window (MoveResizeData *mv_resize,
+ guint32 timestamp)
{
GdkWindowAttr attributes;
gint attributes_mask;
GdkGrabStatus status;
- g_assert (moveresize_emulation_window == NULL);
-
+ g_assert (mv_resize->moveresize_emulation_window == NULL);
+
attributes.x = -100;
attributes.y = -100;
attributes.width = 10;
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_NOREDIR;
- moveresize_emulation_window =
- gdk_window_new (NULL, &attributes, attributes_mask);
+ mv_resize->moveresize_emulation_window =
+ gdk_window_new (gdk_screen_get_root_window (gdk_display_get_default_screen (mv_resize->display)),
+ &attributes,
+ attributes_mask);
- gdk_window_show (moveresize_emulation_window);
+ gdk_window_show (mv_resize->moveresize_emulation_window);
- status = gdk_pointer_grab (moveresize_emulation_window,
+ status = gdk_pointer_grab (mv_resize->moveresize_emulation_window,
FALSE,
GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK,
- FALSE,
+ NULL,
NULL,
timestamp);
/* If this fails, some other client has grabbed the window
* already.
*/
- gdk_window_destroy (moveresize_emulation_window);
- moveresize_emulation_window = NULL;
+ gdk_window_destroy (mv_resize->moveresize_emulation_window);
+ mv_resize->moveresize_emulation_window = NULL;
}
- moveresize_process_time = 0;
+ mv_resize->moveresize_process_time = 0;
}
static void
gint root_y,
guint32 timestamp)
{
- is_resize = TRUE;
- moveresize_button = button;
- resize_edge = edge;
- moveresize_x = root_x;
- moveresize_y = root_y;
- _gdk_moveresize_window = GDK_WINDOW (g_object_ref (G_OBJECT (window)));
+ MoveResizeData *mv_resize = get_move_resize_data (GDK_WINDOW_DISPLAY (window), TRUE);
- gdk_window_get_size (window, &moveresize_orig_width, &moveresize_orig_height);
-
- moveresize_geom_mask = 0;
+ mv_resize->is_resize = TRUE;
+ mv_resize->moveresize_button = button;
+ mv_resize->resize_edge = edge;
+ mv_resize->moveresize_x = root_x;
+ mv_resize->moveresize_y = root_y;
+ mv_resize->moveresize_window = g_object_ref (window);
+
+ gdk_drawable_get_size (window,
+ &mv_resize->moveresize_orig_width,
+ &mv_resize->moveresize_orig_height);
+
+ mv_resize->moveresize_geom_mask = 0;
gdk_window_get_geometry_hints (window,
- &moveresize_geometry,
- &moveresize_geom_mask);
-
- create_moveresize_window (timestamp);
+ &mv_resize->moveresize_geometry,
+ &mv_resize->moveresize_geom_mask);
+
+ create_moveresize_window (mv_resize, timestamp);
}
static void
gint root_y,
guint32 timestamp)
{
- is_resize = FALSE;
- moveresize_button = button;
- moveresize_x = root_x;
- moveresize_y = root_y;
- _gdk_moveresize_window = GDK_WINDOW (g_object_ref (G_OBJECT (window)));
-
- gdk_window_get_deskrelative_origin (_gdk_moveresize_window,
- &moveresize_orig_x,
- &moveresize_orig_y);
+ MoveResizeData *mv_resize = get_move_resize_data (GDK_WINDOW_DISPLAY (window), TRUE);
- create_moveresize_window (timestamp);
+ mv_resize->is_resize = FALSE;
+ mv_resize->moveresize_button = button;
+ mv_resize->moveresize_x = root_x;
+ mv_resize->moveresize_y = root_y;
+
+ mv_resize->moveresize_window = g_object_ref (window);
+
+ gdk_window_get_deskrelative_origin (mv_resize->moveresize_window,
+ &mv_resize->moveresize_orig_x,
+ &mv_resize->moveresize_orig_y);
+
+ create_moveresize_window (mv_resize, timestamp);
}
+/**
+ * gdk_window_begin_resize_drag:
+ * @window: a toplevel #GdkWindow
+ * @edge: the edge or corner from which the drag is started
+ * @button: the button being used to drag
+ * @root_x: root window X coordinate of mouse click that began the drag
+ * @root_y: root window Y coordinate of mouse click that began the drag
+ * @timestamp: timestamp of mouse click that began the drag (use gdk_event_get_time())
+ *
+ * Begins a window resize operation (for a toplevel window).
+ * You might use this function to implement a "window resize grip," for
+ * example; in fact #GtkStatusbar uses it. The function works best
+ * with window managers that support the Extended Window Manager Hints spec
+ * (see http://www.freedesktop.org), but has a fallback implementation
+ * for other window managers.
+ *
+ **/
void
gdk_window_begin_resize_drag (GdkWindow *window,
GdkWindowEdge edge,
guint32 timestamp)
{
g_return_if_fail (GDK_IS_WINDOW (window));
- g_return_if_fail (moveresize_emulation_window == NULL);
-
+
if (GDK_WINDOW_DESTROYED (window))
return;
- if (gdk_net_wm_supports (gdk_atom_intern ("_NET_WM_MOVERESIZE", FALSE)))
+ if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
+ gdk_atom_intern ("_NET_WM_MOVERESIZE", FALSE)))
wmspec_resize_drag (window, edge, button, root_x, root_y, timestamp);
else
emulate_resize_drag (window, edge, button, root_x, root_y, timestamp);
}
+/**
+ * gdk_window_begin_move_drag:
+ * @window: a toplevel #GdkWindow
+ * @button: the button being used to drag
+ * @root_x: root window X coordinate of mouse click that began the drag
+ * @root_y: root window Y coordinate of mouse click that began the drag
+ * @timestamp: timestamp of mouse click that began the drag
+ *
+ * Begins a window move operation (for a toplevel window). You might
+ * use this function to implement a "window move grip," for
+ * example. The function works best with window managers that support
+ * the Extended Window Manager Hints spec (see
+ * http://www.freedesktop.org), but has a fallback implementation for
+ * other window managers.
+ *
+ **/
void
gdk_window_begin_move_drag (GdkWindow *window,
gint button,
guint32 timestamp)
{
g_return_if_fail (GDK_IS_WINDOW (window));
- g_return_if_fail (moveresize_emulation_window == NULL);
-
+
if (GDK_WINDOW_DESTROYED (window))
return;
- if (gdk_net_wm_supports (gdk_atom_intern ("_NET_WM_MOVERESIZE", FALSE)))
- wmspec_moveresize (window, _NET_WM_MOVERESIZE_MOVE,
- root_x, root_y, timestamp);
+ if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
+ gdk_atom_intern ("_NET_WM_MOVERESIZE", FALSE)))
+ wmspec_moveresize (window, _NET_WM_MOVERESIZE_MOVE, root_x, root_y,
+ timestamp);
else
emulate_move_drag (window, button, root_x, root_y, timestamp);
}