gtk2/gdk/x11/gdkgeometry-x11.c
Havoc Pennington df4fc36721 Make this compile without framebuffer enabled
2000-06-20  Havoc Pennington  <hp@redhat.com>

* modules/linux-fb/Makefile.am: Make this compile
without framebuffer enabled

* gdk/linux-fb/Makefile.am: Add conditional to not build
framebuffer unless specified in configure

* gdk/gdkdraw.c (gdk_draw_drawable): Fix bug where I was getting
the size of the target instead of source if -1 was passed for
width/height

* gdk/x11/gdkgeometry-x11.c (gdk_window_compute_position): Fix
width/height confusion.

2000-06-19  Havoc Pennington  <hp@redhat.com>

* gdk/x11/gdkx.h (GDK_WINDOW_XWINDOW): change this to be
GDK_DRAWABLE_XID. In the future, we probably want to make it
faster with G_DISABLE_CHECKS turned on.

2000-06-14  Havoc Pennington  <hp@redhat.com>

        * gdk/Makefile.am: add gdkpixmap.c

	* gdk/gdk.c: s/gdk_window_init/_gdk_windowing_window_init/
	s/gdk_image_init/_gdk_windowing_image_init

	* gdk/gdkcolor.c: make ref/unref compat wrappers for GObject
	ref/unref

	* gdk/gdkcolor.h: make GdkColormap a GObject subclass

	* gdk/gdkcompat.h: remove GdkWindowType compat, since
	GdkWindowType is now non-deprecated;
	change gdk_window_get_type() compat to be
	gdk_window_get_window_type().

	* gdk/gdkdnd.h: make GdkDragContext a GObject.

	* gdk/gdkdraw.c, gdk/gdkdraw.h: Convert GdkDrawable to a pure
	virtual GObject. Make all functions call into the vtable.
	Move gdk_image_put() guts in here. Remove GdkDrawableType
	and gdk_drawable_get_type(), these are now GdkWindow-specific.
	draw_image, get_depth, get_size, set_colormap, get_colormap,
	get_visual added to the vtable.

	* gdk/gdkgc.h, gdk/gdkgc.c: Convert GdkGC to a pure virtual
	GObject. Virtualize everything.
	(gdk_gc_new_with_values): remove check for destroyed window,
	because now GdkWindow::create_gc will check this.
	(gdk_gc_set_values): New function to set GC values, this
	was already implemented but wasn't in the header

	* gdk/gdkimage.h, gdk/gdkimage.c: Convert GdkImage to a GObject.

	* gdk/gdkinternals.h: Remove _gdk_window_alloc(), remove
	_gdk_window_draw_image(), remove _gdk_windowing_window_class,
	remove _gdk_window_class; add _gdk_window_impl_get_type() and
	_gdk_pixmap_impl_get_type(). Rename gdk_window_init to
	_gdk_windowing_window_init, rename gdk_image_init to
	_gdk_windowing_image_init.

	* gdk/gdkpango.c: Reflect GObject-ification of PangoContext.
	(gdk_draw_layout): Remove check for destroyed window,
	because all the drawable methods already check it.

	* gdk/gdkpixmap.h, gdk/gdkpixmap.c: Convert GdkPixmap to GObject.
	Add gdkpixmap.c which contains implementation of GdkDrawable
	virtual table (by chaining to a platform-specific implementation
	object).

	* gdk/gdkprivate.h: Remove GDK_IS_WINDOW, GDK_IS_PIXMAP,
	GDK_DRAWABLE_DESTROYED. Add GDK_WINDOW_DESTROYED. Replace
	GDK_DRAWABLE_TYPE with GDK_WINDOW_TYPE. Remove GdkDrawablePrivate,
	GdkWindowPrivate, GdkImageClass, GdkImagePrivate, GdkGCPrivate,
	GdkColormapPrivate.

	* gdk/gdktypes.h: #include <glib-object.h>

	* gdk/gdkwindow.h, gdk/gdkwindow.c: Convert GdkWindow to GObject.
	Move most functionality to platform-specific implementation
	object. GdkWindow itself now handles the backing store, then
	chains to the platform-specific implementation.
	(gdk_window_get_window_type): return GdkWindowType of the window.
	(gdk_window_peek_children): New routine, returns the children of
	a GdkWindow
	(gdk_window_get_children): Was in X11-specific code and did
	XQueryTree. Changed to simply return a copy of window->children;
	so it can go in cross-platform code.

	* gdk/x11/Makefile.am: fix broken MKINSTALLDIRS path

	* gdk/x11/gdkcolor-x11.c: implement X-specific parts of
	GdkColormap; just changed to use the new private data instead
	of casting to GdkColormapPrivate.

	* gdk/x11/gdkcursor-x11.c: added a couple typechecks to
	gdk_cursor_new().

	* gdk/x11/gdkdnd-x11.c: Change the way we access private fields
	(private data member in the GObject).
	(xdnd_manager_source_filter): Function had broken
	error handling, fix it (use gdk_error_trap_push).

	* gdk/x11/gdkdrawable-x11.c: This file now implements
	a base class for GdkWindowImplX11/GdkPixmapImplX11. This
	base class is purely for the convenience of the X port,
	and not part of the interface to cross-platform GDK.

	* gdk/x11/gdkevents-x11.c: Reflect various renamings.

	* gdk/x11/gdkgc-x11.c: Implement a subclass of GdkGC that's
	specific to X, and returned by the create_gc virtual method
	of GdkDrawableImplX11.
	(gdk_x11_gc_set_dashes): Change this to take an array of gint8
	rather than gchar, this was also changed in the GdkGC vtable.
	(gdk_x11_gc_values_to_xvalues): If GdkGCValues is NULL, or the
	mask is 0, return immediately, instead of checking every flag.
	This is faster, and keeps us from segfaulting if values is NULL
	and the mask contains some nonzero flags.

	* gdk/x11/gdkgeometry-x11.c: deal with all the rearranging of
	GdkWindow.

	* gdk/x11/gdkglobals-x11.c: change type of grab window, since
	GdkWindowPrivate is gone.

	* gdk/x11/gdkim-x11.c: rename things that got renamed.

	* gdk/x11/gdkimage-x11.c: implement in terms of GObject, and
	remove the image_put stuff that got transferred to GdkDrawable.

	* gdk/x11/gdkinput.c: renamings

	* gdk/x11/gdkmain-x11.c: #include <pango/pangox.h>

	* gdk/x11/gdkpixmap-x11.c: GObject conversion

	* gdk/x11/gdkprivate-x11.h: indentation fixes

	* gdk/x11/gdkproperty-x11.c: renamings

	* gdk/x11/gdkselection-x11.c: renamings

	* gdk/x11/gdkwindow-x11.c: Restructuring and renaming; this now
	implements the platform-specific "impl" object.
	Moved gdk_window_get_children to gdk/gdkwindow.c

	* gdk/x11/gdkx.h: Remove all the private structs and private datas
	that no longer exist. Add declaration of GdkGCX11 object here.
	Fix all the macros to still work.

	* gtk/gtk-boxed.defs: Remove GtkStyle, GdkColormap, GdkWindow,
	GdkDragContext from the boxed types since they are now GObjects.

	* gtk/gtkstyle.h, gtk/gtkstyle.c: Converted GtkStyle to a GObject,
	moved xthickness/ythickness into the instance. GtkStyleClass
	functions are now in the standard vtable for GtkStyle, so you have
	to create a GObject subclass to write a theme engine.
	(gtk_style_copy): fixed a leaked PangoFontDescription
	(gtk_style_init): renamed gtk_style_realize, so gtk_style_init
	can be the standard GObject function.

	* Throughout GTK:
	s/style->klass->[xy]thickness/style->[xy]thickness
	s/pango_layout_unref/g_object_unref/

	* gtk/gtkrc.h, gtk/gtkrc.c: Converted GtkRcStyle to a GObject.

	* gtk/gtksocket.c: Use gdk_window_get_user_data() instead of
	accessing GDK internals.

	* gtk/gtkwidget.c: Use gdk_window_peek_children() instead of
	accessing GDK internals.
2000-06-20 21:04:44 +00:00

835 lines
23 KiB
C

/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/* gdkgeometry-x11.c: emulation of 32 bit coordinates within the
* limits of X.
*
* By Owen Taylor <otaylor@redhat.com>
* Copyright Red Hat, Inc. 2000
*/
#include "gdk.h" /* For gdk_rectangle_intersect */
#include "gdkprivate-x11.h"
#include "gdkx.h"
#include "gdkregion.h"
typedef struct _GdkWindowQueueItem GdkWindowQueueItem;
typedef struct _GdkWindowParentPos GdkWindowParentPos;
typedef enum {
GDK_WINDOW_QUEUE_TRANSLATE,
GDK_WINDOW_QUEUE_ANTIEXPOSE
} GdkWindowQueueType;
struct _GdkWindowQueueItem
{
GdkWindow *window;
gulong serial;
GdkWindowQueueType type;
union {
struct {
gint dx;
gint dy;
} translate;
struct {
GdkRegion *area;
} antiexpose;
} u;
};
struct _GdkWindowParentPos
{
gint x;
gint y;
gint x11_x;
gint x11_y;
GdkRectangle clip_rect;
};
static void gdk_window_compute_position (GdkWindowImplX11 *window,
GdkWindowParentPos *parent_pos,
GdkXPositionInfo *info);
static void gdk_window_compute_parent_pos (GdkWindowImplX11 *window,
GdkWindowParentPos *parent_pos);
static void gdk_window_premove (GdkWindow *window,
GdkWindowParentPos *parent_pos);
static void gdk_window_postmove (GdkWindow *window,
GdkWindowParentPos *parent_pos);
static void gdk_window_queue_translation (GdkWindow *window,
gint dx,
gint dy);
static void gdk_window_tmp_unset_bg (GdkWindow *window);
static void gdk_window_tmp_reset_bg (GdkWindow *window);
static void gdk_window_clip_changed (GdkWindow *window,
GdkRectangle *old_clip,
GdkRectangle *new_clip);
static GSList *translate_queue = NULL;
void
_gdk_windowing_window_get_offsets (GdkWindow *window,
gint *x_offset,
gint *y_offset)
{
GdkWindowImplX11 *impl =
GDK_WINDOW_IMPL_X11 (GDK_WINDOW_OBJECT (window)->impl);
*x_offset = impl->position_info.x_offset;
*y_offset = impl->position_info.y_offset;
}
void
_gdk_window_init_position (GdkWindow *window)
{
GdkWindowParentPos parent_pos;
GdkWindowImplX11 *impl;
g_return_if_fail (GDK_IS_WINDOW (window));
impl =
GDK_WINDOW_IMPL_X11 (GDK_WINDOW_OBJECT (window)->impl);
gdk_window_compute_parent_pos (impl, &parent_pos);
gdk_window_compute_position (impl, &parent_pos, &impl->position_info);
}
/**
* gdk_window_scroll:
* @window: a #GdkWindow
* @dx: Amount to scroll in the X direction
* @dy: Amount to scroll in the Y direction
*
* Scroll the contents of its window, both pixels and children, by
* the given amount. Portions of the window that the scroll operation
* brings in from offscreen areas are invalidated. The invalidated
* region may be bigger than what would strictly be necessary.
* (For X11, a minimum area will be invalidated if the window has
* no subwindows, or if the edges of the window's parent do not extend
* beyond the edges of the window. In other cases, a multi-step process
* is used to scroll the window which may produce temporary visual
* artifacts and unnecessary invalidations.)
**/
void
gdk_window_scroll (GdkWindow *window,
gint dx,
gint dy)
{
gboolean can_guffaw_scroll = FALSE;
GdkWindowImplX11 *impl;
GdkWindowObject *obj;
g_return_if_fail (GDK_IS_WINDOW (window));
obj = GDK_WINDOW_OBJECT (window);
impl = GDK_WINDOW_IMPL_X11 (obj->impl);
if (GDK_WINDOW_DESTROYED (window))
return;
/* We can guffaw scroll if we are a child window, and the parent
* does not extend beyond our edges.
*/
if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD)
{
GdkWindowImplX11 *parent_impl = GDK_WINDOW_IMPL_X11 (obj->parent->impl);
can_guffaw_scroll = (obj->x <= 0 &&
obj->y <= 0 &&
obj->x + impl->width >= parent_impl->width &&
obj->y + impl->height >= parent_impl->height);
}
if (!obj->children || !can_guffaw_scroll)
{
/* Use XCopyArea, then move any children later
*/
GList *tmp_list;
GdkRegion *invalidate_region;
GdkRectangle dest_rect;
invalidate_region = gdk_region_rectangle (&impl->position_info.clip_rect);
dest_rect = impl->position_info.clip_rect;
dest_rect.x += dx;
dest_rect.y += dy;
gdk_rectangle_intersect (&dest_rect, &impl->position_info.clip_rect, &dest_rect);
if (dest_rect.width > 0 && dest_rect.height > 0)
{
GC gc;
XGCValues values;
GdkRegion *tmp_region;
tmp_region = gdk_region_rectangle (&dest_rect);
gdk_region_subtract (invalidate_region, tmp_region);
gdk_region_destroy (tmp_region);
gdk_window_queue_translation (window, dx, dy);
values.graphics_exposures = True;
gc = XCreateGC (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
GCGraphicsExposures, &values);
XCopyArea (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
GDK_WINDOW_XID (window),
gc,
dest_rect.x - dx, dest_rect.y - dy,
dest_rect.width, dest_rect.height,
dest_rect.x, dest_rect.y);
XFreeGC (GDK_WINDOW_XDISPLAY (window), gc);
}
gdk_window_invalidate_region (window, invalidate_region, TRUE);
gdk_region_destroy (invalidate_region);
tmp_list = obj->children;
while (tmp_list)
{
GdkWindow * child = GDK_WINDOW (tmp_list->data);
gdk_window_move (child, obj->x + dx, obj->y + dy);
tmp_list = tmp_list->next;
}
}
else
{
/* Guffaw scroll
*/
g_warning ("gdk_window_scroll(): guffaw scrolling not yet implemented");
}
}
void
_gdk_window_move_resize_child (GdkWindow *window,
gint x,
gint y,
gint width,
gint height)
{
GdkWindowImplX11 *impl;
GdkWindowObject *obj;
GdkXPositionInfo new_info;
GdkWindowParentPos parent_pos;
GList *tmp_list;
gint d_xoffset, d_yoffset;
gint dx, dy;
gboolean is_move;
gboolean is_resize;
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
impl = GDK_WINDOW_IMPL_X11 (GDK_WINDOW_OBJECT (window)->impl);
obj = GDK_WINDOW_OBJECT (window);
dx = x - obj->x;
dy = y - obj->y;
is_move = dx != 0 || dy != 0;
is_resize = impl->width != width || impl->height != height;
if (!is_move && !is_resize)
return;
obj->x = x;
obj->y = y;
impl->width = width;
impl->height = height;
gdk_window_compute_parent_pos (impl, &parent_pos);
gdk_window_compute_position (impl, &parent_pos, &new_info);
gdk_window_clip_changed (window, &impl->position_info.clip_rect, &new_info.clip_rect);
parent_pos.x += obj->x;
parent_pos.y += obj->y;
parent_pos.x11_x += new_info.x;
parent_pos.x11_y += new_info.y;
parent_pos.clip_rect = new_info.clip_rect;
d_xoffset = new_info.x_offset - impl->position_info.x_offset;
d_yoffset = new_info.y_offset - impl->position_info.y_offset;
if (d_xoffset != 0 || d_yoffset != 0)
{
gint new_x0, new_y0, new_x1, new_y1;
gdk_window_set_static_gravities (window, TRUE);
if (d_xoffset < 0 || d_yoffset < 0)
gdk_window_queue_translation (window, MIN (d_xoffset, 0), MIN (d_yoffset, 0));
if (d_xoffset < 0)
{
new_x0 = impl->position_info.x + d_xoffset;
new_x1 = impl->position_info.x + impl->position_info.width;
}
else
{
new_x0 = impl->position_info.x;
new_x1 = impl->position_info.x + new_info.width + d_xoffset;
}
if (d_yoffset < 0)
{
new_y0 = impl->position_info.y + d_yoffset;
new_y1 = impl->position_info.y + impl->position_info.height;
}
else
{
new_y0 = impl->position_info.y;
new_y1 = impl->position_info.y + new_info.height + d_yoffset;
}
XMoveResizeWindow (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
new_x0, new_y0, new_x1 - new_x0, new_y1 - new_y0);
tmp_list = obj->children;
while (tmp_list)
{
gdk_window_premove (tmp_list->data, &parent_pos);
tmp_list = tmp_list->next;
}
XMoveWindow (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
new_x0 + dx, new_y0 + dy);
if (d_xoffset > 0 || d_yoffset > 0)
gdk_window_queue_translation (window, MAX (d_xoffset, 0), MAX (d_yoffset, 0));
XMoveResizeWindow (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
new_info.x, new_info.y, new_info.width, new_info.height);
if (impl->position_info.no_bg)
gdk_window_tmp_reset_bg (window);
if (!impl->position_info.mapped && new_info.mapped && obj->mapped)
XMapWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
impl->position_info = new_info;
tmp_list = obj->children;
while (tmp_list)
{
gdk_window_postmove (tmp_list->data, &parent_pos);
tmp_list = tmp_list->next;
}
}
else
{
if (is_move && is_resize)
gdk_window_set_static_gravities (window, FALSE);
if (impl->position_info.mapped && !new_info.mapped)
XUnmapWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
tmp_list = obj->children;
while (tmp_list)
{
gdk_window_premove (tmp_list->data, &parent_pos);
tmp_list = tmp_list->next;
}
if (is_resize)
XMoveResizeWindow (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
new_info.x, new_info.y, new_info.width, new_info.height);
else
XMoveWindow (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
new_info.x, new_info.y);
tmp_list = obj->children;
while (tmp_list)
{
gdk_window_postmove (tmp_list->data, &parent_pos);
tmp_list = tmp_list->next;
}
if (impl->position_info.no_bg)
gdk_window_tmp_reset_bg (window);
if (!impl->position_info.mapped && new_info.mapped && obj->mapped)
XMapWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));
impl->position_info = new_info;
}
}
static void
gdk_window_compute_position (GdkWindowImplX11 *window,
GdkWindowParentPos *parent_pos,
GdkXPositionInfo *info)
{
GdkWindowObject *wrapper;
int parent_x_offset;
int parent_y_offset;
g_return_if_fail (GDK_IS_WINDOW_IMPL_X11 (window));
wrapper = GDK_WINDOW_OBJECT (GDK_DRAWABLE_IMPL_X11 (window)->wrapper);
info->big = FALSE;
if (window->width <= 32768)
{
info->width = window->width;
info->x = parent_pos->x + wrapper->x - parent_pos->x11_x;
}
else
{
info->big = TRUE;
info->width = 32768;
if (parent_pos->x + wrapper->x < -16384)
{
if (parent_pos->x + wrapper->x + window->width < 16384)
info->x = parent_pos->x + wrapper->x + window->width - 32768 - parent_pos->x11_x;
else
info->x = -16384 - parent_pos->x11_y;
}
else
info->x = parent_pos->x + wrapper->x - parent_pos->x11_x;
}
if (window->height <= 32768)
{
info->height = window->height;
info->y = parent_pos->y + wrapper->y - parent_pos->x11_y;
}
else
{
info->big = TRUE;
info->height = 32768;
if (parent_pos->y + wrapper->y < -16384)
{
if (parent_pos->y + wrapper->y + window->height < 16384)
info->y = parent_pos->y + wrapper->y + window->height - 32768 - parent_pos->x11_y;
else
info->y = -16384 - parent_pos->x11_y;
}
else
info->y = parent_pos->y + wrapper->y - parent_pos->x11_y;
}
parent_x_offset = parent_pos->x11_x - parent_pos->x;
parent_y_offset = parent_pos->x11_y - parent_pos->y;
info->x_offset = parent_x_offset + info->x - wrapper->x;
info->y_offset = parent_y_offset + info->y - wrapper->y;
/* We don't considering the clipping of toplevel windows and their immediate children
* by their parents, and simply always map those windows.
*/
if (parent_pos->clip_rect.width == G_MAXINT)
info->mapped = TRUE;
/* Check if the window would wrap around into the visible space in either direction */
else if (info->x + parent_x_offset < parent_pos->clip_rect.x + parent_pos->clip_rect.width - 65536 ||
info->x + info->width + parent_x_offset > parent_pos->clip_rect.x + 65536 ||
info->y + parent_y_offset < parent_pos->clip_rect.y + parent_pos->clip_rect.height - 65536 ||
info->y + info->height + parent_y_offset > parent_pos->clip_rect.y + 65536)
info->mapped = FALSE;
else
info->mapped = TRUE;
info->no_bg = FALSE;
if (GDK_WINDOW_TYPE (wrapper) == GDK_WINDOW_CHILD)
{
info->clip_rect.x = wrapper->x;
info->clip_rect.y = wrapper->y;
info->clip_rect.width = window->width;
info->clip_rect.height = window->height;
gdk_rectangle_intersect (&info->clip_rect, &parent_pos->clip_rect, &info->clip_rect);
info->clip_rect.x -= wrapper->x;
info->clip_rect.y -= wrapper->y;
}
else
{
info->clip_rect.x = 0;
info->clip_rect.y = 0;
info->clip_rect.width = G_MAXINT;
info->clip_rect.height = G_MAXINT;
}
}
static void
gdk_window_compute_parent_pos (GdkWindowImplX11 *window,
GdkWindowParentPos *parent_pos)
{
GdkWindowObject *wrapper;
GdkWindowObject *parent;
GdkRectangle tmp_clip;
int clip_xoffset = 0;
int clip_yoffset = 0;
g_return_if_fail (GDK_IS_WINDOW_IMPL_X11 (window));
wrapper =
GDK_WINDOW_OBJECT (GDK_DRAWABLE_IMPL_X11 (window)->wrapper);
parent_pos->x = 0;
parent_pos->y = 0;
parent_pos->x11_x = 0;
parent_pos->x11_y = 0;
/* We take a simple approach here and simply consider toplevel
* windows not to clip their children on the right/bottom, since the
* size of toplevel windows is not directly under our
* control. Clipping only really matters when scrolling and
* generally we aren't going to be moving the immediate child of a
* toplevel beyond the bounds of that toplevel.
*
* We could go ahead and recompute the clips of toplevel windows and
* their descendents when we receive size notification, but it would
* probably not be an improvement in most cases.
*/
parent_pos->clip_rect.x = 0;
parent_pos->clip_rect.y = 0;
parent_pos->clip_rect.width = G_MAXINT;
parent_pos->clip_rect.height = G_MAXINT;
parent = (GdkWindowObject *)wrapper->parent;
while (parent && parent->window_type == GDK_WINDOW_CHILD)
{
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (parent->impl);
tmp_clip.x = - clip_xoffset;
tmp_clip.y = - clip_yoffset;
tmp_clip.width = impl->width;
tmp_clip.height = impl->height;
gdk_rectangle_intersect (&parent_pos->clip_rect, &tmp_clip, &parent_pos->clip_rect);
parent_pos->x += parent->x;
parent_pos->y += parent->y;
parent_pos->x11_x += impl->position_info.x;
parent_pos->x11_y += impl->position_info.y;
clip_xoffset += parent->x;
clip_yoffset += parent->y;
parent = (GdkWindowObject *)parent->parent;
}
}
static void
gdk_window_premove (GdkWindow *window,
GdkWindowParentPos *parent_pos)
{
GdkWindowImplX11 *impl;
GdkWindowObject *obj;
GdkXPositionInfo new_info;
GList *tmp_list;
gint d_xoffset, d_yoffset;
GdkWindowParentPos this_pos;
obj = (GdkWindowObject *) window;
impl = GDK_WINDOW_IMPL_X11 (obj->impl);
gdk_window_compute_position (impl, parent_pos, &new_info);
gdk_window_clip_changed (window, &impl->position_info.clip_rect, &new_info.clip_rect);
this_pos.x = parent_pos->x + obj->x;
this_pos.y = parent_pos->y + obj->y;
this_pos.x11_x = parent_pos->x11_x + new_info.x;
this_pos.x11_y = parent_pos->x11_y + new_info.y;
this_pos.clip_rect = new_info.clip_rect;
if (impl->position_info.mapped && !new_info.mapped)
XUnmapWindow (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window));
d_xoffset = new_info.x_offset - impl->position_info.x_offset;
d_yoffset = new_info.y_offset - impl->position_info.y_offset;
if (d_xoffset != 0 || d_yoffset != 0)
{
gint new_x0, new_y0, new_x1, new_y1;
if (d_xoffset < 0 || d_yoffset < 0)
gdk_window_queue_translation (window, MIN (d_xoffset, 0), MIN (d_yoffset, 0));
if (d_xoffset < 0)
{
new_x0 = impl->position_info.x + d_xoffset;
new_x1 = impl->position_info.x + impl->position_info.width;
}
else
{
new_x0 = impl->position_info.x;
new_x1 = impl->position_info.x + new_info.width + d_xoffset;
}
if (d_yoffset < 0)
{
new_y0 = impl->position_info.y + d_yoffset;
new_y1 = impl->position_info.y + impl->position_info.height;
}
else
{
new_y0 = impl->position_info.y;
new_y1 = impl->position_info.y + new_info.height + d_yoffset;
}
XMoveResizeWindow (GDK_DRAWABLE_XDISPLAY (window),
GDK_DRAWABLE_XID (window),
new_x0, new_y0, new_x1 - new_x0, new_y1 - new_y0);
}
tmp_list = obj->children;
while (tmp_list)
{
gdk_window_premove (tmp_list->data, &this_pos);
tmp_list = tmp_list->next;
}
}
static void
gdk_window_postmove (GdkWindow *window,
GdkWindowParentPos *parent_pos)
{
GdkWindowImplX11 *impl;
GdkWindowObject *obj;
GdkXPositionInfo new_info;
GList *tmp_list;
gint d_xoffset, d_yoffset;
GdkWindowParentPos this_pos;
obj = (GdkWindowObject *) window;
impl = GDK_WINDOW_IMPL_X11 (obj->impl);
gdk_window_compute_position (impl, parent_pos, &new_info);
this_pos.x = parent_pos->x + obj->x;
this_pos.y = parent_pos->y + obj->y;
this_pos.x11_x = parent_pos->x11_x + new_info.x;
this_pos.x11_y = parent_pos->x11_y + new_info.y;
this_pos.clip_rect = new_info.clip_rect;
d_xoffset = new_info.x_offset - impl->position_info.x_offset;
d_yoffset = new_info.y_offset - impl->position_info.y_offset;
if (d_xoffset != 0 || d_yoffset != 0)
{
if (d_xoffset > 0 || d_yoffset > 0)
gdk_window_queue_translation (window, MAX (d_xoffset, 0), MAX (d_yoffset, 0));
XMoveResizeWindow (GDK_DRAWABLE_XDISPLAY (window),
GDK_DRAWABLE_XID (window),
new_info.x, new_info.y, new_info.width, new_info.height);
}
if (!impl->position_info.mapped && new_info.mapped && obj->mapped)
XMapWindow (GDK_DRAWABLE_XDISPLAY (window), GDK_DRAWABLE_XID (window));
if (impl->position_info.no_bg)
gdk_window_tmp_reset_bg (window);
impl->position_info = new_info;
tmp_list = obj->children;
while (tmp_list)
{
gdk_window_postmove (tmp_list->data, &this_pos);
tmp_list = tmp_list->next;
}
}
static void
gdk_window_queue_translation (GdkWindow *window,
gint dx,
gint dy)
{
GdkWindowQueueItem *item = g_new (GdkWindowQueueItem, 1);
item->window = window;
item->serial = NextRequest (GDK_WINDOW_XDISPLAY (window));
item->type = GDK_WINDOW_QUEUE_TRANSLATE;
item->u.translate.dx = dx;
item->u.translate.dy = dy;
gdk_drawable_ref (window);
translate_queue = g_slist_append (translate_queue, item);
}
gboolean
_gdk_windowing_window_queue_antiexpose (GdkWindow *window,
GdkRegion *area)
{
GdkWindowQueueItem *item = g_new (GdkWindowQueueItem, 1);
item->window = window;
item->serial = NextRequest (GDK_WINDOW_XDISPLAY (window));
item->type = GDK_WINDOW_QUEUE_ANTIEXPOSE;
item->u.antiexpose.area = area;
gdk_drawable_ref (window);
translate_queue = g_slist_append (translate_queue, item);
return TRUE;
}
void
_gdk_window_process_expose (GdkWindow *window,
gulong serial,
GdkRectangle *area)
{
GdkWindowImplX11 *impl;
GdkRegion *invalidate_region = gdk_region_rectangle (area);
GdkRegion *clip_region;
GSList *tmp_list = translate_queue;
impl = GDK_WINDOW_IMPL_X11 (GDK_WINDOW_OBJECT (window)->impl);
while (tmp_list)
{
GdkWindowQueueItem *item = tmp_list->data;
tmp_list = tmp_list->next;
if (serial < item->serial)
{
if (item->window == window)
{
if (item->type == GDK_WINDOW_QUEUE_TRANSLATE)
gdk_region_offset (invalidate_region, - item->u.translate.dx, - item->u.translate.dy);
else /* anti-expose */
gdk_region_subtract (invalidate_region, item->u.antiexpose.area);
}
}
else
{
GSList *tmp_link = translate_queue;
translate_queue = g_slist_remove_link (translate_queue, translate_queue);
gdk_drawable_unref (item->window);
if (item->type == GDK_WINDOW_QUEUE_ANTIEXPOSE)
gdk_region_destroy (item->u.antiexpose.area);
g_free (item);
g_slist_free_1 (tmp_link);
}
}
clip_region = gdk_region_rectangle (&impl->position_info.clip_rect);
gdk_region_intersect (invalidate_region, clip_region);
if (!gdk_region_empty (invalidate_region))
gdk_window_invalidate_region (window, invalidate_region, FALSE);
gdk_region_destroy (invalidate_region);
gdk_region_destroy (clip_region);
}
static void
gdk_window_tmp_unset_bg (GdkWindow *window)
{
GdkWindowImplX11 *impl;
GdkWindowObject *obj;
obj = (GdkWindowObject *) window;
impl = GDK_WINDOW_IMPL_X11 (obj->impl);
impl->position_info.no_bg = TRUE;
if (obj->bg_pixmap != GDK_NO_BG)
XSetWindowBackgroundPixmap (GDK_DRAWABLE_XDISPLAY (window),
GDK_DRAWABLE_XID (window), None);
}
static void
gdk_window_tmp_reset_bg (GdkWindow *window)
{
GdkWindowImplX11 *impl;
GdkWindowObject *obj;
obj = (GdkWindowObject *) window;
impl = GDK_WINDOW_IMPL_X11 (obj->impl);
impl->position_info.no_bg = FALSE;
if (obj->bg_pixmap == GDK_NO_BG)
return;
if (obj->bg_pixmap)
{
Pixmap xpixmap;
if (obj->bg_pixmap == GDK_PARENT_RELATIVE_BG)
xpixmap = ParentRelative;
else
xpixmap = GDK_DRAWABLE_XID (obj->bg_pixmap);
XSetWindowBackgroundPixmap (GDK_DRAWABLE_XDISPLAY (window),
GDK_DRAWABLE_XID (window), xpixmap);
}
else
{
XSetWindowBackground (GDK_DRAWABLE_XDISPLAY (window),
GDK_DRAWABLE_XID (window),
obj->bg_color.pixel);
}
}
static void
gdk_window_clip_changed (GdkWindow *window, GdkRectangle *old_clip, GdkRectangle *new_clip)
{
GdkWindowImplX11 *impl;
GdkWindowObject *obj;
GdkRegion *old_clip_region;
GdkRegion *new_clip_region;
if (((GdkWindowObject *)window)->input_only)
return;
obj = (GdkWindowObject *) window;
impl = GDK_WINDOW_IMPL_X11 (obj->impl);
old_clip_region = gdk_region_rectangle (old_clip);
new_clip_region = gdk_region_rectangle (new_clip);
/* Trim invalid region of window to new clip rectangle
*/
if (obj->update_area)
gdk_region_intersect (obj->update_area, new_clip_region);
/* Invalidate newly exposed portion of window
*/
gdk_region_subtract (new_clip_region, old_clip_region);
if (!gdk_region_empty (new_clip_region))
{
gdk_window_tmp_unset_bg (window);
gdk_window_invalidate_region (window, new_clip_region, FALSE);
}
gdk_region_destroy (new_clip_region);
gdk_region_destroy (old_clip_region);
}