2008-02-20 07:43:54 -05:00
|
|
|
/*
|
|
|
|
* Clutter.
|
|
|
|
*
|
|
|
|
* An OpenGL based 'interactive canvas' library.
|
|
|
|
*
|
|
|
|
* Authored By Johan Bilien <johan.bilien@nokia.com>
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 OpenedHand
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:clutter-x11-texture-pixmap
|
|
|
|
* @short_description: A texture which displays the content of an X Pixmap.
|
|
|
|
*
|
|
|
|
* #ClutterX11TexturePixmap is a class for displaying the content of an
|
|
|
|
* X Pixmap as a ClutterActor. Used together with the X Composite extension,
|
|
|
|
* it allows to display the content of X Windows inside Clutter.
|
|
|
|
*
|
|
|
|
* The class uses the GLX_EXT_texture_from_pixmap OpenGL extension
|
|
|
|
* (http://people.freedesktop.org/~davidr/GLX_EXT_texture_from_pixmap.txt)
|
|
|
|
* if available
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "../clutter-marshal.h"
|
|
|
|
#include "clutter-x11-texture-pixmap.h"
|
|
|
|
#include "clutter-x11.h"
|
|
|
|
#include "clutter-backend-x11.h"
|
|
|
|
|
2008-04-25 09:37:36 -04:00
|
|
|
#include "cogl/cogl.h"
|
2008-02-20 07:43:54 -05:00
|
|
|
|
2008-04-15 17:18:13 -04:00
|
|
|
#include <X11/extensions/Xdamage.h>
|
2008-06-30 10:36:49 -04:00
|
|
|
#include <X11/extensions/Xcomposite.h>
|
2008-04-15 17:18:13 -04:00
|
|
|
|
2008-04-29 12:30:47 -04:00
|
|
|
#include <sys/ipc.h>
|
|
|
|
#include <sys/shm.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <X11/extensions/XShm.h>
|
|
|
|
|
2008-02-20 07:43:54 -05:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_PIXMAP = 1,
|
|
|
|
PROP_PIXMAP_WIDTH,
|
|
|
|
PROP_PIXMAP_HEIGHT,
|
2008-04-15 17:18:13 -04:00
|
|
|
PROP_DEPTH,
|
2008-06-30 10:36:49 -04:00
|
|
|
PROP_AUTO,
|
|
|
|
PROP_WINDOW,
|
2008-09-16 07:50:38 -04:00
|
|
|
PROP_WINDOW_REDIRECT_AUTOMATIC,
|
|
|
|
PROP_WINDOW_MAPPED,
|
|
|
|
PROP_DESTROYED,
|
|
|
|
PROP_WINDOW_X,
|
|
|
|
PROP_WINDOW_Y,
|
|
|
|
PROP_WINDOW_OVERRIDE_REDIRECT
|
2008-02-20 07:43:54 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
UPDATE_AREA,
|
2008-04-15 17:18:13 -04:00
|
|
|
/* FIXME: Pixmap lost signal? */
|
2008-02-20 07:43:54 -05:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2008-09-16 07:50:38 -04:00
|
|
|
static ClutterX11FilterReturn
|
2008-04-15 17:18:13 -04:00
|
|
|
on_x_event_filter (XEvent *xev, ClutterEvent *cev, gpointer data);
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_x11_texture_pixmap_update_area_real (ClutterX11TexturePixmap *texture,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height);
|
2008-09-16 07:50:38 -04:00
|
|
|
static void
|
|
|
|
clutter_x11_texture_pixmap_set_mapped (ClutterX11TexturePixmap *texture, gboolean mapped);
|
|
|
|
static void
|
|
|
|
clutter_x11_texture_pixmap_destroyed (ClutterX11TexturePixmap *texture);
|
2008-04-15 17:18:13 -04:00
|
|
|
|
2008-02-20 07:43:54 -05:00
|
|
|
static guint signals[LAST_SIGNAL] = { 0, };
|
|
|
|
|
|
|
|
struct _ClutterX11TexturePixmapPrivate
|
|
|
|
{
|
2008-06-30 10:36:49 -04:00
|
|
|
Window window;
|
2008-02-20 07:43:54 -05:00
|
|
|
Pixmap pixmap;
|
|
|
|
guint pixmap_width, pixmap_height;
|
|
|
|
guint depth;
|
|
|
|
|
|
|
|
XImage *image;
|
2008-04-29 12:30:47 -04:00
|
|
|
XShmSegmentInfo shminfo;
|
2008-02-20 07:43:54 -05:00
|
|
|
|
2008-09-16 07:50:38 -04:00
|
|
|
gboolean automatic_updates;
|
2008-04-15 17:18:13 -04:00
|
|
|
Damage damage;
|
2008-06-30 10:36:49 -04:00
|
|
|
Drawable damage_drawable;
|
2008-04-15 17:18:13 -04:00
|
|
|
|
2008-09-16 07:50:38 -04:00
|
|
|
/* FIXME: lots of gbooleans. coalesce into bitfields */
|
2008-04-29 12:30:47 -04:00
|
|
|
gboolean have_shm;
|
2008-06-30 10:36:49 -04:00
|
|
|
gboolean window_redirect_automatic;
|
2008-09-16 07:50:38 -04:00
|
|
|
gboolean window_mapped;
|
|
|
|
gboolean destroyed;
|
|
|
|
gboolean owns_pixmap;
|
|
|
|
gboolean override_redirect;
|
|
|
|
gint window_x, window_y;
|
2008-02-20 07:43:54 -05:00
|
|
|
};
|
|
|
|
|
2008-04-15 17:18:13 -04:00
|
|
|
static int _damage_event_base = 0;
|
2008-02-20 07:43:54 -05:00
|
|
|
|
2008-04-15 17:18:13 -04:00
|
|
|
/* FIXME: Ultimatly with current cogl we should subclass clutter actor */
|
|
|
|
G_DEFINE_TYPE (ClutterX11TexturePixmap, \
|
|
|
|
clutter_x11_texture_pixmap, \
|
|
|
|
CLUTTER_TYPE_TEXTURE);
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
check_extensions (ClutterX11TexturePixmap *texture)
|
2008-02-20 07:43:54 -05:00
|
|
|
{
|
2008-04-15 17:18:13 -04:00
|
|
|
int damage_error;
|
|
|
|
ClutterX11TexturePixmapPrivate *priv;
|
|
|
|
Display *dpy;
|
2008-02-20 07:43:54 -05:00
|
|
|
|
2008-04-15 17:18:13 -04:00
|
|
|
priv = texture->priv;
|
2008-02-20 07:43:54 -05:00
|
|
|
|
2008-04-15 17:18:13 -04:00
|
|
|
if (_damage_event_base)
|
|
|
|
return TRUE;
|
2008-02-20 07:43:54 -05:00
|
|
|
|
2008-04-15 17:18:13 -04:00
|
|
|
dpy = clutter_x11_get_default_display();
|
2008-02-20 07:43:54 -05:00
|
|
|
|
2008-04-15 17:18:13 -04:00
|
|
|
if (!XDamageQueryExtension (dpy,
|
|
|
|
&_damage_event_base, &damage_error))
|
|
|
|
{
|
2008-06-30 12:06:36 -04:00
|
|
|
g_warning ("No Damage extension");
|
2008-04-15 17:18:13 -04:00
|
|
|
return FALSE;
|
|
|
|
}
|
2008-02-20 07:43:54 -05:00
|
|
|
|
2008-04-15 17:18:13 -04:00
|
|
|
return TRUE;
|
|
|
|
}
|
2008-02-20 07:43:54 -05:00
|
|
|
|
2008-04-29 12:30:47 -04:00
|
|
|
static void
|
|
|
|
free_shm_resources (ClutterX11TexturePixmap *texture)
|
|
|
|
{
|
|
|
|
ClutterX11TexturePixmapPrivate *priv;
|
|
|
|
|
|
|
|
priv = texture->priv;
|
|
|
|
|
|
|
|
if (priv->shminfo.shmid != -1)
|
|
|
|
{
|
|
|
|
XShmDetach(clutter_x11_get_default_display(),
|
|
|
|
&priv->shminfo);
|
|
|
|
shmdt(priv->shminfo.shmaddr);
|
|
|
|
shmctl(priv->shminfo.shmid, IPC_RMID, 0);
|
|
|
|
priv->shminfo.shmid = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Tries to allocate enough shared mem to handle a full size
|
|
|
|
* update size of the X Pixmap. */
|
|
|
|
static gboolean
|
|
|
|
try_alloc_shm (ClutterX11TexturePixmap *texture)
|
|
|
|
{
|
|
|
|
ClutterX11TexturePixmapPrivate *priv;
|
|
|
|
XImage *dummy_image;
|
|
|
|
Display *dpy;
|
|
|
|
|
|
|
|
priv = texture->priv;
|
|
|
|
dpy = clutter_x11_get_default_display();
|
|
|
|
|
|
|
|
g_return_val_if_fail (priv->pixmap, FALSE);
|
|
|
|
|
|
|
|
if (!XShmQueryExtension(dpy) || g_getenv("CLUTTER_X11_NO_SHM"))
|
|
|
|
{
|
|
|
|
priv->have_shm = FALSE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
clutter_x11_trap_x_errors ();
|
|
|
|
|
|
|
|
/* We are creating a dummy_image so we can have Xlib calculate
|
|
|
|
* image->bytes_per_line - including any magic padding it may
|
|
|
|
* want - for the largest possible ximage we might need to use
|
|
|
|
* when handling updates to the texture.
|
|
|
|
*
|
|
|
|
* Note: we pass a NULL shminfo here, but that has no bearing
|
|
|
|
* on the setup of the XImage, except that ximage->obdata will
|
|
|
|
* == NULL.
|
|
|
|
*/
|
|
|
|
dummy_image =
|
|
|
|
XShmCreateImage(dpy,
|
|
|
|
DefaultVisual(dpy,
|
|
|
|
clutter_x11_get_default_screen()),
|
|
|
|
priv->depth,
|
|
|
|
ZPixmap,
|
|
|
|
NULL,
|
|
|
|
NULL, /* shminfo, */
|
|
|
|
priv->pixmap_width,
|
|
|
|
priv->pixmap_height);
|
|
|
|
if (!dummy_image)
|
|
|
|
goto failed_image_create;
|
|
|
|
|
|
|
|
priv->shminfo.shmid = shmget (IPC_PRIVATE,
|
|
|
|
dummy_image->bytes_per_line
|
|
|
|
* dummy_image->height,
|
|
|
|
IPC_CREAT|0777);
|
|
|
|
if (priv->shminfo.shmid == -1)
|
|
|
|
goto failed_shmget;
|
|
|
|
|
|
|
|
priv->shminfo.shmaddr =
|
|
|
|
shmat (priv->shminfo.shmid, 0, 0);
|
|
|
|
if (priv->shminfo.shmaddr == (void *)-1)
|
|
|
|
goto failed_shmat;
|
|
|
|
|
|
|
|
priv->shminfo.readOnly = False;
|
|
|
|
|
|
|
|
if (XShmAttach(dpy, &priv->shminfo) == 0)
|
|
|
|
goto failed_xshmattach;
|
|
|
|
|
|
|
|
if (clutter_x11_untrap_x_errors ())
|
2008-06-30 12:06:36 -04:00
|
|
|
g_warning ("X Error: Failed to setup XShm");
|
2008-04-29 12:30:47 -04:00
|
|
|
|
|
|
|
priv->have_shm = TRUE;
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
failed_xshmattach:
|
|
|
|
g_warning ("XShmAttach failed");
|
|
|
|
shmdt(priv->shminfo.shmaddr);
|
|
|
|
failed_shmat:
|
|
|
|
g_warning ("shmat failed");
|
|
|
|
shmctl(priv->shminfo.shmid, IPC_RMID, 0);
|
|
|
|
failed_shmget:
|
|
|
|
g_warning ("shmget failed");
|
|
|
|
XDestroyImage(dummy_image);
|
|
|
|
failed_image_create:
|
|
|
|
|
|
|
|
if (clutter_x11_untrap_x_errors ())
|
2008-06-30 12:06:36 -04:00
|
|
|
g_warning ("X Error: Failed to setup XShm");
|
2008-04-29 12:30:47 -04:00
|
|
|
|
|
|
|
priv->have_shm = FALSE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-09-16 07:50:38 -04:00
|
|
|
static ClutterX11FilterReturn
|
2008-04-15 17:18:13 -04:00
|
|
|
on_x_event_filter (XEvent *xev, ClutterEvent *cev, gpointer data)
|
|
|
|
{
|
|
|
|
ClutterX11TexturePixmap *texture;
|
|
|
|
ClutterX11TexturePixmapPrivate *priv;
|
|
|
|
Display *dpy;
|
2008-02-20 07:43:54 -05:00
|
|
|
|
2008-04-15 17:18:13 -04:00
|
|
|
texture = CLUTTER_X11_TEXTURE_PIXMAP (data);
|
2008-09-16 07:50:38 -04:00
|
|
|
|
2008-04-15 17:18:13 -04:00
|
|
|
g_return_val_if_fail (CLUTTER_X11_IS_TEXTURE_PIXMAP (texture), \
|
|
|
|
CLUTTER_X11_FILTER_CONTINUE);
|
2008-02-20 07:43:54 -05:00
|
|
|
|
2008-04-15 17:18:13 -04:00
|
|
|
dpy = clutter_x11_get_default_display();
|
|
|
|
priv = texture->priv;
|
2008-09-16 07:50:38 -04:00
|
|
|
|
2008-04-15 17:18:13 -04:00
|
|
|
if (xev->type == _damage_event_base + XDamageNotify)
|
|
|
|
{
|
|
|
|
XserverRegion parts;
|
|
|
|
gint i, r_count;
|
|
|
|
XRectangle *r_damage;
|
|
|
|
XRectangle r_bounds;
|
|
|
|
XDamageNotifyEvent *dev = (XDamageNotifyEvent*)xev;
|
2008-09-16 07:50:38 -04:00
|
|
|
|
2008-06-30 10:36:49 -04:00
|
|
|
if (dev->drawable != priv->damage_drawable)
|
2008-04-15 17:18:13 -04:00
|
|
|
return CLUTTER_X11_FILTER_CONTINUE;
|
|
|
|
|
|
|
|
|
|
|
|
clutter_x11_trap_x_errors ();
|
|
|
|
/*
|
|
|
|
* Retrieve the damaged region and break it down into individual
|
|
|
|
* rectangles so we do not have to update the whole shebang.
|
|
|
|
*/
|
|
|
|
parts = XFixesCreateRegion (dpy, 0, 0);
|
|
|
|
XDamageSubtract (dpy, priv->damage, None, parts);
|
|
|
|
|
2008-09-16 07:50:38 -04:00
|
|
|
r_damage = XFixesFetchRegionAndBounds (dpy,
|
2008-04-15 17:18:13 -04:00
|
|
|
parts,
|
|
|
|
&r_count,
|
|
|
|
&r_bounds);
|
|
|
|
|
|
|
|
clutter_x11_untrap_x_errors ();
|
|
|
|
|
|
|
|
if (r_damage)
|
|
|
|
{
|
|
|
|
for (i = 0; i < r_count; ++i)
|
|
|
|
clutter_x11_texture_pixmap_update_area (texture,
|
|
|
|
r_damage[i].x,
|
|
|
|
r_damage[i].y,
|
|
|
|
r_damage[i].width,
|
|
|
|
r_damage[i].height);
|
|
|
|
XFree (r_damage);
|
|
|
|
}
|
2008-02-20 07:43:54 -05:00
|
|
|
|
2008-04-15 17:18:13 -04:00
|
|
|
XFixesDestroyRegion (dpy, parts);
|
|
|
|
}
|
2008-02-20 07:43:54 -05:00
|
|
|
|
2008-04-15 17:18:13 -04:00
|
|
|
return CLUTTER_X11_FILTER_CONTINUE;
|
|
|
|
}
|
2008-02-20 07:43:54 -05:00
|
|
|
|
2008-09-16 07:50:38 -04:00
|
|
|
static ClutterX11FilterReturn
|
|
|
|
on_x_event_filter_too (XEvent *xev, ClutterEvent *cev, gpointer data)
|
|
|
|
{
|
|
|
|
ClutterX11TexturePixmap *texture;
|
|
|
|
ClutterX11TexturePixmapPrivate *priv;
|
|
|
|
|
|
|
|
texture = CLUTTER_X11_TEXTURE_PIXMAP (data);
|
|
|
|
|
|
|
|
g_return_val_if_fail (CLUTTER_X11_IS_TEXTURE_PIXMAP (texture), \
|
|
|
|
CLUTTER_X11_FILTER_CONTINUE);
|
|
|
|
|
|
|
|
priv = texture->priv;
|
|
|
|
|
|
|
|
if (xev->xany.window != priv->window)
|
|
|
|
return CLUTTER_X11_FILTER_CONTINUE;
|
|
|
|
|
|
|
|
switch (xev->type) {
|
|
|
|
case MapNotify:
|
|
|
|
case ConfigureNotify:
|
|
|
|
clutter_x11_texture_pixmap_sync_window (texture);
|
|
|
|
break;
|
|
|
|
case UnmapNotify:
|
|
|
|
clutter_x11_texture_pixmap_set_mapped (texture, FALSE);
|
|
|
|
break;
|
|
|
|
case DestroyNotify:
|
|
|
|
clutter_x11_texture_pixmap_destroyed (texture);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CLUTTER_X11_FILTER_CONTINUE;
|
|
|
|
}
|
|
|
|
|
2008-02-20 07:43:54 -05:00
|
|
|
|
2008-04-15 17:18:13 -04:00
|
|
|
static void
|
|
|
|
free_damage_resources (ClutterX11TexturePixmap *texture)
|
|
|
|
{
|
|
|
|
ClutterX11TexturePixmapPrivate *priv;
|
|
|
|
Display *dpy;
|
|
|
|
|
|
|
|
priv = texture->priv;
|
|
|
|
dpy = clutter_x11_get_default_display();
|
|
|
|
|
|
|
|
if (priv->damage)
|
2008-02-20 07:43:54 -05:00
|
|
|
{
|
2008-05-06 15:57:05 -04:00
|
|
|
clutter_x11_trap_x_errors ();
|
2008-04-15 17:18:13 -04:00
|
|
|
XDamageDestroy (dpy, priv->damage);
|
2008-05-06 15:57:05 -04:00
|
|
|
XSync (dpy, FALSE);
|
|
|
|
clutter_x11_untrap_x_errors ();
|
2008-04-15 17:18:13 -04:00
|
|
|
priv->damage = None;
|
2008-06-30 10:36:49 -04:00
|
|
|
priv->damage_drawable = None;
|
2008-02-20 07:43:54 -05:00
|
|
|
}
|
|
|
|
|
2008-04-15 17:18:13 -04:00
|
|
|
clutter_x11_remove_filter (on_x_event_filter, (gpointer)texture);
|
2008-02-20 07:43:54 -05:00
|
|
|
}
|
|
|
|
|
2008-04-15 17:18:13 -04:00
|
|
|
|
2008-02-20 07:43:54 -05:00
|
|
|
static void
|
|
|
|
clutter_x11_texture_pixmap_init (ClutterX11TexturePixmap *self)
|
|
|
|
{
|
|
|
|
self->priv =
|
|
|
|
G_TYPE_INSTANCE_GET_PRIVATE (self,
|
|
|
|
CLUTTER_X11_TYPE_TEXTURE_PIXMAP,
|
|
|
|
ClutterX11TexturePixmapPrivate);
|
|
|
|
|
2008-04-15 17:18:13 -04:00
|
|
|
if (!check_extensions (self))
|
|
|
|
{
|
2008-09-16 07:50:38 -04:00
|
|
|
/* FIMXE: means display lacks needed extensions for at least auto.
|
2008-04-15 17:18:13 -04:00
|
|
|
* - a _can_autoupdate() method ?
|
|
|
|
*/
|
|
|
|
}
|
2008-02-20 07:43:54 -05:00
|
|
|
|
2008-04-29 12:30:47 -04:00
|
|
|
self->priv->image = NULL;
|
|
|
|
self->priv->automatic_updates = FALSE;
|
|
|
|
self->priv->damage = None;
|
2008-06-30 10:36:49 -04:00
|
|
|
self->priv->damage_drawable = None;
|
|
|
|
self->priv->window = None;
|
2008-04-29 12:30:47 -04:00
|
|
|
self->priv->pixmap = None;
|
2008-06-30 10:36:49 -04:00
|
|
|
self->priv->pixmap_height = 0;
|
|
|
|
self->priv->pixmap_width = 0;
|
2008-04-29 12:30:47 -04:00
|
|
|
self->priv->shminfo.shmid = -1;
|
2008-06-30 10:36:49 -04:00
|
|
|
self->priv->window_redirect_automatic = TRUE;
|
2008-09-16 07:50:38 -04:00
|
|
|
self->priv->window_mapped = FALSE;
|
|
|
|
self->priv->destroyed = FALSE;
|
|
|
|
self->priv->override_redirect = FALSE;
|
|
|
|
self->priv->window_x = 0;
|
|
|
|
self->priv->window_y = 0;
|
2008-02-20 07:43:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_x11_texture_pixmap_dispose (GObject *object)
|
|
|
|
{
|
2008-04-15 17:18:13 -04:00
|
|
|
ClutterX11TexturePixmap *texture = CLUTTER_X11_TEXTURE_PIXMAP (object);
|
2008-02-20 07:43:54 -05:00
|
|
|
ClutterX11TexturePixmapPrivate *priv = texture->priv;
|
|
|
|
|
2008-04-15 17:18:13 -04:00
|
|
|
free_damage_resources (texture);
|
|
|
|
|
2008-09-16 07:50:38 -04:00
|
|
|
clutter_x11_remove_filter (on_x_event_filter_too, (gpointer)texture);
|
|
|
|
|
|
|
|
if (priv->owns_pixmap && priv->pixmap)
|
|
|
|
{
|
|
|
|
XFreePixmap (clutter_x11_get_default_display (), priv->pixmap);
|
|
|
|
priv->pixmap = None;
|
|
|
|
}
|
|
|
|
|
2008-02-20 07:43:54 -05:00
|
|
|
if (priv->image)
|
|
|
|
{
|
|
|
|
XDestroyImage (priv->image);
|
|
|
|
priv->image = NULL;
|
|
|
|
}
|
|
|
|
|
2008-04-29 12:30:47 -04:00
|
|
|
free_shm_resources (texture);
|
|
|
|
|
2008-02-20 07:43:54 -05:00
|
|
|
G_OBJECT_CLASS (clutter_x11_texture_pixmap_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_x11_texture_pixmap_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2008-04-15 17:18:13 -04:00
|
|
|
ClutterX11TexturePixmap *texture = CLUTTER_X11_TEXTURE_PIXMAP (object);
|
2008-06-30 10:36:49 -04:00
|
|
|
ClutterX11TexturePixmapPrivate *priv = texture->priv;
|
2008-02-20 07:43:54 -05:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_PIXMAP:
|
2008-04-15 17:18:13 -04:00
|
|
|
clutter_x11_texture_pixmap_set_pixmap (texture,
|
2009-01-16 18:01:04 -05:00
|
|
|
g_value_get_ulong (value));
|
2008-04-15 17:18:13 -04:00
|
|
|
break;
|
|
|
|
case PROP_AUTO:
|
|
|
|
clutter_x11_texture_pixmap_set_automatic (texture,
|
|
|
|
g_value_get_boolean (value));
|
|
|
|
break;
|
2008-06-30 10:36:49 -04:00
|
|
|
case PROP_WINDOW:
|
|
|
|
clutter_x11_texture_pixmap_set_window (texture,
|
2009-01-29 07:25:18 -05:00
|
|
|
g_value_get_ulong (value),
|
2008-06-30 10:36:49 -04:00
|
|
|
priv->window_redirect_automatic);
|
|
|
|
break;
|
|
|
|
case PROP_WINDOW_REDIRECT_AUTOMATIC:
|
|
|
|
{
|
|
|
|
gboolean new;
|
|
|
|
new = g_value_get_boolean (value);
|
|
|
|
|
|
|
|
/* Change the update mode.. */
|
|
|
|
if (new != priv->window_redirect_automatic && priv->window)
|
|
|
|
clutter_x11_texture_pixmap_set_window (texture, priv->window, new);
|
|
|
|
|
|
|
|
priv->window_redirect_automatic = new;
|
|
|
|
}
|
|
|
|
break;
|
2008-02-20 07:43:54 -05:00
|
|
|
default:
|
2008-04-15 17:18:13 -04:00
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
2008-02-20 07:43:54 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_x11_texture_pixmap_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2008-04-15 17:18:13 -04:00
|
|
|
ClutterX11TexturePixmap *texture = CLUTTER_X11_TEXTURE_PIXMAP (object);
|
2008-02-20 07:43:54 -05:00
|
|
|
ClutterX11TexturePixmapPrivate *priv = texture->priv;
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_PIXMAP:
|
2009-01-16 18:01:04 -05:00
|
|
|
g_value_set_ulong (value, priv->pixmap);
|
2008-04-15 17:18:13 -04:00
|
|
|
break;
|
2008-02-20 07:43:54 -05:00
|
|
|
case PROP_PIXMAP_WIDTH:
|
2008-04-15 17:18:13 -04:00
|
|
|
g_value_set_uint (value, priv->pixmap_width);
|
|
|
|
break;
|
2008-02-20 07:43:54 -05:00
|
|
|
case PROP_PIXMAP_HEIGHT:
|
2008-04-15 17:18:13 -04:00
|
|
|
g_value_set_uint (value, priv->pixmap_height);
|
|
|
|
break;
|
2008-02-20 07:43:54 -05:00
|
|
|
case PROP_DEPTH:
|
2008-04-15 17:18:13 -04:00
|
|
|
g_value_set_uint (value, priv->depth);
|
|
|
|
break;
|
|
|
|
case PROP_AUTO:
|
|
|
|
g_value_set_boolean (value, priv->automatic_updates);
|
|
|
|
break;
|
2008-06-30 10:36:49 -04:00
|
|
|
case PROP_WINDOW:
|
2009-01-29 07:25:18 -05:00
|
|
|
g_value_set_ulong (value, priv->window);
|
2008-06-30 10:36:49 -04:00
|
|
|
break;
|
|
|
|
case PROP_WINDOW_REDIRECT_AUTOMATIC:
|
|
|
|
g_value_set_boolean (value, priv->window_redirect_automatic);
|
|
|
|
break;
|
2008-09-16 07:50:38 -04:00
|
|
|
case PROP_WINDOW_MAPPED:
|
|
|
|
g_value_set_boolean (value, priv->window_mapped);
|
|
|
|
break;
|
|
|
|
case PROP_DESTROYED:
|
|
|
|
g_value_set_boolean (value, priv->destroyed);
|
|
|
|
break;
|
|
|
|
case PROP_WINDOW_X:
|
|
|
|
g_value_set_int (value, priv->window_x);
|
|
|
|
break;
|
|
|
|
case PROP_WINDOW_Y:
|
|
|
|
g_value_set_int (value, priv->window_y);
|
|
|
|
break;
|
|
|
|
case PROP_WINDOW_OVERRIDE_REDIRECT:
|
|
|
|
g_value_set_boolean (value, priv->override_redirect);
|
|
|
|
break;
|
2008-02-20 07:43:54 -05:00
|
|
|
default:
|
2008-04-15 17:18:13 -04:00
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
2008-02-20 07:43:54 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_x11_texture_pixmap_realize (ClutterActor *actor)
|
|
|
|
{
|
|
|
|
ClutterX11TexturePixmap *texture = CLUTTER_X11_TEXTURE_PIXMAP (actor);
|
|
|
|
ClutterX11TexturePixmapPrivate *priv = texture->priv;
|
|
|
|
|
|
|
|
CLUTTER_ACTOR_CLASS (clutter_x11_texture_pixmap_parent_class)->
|
|
|
|
realize (actor);
|
|
|
|
|
|
|
|
clutter_x11_texture_pixmap_update_area_real (texture,
|
|
|
|
0, 0,
|
|
|
|
priv->pixmap_width,
|
|
|
|
priv->pixmap_height);
|
|
|
|
}
|
|
|
|
|
2008-04-15 17:18:13 -04:00
|
|
|
static void
|
|
|
|
clutter_x11_texture_pixmap_class_init (ClutterX11TexturePixmapClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
|
|
|
GParamSpec *pspec;
|
|
|
|
ClutterBackend *default_backend;
|
|
|
|
|
|
|
|
g_type_class_add_private (klass, sizeof (ClutterX11TexturePixmapPrivate));
|
|
|
|
|
|
|
|
object_class->dispose = clutter_x11_texture_pixmap_dispose;
|
|
|
|
object_class->set_property = clutter_x11_texture_pixmap_set_property;
|
|
|
|
object_class->get_property = clutter_x11_texture_pixmap_get_property;
|
|
|
|
|
|
|
|
actor_class->realize = clutter_x11_texture_pixmap_realize;
|
|
|
|
|
|
|
|
klass->update_area = clutter_x11_texture_pixmap_update_area_real;
|
|
|
|
|
2009-01-16 18:01:04 -05:00
|
|
|
pspec = g_param_spec_ulong ("pixmap",
|
|
|
|
"Pixmap",
|
|
|
|
"The X11 Pixmap to be bound",
|
|
|
|
0, G_MAXULONG,
|
|
|
|
None,
|
|
|
|
G_PARAM_READWRITE);
|
2008-04-15 17:18:13 -04:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_PIXMAP, pspec);
|
|
|
|
|
|
|
|
pspec = g_param_spec_uint ("pixmap-width",
|
|
|
|
"Pixmap width",
|
|
|
|
"The width of the "
|
|
|
|
"pixmap bound to this texture",
|
|
|
|
0, G_MAXUINT,
|
|
|
|
0,
|
|
|
|
G_PARAM_READABLE);
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_PIXMAP_WIDTH, pspec);
|
|
|
|
|
|
|
|
pspec = g_param_spec_uint ("pixmap-height",
|
|
|
|
"Pixmap height",
|
|
|
|
"The height of the "
|
|
|
|
"pixmap bound to this texture",
|
|
|
|
0, G_MAXUINT,
|
|
|
|
0,
|
|
|
|
G_PARAM_READABLE);
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_PIXMAP_HEIGHT, pspec);
|
|
|
|
|
|
|
|
pspec = g_param_spec_uint ("pixmap-depth",
|
|
|
|
"Pixmap Depth",
|
|
|
|
"The depth (in number of bits) of the "
|
|
|
|
"pixmap bound to this texture",
|
|
|
|
0, G_MAXUINT,
|
|
|
|
0,
|
|
|
|
G_PARAM_READABLE);
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_DEPTH, pspec);
|
|
|
|
|
|
|
|
pspec = g_param_spec_boolean ("automatic-updates",
|
|
|
|
"Automatic Updates",
|
|
|
|
"If the texture should be kept in "
|
|
|
|
"sync with any pixmap changes.",
|
|
|
|
FALSE,
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_AUTO, pspec);
|
|
|
|
|
2009-01-16 18:01:04 -05:00
|
|
|
pspec = g_param_spec_ulong ("window",
|
|
|
|
"Window",
|
|
|
|
"The X11 Window to be bound",
|
|
|
|
0, G_MAXULONG,
|
|
|
|
None,
|
|
|
|
G_PARAM_READWRITE);
|
2008-06-30 10:36:49 -04:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_WINDOW, pspec);
|
|
|
|
|
|
|
|
pspec = g_param_spec_boolean ("window-redirect-automatic",
|
|
|
|
"Window Redirect Automatic",
|
|
|
|
"If composite window redirects are set to "
|
|
|
|
"Automatic (or Manual if false)",
|
|
|
|
TRUE,
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
|
2008-09-16 07:50:38 -04:00
|
|
|
g_object_class_install_property (object_class,
|
2008-06-30 10:36:49 -04:00
|
|
|
PROP_WINDOW_REDIRECT_AUTOMATIC, pspec);
|
|
|
|
|
2008-04-15 17:18:13 -04:00
|
|
|
|
2008-09-16 07:50:38 -04:00
|
|
|
pspec = g_param_spec_boolean ("window-mapped",
|
|
|
|
"Window Mapped",
|
|
|
|
"If window is mapped",
|
|
|
|
FALSE,
|
|
|
|
G_PARAM_READABLE);
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_WINDOW_MAPPED, pspec);
|
|
|
|
|
|
|
|
|
|
|
|
pspec = g_param_spec_boolean ("destroyed",
|
|
|
|
"Destroyed",
|
|
|
|
"If window has been destroyed",
|
|
|
|
FALSE,
|
|
|
|
G_PARAM_READABLE);
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_DESTROYED, pspec);
|
|
|
|
|
|
|
|
pspec = g_param_spec_int ("window-x",
|
|
|
|
"Window X",
|
|
|
|
"X position of window on screen according to X11",
|
|
|
|
G_MININT, G_MAXINT, 0, G_PARAM_READABLE);
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_WINDOW_X, pspec);
|
|
|
|
|
|
|
|
|
|
|
|
pspec = g_param_spec_int ("window-y",
|
|
|
|
"Window Y",
|
|
|
|
"Y position of window on screen according to X11",
|
|
|
|
G_MININT, G_MAXINT, 0, G_PARAM_READABLE);
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_WINDOW_Y, pspec);
|
|
|
|
|
|
|
|
pspec = g_param_spec_boolean ("window-override-redirect",
|
|
|
|
"Window Override Redirect",
|
|
|
|
"If this is an override-redirect window",
|
|
|
|
FALSE,
|
|
|
|
G_PARAM_READABLE);
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_WINDOW_OVERRIDE_REDIRECT, pspec);
|
|
|
|
|
|
|
|
|
2008-04-15 17:18:13 -04:00
|
|
|
/**
|
|
|
|
* ClutterX11TexturePixmap::update-area:
|
|
|
|
* @texture: the object which received the signal
|
|
|
|
*
|
|
|
|
* The ::hide signal is emitted to ask the texture to update its
|
|
|
|
* content from its source pixmap.
|
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
*/
|
|
|
|
signals[UPDATE_AREA] =
|
|
|
|
g_signal_new ("update-area",
|
|
|
|
G_TYPE_FROM_CLASS (object_class),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (ClutterX11TexturePixmapClass, \
|
|
|
|
update_area),
|
|
|
|
NULL, NULL,
|
|
|
|
clutter_marshal_VOID__INT_INT_INT_INT,
|
|
|
|
G_TYPE_NONE, 4,
|
|
|
|
G_TYPE_INT,
|
|
|
|
G_TYPE_INT,
|
|
|
|
G_TYPE_INT,
|
|
|
|
G_TYPE_INT);
|
|
|
|
|
|
|
|
default_backend = clutter_get_default_backend ();
|
|
|
|
|
|
|
|
if (!CLUTTER_IS_BACKEND_X11 (default_backend))
|
|
|
|
{
|
|
|
|
g_critical ("ClutterX11TexturePixmap instanciated with a "
|
|
|
|
"non-X11 backend");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-20 07:43:54 -05:00
|
|
|
static void
|
|
|
|
clutter_x11_texture_pixmap_update_area_real (ClutterX11TexturePixmap *texture,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height)
|
|
|
|
{
|
|
|
|
ClutterX11TexturePixmapPrivate *priv;
|
|
|
|
Display *dpy;
|
|
|
|
XImage *image;
|
2008-04-29 12:30:47 -04:00
|
|
|
char *first_pixel;
|
2008-02-20 07:43:54 -05:00
|
|
|
GError *error = NULL;
|
|
|
|
guint bytes_per_line;
|
2008-04-29 12:30:47 -04:00
|
|
|
char *data;
|
2008-02-20 07:43:54 -05:00
|
|
|
gboolean data_allocated = FALSE;
|
|
|
|
int err_code;
|
|
|
|
|
|
|
|
if (!CLUTTER_ACTOR_IS_REALIZED (texture))
|
|
|
|
return;
|
|
|
|
|
|
|
|
priv = texture->priv;
|
2008-04-15 17:18:13 -04:00
|
|
|
dpy = clutter_x11_get_default_display();
|
2008-02-20 07:43:54 -05:00
|
|
|
|
2008-04-25 09:37:36 -04:00
|
|
|
if (!priv->pixmap)
|
|
|
|
return;
|
|
|
|
|
2008-06-03 12:25:17 -04:00
|
|
|
if (priv->shminfo.shmid == -1)
|
2008-09-16 07:50:38 -04:00
|
|
|
try_alloc_shm (texture);
|
2008-06-03 12:25:17 -04:00
|
|
|
|
2008-02-20 07:43:54 -05:00
|
|
|
clutter_x11_trap_x_errors ();
|
2008-04-15 17:18:13 -04:00
|
|
|
|
2008-04-29 12:30:47 -04:00
|
|
|
if (priv->have_shm)
|
|
|
|
{
|
|
|
|
image =
|
|
|
|
XShmCreateImage(dpy,
|
|
|
|
DefaultVisual(dpy,
|
|
|
|
clutter_x11_get_default_screen()),
|
|
|
|
priv->depth,
|
|
|
|
ZPixmap,
|
|
|
|
NULL,
|
|
|
|
&priv->shminfo,
|
|
|
|
width,
|
|
|
|
height);
|
|
|
|
image->data = priv->shminfo.shmaddr;
|
|
|
|
|
|
|
|
XShmGetImage (dpy, priv->pixmap, image, x, y, AllPlanes);
|
|
|
|
first_pixel = image->data;
|
|
|
|
}
|
2008-02-20 07:43:54 -05:00
|
|
|
else
|
2008-04-29 12:30:47 -04:00
|
|
|
{
|
|
|
|
if (!priv->image)
|
|
|
|
{
|
|
|
|
priv->image = XGetImage (dpy,
|
|
|
|
priv->pixmap,
|
|
|
|
0, 0,
|
|
|
|
priv->pixmap_width, priv->pixmap_height,
|
|
|
|
AllPlanes,
|
|
|
|
ZPixmap);
|
|
|
|
first_pixel = priv->image->data + priv->image->bytes_per_line * y
|
|
|
|
+ x * priv->image->bits_per_pixel/8;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
XGetSubImage (dpy,
|
|
|
|
priv->pixmap,
|
|
|
|
x, y,
|
|
|
|
width, height,
|
|
|
|
AllPlanes,
|
|
|
|
ZPixmap,
|
|
|
|
priv->image,
|
|
|
|
x, y);
|
|
|
|
first_pixel = priv->image->data + priv->image->bytes_per_line * y
|
|
|
|
+ x * priv->image->bits_per_pixel/8;
|
|
|
|
}
|
|
|
|
image = priv->image;
|
|
|
|
}
|
2008-02-20 07:43:54 -05:00
|
|
|
|
|
|
|
XSync (dpy, FALSE);
|
2008-04-15 17:18:13 -04:00
|
|
|
|
2008-02-20 07:43:54 -05:00
|
|
|
if ((err_code = clutter_x11_untrap_x_errors ()))
|
2008-04-15 17:18:13 -04:00
|
|
|
{
|
2008-06-30 12:06:36 -04:00
|
|
|
g_warning ("Failed to get XImage of pixmap: %lx, removing",
|
2008-04-15 17:18:13 -04:00
|
|
|
priv->pixmap);
|
|
|
|
/* safe to assume pixmap has gone away? - therefor reset */
|
|
|
|
clutter_x11_texture_pixmap_set_pixmap (texture, None);
|
|
|
|
return;
|
|
|
|
}
|
2008-02-20 07:43:54 -05:00
|
|
|
|
|
|
|
if (priv->depth == 24)
|
|
|
|
{
|
2008-04-29 12:30:47 -04:00
|
|
|
guint xpos, ypos;
|
2008-02-20 07:43:54 -05:00
|
|
|
|
2008-04-29 12:30:47 -04:00
|
|
|
for (ypos=0; ypos<height; ypos++)
|
|
|
|
for (xpos=0; xpos<width; xpos++)
|
2008-02-20 07:43:54 -05:00
|
|
|
{
|
2008-04-29 12:30:47 -04:00
|
|
|
char *p = first_pixel + image->bytes_per_line*ypos
|
|
|
|
+ xpos * 4;
|
|
|
|
p[3] = 0xFF;
|
2008-02-20 07:43:54 -05:00
|
|
|
}
|
|
|
|
|
2008-04-29 12:30:47 -04:00
|
|
|
data = first_pixel;
|
2008-02-20 07:43:54 -05:00
|
|
|
bytes_per_line = image->bytes_per_line;
|
|
|
|
}
|
|
|
|
else if (priv->depth == 16)
|
|
|
|
{
|
2008-04-29 12:30:47 -04:00
|
|
|
guint xpos, ypos;
|
2008-02-20 07:43:54 -05:00
|
|
|
data = g_malloc (height * width * 4);
|
|
|
|
data_allocated = TRUE;
|
2008-04-29 12:30:47 -04:00
|
|
|
bytes_per_line = width * 4;
|
2008-02-20 07:43:54 -05:00
|
|
|
|
2008-04-29 12:30:47 -04:00
|
|
|
for (ypos=0; ypos<height; ypos++)
|
|
|
|
for (xpos=0; xpos<width; xpos++)
|
2008-02-20 07:43:54 -05:00
|
|
|
{
|
2008-04-29 12:30:47 -04:00
|
|
|
char *src_p = first_pixel + image->bytes_per_line * ypos
|
|
|
|
+ xpos * 2;
|
|
|
|
guint16 *src_pixel = (guint16 *)src_p;
|
|
|
|
char *dst_p = data + bytes_per_line * ypos + xpos * 4;
|
|
|
|
guint32 *dst_pixel = (guint32 *)dst_p;
|
|
|
|
|
|
|
|
*dst_pixel =
|
|
|
|
((((*src_pixel << 3) & 0xf8) | ((*src_pixel >> 2) & 0x7)) | \
|
|
|
|
(((*src_pixel << 5) & 0xfc00) | ((*src_pixel >> 1) & 0x300)) | \
|
2008-04-30 10:58:25 -04:00
|
|
|
(((*src_pixel << 8) & 0xf80000) | ((*src_pixel << 3) & 0x70000)))
|
|
|
|
| 0xff000000;
|
2008-04-29 12:30:47 -04:00
|
|
|
}
|
2008-02-20 07:43:54 -05:00
|
|
|
}
|
|
|
|
else if (priv->depth == 32)
|
|
|
|
{
|
|
|
|
bytes_per_line = image->bytes_per_line;
|
2008-04-29 12:30:47 -04:00
|
|
|
data = first_pixel;
|
2008-02-20 07:43:54 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
|
2008-04-30 10:58:25 -04:00
|
|
|
/* For debugging purposes, un comment to simply generate dummy
|
|
|
|
* pixmap data. (A Green background and Blue cross) */
|
|
|
|
#if 0
|
|
|
|
{
|
|
|
|
guint xpos, ypos;
|
|
|
|
|
|
|
|
if (data_allocated)
|
|
|
|
g_free (data);
|
|
|
|
data_allocated = TRUE;
|
|
|
|
data = g_malloc (width*height*4);
|
|
|
|
bytes_per_line = width *4;
|
|
|
|
|
|
|
|
for (ypos=0; ypos<height; ypos++)
|
|
|
|
for (xpos=0; xpos<width; xpos++)
|
|
|
|
{
|
|
|
|
char *p = data + width*4*ypos + xpos * 4;
|
|
|
|
guint32 *pixel = (guint32 *)p;
|
|
|
|
if ((xpos > width/2 && xpos <= (width/2) + width/4)
|
|
|
|
|| (ypos > height/2 && ypos <= (height/2) + height/4))
|
|
|
|
*pixel=0xff0000ff;
|
|
|
|
else
|
|
|
|
*pixel=0xff00ff00;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-02-20 07:43:54 -05:00
|
|
|
if (x != 0 || y != 0 ||
|
|
|
|
width != priv->pixmap_width || height != priv->pixmap_height)
|
|
|
|
clutter_texture_set_area_from_rgb_data (CLUTTER_TEXTURE (texture),
|
2008-04-29 12:30:47 -04:00
|
|
|
(guint8 *)data,
|
2008-02-20 07:43:54 -05:00
|
|
|
TRUE,
|
|
|
|
x, y,
|
|
|
|
width, height,
|
|
|
|
bytes_per_line,
|
|
|
|
4,
|
2009-05-09 14:39:01 -04:00
|
|
|
CLUTTER_TEXTURE_RGB_FLAG_BGR |
|
|
|
|
CLUTTER_TEXTURE_RGB_FLAG_PREMULT,
|
2008-02-20 07:43:54 -05:00
|
|
|
&error);
|
|
|
|
else
|
|
|
|
clutter_texture_set_from_rgb_data (CLUTTER_TEXTURE (texture),
|
2008-04-29 12:30:47 -04:00
|
|
|
(guint8 *)data,
|
2008-02-20 07:43:54 -05:00
|
|
|
TRUE,
|
|
|
|
width, height,
|
|
|
|
bytes_per_line,
|
|
|
|
4,
|
2009-05-09 14:39:01 -04:00
|
|
|
CLUTTER_TEXTURE_RGB_FLAG_BGR |
|
|
|
|
CLUTTER_TEXTURE_RGB_FLAG_PREMULT,
|
2008-02-20 07:43:54 -05:00
|
|
|
&error);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
g_warning ("Error when uploading from pixbuf: %s",
|
|
|
|
error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data_allocated)
|
|
|
|
g_free (data);
|
2008-04-29 12:30:47 -04:00
|
|
|
|
|
|
|
if (priv->have_shm)
|
|
|
|
XFree (image);
|
2008-02-20 07:43:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_x11_texture_pixmap_new:
|
|
|
|
*
|
|
|
|
* Return value: A new #ClutterX11TexturePixmap
|
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
**/
|
|
|
|
ClutterActor *
|
|
|
|
clutter_x11_texture_pixmap_new (void)
|
|
|
|
{
|
|
|
|
ClutterActor *actor;
|
|
|
|
|
|
|
|
actor = g_object_new (CLUTTER_X11_TYPE_TEXTURE_PIXMAP, NULL);
|
|
|
|
|
|
|
|
return actor;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_x11_texture_pixmap_new_with_pixmap:
|
|
|
|
* @pixmap: the X Pixmap to which this texture should be bound
|
|
|
|
*
|
|
|
|
* Return value: A new #ClutterX11TexturePixmap bound to the given X Pixmap
|
|
|
|
*
|
|
|
|
* Since 0.8
|
|
|
|
**/
|
|
|
|
ClutterActor *
|
2008-04-15 17:18:13 -04:00
|
|
|
clutter_x11_texture_pixmap_new_with_pixmap (Pixmap pixmap)
|
2008-02-20 07:43:54 -05:00
|
|
|
{
|
|
|
|
ClutterActor *actor;
|
|
|
|
|
|
|
|
actor = g_object_new (CLUTTER_X11_TYPE_TEXTURE_PIXMAP,
|
|
|
|
"pixmap", pixmap,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
return actor;
|
|
|
|
}
|
|
|
|
|
2008-06-30 10:36:49 -04:00
|
|
|
/**
|
|
|
|
* clutter_x11_texture_pixmap_new_with_window:
|
|
|
|
* @window: the X window to which this texture should be bound
|
|
|
|
*
|
|
|
|
* Return value: A new #ClutterX11TexturePixmap bound to the given X window.
|
|
|
|
*
|
|
|
|
* Since 0.8
|
|
|
|
**/
|
|
|
|
ClutterActor *
|
|
|
|
clutter_x11_texture_pixmap_new_with_window (Window window)
|
|
|
|
{
|
|
|
|
ClutterActor *actor;
|
|
|
|
|
|
|
|
actor = g_object_new (CLUTTER_X11_TYPE_TEXTURE_PIXMAP,
|
|
|
|
"window", window,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
return actor;
|
|
|
|
}
|
|
|
|
|
2008-02-20 07:43:54 -05:00
|
|
|
/**
|
|
|
|
* clutter_x11_texture_pixmap_set_pixmap:
|
|
|
|
* @texture: the texture to bind
|
|
|
|
* @pixmap: the X Pixmap to which the texture should be bound
|
|
|
|
*
|
|
|
|
* Sets the X Pixmap to which the texture should be bound.
|
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
clutter_x11_texture_pixmap_set_pixmap (ClutterX11TexturePixmap *texture,
|
2008-04-15 17:18:13 -04:00
|
|
|
Pixmap pixmap)
|
2008-02-20 07:43:54 -05:00
|
|
|
{
|
2008-04-15 17:18:13 -04:00
|
|
|
Window root;
|
2008-09-16 07:50:38 -04:00
|
|
|
int x, y;
|
2008-04-15 17:18:13 -04:00
|
|
|
unsigned int width, height, border_width, depth;
|
|
|
|
Status status = 0;
|
2008-04-29 12:30:47 -04:00
|
|
|
gboolean new_pixmap = FALSE, new_pixmap_width = FALSE;
|
|
|
|
gboolean new_pixmap_height = FALSE, new_pixmap_depth = FALSE;
|
2008-04-15 17:18:13 -04:00
|
|
|
|
2008-02-20 07:43:54 -05:00
|
|
|
ClutterX11TexturePixmapPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_X11_IS_TEXTURE_PIXMAP (texture));
|
|
|
|
|
|
|
|
priv = texture->priv;
|
|
|
|
|
2008-04-15 17:18:13 -04:00
|
|
|
clutter_x11_trap_x_errors ();
|
|
|
|
|
|
|
|
status = XGetGeometry (clutter_x11_get_default_display(),
|
2008-09-16 07:50:38 -04:00
|
|
|
(Drawable)pixmap,
|
2008-04-15 17:18:13 -04:00
|
|
|
&root,
|
2008-09-16 07:50:38 -04:00
|
|
|
&x,
|
|
|
|
&y,
|
2008-04-15 17:18:13 -04:00
|
|
|
&width,
|
2008-09-16 07:50:38 -04:00
|
|
|
&height,
|
2008-04-15 17:18:13 -04:00
|
|
|
&border_width,
|
|
|
|
&depth);
|
2008-09-16 07:50:38 -04:00
|
|
|
|
2008-04-15 17:18:13 -04:00
|
|
|
if (clutter_x11_untrap_x_errors () || status == 0)
|
|
|
|
{
|
|
|
|
if (pixmap != None)
|
2008-06-30 12:06:36 -04:00
|
|
|
g_warning ("Unable to query pixmap: %lx", pixmap);
|
2008-04-15 17:18:13 -04:00
|
|
|
pixmap = None;
|
2008-09-16 07:50:38 -04:00
|
|
|
width = height = depth = 0;
|
2008-04-15 17:18:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (priv->image)
|
|
|
|
{
|
|
|
|
XDestroyImage (priv->image);
|
|
|
|
priv->image = NULL;
|
|
|
|
}
|
2008-09-16 07:50:38 -04:00
|
|
|
|
2008-02-20 07:43:54 -05:00
|
|
|
if (priv->pixmap != pixmap)
|
|
|
|
{
|
2008-09-16 07:50:38 -04:00
|
|
|
if (priv->pixmap && priv->owns_pixmap)
|
|
|
|
XFreePixmap (clutter_x11_get_default_display (), priv->pixmap);
|
|
|
|
|
2008-02-20 07:43:54 -05:00
|
|
|
priv->pixmap = pixmap;
|
2008-04-29 12:30:47 -04:00
|
|
|
new_pixmap = TRUE;
|
2008-02-20 07:43:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (priv->pixmap_width != width)
|
|
|
|
{
|
|
|
|
priv->pixmap_width = width;
|
2008-04-29 12:30:47 -04:00
|
|
|
new_pixmap_width = TRUE;
|
2008-02-20 07:43:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (priv->pixmap_height != height)
|
|
|
|
{
|
|
|
|
priv->pixmap_height = height;
|
2008-04-29 12:30:47 -04:00
|
|
|
new_pixmap_height = TRUE;
|
2008-02-20 07:43:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (priv->depth != depth)
|
|
|
|
{
|
|
|
|
priv->depth = depth;
|
2008-04-29 12:30:47 -04:00
|
|
|
new_pixmap_depth = TRUE;
|
2008-02-20 07:43:54 -05:00
|
|
|
}
|
|
|
|
|
2008-04-29 12:30:47 -04:00
|
|
|
/* NB: We defer sending the signals until updating all the
|
|
|
|
* above members so the values are all available to the
|
|
|
|
* signal handlers. */
|
|
|
|
g_object_ref (texture);
|
|
|
|
if (new_pixmap)
|
|
|
|
g_object_notify (G_OBJECT (texture), "pixmap");
|
|
|
|
if (new_pixmap_width)
|
|
|
|
g_object_notify (G_OBJECT (texture), "pixmap-width");
|
|
|
|
if (new_pixmap_height)
|
|
|
|
g_object_notify (G_OBJECT (texture), "pixmap-height");
|
|
|
|
if (new_pixmap_depth)
|
|
|
|
g_object_notify (G_OBJECT (texture), "pixmap-depth");
|
2008-04-15 17:18:13 -04:00
|
|
|
|
2008-04-29 12:30:47 -04:00
|
|
|
free_shm_resources (texture);
|
|
|
|
|
2008-02-20 07:43:54 -05:00
|
|
|
if (priv->depth != 0 &&
|
|
|
|
priv->pixmap != None &&
|
|
|
|
priv->pixmap_width != 0 &&
|
|
|
|
priv->pixmap_height != 0)
|
|
|
|
{
|
|
|
|
if (CLUTTER_ACTOR_IS_REALIZED (texture))
|
|
|
|
clutter_x11_texture_pixmap_update_area (texture,
|
|
|
|
0, 0,
|
|
|
|
priv->pixmap_width,
|
|
|
|
priv->pixmap_height);
|
2008-06-03 12:25:17 -04:00
|
|
|
|
2008-06-30 10:36:49 -04:00
|
|
|
}
|
2008-09-16 07:50:38 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Keep ref until here in case a notify causes removal from the scene; can't
|
|
|
|
* lower the notifies because glx's notify handler needs to run before
|
|
|
|
* update_area
|
|
|
|
*/
|
|
|
|
g_object_unref (texture);
|
2008-06-30 10:36:49 -04:00
|
|
|
}
|
2008-06-03 12:25:17 -04:00
|
|
|
|
2008-06-30 10:36:49 -04:00
|
|
|
/**
|
|
|
|
* clutter_x11_texture_pixmap_set_window:
|
|
|
|
* @texture: the texture to bind
|
|
|
|
* @window: the X window to which the texture should be bound
|
|
|
|
* @automatic: TRUE is automatic window updates, FALSE for manual.
|
|
|
|
*
|
|
|
|
* Sets up a suitable pixmap for the window, using the composite and damage
|
|
|
|
* extensions if possible, and then calls
|
|
|
|
* clutter_x11_texture_pixmap_set_pixmap(). If you want a window in a texture,
|
|
|
|
* you probably want this function, or its older sister,
|
|
|
|
* clutter_glx_texture_pixmap_set_window().
|
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
clutter_x11_texture_pixmap_set_window (ClutterX11TexturePixmap *texture,
|
|
|
|
Window window,
|
|
|
|
gboolean automatic)
|
|
|
|
{
|
|
|
|
ClutterX11TexturePixmapPrivate *priv;
|
2008-09-16 07:50:38 -04:00
|
|
|
XWindowAttributes attr;
|
|
|
|
Display *dpy = clutter_x11_get_default_display ();
|
2008-06-30 10:36:49 -04:00
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_X11_IS_TEXTURE_PIXMAP (texture));
|
|
|
|
|
|
|
|
priv = texture->priv;
|
|
|
|
|
|
|
|
if (!clutter_x11_has_composite_extension())
|
|
|
|
return;
|
|
|
|
|
2008-07-07 18:28:13 -04:00
|
|
|
if (priv->window == window && automatic == priv->window_redirect_automatic)
|
2008-06-30 10:36:49 -04:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (priv->window)
|
|
|
|
{
|
2008-09-16 07:50:38 -04:00
|
|
|
clutter_x11_remove_filter (on_x_event_filter_too, (gpointer)texture);
|
2008-06-30 10:36:49 -04:00
|
|
|
clutter_x11_trap_x_errors ();
|
|
|
|
XCompositeUnredirectWindow(clutter_x11_get_default_display (),
|
|
|
|
priv->window,
|
2008-07-07 18:28:13 -04:00
|
|
|
priv->window_redirect_automatic ?
|
|
|
|
CompositeRedirectAutomatic : CompositeRedirectManual);
|
2008-07-13 18:54:19 -04:00
|
|
|
XSync (clutter_x11_get_default_display (), False);
|
2008-06-30 10:36:49 -04:00
|
|
|
clutter_x11_untrap_x_errors ();
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->window = window;
|
|
|
|
priv->window_redirect_automatic = automatic;
|
2008-09-16 07:50:38 -04:00
|
|
|
priv->window_mapped = FALSE;
|
|
|
|
priv->destroyed = FALSE;
|
2008-06-30 10:36:49 -04:00
|
|
|
|
2008-07-07 18:28:13 -04:00
|
|
|
if (window == None)
|
|
|
|
return;
|
|
|
|
|
2008-06-30 10:36:49 -04:00
|
|
|
clutter_x11_trap_x_errors ();
|
2008-09-16 07:50:38 -04:00
|
|
|
{
|
|
|
|
if (!XGetWindowAttributes (dpy, window, &attr))
|
|
|
|
{
|
|
|
|
XSync (dpy, False);
|
|
|
|
clutter_x11_untrap_x_errors ();
|
|
|
|
g_warning ("bad window 0x%x", (guint32)window);
|
|
|
|
priv->window = None;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
XCompositeRedirectWindow
|
|
|
|
(dpy,
|
|
|
|
window,
|
|
|
|
automatic ?
|
|
|
|
CompositeRedirectAutomatic : CompositeRedirectManual);
|
|
|
|
XSync (dpy, False);
|
|
|
|
}
|
2008-06-30 10:36:49 -04:00
|
|
|
|
|
|
|
clutter_x11_untrap_x_errors ();
|
|
|
|
|
2008-09-16 07:50:38 -04:00
|
|
|
if (priv->window)
|
|
|
|
{
|
|
|
|
XSelectInput (dpy, priv->window,
|
|
|
|
attr.your_event_mask | StructureNotifyMask);
|
|
|
|
clutter_x11_add_filter (on_x_event_filter_too, (gpointer)texture);
|
|
|
|
}
|
|
|
|
|
2008-06-30 10:36:49 -04:00
|
|
|
g_object_ref (texture);
|
|
|
|
g_object_notify (G_OBJECT (texture), "window");
|
2008-09-16 07:50:38 -04:00
|
|
|
|
|
|
|
clutter_x11_texture_pixmap_set_mapped (texture,
|
|
|
|
attr.map_state == IsViewable);
|
2008-06-30 10:36:49 -04:00
|
|
|
|
|
|
|
clutter_x11_texture_pixmap_sync_window (texture);
|
2008-09-16 07:50:38 -04:00
|
|
|
g_object_unref (texture);
|
2008-06-30 10:36:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_x11_texture_pixmap_sync_window:
|
|
|
|
* @texture: the texture to bind
|
|
|
|
*
|
|
|
|
* Resets the texture's pixmap from its window, perhaps in response to the
|
|
|
|
* pixmap's invalidation as the window changed size.
|
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
clutter_x11_texture_pixmap_sync_window (ClutterX11TexturePixmap *texture)
|
|
|
|
{
|
|
|
|
ClutterX11TexturePixmapPrivate *priv;
|
2008-09-16 07:50:38 -04:00
|
|
|
Pixmap pixmap;
|
2008-06-30 10:36:49 -04:00
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_X11_IS_TEXTURE_PIXMAP (texture));
|
|
|
|
|
|
|
|
priv = texture->priv;
|
|
|
|
|
2008-09-16 07:50:38 -04:00
|
|
|
if (priv->destroyed)
|
|
|
|
return;
|
|
|
|
|
2008-06-30 18:00:49 -04:00
|
|
|
if (!clutter_x11_has_composite_extension())
|
2008-06-30 10:36:49 -04:00
|
|
|
{
|
2008-06-30 18:00:49 -04:00
|
|
|
clutter_x11_texture_pixmap_set_pixmap (texture, priv->window);
|
|
|
|
return;
|
2008-06-30 10:36:49 -04:00
|
|
|
}
|
2008-09-16 07:50:38 -04:00
|
|
|
|
2008-06-30 18:00:49 -04:00
|
|
|
if (priv->window)
|
2008-06-30 10:36:49 -04:00
|
|
|
{
|
2008-09-16 07:50:38 -04:00
|
|
|
XWindowAttributes attr;
|
2008-06-30 18:00:49 -04:00
|
|
|
Display *dpy = clutter_x11_get_default_display ();
|
2009-04-17 14:05:21 -04:00
|
|
|
gboolean mapped = FALSE;
|
|
|
|
gboolean notify_x = FALSE;
|
|
|
|
gboolean notify_y = FALSE;
|
|
|
|
gboolean notify_override_redirect = FALSE;
|
|
|
|
Status status;
|
|
|
|
|
|
|
|
/* NB: It's only valid to name a pixmap if the window is viewable.
|
|
|
|
*
|
|
|
|
* We don't explicitly check this though since there would be a race
|
|
|
|
* between checking and naming unless we use a server grab which is
|
|
|
|
* undesireable.
|
|
|
|
*
|
|
|
|
* Instead we gracefully handle any error with naming the pixmap.
|
2008-09-16 07:50:38 -04:00
|
|
|
*/
|
2008-06-30 10:36:49 -04:00
|
|
|
clutter_x11_trap_x_errors ();
|
2008-09-16 07:50:38 -04:00
|
|
|
|
2009-04-17 14:05:21 -04:00
|
|
|
pixmap = XCompositeNameWindowPixmap (dpy, priv->window);
|
2008-09-16 07:50:38 -04:00
|
|
|
|
2009-04-17 14:05:21 -04:00
|
|
|
status = XGetWindowAttributes (dpy, priv->window, &attr);
|
|
|
|
if (status != 0)
|
|
|
|
{
|
|
|
|
notify_x = attr.x != priv->window_x;
|
|
|
|
notify_y = attr.y != priv->window_y;
|
|
|
|
notify_override_redirect = attr.override_redirect != priv->override_redirect;
|
|
|
|
priv->window_x = attr.x;
|
|
|
|
priv->window_y = attr.y;
|
|
|
|
priv->override_redirect = attr.override_redirect;
|
|
|
|
}
|
2008-06-30 10:36:49 -04:00
|
|
|
|
2009-04-17 14:05:21 -04:00
|
|
|
/* We rely on XGetWindowAttributes() implicitly syncing with the server
|
|
|
|
* so if there was an error naming the pixmap that will have been
|
|
|
|
* caught by now. */
|
|
|
|
if (clutter_x11_untrap_x_errors ())
|
|
|
|
pixmap = None;
|
2008-09-16 07:50:38 -04:00
|
|
|
|
|
|
|
g_object_ref (texture); /* guard against unparent */
|
|
|
|
if (pixmap)
|
|
|
|
{
|
|
|
|
clutter_x11_texture_pixmap_set_pixmap (texture, pixmap);
|
|
|
|
priv->owns_pixmap = TRUE;
|
|
|
|
}
|
|
|
|
clutter_x11_texture_pixmap_set_mapped (texture, mapped);
|
|
|
|
/* could do more clever things with a signal, i guess.. */
|
|
|
|
if (notify_override_redirect)
|
|
|
|
g_object_notify (G_OBJECT (texture), "window-override-redirect");
|
|
|
|
if (notify_x)
|
|
|
|
g_object_notify (G_OBJECT (texture), "window-x");
|
|
|
|
if (notify_y)
|
|
|
|
g_object_notify (G_OBJECT (texture), "window-y");
|
|
|
|
g_object_unref (texture);
|
|
|
|
}
|
|
|
|
}
|
2008-06-30 10:36:49 -04:00
|
|
|
|
2008-09-16 07:50:38 -04:00
|
|
|
static void
|
|
|
|
clutter_x11_texture_pixmap_set_mapped (ClutterX11TexturePixmap *texture,
|
|
|
|
gboolean mapped)
|
|
|
|
{
|
|
|
|
ClutterX11TexturePixmapPrivate *priv;
|
|
|
|
|
|
|
|
priv = texture->priv;
|
|
|
|
|
|
|
|
if (mapped != priv->window_mapped)
|
|
|
|
{
|
|
|
|
priv->window_mapped = mapped;
|
|
|
|
g_object_notify (G_OBJECT (texture), "window-mapped");
|
2008-06-30 18:00:49 -04:00
|
|
|
}
|
2008-02-20 07:43:54 -05:00
|
|
|
}
|
|
|
|
|
2008-09-16 07:50:38 -04:00
|
|
|
static void
|
|
|
|
clutter_x11_texture_pixmap_destroyed (ClutterX11TexturePixmap *texture)
|
|
|
|
{
|
|
|
|
ClutterX11TexturePixmapPrivate *priv;
|
|
|
|
|
|
|
|
priv = texture->priv;
|
|
|
|
|
|
|
|
if (!priv->destroyed)
|
|
|
|
{
|
|
|
|
priv->destroyed = TRUE;
|
|
|
|
g_object_notify (G_OBJECT (texture), "destroyed");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't set window to None, that would destroy the pixmap, which might still
|
|
|
|
* be useful e.g. for destroy animations -- app's responsibility.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
2008-02-20 07:43:54 -05:00
|
|
|
/**
|
|
|
|
* clutter_x11_texture_pixmap_update_area:
|
|
|
|
* @texture: The texture whose content shall be updated.
|
|
|
|
* @x: the X coordinate of the area to update
|
|
|
|
* @y: the Y coordinate of the area to update
|
|
|
|
* @width: the width of the area to update
|
|
|
|
* @height: the height of the area to update
|
|
|
|
*
|
|
|
|
* Performs the actual binding of texture to the current content of
|
|
|
|
* the pixmap. Can be called to update the texture if the pixmap
|
|
|
|
* content has changed.
|
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
clutter_x11_texture_pixmap_update_area (ClutterX11TexturePixmap *texture,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height)
|
|
|
|
{
|
|
|
|
g_return_if_fail (CLUTTER_X11_IS_TEXTURE_PIXMAP (texture));
|
|
|
|
|
2008-11-07 11:31:56 -05:00
|
|
|
if (!CLUTTER_ACTOR_IS_VISIBLE (CLUTTER_ACTOR(texture)))
|
|
|
|
return; /* No need to update when not visible */
|
|
|
|
|
2008-02-20 07:43:54 -05:00
|
|
|
g_signal_emit (texture, signals[UPDATE_AREA], 0, x, y, width, height);
|
|
|
|
}
|
2008-04-15 17:18:13 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
clutter_x11_texture_pixmap_set_automatic (ClutterX11TexturePixmap *texture,
|
|
|
|
gboolean setting)
|
|
|
|
{
|
|
|
|
ClutterX11TexturePixmapPrivate *priv;
|
|
|
|
Display *dpy;
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_X11_IS_TEXTURE_PIXMAP (texture));
|
|
|
|
|
|
|
|
priv = texture->priv;
|
|
|
|
|
|
|
|
if (setting == priv->automatic_updates)
|
|
|
|
return;
|
|
|
|
|
|
|
|
dpy = clutter_x11_get_default_display();
|
|
|
|
|
|
|
|
if (setting == TRUE)
|
|
|
|
{
|
|
|
|
clutter_x11_add_filter (on_x_event_filter, (gpointer)texture);
|
2008-05-06 15:57:05 -04:00
|
|
|
|
|
|
|
clutter_x11_trap_x_errors ();
|
2008-09-16 07:50:38 -04:00
|
|
|
|
2008-06-30 10:36:49 -04:00
|
|
|
if (priv->window)
|
|
|
|
priv->damage_drawable = priv->window;
|
|
|
|
else
|
|
|
|
priv->damage_drawable = priv->pixmap;
|
2008-09-16 07:50:38 -04:00
|
|
|
|
|
|
|
priv->damage = XDamageCreate (dpy,
|
2008-06-30 10:36:49 -04:00
|
|
|
priv->damage_drawable,
|
2008-04-15 17:18:13 -04:00
|
|
|
XDamageReportNonEmpty);
|
2008-05-06 15:57:05 -04:00
|
|
|
|
|
|
|
XSync (dpy, FALSE);
|
|
|
|
clutter_x11_untrap_x_errors ();
|
2008-04-15 17:18:13 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
free_damage_resources (texture);
|
|
|
|
|
|
|
|
priv->automatic_updates = setting;
|
|
|
|
|
|
|
|
}
|