+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
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);
+}
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;
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
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))
{
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
}
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);
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
}
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);
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
}
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);
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