2008-07-18 13:03:42 +00:00
|
|
|
|
/* 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 Lesser 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
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser 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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Modified by the GTK+ Team and others 1997-2005. See the AUTHORS
|
|
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
|
* files for a list of changes. These files are distributed with
|
|
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
|
|
|
*/
|
|
|
|
|
|
2010-09-28 14:03:59 +00:00
|
|
|
|
#include "config.h"
|
|
|
|
|
|
2008-07-18 13:03:42 +00:00
|
|
|
|
#include "gdkwindow.h"
|
|
|
|
|
#include "gdkinternals.h"
|
|
|
|
|
#include "gdkwindowimpl.h"
|
2010-07-09 00:34:45 +00:00
|
|
|
|
|
2010-10-15 02:05:51 +00:00
|
|
|
|
#include <math.h>
|
2008-07-18 13:03:42 +00:00
|
|
|
|
|
|
|
|
|
/* LIMITATIONS:
|
|
|
|
|
*
|
|
|
|
|
* Offscreen windows can't be the child of a foreign window,
|
|
|
|
|
* nor contain foreign windows
|
|
|
|
|
* GDK_POINTER_MOTION_HINT_MASK isn't effective
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
typedef struct _GdkOffscreenWindow GdkOffscreenWindow;
|
|
|
|
|
typedef struct _GdkOffscreenWindowClass GdkOffscreenWindowClass;
|
|
|
|
|
|
|
|
|
|
struct _GdkOffscreenWindow
|
|
|
|
|
{
|
2010-11-22 19:42:00 +00:00
|
|
|
|
GdkWindowImpl parent_instance;
|
2008-07-18 13:03:42 +00:00
|
|
|
|
|
|
|
|
|
GdkWindow *wrapper;
|
|
|
|
|
|
2010-08-26 11:46:34 +00:00
|
|
|
|
cairo_surface_t *surface;
|
2009-07-01 12:36:36 +00:00
|
|
|
|
GdkWindow *embedder;
|
2008-07-18 13:03:42 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct _GdkOffscreenWindowClass
|
|
|
|
|
{
|
2010-11-22 19:42:00 +00:00
|
|
|
|
GdkWindowImplClass parent_class;
|
2008-07-18 13:03:42 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define GDK_TYPE_OFFSCREEN_WINDOW (gdk_offscreen_window_get_type())
|
|
|
|
|
#define GDK_OFFSCREEN_WINDOW(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_OFFSCREEN_WINDOW, GdkOffscreenWindow))
|
|
|
|
|
#define GDK_IS_OFFSCREEN_WINDOW(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_OFFSCREEN_WINDOW))
|
|
|
|
|
#define GDK_OFFSCREEN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_OFFSCREEN_WINDOW, GdkOffscreenWindowClass))
|
|
|
|
|
#define GDK_IS_OFFSCREEN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_OFFSCREEN_WINDOW))
|
|
|
|
|
#define GDK_OFFSCREEN_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_OFFSCREEN_WINDOW, GdkOffscreenWindowClass))
|
|
|
|
|
|
|
|
|
|
static void gdk_offscreen_window_hide (GdkWindow *window);
|
|
|
|
|
|
2010-11-22 19:42:00 +00:00
|
|
|
|
G_DEFINE_TYPE (GdkOffscreenWindow, gdk_offscreen_window, GDK_TYPE_WINDOW_IMPL)
|
2008-07-18 13:03:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_offscreen_window_finalize (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
GdkOffscreenWindow *offscreen = GDK_OFFSCREEN_WINDOW (object);
|
|
|
|
|
|
2010-10-12 09:32:42 +00:00
|
|
|
|
if (offscreen->surface)
|
|
|
|
|
cairo_surface_destroy (offscreen->surface);
|
2009-06-04 18:15:29 +00:00
|
|
|
|
|
2008-07-18 13:03:42 +00:00
|
|
|
|
G_OBJECT_CLASS (gdk_offscreen_window_parent_class)->finalize (object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_offscreen_window_init (GdkOffscreenWindow *window)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-15 14:04:44 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_offscreen_window_destroy (GdkWindow *window,
|
|
|
|
|
gboolean recursing,
|
|
|
|
|
gboolean foreign_destroy)
|
2008-07-18 13:03:42 +00:00
|
|
|
|
{
|
|
|
|
|
GdkOffscreenWindow *offscreen;
|
|
|
|
|
|
2010-11-22 23:55:39 +00:00
|
|
|
|
offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
|
2008-07-18 13:03:42 +00:00
|
|
|
|
|
2009-07-01 12:36:36 +00:00
|
|
|
|
gdk_offscreen_window_set_embedder (window, NULL);
|
|
|
|
|
|
2008-07-18 13:03:42 +00:00
|
|
|
|
if (!recursing)
|
|
|
|
|
gdk_offscreen_window_hide (window);
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-12 09:32:42 +00:00
|
|
|
|
static cairo_surface_t *
|
|
|
|
|
get_surface (GdkOffscreenWindow *offscreen)
|
|
|
|
|
{
|
|
|
|
|
if (! offscreen->surface)
|
|
|
|
|
{
|
2010-11-22 23:55:39 +00:00
|
|
|
|
GdkWindow *window = offscreen->wrapper;
|
2010-10-12 09:32:42 +00:00
|
|
|
|
|
2010-11-22 23:55:39 +00:00
|
|
|
|
g_signal_emit_by_name (window, "create-surface",
|
|
|
|
|
window->width,
|
|
|
|
|
window->height,
|
2010-10-14 11:25:23 +00:00
|
|
|
|
&offscreen->surface);
|
2010-10-12 09:32:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return offscreen->surface;
|
|
|
|
|
}
|
|
|
|
|
|
2008-07-18 13:03:42 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
is_parent_of (GdkWindow *parent,
|
2009-06-04 18:15:29 +00:00
|
|
|
|
GdkWindow *child)
|
2008-07-18 13:03:42 +00:00
|
|
|
|
{
|
|
|
|
|
GdkWindow *w;
|
|
|
|
|
|
|
|
|
|
w = child;
|
|
|
|
|
while (w != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (w == parent)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
w = gdk_window_get_parent (w);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static cairo_surface_t *
|
2010-11-23 00:46:03 +00:00
|
|
|
|
gdk_offscreen_window_ref_cairo_surface (GdkWindow *window)
|
2008-07-18 13:03:42 +00:00
|
|
|
|
{
|
2010-11-23 00:46:03 +00:00
|
|
|
|
GdkOffscreenWindow *offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
|
2009-06-04 18:15:29 +00:00
|
|
|
|
|
2010-10-12 09:32:42 +00:00
|
|
|
|
return cairo_surface_reference (get_surface (offscreen));
|
2008-07-18 13:03:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-14 11:25:23 +00:00
|
|
|
|
cairo_surface_t *
|
|
|
|
|
_gdk_offscreen_window_create_surface (GdkWindow *offscreen,
|
|
|
|
|
gint width,
|
|
|
|
|
gint height)
|
|
|
|
|
{
|
|
|
|
|
cairo_surface_t *similar;
|
|
|
|
|
cairo_surface_t *surface;
|
2010-10-20 15:44:23 +00:00
|
|
|
|
cairo_content_t content = CAIRO_CONTENT_COLOR;
|
2010-10-14 11:25:23 +00:00
|
|
|
|
|
2010-11-22 23:55:39 +00:00
|
|
|
|
g_return_val_if_fail (GDK_IS_OFFSCREEN_WINDOW (offscreen->impl), NULL);
|
2010-10-14 11:25:23 +00:00
|
|
|
|
|
2010-11-22 23:55:39 +00:00
|
|
|
|
similar = _gdk_window_ref_cairo_surface (offscreen->parent);
|
2010-10-14 11:25:23 +00:00
|
|
|
|
|
2010-10-20 15:44:23 +00:00
|
|
|
|
if (gdk_window_get_visual (offscreen) ==
|
|
|
|
|
gdk_screen_get_rgba_visual (gdk_window_get_screen (offscreen)))
|
|
|
|
|
{
|
|
|
|
|
content = CAIRO_CONTENT_COLOR_ALPHA;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
surface = cairo_surface_create_similar (similar, content, width, height);
|
2010-10-14 11:25:23 +00:00
|
|
|
|
|
|
|
|
|
cairo_surface_destroy (similar);
|
|
|
|
|
|
|
|
|
|
return surface;
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-04 18:15:29 +00:00
|
|
|
|
void
|
2008-07-18 13:03:42 +00:00
|
|
|
|
_gdk_offscreen_window_new (GdkWindow *window,
|
|
|
|
|
GdkWindowAttr *attributes,
|
|
|
|
|
gint attributes_mask)
|
|
|
|
|
{
|
|
|
|
|
GdkOffscreenWindow *offscreen;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (attributes != NULL);
|
|
|
|
|
|
|
|
|
|
if (attributes->wclass != GDK_INPUT_OUTPUT)
|
|
|
|
|
return; /* Can't support input only offscreens */
|
2009-06-04 18:15:29 +00:00
|
|
|
|
|
2010-11-22 23:55:39 +00:00
|
|
|
|
if (window->parent != NULL && GDK_WINDOW_DESTROYED (window->parent))
|
2008-07-18 13:03:42 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2010-11-22 23:55:39 +00:00
|
|
|
|
window->impl = g_object_new (GDK_TYPE_OFFSCREEN_WINDOW, NULL);
|
|
|
|
|
offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
|
2008-07-18 13:03:42 +00:00
|
|
|
|
offscreen->wrapper = window;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
gdk_offscreen_window_reparent (GdkWindow *window,
|
|
|
|
|
GdkWindow *new_parent,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y)
|
|
|
|
|
{
|
2010-11-22 23:55:39 +00:00
|
|
|
|
GdkWindow *old_parent;
|
2008-07-18 13:03:42 +00:00
|
|
|
|
gboolean was_mapped;
|
|
|
|
|
|
|
|
|
|
if (new_parent)
|
|
|
|
|
{
|
|
|
|
|
/* No input-output children of input-only windows */
|
2010-11-22 23:55:39 +00:00
|
|
|
|
if (new_parent->input_only && !window->input_only)
|
2008-07-18 13:03:42 +00:00
|
|
|
|
return FALSE;
|
2009-06-04 18:15:29 +00:00
|
|
|
|
|
2008-07-18 13:03:42 +00:00
|
|
|
|
/* Don't create loops in hierarchy */
|
|
|
|
|
if (is_parent_of (window, new_parent))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
was_mapped = GDK_WINDOW_IS_MAPPED (window);
|
|
|
|
|
|
|
|
|
|
gdk_window_hide (window);
|
|
|
|
|
|
2010-11-22 23:55:39 +00:00
|
|
|
|
if (window->parent)
|
|
|
|
|
window->parent->children = g_list_remove (window->parent->children, window);
|
2008-07-18 13:03:42 +00:00
|
|
|
|
|
2010-11-22 23:55:39 +00:00
|
|
|
|
old_parent = window->parent;
|
|
|
|
|
window->parent = new_parent;
|
|
|
|
|
window->x = x;
|
|
|
|
|
window->y = y;
|
2008-07-18 13:03:42 +00:00
|
|
|
|
|
2010-11-22 23:55:39 +00:00
|
|
|
|
if (new_parent)
|
|
|
|
|
window->parent->children = g_list_prepend (window->parent->children, window);
|
2008-07-18 13:03:42 +00:00
|
|
|
|
|
2009-06-18 18:58:13 +00:00
|
|
|
|
_gdk_synthesize_crossing_events_for_geometry_change (window);
|
2008-07-18 13:03:42 +00:00
|
|
|
|
if (old_parent)
|
2010-11-22 23:55:39 +00:00
|
|
|
|
_gdk_synthesize_crossing_events_for_geometry_change (old_parent);
|
2009-06-04 18:15:29 +00:00
|
|
|
|
|
2008-07-18 13:03:42 +00:00
|
|
|
|
return was_mapped;
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-08 17:38:15 +00:00
|
|
|
|
static void
|
2009-07-01 12:36:36 +00:00
|
|
|
|
from_embedder (GdkWindow *window,
|
|
|
|
|
double embedder_x, double embedder_y,
|
|
|
|
|
double *offscreen_x, double *offscreen_y)
|
2009-06-08 17:38:15 +00:00
|
|
|
|
{
|
2010-11-22 23:55:39 +00:00
|
|
|
|
g_signal_emit_by_name (window->impl_window,
|
2009-07-01 12:36:36 +00:00
|
|
|
|
"from-embedder",
|
|
|
|
|
embedder_x, embedder_y,
|
2009-06-08 17:38:15 +00:00
|
|
|
|
offscreen_x, offscreen_y,
|
|
|
|
|
NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-08 13:57:59 +00:00
|
|
|
|
static void
|
2009-07-01 12:36:36 +00:00
|
|
|
|
to_embedder (GdkWindow *window,
|
|
|
|
|
double offscreen_x, double offscreen_y,
|
|
|
|
|
double *embedder_x, double *embedder_y)
|
2009-06-08 13:57:59 +00:00
|
|
|
|
{
|
2010-11-22 23:55:39 +00:00
|
|
|
|
g_signal_emit_by_name (window->impl_window,
|
2009-07-01 12:36:36 +00:00
|
|
|
|
"to-embedder",
|
2009-06-08 13:57:59 +00:00
|
|
|
|
offscreen_x, offscreen_y,
|
2009-07-01 12:36:36 +00:00
|
|
|
|
embedder_x, embedder_y,
|
2009-06-08 13:57:59 +00:00
|
|
|
|
NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gint
|
2009-06-08 15:03:47 +00:00
|
|
|
|
gdk_offscreen_window_get_root_coords (GdkWindow *window,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
gint *root_x,
|
|
|
|
|
gint *root_y)
|
2009-06-08 13:57:59 +00:00
|
|
|
|
{
|
2009-07-01 12:36:36 +00:00
|
|
|
|
GdkOffscreenWindow *offscreen;
|
2009-06-08 13:57:59 +00:00
|
|
|
|
int tmpx, tmpy;
|
|
|
|
|
|
2009-06-08 15:03:47 +00:00
|
|
|
|
tmpx = x;
|
|
|
|
|
tmpy = y;
|
2009-06-08 13:57:59 +00:00
|
|
|
|
|
2010-11-22 23:55:39 +00:00
|
|
|
|
offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
|
2009-07-01 12:36:36 +00:00
|
|
|
|
if (offscreen->embedder)
|
2009-06-08 13:57:59 +00:00
|
|
|
|
{
|
|
|
|
|
double dx, dy;
|
2009-07-01 12:36:36 +00:00
|
|
|
|
to_embedder (window,
|
|
|
|
|
x, y,
|
|
|
|
|
&dx, &dy);
|
2009-06-08 15:03:47 +00:00
|
|
|
|
tmpx = floor (dx + 0.5);
|
|
|
|
|
tmpy = floor (dy + 0.5);
|
2009-07-01 12:36:36 +00:00
|
|
|
|
gdk_window_get_root_coords (offscreen->embedder,
|
2009-06-08 15:03:47 +00:00
|
|
|
|
tmpx, tmpy,
|
|
|
|
|
&tmpx, &tmpy);
|
2009-06-08 13:57:59 +00:00
|
|
|
|
|
2009-06-08 15:03:47 +00:00
|
|
|
|
}
|
2009-06-08 13:57:59 +00:00
|
|
|
|
|
2009-06-08 15:03:47 +00:00
|
|
|
|
if (root_x)
|
|
|
|
|
*root_x = tmpx;
|
|
|
|
|
if (root_y)
|
|
|
|
|
*root_y = tmpy;
|
2009-06-08 13:57:59 +00:00
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-04 17:21:20 +00:00
|
|
|
|
static gboolean
|
2010-05-25 22:38:44 +00:00
|
|
|
|
gdk_offscreen_window_get_device_state (GdkWindow *window,
|
|
|
|
|
GdkDevice *device,
|
|
|
|
|
gint *x,
|
|
|
|
|
gint *y,
|
|
|
|
|
GdkModifierType *mask)
|
2009-06-04 17:21:20 +00:00
|
|
|
|
{
|
2009-07-01 12:36:36 +00:00
|
|
|
|
GdkOffscreenWindow *offscreen;
|
2009-06-08 17:38:15 +00:00
|
|
|
|
int tmpx, tmpy;
|
|
|
|
|
double dtmpx, dtmpy;
|
|
|
|
|
GdkModifierType tmpmask;
|
|
|
|
|
|
|
|
|
|
tmpx = 0;
|
|
|
|
|
tmpy = 0;
|
|
|
|
|
tmpmask = 0;
|
|
|
|
|
|
2010-11-22 23:55:39 +00:00
|
|
|
|
offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
|
2009-07-01 12:36:36 +00:00
|
|
|
|
if (offscreen->embedder != NULL)
|
2009-06-08 17:38:15 +00:00
|
|
|
|
{
|
2010-05-25 22:38:44 +00:00
|
|
|
|
gdk_window_get_device_position (offscreen->embedder, device, &tmpx, &tmpy, &tmpmask);
|
2009-07-01 12:36:36 +00:00
|
|
|
|
from_embedder (window,
|
|
|
|
|
tmpx, tmpy,
|
|
|
|
|
&dtmpx, &dtmpy);
|
2009-06-08 17:38:15 +00:00
|
|
|
|
tmpx = floor (dtmpx + 0.5);
|
|
|
|
|
tmpy = floor (dtmpy + 0.5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (x)
|
|
|
|
|
*x = tmpx;
|
|
|
|
|
if (y)
|
|
|
|
|
*y = tmpy;
|
|
|
|
|
if (mask)
|
|
|
|
|
*mask = tmpmask;
|
2009-06-04 17:21:20 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2008-07-18 13:03:42 +00:00
|
|
|
|
/**
|
2010-08-26 11:46:34 +00:00
|
|
|
|
* gdk_offscreen_window_get_surface:
|
2008-07-18 13:03:42 +00:00
|
|
|
|
* @window: a #GdkWindow
|
|
|
|
|
*
|
2010-08-26 11:46:34 +00:00
|
|
|
|
* Gets the offscreen surface that an offscreen window renders into.
|
2009-07-03 19:17:26 +00:00
|
|
|
|
* If you need to keep this around over window resizes, you need to
|
|
|
|
|
* add a reference to it.
|
2008-07-18 13:03:42 +00:00
|
|
|
|
*
|
2010-08-26 11:46:34 +00:00
|
|
|
|
* Returns: The offscreen surface, or %NULL if not offscreen
|
2009-07-03 19:17:26 +00:00
|
|
|
|
*/
|
2010-08-26 11:46:34 +00:00
|
|
|
|
cairo_surface_t *
|
|
|
|
|
gdk_offscreen_window_get_surface (GdkWindow *window)
|
2008-07-18 13:03:42 +00:00
|
|
|
|
{
|
|
|
|
|
GdkOffscreenWindow *offscreen;
|
2009-06-04 18:15:29 +00:00
|
|
|
|
|
2008-07-18 13:03:42 +00:00
|
|
|
|
g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
|
|
|
|
|
|
2010-11-22 23:55:39 +00:00
|
|
|
|
if (!GDK_IS_OFFSCREEN_WINDOW (window->impl))
|
2008-07-18 13:03:42 +00:00
|
|
|
|
return NULL;
|
2009-06-04 18:15:29 +00:00
|
|
|
|
|
2010-11-22 23:55:39 +00:00
|
|
|
|
offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
|
2010-10-12 09:32:42 +00:00
|
|
|
|
|
|
|
|
|
return get_surface (offscreen);
|
2008-07-18 13:03:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_offscreen_window_raise (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
/* gdk_window_raise already changed the stacking order */
|
2009-06-18 18:58:13 +00:00
|
|
|
|
_gdk_synthesize_crossing_events_for_geometry_change (window);
|
2008-07-18 13:03:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_offscreen_window_lower (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
/* gdk_window_lower already changed the stacking order */
|
2009-06-18 18:58:13 +00:00
|
|
|
|
_gdk_synthesize_crossing_events_for_geometry_change (window);
|
2008-07-18 13:03:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_offscreen_window_move_resize_internal (GdkWindow *window,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
gint width,
|
|
|
|
|
gint height,
|
|
|
|
|
gboolean send_expose_events)
|
|
|
|
|
{
|
|
|
|
|
GdkOffscreenWindow *offscreen;
|
|
|
|
|
gint dx, dy, dw, dh;
|
|
|
|
|
|
2010-11-22 23:55:39 +00:00
|
|
|
|
offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
|
2008-07-18 13:03:42 +00:00
|
|
|
|
|
|
|
|
|
if (width < 1)
|
|
|
|
|
width = 1;
|
|
|
|
|
if (height < 1)
|
|
|
|
|
height = 1;
|
|
|
|
|
|
2010-11-22 23:55:39 +00:00
|
|
|
|
if (window->destroyed)
|
2008-07-18 13:03:42 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2010-11-22 23:55:39 +00:00
|
|
|
|
dx = x - window->x;
|
|
|
|
|
dy = y - window->y;
|
|
|
|
|
dw = width - window->width;
|
|
|
|
|
dh = height - window->height;
|
2008-07-18 13:03:42 +00:00
|
|
|
|
|
2010-11-22 23:55:39 +00:00
|
|
|
|
window->x = x;
|
|
|
|
|
window->y = y;
|
2008-07-18 13:03:42 +00:00
|
|
|
|
|
2010-11-22 23:55:39 +00:00
|
|
|
|
if (window->width != width ||
|
|
|
|
|
window->height != height)
|
2008-07-18 13:03:42 +00:00
|
|
|
|
{
|
2010-11-22 23:55:39 +00:00
|
|
|
|
window->width = width;
|
|
|
|
|
window->height = height;
|
2009-06-04 18:15:29 +00:00
|
|
|
|
|
2010-10-12 09:32:42 +00:00
|
|
|
|
if (offscreen->surface)
|
|
|
|
|
{
|
|
|
|
|
cairo_surface_t *old_surface;
|
|
|
|
|
cairo_t *cr;
|
2008-07-18 13:03:42 +00:00
|
|
|
|
|
2010-10-12 09:32:42 +00:00
|
|
|
|
old_surface = offscreen->surface;
|
|
|
|
|
offscreen->surface = NULL;
|
|
|
|
|
|
|
|
|
|
offscreen->surface = get_surface (offscreen);
|
2010-08-26 11:46:34 +00:00
|
|
|
|
|
2010-10-12 09:32:42 +00:00
|
|
|
|
cr = cairo_create (offscreen->surface);
|
|
|
|
|
cairo_set_source_surface (cr, old_surface, 0, 0);
|
|
|
|
|
cairo_paint (cr);
|
|
|
|
|
cairo_destroy (cr);
|
|
|
|
|
|
|
|
|
|
cairo_surface_destroy (old_surface);
|
|
|
|
|
}
|
2008-07-18 13:03:42 +00:00
|
|
|
|
}
|
2009-06-04 18:15:29 +00:00
|
|
|
|
|
2010-11-22 23:55:39 +00:00
|
|
|
|
if (GDK_WINDOW_IS_MAPPED (window))
|
2008-07-18 13:03:42 +00:00
|
|
|
|
{
|
|
|
|
|
// TODO: Only invalidate new area, i.e. for larger windows
|
|
|
|
|
gdk_window_invalidate_rect (window, NULL, TRUE);
|
2009-06-18 18:58:13 +00:00
|
|
|
|
_gdk_synthesize_crossing_events_for_geometry_change (window);
|
2008-07-18 13:03:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_offscreen_window_move_resize (GdkWindow *window,
|
2009-06-04 18:15:29 +00:00
|
|
|
|
gboolean with_move,
|
2008-07-18 13:03:42 +00:00
|
|
|
|
gint x,
|
2009-06-04 18:15:29 +00:00
|
|
|
|
gint y,
|
2008-07-18 13:03:42 +00:00
|
|
|
|
gint width,
|
2009-06-04 18:15:29 +00:00
|
|
|
|
gint height)
|
2008-07-18 13:03:42 +00:00
|
|
|
|
{
|
|
|
|
|
GdkOffscreenWindow *offscreen;
|
|
|
|
|
|
2010-11-22 23:55:39 +00:00
|
|
|
|
offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
|
2008-07-18 13:03:42 +00:00
|
|
|
|
|
|
|
|
|
if (!with_move)
|
|
|
|
|
{
|
2010-11-22 23:55:39 +00:00
|
|
|
|
x = window->x;
|
|
|
|
|
y = window->y;
|
2008-07-18 13:03:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (width < 0)
|
2010-11-22 23:55:39 +00:00
|
|
|
|
width = window->width;
|
2008-07-18 13:03:42 +00:00
|
|
|
|
|
|
|
|
|
if (height < 0)
|
2010-11-22 23:55:39 +00:00
|
|
|
|
height = window->height;
|
2008-07-18 13:03:42 +00:00
|
|
|
|
|
|
|
|
|
gdk_offscreen_window_move_resize_internal (window, x, y,
|
|
|
|
|
width, height,
|
|
|
|
|
TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2009-07-01 12:36:36 +00:00
|
|
|
|
gdk_offscreen_window_show (GdkWindow *window,
|
|
|
|
|
gboolean already_mapped)
|
2008-07-18 13:03:42 +00:00
|
|
|
|
{
|
2010-11-22 23:55:39 +00:00
|
|
|
|
GdkRectangle area = { 0, 0, window->width, window->height };
|
2008-07-18 13:03:42 +00:00
|
|
|
|
|
2010-08-15 01:10:16 +00:00
|
|
|
|
gdk_window_invalidate_rect (window, &area, FALSE);
|
2008-07-18 13:03:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_offscreen_window_hide (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkOffscreenWindow *offscreen;
|
|
|
|
|
GdkDisplay *display;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (window != NULL);
|
|
|
|
|
|
2010-11-22 23:55:39 +00:00
|
|
|
|
offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
|
2008-07-18 13:03:42 +00:00
|
|
|
|
|
|
|
|
|
/* May need to break grabs on children */
|
2010-08-29 00:08:47 +00:00
|
|
|
|
display = gdk_window_get_display (window);
|
2009-01-31 18:42:44 +00:00
|
|
|
|
|
|
|
|
|
/* TODO: This needs updating to the new grab world */
|
|
|
|
|
#if 0
|
2008-07-18 13:03:42 +00:00
|
|
|
|
if (display->pointer_grab.window != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (is_parent_of (window, display->pointer_grab.window))
|
|
|
|
|
{
|
|
|
|
|
/* Call this ourselves, even though gdk_display_pointer_ungrab
|
|
|
|
|
does so too, since we want to pass implicit == TRUE so the
|
|
|
|
|
broken grab event is generated */
|
|
|
|
|
_gdk_display_unset_has_pointer_grab (display,
|
|
|
|
|
TRUE,
|
|
|
|
|
FALSE,
|
|
|
|
|
GDK_CURRENT_TIME);
|
|
|
|
|
gdk_display_pointer_ungrab (display, GDK_CURRENT_TIME);
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-01-31 18:42:44 +00:00
|
|
|
|
#endif
|
2008-07-18 13:03:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_offscreen_window_withdraw (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GdkEventMask
|
|
|
|
|
gdk_offscreen_window_get_events (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_offscreen_window_set_events (GdkWindow *window,
|
|
|
|
|
GdkEventMask event_mask)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_offscreen_window_set_background (GdkWindow *window,
|
2010-08-15 11:49:30 +00:00
|
|
|
|
cairo_pattern_t *pattern)
|
2008-07-18 13:03:42 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_offscreen_window_shape_combine_region (GdkWindow *window,
|
2010-06-28 12:54:37 +00:00
|
|
|
|
const cairo_region_t *shape_region,
|
2009-06-04 18:15:29 +00:00
|
|
|
|
gint offset_x,
|
|
|
|
|
gint offset_y)
|
2008-07-18 13:03:42 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2008-12-17 10:24:46 +00:00
|
|
|
|
gdk_offscreen_window_input_shape_combine_region (GdkWindow *window,
|
2010-06-28 12:54:37 +00:00
|
|
|
|
const cairo_region_t *shape_region,
|
2008-12-17 10:24:46 +00:00
|
|
|
|
gint offset_x,
|
|
|
|
|
gint offset_y)
|
2008-07-18 13:03:42 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
gdk_offscreen_window_set_static_gravities (GdkWindow *window,
|
|
|
|
|
gboolean use_static)
|
|
|
|
|
{
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_offscreen_window_get_geometry (GdkWindow *window,
|
|
|
|
|
gint *x,
|
|
|
|
|
gint *y,
|
|
|
|
|
gint *width,
|
2010-12-05 13:40:35 +00:00
|
|
|
|
gint *height)
|
2008-07-18 13:03:42 +00:00
|
|
|
|
{
|
|
|
|
|
if (!GDK_WINDOW_DESTROYED (window))
|
|
|
|
|
{
|
|
|
|
|
if (x)
|
2010-11-22 23:55:39 +00:00
|
|
|
|
*x = window->x;
|
2008-07-18 13:03:42 +00:00
|
|
|
|
if (y)
|
2010-11-22 23:55:39 +00:00
|
|
|
|
*y = window->y;
|
2008-07-18 13:03:42 +00:00
|
|
|
|
if (width)
|
2010-11-22 23:55:39 +00:00
|
|
|
|
*width = window->width;
|
2008-07-18 13:03:42 +00:00
|
|
|
|
if (height)
|
2010-11-22 23:55:39 +00:00
|
|
|
|
*height = window->height;
|
2008-07-18 13:03:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
gdk_offscreen_window_queue_antiexpose (GdkWindow *window,
|
2010-06-28 12:54:37 +00:00
|
|
|
|
cairo_region_t *area)
|
2008-07-18 13:03:42 +00:00
|
|
|
|
{
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-15 13:55:53 +00:00
|
|
|
|
static void
|
2010-07-21 18:37:33 +00:00
|
|
|
|
gdk_offscreen_window_translate (GdkWindow *window,
|
|
|
|
|
cairo_region_t *area,
|
|
|
|
|
gint dx,
|
|
|
|
|
gint dy)
|
2008-12-15 13:55:53 +00:00
|
|
|
|
{
|
2010-11-22 23:55:39 +00:00
|
|
|
|
GdkOffscreenWindow *offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
|
2010-07-21 18:37:33 +00:00
|
|
|
|
|
2010-10-12 09:32:42 +00:00
|
|
|
|
if (offscreen->surface)
|
|
|
|
|
{
|
|
|
|
|
cairo_t *cr;
|
|
|
|
|
|
|
|
|
|
cr = cairo_create (offscreen->surface);
|
2010-07-21 18:37:33 +00:00
|
|
|
|
|
2010-10-12 09:32:42 +00:00
|
|
|
|
area = cairo_region_copy (area);
|
2010-07-21 18:37:33 +00:00
|
|
|
|
|
2010-10-12 09:32:42 +00:00
|
|
|
|
gdk_cairo_region (cr, area);
|
|
|
|
|
cairo_clip (cr);
|
|
|
|
|
|
|
|
|
|
/* NB: This is a self-copy and Cairo doesn't support that yet.
|
|
|
|
|
* So we do a litle trick.
|
|
|
|
|
*/
|
|
|
|
|
cairo_push_group (cr);
|
2010-07-21 18:37:33 +00:00
|
|
|
|
|
2010-10-12 09:32:42 +00:00
|
|
|
|
cairo_set_source_surface (cr, offscreen->surface, dx, dy);
|
|
|
|
|
cairo_paint (cr);
|
2010-07-21 18:37:33 +00:00
|
|
|
|
|
2010-10-12 09:32:42 +00:00
|
|
|
|
cairo_pop_group_to_source (cr);
|
|
|
|
|
cairo_paint (cr);
|
2010-07-21 18:37:33 +00:00
|
|
|
|
|
2010-10-12 09:32:42 +00:00
|
|
|
|
cairo_destroy (cr);
|
|
|
|
|
}
|
2010-07-21 18:37:33 +00:00
|
|
|
|
|
|
|
|
|
_gdk_window_add_damage (window, area);
|
2008-12-15 13:55:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-05 13:21:40 +00:00
|
|
|
|
static cairo_surface_t *
|
2010-11-23 01:09:01 +00:00
|
|
|
|
gdk_offscreen_window_resize_cairo_surface (GdkWindow *window,
|
2010-10-05 13:21:40 +00:00
|
|
|
|
cairo_surface_t *surface,
|
|
|
|
|
gint width,
|
|
|
|
|
gint height)
|
|
|
|
|
{
|
|
|
|
|
/* No-op. The surface gets resized in
|
|
|
|
|
* gdk_offscreen_window_move_resize_internal().
|
|
|
|
|
*/
|
|
|
|
|
return surface;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-03 19:17:26 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_offscreen_window_set_embedder:
|
|
|
|
|
* @window: a #GdkWindow
|
|
|
|
|
* @embedder: the #GdkWindow that @window gets embedded in
|
|
|
|
|
*
|
2009-08-31 04:55:32 +00:00
|
|
|
|
* Sets @window to be embedded in @embedder.
|
|
|
|
|
*
|
|
|
|
|
* To fully embed an offscreen window, in addition to calling this
|
|
|
|
|
* function, it is also necessary to handle the #GdkWindow::pick-embedded-child
|
|
|
|
|
* signal on the @embedder and the #GdkWindow::to-embedder and
|
|
|
|
|
* #GdkWindow::from-embedder signals on @window.
|
|
|
|
|
*
|
2009-07-03 19:17:26 +00:00
|
|
|
|
* Since: 2.18
|
|
|
|
|
*/
|
2009-07-01 12:36:36 +00:00
|
|
|
|
void
|
|
|
|
|
gdk_offscreen_window_set_embedder (GdkWindow *window,
|
|
|
|
|
GdkWindow *embedder)
|
|
|
|
|
{
|
|
|
|
|
GdkOffscreenWindow *offscreen;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GDK_IS_WINDOW (window));
|
|
|
|
|
|
2010-11-22 23:55:39 +00:00
|
|
|
|
if (!GDK_IS_OFFSCREEN_WINDOW (window->impl))
|
2009-07-01 12:36:36 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2010-11-22 23:55:39 +00:00
|
|
|
|
offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
|
2009-07-01 12:36:36 +00:00
|
|
|
|
|
|
|
|
|
if (embedder)
|
|
|
|
|
{
|
|
|
|
|
g_object_ref (embedder);
|
2010-11-22 23:55:39 +00:00
|
|
|
|
embedder->num_offscreen_children++;
|
2009-07-01 12:36:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (offscreen->embedder)
|
|
|
|
|
{
|
|
|
|
|
g_object_unref (offscreen->embedder);
|
2010-11-22 23:55:39 +00:00
|
|
|
|
offscreen->embedder->num_offscreen_children--;
|
2009-07-01 12:36:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
offscreen->embedder = embedder;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-03 19:17:26 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_offscreen_window_get_embedder:
|
|
|
|
|
* @window: a #GdkWindow
|
|
|
|
|
*
|
|
|
|
|
* Gets the window that @window is embedded in.
|
|
|
|
|
*
|
2010-11-24 19:13:09 +00:00
|
|
|
|
* Returns: (transfer none): the embedding #GdkWindow, or %NULL
|
|
|
|
|
* if @window is not an mbedded offscreen window
|
2009-07-03 19:17:26 +00:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.18
|
|
|
|
|
*/
|
2009-07-01 12:36:36 +00:00
|
|
|
|
GdkWindow *
|
|
|
|
|
gdk_offscreen_window_get_embedder (GdkWindow *window)
|
|
|
|
|
{
|
|
|
|
|
GdkOffscreenWindow *offscreen;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
|
|
|
|
|
|
2010-11-22 23:55:39 +00:00
|
|
|
|
if (!GDK_IS_OFFSCREEN_WINDOW (window->impl))
|
2009-07-01 12:36:36 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
|
2010-11-22 23:55:39 +00:00
|
|
|
|
offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
|
2009-07-01 12:36:36 +00:00
|
|
|
|
|
|
|
|
|
return offscreen->embedder;
|
|
|
|
|
}
|
2008-12-15 13:55:53 +00:00
|
|
|
|
|
2008-07-18 13:03:42 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_offscreen_window_class_init (GdkOffscreenWindowClass *klass)
|
|
|
|
|
{
|
2010-11-22 19:42:00 +00:00
|
|
|
|
GdkWindowImplClass *impl_class = GDK_WINDOW_IMPL_CLASS (klass);
|
2008-07-18 13:03:42 +00:00
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
|
|
object_class->finalize = gdk_offscreen_window_finalize;
|
|
|
|
|
|
2010-11-23 00:46:03 +00:00
|
|
|
|
impl_class->ref_cairo_surface = gdk_offscreen_window_ref_cairo_surface;
|
2010-11-22 19:42:00 +00:00
|
|
|
|
impl_class->show = gdk_offscreen_window_show;
|
|
|
|
|
impl_class->hide = gdk_offscreen_window_hide;
|
|
|
|
|
impl_class->withdraw = gdk_offscreen_window_withdraw;
|
|
|
|
|
impl_class->raise = gdk_offscreen_window_raise;
|
|
|
|
|
impl_class->lower = gdk_offscreen_window_lower;
|
|
|
|
|
impl_class->move_resize = gdk_offscreen_window_move_resize;
|
|
|
|
|
impl_class->set_background = gdk_offscreen_window_set_background;
|
|
|
|
|
impl_class->get_events = gdk_offscreen_window_get_events;
|
|
|
|
|
impl_class->set_events = gdk_offscreen_window_set_events;
|
|
|
|
|
impl_class->reparent = gdk_offscreen_window_reparent;
|
|
|
|
|
impl_class->get_geometry = gdk_offscreen_window_get_geometry;
|
|
|
|
|
impl_class->shape_combine_region = gdk_offscreen_window_shape_combine_region;
|
|
|
|
|
impl_class->input_shape_combine_region = gdk_offscreen_window_input_shape_combine_region;
|
|
|
|
|
impl_class->set_static_gravities = gdk_offscreen_window_set_static_gravities;
|
|
|
|
|
impl_class->queue_antiexpose = gdk_offscreen_window_queue_antiexpose;
|
|
|
|
|
impl_class->translate = gdk_offscreen_window_translate;
|
|
|
|
|
impl_class->get_root_coords = gdk_offscreen_window_get_root_coords;
|
|
|
|
|
impl_class->get_device_state = gdk_offscreen_window_get_device_state;
|
|
|
|
|
impl_class->destroy = gdk_offscreen_window_destroy;
|
|
|
|
|
impl_class->resize_cairo_surface = gdk_offscreen_window_resize_cairo_surface;
|
2008-07-18 13:03:42 +00:00
|
|
|
|
}
|