From fd11d3098f0182f24666ed77973269111cb0a8f5 Mon Sep 17 00:00:00 2001 From: Chris Lord Date: Sat, 6 Feb 2010 11:23:37 +0000 Subject: [PATCH] [stage] Add set/get_minumum_size Add two functions to set/get the minimum stage size. This takes effect when a stage is set to user resizable. --- clutter/clutter-stage.c | 75 ++++++++++++++++++++++++++++++ clutter/clutter-stage.h | 7 +++ clutter/x11/clutter-stage-x11.c | 6 +-- doc/reference/clutter/clutter-sections.txt | 2 + 4 files changed, 87 insertions(+), 3 deletions(-) diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c index c67056d..bef6652 100644 --- a/clutter/clutter-stage.c +++ b/clutter/clutter-stage.c @@ -82,6 +82,8 @@ struct _ClutterStagePrivate { /* the stage implementation */ ClutterStageWindow *impl; + guint minimum_width; + guint minimum_height; ClutterColor color; ClutterPerspective perspective; @@ -1179,6 +1181,8 @@ clutter_stage_init (ClutterStage *self) priv->throttle_motion_events = TRUE; priv->color = default_stage_color; + priv->minimum_width = 640; + priv->minimum_height = 480; priv->perspective.fovy = 60.0; /* 60 Degrees */ priv->perspective.aspect = 1.0; @@ -2322,3 +2326,74 @@ clutter_stage_get_use_alpha (ClutterStage *stage) return stage->priv->use_alpha; } + +/** + * clutter_stage_set_minimum_size: + * @stage: a #ClutterStage + * @width: width, in pixels + * @height: height, in pixels + * + * Sets the minimum size for a stage window. This has no effect if the stage + * is fullscreen. + * + * Since: 1.2 + */ +void +clutter_stage_set_minimum_size (ClutterStage *stage, + guint width, + guint height) +{ + gboolean resize; + ClutterGeometry geom; + + g_return_if_fail (CLUTTER_IS_STAGE (stage)); + g_return_if_fail ((width > 0) && (height > 0)); + + stage->priv->minimum_width = width; + stage->priv->minimum_height = height; + + if (stage->priv->impl == NULL) + return; + + resize = FALSE; + _clutter_stage_window_get_geometry (stage->priv->impl, &geom); + + if (geom.width < width) + resize = TRUE; + else + width = geom.width; + + if (geom.height < height) + resize = TRUE; + else + height = geom.height; + + if (resize) + _clutter_stage_window_resize (stage->priv->impl, width, height); +} + +/** + * clutter_stage_get_minimum_size: + * @stage: a #ClutterStage + * @width: width, in pixels + * @height: height, in pixels + * + * Gets the set minimum size for a stage window. This may not correspond + * to the actual minimum size and is specific to the back-end + * implementation. + * + * Since: 1.2 + */ +void +clutter_stage_get_minimum_size (ClutterStage *stage, + guint *width, + guint *height) +{ + g_return_if_fail (CLUTTER_IS_STAGE (stage)); + + if (width) + *width = stage->priv->minimum_width; + if (height) + *height = stage->priv->minimum_height; +} + diff --git a/clutter/clutter-stage.h b/clutter/clutter-stage.h index a4e3bfb..c26460e 100644 --- a/clutter/clutter-stage.h +++ b/clutter/clutter-stage.h @@ -247,6 +247,13 @@ void clutter_stage_set_use_alpha (ClutterStage *stage, gboolean use_alpha); gboolean clutter_stage_get_use_alpha (ClutterStage *stage); +void clutter_stage_set_minimum_size (ClutterStage *stage, + guint width, + guint height); +void clutter_stage_get_minimum_size (ClutterStage *stage, + guint *width, + guint *height); + /* Commodity macro, for mallum only */ #define clutter_stage_add(stage,actor) G_STMT_START { \ if (CLUTTER_IS_STAGE ((stage)) && CLUTTER_IS_ACTOR ((actor))) \ diff --git a/clutter/x11/clutter-stage-x11.c b/clutter/x11/clutter-stage-x11.c index 12b1322..f2e6f30 100644 --- a/clutter/x11/clutter-stage-x11.c +++ b/clutter/x11/clutter-stage-x11.c @@ -191,9 +191,9 @@ clutter_stage_x11_get_geometry (ClutterStageWindow *stage_window, if (resize) { - /* FIXME need API to set this */ - geometry->width = 1; - geometry->height = 1; + clutter_stage_get_minimum_size (stage_x11->wrapper, + &geometry->width, + &geometry->height); } else { diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index 6626369..b686072 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -533,6 +533,8 @@ clutter_stage_set_throttle_motion_events clutter_stage_get_throttle_motion_events clutter_stage_set_use_alpha clutter_stage_get_use_alpha +clutter_stage_set_minimum_size +clutter_stage_get_minimum_size ClutterPerspective -- 2.7.4