From 8008bfea258920d7063952746b703184072d101b Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 25 Jun 2008 13:05:59 +0000 Subject: [PATCH] 2008-06-25 Emmanuele Bassi * 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. --- ChangeLog | 27 +++++++++++++++++++++ clutter/clutter-backend.c | 24 +++++++++++++++++++ clutter/clutter-backend.h | 38 ++++++++++++++++------------- clutter/clutter-stage.c | 24 +++++++++++++++++-- clutter/eglnative/clutter-backend-egl.c | 42 +++++++++++++++++++++++++++------ clutter/fruity/clutter-backend-fruity.c | 42 +++++++++++++++++++++++++++------ clutter/x11/clutter-backend-x11.c | 36 ++++++++++++++++++++++++---- 7 files changed, 196 insertions(+), 37 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2a9cfcd..f162f39 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +2008-06-25 Emmanuele Bassi + + * 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 * clutter/win32/clutter-stage-win32.c diff --git a/clutter/clutter-backend.c b/clutter/clutter-backend.c index b3e016b..4ccaed1 100644 --- a/clutter/clutter-backend.c +++ b/clutter/clutter-backend.c @@ -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); +} diff --git a/clutter/clutter-backend.h b/clutter/clutter-backend.h index ab5395c..bee180e 100644 --- a/clutter/clutter-backend.h +++ b/clutter/clutter-backend.h @@ -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 diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c index 1513bb7..0c9ef1b 100644 --- a/clutter/clutter-stage.c +++ b/clutter/clutter-stage.c @@ -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 diff --git a/clutter/eglnative/clutter-backend-egl.c b/clutter/eglnative/clutter-backend-egl.c index cb68e8c..5d5a8a7 100644 --- a/clutter/eglnative/clutter-backend-egl.c +++ b/clutter/eglnative/clutter-backend-egl.c @@ -198,6 +198,33 @@ clutter_backend_egl_get_features (ClutterBackend *backend) } 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) { GObjectClass *gobject_class = G_OBJECT_CLASS (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 diff --git a/clutter/fruity/clutter-backend-fruity.c b/clutter/fruity/clutter-backend-fruity.c index 93263b7..e3817c5 100644 --- a/clutter/fruity/clutter-backend-fruity.c +++ b/clutter/fruity/clutter-backend-fruity.c @@ -191,6 +191,33 @@ clutter_backend_egl_get_features (ClutterBackend *backend) } 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) { GObjectClass *gobject_class = G_OBJECT_CLASS (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 diff --git a/clutter/x11/clutter-backend-x11.c b/clutter/x11/clutter-backend-x11.c index 2f4d7bd..19a2706 100644 --- a/clutter/x11/clutter-backend-x11.c +++ b/clutter/x11/clutter-backend-x11.c @@ -312,6 +312,31 @@ clutter_backend_x11_get_features (ClutterBackend *backend) } 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) { GObjectClass *gobject_class = G_OBJECT_CLASS (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 -- 2.7.4