#include "gdkpixmap.h"
#include "gdkdrawable.h"
#include "gdkpixmap.h"
+#include "gdkscreen.h"
#define USE_BACKING_STORE /* Appears to work on Win32, too, now. */
gint y_offset;
};
-static const GdkPointerHooks default_pointer_hooks = {
- _gdk_windowing_window_get_pointer,
- _gdk_windowing_window_at_pointer
-};
-
-static const GdkPointerHooks *current_pointer_hooks = &default_pointer_hooks;
-
static GdkGC *gdk_window_create_gc (GdkDrawable *drawable,
GdkGCValues *values,
GdkGCValuesMask mask);
static void gdk_window_draw_rectangle (GdkDrawable *drawable,
GdkGC *gc,
- gint filled,
+ gboolean filled,
gint x,
gint y,
gint width,
gint height);
static void gdk_window_draw_arc (GdkDrawable *drawable,
GdkGC *gc,
- gint filled,
+ gboolean filled,
gint x,
gint y,
gint width,
gint angle2);
static void gdk_window_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
- gint filled,
+ gboolean filled,
GdkPoint *points,
gint npoints);
static void gdk_window_draw_text (GdkDrawable *drawable,
gint width,
gint height);
-static GdkImage* gdk_window_get_image (GdkDrawable *drawable,
- gint x,
- gint y,
- gint width,
- gint height);
-
+static void gdk_window_draw_pixbuf (GdkDrawable *drawable,
+ GdkGC *gc,
+ GdkPixbuf *pixbuf,
+ gint src_x,
+ gint src_y,
+ gint dest_x,
+ gint dest_y,
+ gint width,
+ gint height,
+ GdkRgbDither dither,
+ gint x_dither,
+ gint y_dither);
+
+static GdkImage* gdk_window_copy_to_image (GdkDrawable *drawable,
+ GdkImage *image,
+ gint src_x,
+ gint src_y,
+ gint dest_x,
+ gint dest_y,
+ gint width,
+ gint height);
static void gdk_window_real_get_size (GdkDrawable *drawable,
gint *width,
static GdkVisual* gdk_window_real_get_visual (GdkDrawable *drawable);
static gint gdk_window_real_get_depth (GdkDrawable *drawable);
+static GdkScreen* gdk_window_real_get_screen (GdkDrawable *drawable);
static void gdk_window_real_set_colormap (GdkDrawable *drawable,
- GdkColormap *cmap);
+ GdkColormap *cmap);
static GdkColormap* gdk_window_real_get_colormap (GdkDrawable *drawable);
static GdkDrawable* gdk_window_get_composite_drawable (GdkDrawable *drawable,
drawable_class->draw_lines = gdk_window_draw_lines;
drawable_class->draw_glyphs = gdk_window_draw_glyphs;
drawable_class->draw_image = gdk_window_draw_image;
+ drawable_class->draw_pixbuf = gdk_window_draw_pixbuf;
drawable_class->get_depth = gdk_window_real_get_depth;
+ drawable_class->get_screen = gdk_window_real_get_screen;
drawable_class->get_size = gdk_window_real_get_size;
drawable_class->set_colormap = gdk_window_real_set_colormap;
drawable_class->get_colormap = gdk_window_real_get_colormap;
drawable_class->get_visual = gdk_window_real_get_visual;
- drawable_class->get_image = gdk_window_get_image;
+ drawable_class->_copy_to_image = gdk_window_copy_to_image;
drawable_class->get_clip_region = gdk_window_get_clip_region;
drawable_class->get_visible_region = gdk_window_get_visible_region;
drawable_class->get_composite_drawable = gdk_window_get_composite_drawable;
_gdk_window_destroy (window, TRUE);
}
- g_object_unref (G_OBJECT (obj->impl));
+ g_object_unref (obj->impl);
obj->impl = NULL;
G_OBJECT_CLASS (parent_class)->finalize (object);
* _gdk_window_destroy_hierarchy:
* @window: a #GdkWindow
* @recursing: If TRUE, then this is being called because a parent
- * was destroyed. This generally means that the call to the windowing system
- * to destroy the window can be omitted, since it will be destroyed as a result
- * of the parent being destroyed. Unless @foreign_destroy
- *
- * foreign_destroy: If TRUE, the window or a parent was destroyed by some external
- * agency. The window has already been destroyed and no windowing
- * system calls should be made. (This may never happen for some
- * windowing systems.)
+ * was destroyed. This generally means that the call to the
+ * windowing system to destroy the window can be omitted, since
+ * it will be destroyed as a result of the parent being destroyed.
+ * Unless @foreign_destroy.
+ * @foreign_destroy: If TRUE, the window or a parent was destroyed by some
+ * external agency. The window has already been destroyed and no
+ * windowing system calls should be made. (This may never happen
+ * for some windowing systems.)
*
- * Internal function to destroy a window. Like gdk_window_destroy(), but does not
- * drop the reference count created by gdk_window_new().
+ * Internal function to destroy a window. Like gdk_window_destroy(),
+ * but does not drop the reference count created by gdk_window_new().
**/
static void
_gdk_window_destroy_hierarchy (GdkWindow *window,
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);
private->bg_pixmap = NULL;
}
temp_private = (GdkWindowObject*) temp_window;
if (temp_private)
- _gdk_window_destroy_hierarchy (temp_window, TRUE, foreign_destroy);
+ _gdk_window_destroy_hierarchy (temp_window,
+ TRUE, foreign_destroy);
}
g_list_free (children);
/**
* _gdk_window_destroy:
* @window: a #GdkWindow
- * foreign_destroy: If TRUE, the window or a parent was destroyed by some external
- * agency. The window has already been destroyed and no windowing
- * system calls should be made. (This may never happen for some
- * windowing systems.)
+ * @foreign_destroy: If TRUE, the window or a parent was destroyed by some
+ * external agency. The window has already been destroyed and no
+ * windowing system calls should be made. (This may never happen
+ * for some windowing systems.)
*
- * Internal function to destroy a window. Like gdk_window_destroy(), but does not
- * drop the reference count created by gdk_window_new().
+ * Internal function to destroy a window. Like gdk_window_destroy(),
+ * but does not drop the reference count created by gdk_window_new().
**/
void
_gdk_window_destroy (GdkWindow *window,
* gdk_window_destroy:
* @window: a #GdkWindow
*
- * Destroys @window (destroys the server-side resource associated with @window).
- * Memory allocated for @window may not be freed until all references
- * to @window are dropped. All children of @window are also destroyed.
+ * Destroys the window system resources associated with @window and decrements @window's
+ * reference count. The window system resources for all children of @window are also
+ * destroyed, but the children's reference counts are not decremented.
+ *
+ * Note that a window will not be destroyed automatically when its reference count
+ * reaches zero. You must call this function yourself before that happens.
*
- * There's normally no need to use this function, window are automatically
- * destroyed when their reference count reaches 0.
- *
**/
void
gdk_window_destroy (GdkWindow *window)
{
_gdk_window_destroy_hierarchy (window, FALSE, FALSE);
- gdk_drawable_unref (window);
+ g_object_unref (window);
}
/**
* @x: X coordinate of window
* @y: Y coordinate of window
*
- * Obtains the position of the window as reported in the most-recently-processed
- * #GdkEventConfigure. Contrast with gdk_window_get_geometry() which
- * queries the X server for the current window position, regardless of which
- * events have been received or processed.
+ * Obtains the position of the window as reported in the
+ * most-recently-processed #GdkEventConfigure. Contrast with
+ * gdk_window_get_geometry() which queries the X server for the
+ * current window position, regardless of which events have been
+ * received or processed.
*
* The position coordinates are relative to the window's parent window.
*
* @data: data to pass to filter callback
*
* Adds an event filter to @window, allowing you to intercept events
- * before they reach GDK. This is a low-level operation and makes it easy to break
- * GDK and/or GTK+, so you have to know what you're doing.
+ * before they reach GDK. This is a low-level operation and makes it
+ * easy to break GDK and/or GTK+, so you have to know what you're
+ * doing. Pass %NULL for @window to get all events for all windows,
+ * instead of events for a specific window.
*
**/
void
}
/**
- * gdk_window_get_toplevels:
+ * gdk_screen_get_toplevel_windows:
+ * @screen: The #GdkScreen where the toplevels are located.
*
- * Obtains a list of all toplevel windows known to GDK.
+ * Obtains a list of all toplevel windows known to GDK on the screen @screen.
* A toplevel window is a child of the root window (see
* gdk_get_default_root_window()).
*
* its elements need not be freed.
*
* Return value: list of toplevel windows, free with g_list_free()
+ *
+ * Since: 2.2
**/
GList *
-gdk_window_get_toplevels (void)
+gdk_screen_get_toplevel_windows (GdkScreen *screen)
{
+ GdkWindow * root_window;
GList *new_list = NULL;
GList *tmp_list;
- tmp_list = ((GdkWindowObject *)_gdk_parent_root)->children;
+ g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
+
+ root_window = gdk_screen_get_root_window (screen);
+
+ tmp_list = ((GdkWindowObject *)root_window)->children;
while (tmp_list)
{
if (GDK_WINDOW_TYPE (tmp_list->data) != GDK_WINDOW_FOREIGN)
return new_list;
}
+/**
+ * gdk_window_get_toplevels:
+ *
+ * Obtains a list of all toplevel windows known to GDK on the default
+ * screen (see gdk_window_get_toplevels_for_screen()).
+ * A toplevel window is a child of the root window (see
+ * gdk_get_default_root_window()).
+ *
+ * The returned list should be freed with g_list_free(), but
+ * its elements need not be freed.
+ *
+ * Return value: list of toplevel windows, free with g_list_free()
+ **/
+GList *
+gdk_window_get_toplevels (void)
+{
+ return gdk_screen_get_toplevel_windows (gdk_screen_get_default ());
+}
+
/**
* gdk_window_is_visible:
* @window: a #GdkWindow
* Check if the window and all ancestors of the window are
* mapped. (This is not necessarily "viewable" in the X sense, since
* we only check as far as we have GDK window parents, not to the root
- * window)
- *
- *
- *
+ * window.)
+ *
* Return value: %TRUE if the window is viewable
**/
gboolean
gdk_window_is_viewable (GdkWindow *window)
{
GdkWindowObject *private = (GdkWindowObject *)window;
+ GdkScreen *screen = gdk_drawable_get_screen (window);
+ GdkWindow *root_window = gdk_screen_get_root_window (screen);
g_return_val_if_fail (window != NULL, FALSE);
g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
while (private &&
- (private != (GdkWindowObject *)_gdk_parent_root) &&
+ (private != (GdkWindowObject *)root_window) &&
(GDK_WINDOW_TYPE (private) != GDK_WINDOW_FOREIGN))
{
if (!GDK_WINDOW_IS_MAPPED (window))
return gdk_window_get_bg_gc (GDK_WINDOW (private->parent), &tmp_paint);
}
- else if (private->bg_pixmap && private->bg_pixmap != GDK_PARENT_RELATIVE_BG && private->bg_pixmap != GDK_NO_BG)
+ else if (private->bg_pixmap &&
+ private->bg_pixmap != GDK_PARENT_RELATIVE_BG &&
+ private->bg_pixmap != GDK_NO_BG)
{
gc_values.fill = GDK_TILED;
gc_values.tile = private->bg_pixmap;
gc_values.ts_x_origin = - paint->x_offset;
gc_values.ts_y_origin = - paint->y_offset;
- gc_mask = GDK_GC_FILL | GDK_GC_TILE | GDK_GC_TS_X_ORIGIN | GDK_GC_TS_Y_ORIGIN;
+ gc_mask = (GDK_GC_FILL | GDK_GC_TILE |
+ GDK_GC_TS_X_ORIGIN | GDK_GC_TS_Y_ORIGIN);
}
else
{
gdk_gc_set_clip_region (tmp_gc, init_region);
gdk_draw_rectangle (paint->pixmap, tmp_gc, TRUE, 0, 0, -1, -1);
- gdk_gc_unref (tmp_gc);
+ g_object_unref (tmp_gc);
}
#ifdef GDK_WINDOWING_X11
0, 0,
old_rect.x - new_rect.x, old_rect.y - new_rect.y,
old_rect.width, old_rect.height);
- gdk_gc_unref (tmp_gc);
- gdk_drawable_unref (tmp_paint->pixmap);
+ g_object_unref (tmp_gc);
+ g_object_unref (tmp_paint->pixmap);
paint->x_offset = new_rect.x;
paint->y_offset = new_rect.y;
{
paint->x_offset = clip_box.x;
paint->y_offset = clip_box.y;
- paint->pixmap = gdk_pixmap_new (window, clip_box.width, clip_box.height, -1);
+ paint->pixmap = gdk_pixmap_new (window,
+ clip_box.width, clip_box.height, -1);
}
if (!gdk_region_empty (init_region))
}
paint = private->paint_stack->data;
- private->paint_stack = g_slist_delete_link (private->paint_stack, private->paint_stack);
+ private->paint_stack = g_slist_delete_link (private->paint_stack,
+ private->paint_stack);
gdk_region_get_clipbox (paint->region, &clip_box);
clip_box.y - paint->y_offset,
clip_box.x - x_offset, clip_box.y - y_offset,
clip_box.width, clip_box.height);
- gdk_gc_unref (tmp_gc);
+ g_object_unref (tmp_gc);
if (private->paint_stack)
{
}
}
else
- gdk_drawable_unref (paint->pixmap);
+ g_object_unref (paint->pixmap);
gdk_region_destroy (paint->region);
g_free (paint);
GdkWindowPaint *paint = tmp_list->data;
if (tmp_list == private->paint_stack)
- gdk_drawable_unref (paint->pixmap);
+ g_object_unref (paint->pixmap);
gdk_region_destroy (paint->region);
g_free (paint);
/**
* gdk_window_get_internal_paint_info:
* @window: a #GdkWindow
- * @real_drawable: location to store the drawable to which drawing should be done.
- * @x_offset: location to store the X offset between coordinates in @window, and
- * the underlying window system primitive coordinates for *@real_drawable.
- * @y_offset: location to store the Y offset between coordinates in @window, and
- * the underlying window system primitive coordinates for *@real_drawable.
+ * @real_drawable: location to store the drawable to which drawing should be
+ * done.
+ * @x_offset: location to store the X offset between coordinates in @window,
+ * and the underlying window system primitive coordinates for
+ * *@real_drawable.
+ * @y_offset: location to store the Y offset between coordinates in @window,
+ * and the underlying window system primitive coordinates for
+ * *@real_drawable.
*
* If you bypass the GDK layer and use windowing system primitives to
* draw directly onto a #GdkWindow, then you need to deal with two
static void
gdk_window_draw_rectangle (GdkDrawable *drawable,
GdkGC *gc,
- gint filled,
+ gboolean filled,
gint x,
gint y,
gint width,
static void
gdk_window_draw_arc (GdkDrawable *drawable,
GdkGC *gc,
- gint filled,
+ gboolean filled,
gint x,
gint y,
gint width,
static void
gdk_window_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
- gint filled,
+ gboolean filled,
GdkPoint *points,
gint npoints)
{
composite_x_offset,
composite_y_offset);
- return GDK_DRAWABLE (g_object_ref (G_OBJECT (window)));
+ return g_object_ref (window);
}
buffered_region = NULL;
composite_x_offset,
composite_y_offset);
- return GDK_DRAWABLE (g_object_ref (G_OBJECT (window)));
+ return g_object_ref (window);
}
tmp_pixmap = gdk_pixmap_new (window,
*composite_x_offset = x;
*composite_y_offset = y;
- g_object_unref (G_OBJECT (tmp_gc));
+ g_object_unref (tmp_gc);
return tmp_pixmap;
}
tmp_gc = gdk_window_get_bg_gc (window, paint);
gdk_draw_rectangle (paint->pixmap, tmp_gc, TRUE,
x - paint->x_offset, y - paint->y_offset, width, height);
- gdk_gc_unref (tmp_gc);
+ g_object_unref (tmp_gc);
}
/**
RESTORE_GC (gc);
}
+static void
+gdk_window_draw_pixbuf (GdkDrawable *drawable,
+ GdkGC *gc,
+ GdkPixbuf *pixbuf,
+ gint src_x,
+ gint src_y,
+ gint dest_x,
+ gint dest_y,
+ gint width,
+ gint height,
+ GdkRgbDither dither,
+ gint x_dither,
+ gint y_dither)
+{
+ GdkWindowObject *private = (GdkWindowObject *)drawable;
+
+ if (GDK_WINDOW_DESTROYED (drawable))
+ return;
+
+ if (gc)
+ {
+ OFFSET_GC (gc);
+
+ if (private->paint_stack)
+ {
+ GdkWindowPaint *paint = private->paint_stack->data;
+ gdk_draw_pixbuf (paint->pixmap, gc, pixbuf, src_x, src_y,
+ dest_x - x_offset, dest_y - y_offset,
+ width, height,
+ dither, x_dither - x_offset, y_dither - y_offset);
+ }
+ else
+ gdk_draw_pixbuf (private->impl, gc, pixbuf, src_x, src_y,
+ dest_x - x_offset, dest_y - y_offset,
+ width, height,
+ dither, x_dither, y_dither);
+
+ RESTORE_GC (gc);
+ }
+ else
+ {
+ gint x_offset, y_offset;
+ gdk_window_get_offsets (drawable, &x_offset, &y_offset);
+
+ if (private->paint_stack)
+ {
+ GdkWindowPaint *paint = private->paint_stack->data;
+ gdk_draw_pixbuf (paint->pixmap, gc, pixbuf, src_x, src_y,
+ dest_x - x_offset, dest_y - y_offset,
+ width, height,
+ dither, x_dither - x_offset, y_dither - y_offset);
+ }
+ else
+ gdk_draw_pixbuf (private->impl, gc, pixbuf, src_x, src_y,
+ dest_x - x_offset, dest_y - y_offset,
+ width, height,
+ dither, x_dither, y_dither);
+ }
+}
static void
gdk_window_real_get_size (GdkDrawable *drawable,
static gint
gdk_window_real_get_depth (GdkDrawable *drawable)
{
- gint depth;
-
g_return_val_if_fail (GDK_IS_WINDOW (drawable), 0);
- depth = ((GdkWindowObject *)GDK_WINDOW (drawable))->depth;
-
- if (depth == 0)
- {
- g_print ("0 depth for type %s\n", g_type_name (G_OBJECT_TYPE (drawable)));
- G_BREAKPOINT ();
- }
+ return ((GdkWindowObject *)GDK_WINDOW (drawable))->depth;
+}
- return depth;
+static GdkScreen*
+gdk_window_real_get_screen (GdkDrawable *drawable)
+{
+ return gdk_drawable_get_screen (GDK_WINDOW_OBJECT (drawable)->impl);
}
static void
}
static GdkImage*
-gdk_window_get_image (GdkDrawable *drawable,
- gint x,
- gint y,
- gint width,
- gint height)
+gdk_window_copy_to_image (GdkDrawable *drawable,
+ GdkImage *image,
+ gint src_x,
+ gint src_y,
+ gint dest_x,
+ gint dest_y,
+ gint width,
+ gint height)
{
gint x_offset, y_offset;
_gdk_windowing_window_get_offsets (drawable, &x_offset, &y_offset);
- return gdk_drawable_get_image (((GdkWindowObject*)drawable)->impl,
- x - x_offset,
- y - y_offset,
- width, height);
+ return _gdk_drawable_copy_to_image (((GdkWindowObject*)drawable)->impl,
+ image,
+ src_x - x_offset,
+ src_y - y_offset,
+ dest_x, dest_y,
+ width, height);
}
/* Code for dirty-region queueing
GdkRegion *update_area = private->update_area;
private->update_area = NULL;
- if (_gdk_event_func && gdk_window_is_viewable (window))
+ if (_gdk_event_func && gdk_window_is_viewable (window) &&
+ (private->event_mask & GDK_EXPOSURE_MASK))
{
GdkEvent event;
GdkRectangle window_rect;
if (debug_updates)
{
/* Make sure we see the red invalid area before redrawing. */
- gdk_flush ();
+ gdk_display_sync (gdk_drawable_get_display (window));
g_usleep (70000);
}
save_region = _gdk_windowing_window_queue_antiexpose (window, update_area);
event.expose.type = GDK_EXPOSE;
- event.expose.window = gdk_window_ref (window);
+ event.expose.window = g_object_ref (window);
event.expose.count = 0;
if (save_region)
if (expose_region != update_area)
gdk_region_destroy (expose_region);
- gdk_window_unref (window);
+ g_object_unref (window);
}
if (!save_region)
gdk_region_destroy (update_area);
update_windows = NULL;
update_idle = 0;
+ g_slist_foreach (old_update_windows, (GFunc)g_object_ref, NULL);
+
while (tmp_list)
{
gdk_window_process_updates_internal (tmp_list->data);
+ g_object_unref (tmp_list->data);
tmp_list = tmp_list->next;
}
static gboolean
gdk_window_update_idle (gpointer data)
{
+ GDK_THREADS_ENTER ();
gdk_window_process_all_updates ();
+ GDK_THREADS_LEAVE ();
return FALSE;
}
gdk_region_destroy (region);
}
+static void
+draw_ugly_color (GdkWindow *window,
+ GdkRegion *region)
+{
+ /* Draw ugly color all over the newly-invalid region */
+ GdkColor ugly_color = { 0, 50000, 10000, 10000 };
+ GdkGC *ugly_gc;
+ GdkRectangle clipbox;
+
+ ugly_gc = gdk_gc_new (window);
+ gdk_gc_set_rgb_fg_color (ugly_gc, &ugly_color);
+ gdk_gc_set_clip_region (ugly_gc, region);
+
+ gdk_region_get_clipbox (region, &clipbox);
+
+ gdk_draw_rectangle (window,
+ ugly_gc,
+ TRUE,
+ clipbox.x, clipbox.y,
+ clipbox.width, clipbox.height);
+
+ g_object_unref (ugly_gc);
+}
+
/**
* gdk_window_invalidate_maybe_recurse:
* @window: a #GdkWindow
* @region: a #GdkRegion
* @child_func: function to use to decide if to recurse to a child,
* %NULL means never recurse.
- * @child_func_data: data passed to @child_func
+ * @user_data: data passed to @child_func
*
* Adds @region to the update area for @window. The update area is the
* region that needs to be redrawn, or "dirty region." The call
*
* The @child_func parameter controls whether the region of
* each child window that intersects @region will also be invalidated.
- * Only children for whic @child_func returns TRUE will have the area
+ * Only children for which @child_func returns TRUE will have the area
* invalidated.
**/
void
if (!gdk_region_empty (visible_region))
{
if (debug_updates)
- {
- /* Draw ugly color all over the newly-invalid region */
- GdkRectangle ugly_rect;
- GdkGC *ugly_gc;
- GdkColor ugly_color = { 0, 60000, 10000, 10000 };
-
- ugly_gc = gdk_gc_new (window);
-
- gdk_gc_set_rgb_fg_color (ugly_gc, &ugly_color);
-
- gdk_region_get_clipbox (visible_region, &ugly_rect);
-
- gdk_draw_rectangle (window,
- ugly_gc,
- TRUE,
- ugly_rect.x, ugly_rect.y,
- ugly_rect.width, ugly_rect.height);
-
- g_object_unref (G_OBJECT (ugly_gc));
- }
+ draw_ugly_color (window, region);
if (private->update_area)
{
*new_height = height;
}
-/**
- * gdk_set_pointer_hooks:
- * @new_hooks: a table of pointer to functions for getting
- * quantities related to the current pointer position,
- * or %NULL to restore the default table.
- *
- * This function allows for hooking into the operation
- * of getting the current location of the pointer. This
- * is only useful for such low-level tools as an
- * event recorder. Applications should never have any
- * reason to use this facility
- *
- * Return value: the previous pointer hook table
- **/
-GdkPointerHooks *
-gdk_set_pointer_hooks (const GdkPointerHooks *new_hooks)
-{
- const GdkPointerHooks *result = current_pointer_hooks;
-
- if (new_hooks)
- current_pointer_hooks = new_hooks;
- else
- current_pointer_hooks = &default_pointer_hooks;
-
- return (GdkPointerHooks *)result;
-}
-
/**
* gdk_window_get_pointer:
* @window: a #GdkWindow
* Obtains the current pointer position and modifier state.
* The position is given in coordinates relative to @window.
*
- * Return value: the window containing the pointer (as with gdk_window_at_pointer()), or %NULL
- * if the window containing the pointer isn't known to GDK
+ * Return value: the window containing the pointer (as with
+ * gdk_window_at_pointer()), or %NULL if the window containing the
+ * pointer isn't known to GDK
**/
GdkWindow*
gdk_window_get_pointer (GdkWindow *window,
gint *x,
gint *y,
- GdkModifierType *mask)
+ GdkModifierType *mask)
{
- g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
+ GdkDisplay *display;
+ gint tmp_x, tmp_y;
+ GdkModifierType tmp_mask;
+ GdkWindow *child;
- return current_pointer_hooks->get_pointer (window, x, y, mask);
+ g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
+
+ if (window)
+ {
+ display = gdk_drawable_get_display (window);
+ }
+ else
+ {
+ GdkScreen *screen = gdk_screen_get_default ();
+
+ display = gdk_screen_get_display (screen);
+ window = gdk_screen_get_root_window (screen);
+
+ GDK_NOTE (MULTIHEAD,
+ g_message ("Passing NULL for window to gdk_window_get_pointer()\n"
+ "is not multihead safe"));
+ }
+
+ child = display->pointer_hooks->window_get_pointer (display, window, &tmp_x, &tmp_y, &tmp_mask);
+
+ if (x)
+ *x = tmp_x;
+ if (y)
+ *y = tmp_y;
+ if (mask)
+ *mask = tmp_mask;
+
+ return child;
}
/**
* @win_x: return location for origin of the window under the pointer
* @win_y: return location for origin of the window under the pointer
*
- * Obtains the window underneath the mouse pointer, returning the location
- * of that window in @win_x, @win_y. Returns %NULL if the window under
- * the mouse pointer is not known to GDK (for example, belongs to
- * another application).
+ * Obtains the window underneath the mouse pointer, returning the
+ * location of that window in @win_x, @win_y. Returns %NULL if the
+ * window under the mouse pointer is not known to GDK (if the window
+ * belongs to another application and a #GdkWindow hasn't been created
+ * for it with gdk_window_foreign_new())
+ *
+ * NOTE: For multihead-aware widgets or applications use
+ * gdk_display_get_window_at_pointer() instead.
*
* Return value: window under the mouse pointer
**/
gdk_window_at_pointer (gint *win_x,
gint *win_y)
{
- return current_pointer_hooks->window_at_pointer (NULL, win_x, win_y);
+ return gdk_display_get_window_at_pointer (gdk_display_get_default (), win_x, win_y);
}
/**
GdkWindow *
gdk_get_default_root_window (void)
{
- return _gdk_parent_root;
+ return gdk_screen_get_root_window (gdk_screen_get_default ());
+}
+
+/**
+ * gdk_window_foreign_new:
+ * @anid: a native window handle.
+ *
+ * Wraps a native window for the default display 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)
+{
+ return gdk_window_foreign_new_for_display (gdk_display_get_default (), anid);
}