Add missing template files.

This commit is contained in:
Emmanuele Bassi 2007-04-19 15:22:49 +00:00
parent d511902fad
commit 1722c6fec4
7 changed files with 77 additions and 250 deletions

View File

@ -1,28 +1,6 @@
2007-04-16 Emmanuele Bassi <ebassi@openedhand.com>
Merge from clutter.git/merge-from-stable
* clutter/clutter-event.h:
* clutter/glx/clutter-event-glx.c: Add the XEMBED protocol support
in the GLX backend, for embedding the stage window into another
X window. This allows cross-toolkit inclusion and makes clutter-gtk
possible.
* clutter/clutter-behaviour-scale.c: Implement every ClutterGravity
value inside the scale behaviour and make the actors anchor to a
gravity when scaling up and down.
* clutter/clutter-texture.c: Revert to copying GdkPixbuf areas to
correctly implement the texture tiling. This fixes segmentation
faults occurring with cards with a small texture memory area.
* clutter/clutter-actor.c: Call g_object_freeze_notify() (and take
a reference on the actor) inside clutter_actor_request_size() so
that the notifications get unqueued at the end of the size request.
2007-04-16 Emmanuele Bassi <ebassi@openedhand.com>
Merge from clutter.git/work
Merge from clutter.git
* clutter/clutter-behaviour-bspline.[ch]: Return a ClutterBehaviour
when splicing the b-spline; fix the header and the API documentation;

View File

@ -437,9 +437,6 @@ clutter_actor_request_coords (ClutterActor *self,
if (CLUTTER_ACTOR_IS_VISIBLE (self))
clutter_actor_queue_redraw (self);
g_object_ref (self);
g_object_freeze_notify (G_OBJECT (self));
if (x_change)
g_object_notify (G_OBJECT (self), "x");
@ -452,9 +449,6 @@ clutter_actor_request_coords (ClutterActor *self,
if (height_change)
g_object_notify (G_OBJECT (self), "height");
g_object_thaw_notify (G_OBJECT (self));
g_object_unref (self);
}
}

View File

@ -79,51 +79,42 @@ scale_frame_foreach (ClutterBehaviour *behaviour,
gpointer data)
{
ClutterBehaviourScalePrivate *priv;
guint sw, sh, w, h;
gint x, y;
gint sw, sh, w, h;
guint scale = GPOINTER_TO_UINT (data);
priv = CLUTTER_BEHAVIOUR_SCALE (behaviour)->priv;
clutter_actor_get_abs_size (actor, &w, &h);
clutter_actor_set_scalex (actor, scale, scale);
if (priv->gravity == CLUTTER_GRAVITY_NONE ||
priv->gravity == CLUTTER_GRAVITY_NORTH_WEST)
return;
clutter_actor_get_abs_size (actor, &sw, &sh);
x = clutter_actor_get_x (actor);
y = clutter_actor_get_y (actor);
clutter_actor_get_abs_size (actor, (guint*) &sw, (guint*) &sh);
clutter_actor_get_size (actor, (guint*) &w, (guint*) &h);
switch (priv->gravity)
{
case CLUTTER_GRAVITY_NORTH:
clutter_actor_set_position (actor, x - ((sw - w) / 2), y);
break;
case CLUTTER_GRAVITY_NORTH_EAST:
clutter_actor_set_position (actor, x + w - sw, y);
break;
case CLUTTER_GRAVITY_EAST:
clutter_actor_set_position (actor, x + w - sw, y - (sh - h) / 2);
break;
case CLUTTER_GRAVITY_SOUTH_EAST:
clutter_actor_set_position (actor, x + w - sw, y + h - sh);
break;
case CLUTTER_GRAVITY_SOUTH:
clutter_actor_set_position (actor, x - ((sw - w) / 2), y + h - sh);
break;
case CLUTTER_GRAVITY_SOUTH_WEST:
clutter_actor_set_position (actor, x, y + h - sh);
break;
case CLUTTER_GRAVITY_WEST:
clutter_actor_set_position (actor, x, y - ((sh - h) / 2));
break;
case CLUTTER_GRAVITY_CENTER:
clutter_actor_set_position (actor,
x - ((sw - w) / 2),
y - ((sh - h) / 2));
CLUTTER_NOTE (MISC, "gravity %i vs %i\n", sw, w);
/*
* FIXME: This is actually broken for anything other than 0,0
*/
clutter_actor_set_position (actor, (w - sw) / 2, (h - sh) / 2);
default:
break;
}

View File

@ -37,11 +37,11 @@ G_BEGIN_DECLS
enum
{
/* Map to xlibs masks */
CLUTTER_BUTTON1_MASK = (1 << 8),
CLUTTER_BUTTON2_MASK = (1 << 9),
CLUTTER_BUTTON3_MASK = (1 << 10),
CLUTTER_BUTTON4_MASK = (1 << 11),
CLUTTER_BUTTON5_MASK = (1 << 12)
CLUTTER_BUTTON1_MASK = (1<<8),
CLUTTER_BUTTON2_MASK = (1<<9),
CLUTTER_BUTTON3_MASK = (1<<10),
CLUTTER_BUTTON4_MASK = (1<<11),
CLUTTER_BUTTON5_MASK = (1<<12)
};
typedef enum
@ -57,8 +57,7 @@ typedef enum
CLUTTER_BUTTON_RELEASE,
CLUTTER_SCROLL,
CLUTTER_STAGE_STATE,
CLUTTER_DESTROY_NOTIFY,
CLUTTER_CLIENT_MESSAGE
CLUTTER_DESTROY_NOTIFY
} ClutterEventType;
typedef enum

View File

@ -383,10 +383,8 @@ texture_upload_data (ClutterTexture *texture,
gint bpp)
{
ClutterTexturePrivate *priv;
gint x, y;
gint i = 0;
gboolean create_textures = FALSE;
GdkPixbuf *master_pixbuf = NULL;
int x, y, i = 0;
gboolean create_textures = FALSE;
priv = texture->priv;
@ -468,13 +466,6 @@ texture_upload_data (ClutterTexture *texture,
priv->width, priv->height);
g_return_if_fail (priv->x_tiles != NULL && priv->y_tiles != NULL);
master_pixbuf = gdk_pixbuf_new_from_data (data,
GDK_COLORSPACE_RGB,
has_alpha,
8,
width, height, rowstride,
NULL, NULL);
if (priv->tiles == NULL)
{
@ -486,31 +477,42 @@ texture_upload_data (ClutterTexture *texture,
for (x = 0; x < priv->n_x_tiles; x++)
for (y = 0; y < priv->n_y_tiles; y++)
{
GdkPixbuf *pixtmp;
gint src_h, src_w;
guchar *tmp;
gint src_h, src_w, dy;
src_w = priv->x_tiles[x].size;
src_h = priv->y_tiles[y].size;
pixtmp = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
has_alpha,
8,
src_w, src_h);
/* fixme - gslice ? */
tmp = g_malloc (sizeof (guchar) * priv->x_tiles[x].size
* priv->y_tiles[y].size
* bpp);
/* clip */
if (priv->x_tiles[x].pos + src_w > priv->width)
src_w = priv->width - priv->x_tiles[x].pos;
{
src_w = priv->width - priv->x_tiles[x].pos;
}
if (priv->y_tiles[y].pos + src_h > priv->height)
src_h = priv->height - priv->y_tiles[y].pos;
{
src_h = priv->height - priv->y_tiles[y].pos;
}
gdk_pixbuf_copy_area (master_pixbuf,
priv->x_tiles[x].pos,
priv->y_tiles[y].pos,
src_w,
src_h,
pixtmp,
0, 0);
CLUTTER_NOTE (TEXTURE,
"copying tile %i,%i - %ix%i to 0,0 %ix%i",
priv->x_tiles[x].pos, priv->y_tiles[y].pos,
src_w, src_h,
priv->x_tiles[x].size,
priv->y_tiles[y].size);
for (dy = 0; dy < src_h; dy++)
{
memcpy (tmp + (dy * src_w * bpp),
data + ((priv->y_tiles[y].pos + dy) * rowstride)
+ (priv->x_tiles[x].pos * bpp),
(src_w * bpp));
}
#ifdef CLUTTER_DUMP_TILES
{
@ -547,13 +549,15 @@ texture_upload_data (ClutterTexture *texture,
if (create_textures)
{
glTexImage2D (priv->target_type, 0, GL_RGBA,
gdk_pixbuf_get_width (pixtmp),
gdk_pixbuf_get_height (pixtmp),
0,
priv->pixel_format,
priv->pixel_type,
gdk_pixbuf_get_pixels (pixtmp));
glTexImage2D(priv->target_type,
0,
(bpp == 4) ? GL_RGBA : GL_RGB,
priv->x_tiles[x].size,
priv->y_tiles[y].size,
0,
priv->pixel_format,
priv->pixel_type,
tmp);
}
else
{
@ -561,19 +565,17 @@ texture_upload_data (ClutterTexture *texture,
*/
glTexSubImage2D (priv->target_type, 0,
0, 0,
gdk_pixbuf_get_width (pixtmp),
gdk_pixbuf_get_height (pixtmp),
priv->pixel_format,
priv->x_tiles[x].size,
priv->y_tiles[y].size,
priv->pixel_format,
priv->pixel_type,
gdk_pixbuf_get_pixels (pixtmp));
tmp);
}
g_object_unref (pixtmp);
g_free(tmp);
i++;
}
g_object_unref (master_pixbuf);
}
static void
@ -752,7 +754,8 @@ clutter_texture_set_property (GObject *object,
case PROP_USE_TILES:
priv->is_tiled = g_value_get_boolean (value);
if (priv->target_type == GL_TEXTURE_RECTANGLE_ARB && priv->is_tiled)
if (priv->target_type == GL_TEXTURE_RECTANGLE_ARB &&
priv->is_tiled)
priv->target_type = GL_TEXTURE_2D;
CLUTTER_NOTE (TEXTURE, "Texture is tiled ? %s",
@ -1049,9 +1052,9 @@ clutter_texture_get_pixbuf (ClutterTexture* texture)
if (!priv->is_tiled)
{
pixels = g_malloc (((priv->width * bpp + 3) &~ 3) * priv->height);
pixels = g_malloc (priv->width * priv->height * bpp);
if (!pixels)
if (pixels == NULL)
return NULL;
glBindTexture(priv->target_type, priv->tiles[0]);
@ -1072,7 +1075,7 @@ clutter_texture_get_pixbuf (ClutterTexture* texture)
8,
priv->width,
priv->height,
((priv->width * bpp + 3) &~ 3),
priv->width * bpp,
pixbuf_destroy_notify,
NULL);
}
@ -1088,8 +1091,8 @@ clutter_texture_get_pixbuf (ClutterTexture* texture)
priv->width,
priv->height);
for (x = 0; x < priv->n_x_tiles; x++)
for (y = 0; y < priv->n_y_tiles; y++)
for (x=0; x < priv->n_x_tiles; x++)
for (y=0; y < priv->n_y_tiles; y++)
{
GdkPixbuf *tmp_pixb;
gint src_h, src_w;
@ -1097,7 +1100,7 @@ clutter_texture_get_pixbuf (ClutterTexture* texture)
src_w = priv->x_tiles[x].size;
src_h = priv->y_tiles[y].size;
pixels = g_malloc (((src_w * bpp) &~ 3) * src_h);
pixels = g_malloc (src_w * src_h * bpp);
glBindTexture(priv->target_type, priv->tiles[i]);
@ -1108,25 +1111,18 @@ clutter_texture_get_pixbuf (ClutterTexture* texture)
0,
priv->pixel_format,
priv->pixel_type,
(GLvoid *) pixels);
(GLvoid*)pixels);
/* Clip */
if (priv->x_tiles[x].pos + src_w > priv->width)
src_w = priv->width - priv->x_tiles[x].pos;
if (priv->y_tiles[y].pos + src_h > priv->height)
src_h = priv->height = priv->y_tiles[y].pos;
tmp_pixb =
gdk_pixbuf_new_from_data ((const guchar*)pixels,
GDK_COLORSPACE_RGB,
(priv->pixel_format == GL_RGBA),
8,
src_w,
src_h,
((src_w * bpp + 3) &~ 3),
pixbuf_destroy_notify,
NULL);
tmp_pixb
= gdk_pixbuf_new_from_data ((const guchar*)pixels,
GDK_COLORSPACE_RGB,
(priv->pixel_format == GL_RGBA),
8,
src_w,
src_h,
src_w * bpp,
pixbuf_destroy_notify,
NULL);
gdk_pixbuf_copy_area (tmp_pixb,
0,

View File

@ -41,28 +41,6 @@
#include <X11/Xatom.h>
/* XEMBED protocol support for toolkit embedding */
#define XEMBED_MAPPED (1 << 0)
#define MAX_SUPPORTED_XEMBED_VERSION 1
#define XEMBED_EMBEDDED_NOTIFY 0
#define XEMBED_WINDOW_ACTIVATE 1
#define XEMBED_WINDOW_DEACTIVATE 2
#define XEMBED_REQUEST_FOCUS 3
#define XEMBED_FOCUS_IN 4
#define XEMBED_FOCUS_OUT 5
#define XEMBED_FOCUS_NEXT 6
#define XEMBED_FOCUS_PREV 7
/* 8-9 were used for XEMBED_GRAB_KEY/XEMBED_UNGRAB_KEY */
#define XEMBED_MODALITY_ON 10
#define XEMBED_MODALITY_OFF 11
#define XEMBED_REGISTER_ACCELERATOR 12
#define XEMBED_UNREGISTER_ACCELERATOR 13
#define XEMBED_ACTIVATE_ACCELERATOR 14
static Atom Atom_XEMBED = 0;
static Window ParentEmbedderWin = None;
typedef struct _ClutterEventSource ClutterEventSource;
struct _ClutterEventSource
@ -106,59 +84,6 @@ clutter_check_xpending (ClutterBackend *backend)
return XPending (CLUTTER_BACKEND_GLX (backend)->xdpy);
}
static gboolean
xembed_send_message (Display *xdisplay,
Window window,
long message,
long detail,
long data1,
long data2)
{
XEvent ev;
memset (&ev, 0, sizeof (ev));
ev.xclient.type = ClientMessage;
ev.xclient.window = window;
ev.xclient.message_type = Atom_XEMBED;
ev.xclient.format = 32;
ev.xclient.data.l[0] = CurrentTime;
ev.xclient.data.l[1] = message;
ev.xclient.data.l[2] = detail;
ev.xclient.data.l[3] = data1;
ev.xclient.data.l[4] = data2;
clutter_glx_trap_x_errors ();
XSendEvent (xdisplay, window, False, NoEventMask, &ev);
XSync (xdisplay, False);
if (clutter_glx_untrap_x_errors ())
return False;
return True;
}
static void
xembed_set_info (Display *xdisplay,
Window window,
gint flags)
{
gint32 list[2];
Atom atom_XEMBED_INFO;
atom_XEMBED_INFO = XInternAtom (xdisplay, "_XEMBED_INFO", False);
list[0] = MAX_SUPPORTED_XEMBED_VERSION;
list[1] = XEMBED_MAPPED;
clutter_glx_trap_x_errors ();
XChangeProperty (xdisplay, window,
atom_XEMBED_INFO,
atom_XEMBED_INFO, 32,
PropModeReplace, (unsigned char *) list, 2);
clutter_glx_untrap_x_errors ();
}
void
_clutter_events_init (ClutterBackend *backend)
@ -171,8 +96,6 @@ _clutter_events_init (ClutterBackend *backend)
connection_number = ConnectionNumber (backend_glx->xdpy);
CLUTTER_NOTE (EVENT, "Connection number: %d", connection_number);
Atom_XEMBED = XInternAtom (backend_glx->xdpy, "_XEMBED", False);
source = backend_glx->event_source = clutter_event_source_new (backend);
event_source = (ClutterEventSource *) source;
g_source_set_priority (source, CLUTTER_PRIORITY_EVENTS);
@ -185,10 +108,6 @@ _clutter_events_init (ClutterBackend *backend)
g_source_add_poll (source, &event_source->event_poll_fd);
g_source_set_can_recurse (source, TRUE);
g_source_attach (source, NULL);
xembed_set_info (backend_glx->xdpy,
clutter_glx_get_stage_window (CLUTTER_STAGE (backend_glx->stage)),
0);
}
void
@ -209,7 +128,6 @@ _clutter_events_uninit (ClutterBackend *backend)
}
}
static void
set_user_time (Display *display,
Window *xwindow,
@ -282,48 +200,6 @@ translate_key_event (ClutterBackend *backend,
0); /* FIXME: index with modifiers */
}
static void
handle_xembed_event (ClutterBackendGlx *backend_glx,
XEvent *xevent)
{
ClutterActor *stage;
stage = _clutter_backend_get_stage (CLUTTER_BACKEND (backend_glx));
switch (xevent->xclient.data.l[1])
{
case XEMBED_EMBEDDED_NOTIFY:
CLUTTER_NOTE (EVENT, "got XEMBED_EMBEDDED_NOTIFY from %lx",
xevent->xclient.data.l[3]);
ParentEmbedderWin = xevent->xclient.data.l[3];
clutter_actor_realize (stage);
clutter_actor_show (stage);
xembed_set_info (backend_glx->xdpy,
clutter_glx_get_stage_window (CLUTTER_STAGE (stage)),
XEMBED_MAPPED);
break;
case XEMBED_WINDOW_ACTIVATE:
CLUTTER_NOTE (EVENT, "got XEMBED_WINDOW_ACTIVATE");
break;
case XEMBED_WINDOW_DEACTIVATE:
CLUTTER_NOTE (EVENT, "got XEMBED_WINDOW_DEACTIVATE");
break;
case XEMBED_FOCUS_IN:
CLUTTER_NOTE (EVENT, "got XEMBED_FOCUS_IN");
if (ParentEmbedderWin)
xembed_send_message (backend_glx->xdpy, ParentEmbedderWin,
XEMBED_FOCUS_NEXT,
0, 0, 0);
break;
default:
CLUTTER_NOTE (EVENT, "got unknown XEMBED message");
break;
}
}
static gboolean
clutter_event_translate (ClutterBackend *backend,
ClutterEvent *event,
@ -440,12 +316,6 @@ clutter_event_translate (ClutterBackend *backend,
xevent->xdestroywindow.window);
event->type = event->any.type = CLUTTER_DESTROY_NOTIFY;
break;
case ClientMessage:
CLUTTER_NOTE (EVENT, "client message");
if (xevent->xclient.message_type == Atom_XEMBED)
handle_xembed_event (backend_glx, xevent);
event->type = event->any.type = CLUTTER_CLIENT_MESSAGE;
break;
default:
/* ignore every other event */
res = FALSE;

View File

@ -85,7 +85,6 @@ Windowing events handled by Clutter.
@CLUTTER_SCROLL:
@CLUTTER_STAGE_STATE:
@CLUTTER_DESTROY_NOTIFY:
@CLUTTER_CLIENT_MESSAGE:
<!-- ##### UNION ClutterEvent ##### -->
<para>