mutter/tests/interactive/test-fullscreen.c

100 lines
2.5 KiB
C
Raw Normal View History

#include <stdlib.h>
#include <gmodule.h>
#include <clutter/clutter.h>
enum
{
START,
HIDE,
SHOW,
DONE
};
static int state = START;
static void
on_fullscreen (ClutterStage *stage)
{
Remove Units from the public API With the recent change to internal floating point values, ClutterUnit has become a redundant type, defined to be a float. All integer entry points are being internally converted to floating point values to be passed to the GL pipeline with the least amount of conversion. ClutterUnit is thus exposed as just a "pixel with fractionary bits", and not -- as users might think -- as generic, resolution and device independent units. not that it was the case, but a definitive amount of people was convinced it did provide this "feature", and was flummoxed about the mere existence of this type. So, having ClutterUnit exposed in the public API doubles the entry points and has the following disadvantages: - we have to maintain twice the amount of entry points in ClutterActor - we still do an integer-to-float implicit conversion - we introduce a weird impedance between pixels and "pixels with fractionary bits" - language bindings will have to choose what to bind, and resort to manually overriding the API + *except* for language bindings based on GObject-Introspection, as they cannot do manual overrides, thus will replicate the entire set of entry points For these reason, we should coalesces every Actor entry point for pixels and for ClutterUnit into a single entry point taking a float, like: void clutter_actor_set_x (ClutterActor *self, gfloat x); void clutter_actor_get_size (ClutterActor *self, gfloat *width, gfloat *height); gfloat clutter_actor_get_height (ClutterActor *self); etc. The issues I have identified are: - we'll have a two cases of compiler warnings: - printf() format of the return values from %d to %f - clutter_actor_get_size() taking floats instead of unsigned ints - we'll have a problem with varargs when passing an integer instead of a floating point value, except on 64bit platforms where the size of a float is the same as the size of an int To be clear: the *intent* of the API should not change -- we still use pixels everywhere -- but: - we remove ambiguity in the API with regard to pixels and units - we remove entry points we get to maintain for the whole 1.0 version of the API - we make things simpler to bind for both manual language bindings and automatic (gobject-introspection based) ones - we have the simplest API possible while still exposing the capabilities of the underlying GL implementation
2009-05-06 15:44:47 +00:00
g_debug ("fullscreen set, size: %.2fx%.2f, mapped: %s",
clutter_actor_get_width (CLUTTER_ACTOR (stage)),
clutter_actor_get_height (CLUTTER_ACTOR (stage)),
CLUTTER_ACTOR_IS_MAPPED (stage) ? "true" : "false");
}
static void
on_unfullscreen (ClutterStage *stage)
{
Remove Units from the public API With the recent change to internal floating point values, ClutterUnit has become a redundant type, defined to be a float. All integer entry points are being internally converted to floating point values to be passed to the GL pipeline with the least amount of conversion. ClutterUnit is thus exposed as just a "pixel with fractionary bits", and not -- as users might think -- as generic, resolution and device independent units. not that it was the case, but a definitive amount of people was convinced it did provide this "feature", and was flummoxed about the mere existence of this type. So, having ClutterUnit exposed in the public API doubles the entry points and has the following disadvantages: - we have to maintain twice the amount of entry points in ClutterActor - we still do an integer-to-float implicit conversion - we introduce a weird impedance between pixels and "pixels with fractionary bits" - language bindings will have to choose what to bind, and resort to manually overriding the API + *except* for language bindings based on GObject-Introspection, as they cannot do manual overrides, thus will replicate the entire set of entry points For these reason, we should coalesces every Actor entry point for pixels and for ClutterUnit into a single entry point taking a float, like: void clutter_actor_set_x (ClutterActor *self, gfloat x); void clutter_actor_get_size (ClutterActor *self, gfloat *width, gfloat *height); gfloat clutter_actor_get_height (ClutterActor *self); etc. The issues I have identified are: - we'll have a two cases of compiler warnings: - printf() format of the return values from %d to %f - clutter_actor_get_size() taking floats instead of unsigned ints - we'll have a problem with varargs when passing an integer instead of a floating point value, except on 64bit platforms where the size of a float is the same as the size of an int To be clear: the *intent* of the API should not change -- we still use pixels everywhere -- but: - we remove ambiguity in the API with regard to pixels and units - we remove entry points we get to maintain for the whole 1.0 version of the API - we make things simpler to bind for both manual language bindings and automatic (gobject-introspection based) ones - we have the simplest API possible while still exposing the capabilities of the underlying GL implementation
2009-05-06 15:44:47 +00:00
g_debug ("fullscreen unset, size: %.2fx%.2f, mapped: %s",
clutter_actor_get_width (CLUTTER_ACTOR (stage)),
clutter_actor_get_height (CLUTTER_ACTOR (stage)),
CLUTTER_ACTOR_IS_MAPPED (stage) ? "true" : "false");
}
static gboolean
toggle_fullscreen (gpointer dummy)
{
ClutterActor *stage = clutter_stage_get_default ();
gboolean is_fullscreen = FALSE;
g_object_get (G_OBJECT (stage), "fullscreen-set", &is_fullscreen, NULL);
switch (state)
{
case START:
g_debug ("start: is_fullscreen := %s", is_fullscreen ? "true" : "false");
clutter_actor_hide (stage);
state = HIDE;
return TRUE;
case HIDE:
g_debug ("hide: is_fullscreen := %s", is_fullscreen ? "true" : "false");
clutter_actor_show (stage);
state = SHOW;
return TRUE;
case SHOW:
g_debug ("show: is_fullscreen := %s", is_fullscreen ? "true" : "false");
clutter_stage_set_fullscreen (CLUTTER_STAGE (stage), FALSE);
state = DONE;
return TRUE;
case DONE:
g_debug ("done: is_fullscreen := %s", is_fullscreen ? "true" : "false");
clutter_main_quit ();
break;
}
return FALSE;
}
G_MODULE_EXPORT int
test_fullscreen_main (int argc, char *argv[])
{
ClutterActor *stage;
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_get_default ();
g_signal_connect (stage,
"fullscreen", G_CALLBACK (on_fullscreen),
NULL);
g_signal_connect (stage,
"unfullscreen", G_CALLBACK (on_unfullscreen),
NULL);
clutter_stage_set_fullscreen (CLUTTER_STAGE (stage), TRUE);
clutter_actor_show (stage);
Remove Units from the public API With the recent change to internal floating point values, ClutterUnit has become a redundant type, defined to be a float. All integer entry points are being internally converted to floating point values to be passed to the GL pipeline with the least amount of conversion. ClutterUnit is thus exposed as just a "pixel with fractionary bits", and not -- as users might think -- as generic, resolution and device independent units. not that it was the case, but a definitive amount of people was convinced it did provide this "feature", and was flummoxed about the mere existence of this type. So, having ClutterUnit exposed in the public API doubles the entry points and has the following disadvantages: - we have to maintain twice the amount of entry points in ClutterActor - we still do an integer-to-float implicit conversion - we introduce a weird impedance between pixels and "pixels with fractionary bits" - language bindings will have to choose what to bind, and resort to manually overriding the API + *except* for language bindings based on GObject-Introspection, as they cannot do manual overrides, thus will replicate the entire set of entry points For these reason, we should coalesces every Actor entry point for pixels and for ClutterUnit into a single entry point taking a float, like: void clutter_actor_set_x (ClutterActor *self, gfloat x); void clutter_actor_get_size (ClutterActor *self, gfloat *width, gfloat *height); gfloat clutter_actor_get_height (ClutterActor *self); etc. The issues I have identified are: - we'll have a two cases of compiler warnings: - printf() format of the return values from %d to %f - clutter_actor_get_size() taking floats instead of unsigned ints - we'll have a problem with varargs when passing an integer instead of a floating point value, except on 64bit platforms where the size of a float is the same as the size of an int To be clear: the *intent* of the API should not change -- we still use pixels everywhere -- but: - we remove ambiguity in the API with regard to pixels and units - we remove entry points we get to maintain for the whole 1.0 version of the API - we make things simpler to bind for both manual language bindings and automatic (gobject-introspection based) ones - we have the simplest API possible while still exposing the capabilities of the underlying GL implementation
2009-05-06 15:44:47 +00:00
g_debug ("stage size: %.2fx%.2f, mapped: %s",
clutter_actor_get_width (stage),
clutter_actor_get_height (stage),
CLUTTER_ACTOR_IS_MAPPED (stage) ? "true" : "false");
g_timeout_add (1000, toggle_fullscreen, NULL);
clutter_main ();
return EXIT_SUCCESS;
}