2008-06-25 Emmanuele Bassi <ebassi@openedhand.com>

* clutter/clutter-backend.h:
	* clutter/clutter-backend.c:
	(clutter_backend_get_display_size): Add a function for getting the
	display size out of the backend.

	* clutter/clutter-stage.c:
	(clutter_stage_allocate): When allocating on a backend with a
	static stage, we simply ignore the passed box and override it with
	the size of the display.

	* clutter/eglnative/clutter-backend-egl.c:
	(clutter_backend_egl_get_display_size),
	(clutter_backend_egl_class_init): Implement get_display_size() by
	returning the size of the EGL surface.

	* clutter/fruity/clutter-backend-fruity.c:
	(clutter_backend_egl_get_display_size),
	(clutter_backend_egl_class_init): Ditto as above.

	* clutter/x11/clutter-backend-x11.c:
	(clutter_backend_x11_get_display_size),
	(clutter_backend_x11_class_init): Implement get_display_size() by
	returning the DisplayWidth and DisplayHeight of the current
	screen.
This commit is contained in:
Emmanuele Bassi 2008-06-25 13:05:59 +00:00
parent 1049959d34
commit 8008bfea25
7 changed files with 196 additions and 37 deletions

View File

@ -1,3 +1,30 @@
2008-06-25 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-backend.h:
* clutter/clutter-backend.c:
(clutter_backend_get_display_size): Add a function for getting the
display size out of the backend.
* clutter/clutter-stage.c:
(clutter_stage_allocate): When allocating on a backend with a
static stage, we simply ignore the passed box and override it with
the size of the display.
* clutter/eglnative/clutter-backend-egl.c:
(clutter_backend_egl_get_display_size),
(clutter_backend_egl_class_init): Implement get_display_size() by
returning the size of the EGL surface.
* clutter/fruity/clutter-backend-fruity.c:
(clutter_backend_egl_get_display_size),
(clutter_backend_egl_class_init): Ditto as above.
* clutter/x11/clutter-backend-x11.c:
(clutter_backend_x11_get_display_size),
(clutter_backend_x11_class_init): Implement get_display_size() by
returning the DisplayWidth and DisplayHeight of the current
screen.
2008-06-25 Neil Roberts <neil@o-hand.com>
* clutter/win32/clutter-stage-win32.c

View File

@ -481,3 +481,27 @@ clutter_backend_get_font_options (ClutterBackend *backend)
return priv->font_options;
}
void
clutter_backend_get_display_size (ClutterBackend *backend,
gint *width,
gint *height)
{
ClutterBackendClass *klass;
g_return_if_fail (CLUTTER_IS_BACKEND (backend));
klass = CLUTTER_BACKEND_GET_CLASS (backend);
if (!klass->get_display_size)
{
if (width)
*width = 0;
if (height)
*height = 0;
return;
}
klass->get_display_size (backend, width, height);
}

View File

@ -59,22 +59,25 @@ struct _ClutterBackendClass
GObjectClass parent_class;
/* vfuncs */
gboolean (* pre_parse) (ClutterBackend *backend,
GError **error);
gboolean (* post_parse) (ClutterBackend *backend,
GError **error);
ClutterActor * (* create_stage) (ClutterBackend *backend,
ClutterStage *wrapper,
GError **error);
void (* init_events) (ClutterBackend *backend);
void (* init_features) (ClutterBackend *backend);
void (* add_options) (ClutterBackend *backend,
GOptionGroup *group);
ClutterFeatureFlags (* get_features) (ClutterBackend *backend);
void (* redraw) (ClutterBackend *backend,
ClutterStage *stage);
void (* ensure_context) (ClutterBackend *backend,
ClutterStage *stage);
gboolean (* pre_parse) (ClutterBackend *backend,
GError **error);
gboolean (* post_parse) (ClutterBackend *backend,
GError **error);
ClutterActor * (* create_stage) (ClutterBackend *backend,
ClutterStage *wrapper,
GError **error);
void (* init_events) (ClutterBackend *backend);
void (* init_features) (ClutterBackend *backend);
void (* add_options) (ClutterBackend *backend,
GOptionGroup *group);
ClutterFeatureFlags (* get_features) (ClutterBackend *backend);
void (* redraw) (ClutterBackend *backend,
ClutterStage *stage);
void (* ensure_context) (ClutterBackend *backend,
ClutterStage *stage);
void (* get_display_size) (ClutterBackend *backend,
gint *width,
gint *height);
};
GType clutter_backend_get_type (void) G_GNUC_CONST;
@ -93,6 +96,9 @@ guint clutter_backend_get_double_click_distance (ClutterBackend
void clutter_backend_set_font_options (ClutterBackend *backend,
cairo_font_options_t *options);
cairo_font_options_t *clutter_backend_get_font_options (ClutterBackend *backend);
void clutter_backend_get_display_size (ClutterBackend *backend,
gint *width,
gint *height);
G_END_DECLS

View File

@ -161,8 +161,8 @@ clutter_stage_allocate (ClutterActor *self,
g_assert (priv->impl != NULL);
/* if the stage is fixed size (for instance, it's using a frame-buffer)
* then we simply ignore any allocation request and interrupt the
* allocation chain here.
* then we simply ignore any allocation request and override the
* allocation chain.
*/
if (!clutter_feature_available (CLUTTER_FEATURE_STAGE_STATIC))
{
@ -174,6 +174,26 @@ clutter_stage_allocate (ClutterActor *self,
klass = CLUTTER_ACTOR_GET_CLASS (priv->impl);
klass->allocate (priv->impl, box, origin_changed);
}
else
{
ClutterActorBox override = { 0, };
ClutterBackend *backend = clutter_get_default_backend ();
gint display_width, display_height;
ClutterActorClass *klass;
display_width = display_height = 0;
clutter_backend_get_display_size (backend,
&display_width,
&display_height);
override.x1 = 0;
override.y1 = 0;
override.x2 = CLUTTER_UNITS_FROM_DEVICE (display_width);
override.y2 = CLUTTER_UNITS_FROM_DEVICE (display_height);
klass = CLUTTER_ACTOR_CLASS (clutter_stage_parent_class);
klass->allocate (self, &override, origin_changed);
}
}
static void

View File

@ -197,6 +197,33 @@ clutter_backend_egl_get_features (ClutterBackend *backend)
return CLUTTER_FEATURE_STAGE_STATIC;
}
static void
clutter_backend_egl_get_display_size (ClutterBackend *backend,
gint *width,
gint *height)
{
ClutterBackendEGL *backend_egl = CLUTTER_BACKEND_EGL (backend);
gint surface_width, surface_height;
if (backend_egl->stage)
{
ClutterStageEgl *stage_egl;
stage_egl = CLUTTER_STAGE_EGL (backend_egl->stage);
surface_width = stage_egl->surface_width;
surface_height = stage_egl->surface_height;
}
else
surface_width = surface_height = 0;
if (width)
*width = surface_width;
if (height)
*height = surface_height;
}
static void
clutter_backend_egl_class_init (ClutterBackendEGLClass *klass)
{
@ -207,13 +234,14 @@ clutter_backend_egl_class_init (ClutterBackendEGLClass *klass)
gobject_class->dispose = clutter_backend_egl_dispose;
gobject_class->finalize = clutter_backend_egl_finalize;
backend_class->pre_parse = clutter_backend_egl_pre_parse;
backend_class->post_parse = clutter_backend_egl_post_parse;
backend_class->init_events = clutter_backend_egl_init_events;
backend_class->create_stage = clutter_backend_egl_create_stage;
backend_class->ensure_context = clutter_backend_egl_ensure_context;
backend_class->redraw = clutter_backend_egl_redraw;
backend_class->get_features = clutter_backend_egl_get_features;
backend_class->pre_parse = clutter_backend_egl_pre_parse;
backend_class->post_parse = clutter_backend_egl_post_parse;
backend_class->init_events = clutter_backend_egl_init_events;
backend_class->create_stage = clutter_backend_egl_create_stage;
backend_class->ensure_context = clutter_backend_egl_ensure_context;
backend_class->redraw = clutter_backend_egl_redraw;
backend_class->get_features = clutter_backend_egl_get_features;
backend_class->get_display_size = clutter_backend_egl_get_display_size;
}
static void

View File

@ -190,6 +190,33 @@ clutter_backend_egl_get_features (ClutterBackend *backend)
return CLUTTER_FEATURE_STAGE_STATIC;
}
static void
clutter_backend_egl_get_display_size (ClutterBackend *backend,
gint *width,
gint *height)
{
ClutterBackendEGL *backend_egl = CLUTTER_BACKEND_EGL (backend);
gint surface_width, surface_height;
if (backend_egl->stage)
{
ClutterStageEgl *stage_egl;
stage_egl = CLUTTER_STAGE_EGL (backend_egl->stage);
surface_width = stage_egl->surface_width;
surface_height = stage_egl->surface_height;
}
else
surface_width = surface_height = 0;
if (width)
*width = surface_width;
if (height)
*height = surface_height;
}
static void
clutter_backend_egl_class_init (ClutterBackendEGLClass *klass)
{
@ -200,13 +227,14 @@ clutter_backend_egl_class_init (ClutterBackendEGLClass *klass)
gobject_class->dispose = clutter_backend_egl_dispose;
gobject_class->finalize = clutter_backend_egl_finalize;
backend_class->pre_parse = clutter_backend_egl_pre_parse;
backend_class->post_parse = clutter_backend_egl_post_parse;
backend_class->init_events = clutter_backend_egl_init_events;
backend_class->create_stage = clutter_backend_egl_create_stage;
backend_class->ensure_context = clutter_backend_egl_ensure_context;
backend_class->redraw = clutter_backend_egl_redraw;
backend_class->get_features = clutter_backend_egl_get_features;
backend_class->pre_parse = clutter_backend_egl_pre_parse;
backend_class->post_parse = clutter_backend_egl_post_parse;
backend_class->init_events = clutter_backend_egl_init_events;
backend_class->create_stage = clutter_backend_egl_create_stage;
backend_class->ensure_context = clutter_backend_egl_ensure_context;
backend_class->redraw = clutter_backend_egl_redraw;
backend_class->get_features = clutter_backend_egl_get_features;
backend_class->get_display_size = clutter_backend_egl_get_display_size;
}
static void

View File

@ -311,6 +311,31 @@ clutter_backend_x11_get_features (ClutterBackend *backend)
return CLUTTER_FEATURE_STAGE_USER_RESIZE | CLUTTER_FEATURE_STAGE_CURSOR;
}
static void
clutter_backend_x11_get_display_size (ClutterBackend *backend,
gint *width,
gint *height)
{
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
gint display_width, display_height;
if (G_LIKELY (backend_x11->xdpy))
{
display_width = DisplayWidth (backend_x11->xdpy,
backend_x11->xscreen_num);
display_height = DisplayHeight (backend_x11->xdpy,
backend_x11->xscreen_num);
}
else
display_width = display_height = 0;
if (width)
*width = display_width;
if (height)
*height = display_height;
}
static void
clutter_backend_x11_class_init (ClutterBackendX11Class *klass)
{
@ -321,11 +346,12 @@ clutter_backend_x11_class_init (ClutterBackendX11Class *klass)
gobject_class->dispose = clutter_backend_x11_dispose;
gobject_class->finalize = clutter_backend_x11_finalize;
backend_class->pre_parse = clutter_backend_x11_pre_parse;
backend_class->post_parse = clutter_backend_x11_post_parse;
backend_class->init_events = clutter_backend_x11_init_events;
backend_class->add_options = clutter_backend_x11_add_options;
backend_class->get_features = clutter_backend_x11_get_features;
backend_class->pre_parse = clutter_backend_x11_pre_parse;
backend_class->post_parse = clutter_backend_x11_post_parse;
backend_class->init_events = clutter_backend_x11_init_events;
backend_class->add_options = clutter_backend_x11_add_options;
backend_class->get_features = clutter_backend_x11_get_features;
backend_class->get_display_size = clutter_backend_x11_get_display_size;
}
static void