2006-05-29 08:59:36 +00:00
|
|
|
|
/*
|
|
|
|
|
* Clutter.
|
|
|
|
|
*
|
|
|
|
|
* An OpenGL based 'interactive canvas' library.
|
|
|
|
|
*
|
|
|
|
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2006 OpenedHand
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2010-03-01 12:56:10 +00:00
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2006-05-29 08:59:36 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2006-06-21 22:34:25 +00:00
|
|
|
|
/**
|
|
|
|
|
* SECTION:clutter-stage
|
|
|
|
|
* @short_description: Top level visual element to which actors are placed.
|
2007-10-12 08:17:00 +00:00
|
|
|
|
*
|
2006-06-21 22:34:25 +00:00
|
|
|
|
* #ClutterStage is a top level 'window' on which child actors are placed
|
|
|
|
|
* and manipulated.
|
2008-04-04 15:02:11 +00:00
|
|
|
|
*
|
|
|
|
|
* Backends might provide support for multiple stages. The support for this
|
|
|
|
|
* feature can be checked at run-time using the clutter_feature_available()
|
|
|
|
|
* function and the %CLUTTER_FEATURE_STAGE_MULTIPLE flag. If the backend used
|
|
|
|
|
* supports multiple stages, new #ClutterStage instances can be created
|
|
|
|
|
* using clutter_stage_new(). These stages must be managed by the developer
|
|
|
|
|
* using clutter_actor_destroy(), which will take care of destroying all the
|
|
|
|
|
* actors contained inside them.
|
|
|
|
|
*
|
|
|
|
|
* #ClutterStage is a proxy actor, wrapping the backend-specific
|
|
|
|
|
* implementation of the windowing system. It is possible to subclass
|
|
|
|
|
* #ClutterStage, as long as every overridden virtual function chains up to
|
|
|
|
|
* the parent class corresponding function.
|
2006-06-21 22:34:25 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2007-10-12 08:17:00 +00:00
|
|
|
|
#ifdef HAVE_CONFIG_H
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
#include "config.h"
|
2007-10-12 08:17:00 +00:00
|
|
|
|
#endif
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
|
2011-12-30 10:23:15 +00:00
|
|
|
|
#include <math.h>
|
2011-06-10 16:48:54 +00:00
|
|
|
|
#include <cairo.h>
|
2011-04-12 16:01:51 +00:00
|
|
|
|
|
2012-11-08 17:42:24 +00:00
|
|
|
|
#define CLUTTER_ENABLE_EXPERIMENTAL_API
|
2011-12-30 10:23:15 +00:00
|
|
|
|
|
2006-05-29 08:59:36 +00:00
|
|
|
|
#include "clutter-stage.h"
|
2010-04-16 14:34:36 +00:00
|
|
|
|
|
2010-10-21 11:16:05 +00:00
|
|
|
|
#include "clutter-actor-private.h"
|
2010-10-21 10:49:37 +00:00
|
|
|
|
#include "clutter-backend-private.h"
|
2012-04-17 17:40:43 +00:00
|
|
|
|
#include "clutter-cairo.h"
|
2006-05-29 08:59:36 +00:00
|
|
|
|
#include "clutter-color.h"
|
2010-10-21 10:59:50 +00:00
|
|
|
|
#include "clutter-container.h"
|
|
|
|
|
#include "clutter-debug.h"
|
|
|
|
|
#include "clutter-device-manager-private.h"
|
|
|
|
|
#include "clutter-enum-types.h"
|
2011-02-18 16:27:49 +00:00
|
|
|
|
#include "clutter-event-private.h"
|
2011-04-11 13:11:39 +00:00
|
|
|
|
#include "clutter-id-pool.h"
|
2010-10-21 10:59:50 +00:00
|
|
|
|
#include "clutter-main.h"
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
#include "clutter-marshal.h"
|
2009-03-21 20:39:32 +00:00
|
|
|
|
#include "clutter-master-clock.h"
|
2010-10-21 10:59:50 +00:00
|
|
|
|
#include "clutter-paint-volume-private.h"
|
2006-11-21 Emmanuele Bassi <ebassi@openedhand.com>
* configure.ac: Enable debug messages also when
--enable-debug is set to "minimum".
* clutter/Makefile.am:
* clutter/clutter-debug.h: Move all debugging macros inside
this private header; make all debug macros depend on the
CLUTTER_ENABLE_DEBUG compile time define, controlled by
the --enable-debug configure switch; add G_LOG_DOMAIN define.
* clutter/clutter-main.c: Clean up the debug stuff; add
command line argument parsing using GOption; the debug
messages now are triggered like this:
CLUTTER_DEBUG=section:section:... clutter-app
or like this:
clutter-app --clutter-debug=section:section:...
where "section" is one of the sections listed in clutter-main.c,
or "all", for all sections; each section is bound to a flag,
which can be used to define a domain when adding a debug note
using the CLUTTER_NOTE() macro; the old CLUTTER_DBG() macro is
just a wrapper around that, under the CLUTTER_DEBUG_MISC domain;
CLUTTER_NOTE() is used like this:
CLUTTER_NOTE (DOMAIN, log-function);
where log function is g_printerr(), g_message(), g_warning(),
g_critical() or directly g_log() - for instance:
CLUTTER_NOTE (PANGO, g_warning ("Cache miss: %d", glyph));
will print the warning only if the "pango" flag has been
set to the CLUTTER_DEBUG envvar or passed to the --clutter-debug
command line argument.
similar to CLUTTER_SHOW_FPS, there's also the --clutter-show-fps
command line switch; also, the --display and --screen command
line switches have been added: the first overrides the DISPLAY
envvar and the second controls the X screen used by Clutter to
get the root window on the display.
* clutter/clutter-main.h:
* clutter/clutter-main.c: Add extended support for GOption
in Clutter; use clutter_init_with_args() to let Clutter
parse your own command line arguments; use instead
clutter_get_option_group() to get the GOptionGroup used by
Clutter if you want to do the parsing yourself with
g_option_context_parse(). The init sequence has been verified,
updated and moved into common functions where possible.
* clutter/pango/pangoclutter-render.c:
* clutter/*.c: Include "clutter-debug.h" where needed; use
CLUTTER_NOTE() instead of CLUTTER_DBG().
* examples/super-oh.c: Use the new clutter_init_with_args()
function, and add a --num-hands command line switch to
the SuperOH example code controlling the number of hands at
runtime.
2006-11-21 21:27:53 +00:00
|
|
|
|
#include "clutter-private.h"
|
2009-03-30 15:41:02 +00:00
|
|
|
|
#include "clutter-profile.h"
|
2010-10-21 10:59:50 +00:00
|
|
|
|
#include "clutter-stage-manager-private.h"
|
2010-10-21 10:29:09 +00:00
|
|
|
|
#include "clutter-stage-private.h"
|
2010-10-21 10:59:50 +00:00
|
|
|
|
#include "clutter-version.h" /* For flavour */
|
2011-03-15 13:17:04 +00:00
|
|
|
|
#include "clutter-private.h"
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
|
#include "cogl/cogl.h"
|
2007-03-25 11:47:30 +00:00
|
|
|
|
|
2012-08-24 07:46:59 +00:00
|
|
|
|
G_DEFINE_TYPE (ClutterStage, clutter_stage, CLUTTER_TYPE_ACTOR)
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
#define CLUTTER_STAGE_GET_PRIVATE(obj) \
|
|
|
|
|
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), CLUTTER_TYPE_STAGE, ClutterStagePrivate))
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
2010-04-16 14:34:36 +00:00
|
|
|
|
/* <private>
|
|
|
|
|
* ClutterStageHint:
|
|
|
|
|
* @CLUTTER_STAGE_NONE: No hint set
|
|
|
|
|
* @CLUTTER_STAGE_NO_CLEAR_ON_PAINT: When this hint is set, the stage
|
|
|
|
|
* should not clear the viewport; this flag is useful when painting
|
|
|
|
|
* fully opaque actors covering the whole visible area of the stage,
|
|
|
|
|
* i.e. when no blending with the stage color happens over the whole
|
|
|
|
|
* stage viewport
|
|
|
|
|
*
|
|
|
|
|
* A series of hints that enable or disable behaviours on the stage
|
|
|
|
|
*/
|
|
|
|
|
typedef enum { /*< prefix=CLUTTER_STAGE >*/
|
|
|
|
|
CLUTTER_STAGE_HINT_NONE = 0,
|
|
|
|
|
|
|
|
|
|
CLUTTER_STAGE_NO_CLEAR_ON_PAINT = 1 << 0
|
|
|
|
|
} ClutterStageHint;
|
|
|
|
|
|
|
|
|
|
#define STAGE_NO_CLEAR_ON_PAINT(s) ((((ClutterStage *) (s))->priv->stage_hints & CLUTTER_STAGE_NO_CLEAR_ON_PAINT) != 0)
|
|
|
|
|
|
2010-09-10 00:33:02 +00:00
|
|
|
|
struct _ClutterStageQueueRedrawEntry
|
|
|
|
|
{
|
|
|
|
|
ClutterActor *actor;
|
|
|
|
|
gboolean has_clip;
|
|
|
|
|
ClutterPaintVolume clip;
|
|
|
|
|
};
|
|
|
|
|
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
struct _ClutterStagePrivate
|
2006-05-29 08:59:36 +00:00
|
|
|
|
{
|
2008-04-04 15:02:11 +00:00
|
|
|
|
/* the stage implementation */
|
2009-08-13 11:34:07 +00:00
|
|
|
|
ClutterStageWindow *impl;
|
2008-04-04 15:02:11 +00:00
|
|
|
|
|
2012-01-25 21:24:47 +00:00
|
|
|
|
ClutterPerspective perspective;
|
|
|
|
|
CoglMatrix projection;
|
|
|
|
|
CoglMatrix inverse_projection;
|
|
|
|
|
CoglMatrix view;
|
|
|
|
|
float viewport[4];
|
2007-03-22 18:21:59 +00:00
|
|
|
|
|
2012-01-25 21:24:47 +00:00
|
|
|
|
gchar *title;
|
|
|
|
|
ClutterActor *key_focused_actor;
|
2008-04-04 15:02:11 +00:00
|
|
|
|
|
2012-01-25 21:24:47 +00:00
|
|
|
|
GQueue *event_queue;
|
2010-04-16 14:34:36 +00:00
|
|
|
|
|
2012-01-25 21:24:47 +00:00
|
|
|
|
ClutterStageHint stage_hints;
|
2010-09-10 23:29:05 +00:00
|
|
|
|
|
2012-01-25 21:24:47 +00:00
|
|
|
|
gint picks_per_frame;
|
2010-09-07 17:04:19 +00:00
|
|
|
|
|
2012-01-25 21:24:47 +00:00
|
|
|
|
GArray *paint_volume_stack;
|
2010-09-07 21:21:28 +00:00
|
|
|
|
|
2012-01-25 21:24:47 +00:00
|
|
|
|
ClutterPlane current_clip_planes[4];
|
2010-09-10 00:33:02 +00:00
|
|
|
|
|
2012-01-25 21:24:47 +00:00
|
|
|
|
GList *pending_queue_redraws;
|
2010-10-27 17:02:47 +00:00
|
|
|
|
|
2012-01-25 21:24:47 +00:00
|
|
|
|
ClutterPickMode pick_buffer_mode;
|
|
|
|
|
|
|
|
|
|
CoglFramebuffer *active_framebuffer;
|
2011-03-10 22:05:03 +00:00
|
|
|
|
|
2012-11-08 17:42:24 +00:00
|
|
|
|
gint sync_delay;
|
|
|
|
|
|
2011-02-18 12:56:17 +00:00
|
|
|
|
GTimer *fps_timer;
|
|
|
|
|
gint32 timer_n_frames;
|
|
|
|
|
|
2011-04-11 13:11:39 +00:00
|
|
|
|
ClutterIDPool *pick_id_pool;
|
|
|
|
|
|
2011-02-18 14:38:54 +00:00
|
|
|
|
#ifdef CLUTTER_ENABLE_DEBUG
|
|
|
|
|
gulong redraw_count;
|
|
|
|
|
#endif /* CLUTTER_ENABLE_DEBUG */
|
|
|
|
|
|
2012-01-25 21:24:47 +00:00
|
|
|
|
ClutterStageState current_state;
|
|
|
|
|
|
2010-09-07 19:08:00 +00:00
|
|
|
|
guint relayout_pending : 1;
|
2009-07-14 12:47:35 +00:00
|
|
|
|
guint redraw_pending : 1;
|
|
|
|
|
guint is_fullscreen : 1;
|
|
|
|
|
guint is_cursor_visible : 1;
|
|
|
|
|
guint is_user_resizable : 1;
|
|
|
|
|
guint throttle_motion_events : 1;
|
2009-12-01 16:16:18 +00:00
|
|
|
|
guint use_alpha : 1;
|
2010-02-26 18:36:38 +00:00
|
|
|
|
guint min_size_changed : 1;
|
2010-09-07 12:10:55 +00:00
|
|
|
|
guint dirty_viewport : 1;
|
|
|
|
|
guint dirty_projection : 1;
|
2010-09-10 23:29:05 +00:00
|
|
|
|
guint have_valid_pick_buffer : 1;
|
2010-12-28 17:37:18 +00:00
|
|
|
|
guint accept_focus : 1;
|
Store the motion event deliver flag in ClutterStage
Once upon a time, the land of Clutter had a stage singleton. It was
created automatically at initialization time and stayed around even
after the main loop was terminated. The singleton was content in
being all there was. There also was a global API to handle the
configuration of the stage singleton that would affect the behaviour
on other classes, signals and properties.
Then, an evil wizard came along and locked the stage singleton in his
black tower, and twisted it until it was possible to create new stages.
These new stages were pesky, and didn't have the same semantics of the
singleton: they didn't stay around when closed, or terminate the main
loop on delete events.
The evil wizard also started moving all the stage-related API from the
global context into class-specific methods.
Finally, the evil wizard cast a spell, and the stage singleton was
demoted to creation on demand - and until somebody called the
clutter_stage_get_default() function, the singleton remained in a limbo
of NULL pointers and undefined memory areas.
There was a last bit - literally - of information still held by the
global API; a tiny, little flag that disabled per-actor motion events.
The evil wizard added private accessors for it, and stored it inside the
stage private structure, in preparation for a deprecation that would
come in a future development cycle.
The evil wizard looked down upon the land of Clutter from the height of
his black tower; the lay of the land had been reshaped into a crucible
of potential, and the last dregs of the original force of creation were
either molted into new, useful shapes, or blasted away by the sheer fury
of his will.
All was good.
2011-02-18 17:19:04 +00:00
|
|
|
|
guint motion_events_enabled : 1;
|
2011-04-04 17:42:52 +00:00
|
|
|
|
guint has_custom_perspective : 1;
|
2006-05-29 08:59:36 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
PROP_0,
|
2007-10-12 08:17:00 +00:00
|
|
|
|
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
PROP_COLOR,
|
2009-06-09 12:48:03 +00:00
|
|
|
|
PROP_FULLSCREEN_SET,
|
2006-06-02 20:24:55 +00:00
|
|
|
|
PROP_OFFSCREEN,
|
2007-05-25 10:56:09 +00:00
|
|
|
|
PROP_CURSOR_VISIBLE,
|
|
|
|
|
PROP_PERSPECTIVE,
|
2007-06-19 09:10:37 +00:00
|
|
|
|
PROP_TITLE,
|
2010-08-11 11:40:22 +00:00
|
|
|
|
PROP_USER_RESIZABLE,
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
PROP_USE_FOG,
|
2009-12-01 16:16:18 +00:00
|
|
|
|
PROP_FOG,
|
2010-02-01 11:04:59 +00:00
|
|
|
|
PROP_USE_ALPHA,
|
2010-04-16 14:34:36 +00:00
|
|
|
|
PROP_KEY_FOCUS,
|
2010-12-28 17:37:18 +00:00
|
|
|
|
PROP_NO_CLEAR_HINT,
|
|
|
|
|
PROP_ACCEPT_FOCUS
|
2006-05-29 08:59:36 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
|
{
|
2007-08-24 15:12:52 +00:00
|
|
|
|
FULLSCREEN,
|
|
|
|
|
UNFULLSCREEN,
|
|
|
|
|
ACTIVATE,
|
|
|
|
|
DEACTIVATE,
|
2010-01-12 15:44:28 +00:00
|
|
|
|
DELETE_EVENT,
|
2009-01-12 14:19:48 +00:00
|
|
|
|
|
2006-05-29 08:59:36 +00:00
|
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
|
|
|
|
|
2007-04-25 14:22:24 +00:00
|
|
|
|
static guint stage_signals[LAST_SIGNAL] = { 0, };
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
|
2008-11-17 14:21:49 +00:00
|
|
|
|
static const ClutterColor default_stage_color = { 255, 255, 255, 255 };
|
|
|
|
|
|
2010-09-10 00:33:02 +00:00
|
|
|
|
static void _clutter_stage_maybe_finish_queue_redraws (ClutterStage *stage);
|
2012-06-24 17:29:22 +00:00
|
|
|
|
static void free_queue_redraw_entry (ClutterStageQueueRedrawEntry *entry);
|
2010-09-10 00:33:02 +00:00
|
|
|
|
|
2008-04-04 15:02:11 +00:00
|
|
|
|
static void
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
|
clutter_stage_get_preferred_width (ClutterActor *self,
|
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
|
|
|
|
gfloat for_height,
|
|
|
|
|
gfloat *min_width_p,
|
|
|
|
|
gfloat *natural_width_p)
|
2008-04-04 15:02:11 +00:00
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv = CLUTTER_STAGE (self)->priv;
|
2011-08-16 15:01:22 +00:00
|
|
|
|
cairo_rectangle_int_t geom;
|
2008-04-04 15:02:11 +00:00
|
|
|
|
|
2009-06-16 15:38:01 +00:00
|
|
|
|
if (priv->impl == NULL)
|
|
|
|
|
return;
|
2008-04-04 15:02:11 +00:00
|
|
|
|
|
2009-08-13 11:34:07 +00:00
|
|
|
|
_clutter_stage_window_get_geometry (priv->impl, &geom);
|
|
|
|
|
|
|
|
|
|
if (min_width_p)
|
|
|
|
|
*min_width_p = geom.width;
|
|
|
|
|
|
|
|
|
|
if (natural_width_p)
|
|
|
|
|
*natural_width_p = geom.width;
|
2008-04-04 15:02:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
|
clutter_stage_get_preferred_height (ClutterActor *self,
|
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
|
|
|
|
gfloat for_width,
|
|
|
|
|
gfloat *min_height_p,
|
|
|
|
|
gfloat *natural_height_p)
|
2008-04-04 15:02:11 +00:00
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv = CLUTTER_STAGE (self)->priv;
|
2011-08-16 15:01:22 +00:00
|
|
|
|
cairo_rectangle_int_t geom;
|
2008-04-04 15:02:11 +00:00
|
|
|
|
|
2009-06-16 15:38:01 +00:00
|
|
|
|
if (priv->impl == NULL)
|
|
|
|
|
return;
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
|
|
2009-08-13 11:34:07 +00:00
|
|
|
|
_clutter_stage_window_get_geometry (priv->impl, &geom);
|
|
|
|
|
|
|
|
|
|
if (min_height_p)
|
|
|
|
|
*min_height_p = geom.height;
|
|
|
|
|
|
|
|
|
|
if (natural_height_p)
|
|
|
|
|
*natural_height_p = geom.height;
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
|
}
|
2010-09-07 22:25:18 +00:00
|
|
|
|
|
2010-09-30 09:27:10 +00:00
|
|
|
|
static inline void
|
2010-09-07 22:25:18 +00:00
|
|
|
|
queue_full_redraw (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
ClutterStageWindow *stage_window;
|
|
|
|
|
|
2010-09-30 09:27:10 +00:00
|
|
|
|
if (CLUTTER_ACTOR_IN_DESTRUCTION (stage))
|
|
|
|
|
return;
|
|
|
|
|
|
2010-09-07 22:25:18 +00:00
|
|
|
|
clutter_actor_queue_redraw (CLUTTER_ACTOR (stage));
|
|
|
|
|
|
|
|
|
|
/* Just calling clutter_actor_queue_redraw will typically only
|
|
|
|
|
* redraw the bounding box of the children parented on the stage but
|
|
|
|
|
* in this case we really need to ensure that the full stage is
|
|
|
|
|
* redrawn so we add a NULL redraw clip to the stage window. */
|
|
|
|
|
stage_window = _clutter_stage_get_window (stage);
|
2010-09-30 09:27:10 +00:00
|
|
|
|
if (stage_window == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
2010-09-07 22:25:18 +00:00
|
|
|
|
_clutter_stage_window_add_redraw_clip (stage_window, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
|
static void
|
2009-06-03 13:02:06 +00:00
|
|
|
|
clutter_stage_allocate (ClutterActor *self,
|
|
|
|
|
const ClutterActorBox *box,
|
|
|
|
|
ClutterAllocationFlags flags)
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv = CLUTTER_STAGE (self)->priv;
|
2012-08-10 13:06:49 +00:00
|
|
|
|
ClutterActorBox alloc = CLUTTER_ACTOR_BOX_INIT_ZERO;
|
|
|
|
|
float old_width, old_height;
|
|
|
|
|
float new_width, new_height;
|
|
|
|
|
float width, height;
|
2011-08-16 15:01:22 +00:00
|
|
|
|
cairo_rectangle_int_t window_size;
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
|
|
2009-06-16 15:38:01 +00:00
|
|
|
|
if (priv->impl == NULL)
|
|
|
|
|
return;
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
|
|
2011-08-16 15:01:22 +00:00
|
|
|
|
/* our old allocation */
|
2012-08-10 13:06:49 +00:00
|
|
|
|
clutter_actor_get_allocation_box (self, &alloc);
|
|
|
|
|
clutter_actor_box_get_size (&alloc, &old_width, &old_height);
|
2010-09-08 10:32:29 +00:00
|
|
|
|
|
2011-08-16 15:01:22 +00:00
|
|
|
|
/* the current allocation */
|
2012-08-10 13:06:49 +00:00
|
|
|
|
clutter_actor_box_get_size (box, &width, &height);
|
2010-02-15 18:53:58 +00:00
|
|
|
|
|
2011-08-16 15:01:22 +00:00
|
|
|
|
/* the current Stage implementation size */
|
|
|
|
|
_clutter_stage_window_get_geometry (priv->impl, &window_size);
|
|
|
|
|
|
|
|
|
|
/* if the stage is fixed size (for instance, it's using a EGL framebuffer)
|
2008-06-25 13:05:59 +00:00
|
|
|
|
* then we simply ignore any allocation request and override the
|
2011-08-16 15:01:22 +00:00
|
|
|
|
* allocation chain - because we cannot forcibly change the size of the
|
|
|
|
|
* stage window.
|
2008-06-25 11:49:43 +00:00
|
|
|
|
*/
|
2012-08-10 13:06:49 +00:00
|
|
|
|
if (!clutter_feature_available (CLUTTER_FEATURE_STAGE_STATIC))
|
2008-06-25 11:49:43 +00:00
|
|
|
|
{
|
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
|
|
|
|
CLUTTER_NOTE (LAYOUT,
|
2013-03-25 17:57:28 +00:00
|
|
|
|
"Following allocation to %.2fx%.2f (absolute origin %s)",
|
2009-08-13 11:34:07 +00:00
|
|
|
|
width, height,
|
2013-03-25 17:57:28 +00:00
|
|
|
|
(flags & CLUTTER_ABSOLUTE_ORIGIN_CHANGED)
|
|
|
|
|
? "changed"
|
|
|
|
|
: "not changed");
|
2008-06-25 13:32:03 +00:00
|
|
|
|
|
2012-01-23 18:00:01 +00:00
|
|
|
|
clutter_actor_set_allocation (self, box,
|
|
|
|
|
flags | CLUTTER_DELEGATE_LAYOUT);
|
2008-06-25 11:49:43 +00:00
|
|
|
|
|
2010-02-15 18:53:58 +00:00
|
|
|
|
/* Ensure the window is sized correctly */
|
2010-02-26 18:36:38 +00:00
|
|
|
|
if (!priv->is_fullscreen)
|
|
|
|
|
{
|
|
|
|
|
if (priv->min_size_changed)
|
|
|
|
|
{
|
|
|
|
|
gfloat min_width, min_height;
|
|
|
|
|
gboolean min_width_set, min_height_set;
|
|
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (self),
|
|
|
|
|
"min-width", &min_width,
|
|
|
|
|
"min-width-set", &min_width_set,
|
|
|
|
|
"min-height", &min_height,
|
|
|
|
|
"min-height-set", &min_height_set,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
if (!min_width_set)
|
|
|
|
|
min_width = 1;
|
|
|
|
|
if (!min_height_set)
|
|
|
|
|
min_height = 1;
|
|
|
|
|
|
|
|
|
|
if (width < min_width)
|
|
|
|
|
width = min_width;
|
|
|
|
|
if (height < min_height)
|
|
|
|
|
height = min_height;
|
|
|
|
|
|
|
|
|
|
priv->min_size_changed = FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-10 13:06:49 +00:00
|
|
|
|
if (window_size.width != CLUTTER_NEARBYINT (width) ||
|
|
|
|
|
window_size.height != CLUTTER_NEARBYINT (height))
|
2011-08-16 15:01:22 +00:00
|
|
|
|
{
|
2012-08-10 13:06:49 +00:00
|
|
|
|
_clutter_stage_window_resize (priv->impl,
|
|
|
|
|
CLUTTER_NEARBYINT (width),
|
|
|
|
|
CLUTTER_NEARBYINT (height));
|
2011-08-16 15:01:22 +00:00
|
|
|
|
}
|
2010-02-26 18:36:38 +00:00
|
|
|
|
}
|
2008-06-25 11:49:43 +00:00
|
|
|
|
}
|
2008-06-25 13:05:59 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ClutterActorBox override = { 0, };
|
2008-06-26 21:42:44 +00:00
|
|
|
|
|
2011-08-16 15:01:22 +00:00
|
|
|
|
/* override the passed allocation */
|
2008-06-25 13:05:59 +00:00
|
|
|
|
override.x1 = 0;
|
|
|
|
|
override.y1 = 0;
|
2011-08-16 15:01:22 +00:00
|
|
|
|
override.x2 = window_size.width;
|
|
|
|
|
override.y2 = window_size.height;
|
2008-06-25 13:32:03 +00:00
|
|
|
|
|
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
|
|
|
|
CLUTTER_NOTE (LAYOUT,
|
2012-09-13 10:05:21 +00:00
|
|
|
|
"Overriding original allocation of %dx%d "
|
2013-03-25 17:57:28 +00:00
|
|
|
|
"with %.2fx%.2f (absolute origin %s)",
|
2009-08-13 11:34:07 +00:00
|
|
|
|
width, height,
|
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
|
|
|
|
(int) (override.x2),
|
|
|
|
|
(int) (override.y2),
|
2013-03-25 17:57:28 +00:00
|
|
|
|
(flags & CLUTTER_ABSOLUTE_ORIGIN_CHANGED)
|
|
|
|
|
? "changed"
|
|
|
|
|
: "not changed");
|
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
|
|
|
|
|
2008-06-26 21:42:44 +00:00
|
|
|
|
/* and store the overridden allocation */
|
2012-01-23 18:00:01 +00:00
|
|
|
|
clutter_actor_set_allocation (self, &override,
|
|
|
|
|
flags | CLUTTER_DELEGATE_LAYOUT);
|
2008-06-25 13:05:59 +00:00
|
|
|
|
}
|
2010-09-07 12:10:55 +00:00
|
|
|
|
|
2010-10-21 15:27:17 +00:00
|
|
|
|
/* XXX: Until Cogl becomes fully responsible for backend windows
|
|
|
|
|
* Clutter need to manually keep it informed of the current window
|
|
|
|
|
* size. We do this after the allocation above so that the stage
|
|
|
|
|
* window has a chance to update the window size based on the
|
2011-08-16 15:01:22 +00:00
|
|
|
|
* allocation.
|
|
|
|
|
*/
|
|
|
|
|
_clutter_stage_window_get_geometry (priv->impl, &window_size);
|
|
|
|
|
cogl_onscreen_clutter_backend_set_size (window_size.width,
|
|
|
|
|
window_size.height);
|
2010-10-21 15:27:17 +00:00
|
|
|
|
|
2011-08-16 15:01:22 +00:00
|
|
|
|
/* reset the viewport if the allocation effectively changed */
|
2012-08-10 13:06:49 +00:00
|
|
|
|
clutter_actor_get_allocation_box (self, &alloc);
|
|
|
|
|
clutter_actor_box_get_size (&alloc, &new_width, &new_height);
|
|
|
|
|
|
|
|
|
|
if (CLUTTER_NEARBYINT (old_width) != CLUTTER_NEARBYINT (new_width) ||
|
|
|
|
|
CLUTTER_NEARBYINT (old_height) != CLUTTER_NEARBYINT (new_height))
|
2010-09-08 10:32:29 +00:00
|
|
|
|
{
|
|
|
|
|
_clutter_stage_set_viewport (CLUTTER_STAGE (self),
|
2011-08-16 15:01:22 +00:00
|
|
|
|
0, 0,
|
2012-08-10 13:06:49 +00:00
|
|
|
|
CLUTTER_NEARBYINT (new_width),
|
|
|
|
|
CLUTTER_NEARBYINT (new_height));
|
2010-09-07 12:10:55 +00:00
|
|
|
|
|
2010-09-08 10:32:29 +00:00
|
|
|
|
/* Note: we don't assume that set_viewport will queue a full redraw
|
|
|
|
|
* since it may bail-out early if something preemptively set the
|
2011-08-16 15:01:22 +00:00
|
|
|
|
* viewport before the stage was really allocated its new size.
|
|
|
|
|
*/
|
2010-09-08 10:32:29 +00:00
|
|
|
|
queue_full_redraw (CLUTTER_STAGE (self));
|
|
|
|
|
}
|
2008-04-04 15:02:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:32:08 +00:00
|
|
|
|
typedef struct _Vector4
|
|
|
|
|
{
|
|
|
|
|
float x, y, z, w;
|
|
|
|
|
} Vector4;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
_cogl_util_get_eye_planes_for_screen_poly (float *polygon,
|
|
|
|
|
int n_vertices,
|
|
|
|
|
float *viewport,
|
|
|
|
|
const CoglMatrix *projection,
|
|
|
|
|
const CoglMatrix *inverse_project,
|
|
|
|
|
ClutterPlane *planes)
|
|
|
|
|
{
|
|
|
|
|
float Wc;
|
|
|
|
|
Vector4 *tmp_poly;
|
|
|
|
|
ClutterPlane *plane;
|
|
|
|
|
int i;
|
2012-01-16 15:22:43 +00:00
|
|
|
|
float b[3];
|
|
|
|
|
float c[3];
|
2011-02-01 18:32:08 +00:00
|
|
|
|
int count;
|
|
|
|
|
|
|
|
|
|
tmp_poly = g_alloca (sizeof (Vector4) * n_vertices * 2);
|
|
|
|
|
|
|
|
|
|
#define DEPTH -50
|
|
|
|
|
|
|
|
|
|
/* Determine W in clip-space (Wc) for a point (0, 0, DEPTH, 1)
|
|
|
|
|
*
|
|
|
|
|
* Note: the depth could be anything except 0.
|
|
|
|
|
*
|
|
|
|
|
* We will transform the polygon into clip coordinates using this
|
|
|
|
|
* depth and then into eye coordinates. Our clip planes will be
|
|
|
|
|
* defined by triangles that extend between points of the polygon at
|
|
|
|
|
* DEPTH and corresponding points of the same polygon at DEPTH * 2.
|
|
|
|
|
*
|
|
|
|
|
* NB: Wc defines the position of the clip planes in clip
|
|
|
|
|
* coordinates. Given a screen aligned cross section through the
|
|
|
|
|
* frustum; coordinates range from [-Wc,Wc] left to right on the
|
|
|
|
|
* x-axis and [Wc,-Wc] top to bottom on the y-axis.
|
|
|
|
|
*/
|
|
|
|
|
Wc = DEPTH * projection->wz + projection->ww;
|
|
|
|
|
|
|
|
|
|
#define CLIP_X(X) ((((float)X - viewport[0]) * (2.0 / viewport[2])) - 1) * Wc
|
|
|
|
|
#define CLIP_Y(Y) ((((float)Y - viewport[1]) * (2.0 / viewport[3])) - 1) * -Wc
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < n_vertices; i++)
|
|
|
|
|
{
|
|
|
|
|
tmp_poly[i].x = CLIP_X (polygon[i * 2]);
|
|
|
|
|
tmp_poly[i].y = CLIP_Y (polygon[i * 2 + 1]);
|
|
|
|
|
tmp_poly[i].z = DEPTH;
|
|
|
|
|
tmp_poly[i].w = Wc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Wc = DEPTH * 2 * projection->wz + projection->ww;
|
|
|
|
|
|
|
|
|
|
/* FIXME: technically we don't need to project all of the points
|
|
|
|
|
* twice, it would be enough project every other point since
|
|
|
|
|
* we can share points in this set to define the plane vectors. */
|
|
|
|
|
for (i = 0; i < n_vertices; i++)
|
|
|
|
|
{
|
|
|
|
|
tmp_poly[n_vertices + i].x = CLIP_X (polygon[i * 2]);
|
|
|
|
|
tmp_poly[n_vertices + i].y = CLIP_Y (polygon[i * 2 + 1]);
|
|
|
|
|
tmp_poly[n_vertices + i].z = DEPTH * 2;
|
|
|
|
|
tmp_poly[n_vertices + i].w = Wc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#undef CLIP_X
|
|
|
|
|
#undef CLIP_Y
|
|
|
|
|
|
|
|
|
|
cogl_matrix_project_points (inverse_project,
|
|
|
|
|
4,
|
|
|
|
|
sizeof (Vector4),
|
|
|
|
|
tmp_poly,
|
|
|
|
|
sizeof (Vector4),
|
|
|
|
|
tmp_poly,
|
|
|
|
|
n_vertices * 2);
|
|
|
|
|
|
|
|
|
|
/* XXX: It's quite ugly that we end up with these casts between
|
|
|
|
|
* Vector4 types and CoglVector3s, it might be better if the
|
|
|
|
|
* cogl_vector APIs just took pointers to floats.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
count = n_vertices - 1;
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
plane = &planes[i];
|
2012-01-16 15:22:43 +00:00
|
|
|
|
memcpy (plane->v0, tmp_poly + i, sizeof (float) * 3);
|
|
|
|
|
memcpy (b, tmp_poly + n_vertices + i, sizeof (float) * 3);
|
|
|
|
|
memcpy (c, tmp_poly + n_vertices + i + 1, sizeof (float) * 3);
|
|
|
|
|
cogl_vector3_subtract (b, b, plane->v0);
|
|
|
|
|
cogl_vector3_subtract (c, c, plane->v0);
|
|
|
|
|
cogl_vector3_cross_product (plane->n, b, c);
|
|
|
|
|
cogl_vector3_normalize (plane->n);
|
2011-02-01 18:32:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
plane = &planes[n_vertices - 1];
|
2012-01-16 15:22:43 +00:00
|
|
|
|
memcpy (plane->v0, tmp_poly + 0, sizeof (float) * 3);
|
|
|
|
|
memcpy (b, tmp_poly + (2 * n_vertices - 1), sizeof (float) * 3);
|
|
|
|
|
memcpy (c, tmp_poly + n_vertices, sizeof (float) * 3);
|
|
|
|
|
cogl_vector3_subtract (b, b, plane->v0);
|
|
|
|
|
cogl_vector3_subtract (c, c, plane->v0);
|
|
|
|
|
cogl_vector3_cross_product (plane->n, b, c);
|
|
|
|
|
cogl_vector3_normalize (plane->n);
|
2011-02-01 18:32:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-03-10 22:05:03 +00:00
|
|
|
|
static void
|
|
|
|
|
_clutter_stage_update_active_framebuffer (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv = stage->priv;
|
|
|
|
|
|
|
|
|
|
/* We track the CoglFramebuffer that corresponds to the stage itself
|
|
|
|
|
* so, for example, we can disable culling when rendering to an
|
|
|
|
|
* offscreen framebuffer.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
priv->active_framebuffer =
|
|
|
|
|
_clutter_stage_window_get_active_framebuffer (priv->impl);
|
|
|
|
|
|
|
|
|
|
if (!priv->active_framebuffer)
|
|
|
|
|
priv->active_framebuffer = cogl_get_draw_framebuffer ();
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-07 17:04:19 +00:00
|
|
|
|
/* This provides a common point of entry for painting the scenegraph
|
|
|
|
|
* for picking or painting...
|
2010-09-07 21:21:28 +00:00
|
|
|
|
*
|
|
|
|
|
* XXX: Instead of having a toplevel 2D clip region, it might be
|
|
|
|
|
* better to have a clip volume within the view frustum. This could
|
|
|
|
|
* allow us to avoid projecting actors into window coordinates to
|
|
|
|
|
* be able to cull them.
|
2010-09-07 17:04:19 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
2011-08-16 15:01:22 +00:00
|
|
|
|
_clutter_stage_do_paint (ClutterStage *stage,
|
|
|
|
|
const cairo_rectangle_int_t *clip)
|
2010-09-07 17:04:19 +00:00
|
|
|
|
{
|
2010-09-07 21:21:28 +00:00
|
|
|
|
ClutterStagePrivate *priv = stage->priv;
|
2011-02-01 18:32:08 +00:00
|
|
|
|
float clip_poly[8];
|
2011-08-16 15:01:22 +00:00
|
|
|
|
cairo_rectangle_int_t geom;
|
2011-09-19 11:54:31 +00:00
|
|
|
|
|
|
|
|
|
_clutter_stage_window_get_geometry (priv->impl, &geom);
|
2011-02-01 18:32:08 +00:00
|
|
|
|
|
|
|
|
|
if (clip)
|
|
|
|
|
{
|
2011-09-19 11:54:31 +00:00
|
|
|
|
clip_poly[0] = MAX (clip->x, 0);
|
|
|
|
|
clip_poly[1] = MAX (clip->y, 0);
|
|
|
|
|
clip_poly[2] = MIN (clip->x + clip->width, geom.width);
|
|
|
|
|
clip_poly[3] = clip_poly[1];
|
|
|
|
|
clip_poly[4] = clip_poly[2];
|
|
|
|
|
clip_poly[5] = MIN (clip->y + clip->height, geom.height);
|
|
|
|
|
clip_poly[6] = clip_poly[0];
|
|
|
|
|
clip_poly[7] = clip_poly[5];
|
2011-02-01 18:32:08 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
clip_poly[0] = 0;
|
|
|
|
|
clip_poly[1] = 0;
|
|
|
|
|
clip_poly[2] = geom.width;
|
|
|
|
|
clip_poly[3] = 0;
|
|
|
|
|
clip_poly[4] = geom.width;
|
|
|
|
|
clip_poly[5] = geom.height;
|
|
|
|
|
clip_poly[6] = 0;
|
|
|
|
|
clip_poly[7] = geom.height;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-10 18:50:23 +00:00
|
|
|
|
CLUTTER_NOTE (CLIPPING, "Setting stage clip too: "
|
|
|
|
|
"x=%f, y=%f, width=%f, height=%f",
|
|
|
|
|
clip_poly[0], clip_poly[1],
|
|
|
|
|
clip_poly[2] - clip_poly[0],
|
|
|
|
|
clip_poly[5] - clip_poly[1]);
|
|
|
|
|
|
2011-02-01 18:32:08 +00:00
|
|
|
|
_cogl_util_get_eye_planes_for_screen_poly (clip_poly,
|
|
|
|
|
4,
|
|
|
|
|
priv->viewport,
|
|
|
|
|
&priv->projection,
|
|
|
|
|
&priv->inverse_projection,
|
|
|
|
|
priv->current_clip_planes);
|
|
|
|
|
|
2010-09-07 17:04:19 +00:00
|
|
|
|
_clutter_stage_paint_volume_stack_free_all (stage);
|
2011-03-10 22:05:03 +00:00
|
|
|
|
_clutter_stage_update_active_framebuffer (stage);
|
2010-09-07 17:04:19 +00:00
|
|
|
|
clutter_actor_paint (CLUTTER_ACTOR (stage));
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-23 16:37:56 +00:00
|
|
|
|
static void
|
2007-05-28 18:49:34 +00:00
|
|
|
|
clutter_stage_paint (ClutterActor *self)
|
2007-03-23 16:37:56 +00:00
|
|
|
|
{
|
2007-07-04 09:36:44 +00:00
|
|
|
|
ClutterStagePrivate *priv = CLUTTER_STAGE (self)->priv;
|
2010-04-16 14:34:36 +00:00
|
|
|
|
CoglBufferBit clear_flags;
|
2012-02-13 16:05:21 +00:00
|
|
|
|
ClutterColor bg_color;
|
2008-10-30 16:50:07 +00:00
|
|
|
|
CoglColor stage_color;
|
2012-01-25 15:31:51 +00:00
|
|
|
|
ClutterActorIter iter;
|
2012-01-23 18:00:01 +00:00
|
|
|
|
ClutterActor *child;
|
2009-12-07 17:35:17 +00:00
|
|
|
|
guint8 real_alpha;
|
2012-01-21 23:06:49 +00:00
|
|
|
|
|
2009-03-30 15:41:02 +00:00
|
|
|
|
CLUTTER_STATIC_TIMER (stage_clear_timer,
|
|
|
|
|
"Painting actors", /* parent */
|
|
|
|
|
"Stage clear",
|
|
|
|
|
"The time spent clearing the stage",
|
|
|
|
|
0 /* no application private data */);
|
2007-07-04 09:36:44 +00:00
|
|
|
|
|
2008-04-04 15:02:11 +00:00
|
|
|
|
CLUTTER_NOTE (PAINT, "Initializing stage paint");
|
|
|
|
|
|
2009-12-07 17:35:17 +00:00
|
|
|
|
/* composite the opacity to the stage color */
|
2012-02-13 16:05:21 +00:00
|
|
|
|
clutter_actor_get_background_color (self, &bg_color);
|
2009-12-07 17:35:17 +00:00
|
|
|
|
real_alpha = clutter_actor_get_opacity (self)
|
2012-02-13 16:05:21 +00:00
|
|
|
|
* bg_color.alpha
|
2009-12-07 17:35:17 +00:00
|
|
|
|
/ 255;
|
|
|
|
|
|
2012-02-13 08:44:40 +00:00
|
|
|
|
clear_flags = COGL_BUFFER_BIT_DEPTH;
|
|
|
|
|
if (!STAGE_NO_CLEAR_ON_PAINT (self))
|
|
|
|
|
clear_flags |= COGL_BUFFER_BIT_COLOR;
|
|
|
|
|
|
|
|
|
|
CLUTTER_TIMER_START (_clutter_uprof_context, stage_clear_timer);
|
2009-12-07 17:35:17 +00:00
|
|
|
|
/* we use the real alpha to clear the stage if :use-alpha is
|
2012-02-13 08:44:40 +00:00
|
|
|
|
* set; the effect depends entirely on the Clutter backend
|
2009-12-07 17:35:17 +00:00
|
|
|
|
*/
|
2010-09-03 15:55:12 +00:00
|
|
|
|
cogl_color_init_from_4ub (&stage_color,
|
2012-02-13 16:05:21 +00:00
|
|
|
|
bg_color.red,
|
|
|
|
|
bg_color.green,
|
|
|
|
|
bg_color.blue,
|
2012-02-13 08:44:40 +00:00
|
|
|
|
priv->use_alpha ? real_alpha : 255);
|
2009-12-09 01:46:09 +00:00
|
|
|
|
cogl_color_premultiply (&stage_color);
|
2010-04-16 14:34:36 +00:00
|
|
|
|
cogl_clear (&stage_color, clear_flags);
|
2009-03-30 15:41:02 +00:00
|
|
|
|
CLUTTER_TIMER_STOP (_clutter_uprof_context, stage_clear_timer);
|
2007-07-04 09:36:44 +00:00
|
|
|
|
|
2012-01-25 15:31:51 +00:00
|
|
|
|
clutter_actor_iter_init (&iter, self);
|
|
|
|
|
while (clutter_actor_iter_next (&iter, &child))
|
|
|
|
|
clutter_actor_paint (child);
|
2007-03-23 16:37:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-11-18 23:24:55 +00:00
|
|
|
|
static void
|
|
|
|
|
clutter_stage_pick (ClutterActor *self,
|
|
|
|
|
const ClutterColor *color)
|
|
|
|
|
{
|
2012-01-25 15:31:51 +00:00
|
|
|
|
ClutterActorIter iter;
|
2011-12-19 12:04:03 +00:00
|
|
|
|
ClutterActor *child;
|
|
|
|
|
|
2009-11-25 20:37:01 +00:00
|
|
|
|
/* Note: we don't chain up to our parent as we don't want any geometry
|
|
|
|
|
* emitted for the stage itself. The stage's pick id is effectively handled
|
|
|
|
|
* by the call to cogl_clear done in clutter-main.c:_clutter_do_pick_async()
|
2007-11-18 23:24:55 +00:00
|
|
|
|
*/
|
2012-01-25 15:31:51 +00:00
|
|
|
|
clutter_actor_iter_init (&iter, self);
|
|
|
|
|
while (clutter_actor_iter_next (&iter, &child))
|
|
|
|
|
clutter_actor_paint (child);
|
2007-11-18 23:24:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-11-23 14:31:45 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
clutter_stage_get_paint_volume (ClutterActor *self,
|
|
|
|
|
ClutterPaintVolume *volume)
|
|
|
|
|
{
|
|
|
|
|
/* Returning False effectively means Clutter has to assume it covers
|
|
|
|
|
* everything... */
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-04 15:02:11 +00:00
|
|
|
|
static void
|
|
|
|
|
clutter_stage_realize (ClutterActor *self)
|
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv = CLUTTER_STAGE (self)->priv;
|
2009-08-13 11:34:07 +00:00
|
|
|
|
gboolean is_realized;
|
2008-04-04 15:02:11 +00:00
|
|
|
|
|
2009-01-21 12:47:29 +00:00
|
|
|
|
/* Make sure the viewport and projection matrix are valid for the
|
2009-05-08 16:17:48 +00:00
|
|
|
|
* first paint (which will likely occur before the ConfigureNotify
|
|
|
|
|
* is received)
|
|
|
|
|
*/
|
2010-09-07 12:10:55 +00:00
|
|
|
|
priv->dirty_viewport = TRUE;
|
|
|
|
|
priv->dirty_projection = TRUE;
|
2009-01-21 12:47:29 +00:00
|
|
|
|
|
2008-04-04 17:26:26 +00:00
|
|
|
|
g_assert (priv->impl != NULL);
|
2009-08-13 11:34:07 +00:00
|
|
|
|
is_realized = _clutter_stage_window_realize (priv->impl);
|
2008-04-04 15:02:11 +00:00
|
|
|
|
|
2008-05-12 Emmanuele Bassi <ebassi@openedhand.com>
Rework the stage wrapper/implementation relation: remove
duplicated code and all the bookkeeping from the backends into
ClutterStage whenever possible, to reduce the amount of work a
backend must do (and possibly get wrong). Thanks to Tommi
Komulainen.
* clutter/clutter-main.c:
(clutter_init_with_args), (clutter_init): Realize the default
stage after creation. The default stage is special, because we
use it in the initialization sequence. This removes the burden
from the backends and reduces the things a backend can get
wrong.
* clutter/clutter-stage.c:
(clutter_stage_show): Make sure to realize the implementation if
it hasn't been realized yet.
(clutter_stage_realize): Set the REALIZED flag and call
clutter_stage_ensure_current() if the implementation was
successfully realized.
(clutter_stage_unrealized): Call clutter_stage_ensure_current()
on unrealize.
* clutter/glx/clutter-backend-glx.c:
(clutter_backend_glx_create_stage): Do not realize the stage anymore
when creating it, and let the normal realization sequence take
place.
(clutter_backend_glx_ensure_context): Trap for X11 errors.
* clutter/glx/clutter-stage-glx.c:
(clutter_stage_glx_realize): Chain up to the X11 implementation
so that we can set up the window state (title, cursor visibility)
when we actually have a X window. Also, do not call
clutter_stage_ensure_current(), and rely on the wrapper to do
it for us. This means we can drop setting the REALIZED flag on
the wrapper.
(clutter_stage_glx_unrealize): Do not call
clutter_stage_ensure_current() ourselves, and rely on the wrapper
to do it for us.
* clutter/x11/clutter-stage-x11.c:
(set_wm_title), (set_cursor_visible): Move the WM title and
cursor visibility code inside their own functions.
(clutter_stage_x11_realize): Set the window title and whether the
cursor is visible or not after realizing the stage.
(clutter_stage_x11_set_cursor_visible),
(clutter_stage_x11_set_title): Call set_wm_title() and
set_cursor_visible().
(clutter_stage_x11_finalize): Free the title string.
* clutter/x11/clutter-stage-x11.h: Save more of the stage state,
so that we can set it even when the stage hasn't been realized
yet.
* clutter/eglnative/clutter-backend-egl.c:
(clutter_backend_egl_create_stage):
* clutter/eglnative/clutter-stage-egl.c:
(clutter_stage_egl_unrealize),
(clutter_stage_egl_realize): Update the eglnative backend.
* clutter/eglx/clutter-backend-egl.c:
(clutter_backend_egl_ensure_context),
(clutter_backend_egl_create_stage):
* clutter/eglx/clutter-stage-egl.c:
(clutter_stage_egl_unrealize),
(clutter_stage_egl_realize): Update the eglx backend.
* clutter/sdl/clutter-backend-sdl.c:
(clutter_backend_sdl_create_stage):
* clutter/sdl/clutter-stage-sdl.c:
(clutter_stage_sdl_realize): Update the sdl backend.
* clutter/fruity/clutter-backend-fruity.c:
(clutter_backend_fruity_create_stage):
* clutter/sdl/clutter-stage-fruity.c:
(clutter_stage_fruity_realize): Update the fruity backend.
* tests/test-multistage.c (on_button_press): Bail out if
clutter_stage_new() returns NULL.
* HACKING.backends: Update backend writing documentation.
2008-05-12 15:26:37 +00:00
|
|
|
|
/* ensure that the stage is using the context if the
|
|
|
|
|
* realization sequence was successful
|
|
|
|
|
*/
|
2009-08-13 11:34:07 +00:00
|
|
|
|
if (is_realized)
|
|
|
|
|
{
|
2009-11-11 13:26:54 +00:00
|
|
|
|
ClutterBackend *backend = clutter_get_default_backend ();
|
|
|
|
|
|
|
|
|
|
/* We want to select the context without calling
|
|
|
|
|
clutter_backend_ensure_context so that it doesn't call any
|
|
|
|
|
Cogl functions. Otherwise it would create the Cogl context
|
|
|
|
|
before we get a chance to check whether the GL version is
|
|
|
|
|
valid */
|
|
|
|
|
_clutter_backend_ensure_context_internal (backend, CLUTTER_STAGE (self));
|
2009-08-13 11:34:07 +00:00
|
|
|
|
}
|
2008-04-04 17:26:26 +00:00
|
|
|
|
else
|
|
|
|
|
CLUTTER_ACTOR_UNSET_FLAGS (self, CLUTTER_ACTOR_REALIZED);
|
2008-04-04 15:02:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
clutter_stage_unrealize (ClutterActor *self)
|
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv = CLUTTER_STAGE (self)->priv;
|
|
|
|
|
|
|
|
|
|
/* and then unrealize the implementation */
|
2008-04-04 17:26:26 +00:00
|
|
|
|
g_assert (priv->impl != NULL);
|
2009-08-13 11:34:07 +00:00
|
|
|
|
_clutter_stage_window_unrealize (priv->impl);
|
|
|
|
|
|
|
|
|
|
CLUTTER_ACTOR_UNSET_FLAGS (self, CLUTTER_ACTOR_REALIZED);
|
2008-05-12 Emmanuele Bassi <ebassi@openedhand.com>
Rework the stage wrapper/implementation relation: remove
duplicated code and all the bookkeeping from the backends into
ClutterStage whenever possible, to reduce the amount of work a
backend must do (and possibly get wrong). Thanks to Tommi
Komulainen.
* clutter/clutter-main.c:
(clutter_init_with_args), (clutter_init): Realize the default
stage after creation. The default stage is special, because we
use it in the initialization sequence. This removes the burden
from the backends and reduces the things a backend can get
wrong.
* clutter/clutter-stage.c:
(clutter_stage_show): Make sure to realize the implementation if
it hasn't been realized yet.
(clutter_stage_realize): Set the REALIZED flag and call
clutter_stage_ensure_current() if the implementation was
successfully realized.
(clutter_stage_unrealized): Call clutter_stage_ensure_current()
on unrealize.
* clutter/glx/clutter-backend-glx.c:
(clutter_backend_glx_create_stage): Do not realize the stage anymore
when creating it, and let the normal realization sequence take
place.
(clutter_backend_glx_ensure_context): Trap for X11 errors.
* clutter/glx/clutter-stage-glx.c:
(clutter_stage_glx_realize): Chain up to the X11 implementation
so that we can set up the window state (title, cursor visibility)
when we actually have a X window. Also, do not call
clutter_stage_ensure_current(), and rely on the wrapper to do
it for us. This means we can drop setting the REALIZED flag on
the wrapper.
(clutter_stage_glx_unrealize): Do not call
clutter_stage_ensure_current() ourselves, and rely on the wrapper
to do it for us.
* clutter/x11/clutter-stage-x11.c:
(set_wm_title), (set_cursor_visible): Move the WM title and
cursor visibility code inside their own functions.
(clutter_stage_x11_realize): Set the window title and whether the
cursor is visible or not after realizing the stage.
(clutter_stage_x11_set_cursor_visible),
(clutter_stage_x11_set_title): Call set_wm_title() and
set_cursor_visible().
(clutter_stage_x11_finalize): Free the title string.
* clutter/x11/clutter-stage-x11.h: Save more of the stage state,
so that we can set it even when the stage hasn't been realized
yet.
* clutter/eglnative/clutter-backend-egl.c:
(clutter_backend_egl_create_stage):
* clutter/eglnative/clutter-stage-egl.c:
(clutter_stage_egl_unrealize),
(clutter_stage_egl_realize): Update the eglnative backend.
* clutter/eglx/clutter-backend-egl.c:
(clutter_backend_egl_ensure_context),
(clutter_backend_egl_create_stage):
* clutter/eglx/clutter-stage-egl.c:
(clutter_stage_egl_unrealize),
(clutter_stage_egl_realize): Update the eglx backend.
* clutter/sdl/clutter-backend-sdl.c:
(clutter_backend_sdl_create_stage):
* clutter/sdl/clutter-stage-sdl.c:
(clutter_stage_sdl_realize): Update the sdl backend.
* clutter/fruity/clutter-backend-fruity.c:
(clutter_backend_fruity_create_stage):
* clutter/sdl/clutter-stage-fruity.c:
(clutter_stage_fruity_realize): Update the fruity backend.
* tests/test-multistage.c (on_button_press): Bail out if
clutter_stage_new() returns NULL.
* HACKING.backends: Update backend writing documentation.
2008-05-12 15:26:37 +00:00
|
|
|
|
|
|
|
|
|
clutter_stage_ensure_current (CLUTTER_STAGE (self));
|
2008-04-04 15:02:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2012-03-05 17:38:27 +00:00
|
|
|
|
clutter_stage_show_all (ClutterActor *self)
|
2008-04-04 15:02:11 +00:00
|
|
|
|
{
|
2012-01-25 15:31:51 +00:00
|
|
|
|
ClutterActorIter iter;
|
2012-01-23 18:00:01 +00:00
|
|
|
|
ClutterActor *child;
|
|
|
|
|
|
2012-03-05 17:38:27 +00:00
|
|
|
|
/* we don't do a recursive show_all(), to maintain the old
|
|
|
|
|
* invariants from ClutterGroup
|
|
|
|
|
*/
|
2012-01-25 15:31:51 +00:00
|
|
|
|
clutter_actor_iter_init (&iter, self);
|
|
|
|
|
while (clutter_actor_iter_next (&iter, &child))
|
|
|
|
|
clutter_actor_show (child);
|
2008-04-04 15:02:11 +00:00
|
|
|
|
|
2012-03-05 17:38:27 +00:00
|
|
|
|
clutter_actor_show (self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
clutter_stage_show (ClutterActor *self)
|
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv = CLUTTER_STAGE (self)->priv;
|
|
|
|
|
|
2009-05-11 11:43:37 +00:00
|
|
|
|
CLUTTER_ACTOR_CLASS (clutter_stage_parent_class)->show (self);
|
|
|
|
|
|
2009-07-17 11:43:52 +00:00
|
|
|
|
/* Possibly do an allocation run so that the stage will have the
|
|
|
|
|
right size before we map it */
|
|
|
|
|
_clutter_stage_maybe_relayout (self);
|
|
|
|
|
|
2008-04-04 15:02:11 +00:00
|
|
|
|
g_assert (priv->impl != NULL);
|
2009-08-13 11:34:07 +00:00
|
|
|
|
_clutter_stage_window_show (priv->impl, TRUE);
|
2008-04-04 15:02:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2012-03-05 17:38:27 +00:00
|
|
|
|
clutter_stage_hide_all (ClutterActor *self)
|
2008-04-04 15:02:11 +00:00
|
|
|
|
{
|
2012-01-25 15:31:51 +00:00
|
|
|
|
ClutterActorIter iter;
|
2012-01-23 18:00:01 +00:00
|
|
|
|
ClutterActor *child;
|
2009-05-11 11:43:37 +00:00
|
|
|
|
|
2012-03-05 17:38:27 +00:00
|
|
|
|
clutter_actor_hide (self);
|
2009-06-04 15:27:21 +00:00
|
|
|
|
|
2012-03-05 17:38:27 +00:00
|
|
|
|
/* we don't do a recursive hide_all(), to maintain the old invariants
|
|
|
|
|
* from ClutterGroup
|
|
|
|
|
*/
|
2012-01-25 15:31:51 +00:00
|
|
|
|
clutter_actor_iter_init (&iter, self);
|
|
|
|
|
while (clutter_actor_iter_next (&iter, &child))
|
2012-03-05 17:38:27 +00:00
|
|
|
|
clutter_actor_hide (child);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
clutter_stage_hide (ClutterActor *self)
|
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv = CLUTTER_STAGE (self)->priv;
|
|
|
|
|
|
|
|
|
|
g_assert (priv->impl != NULL);
|
|
|
|
|
_clutter_stage_window_hide (priv->impl);
|
2012-01-23 18:00:01 +00:00
|
|
|
|
|
2009-06-04 15:27:21 +00:00
|
|
|
|
CLUTTER_ACTOR_CLASS (clutter_stage_parent_class)->hide (self);
|
2008-04-04 15:02:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-05-07 10:20:19 +00:00
|
|
|
|
static void
|
|
|
|
|
clutter_stage_emit_key_focus_event (ClutterStage *stage,
|
|
|
|
|
gboolean focus_in)
|
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv = stage->priv;
|
|
|
|
|
|
|
|
|
|
if (priv->key_focused_actor == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (focus_in)
|
|
|
|
|
g_signal_emit_by_name (priv->key_focused_actor, "key-focus-in");
|
|
|
|
|
else
|
|
|
|
|
g_signal_emit_by_name (priv->key_focused_actor, "key-focus-out");
|
2012-02-14 15:37:51 +00:00
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (stage), "key-focus");
|
2009-05-07 10:20:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
clutter_stage_real_activate (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
clutter_stage_emit_key_focus_event (stage, TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
clutter_stage_real_deactivate (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
clutter_stage_emit_key_focus_event (stage, FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
|
static void
|
|
|
|
|
clutter_stage_real_fullscreen (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv = stage->priv;
|
2011-08-16 15:01:22 +00:00
|
|
|
|
cairo_rectangle_int_t geom;
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
|
ClutterActorBox box;
|
|
|
|
|
|
|
|
|
|
/* we need to force an allocation here because the size
|
|
|
|
|
* of the stage might have been changed by the backend
|
|
|
|
|
*
|
|
|
|
|
* this is a really bad solution to the issues caused by
|
|
|
|
|
* the fact that fullscreening the stage on the X11 backends
|
|
|
|
|
* is really an asynchronous operation
|
|
|
|
|
*/
|
2009-08-13 11:34:07 +00:00
|
|
|
|
_clutter_stage_window_get_geometry (priv->impl, &geom);
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
|
|
|
|
|
|
box.x1 = 0;
|
|
|
|
|
box.y1 = 0;
|
2009-08-13 11:34:07 +00:00
|
|
|
|
box.x2 = geom.width;
|
|
|
|
|
box.y2 = geom.height;
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
|
|
2012-04-10 11:12:50 +00:00
|
|
|
|
/* we need to blow the caching on the Stage size, given that
|
|
|
|
|
* we're about to force an allocation, because if anything
|
|
|
|
|
* ends up querying the size of the stage during the allocate()
|
|
|
|
|
* call, like constraints or signal handlers, we'll get into an
|
|
|
|
|
* inconsistent state: the stage will report the old cached size,
|
|
|
|
|
* but the allocation will be updated anyway.
|
|
|
|
|
*/
|
|
|
|
|
clutter_actor_set_size (CLUTTER_ACTOR (stage), -1.0, -1.0);
|
2009-06-03 13:02:06 +00:00
|
|
|
|
clutter_actor_allocate (CLUTTER_ACTOR (stage),
|
|
|
|
|
&box,
|
|
|
|
|
CLUTTER_ALLOCATION_NONE);
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-06-06 23:10:41 +00:00
|
|
|
|
void
|
|
|
|
|
_clutter_stage_queue_event (ClutterStage *stage,
|
|
|
|
|
ClutterEvent *event)
|
2009-01-12 14:19:48 +00:00
|
|
|
|
{
|
2009-06-06 23:10:41 +00:00
|
|
|
|
ClutterStagePrivate *priv;
|
2009-06-07 02:48:15 +00:00
|
|
|
|
gboolean first_event;
|
2010-01-08 17:51:00 +00:00
|
|
|
|
ClutterInputDevice *device;
|
2009-03-21 20:39:32 +00:00
|
|
|
|
|
2009-06-06 23:10:41 +00:00
|
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
2009-03-21 20:39:32 +00:00
|
|
|
|
|
2009-06-06 23:10:41 +00:00
|
|
|
|
priv = stage->priv;
|
|
|
|
|
|
2009-06-07 02:48:15 +00:00
|
|
|
|
first_event = priv->event_queue->length == 0;
|
|
|
|
|
|
2010-01-08 17:51:00 +00:00
|
|
|
|
g_queue_push_tail (priv->event_queue, clutter_event_copy (event));
|
2009-06-07 02:48:15 +00:00
|
|
|
|
|
|
|
|
|
if (first_event)
|
|
|
|
|
{
|
|
|
|
|
ClutterMasterClock *master_clock = _clutter_master_clock_get_default ();
|
|
|
|
|
_clutter_master_clock_start_running (master_clock);
|
2012-11-08 17:42:24 +00:00
|
|
|
|
_clutter_stage_schedule_update (stage);
|
2009-06-07 02:48:15 +00:00
|
|
|
|
}
|
2010-01-08 17:51:00 +00:00
|
|
|
|
|
|
|
|
|
/* if needed, update the state of the input device of the event.
|
|
|
|
|
* we do it here to avoid calling the same code from every backend
|
|
|
|
|
* event processing function
|
|
|
|
|
*/
|
|
|
|
|
device = clutter_event_get_device (event);
|
|
|
|
|
if (device != NULL)
|
|
|
|
|
{
|
|
|
|
|
ClutterModifierType event_state = clutter_event_get_state (event);
|
2012-07-11 15:21:28 +00:00
|
|
|
|
ClutterEventSequence *sequence = clutter_event_get_event_sequence (event);
|
2010-01-08 17:51:00 +00:00
|
|
|
|
guint32 event_time = clutter_event_get_time (event);
|
|
|
|
|
gfloat event_x, event_y;
|
|
|
|
|
|
|
|
|
|
clutter_event_get_coords (event, &event_x, &event_y);
|
|
|
|
|
|
2012-08-21 14:26:30 +00:00
|
|
|
|
_clutter_input_device_set_coords (device, sequence, event_x, event_y, stage);
|
2010-01-08 17:51:00 +00:00
|
|
|
|
_clutter_input_device_set_state (device, event_state);
|
|
|
|
|
_clutter_input_device_set_time (device, event_time);
|
|
|
|
|
}
|
2009-06-06 23:10:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
_clutter_stage_has_queued_events (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE);
|
|
|
|
|
|
|
|
|
|
priv = stage->priv;
|
|
|
|
|
|
|
|
|
|
return priv->event_queue->length > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_clutter_stage_process_queued_events (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv;
|
2010-01-08 17:51:00 +00:00
|
|
|
|
GList *events, *l;
|
2009-06-06 23:10:41 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
|
|
|
|
|
|
|
|
|
priv = stage->priv;
|
|
|
|
|
|
|
|
|
|
if (priv->event_queue->length == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* In case the stage gets destroyed during event processing */
|
|
|
|
|
g_object_ref (stage);
|
|
|
|
|
|
|
|
|
|
/* Steal events before starting processing to avoid reentrancy
|
|
|
|
|
* issues */
|
|
|
|
|
events = priv->event_queue->head;
|
|
|
|
|
priv->event_queue->head = NULL;
|
|
|
|
|
priv->event_queue->tail = NULL;
|
|
|
|
|
priv->event_queue->length = 0;
|
|
|
|
|
|
2010-01-08 17:51:00 +00:00
|
|
|
|
for (l = events; l != NULL; l = l->next)
|
2009-06-06 23:10:41 +00:00
|
|
|
|
{
|
|
|
|
|
ClutterEvent *event;
|
|
|
|
|
ClutterEvent *next_event;
|
2010-02-22 11:34:04 +00:00
|
|
|
|
ClutterInputDevice *device;
|
|
|
|
|
ClutterInputDevice *next_device;
|
|
|
|
|
gboolean check_device = FALSE;
|
2009-06-06 23:10:41 +00:00
|
|
|
|
|
|
|
|
|
event = l->data;
|
|
|
|
|
next_event = l->next ? l->next->data : NULL;
|
|
|
|
|
|
2010-02-22 11:34:04 +00:00
|
|
|
|
device = clutter_event_get_device (event);
|
|
|
|
|
|
|
|
|
|
if (next_event != NULL)
|
|
|
|
|
next_device = clutter_event_get_device (next_event);
|
|
|
|
|
else
|
|
|
|
|
next_device = NULL;
|
|
|
|
|
|
|
|
|
|
if (device != NULL && next_device != NULL)
|
|
|
|
|
check_device = TRUE;
|
|
|
|
|
|
|
|
|
|
/* Skip consecutive motion events coming from the same device */
|
2009-07-14 12:47:35 +00:00
|
|
|
|
if (priv->throttle_motion_events &&
|
2010-02-22 11:34:04 +00:00
|
|
|
|
next_event != NULL &&
|
2009-06-06 23:10:41 +00:00
|
|
|
|
event->type == CLUTTER_MOTION &&
|
|
|
|
|
(next_event->type == CLUTTER_MOTION ||
|
2010-02-22 11:34:04 +00:00
|
|
|
|
next_event->type == CLUTTER_LEAVE) &&
|
|
|
|
|
(!check_device || (device == next_device)))
|
2009-06-06 23:10:41 +00:00
|
|
|
|
{
|
2010-02-22 11:34:04 +00:00
|
|
|
|
CLUTTER_NOTE (EVENT,
|
|
|
|
|
"Omitting motion event at %d, %d",
|
|
|
|
|
(int) event->motion.x,
|
|
|
|
|
(int) event->motion.y);
|
|
|
|
|
goto next_event;
|
2009-06-06 23:10:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_clutter_process_event (event);
|
|
|
|
|
|
|
|
|
|
next_event:
|
|
|
|
|
clutter_event_free (event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_list_free (events);
|
|
|
|
|
|
|
|
|
|
g_object_unref (stage);
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-06 22:22:51 +00:00
|
|
|
|
/**
|
|
|
|
|
* _clutter_stage_needs_update:
|
|
|
|
|
* @stage: A #ClutterStage
|
|
|
|
|
*
|
|
|
|
|
* Determines if _clutter_stage_do_update() needs to be called.
|
|
|
|
|
*
|
2009-06-10 14:50:27 +00:00
|
|
|
|
* Return value: %TRUE if the stage need layout or painting
|
2009-06-06 22:22:51 +00:00
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
_clutter_stage_needs_update (ClutterStage *stage)
|
2009-01-12 14:19:48 +00:00
|
|
|
|
{
|
2009-06-06 22:22:51 +00:00
|
|
|
|
ClutterStagePrivate *priv;
|
2009-03-21 20:39:32 +00:00
|
|
|
|
|
2009-06-06 22:22:51 +00:00
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE);
|
|
|
|
|
|
|
|
|
|
priv = stage->priv;
|
|
|
|
|
|
2010-09-07 19:08:00 +00:00
|
|
|
|
return priv->relayout_pending || priv->redraw_pending;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_clutter_stage_maybe_relayout (ClutterActor *actor)
|
|
|
|
|
{
|
|
|
|
|
ClutterStage *stage = CLUTTER_STAGE (actor);
|
|
|
|
|
ClutterStagePrivate *priv = stage->priv;
|
|
|
|
|
gfloat natural_width, natural_height;
|
|
|
|
|
ClutterActorBox box = { 0, };
|
|
|
|
|
CLUTTER_STATIC_TIMER (relayout_timer,
|
|
|
|
|
"Mainloop", /* no parent */
|
|
|
|
|
"Layouting",
|
|
|
|
|
"The time spent reallocating the stage",
|
|
|
|
|
0 /* no application private data */);
|
|
|
|
|
|
|
|
|
|
if (!priv->relayout_pending)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* avoid reentrancy */
|
|
|
|
|
if (!CLUTTER_ACTOR_IN_RELAYOUT (stage))
|
|
|
|
|
{
|
2010-12-29 21:57:02 +00:00
|
|
|
|
priv->relayout_pending = FALSE;
|
|
|
|
|
|
2010-09-07 19:08:00 +00:00
|
|
|
|
CLUTTER_TIMER_START (_clutter_uprof_context, relayout_timer);
|
|
|
|
|
CLUTTER_NOTE (ACTOR, "Recomputing layout");
|
|
|
|
|
|
|
|
|
|
CLUTTER_SET_PRIVATE_FLAGS (stage, CLUTTER_IN_RELAYOUT);
|
|
|
|
|
|
|
|
|
|
natural_width = natural_height = 0;
|
|
|
|
|
clutter_actor_get_preferred_size (CLUTTER_ACTOR (stage),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
&natural_width, &natural_height);
|
|
|
|
|
|
|
|
|
|
box.x1 = 0;
|
|
|
|
|
box.y1 = 0;
|
|
|
|
|
box.x2 = natural_width;
|
|
|
|
|
box.y2 = natural_height;
|
|
|
|
|
|
|
|
|
|
CLUTTER_NOTE (ACTOR, "Allocating (0, 0 - %d, %d) for the stage",
|
|
|
|
|
(int) natural_width,
|
|
|
|
|
(int) natural_height);
|
|
|
|
|
|
|
|
|
|
clutter_actor_allocate (CLUTTER_ACTOR (stage),
|
|
|
|
|
&box, CLUTTER_ALLOCATION_NONE);
|
|
|
|
|
|
|
|
|
|
CLUTTER_UNSET_PRIVATE_FLAGS (stage, CLUTTER_IN_RELAYOUT);
|
|
|
|
|
CLUTTER_TIMER_STOP (_clutter_uprof_context, relayout_timer);
|
|
|
|
|
}
|
2009-06-06 22:22:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-03-15 13:17:04 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
_clutter_stage_get_pick_buffer_valid (ClutterStage *stage, ClutterPickMode mode)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE);
|
|
|
|
|
|
|
|
|
|
if (stage->priv->pick_buffer_mode != mode)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
return stage->priv->have_valid_pick_buffer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
_clutter_stage_set_pick_buffer_valid (ClutterStage *stage,
|
|
|
|
|
gboolean valid,
|
|
|
|
|
ClutterPickMode mode)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
|
|
|
|
|
|
|
|
|
stage->priv->have_valid_pick_buffer = !!valid;
|
|
|
|
|
stage->priv->pick_buffer_mode = mode;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-18 12:56:17 +00:00
|
|
|
|
static void
|
|
|
|
|
clutter_stage_do_redraw (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
ClutterBackend *backend = clutter_get_default_backend ();
|
|
|
|
|
ClutterActor *actor = CLUTTER_ACTOR (stage);
|
|
|
|
|
ClutterStagePrivate *priv = stage->priv;
|
|
|
|
|
|
2012-01-12 13:31:21 +00:00
|
|
|
|
CLUTTER_STATIC_COUNTER (redraw_counter,
|
|
|
|
|
"clutter_stage_do_redraw counter",
|
|
|
|
|
"Increments for each Stage redraw",
|
|
|
|
|
0 /* no application private data */);
|
|
|
|
|
CLUTTER_STATIC_TIMER (redraw_timer,
|
|
|
|
|
"Master Clock", /* parent */
|
|
|
|
|
"Redrawing",
|
|
|
|
|
"The time spent redrawing everything",
|
|
|
|
|
0 /* no application private data */);
|
|
|
|
|
|
|
|
|
|
if (CLUTTER_ACTOR_IN_DESTRUCTION (stage))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (priv->impl == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
2011-11-15 16:07:13 +00:00
|
|
|
|
CLUTTER_NOTE (PAINT, "Redraw started for stage '%s'[%p]",
|
|
|
|
|
_clutter_actor_get_debug_name (actor),
|
|
|
|
|
stage);
|
2011-02-18 12:56:17 +00:00
|
|
|
|
|
|
|
|
|
_clutter_stage_set_pick_buffer_valid (stage, FALSE, -1);
|
2011-03-15 13:17:04 +00:00
|
|
|
|
priv->picks_per_frame = 0;
|
2011-02-18 12:56:17 +00:00
|
|
|
|
|
|
|
|
|
_clutter_backend_ensure_context (backend, stage);
|
|
|
|
|
|
2011-11-15 17:58:25 +00:00
|
|
|
|
if (_clutter_context_get_show_fps ())
|
2011-02-18 12:56:17 +00:00
|
|
|
|
{
|
|
|
|
|
if (priv->fps_timer == NULL)
|
|
|
|
|
priv->fps_timer = g_timer_new ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_clutter_stage_maybe_setup_viewport (stage);
|
|
|
|
|
|
2012-01-12 13:31:21 +00:00
|
|
|
|
CLUTTER_COUNTER_INC (_clutter_uprof_context, redraw_counter);
|
|
|
|
|
CLUTTER_TIMER_START (_clutter_uprof_context, redraw_timer);
|
|
|
|
|
|
|
|
|
|
_clutter_stage_window_redraw (priv->impl);
|
|
|
|
|
|
|
|
|
|
CLUTTER_TIMER_STOP (_clutter_uprof_context, redraw_timer);
|
2011-02-18 12:56:17 +00:00
|
|
|
|
|
2011-11-15 17:58:25 +00:00
|
|
|
|
if (_clutter_context_get_show_fps ())
|
2011-02-18 12:56:17 +00:00
|
|
|
|
{
|
|
|
|
|
priv->timer_n_frames += 1;
|
|
|
|
|
|
|
|
|
|
if (g_timer_elapsed (priv->fps_timer, NULL) >= 1.0)
|
|
|
|
|
{
|
|
|
|
|
g_print ("*** FPS for %s: %i ***\n",
|
|
|
|
|
_clutter_actor_get_debug_name (actor),
|
|
|
|
|
priv->timer_n_frames);
|
|
|
|
|
|
|
|
|
|
priv->timer_n_frames = 0;
|
|
|
|
|
g_timer_start (priv->fps_timer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-15 16:07:13 +00:00
|
|
|
|
CLUTTER_NOTE (PAINT, "Redraw finished for stage '%s'[%p]",
|
|
|
|
|
_clutter_actor_get_debug_name (actor),
|
|
|
|
|
stage);
|
2011-02-18 12:56:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-06-06 22:22:51 +00:00
|
|
|
|
/**
|
|
|
|
|
* _clutter_stage_do_update:
|
|
|
|
|
* @stage: A #ClutterStage
|
|
|
|
|
*
|
|
|
|
|
* Handles per-frame layout and repaint for the stage.
|
2009-06-10 14:50:27 +00:00
|
|
|
|
*
|
|
|
|
|
* Return value: %TRUE if the stage was updated
|
2009-06-06 22:22:51 +00:00
|
|
|
|
*/
|
2009-06-10 14:50:27 +00:00
|
|
|
|
gboolean
|
2009-06-06 22:22:51 +00:00
|
|
|
|
_clutter_stage_do_update (ClutterStage *stage)
|
|
|
|
|
{
|
2011-06-07 13:34:19 +00:00
|
|
|
|
ClutterStagePrivate *priv = stage->priv;
|
2009-06-06 22:22:51 +00:00
|
|
|
|
|
2011-06-07 13:34:19 +00:00
|
|
|
|
/* if the stage is being destroyed, or if the destruction already
|
|
|
|
|
* happened and we don't have an StageWindow any more, then we
|
|
|
|
|
* should bail out
|
|
|
|
|
*/
|
|
|
|
|
if (CLUTTER_ACTOR_IN_DESTRUCTION (stage) || priv->impl == NULL)
|
2011-02-03 11:25:28 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
|
2011-06-14 15:11:54 +00:00
|
|
|
|
if (!CLUTTER_ACTOR_IS_REALIZED (stage))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2010-09-07 19:08:00 +00:00
|
|
|
|
/* NB: We need to ensure we have an up to date layout *before* we
|
|
|
|
|
* check or clear the pending redraws flag since a relayout may
|
|
|
|
|
* queue a redraw.
|
2009-03-12 19:33:36 +00:00
|
|
|
|
*/
|
|
|
|
|
_clutter_stage_maybe_relayout (CLUTTER_ACTOR (stage));
|
|
|
|
|
|
2010-09-07 19:08:00 +00:00
|
|
|
|
if (!priv->redraw_pending)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2010-09-10 00:33:02 +00:00
|
|
|
|
_clutter_stage_maybe_finish_queue_redraws (stage);
|
|
|
|
|
|
2011-02-18 12:56:17 +00:00
|
|
|
|
clutter_stage_do_redraw (stage);
|
2009-03-21 20:39:32 +00:00
|
|
|
|
|
2009-05-07 18:07:21 +00:00
|
|
|
|
/* reset the guard, so that new redraws are possible */
|
2009-06-06 22:22:51 +00:00
|
|
|
|
priv->redraw_pending = FALSE;
|
2009-05-07 18:07:21 +00:00
|
|
|
|
|
2011-02-18 14:38:54 +00:00
|
|
|
|
#ifdef CLUTTER_ENABLE_DEBUG
|
|
|
|
|
if (priv->redraw_count > 0)
|
2009-01-12 14:19:48 +00:00
|
|
|
|
{
|
2009-05-07 18:07:21 +00:00
|
|
|
|
CLUTTER_NOTE (SCHEDULER, "Queued %lu redraws during the last cycle",
|
2011-02-18 14:38:54 +00:00
|
|
|
|
priv->redraw_count);
|
2009-03-21 20:39:32 +00:00
|
|
|
|
|
2011-02-18 14:38:54 +00:00
|
|
|
|
priv->redraw_count = 0;
|
2009-01-12 14:19:48 +00:00
|
|
|
|
}
|
2011-02-18 14:38:54 +00:00
|
|
|
|
#endif /* CLUTTER_ENABLE_DEBUG */
|
2009-01-12 14:19:48 +00:00
|
|
|
|
|
2009-06-10 14:50:27 +00:00
|
|
|
|
return TRUE;
|
2009-01-12 14:19:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-09-07 19:08:00 +00:00
|
|
|
|
static void
|
|
|
|
|
clutter_stage_real_queue_relayout (ClutterActor *self)
|
|
|
|
|
{
|
|
|
|
|
ClutterStage *stage = CLUTTER_STAGE (self);
|
|
|
|
|
ClutterStagePrivate *priv = stage->priv;
|
|
|
|
|
ClutterActorClass *parent_class;
|
|
|
|
|
|
2012-11-08 17:42:24 +00:00
|
|
|
|
if (!priv->relayout_pending)
|
|
|
|
|
{
|
|
|
|
|
_clutter_stage_schedule_update (stage);
|
|
|
|
|
priv->relayout_pending = TRUE;
|
|
|
|
|
}
|
2010-09-07 19:08:00 +00:00
|
|
|
|
|
|
|
|
|
/* chain up */
|
|
|
|
|
parent_class = CLUTTER_ACTOR_CLASS (clutter_stage_parent_class);
|
|
|
|
|
parent_class->queue_relayout (self);
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-12 14:19:48 +00:00
|
|
|
|
static void
|
2009-02-17 17:22:02 +00:00
|
|
|
|
clutter_stage_real_queue_redraw (ClutterActor *actor,
|
|
|
|
|
ClutterActor *leaf)
|
2009-01-12 14:19:48 +00:00
|
|
|
|
{
|
2009-02-17 17:22:02 +00:00
|
|
|
|
ClutterStage *stage = CLUTTER_STAGE (actor);
|
2009-11-30 17:47:55 +00:00
|
|
|
|
ClutterStageWindow *stage_window;
|
2011-02-01 18:32:08 +00:00
|
|
|
|
ClutterPaintVolume *redraw_clip;
|
2010-09-07 18:31:27 +00:00
|
|
|
|
ClutterActorBox bounding_box;
|
2011-09-19 11:54:31 +00:00
|
|
|
|
ClutterActorBox intersection_box;
|
2011-08-16 15:01:22 +00:00
|
|
|
|
cairo_rectangle_int_t geom, stage_clip;
|
2009-01-12 14:19:48 +00:00
|
|
|
|
|
2010-09-30 09:27:10 +00:00
|
|
|
|
if (CLUTTER_ACTOR_IN_DESTRUCTION (actor))
|
|
|
|
|
return;
|
|
|
|
|
|
2009-11-30 17:47:55 +00:00
|
|
|
|
/* If the backend can't do anything with redraw clips (e.g. it already knows
|
|
|
|
|
* it needs to redraw everything anyway) then don't spend time transforming
|
2010-09-07 18:31:27 +00:00
|
|
|
|
* any clip volume into stage coordinates... */
|
2009-11-30 17:47:55 +00:00
|
|
|
|
stage_window = _clutter_stage_get_window (stage);
|
2010-09-30 09:27:10 +00:00
|
|
|
|
if (stage_window == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
2009-11-30 17:47:55 +00:00
|
|
|
|
if (_clutter_stage_window_ignoring_redraw_clips (stage_window))
|
2010-11-23 16:48:59 +00:00
|
|
|
|
{
|
|
|
|
|
_clutter_stage_window_add_redraw_clip (stage_window, NULL);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2009-11-30 17:47:55 +00:00
|
|
|
|
|
2011-02-01 18:32:08 +00:00
|
|
|
|
/* Convert the clip volume into stage coordinates and then into an
|
|
|
|
|
* axis aligned stage coordinates bounding box...
|
2009-11-30 17:47:55 +00:00
|
|
|
|
*/
|
2011-11-24 14:34:18 +00:00
|
|
|
|
redraw_clip = _clutter_actor_get_queue_redraw_clip (leaf);
|
|
|
|
|
if (redraw_clip == NULL)
|
2009-11-30 17:47:55 +00:00
|
|
|
|
{
|
|
|
|
|
_clutter_stage_window_add_redraw_clip (stage_window, NULL);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:32:08 +00:00
|
|
|
|
_clutter_paint_volume_get_stage_paint_box (redraw_clip,
|
|
|
|
|
stage,
|
|
|
|
|
&bounding_box);
|
2009-11-30 17:47:55 +00:00
|
|
|
|
|
2011-09-19 11:54:31 +00:00
|
|
|
|
_clutter_stage_window_get_geometry (stage_window, &geom);
|
|
|
|
|
|
|
|
|
|
intersection_box.x1 = MAX (bounding_box.x1, 0);
|
|
|
|
|
intersection_box.y1 = MAX (bounding_box.y1, 0);
|
|
|
|
|
intersection_box.x2 = MIN (bounding_box.x2, geom.width);
|
|
|
|
|
intersection_box.y2 = MIN (bounding_box.y2, geom.height);
|
|
|
|
|
|
|
|
|
|
/* There is no need to track degenerate/empty redraw clips */
|
|
|
|
|
if (intersection_box.x2 <= intersection_box.x1 ||
|
|
|
|
|
intersection_box.y2 <= intersection_box.y1)
|
|
|
|
|
return;
|
|
|
|
|
|
2009-11-30 17:47:55 +00:00
|
|
|
|
/* when converting to integer coordinates make sure we round the edges of the
|
|
|
|
|
* clip rectangle outwards... */
|
2011-09-19 11:54:31 +00:00
|
|
|
|
stage_clip.x = intersection_box.x1;
|
|
|
|
|
stage_clip.y = intersection_box.y1;
|
|
|
|
|
stage_clip.width = intersection_box.x2 - stage_clip.x;
|
|
|
|
|
stage_clip.height = intersection_box.y2 - stage_clip.y;
|
2009-11-30 17:47:55 +00:00
|
|
|
|
|
|
|
|
|
_clutter_stage_window_add_redraw_clip (stage_window, &stage_clip);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
_clutter_stage_has_full_redraw_queued (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
ClutterStageWindow *stage_window = _clutter_stage_get_window (stage);
|
2010-07-20 13:39:43 +00:00
|
|
|
|
|
2010-07-21 15:10:46 +00:00
|
|
|
|
if (CLUTTER_ACTOR_IN_DESTRUCTION (stage) || stage_window == NULL)
|
2010-07-20 13:39:43 +00:00
|
|
|
|
return FALSE;
|
2009-11-30 17:47:55 +00:00
|
|
|
|
|
|
|
|
|
if (stage->priv->redraw_pending &&
|
|
|
|
|
!_clutter_stage_window_has_redraw_clips (stage_window))
|
|
|
|
|
return TRUE;
|
|
|
|
|
else
|
|
|
|
|
return FALSE;
|
2009-01-12 14:19:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-07-12 16:16:43 +00:00
|
|
|
|
/**
|
|
|
|
|
* clutter_stage_get_redraw_clip_bounds:
|
|
|
|
|
* @stage: A #ClutterStage
|
|
|
|
|
* @clip: (out caller-allocates): Return location for the clip bounds
|
|
|
|
|
*
|
|
|
|
|
* Gets the bounds of the current redraw for @stage in stage pixel
|
|
|
|
|
* coordinates. E.g., if only a single actor has queued a redraw then
|
|
|
|
|
* Clutter may redraw the stage with a clip so that it doesn't have to
|
|
|
|
|
* paint every pixel in the stage. This function would then return the
|
|
|
|
|
* bounds of that clip. An application can use this information to
|
|
|
|
|
* avoid some extra work if it knows that some regions of the stage
|
|
|
|
|
* aren't going to be painted. This should only be called while the
|
|
|
|
|
* stage is being painted. If there is no current redraw clip then
|
|
|
|
|
* this function will set @clip to the full extents of the stage.
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2011-07-12 16:16:43 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
clutter_stage_get_redraw_clip_bounds (ClutterStage *stage,
|
|
|
|
|
cairo_rectangle_int_t *clip)
|
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
|
|
|
|
g_return_if_fail (clip != NULL);
|
|
|
|
|
|
|
|
|
|
priv = stage->priv;
|
|
|
|
|
|
|
|
|
|
if (!_clutter_stage_window_get_redraw_clip_bounds (priv->impl, clip))
|
|
|
|
|
{
|
|
|
|
|
/* Set clip to the full extents of the stage */
|
2011-08-16 15:01:22 +00:00
|
|
|
|
_clutter_stage_window_get_geometry (priv->impl, clip);
|
2011-07-12 16:16:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-15 13:17:04 +00:00
|
|
|
|
static void
|
|
|
|
|
read_pixels_to_file (char *filename_stem,
|
|
|
|
|
int x,
|
|
|
|
|
int y,
|
|
|
|
|
int width,
|
|
|
|
|
int height)
|
|
|
|
|
{
|
2012-03-23 17:12:26 +00:00
|
|
|
|
guint8 *data;
|
2011-04-12 16:01:51 +00:00
|
|
|
|
cairo_surface_t *surface;
|
2011-03-15 13:17:04 +00:00
|
|
|
|
static int read_count = 0;
|
2011-04-12 16:01:51 +00:00
|
|
|
|
char *filename = g_strdup_printf ("%s-%05d.png",
|
|
|
|
|
filename_stem,
|
|
|
|
|
read_count);
|
2011-03-15 13:17:04 +00:00
|
|
|
|
|
|
|
|
|
data = g_malloc (4 * width * height);
|
|
|
|
|
cogl_read_pixels (x, y, width, height,
|
|
|
|
|
COGL_READ_PIXELS_COLOR_BUFFER,
|
2011-04-12 16:01:51 +00:00
|
|
|
|
CLUTTER_CAIRO_FORMAT_ARGB32,
|
2011-03-15 13:17:04 +00:00
|
|
|
|
data);
|
|
|
|
|
|
2011-04-12 16:01:51 +00:00
|
|
|
|
surface = cairo_image_surface_create_for_data (data, CAIRO_FORMAT_RGB24,
|
|
|
|
|
width, height,
|
|
|
|
|
width * 4);
|
2011-03-15 13:17:04 +00:00
|
|
|
|
|
2011-04-12 16:01:51 +00:00
|
|
|
|
cairo_surface_write_to_png (surface, filename);
|
|
|
|
|
cairo_surface_destroy (surface);
|
|
|
|
|
|
|
|
|
|
g_free (data);
|
|
|
|
|
g_free (filename);
|
|
|
|
|
|
|
|
|
|
read_count++;
|
2011-03-15 13:17:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ClutterActor *
|
|
|
|
|
_clutter_stage_do_pick (ClutterStage *stage,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
ClutterPickMode mode)
|
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv;
|
|
|
|
|
ClutterMainContext *context;
|
|
|
|
|
guchar pixel[4] = { 0xff, 0xff, 0xff, 0xff };
|
|
|
|
|
CoglColor stage_pick_id;
|
2011-07-12 16:04:15 +00:00
|
|
|
|
gboolean dither_enabled_save;
|
|
|
|
|
CoglFramebuffer *fb;
|
2011-03-15 13:17:04 +00:00
|
|
|
|
ClutterActor *actor;
|
|
|
|
|
gboolean is_clipped;
|
2013-02-06 10:05:58 +00:00
|
|
|
|
gint read_x;
|
|
|
|
|
gint read_y;
|
|
|
|
|
|
2011-03-15 13:17:04 +00:00
|
|
|
|
CLUTTER_STATIC_COUNTER (do_pick_counter,
|
|
|
|
|
"_clutter_stage_do_pick counter",
|
|
|
|
|
"Increments for each full pick run",
|
|
|
|
|
0 /* no application private data */);
|
|
|
|
|
CLUTTER_STATIC_TIMER (pick_timer,
|
|
|
|
|
"Mainloop", /* parent */
|
|
|
|
|
"Picking",
|
|
|
|
|
"The time spent picking",
|
|
|
|
|
0 /* no application private data */);
|
|
|
|
|
CLUTTER_STATIC_TIMER (pick_clear,
|
|
|
|
|
"Picking", /* parent */
|
|
|
|
|
"Stage clear (pick)",
|
|
|
|
|
"The time spent clearing stage for picking",
|
|
|
|
|
0 /* no application private data */);
|
|
|
|
|
CLUTTER_STATIC_TIMER (pick_paint,
|
|
|
|
|
"Picking", /* parent */
|
|
|
|
|
"Painting actors (pick mode)",
|
|
|
|
|
"The time spent painting actors in pick mode",
|
|
|
|
|
0 /* no application private data */);
|
|
|
|
|
CLUTTER_STATIC_TIMER (pick_read,
|
|
|
|
|
"Picking", /* parent */
|
|
|
|
|
"Read Pixels",
|
|
|
|
|
"The time spent issuing a read pixels",
|
|
|
|
|
0 /* no application private data */);
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), NULL);
|
|
|
|
|
|
|
|
|
|
priv = stage->priv;
|
|
|
|
|
|
|
|
|
|
if (G_UNLIKELY (clutter_pick_debug_flags & CLUTTER_DEBUG_NOP_PICKING))
|
|
|
|
|
return CLUTTER_ACTOR (stage);
|
|
|
|
|
|
|
|
|
|
#ifdef CLUTTER_ENABLE_PROFILE
|
|
|
|
|
if (clutter_profile_flags & CLUTTER_PROFILE_PICKING_ONLY)
|
|
|
|
|
_clutter_profile_resume ();
|
|
|
|
|
#endif /* CLUTTER_ENABLE_PROFILE */
|
|
|
|
|
|
|
|
|
|
CLUTTER_COUNTER_INC (_clutter_uprof_context, do_pick_counter);
|
|
|
|
|
CLUTTER_TIMER_START (_clutter_uprof_context, pick_timer);
|
|
|
|
|
|
|
|
|
|
context = _clutter_context_get_default ();
|
2011-06-01 21:42:41 +00:00
|
|
|
|
clutter_stage_ensure_current (stage);
|
2011-03-15 13:17:04 +00:00
|
|
|
|
|
|
|
|
|
/* It's possible that we currently have a static scene and have renderered a
|
|
|
|
|
* full, unclipped pick buffer. If so we can simply continue to read from
|
|
|
|
|
* this cached buffer until the scene next changes. */
|
|
|
|
|
if (_clutter_stage_get_pick_buffer_valid (stage, mode))
|
|
|
|
|
{
|
|
|
|
|
CLUTTER_TIMER_START (_clutter_uprof_context, pick_read);
|
|
|
|
|
cogl_read_pixels (x, y, 1, 1,
|
|
|
|
|
COGL_READ_PIXELS_COLOR_BUFFER,
|
|
|
|
|
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
|
|
|
|
|
pixel);
|
|
|
|
|
CLUTTER_TIMER_STOP (_clutter_uprof_context, pick_read);
|
|
|
|
|
|
|
|
|
|
CLUTTER_NOTE (PICK, "Reusing pick buffer from previous render to fetch "
|
|
|
|
|
"actor at %i,%i", x, y);
|
|
|
|
|
|
2012-02-13 08:44:40 +00:00
|
|
|
|
goto check_pixel;
|
2011-03-15 13:17:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
priv->picks_per_frame++;
|
|
|
|
|
|
|
|
|
|
_clutter_backend_ensure_context (context->backend, stage);
|
|
|
|
|
|
|
|
|
|
/* needed for when a context switch happens */
|
|
|
|
|
_clutter_stage_maybe_setup_viewport (stage);
|
|
|
|
|
|
|
|
|
|
/* If we are seeing multiple picks per frame that means the scene is static
|
|
|
|
|
* so we promote to doing a non-scissored pick render so that all subsequent
|
|
|
|
|
* picks for the same static scene won't require additional renders */
|
|
|
|
|
if (priv->picks_per_frame < 2)
|
|
|
|
|
{
|
2013-02-06 10:05:58 +00:00
|
|
|
|
gint dirty_x;
|
|
|
|
|
gint dirty_y;
|
|
|
|
|
|
|
|
|
|
_clutter_stage_window_get_dirty_pixel (priv->impl, &dirty_x, &dirty_y);
|
|
|
|
|
|
|
|
|
|
if (G_LIKELY (!(clutter_pick_debug_flags & CLUTTER_DEBUG_DUMP_PICK_BUFFERS)))
|
|
|
|
|
cogl_clip_push_window_rectangle (dirty_x, dirty_y, 1, 1);
|
|
|
|
|
|
|
|
|
|
cogl_set_viewport (priv->viewport[0] - x + dirty_x,
|
|
|
|
|
priv->viewport[1] - y + dirty_y,
|
|
|
|
|
priv->viewport[2],
|
|
|
|
|
priv->viewport[3]);
|
|
|
|
|
|
|
|
|
|
read_x = dirty_x;
|
|
|
|
|
read_y = dirty_y;
|
2011-03-15 13:17:04 +00:00
|
|
|
|
is_clipped = TRUE;
|
|
|
|
|
}
|
|
|
|
|
else
|
2013-02-06 10:05:58 +00:00
|
|
|
|
{
|
|
|
|
|
read_x = x;
|
|
|
|
|
read_y = y;
|
|
|
|
|
is_clipped = FALSE;
|
|
|
|
|
}
|
2011-03-15 13:17:04 +00:00
|
|
|
|
|
|
|
|
|
CLUTTER_NOTE (PICK, "Performing %s pick at %i,%i",
|
2013-02-03 11:11:01 +00:00
|
|
|
|
is_clipped ? "clipped" : "full", x, y);
|
2011-03-15 13:17:04 +00:00
|
|
|
|
|
|
|
|
|
cogl_color_init_from_4ub (&stage_pick_id, 255, 255, 255, 255);
|
|
|
|
|
CLUTTER_TIMER_START (_clutter_uprof_context, pick_clear);
|
|
|
|
|
cogl_clear (&stage_pick_id,
|
|
|
|
|
COGL_BUFFER_BIT_COLOR |
|
|
|
|
|
COGL_BUFFER_BIT_DEPTH);
|
|
|
|
|
CLUTTER_TIMER_STOP (_clutter_uprof_context, pick_clear);
|
|
|
|
|
|
|
|
|
|
/* Disable dithering (if any) when doing the painting in pick mode */
|
2011-07-12 16:04:15 +00:00
|
|
|
|
fb = cogl_get_draw_framebuffer ();
|
|
|
|
|
dither_enabled_save = cogl_framebuffer_get_dither_enabled (fb);
|
|
|
|
|
cogl_framebuffer_set_dither_enabled (fb, FALSE);
|
2011-03-15 13:17:04 +00:00
|
|
|
|
|
|
|
|
|
/* Render the entire scence in pick mode - just single colored silhouette's
|
|
|
|
|
* are drawn offscreen (as we never swap buffers)
|
|
|
|
|
*/
|
|
|
|
|
CLUTTER_TIMER_START (_clutter_uprof_context, pick_paint);
|
|
|
|
|
context->pick_mode = mode;
|
|
|
|
|
_clutter_stage_do_paint (stage, NULL);
|
|
|
|
|
context->pick_mode = CLUTTER_PICK_NONE;
|
|
|
|
|
CLUTTER_TIMER_STOP (_clutter_uprof_context, pick_paint);
|
|
|
|
|
|
|
|
|
|
/* Read the color of the screen co-ords pixel. RGBA_8888_PRE is used
|
|
|
|
|
even though we don't care about the alpha component because under
|
|
|
|
|
GLES this is the only format that is guaranteed to work so Cogl
|
|
|
|
|
will end up having to do a conversion if any other format is
|
|
|
|
|
used. The format is requested as pre-multiplied because Cogl
|
|
|
|
|
assumes that all pixels in the framebuffer are premultiplied so
|
|
|
|
|
it avoids a conversion. */
|
|
|
|
|
CLUTTER_TIMER_START (_clutter_uprof_context, pick_read);
|
2013-02-06 10:05:58 +00:00
|
|
|
|
cogl_read_pixels (read_x, read_y, 1, 1,
|
2011-03-15 13:17:04 +00:00
|
|
|
|
COGL_READ_PIXELS_COLOR_BUFFER,
|
|
|
|
|
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
|
|
|
|
|
pixel);
|
|
|
|
|
CLUTTER_TIMER_STOP (_clutter_uprof_context, pick_read);
|
|
|
|
|
|
|
|
|
|
if (G_UNLIKELY (clutter_pick_debug_flags & CLUTTER_DEBUG_DUMP_PICK_BUFFERS))
|
|
|
|
|
{
|
2011-06-01 17:33:27 +00:00
|
|
|
|
char *file_name =
|
|
|
|
|
g_strconcat ("pick-buffer-",
|
|
|
|
|
_clutter_actor_get_debug_name (CLUTTER_ACTOR (stage)),
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
read_pixels_to_file (file_name, 0, 0,
|
2011-03-15 13:17:04 +00:00
|
|
|
|
clutter_actor_get_width (CLUTTER_ACTOR (stage)),
|
|
|
|
|
clutter_actor_get_height (CLUTTER_ACTOR (stage)));
|
2011-06-01 17:33:27 +00:00
|
|
|
|
|
|
|
|
|
g_free (file_name);
|
2011-03-15 13:17:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Restore whether GL_DITHER was enabled */
|
2011-07-12 16:04:15 +00:00
|
|
|
|
cogl_framebuffer_set_dither_enabled (fb, dither_enabled_save);
|
2011-03-15 13:17:04 +00:00
|
|
|
|
|
2013-02-06 10:05:58 +00:00
|
|
|
|
if (is_clipped)
|
|
|
|
|
{
|
|
|
|
|
if (G_LIKELY (!(clutter_pick_debug_flags & CLUTTER_DEBUG_DUMP_PICK_BUFFERS)))
|
|
|
|
|
cogl_clip_pop ();
|
|
|
|
|
|
|
|
|
|
_clutter_stage_dirty_viewport (stage);
|
|
|
|
|
|
|
|
|
|
_clutter_stage_set_pick_buffer_valid (stage, FALSE, -1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Notify the backend that we have trashed the contents of
|
|
|
|
|
* the back buffer... */
|
|
|
|
|
_clutter_stage_window_dirty_back_buffer (priv->impl);
|
|
|
|
|
|
|
|
|
|
_clutter_stage_set_pick_buffer_valid (stage, TRUE, mode);
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-13 08:44:40 +00:00
|
|
|
|
check_pixel:
|
2011-03-15 13:17:04 +00:00
|
|
|
|
if (pixel[0] == 0xff && pixel[1] == 0xff && pixel[2] == 0xff)
|
|
|
|
|
{
|
|
|
|
|
actor = CLUTTER_ACTOR (stage);
|
|
|
|
|
}
|
2012-02-13 08:44:40 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
guint32 id_ = _clutter_pixel_to_id (pixel);
|
2011-03-15 13:17:04 +00:00
|
|
|
|
|
2012-02-13 08:44:40 +00:00
|
|
|
|
actor = _clutter_get_actor_by_id (stage, id_);
|
|
|
|
|
}
|
2011-03-15 13:17:04 +00:00
|
|
|
|
|
|
|
|
|
CLUTTER_TIMER_STOP (_clutter_uprof_context, pick_timer);
|
|
|
|
|
|
|
|
|
|
#ifdef CLUTTER_ENABLE_PROFILE
|
|
|
|
|
if (clutter_profile_flags & CLUTTER_PROFILE_PICKING_ONLY)
|
|
|
|
|
_clutter_profile_suspend ();
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
return actor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-01-12 15:44:28 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
clutter_stage_real_delete_event (ClutterStage *stage,
|
|
|
|
|
ClutterEvent *event)
|
|
|
|
|
{
|
2012-08-24 07:36:35 +00:00
|
|
|
|
clutter_actor_destroy (CLUTTER_ACTOR (stage));
|
2010-01-12 15:44:28 +00:00
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-07 12:10:55 +00:00
|
|
|
|
static void
|
|
|
|
|
clutter_stage_real_apply_transform (ClutterActor *stage,
|
|
|
|
|
CoglMatrix *matrix)
|
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv = CLUTTER_STAGE (stage)->priv;
|
|
|
|
|
|
2011-02-08 14:46:31 +00:00
|
|
|
|
/* FIXME: we probably shouldn't be explicitly reseting the matrix
|
|
|
|
|
* here... */
|
2010-09-07 12:10:55 +00:00
|
|
|
|
cogl_matrix_init_identity (matrix);
|
2011-02-08 14:46:31 +00:00
|
|
|
|
cogl_matrix_multiply (matrix, matrix, &priv->view);
|
2010-09-07 12:10:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
Try to mop up the default stage mess
The default stage was a neat concept when we started Clutter out,
somewhere in the Jurassic era; a singleton instance that gets created at
initialization time, and remains the same for the entire duration of the
process.
Worked well enough when Clutter was a small library meant to be used to
write fullscreen media browsers, but since the introduction of multiple
stages, and Clutter being used to create all sorts of applications, the
default stage is just a vestigial remainder of that past, like an
appendix; something that complicates the layout of the code and
introduces weird behaviour, so that you notice its existence only when
something goes wrong.
Some platforms we do support, though, only have one framebuffer, so it
makes sense for them to have only one stage.
At this point, the only sane thing to do is to go through the same code
paths on all platforms, and that code path is the stage instance
creation and initialization — i.e. clutter_stage_new() (or
g_object_new() with CLUTTER_TYPE_STAGE).
For platforms that support multiple stages, nothing has changed: the stage
created by clutter_stage_get_default() will be set as the default one;
if nobody calls it, the default stage is never created, and it just
lives on as a meaningless check.
For platforms that only support one stage, clutter_stage_new() and
clutter_stage_get_default() will behave exactly the same the first time
they are called: both will create a stage, and set it as the default.
Calling clutter_stage_new() a second time is treated as a programmer
error, and will result in Clutter aborting. This is a behavioural change
because the existing behaviour or creating a new ClutterStage instance
with the same ClutterStageWindow private implementation is, simply put,
utterly braindamaged and I should have *never* had written it, and I
apologize for it. In my defence, I didn't know any better at the time.
This is the first step towards the complete deprecation of
clutter_stage_get_default() and clutter_stage_is_default(), which will
come later.
2011-11-09 14:04:05 +00:00
|
|
|
|
static void
|
|
|
|
|
clutter_stage_constructed (GObject *gobject)
|
|
|
|
|
{
|
|
|
|
|
ClutterStage *self = CLUTTER_STAGE (gobject);
|
|
|
|
|
ClutterStageManager *stage_manager;
|
|
|
|
|
|
|
|
|
|
stage_manager = clutter_stage_manager_get_default ();
|
|
|
|
|
|
2011-11-14 11:46:02 +00:00
|
|
|
|
/* this will take care to sinking the floating reference */
|
Try to mop up the default stage mess
The default stage was a neat concept when we started Clutter out,
somewhere in the Jurassic era; a singleton instance that gets created at
initialization time, and remains the same for the entire duration of the
process.
Worked well enough when Clutter was a small library meant to be used to
write fullscreen media browsers, but since the introduction of multiple
stages, and Clutter being used to create all sorts of applications, the
default stage is just a vestigial remainder of that past, like an
appendix; something that complicates the layout of the code and
introduces weird behaviour, so that you notice its existence only when
something goes wrong.
Some platforms we do support, though, only have one framebuffer, so it
makes sense for them to have only one stage.
At this point, the only sane thing to do is to go through the same code
paths on all platforms, and that code path is the stage instance
creation and initialization — i.e. clutter_stage_new() (or
g_object_new() with CLUTTER_TYPE_STAGE).
For platforms that support multiple stages, nothing has changed: the stage
created by clutter_stage_get_default() will be set as the default one;
if nobody calls it, the default stage is never created, and it just
lives on as a meaningless check.
For platforms that only support one stage, clutter_stage_new() and
clutter_stage_get_default() will behave exactly the same the first time
they are called: both will create a stage, and set it as the default.
Calling clutter_stage_new() a second time is treated as a programmer
error, and will result in Clutter aborting. This is a behavioural change
because the existing behaviour or creating a new ClutterStage instance
with the same ClutterStageWindow private implementation is, simply put,
utterly braindamaged and I should have *never* had written it, and I
apologize for it. In my defence, I didn't know any better at the time.
This is the first step towards the complete deprecation of
clutter_stage_get_default() and clutter_stage_is_default(), which will
come later.
2011-11-09 14:04:05 +00:00
|
|
|
|
_clutter_stage_manager_add_stage (stage_manager, self);
|
|
|
|
|
|
|
|
|
|
/* if this stage has been created on a backend that does not
|
|
|
|
|
* support multiple stages then it becomes the default stage
|
|
|
|
|
* as well; any other attempt at creating a ClutterStage will
|
|
|
|
|
* fail.
|
|
|
|
|
*/
|
|
|
|
|
if (!clutter_feature_available (CLUTTER_FEATURE_STAGE_MULTIPLE))
|
|
|
|
|
{
|
|
|
|
|
if (G_UNLIKELY (clutter_stage_manager_get_default_stage (stage_manager) != NULL))
|
|
|
|
|
{
|
|
|
|
|
g_error ("Unable to create another stage: the backend of "
|
|
|
|
|
"type '%s' does not support multiple stages. Use "
|
2011-11-14 11:46:02 +00:00
|
|
|
|
"clutter_stage_manager_get_default_stage() instead "
|
|
|
|
|
"to access the stage singleton.",
|
Try to mop up the default stage mess
The default stage was a neat concept when we started Clutter out,
somewhere in the Jurassic era; a singleton instance that gets created at
initialization time, and remains the same for the entire duration of the
process.
Worked well enough when Clutter was a small library meant to be used to
write fullscreen media browsers, but since the introduction of multiple
stages, and Clutter being used to create all sorts of applications, the
default stage is just a vestigial remainder of that past, like an
appendix; something that complicates the layout of the code and
introduces weird behaviour, so that you notice its existence only when
something goes wrong.
Some platforms we do support, though, only have one framebuffer, so it
makes sense for them to have only one stage.
At this point, the only sane thing to do is to go through the same code
paths on all platforms, and that code path is the stage instance
creation and initialization — i.e. clutter_stage_new() (or
g_object_new() with CLUTTER_TYPE_STAGE).
For platforms that support multiple stages, nothing has changed: the stage
created by clutter_stage_get_default() will be set as the default one;
if nobody calls it, the default stage is never created, and it just
lives on as a meaningless check.
For platforms that only support one stage, clutter_stage_new() and
clutter_stage_get_default() will behave exactly the same the first time
they are called: both will create a stage, and set it as the default.
Calling clutter_stage_new() a second time is treated as a programmer
error, and will result in Clutter aborting. This is a behavioural change
because the existing behaviour or creating a new ClutterStage instance
with the same ClutterStageWindow private implementation is, simply put,
utterly braindamaged and I should have *never* had written it, and I
apologize for it. In my defence, I didn't know any better at the time.
This is the first step towards the complete deprecation of
clutter_stage_get_default() and clutter_stage_is_default(), which will
come later.
2011-11-09 14:04:05 +00:00
|
|
|
|
G_OBJECT_TYPE_NAME (clutter_get_default_backend ()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_clutter_stage_manager_set_default_stage (stage_manager, self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (clutter_stage_parent_class)->constructed (gobject);
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-29 08:59:36 +00:00
|
|
|
|
static void
|
2007-10-12 08:17:00 +00:00
|
|
|
|
clutter_stage_set_property (GObject *object,
|
2006-05-29 08:59:36 +00:00
|
|
|
|
guint prop_id,
|
2007-10-12 08:17:00 +00:00
|
|
|
|
const GValue *value,
|
2006-05-29 08:59:36 +00:00
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
2010-02-11 15:19:18 +00:00
|
|
|
|
ClutterStage *stage = CLUTTER_STAGE (object);
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
2007-10-12 08:17:00 +00:00
|
|
|
|
switch (prop_id)
|
2006-05-29 08:59:36 +00:00
|
|
|
|
{
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
case PROP_COLOR:
|
2012-02-13 16:05:21 +00:00
|
|
|
|
clutter_actor_set_background_color (CLUTTER_ACTOR (stage),
|
|
|
|
|
clutter_value_get_color (value));
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
break;
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
|
2006-06-02 20:24:55 +00:00
|
|
|
|
case PROP_OFFSCREEN:
|
2009-07-31 17:34:51 +00:00
|
|
|
|
if (g_value_get_boolean (value))
|
|
|
|
|
g_warning ("Offscreen stages are currently not supported\n");
|
2006-06-02 20:24:55 +00:00
|
|
|
|
break;
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
|
case PROP_CURSOR_VISIBLE:
|
|
|
|
|
if (g_value_get_boolean (value))
|
|
|
|
|
clutter_stage_show_cursor (stage);
|
|
|
|
|
else
|
|
|
|
|
clutter_stage_hide_cursor (stage);
|
2006-05-29 08:59:36 +00:00
|
|
|
|
break;
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
|
2007-05-25 10:56:09 +00:00
|
|
|
|
case PROP_PERSPECTIVE:
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
clutter_stage_set_perspective (stage, g_value_get_boxed (value));
|
2007-05-25 10:56:09 +00:00
|
|
|
|
break;
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
|
2007-06-19 09:10:37 +00:00
|
|
|
|
case PROP_TITLE:
|
2007-10-12 08:17:00 +00:00
|
|
|
|
clutter_stage_set_title (stage, g_value_get_string (value));
|
2007-06-19 09:10:37 +00:00
|
|
|
|
break;
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
|
2010-08-11 11:40:22 +00:00
|
|
|
|
case PROP_USER_RESIZABLE:
|
2007-07-31 17:01:52 +00:00
|
|
|
|
clutter_stage_set_user_resizable (stage, g_value_get_boolean (value));
|
2007-07-26 20:08:09 +00:00
|
|
|
|
break;
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
|
2009-12-01 16:16:18 +00:00
|
|
|
|
case PROP_USE_ALPHA:
|
2009-12-09 02:04:56 +00:00
|
|
|
|
clutter_stage_set_use_alpha (stage, g_value_get_boolean (value));
|
2009-12-01 16:16:18 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2010-02-01 11:04:59 +00:00
|
|
|
|
case PROP_KEY_FOCUS:
|
|
|
|
|
clutter_stage_set_key_focus (stage, g_value_get_object (value));
|
|
|
|
|
break;
|
|
|
|
|
|
2010-04-16 14:34:36 +00:00
|
|
|
|
case PROP_NO_CLEAR_HINT:
|
|
|
|
|
clutter_stage_set_no_clear_hint (stage, g_value_get_boolean (value));
|
|
|
|
|
break;
|
|
|
|
|
|
2011-03-11 17:09:59 +00:00
|
|
|
|
case PROP_ACCEPT_FOCUS:
|
|
|
|
|
clutter_stage_set_accept_focus (stage, g_value_get_boolean (value));
|
|
|
|
|
break;
|
|
|
|
|
|
2006-05-29 08:59:36 +00:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
clutter_stage_get_property (GObject *gobject,
|
2007-05-16 09:08:30 +00:00
|
|
|
|
guint prop_id,
|
2007-10-12 08:17:00 +00:00
|
|
|
|
GValue *value,
|
2007-05-16 09:08:30 +00:00
|
|
|
|
GParamSpec *pspec)
|
2006-05-29 08:59:36 +00:00
|
|
|
|
{
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
ClutterStagePrivate *priv = CLUTTER_STAGE (gobject)->priv;
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
2007-10-12 08:17:00 +00:00
|
|
|
|
switch (prop_id)
|
2006-05-29 08:59:36 +00:00
|
|
|
|
{
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
case PROP_COLOR:
|
2012-02-13 16:05:21 +00:00
|
|
|
|
{
|
|
|
|
|
ClutterColor bg_color;
|
|
|
|
|
|
|
|
|
|
clutter_actor_get_background_color (CLUTTER_ACTOR (gobject),
|
|
|
|
|
&bg_color);
|
|
|
|
|
clutter_value_set_color (value, &bg_color);
|
|
|
|
|
}
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
break;
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
|
2006-06-02 20:24:55 +00:00
|
|
|
|
case PROP_OFFSCREEN:
|
2009-07-31 17:34:51 +00:00
|
|
|
|
g_value_set_boolean (value, FALSE);
|
2006-06-02 20:24:55 +00:00
|
|
|
|
break;
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
|
2009-06-09 12:48:03 +00:00
|
|
|
|
case PROP_FULLSCREEN_SET:
|
2007-03-22 18:21:59 +00:00
|
|
|
|
g_value_set_boolean (value, priv->is_fullscreen);
|
2006-05-29 08:59:36 +00:00
|
|
|
|
break;
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
|
case PROP_CURSOR_VISIBLE:
|
|
|
|
|
g_value_set_boolean (value, priv->is_cursor_visible);
|
2006-05-29 08:59:36 +00:00
|
|
|
|
break;
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
|
2007-05-25 10:56:09 +00:00
|
|
|
|
case PROP_PERSPECTIVE:
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
g_value_set_boxed (value, &priv->perspective);
|
2007-05-25 10:56:09 +00:00
|
|
|
|
break;
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
|
2007-06-19 09:10:37 +00:00
|
|
|
|
case PROP_TITLE:
|
|
|
|
|
g_value_set_string (value, priv->title);
|
|
|
|
|
break;
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
|
2010-08-11 11:40:22 +00:00
|
|
|
|
case PROP_USER_RESIZABLE:
|
2007-07-31 17:01:52 +00:00
|
|
|
|
g_value_set_boolean (value, priv->is_user_resizable);
|
2007-07-26 20:08:09 +00:00
|
|
|
|
break;
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
|
2009-12-01 16:16:18 +00:00
|
|
|
|
case PROP_USE_ALPHA:
|
|
|
|
|
g_value_set_boolean (value, priv->use_alpha);
|
|
|
|
|
break;
|
|
|
|
|
|
2010-02-01 11:04:59 +00:00
|
|
|
|
case PROP_KEY_FOCUS:
|
|
|
|
|
g_value_set_object (value, priv->key_focused_actor);
|
|
|
|
|
break;
|
|
|
|
|
|
2010-04-16 14:34:36 +00:00
|
|
|
|
case PROP_NO_CLEAR_HINT:
|
|
|
|
|
{
|
|
|
|
|
gboolean hint =
|
|
|
|
|
(priv->stage_hints & CLUTTER_STAGE_NO_CLEAR_ON_PAINT) != 0;
|
|
|
|
|
|
|
|
|
|
g_value_set_boolean (value, hint);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2011-03-11 17:09:59 +00:00
|
|
|
|
case PROP_ACCEPT_FOCUS:
|
|
|
|
|
g_value_set_boolean (value, priv->accept_focus);
|
|
|
|
|
break;
|
|
|
|
|
|
2006-05-29 08:59:36 +00:00
|
|
|
|
default:
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
2006-05-29 08:59:36 +00:00
|
|
|
|
break;
|
2007-10-12 08:17:00 +00:00
|
|
|
|
}
|
2006-05-29 08:59:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-03-31 17:15:02 +00:00
|
|
|
|
static void
|
|
|
|
|
clutter_stage_dispose (GObject *object)
|
|
|
|
|
{
|
2008-04-04 15:02:11 +00:00
|
|
|
|
ClutterStage *stage = CLUTTER_STAGE (object);
|
|
|
|
|
ClutterStagePrivate *priv = stage->priv;
|
2011-02-09 12:38:10 +00:00
|
|
|
|
ClutterStageManager *stage_manager;
|
2008-04-04 15:02:11 +00:00
|
|
|
|
|
Enforce invariants on mapped, realized, visibility states
Bug 1138 - No trackable "mapped" state
* Add a VISIBLE flag tracking application programmer's
expected showing-state for the actor, allowing us to
always ensure we keep what the app wants while tracking
internal implementation state separately.
* Make MAPPED reflect whether the actor will be painted;
add notification on a ClutterActor::mapped property.
Keep MAPPED state updated as the actor is shown,
ancestors are shown, actor is reparented, etc.
* Require a stage and realized parents to realize; this means
at realization time the correct window system and GL resources
are known. But unparented actors can no longer be realized.
* Allow children to be unrealized even if parent is realized.
Otherwise in effect either all actors or no actors are realized,
i.e. it becomes a stage-global flag.
* Allow clutter_actor_realize() to "fail" if not inside a toplevel
* Rework clutter_actor_unrealize() so internally we have
a flavor that does not mess with visibility flag
* Add _clutter_actor_rerealize() to encapsulate a somewhat
tricky operation we were doing in a couple of places
* Do not realize/unrealize children in ClutterGroup,
ClutterActor already does it
* Do not realize impl by hand in clutter_stage_show(),
since showing impl already does that
* Do not unrealize in various dispose() methods, since
ClutterActor dispose implementation already does it
and chaining up is mandatory
* ClutterTexture uses COGL while unrealizable (before it's
added to a stage). Previously this breakage was affecting
ClutterActor because we had to allow realize outside
a stage. Move the breakage to ClutterTexture, by making
ClutterTexture just use COGL while not realized.
* Unrealize before we set parent to NULL in clutter_actor_unparent().
This means unrealize() implementations can get to the stage.
Because actors need the stage in order to detach from stage.
* Update clutter-actor-invariants.txt to reflect latest changes
* Remove explicit hide/unrealize from ClutterActor::dispose since
unparent already forces those
Instead just assert that unparent() occurred and did the right thing.
* Check whether parent implements unrealize before chaining up
Needed because ClutterGroup no longer has to implement unrealize.
* Perform unrealize in the default handler for the signal.
This allows non-containers that have children to work properly,
and allows containers to override how it's done.
* Add map/unmap virtual methods and set MAPPED flag on self and
children in there. This allows subclasses to hook map/unmap.
These are not signals, because notify::mapped is better for
anything it's legitimate for a non-subclass to do.
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-04-02 13:16:43 +00:00
|
|
|
|
clutter_actor_hide (CLUTTER_ACTOR (object));
|
2008-07-31 08:54:43 +00:00
|
|
|
|
|
2011-02-09 12:38:10 +00:00
|
|
|
|
_clutter_clear_events_queue_for_stage (stage);
|
2009-11-13 13:39:24 +00:00
|
|
|
|
|
2009-08-13 11:34:07 +00:00
|
|
|
|
if (priv->impl != NULL)
|
2008-04-04 15:02:11 +00:00
|
|
|
|
{
|
2009-05-08 16:17:48 +00:00
|
|
|
|
CLUTTER_NOTE (BACKEND, "Disposing of the stage implementation");
|
2009-08-13 11:34:07 +00:00
|
|
|
|
|
2011-09-09 12:53:33 +00:00
|
|
|
|
if (CLUTTER_ACTOR_IS_REALIZED (object))
|
|
|
|
|
_clutter_stage_window_unrealize (priv->impl);
|
|
|
|
|
|
2009-08-13 11:34:07 +00:00
|
|
|
|
g_object_unref (priv->impl);
|
2008-04-04 15:02:11 +00:00
|
|
|
|
priv->impl = NULL;
|
|
|
|
|
}
|
2008-03-31 17:15:02 +00:00
|
|
|
|
|
2012-01-23 18:00:01 +00:00
|
|
|
|
clutter_actor_remove_all_children (CLUTTER_ACTOR (object));
|
|
|
|
|
|
2012-06-24 17:29:22 +00:00
|
|
|
|
g_list_free_full (priv->pending_queue_redraws,
|
|
|
|
|
(GDestroyNotify) free_queue_redraw_entry);
|
|
|
|
|
priv->pending_queue_redraws = NULL;
|
|
|
|
|
|
2012-06-24 17:02:45 +00:00
|
|
|
|
/* this will release the reference on the stage */
|
|
|
|
|
stage_manager = clutter_stage_manager_get_default ();
|
|
|
|
|
_clutter_stage_manager_remove_stage (stage_manager, stage);
|
|
|
|
|
|
2008-03-31 17:15:02 +00:00
|
|
|
|
G_OBJECT_CLASS (clutter_stage_parent_class)->dispose (object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
clutter_stage_finalize (GObject *object)
|
|
|
|
|
{
|
2008-07-30 15:01:37 +00:00
|
|
|
|
ClutterStage *stage = CLUTTER_STAGE (object);
|
2009-06-06 23:10:41 +00:00
|
|
|
|
ClutterStagePrivate *priv = stage->priv;
|
|
|
|
|
|
2011-02-09 12:38:10 +00:00
|
|
|
|
g_queue_foreach (priv->event_queue, (GFunc) clutter_event_free, NULL);
|
2009-06-06 23:10:41 +00:00
|
|
|
|
g_queue_free (priv->event_queue);
|
2008-07-30 15:01:37 +00:00
|
|
|
|
|
2011-01-27 17:26:16 +00:00
|
|
|
|
g_free (priv->title);
|
2009-06-06 23:10:41 +00:00
|
|
|
|
|
2010-09-07 17:04:19 +00:00
|
|
|
|
g_array_free (priv->paint_volume_stack, TRUE);
|
|
|
|
|
|
2011-04-11 13:11:39 +00:00
|
|
|
|
_clutter_id_pool_free (priv->pick_id_pool);
|
|
|
|
|
|
2011-02-18 12:56:17 +00:00
|
|
|
|
if (priv->fps_timer != NULL)
|
|
|
|
|
g_timer_destroy (priv->fps_timer);
|
|
|
|
|
|
2008-03-31 17:15:02 +00:00
|
|
|
|
G_OBJECT_CLASS (clutter_stage_parent_class)->finalize (object);
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-29 08:59:36 +00:00
|
|
|
|
static void
|
|
|
|
|
clutter_stage_class_init (ClutterStageClass *klass)
|
|
|
|
|
{
|
2007-03-22 18:21:59 +00:00
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
2007-03-23 16:37:56 +00:00
|
|
|
|
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
2008-11-17 14:21:49 +00:00
|
|
|
|
GParamSpec *pspec;
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
Try to mop up the default stage mess
The default stage was a neat concept when we started Clutter out,
somewhere in the Jurassic era; a singleton instance that gets created at
initialization time, and remains the same for the entire duration of the
process.
Worked well enough when Clutter was a small library meant to be used to
write fullscreen media browsers, but since the introduction of multiple
stages, and Clutter being used to create all sorts of applications, the
default stage is just a vestigial remainder of that past, like an
appendix; something that complicates the layout of the code and
introduces weird behaviour, so that you notice its existence only when
something goes wrong.
Some platforms we do support, though, only have one framebuffer, so it
makes sense for them to have only one stage.
At this point, the only sane thing to do is to go through the same code
paths on all platforms, and that code path is the stage instance
creation and initialization — i.e. clutter_stage_new() (or
g_object_new() with CLUTTER_TYPE_STAGE).
For platforms that support multiple stages, nothing has changed: the stage
created by clutter_stage_get_default() will be set as the default one;
if nobody calls it, the default stage is never created, and it just
lives on as a meaningless check.
For platforms that only support one stage, clutter_stage_new() and
clutter_stage_get_default() will behave exactly the same the first time
they are called: both will create a stage, and set it as the default.
Calling clutter_stage_new() a second time is treated as a programmer
error, and will result in Clutter aborting. This is a behavioural change
because the existing behaviour or creating a new ClutterStage instance
with the same ClutterStageWindow private implementation is, simply put,
utterly braindamaged and I should have *never* had written it, and I
apologize for it. In my defence, I didn't know any better at the time.
This is the first step towards the complete deprecation of
clutter_stage_get_default() and clutter_stage_is_default(), which will
come later.
2011-11-09 14:04:05 +00:00
|
|
|
|
gobject_class->constructed = clutter_stage_constructed;
|
2006-05-29 08:59:36 +00:00
|
|
|
|
gobject_class->set_property = clutter_stage_set_property;
|
|
|
|
|
gobject_class->get_property = clutter_stage_get_property;
|
2008-03-31 17:15:02 +00:00
|
|
|
|
gobject_class->dispose = clutter_stage_dispose;
|
|
|
|
|
gobject_class->finalize = clutter_stage_finalize;
|
2007-03-22 18:21:59 +00:00
|
|
|
|
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
|
actor_class->allocate = clutter_stage_allocate;
|
|
|
|
|
actor_class->get_preferred_width = clutter_stage_get_preferred_width;
|
|
|
|
|
actor_class->get_preferred_height = clutter_stage_get_preferred_height;
|
2007-03-23 16:37:56 +00:00
|
|
|
|
actor_class->paint = clutter_stage_paint;
|
2007-11-18 23:24:55 +00:00
|
|
|
|
actor_class->pick = clutter_stage_pick;
|
2010-11-23 14:31:45 +00:00
|
|
|
|
actor_class->get_paint_volume = clutter_stage_get_paint_volume;
|
2008-04-04 15:02:11 +00:00
|
|
|
|
actor_class->realize = clutter_stage_realize;
|
|
|
|
|
actor_class->unrealize = clutter_stage_unrealize;
|
|
|
|
|
actor_class->show = clutter_stage_show;
|
2012-03-05 17:38:27 +00:00
|
|
|
|
actor_class->show_all = clutter_stage_show_all;
|
2008-04-04 15:02:11 +00:00
|
|
|
|
actor_class->hide = clutter_stage_hide;
|
2012-03-05 17:38:27 +00:00
|
|
|
|
actor_class->hide_all = clutter_stage_hide_all;
|
2010-09-07 19:08:00 +00:00
|
|
|
|
actor_class->queue_relayout = clutter_stage_real_queue_relayout;
|
2009-02-17 17:22:02 +00:00
|
|
|
|
actor_class->queue_redraw = clutter_stage_real_queue_redraw;
|
2010-09-07 12:10:55 +00:00
|
|
|
|
actor_class->apply_transform = clutter_stage_real_apply_transform;
|
2007-03-23 16:37:56 +00:00
|
|
|
|
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
/**
|
2007-08-21 15:47:51 +00:00
|
|
|
|
* ClutterStage:fullscreen:
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
*
|
|
|
|
|
* Whether the stage should be fullscreen or not.
|
2009-06-09 12:48:03 +00:00
|
|
|
|
*
|
2009-06-09 13:05:03 +00:00
|
|
|
|
* This property is set by calling clutter_stage_set_fullscreen()
|
|
|
|
|
* but since the actual implementation is delegated to the backend
|
|
|
|
|
* you should connect to the notify::fullscreen-set signal in order
|
|
|
|
|
* to get notification if the fullscreen state has been successfully
|
|
|
|
|
* achieved.
|
2009-06-09 12:48:03 +00:00
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
*/
|
2009-06-09 12:48:03 +00:00
|
|
|
|
pspec = g_param_spec_boolean ("fullscreen-set",
|
2010-06-03 11:57:50 +00:00
|
|
|
|
P_("Fullscreen Set"),
|
|
|
|
|
P_("Whether the main stage is fullscreen"),
|
2009-06-09 12:48:03 +00:00
|
|
|
|
FALSE,
|
|
|
|
|
CLUTTER_PARAM_READABLE);
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
|
PROP_FULLSCREEN_SET,
|
|
|
|
|
pspec);
|
2007-08-21 15:47:51 +00:00
|
|
|
|
/**
|
|
|
|
|
* ClutterStage:cursor-visible:
|
|
|
|
|
*
|
|
|
|
|
* Whether the mouse pointer should be visible
|
|
|
|
|
*/
|
2009-06-09 12:48:03 +00:00
|
|
|
|
pspec = g_param_spec_boolean ("cursor-visible",
|
2010-06-03 11:57:50 +00:00
|
|
|
|
P_("Cursor Visible"),
|
|
|
|
|
P_("Whether the mouse pointer is visible on the main stage"),
|
2009-06-09 12:48:03 +00:00
|
|
|
|
TRUE,
|
|
|
|
|
CLUTTER_PARAM_READWRITE);
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
|
PROP_CURSOR_VISIBLE,
|
|
|
|
|
pspec);
|
2007-08-21 15:47:51 +00:00
|
|
|
|
/**
|
|
|
|
|
* ClutterStage:user-resizable:
|
|
|
|
|
*
|
2008-02-15 15:18:02 +00:00
|
|
|
|
* Whether the stage is resizable via user interaction.
|
2007-08-21 15:47:51 +00:00
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2007-08-21 15:47:51 +00:00
|
|
|
|
*/
|
2009-06-09 12:48:03 +00:00
|
|
|
|
pspec = g_param_spec_boolean ("user-resizable",
|
2010-06-03 11:57:50 +00:00
|
|
|
|
P_("User Resizable"),
|
|
|
|
|
P_("Whether the stage is able to be resized via user interaction"),
|
2009-06-09 12:48:03 +00:00
|
|
|
|
FALSE,
|
|
|
|
|
CLUTTER_PARAM_READWRITE);
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
2010-08-11 11:40:22 +00:00
|
|
|
|
PROP_USER_RESIZABLE,
|
2009-06-09 12:48:03 +00:00
|
|
|
|
pspec);
|
2008-07-30 21:09:58 +00:00
|
|
|
|
/**
|
|
|
|
|
* ClutterStage:perspective:
|
|
|
|
|
*
|
|
|
|
|
* The parameters used for the perspective projection from 3D
|
|
|
|
|
* coordinates to 2D
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2008-07-30 21:09:58 +00:00
|
|
|
|
*/
|
2009-06-09 12:48:03 +00:00
|
|
|
|
pspec = g_param_spec_boxed ("perspective",
|
2010-06-03 11:57:50 +00:00
|
|
|
|
P_("Perspective"),
|
|
|
|
|
P_("Perspective projection parameters"),
|
2009-06-09 12:48:03 +00:00
|
|
|
|
CLUTTER_TYPE_PERSPECTIVE,
|
|
|
|
|
CLUTTER_PARAM_READWRITE);
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
|
PROP_PERSPECTIVE,
|
|
|
|
|
pspec);
|
2008-07-30 21:09:58 +00:00
|
|
|
|
|
2007-06-19 09:10:37 +00:00
|
|
|
|
/**
|
|
|
|
|
* ClutterStage:title:
|
|
|
|
|
*
|
2008-02-15 15:18:02 +00:00
|
|
|
|
* The stage's title - usually displayed in stage windows title decorations.
|
2007-06-19 09:10:37 +00:00
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2007-06-19 09:10:37 +00:00
|
|
|
|
*/
|
2009-06-09 12:48:03 +00:00
|
|
|
|
pspec = g_param_spec_string ("title",
|
2010-06-03 11:57:50 +00:00
|
|
|
|
P_("Title"),
|
|
|
|
|
P_("Stage Title"),
|
2009-06-09 12:48:03 +00:00
|
|
|
|
NULL,
|
|
|
|
|
CLUTTER_PARAM_READWRITE);
|
|
|
|
|
g_object_class_install_property (gobject_class, PROP_TITLE, pspec);
|
|
|
|
|
|
2009-12-01 16:16:18 +00:00
|
|
|
|
/**
|
|
|
|
|
* ClutterStage:use-alpha:
|
|
|
|
|
*
|
|
|
|
|
* Whether the #ClutterStage should honour the alpha component of the
|
|
|
|
|
* #ClutterStage:color property when painting. If Clutter is run under
|
|
|
|
|
* a compositing manager this will result in the stage being blended
|
|
|
|
|
* with the underlying window(s)
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2009-12-01 16:16:18 +00:00
|
|
|
|
*/
|
|
|
|
|
pspec = g_param_spec_boolean ("use-alpha",
|
2010-06-03 11:57:50 +00:00
|
|
|
|
P_("Use Alpha"),
|
|
|
|
|
P_("Whether to honour the alpha component of the stage color"),
|
2009-12-01 16:16:18 +00:00
|
|
|
|
FALSE,
|
|
|
|
|
CLUTTER_PARAM_READWRITE);
|
|
|
|
|
g_object_class_install_property (gobject_class, PROP_USE_ALPHA, pspec);
|
|
|
|
|
|
2010-02-01 11:04:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* ClutterStage:key-focus:
|
|
|
|
|
*
|
|
|
|
|
* The #ClutterActor that will receive key events from the underlying
|
|
|
|
|
* windowing system.
|
|
|
|
|
*
|
|
|
|
|
* If %NULL, the #ClutterStage will receive the events.
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2010-02-01 11:04:59 +00:00
|
|
|
|
*/
|
|
|
|
|
pspec = g_param_spec_object ("key-focus",
|
2010-06-03 11:57:50 +00:00
|
|
|
|
P_("Key Focus"),
|
|
|
|
|
P_("The currently key focused actor"),
|
2010-02-01 11:04:59 +00:00
|
|
|
|
CLUTTER_TYPE_ACTOR,
|
|
|
|
|
CLUTTER_PARAM_READWRITE);
|
|
|
|
|
g_object_class_install_property (gobject_class, PROP_KEY_FOCUS, pspec);
|
|
|
|
|
|
2010-04-16 14:34:36 +00:00
|
|
|
|
/**
|
|
|
|
|
* ClutterStage:no-clear-hint:
|
|
|
|
|
*
|
|
|
|
|
* Whether or not the #ClutterStage should clear its contents
|
|
|
|
|
* before each paint cycle.
|
|
|
|
|
*
|
|
|
|
|
* See clutter_stage_set_no_clear_hint() for further information.
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2010-04-16 14:34:36 +00:00
|
|
|
|
*/
|
|
|
|
|
pspec = g_param_spec_boolean ("no-clear-hint",
|
2010-06-03 11:57:50 +00:00
|
|
|
|
P_("No Clear Hint"),
|
|
|
|
|
P_("Whether the stage should clear its contents"),
|
2010-04-16 14:34:36 +00:00
|
|
|
|
FALSE,
|
|
|
|
|
CLUTTER_PARAM_READWRITE);
|
|
|
|
|
g_object_class_install_property (gobject_class, PROP_NO_CLEAR_HINT, pspec);
|
|
|
|
|
|
2010-12-28 17:37:18 +00:00
|
|
|
|
/**
|
|
|
|
|
* ClutterStage:accept-focus:
|
|
|
|
|
*
|
|
|
|
|
* Whether the #ClutterStage should accept key focus when shown.
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2010-12-28 17:37:18 +00:00
|
|
|
|
*/
|
|
|
|
|
pspec = g_param_spec_boolean ("accept-focus",
|
|
|
|
|
P_("Accept Focus"),
|
|
|
|
|
P_("Whether the stage should accept focus on show"),
|
|
|
|
|
TRUE,
|
|
|
|
|
CLUTTER_PARAM_READWRITE);
|
|
|
|
|
g_object_class_install_property (gobject_class, PROP_ACCEPT_FOCUS, pspec);
|
|
|
|
|
|
2007-08-24 15:12:52 +00:00
|
|
|
|
/**
|
2012-04-30 16:12:12 +00:00
|
|
|
|
* ClutterStage::fullscreen:
|
2007-08-24 15:12:52 +00:00
|
|
|
|
* @stage: the stage which was fullscreened
|
|
|
|
|
*
|
|
|
|
|
* The ::fullscreen signal is emitted when the stage is made fullscreen.
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2007-08-24 15:12:52 +00:00
|
|
|
|
*/
|
|
|
|
|
stage_signals[FULLSCREEN] =
|
2010-06-03 11:57:50 +00:00
|
|
|
|
g_signal_new (I_("fullscreen"),
|
2007-08-24 15:12:52 +00:00
|
|
|
|
G_TYPE_FROM_CLASS (gobject_class),
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
2007-08-24 15:12:52 +00:00
|
|
|
|
G_STRUCT_OFFSET (ClutterStageClass, fullscreen),
|
|
|
|
|
NULL, NULL,
|
2010-06-11 14:49:46 +00:00
|
|
|
|
_clutter_marshal_VOID__VOID,
|
2007-08-24 15:12:52 +00:00
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
/**
|
2012-04-30 16:12:12 +00:00
|
|
|
|
* ClutterStage::unfullscreen:
|
2007-08-24 15:12:52 +00:00
|
|
|
|
* @stage: the stage which has left a fullscreen state.
|
|
|
|
|
*
|
|
|
|
|
* The ::unfullscreen signal is emitted when the stage leaves a fullscreen
|
|
|
|
|
* state.
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2007-08-24 15:12:52 +00:00
|
|
|
|
*/
|
|
|
|
|
stage_signals[UNFULLSCREEN] =
|
2010-06-03 11:57:50 +00:00
|
|
|
|
g_signal_new (I_("unfullscreen"),
|
2007-08-24 15:12:52 +00:00
|
|
|
|
G_TYPE_FROM_CLASS (gobject_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (ClutterStageClass, unfullscreen),
|
|
|
|
|
NULL, NULL,
|
2010-06-11 14:49:46 +00:00
|
|
|
|
_clutter_marshal_VOID__VOID,
|
2007-08-24 15:12:52 +00:00
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
/**
|
2012-04-30 16:12:12 +00:00
|
|
|
|
* ClutterStage::activate:
|
2007-08-24 15:12:52 +00:00
|
|
|
|
* @stage: the stage which was activated
|
|
|
|
|
*
|
2008-02-15 15:18:02 +00:00
|
|
|
|
* The ::activate signal is emitted when the stage receives key focus
|
2007-08-24 15:12:52 +00:00
|
|
|
|
* from the underlying window system.
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2007-08-24 15:12:52 +00:00
|
|
|
|
*/
|
|
|
|
|
stage_signals[ACTIVATE] =
|
2010-06-03 11:57:50 +00:00
|
|
|
|
g_signal_new (I_("activate"),
|
2007-08-24 15:12:52 +00:00
|
|
|
|
G_TYPE_FROM_CLASS (gobject_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (ClutterStageClass, activate),
|
|
|
|
|
NULL, NULL,
|
2010-06-11 14:49:46 +00:00
|
|
|
|
_clutter_marshal_VOID__VOID,
|
2007-08-24 15:12:52 +00:00
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
/**
|
2012-04-30 16:12:12 +00:00
|
|
|
|
* ClutterStage::deactivate:
|
2007-08-24 15:12:52 +00:00
|
|
|
|
* @stage: the stage which was deactivated
|
|
|
|
|
*
|
|
|
|
|
* The ::activate signal is emitted when the stage loses key focus
|
|
|
|
|
* from the underlying window system.
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2007-08-24 15:12:52 +00:00
|
|
|
|
*/
|
|
|
|
|
stage_signals[DEACTIVATE] =
|
2010-06-03 11:57:50 +00:00
|
|
|
|
g_signal_new (I_("deactivate"),
|
2007-08-24 15:12:52 +00:00
|
|
|
|
G_TYPE_FROM_CLASS (gobject_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (ClutterStageClass, deactivate),
|
|
|
|
|
NULL, NULL,
|
2010-06-11 14:49:46 +00:00
|
|
|
|
_clutter_marshal_VOID__VOID,
|
2007-08-24 15:12:52 +00:00
|
|
|
|
G_TYPE_NONE, 0);
|
2007-10-12 08:17:00 +00:00
|
|
|
|
|
2010-01-12 15:44:28 +00:00
|
|
|
|
/**
|
|
|
|
|
* ClutterStage::delete-event:
|
|
|
|
|
* @stage: the stage that received the event
|
|
|
|
|
* @event: a #ClutterEvent of type %CLUTTER_DELETE
|
|
|
|
|
*
|
|
|
|
|
* The ::delete-event signal is emitted when the user closes a
|
|
|
|
|
* #ClutterStage window using the window controls.
|
|
|
|
|
*
|
|
|
|
|
* Clutter by default will call clutter_main_quit() if @stage is
|
|
|
|
|
* the default stage, and clutter_actor_destroy() for any other
|
|
|
|
|
* stage.
|
|
|
|
|
*
|
|
|
|
|
* It is possible to override the default behaviour by connecting
|
|
|
|
|
* a new handler and returning %TRUE there.
|
|
|
|
|
*
|
|
|
|
|
* <note>This signal is emitted only on Clutter backends that
|
|
|
|
|
* embed #ClutterStage in native windows. It is not emitted for
|
|
|
|
|
* backends that use a static frame buffer.</note>
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2010-01-12 15:44:28 +00:00
|
|
|
|
*/
|
|
|
|
|
stage_signals[DELETE_EVENT] =
|
|
|
|
|
g_signal_new (I_("delete-event"),
|
|
|
|
|
G_TYPE_FROM_CLASS (gobject_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (ClutterStageClass, delete_event),
|
|
|
|
|
_clutter_boolean_handled_accumulator, NULL,
|
2010-06-11 14:49:46 +00:00
|
|
|
|
_clutter_marshal_BOOLEAN__BOXED,
|
2010-01-12 15:44:28 +00:00
|
|
|
|
G_TYPE_BOOLEAN, 1,
|
|
|
|
|
CLUTTER_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
|
|
|
|
|
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
|
klass->fullscreen = clutter_stage_real_fullscreen;
|
2009-05-07 10:20:19 +00:00
|
|
|
|
klass->activate = clutter_stage_real_activate;
|
|
|
|
|
klass->deactivate = clutter_stage_real_deactivate;
|
2010-01-12 15:44:28 +00:00
|
|
|
|
klass->delete_event = clutter_stage_real_delete_event;
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
|
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
g_type_class_add_private (gobject_class, sizeof (ClutterStagePrivate));
|
2006-05-29 08:59:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-02-26 18:36:38 +00:00
|
|
|
|
static void
|
|
|
|
|
clutter_stage_notify_min_size (ClutterStage *self)
|
|
|
|
|
{
|
|
|
|
|
self->priv->min_size_changed = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-29 08:59:36 +00:00
|
|
|
|
static void
|
|
|
|
|
clutter_stage_init (ClutterStage *self)
|
|
|
|
|
{
|
2011-11-14 11:46:02 +00:00
|
|
|
|
cairo_rectangle_int_t geom = { 0, };
|
2006-05-29 08:59:36 +00:00
|
|
|
|
ClutterStagePrivate *priv;
|
Try to mop up the default stage mess
The default stage was a neat concept when we started Clutter out,
somewhere in the Jurassic era; a singleton instance that gets created at
initialization time, and remains the same for the entire duration of the
process.
Worked well enough when Clutter was a small library meant to be used to
write fullscreen media browsers, but since the introduction of multiple
stages, and Clutter being used to create all sorts of applications, the
default stage is just a vestigial remainder of that past, like an
appendix; something that complicates the layout of the code and
introduces weird behaviour, so that you notice its existence only when
something goes wrong.
Some platforms we do support, though, only have one framebuffer, so it
makes sense for them to have only one stage.
At this point, the only sane thing to do is to go through the same code
paths on all platforms, and that code path is the stage instance
creation and initialization — i.e. clutter_stage_new() (or
g_object_new() with CLUTTER_TYPE_STAGE).
For platforms that support multiple stages, nothing has changed: the stage
created by clutter_stage_get_default() will be set as the default one;
if nobody calls it, the default stage is never created, and it just
lives on as a meaningless check.
For platforms that only support one stage, clutter_stage_new() and
clutter_stage_get_default() will behave exactly the same the first time
they are called: both will create a stage, and set it as the default.
Calling clutter_stage_new() a second time is treated as a programmer
error, and will result in Clutter aborting. This is a behavioural change
because the existing behaviour or creating a new ClutterStage instance
with the same ClutterStageWindow private implementation is, simply put,
utterly braindamaged and I should have *never* had written it, and I
apologize for it. In my defence, I didn't know any better at the time.
This is the first step towards the complete deprecation of
clutter_stage_get_default() and clutter_stage_is_default(), which will
come later.
2011-11-09 14:04:05 +00:00
|
|
|
|
ClutterStageWindow *impl;
|
2008-04-04 15:02:11 +00:00
|
|
|
|
ClutterBackend *backend;
|
Try to mop up the default stage mess
The default stage was a neat concept when we started Clutter out,
somewhere in the Jurassic era; a singleton instance that gets created at
initialization time, and remains the same for the entire duration of the
process.
Worked well enough when Clutter was a small library meant to be used to
write fullscreen media browsers, but since the introduction of multiple
stages, and Clutter being used to create all sorts of applications, the
default stage is just a vestigial remainder of that past, like an
appendix; something that complicates the layout of the code and
introduces weird behaviour, so that you notice its existence only when
something goes wrong.
Some platforms we do support, though, only have one framebuffer, so it
makes sense for them to have only one stage.
At this point, the only sane thing to do is to go through the same code
paths on all platforms, and that code path is the stage instance
creation and initialization — i.e. clutter_stage_new() (or
g_object_new() with CLUTTER_TYPE_STAGE).
For platforms that support multiple stages, nothing has changed: the stage
created by clutter_stage_get_default() will be set as the default one;
if nobody calls it, the default stage is never created, and it just
lives on as a meaningless check.
For platforms that only support one stage, clutter_stage_new() and
clutter_stage_get_default() will behave exactly the same the first time
they are called: both will create a stage, and set it as the default.
Calling clutter_stage_new() a second time is treated as a programmer
error, and will result in Clutter aborting. This is a behavioural change
because the existing behaviour or creating a new ClutterStage instance
with the same ClutterStageWindow private implementation is, simply put,
utterly braindamaged and I should have *never* had written it, and I
apologize for it. In my defence, I didn't know any better at the time.
This is the first step towards the complete deprecation of
clutter_stage_get_default() and clutter_stage_is_default(), which will
come later.
2011-11-09 14:04:05 +00:00
|
|
|
|
GError *error;
|
2006-07-06 Emmanuele Bassi <ebassi@openedhand.com>
Big rework of the actor management semantics: now ClutterActor
objects behave like GtkObjects - that is they have an initial
"floating" reference that gets "sunk" when they are added to
a ClutterGroup. This makes a group responsible of de-allocating
each actor inside it, so you just have to destroy the group to
get every child actor destroyed. Also, now you can do:
clutter_group_add (group, clutter_video_texture_new ());
without having to care about reference counting and explicit
unreffing.
* clutter/clutter-private.h: Add private flags setter and
getter macros.
* clutter/clutter-actor.h:
* clutter/clutter-actor.c: Clean up; inherit from GInitiallyUnowned;
add a "visible" property; add the "destroy", "show" and "hide"
signals to ClutterActorClass.
(clutter_actor_show), (clutter_actor_hide): Refactor a bit; emit
the "show" and "hide" signals.
(clutter_actor_set_property), (clutter_actor_get_property),
(clutter_actor_class_init): Implement the "visible" property; add
signals.
(clutter_actor_finalize): Do not leak the actor's name, if it is
set.
(clutter_actor_dispose): Emit the "destroy" signal here.
(clutter_actor_init): Sink the initial floating flag if needed.
(clutter_actor_destroy): Add a function to explicitely destroy
a ClutterActor.
(clutter_actor_set_parent), (clutter_actor_get_parent),
(clutter_actor_unparent): Make set_parent require a valid parent;
add unparent; check on get_parent; ref_sink the actor when
setting its parent and unref it when unsetting it. Probably we'll
need a function that does reparenting as unparent+set_parent in
a single shot.
* clutter/clutter-group.h:
* clutter/clutter-group.c (clutter_group_dispose),
(clutter_group_finalize), (clutter_group_add),
(clutter_group_remove): Make the group destroy its children when
disposing it; clean up, and use the newly-available
clutter_actor_unparent().
* clutter/clutter-stage.h:
* clutter/clutter-stage.c (clutter_stage_init): ClutterStage is
a top-level actor; clean up.
* clutter/clutter-video-texture.h:
* clutter/clutter-video-texture.c: Clean up.
* examples/super-oh.c:
* examples/test.c:
* examples/video-player.c:
* examples/test-text.c:
* examples/video-cube.c: Remove the g_object_unref() call, as the
ClutterStage object is destroyed on clutter_main_quit().
2006-07-06 17:52:57 +00:00
|
|
|
|
|
2012-08-23 16:37:40 +00:00
|
|
|
|
CLUTTER_ACTOR_UNSET_FLAGS (self, CLUTTER_ACTOR_VISIBLE);
|
|
|
|
|
|
2006-07-06 Emmanuele Bassi <ebassi@openedhand.com>
Big rework of the actor management semantics: now ClutterActor
objects behave like GtkObjects - that is they have an initial
"floating" reference that gets "sunk" when they are added to
a ClutterGroup. This makes a group responsible of de-allocating
each actor inside it, so you just have to destroy the group to
get every child actor destroyed. Also, now you can do:
clutter_group_add (group, clutter_video_texture_new ());
without having to care about reference counting and explicit
unreffing.
* clutter/clutter-private.h: Add private flags setter and
getter macros.
* clutter/clutter-actor.h:
* clutter/clutter-actor.c: Clean up; inherit from GInitiallyUnowned;
add a "visible" property; add the "destroy", "show" and "hide"
signals to ClutterActorClass.
(clutter_actor_show), (clutter_actor_hide): Refactor a bit; emit
the "show" and "hide" signals.
(clutter_actor_set_property), (clutter_actor_get_property),
(clutter_actor_class_init): Implement the "visible" property; add
signals.
(clutter_actor_finalize): Do not leak the actor's name, if it is
set.
(clutter_actor_dispose): Emit the "destroy" signal here.
(clutter_actor_init): Sink the initial floating flag if needed.
(clutter_actor_destroy): Add a function to explicitely destroy
a ClutterActor.
(clutter_actor_set_parent), (clutter_actor_get_parent),
(clutter_actor_unparent): Make set_parent require a valid parent;
add unparent; check on get_parent; ref_sink the actor when
setting its parent and unref it when unsetting it. Probably we'll
need a function that does reparenting as unparent+set_parent in
a single shot.
* clutter/clutter-group.h:
* clutter/clutter-group.c (clutter_group_dispose),
(clutter_group_finalize), (clutter_group_add),
(clutter_group_remove): Make the group destroy its children when
disposing it; clean up, and use the newly-available
clutter_actor_unparent().
* clutter/clutter-stage.h:
* clutter/clutter-stage.c (clutter_stage_init): ClutterStage is
a top-level actor; clean up.
* clutter/clutter-video-texture.h:
* clutter/clutter-video-texture.c: Clean up.
* examples/super-oh.c:
* examples/test.c:
* examples/video-player.c:
* examples/test-text.c:
* examples/video-cube.c: Remove the g_object_unref() call, as the
ClutterStage object is destroyed on clutter_main_quit().
2006-07-06 17:52:57 +00:00
|
|
|
|
/* a stage is a top-level object */
|
2010-07-21 15:10:46 +00:00
|
|
|
|
CLUTTER_SET_PRIVATE_FLAGS (self, CLUTTER_IS_TOPLEVEL);
|
2007-10-12 08:17:00 +00:00
|
|
|
|
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
self->priv = priv = CLUTTER_STAGE_GET_PRIVATE (self);
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
2008-04-04 15:02:11 +00:00
|
|
|
|
CLUTTER_NOTE (BACKEND, "Creating stage from the default backend");
|
|
|
|
|
backend = clutter_get_default_backend ();
|
|
|
|
|
|
Try to mop up the default stage mess
The default stage was a neat concept when we started Clutter out,
somewhere in the Jurassic era; a singleton instance that gets created at
initialization time, and remains the same for the entire duration of the
process.
Worked well enough when Clutter was a small library meant to be used to
write fullscreen media browsers, but since the introduction of multiple
stages, and Clutter being used to create all sorts of applications, the
default stage is just a vestigial remainder of that past, like an
appendix; something that complicates the layout of the code and
introduces weird behaviour, so that you notice its existence only when
something goes wrong.
Some platforms we do support, though, only have one framebuffer, so it
makes sense for them to have only one stage.
At this point, the only sane thing to do is to go through the same code
paths on all platforms, and that code path is the stage instance
creation and initialization — i.e. clutter_stage_new() (or
g_object_new() with CLUTTER_TYPE_STAGE).
For platforms that support multiple stages, nothing has changed: the stage
created by clutter_stage_get_default() will be set as the default one;
if nobody calls it, the default stage is never created, and it just
lives on as a meaningless check.
For platforms that only support one stage, clutter_stage_new() and
clutter_stage_get_default() will behave exactly the same the first time
they are called: both will create a stage, and set it as the default.
Calling clutter_stage_new() a second time is treated as a programmer
error, and will result in Clutter aborting. This is a behavioural change
because the existing behaviour or creating a new ClutterStage instance
with the same ClutterStageWindow private implementation is, simply put,
utterly braindamaged and I should have *never* had written it, and I
apologize for it. In my defence, I didn't know any better at the time.
This is the first step towards the complete deprecation of
clutter_stage_get_default() and clutter_stage_is_default(), which will
come later.
2011-11-09 14:04:05 +00:00
|
|
|
|
error = NULL;
|
|
|
|
|
impl = _clutter_backend_create_stage (backend, self, &error);
|
2011-11-14 11:46:02 +00:00
|
|
|
|
|
|
|
|
|
if (G_LIKELY (impl != NULL))
|
|
|
|
|
{
|
|
|
|
|
_clutter_stage_set_window (self, impl);
|
|
|
|
|
_clutter_stage_window_get_geometry (priv->impl, &geom);
|
|
|
|
|
}
|
|
|
|
|
else
|
Try to mop up the default stage mess
The default stage was a neat concept when we started Clutter out,
somewhere in the Jurassic era; a singleton instance that gets created at
initialization time, and remains the same for the entire duration of the
process.
Worked well enough when Clutter was a small library meant to be used to
write fullscreen media browsers, but since the introduction of multiple
stages, and Clutter being used to create all sorts of applications, the
default stage is just a vestigial remainder of that past, like an
appendix; something that complicates the layout of the code and
introduces weird behaviour, so that you notice its existence only when
something goes wrong.
Some platforms we do support, though, only have one framebuffer, so it
makes sense for them to have only one stage.
At this point, the only sane thing to do is to go through the same code
paths on all platforms, and that code path is the stage instance
creation and initialization — i.e. clutter_stage_new() (or
g_object_new() with CLUTTER_TYPE_STAGE).
For platforms that support multiple stages, nothing has changed: the stage
created by clutter_stage_get_default() will be set as the default one;
if nobody calls it, the default stage is never created, and it just
lives on as a meaningless check.
For platforms that only support one stage, clutter_stage_new() and
clutter_stage_get_default() will behave exactly the same the first time
they are called: both will create a stage, and set it as the default.
Calling clutter_stage_new() a second time is treated as a programmer
error, and will result in Clutter aborting. This is a behavioural change
because the existing behaviour or creating a new ClutterStage instance
with the same ClutterStageWindow private implementation is, simply put,
utterly braindamaged and I should have *never* had written it, and I
apologize for it. In my defence, I didn't know any better at the time.
This is the first step towards the complete deprecation of
clutter_stage_get_default() and clutter_stage_is_default(), which will
come later.
2011-11-09 14:04:05 +00:00
|
|
|
|
{
|
|
|
|
|
if (error != NULL)
|
|
|
|
|
{
|
|
|
|
|
g_critical ("Unable to create a new stage implementation: %s",
|
|
|
|
|
error->message);
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
g_critical ("Unable to create a new stage implementation.");
|
2008-04-04 15:02:11 +00:00
|
|
|
|
}
|
2009-05-08 16:17:48 +00:00
|
|
|
|
|
2009-06-06 23:10:41 +00:00
|
|
|
|
priv->event_queue = g_queue_new ();
|
|
|
|
|
|
Try to mop up the default stage mess
The default stage was a neat concept when we started Clutter out,
somewhere in the Jurassic era; a singleton instance that gets created at
initialization time, and remains the same for the entire duration of the
process.
Worked well enough when Clutter was a small library meant to be used to
write fullscreen media browsers, but since the introduction of multiple
stages, and Clutter being used to create all sorts of applications, the
default stage is just a vestigial remainder of that past, like an
appendix; something that complicates the layout of the code and
introduces weird behaviour, so that you notice its existence only when
something goes wrong.
Some platforms we do support, though, only have one framebuffer, so it
makes sense for them to have only one stage.
At this point, the only sane thing to do is to go through the same code
paths on all platforms, and that code path is the stage instance
creation and initialization — i.e. clutter_stage_new() (or
g_object_new() with CLUTTER_TYPE_STAGE).
For platforms that support multiple stages, nothing has changed: the stage
created by clutter_stage_get_default() will be set as the default one;
if nobody calls it, the default stage is never created, and it just
lives on as a meaningless check.
For platforms that only support one stage, clutter_stage_new() and
clutter_stage_get_default() will behave exactly the same the first time
they are called: both will create a stage, and set it as the default.
Calling clutter_stage_new() a second time is treated as a programmer
error, and will result in Clutter aborting. This is a behavioural change
because the existing behaviour or creating a new ClutterStage instance
with the same ClutterStageWindow private implementation is, simply put,
utterly braindamaged and I should have *never* had written it, and I
apologize for it. In my defence, I didn't know any better at the time.
This is the first step towards the complete deprecation of
clutter_stage_get_default() and clutter_stage_is_default(), which will
come later.
2011-11-09 14:04:05 +00:00
|
|
|
|
priv->is_fullscreen = FALSE;
|
|
|
|
|
priv->is_user_resizable = FALSE;
|
|
|
|
|
priv->is_cursor_visible = TRUE;
|
2009-07-14 12:47:35 +00:00
|
|
|
|
priv->throttle_motion_events = TRUE;
|
Try to mop up the default stage mess
The default stage was a neat concept when we started Clutter out,
somewhere in the Jurassic era; a singleton instance that gets created at
initialization time, and remains the same for the entire duration of the
process.
Worked well enough when Clutter was a small library meant to be used to
write fullscreen media browsers, but since the introduction of multiple
stages, and Clutter being used to create all sorts of applications, the
default stage is just a vestigial remainder of that past, like an
appendix; something that complicates the layout of the code and
introduces weird behaviour, so that you notice its existence only when
something goes wrong.
Some platforms we do support, though, only have one framebuffer, so it
makes sense for them to have only one stage.
At this point, the only sane thing to do is to go through the same code
paths on all platforms, and that code path is the stage instance
creation and initialization — i.e. clutter_stage_new() (or
g_object_new() with CLUTTER_TYPE_STAGE).
For platforms that support multiple stages, nothing has changed: the stage
created by clutter_stage_get_default() will be set as the default one;
if nobody calls it, the default stage is never created, and it just
lives on as a meaningless check.
For platforms that only support one stage, clutter_stage_new() and
clutter_stage_get_default() will behave exactly the same the first time
they are called: both will create a stage, and set it as the default.
Calling clutter_stage_new() a second time is treated as a programmer
error, and will result in Clutter aborting. This is a behavioural change
because the existing behaviour or creating a new ClutterStage instance
with the same ClutterStageWindow private implementation is, simply put,
utterly braindamaged and I should have *never* had written it, and I
apologize for it. In my defence, I didn't know any better at the time.
This is the first step towards the complete deprecation of
clutter_stage_get_default() and clutter_stage_is_default(), which will
come later.
2011-11-09 14:04:05 +00:00
|
|
|
|
priv->min_size_changed = FALSE;
|
2012-11-08 17:42:24 +00:00
|
|
|
|
priv->sync_delay = -1;
|
2011-06-20 12:53:09 +00:00
|
|
|
|
|
|
|
|
|
/* XXX - we need to keep the invariant that calling
|
|
|
|
|
* clutter_set_motion_event_enabled() before the stage creation
|
|
|
|
|
* will cause motion event delivery to be disabled on any newly
|
|
|
|
|
* created stage. this can go away when we break API and remove
|
|
|
|
|
* deprecated functions.
|
|
|
|
|
*/
|
|
|
|
|
priv->motion_events_enabled = _clutter_context_get_motion_events_enabled ();
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
2012-02-13 16:05:21 +00:00
|
|
|
|
clutter_actor_set_background_color (CLUTTER_ACTOR (self),
|
|
|
|
|
&default_stage_color);
|
2007-05-31 17:11:09 +00:00
|
|
|
|
|
2009-01-20 16:20:54 +00:00
|
|
|
|
priv->perspective.fovy = 60.0; /* 60 Degrees */
|
2011-11-14 11:46:02 +00:00
|
|
|
|
priv->perspective.aspect = (float) geom.width / (float) geom.height;
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
priv->perspective.z_near = 0.1;
|
|
|
|
|
priv->perspective.z_far = 100.0;
|
2007-06-01 11:30:52 +00:00
|
|
|
|
|
2010-09-07 12:10:55 +00:00
|
|
|
|
cogl_matrix_init_identity (&priv->projection);
|
|
|
|
|
cogl_matrix_perspective (&priv->projection,
|
|
|
|
|
priv->perspective.fovy,
|
|
|
|
|
priv->perspective.aspect,
|
|
|
|
|
priv->perspective.z_near,
|
|
|
|
|
priv->perspective.z_far);
|
2011-02-08 14:46:31 +00:00
|
|
|
|
cogl_matrix_get_inverse (&priv->projection,
|
|
|
|
|
&priv->inverse_projection);
|
|
|
|
|
cogl_matrix_init_identity (&priv->view);
|
|
|
|
|
cogl_matrix_view_2d_in_perspective (&priv->view,
|
|
|
|
|
priv->perspective.fovy,
|
|
|
|
|
priv->perspective.aspect,
|
|
|
|
|
priv->perspective.z_near,
|
|
|
|
|
50, /* distance to 2d plane */
|
|
|
|
|
geom.width,
|
|
|
|
|
geom.height);
|
|
|
|
|
|
2010-09-07 12:10:55 +00:00
|
|
|
|
|
2010-09-07 19:08:00 +00:00
|
|
|
|
priv->relayout_pending = TRUE;
|
|
|
|
|
|
2007-11-15 17:35:47 +00:00
|
|
|
|
clutter_actor_set_reactive (CLUTTER_ACTOR (self), TRUE);
|
2009-12-03 20:47:48 +00:00
|
|
|
|
clutter_stage_set_title (self, g_get_prgname ());
|
2007-10-02 14:03:36 +00:00
|
|
|
|
clutter_stage_set_key_focus (self, NULL);
|
2010-02-26 18:36:38 +00:00
|
|
|
|
|
|
|
|
|
g_signal_connect (self, "notify::min-width",
|
|
|
|
|
G_CALLBACK (clutter_stage_notify_min_size), NULL);
|
|
|
|
|
g_signal_connect (self, "notify::min-height",
|
|
|
|
|
G_CALLBACK (clutter_stage_notify_min_size), NULL);
|
2010-09-07 12:10:55 +00:00
|
|
|
|
|
|
|
|
|
_clutter_stage_set_viewport (self, 0, 0, geom.width, geom.height);
|
2010-09-10 23:29:05 +00:00
|
|
|
|
|
2010-10-27 17:02:47 +00:00
|
|
|
|
_clutter_stage_set_pick_buffer_valid (self, FALSE, CLUTTER_PICK_ALL);
|
2011-03-15 13:17:04 +00:00
|
|
|
|
priv->picks_per_frame = 0;
|
2010-09-07 17:04:19 +00:00
|
|
|
|
|
|
|
|
|
priv->paint_volume_stack =
|
|
|
|
|
g_array_new (FALSE, FALSE, sizeof (ClutterPaintVolume));
|
2011-02-03 11:26:09 +00:00
|
|
|
|
|
2011-04-11 13:11:39 +00:00
|
|
|
|
priv->pick_id_pool = _clutter_id_pool_new (256);
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-04 17:42:52 +00:00
|
|
|
|
static void
|
|
|
|
|
clutter_stage_set_perspective_internal (ClutterStage *stage,
|
|
|
|
|
ClutterPerspective *perspective)
|
2007-05-25 10:56:09 +00:00
|
|
|
|
{
|
2011-04-04 17:42:52 +00:00
|
|
|
|
ClutterStagePrivate *priv = stage->priv;
|
2007-05-25 10:56:09 +00:00
|
|
|
|
|
2010-09-07 12:10:55 +00:00
|
|
|
|
if (priv->perspective.fovy == perspective->fovy &&
|
|
|
|
|
priv->perspective.aspect == perspective->aspect &&
|
|
|
|
|
priv->perspective.z_near == perspective->z_near &&
|
|
|
|
|
priv->perspective.z_far == perspective->z_far)
|
|
|
|
|
return;
|
|
|
|
|
|
2007-11-21 11:55:26 +00:00
|
|
|
|
priv->perspective = *perspective;
|
|
|
|
|
|
2010-09-07 12:10:55 +00:00
|
|
|
|
cogl_matrix_init_identity (&priv->projection);
|
|
|
|
|
cogl_matrix_perspective (&priv->projection,
|
|
|
|
|
priv->perspective.fovy,
|
|
|
|
|
priv->perspective.aspect,
|
|
|
|
|
priv->perspective.z_near,
|
|
|
|
|
priv->perspective.z_far);
|
2011-02-08 14:46:31 +00:00
|
|
|
|
cogl_matrix_get_inverse (&priv->projection,
|
|
|
|
|
&priv->inverse_projection);
|
2010-09-07 12:10:55 +00:00
|
|
|
|
|
|
|
|
|
priv->dirty_projection = TRUE;
|
|
|
|
|
clutter_actor_queue_redraw (CLUTTER_ACTOR (stage));
|
2007-05-25 10:56:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-04 17:42:52 +00:00
|
|
|
|
/**
|
|
|
|
|
* clutter_stage_set_perspective:
|
|
|
|
|
* @stage: A #ClutterStage
|
|
|
|
|
* @perspective: A #ClutterPerspective
|
|
|
|
|
*
|
|
|
|
|
* Sets the stage perspective. Using this function is not recommended
|
|
|
|
|
* because it will disable Clutter's attempts to generate an
|
|
|
|
|
* appropriate perspective based on the size of the stage.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
clutter_stage_set_perspective (ClutterStage *stage,
|
|
|
|
|
ClutterPerspective *perspective)
|
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
|
|
|
|
g_return_if_fail (perspective != NULL);
|
|
|
|
|
g_return_if_fail (perspective->z_far - perspective->z_near != 0);
|
|
|
|
|
|
|
|
|
|
priv = stage->priv;
|
|
|
|
|
|
|
|
|
|
/* If the application ever calls this function then we'll stop
|
|
|
|
|
automatically updating the perspective when the stage changes
|
|
|
|
|
size */
|
|
|
|
|
priv->has_custom_perspective = TRUE;
|
|
|
|
|
|
|
|
|
|
clutter_stage_set_perspective_internal (stage, perspective);
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-25 10:56:09 +00:00
|
|
|
|
/**
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
* clutter_stage_get_perspective:
|
2007-05-25 10:56:09 +00:00
|
|
|
|
* @stage: A #ClutterStage
|
2010-09-08 16:04:21 +00:00
|
|
|
|
* @perspective: (out caller-allocates) (allow-none): return location for a
|
|
|
|
|
* #ClutterPerspective
|
2007-10-12 08:17:00 +00:00
|
|
|
|
*
|
2007-05-25 10:56:09 +00:00
|
|
|
|
* Retrieves the stage perspective.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
clutter_stage_get_perspective (ClutterStage *stage,
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
ClutterPerspective *perspective)
|
2007-05-25 10:56:09 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
g_return_if_fail (perspective != NULL);
|
2007-05-25 10:56:09 +00:00
|
|
|
|
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
*perspective = stage->priv->perspective;
|
2007-05-25 10:56:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-09-07 12:10:55 +00:00
|
|
|
|
/*
|
|
|
|
|
* clutter_stage_get_projection_matrix:
|
|
|
|
|
* @stage: A #ClutterStage
|
|
|
|
|
* @projection: return location for a #CoglMatrix representing the
|
|
|
|
|
* perspective projection applied to actors on the given
|
|
|
|
|
* @stage.
|
|
|
|
|
*
|
|
|
|
|
* Retrieves the @stage's projection matrix. This is derived from the
|
|
|
|
|
* current perspective set using clutter_stage_set_perspective().
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2010-09-07 12:10:55 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
_clutter_stage_get_projection_matrix (ClutterStage *stage,
|
|
|
|
|
CoglMatrix *projection)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
|
|
|
|
g_return_if_fail (projection != NULL);
|
|
|
|
|
|
|
|
|
|
*projection = stage->priv->projection;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This simply provides a simple mechanism for us to ensure that
|
|
|
|
|
* the projection matrix gets re-asserted before painting.
|
|
|
|
|
*
|
|
|
|
|
* This is used when switching between multiple stages */
|
|
|
|
|
void
|
|
|
|
|
_clutter_stage_dirty_projection (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
stage->priv->dirty_projection = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* clutter_stage_set_viewport:
|
|
|
|
|
* @stage: A #ClutterStage
|
|
|
|
|
* @x: The X postition to render the stage at, in window coordinates
|
|
|
|
|
* @y: The Y position to render the stage at, in window coordinates
|
|
|
|
|
* @width: The width to render the stage at, in window coordinates
|
|
|
|
|
* @height: The height to render the stage at, in window coordinates
|
|
|
|
|
*
|
|
|
|
|
* Sets the stage viewport. The viewport defines a final scale and
|
|
|
|
|
* translation of your rendered stage and actors. This lets you render
|
|
|
|
|
* your stage into a subregion of the stage window or you could use it to
|
|
|
|
|
* pan a subregion of the stage if your stage window is smaller then
|
|
|
|
|
* the stage. (XXX: currently this isn't possible)
|
|
|
|
|
*
|
|
|
|
|
* Unlike a scale and translation done using the modelview matrix this
|
|
|
|
|
* is done after everything has had perspective projection applied, so
|
|
|
|
|
* for example if you were to pan across a subregion of the stage using
|
|
|
|
|
* the viewport then you would not see a change in perspective for the
|
|
|
|
|
* actors on the stage.
|
|
|
|
|
*
|
|
|
|
|
* Normally the stage viewport will automatically track the size of the
|
|
|
|
|
* stage window with no offset so the stage will fill your window. This
|
|
|
|
|
* behaviour can be changed with the "viewport-mimics-window" property
|
|
|
|
|
* which will automatically be set to FALSE if you use this API. If
|
|
|
|
|
* you want to revert to the original behaviour then you should set
|
|
|
|
|
* this property back to %TRUE using
|
|
|
|
|
* clutter_stage_set_viewport_mimics_window().
|
|
|
|
|
* (XXX: If we were to make this API public then we might want to do
|
|
|
|
|
* add that property.)
|
|
|
|
|
*
|
2011-02-01 16:51:58 +00:00
|
|
|
|
* Note: currently this interface only support integer precision
|
|
|
|
|
* offsets and sizes for viewports but the interface takes floats because
|
|
|
|
|
* OpenGL 4.0 has introduced floating point viewports which we might
|
|
|
|
|
* want to expose via this API eventually.
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2010-09-07 12:10:55 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
_clutter_stage_set_viewport (ClutterStage *stage,
|
2011-02-01 16:51:58 +00:00
|
|
|
|
float x,
|
|
|
|
|
float y,
|
|
|
|
|
float width,
|
|
|
|
|
float height)
|
2010-09-07 12:10:55 +00:00
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
|
|
|
|
|
|
|
|
|
priv = stage->priv;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (x == priv->viewport[0] &&
|
|
|
|
|
y == priv->viewport[1] &&
|
|
|
|
|
width == priv->viewport[2] &&
|
|
|
|
|
height == priv->viewport[3])
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
priv->viewport[0] = x;
|
|
|
|
|
priv->viewport[1] = y;
|
|
|
|
|
priv->viewport[2] = width;
|
|
|
|
|
priv->viewport[3] = height;
|
|
|
|
|
|
|
|
|
|
priv->dirty_viewport = TRUE;
|
|
|
|
|
|
2010-09-07 22:25:18 +00:00
|
|
|
|
queue_full_redraw (stage);
|
2010-09-07 12:10:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This simply provides a simple mechanism for us to ensure that
|
|
|
|
|
* the viewport gets re-asserted before next painting.
|
|
|
|
|
*
|
|
|
|
|
* This is used when switching between multiple stages */
|
|
|
|
|
void
|
|
|
|
|
_clutter_stage_dirty_viewport (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
stage->priv->dirty_viewport = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* clutter_stage_get_viewport:
|
|
|
|
|
* @stage: A #ClutterStage
|
|
|
|
|
* @x: A location for the X position where the stage is rendered,
|
|
|
|
|
* in window coordinates.
|
|
|
|
|
* @y: A location for the Y position where the stage is rendered,
|
|
|
|
|
* in window coordinates.
|
|
|
|
|
* @width: A location for the width the stage is rendered at,
|
|
|
|
|
* in window coordinates.
|
|
|
|
|
* @height: A location for the height the stage is rendered at,
|
|
|
|
|
* in window coordinates.
|
|
|
|
|
*
|
|
|
|
|
* Returns the viewport offset and size set using
|
|
|
|
|
* clutter_stage_set_viewport() or if the "viewport-mimics-window" property
|
|
|
|
|
* is TRUE then @x and @y will be set to 0 and @width and @height will equal
|
|
|
|
|
* the width if the stage window.
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2010-09-07 12:10:55 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
_clutter_stage_get_viewport (ClutterStage *stage,
|
2011-02-01 16:51:58 +00:00
|
|
|
|
float *x,
|
|
|
|
|
float *y,
|
|
|
|
|
float *width,
|
|
|
|
|
float *height)
|
2010-09-07 12:10:55 +00:00
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
|
|
|
|
|
|
|
|
|
priv = stage->priv;
|
|
|
|
|
|
|
|
|
|
*x = priv->viewport[0];
|
|
|
|
|
*y = priv->viewport[1];
|
|
|
|
|
*width = priv->viewport[2];
|
|
|
|
|
*height = priv->viewport[3];
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
|
/**
|
2009-06-09 13:05:03 +00:00
|
|
|
|
* clutter_stage_set_fullscreen:
|
2007-03-22 18:21:59 +00:00
|
|
|
|
* @stage: a #ClutterStage
|
2009-06-09 13:47:36 +00:00
|
|
|
|
* @fullscreen: %TRUE to to set the stage fullscreen
|
2007-03-22 18:21:59 +00:00
|
|
|
|
*
|
2009-06-09 13:05:03 +00:00
|
|
|
|
* Asks to place the stage window in the fullscreen or unfullscreen
|
|
|
|
|
* states.
|
|
|
|
|
*
|
|
|
|
|
( Note that you shouldn't assume the window is definitely full screen
|
|
|
|
|
* afterward, because other entities (e.g. the user or window manager)
|
|
|
|
|
* could unfullscreen it again, and not all window managers honor
|
|
|
|
|
* requests to fullscreen windows.
|
|
|
|
|
*
|
|
|
|
|
* If you want to receive notification of the fullscreen state you
|
|
|
|
|
* should either use the #ClutterStage::fullscreen and
|
|
|
|
|
* #ClutterStage::unfullscreen signals, or use the notify signal
|
|
|
|
|
* for the #ClutterStage:fullscreen-set property
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2007-03-22 18:21:59 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
2009-06-09 13:05:03 +00:00
|
|
|
|
clutter_stage_set_fullscreen (ClutterStage *stage,
|
|
|
|
|
gboolean fullscreen)
|
2006-05-29 08:59:36 +00:00
|
|
|
|
{
|
2007-03-22 18:21:59 +00:00
|
|
|
|
ClutterStagePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
|
|
|
|
|
|
|
|
|
priv = stage->priv;
|
2009-06-09 13:05:03 +00:00
|
|
|
|
|
|
|
|
|
if (priv->is_fullscreen != fullscreen)
|
2007-03-22 18:21:59 +00:00
|
|
|
|
{
|
2008-04-04 15:02:11 +00:00
|
|
|
|
ClutterStageWindow *impl = CLUTTER_STAGE_WINDOW (priv->impl);
|
|
|
|
|
ClutterStageWindowIface *iface;
|
|
|
|
|
|
|
|
|
|
iface = CLUTTER_STAGE_WINDOW_GET_IFACE (impl);
|
|
|
|
|
|
2007-10-12 08:17:00 +00:00
|
|
|
|
/* Only set if backend implements.
|
2009-06-09 13:05:03 +00:00
|
|
|
|
*
|
2007-10-08 16:18:33 +00:00
|
|
|
|
* Also see clutter_stage_event() for setting priv->is_fullscreen
|
2007-10-12 08:17:00 +00:00
|
|
|
|
* on state change event.
|
2009-06-09 13:05:03 +00:00
|
|
|
|
*/
|
2008-04-04 15:02:11 +00:00
|
|
|
|
if (iface->set_fullscreen)
|
2009-06-09 13:05:03 +00:00
|
|
|
|
iface->set_fullscreen (impl, fullscreen);
|
2007-03-22 18:21:59 +00:00
|
|
|
|
}
|
2010-09-07 12:10:55 +00:00
|
|
|
|
|
|
|
|
|
/* If the backend did fullscreen the stage window then we need to resize
|
|
|
|
|
* the stage and update its viewport so we queue a relayout. Note: if the
|
|
|
|
|
* fullscreen request is handled asynchronously we can't rely on this
|
|
|
|
|
* queue_relayout to update the viewport, but for example the X backend
|
|
|
|
|
* will recieve a ConfigureNotify after a successful resize which is how
|
|
|
|
|
* we ensure the viewport is updated on X.
|
|
|
|
|
*/
|
|
|
|
|
clutter_actor_queue_relayout (CLUTTER_ACTOR (stage));
|
2006-05-29 08:59:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2009-06-09 13:05:03 +00:00
|
|
|
|
* clutter_stage_get_fullscreen:
|
2007-03-22 18:21:59 +00:00
|
|
|
|
* @stage: a #ClutterStage
|
2006-05-29 08:59:36 +00:00
|
|
|
|
*
|
2009-06-09 13:05:03 +00:00
|
|
|
|
* Retrieves whether the stage is full screen or not
|
|
|
|
|
*
|
|
|
|
|
* Return value: %TRUE if the stage is full screen
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2007-03-22 18:21:59 +00:00
|
|
|
|
*/
|
2009-06-09 13:05:03 +00:00
|
|
|
|
gboolean
|
|
|
|
|
clutter_stage_get_fullscreen (ClutterStage *stage)
|
2006-05-29 08:59:36 +00:00
|
|
|
|
{
|
2009-06-09 13:05:03 +00:00
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE);
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
|
2009-06-09 13:05:03 +00:00
|
|
|
|
return stage->priv->is_fullscreen;
|
2007-03-22 18:21:59 +00:00
|
|
|
|
}
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
|
2007-07-26 20:08:09 +00:00
|
|
|
|
/**
|
2007-07-31 17:01:52 +00:00
|
|
|
|
* clutter_stage_set_user_resizable:
|
2007-07-26 20:08:09 +00:00
|
|
|
|
* @stage: a #ClutterStage
|
2008-02-15 15:18:02 +00:00
|
|
|
|
* @resizable: whether the stage should be user resizable.
|
2007-07-26 20:08:09 +00:00
|
|
|
|
*
|
2008-02-15 15:18:02 +00:00
|
|
|
|
* Sets if the stage is resizable by user interaction (e.g. via
|
2007-07-26 20:08:09 +00:00
|
|
|
|
* window manager controls)
|
2007-07-31 17:01:52 +00:00
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2007-07-26 20:08:09 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
2007-07-31 17:01:52 +00:00
|
|
|
|
clutter_stage_set_user_resizable (ClutterStage *stage,
|
|
|
|
|
gboolean resizable)
|
2007-07-26 20:08:09 +00:00
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
|
|
|
|
|
|
|
|
|
priv = stage->priv;
|
|
|
|
|
|
|
|
|
|
if (clutter_feature_available (CLUTTER_FEATURE_STAGE_USER_RESIZE)
|
2008-04-04 15:02:11 +00:00
|
|
|
|
&& priv->is_user_resizable != resizable)
|
2007-07-26 20:08:09 +00:00
|
|
|
|
{
|
2008-04-04 15:02:11 +00:00
|
|
|
|
ClutterStageWindow *impl = CLUTTER_STAGE_WINDOW (priv->impl);
|
|
|
|
|
ClutterStageWindowIface *iface;
|
2007-07-26 20:08:09 +00:00
|
|
|
|
|
2008-04-04 15:02:11 +00:00
|
|
|
|
iface = CLUTTER_STAGE_WINDOW_GET_IFACE (impl);
|
|
|
|
|
if (iface->set_user_resizable)
|
|
|
|
|
{
|
|
|
|
|
priv->is_user_resizable = resizable;
|
|
|
|
|
|
|
|
|
|
iface->set_user_resizable (impl, resizable);
|
2007-07-26 20:08:09 +00:00
|
|
|
|
|
2008-04-04 15:02:11 +00:00
|
|
|
|
g_object_notify (G_OBJECT (stage), "user-resizable");
|
|
|
|
|
}
|
2007-07-26 20:08:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-31 17:01:52 +00:00
|
|
|
|
/**
|
|
|
|
|
* clutter_stage_get_user_resizable:
|
|
|
|
|
* @stage: a #ClutterStage
|
|
|
|
|
*
|
|
|
|
|
* Retrieves the value set with clutter_stage_set_user_resizable().
|
|
|
|
|
*
|
2008-02-15 15:18:02 +00:00
|
|
|
|
* Return value: %TRUE if the stage is resizable by the user.
|
2007-07-31 17:01:52 +00:00
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2007-07-31 17:01:52 +00:00
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
clutter_stage_get_user_resizable (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE);
|
|
|
|
|
|
|
|
|
|
return stage->priv->is_user_resizable;
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* clutter_stage_show_cursor:
|
|
|
|
|
* @stage: a #ClutterStage
|
|
|
|
|
*
|
|
|
|
|
* Shows the cursor on the stage window
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
clutter_stage_show_cursor (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv;
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
|
priv = stage->priv;
|
|
|
|
|
if (!priv->is_cursor_visible)
|
2006-06-08 21:28:05 +00:00
|
|
|
|
{
|
2008-04-04 15:02:11 +00:00
|
|
|
|
ClutterStageWindow *impl = CLUTTER_STAGE_WINDOW (priv->impl);
|
|
|
|
|
ClutterStageWindowIface *iface;
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
2008-04-04 15:02:11 +00:00
|
|
|
|
iface = CLUTTER_STAGE_WINDOW_GET_IFACE (impl);
|
|
|
|
|
if (iface->set_cursor_visible)
|
|
|
|
|
{
|
|
|
|
|
priv->is_cursor_visible = TRUE;
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
2008-04-04 15:02:11 +00:00
|
|
|
|
iface->set_cursor_visible (impl, TRUE);
|
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (stage), "cursor-visible");
|
|
|
|
|
}
|
2006-06-08 21:28:05 +00:00
|
|
|
|
}
|
2006-05-29 08:59:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* clutter_stage_hide_cursor:
|
2007-07-24 17:34:06 +00:00
|
|
|
|
* @stage: a #ClutterStage
|
|
|
|
|
*
|
|
|
|
|
* Makes the cursor invisible on the stage window
|
2007-03-22 18:21:59 +00:00
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2007-03-22 18:21:59 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
clutter_stage_hide_cursor (ClutterStage *stage)
|
2007-01-23 20:29:11 +00:00
|
|
|
|
{
|
2007-03-22 18:21:59 +00:00
|
|
|
|
ClutterStagePrivate *priv;
|
2007-01-23 20:29:11 +00:00
|
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
2007-01-23 20:29:11 +00:00
|
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
|
priv = stage->priv;
|
|
|
|
|
if (priv->is_cursor_visible)
|
|
|
|
|
{
|
2008-04-04 15:02:11 +00:00
|
|
|
|
ClutterStageWindow *impl = CLUTTER_STAGE_WINDOW (priv->impl);
|
|
|
|
|
ClutterStageWindowIface *iface;
|
|
|
|
|
|
|
|
|
|
iface = CLUTTER_STAGE_WINDOW_GET_IFACE (impl);
|
|
|
|
|
if (iface->set_cursor_visible)
|
|
|
|
|
{
|
2008-07-14 08:49:22 +00:00
|
|
|
|
priv->is_cursor_visible = FALSE;
|
2007-01-23 20:29:11 +00:00
|
|
|
|
|
2008-04-04 15:02:11 +00:00
|
|
|
|
iface->set_cursor_visible (impl, FALSE);
|
2007-01-23 20:29:11 +00:00
|
|
|
|
|
2008-04-04 15:02:11 +00:00
|
|
|
|
g_object_notify (G_OBJECT (stage), "cursor-visible");
|
|
|
|
|
}
|
2007-03-22 18:21:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2007-01-23 20:29:11 +00:00
|
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
|
/**
|
2008-04-25 13:37:36 +00:00
|
|
|
|
* clutter_stage_read_pixels:
|
2007-03-22 18:21:59 +00:00
|
|
|
|
* @stage: A #ClutterStage
|
|
|
|
|
* @x: x coordinate of the first pixel that is read from stage
|
|
|
|
|
* @y: y coordinate of the first pixel that is read from stage
|
|
|
|
|
* @width: Width dimention of pixels to be read, or -1 for the
|
|
|
|
|
* entire stage width
|
|
|
|
|
* @height: Height dimention of pixels to be read, or -1 for the
|
|
|
|
|
* entire stage height
|
|
|
|
|
*
|
2008-04-25 13:37:36 +00:00
|
|
|
|
* Makes a screenshot of the stage in RGBA 8bit data, returns a
|
2008-06-23 10:06:02 +00:00
|
|
|
|
* linear buffer with @width * 4 as rowstride.
|
2007-03-22 18:21:59 +00:00
|
|
|
|
*
|
2008-07-14 08:49:22 +00:00
|
|
|
|
* The alpha data contained in the returned buffer is driver-dependent,
|
2008-07-01 14:08:24 +00:00
|
|
|
|
* and not guaranteed to hold any sensible value.
|
|
|
|
|
*
|
2012-06-12 22:41:39 +00:00
|
|
|
|
* Return value: (transfer full) (array): a pointer to newly allocated memory with the buffer
|
2008-06-23 10:06:02 +00:00
|
|
|
|
* or %NULL if the read failed. Use g_free() on the returned data
|
|
|
|
|
* to release the resources it has allocated.
|
2008-04-04 15:02:11 +00:00
|
|
|
|
*/
|
2008-04-25 13:37:36 +00:00
|
|
|
|
guchar *
|
|
|
|
|
clutter_stage_read_pixels (ClutterStage *stage,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
gint width,
|
|
|
|
|
gint height)
|
2007-03-22 18:21:59 +00:00
|
|
|
|
{
|
2012-08-10 13:06:49 +00:00
|
|
|
|
ClutterActorBox box;
|
2008-04-25 13:37:36 +00:00
|
|
|
|
guchar *pixels;
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), NULL);
|
2008-04-25 13:37:36 +00:00
|
|
|
|
|
|
|
|
|
/* Force a redraw of the stage before reading back pixels */
|
|
|
|
|
clutter_stage_ensure_current (stage);
|
2009-06-10 13:52:53 +00:00
|
|
|
|
clutter_actor_paint (CLUTTER_ACTOR (stage));
|
2008-04-25 13:37:36 +00:00
|
|
|
|
|
2012-08-10 13:06:49 +00:00
|
|
|
|
clutter_actor_get_allocation_box (CLUTTER_ACTOR (stage), &box);
|
2008-06-23 10:06:02 +00:00
|
|
|
|
|
2011-02-01 18:15:50 +00:00
|
|
|
|
if (width < 0)
|
2012-08-10 13:06:49 +00:00
|
|
|
|
width = ceilf (box.x2 - box.x1);
|
2008-06-23 10:06:02 +00:00
|
|
|
|
|
2011-02-01 18:15:50 +00:00
|
|
|
|
if (height < 0)
|
2012-08-10 13:06:49 +00:00
|
|
|
|
height = ceilf (box.y2 - box.y1);
|
2008-06-23 10:06:02 +00:00
|
|
|
|
|
2011-02-01 18:15:50 +00:00
|
|
|
|
pixels = g_malloc (height * width * 4);
|
2008-04-04 15:02:11 +00:00
|
|
|
|
|
2009-06-17 13:30:44 +00:00
|
|
|
|
cogl_read_pixels (x, y, width, height,
|
|
|
|
|
COGL_READ_PIXELS_COLOR_BUFFER,
|
|
|
|
|
COGL_PIXEL_FORMAT_RGBA_8888,
|
|
|
|
|
pixels);
|
2008-06-23 10:06:02 +00:00
|
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
|
return pixels;
|
2007-03-22 18:21:59 +00:00
|
|
|
|
}
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
2007-03-25 11:47:30 +00:00
|
|
|
|
/**
|
|
|
|
|
* clutter_stage_get_actor_at_pos:
|
2007-07-01 16:44:24 +00:00
|
|
|
|
* @stage: a #ClutterStage
|
2009-04-24 14:05:02 +00:00
|
|
|
|
* @pick_mode: how the scene graph should be painted
|
2007-07-01 16:44:24 +00:00
|
|
|
|
* @x: X coordinate to check
|
|
|
|
|
* @y: Y coordinate to check
|
2007-03-25 11:47:30 +00:00
|
|
|
|
*
|
2007-07-01 16:44:24 +00:00
|
|
|
|
* Checks the scene at the coordinates @x and @y and returns a pointer
|
|
|
|
|
* to the #ClutterActor at those coordinates.
|
2007-03-25 11:47:30 +00:00
|
|
|
|
*
|
2009-04-24 14:05:02 +00:00
|
|
|
|
* By using @pick_mode it is possible to control which actors will be
|
|
|
|
|
* painted and thus available.
|
|
|
|
|
*
|
|
|
|
|
* Return value: (transfer none): the actor at the specified coordinates,
|
|
|
|
|
* if any
|
2007-03-25 11:47:30 +00:00
|
|
|
|
*/
|
2007-03-22 18:21:59 +00:00
|
|
|
|
ClutterActor *
|
2009-04-24 14:05:02 +00:00
|
|
|
|
clutter_stage_get_actor_at_pos (ClutterStage *stage,
|
|
|
|
|
ClutterPickMode pick_mode,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y)
|
2007-03-22 18:21:59 +00:00
|
|
|
|
{
|
2011-03-15 13:17:04 +00:00
|
|
|
|
return _clutter_stage_do_pick (stage, x, y, pick_mode);
|
2006-05-29 08:59:36 +00:00
|
|
|
|
}
|
2007-03-26 23:18:39 +00:00
|
|
|
|
|
2007-04-25 14:22:24 +00:00
|
|
|
|
/**
|
|
|
|
|
* clutter_stage_event:
|
|
|
|
|
* @stage: a #ClutterStage
|
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
|
*
|
|
|
|
|
* This function is used to emit an event on the main stage.
|
2008-04-04 15:02:11 +00:00
|
|
|
|
*
|
2007-04-25 14:22:24 +00:00
|
|
|
|
* You should rarely need to use this function, except for
|
2008-04-04 15:02:11 +00:00
|
|
|
|
* synthetised events.
|
2007-04-25 14:22:24 +00:00
|
|
|
|
*
|
|
|
|
|
* Return value: the return value from the signal emission
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2007-04-25 14:22:24 +00:00
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
clutter_stage_event (ClutterStage *stage,
|
|
|
|
|
ClutterEvent *event)
|
|
|
|
|
{
|
2007-10-08 16:18:33 +00:00
|
|
|
|
ClutterStagePrivate *priv;
|
|
|
|
|
|
2007-04-25 14:22:24 +00:00
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE);
|
|
|
|
|
g_return_val_if_fail (event != NULL, FALSE);
|
|
|
|
|
|
2007-10-08 16:18:33 +00:00
|
|
|
|
priv = stage->priv;
|
|
|
|
|
|
2007-08-24 15:12:52 +00:00
|
|
|
|
if (event->type == CLUTTER_DELETE)
|
2008-01-18 18:08:37 +00:00
|
|
|
|
{
|
|
|
|
|
gboolean retval = FALSE;
|
|
|
|
|
|
|
|
|
|
g_signal_emit_by_name (stage, "event", event, &retval);
|
|
|
|
|
|
2010-01-12 15:44:28 +00:00
|
|
|
|
if (!retval)
|
|
|
|
|
g_signal_emit_by_name (stage, "delete-event", event, &retval);
|
|
|
|
|
|
2008-01-18 18:08:37 +00:00
|
|
|
|
return retval;
|
|
|
|
|
}
|
2007-08-24 15:12:52 +00:00
|
|
|
|
|
|
|
|
|
if (event->type != CLUTTER_STAGE_STATE)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
/* emit raw event */
|
2007-10-10 13:04:34 +00:00
|
|
|
|
if (clutter_actor_event (CLUTTER_ACTOR (stage), event, FALSE))
|
2007-10-02 14:03:36 +00:00
|
|
|
|
return TRUE;
|
2007-08-24 15:12:52 +00:00
|
|
|
|
|
|
|
|
|
if (event->stage_state.changed_mask & CLUTTER_STAGE_STATE_FULLSCREEN)
|
|
|
|
|
{
|
|
|
|
|
if (event->stage_state.new_state & CLUTTER_STAGE_STATE_FULLSCREEN)
|
2007-10-08 16:18:33 +00:00
|
|
|
|
{
|
|
|
|
|
priv->is_fullscreen = TRUE;
|
|
|
|
|
g_signal_emit (stage, stage_signals[FULLSCREEN], 0);
|
2007-10-10 14:29:29 +00:00
|
|
|
|
|
2009-06-09 12:48:03 +00:00
|
|
|
|
g_object_notify (G_OBJECT (stage), "fullscreen-set");
|
2007-10-08 16:18:33 +00:00
|
|
|
|
}
|
2007-08-24 15:12:52 +00:00
|
|
|
|
else
|
2007-10-08 16:18:33 +00:00
|
|
|
|
{
|
|
|
|
|
priv->is_fullscreen = FALSE;
|
|
|
|
|
g_signal_emit (stage, stage_signals[UNFULLSCREEN], 0);
|
2007-10-12 08:17:00 +00:00
|
|
|
|
|
2009-06-09 12:48:03 +00:00
|
|
|
|
g_object_notify (G_OBJECT (stage), "fullscreen-set");
|
2007-10-08 16:18:33 +00:00
|
|
|
|
}
|
2007-08-24 15:12:52 +00:00
|
|
|
|
}
|
2007-10-12 08:17:00 +00:00
|
|
|
|
|
2007-08-24 15:12:52 +00:00
|
|
|
|
if (event->stage_state.changed_mask & CLUTTER_STAGE_STATE_ACTIVATED)
|
|
|
|
|
{
|
|
|
|
|
if (event->stage_state.new_state & CLUTTER_STAGE_STATE_ACTIVATED)
|
|
|
|
|
g_signal_emit (stage, stage_signals[ACTIVATE], 0);
|
|
|
|
|
else
|
|
|
|
|
g_signal_emit (stage, stage_signals[DEACTIVATE], 0);
|
|
|
|
|
}
|
2007-04-25 14:22:24 +00:00
|
|
|
|
|
2007-08-13 20:48:01 +00:00
|
|
|
|
return TRUE;
|
2007-04-25 14:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-06-19 09:10:37 +00:00
|
|
|
|
/**
|
2012-04-30 16:12:12 +00:00
|
|
|
|
* clutter_stage_set_title:
|
2007-06-19 09:10:37 +00:00
|
|
|
|
* @stage: A #ClutterStage
|
|
|
|
|
* @title: A utf8 string for the stage windows title.
|
2007-10-12 08:17:00 +00:00
|
|
|
|
*
|
2007-06-19 09:10:37 +00:00
|
|
|
|
* Sets the stage title.
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2007-06-19 09:10:37 +00:00
|
|
|
|
**/
|
2007-10-12 08:17:00 +00:00
|
|
|
|
void
|
2007-06-19 09:10:37 +00:00
|
|
|
|
clutter_stage_set_title (ClutterStage *stage,
|
|
|
|
|
const gchar *title)
|
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv;
|
2008-04-04 15:02:11 +00:00
|
|
|
|
ClutterStageWindow *impl;
|
2007-06-19 09:10:37 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
|
|
|
|
|
|
|
|
|
priv = stage->priv;
|
|
|
|
|
|
|
|
|
|
g_free (priv->title);
|
|
|
|
|
priv->title = g_strdup (title);
|
|
|
|
|
|
2008-04-04 15:02:11 +00:00
|
|
|
|
impl = CLUTTER_STAGE_WINDOW (priv->impl);
|
2008-04-25 13:37:36 +00:00
|
|
|
|
if (CLUTTER_STAGE_WINDOW_GET_IFACE(impl)->set_title != NULL)
|
|
|
|
|
CLUTTER_STAGE_WINDOW_GET_IFACE (impl)->set_title (impl, priv->title);
|
2007-06-19 09:10:37 +00:00
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (stage), "title");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2012-04-30 16:12:12 +00:00
|
|
|
|
* clutter_stage_get_title:
|
2007-06-19 09:10:37 +00:00
|
|
|
|
* @stage: A #ClutterStage
|
2007-10-12 08:17:00 +00:00
|
|
|
|
*
|
2007-06-19 09:10:37 +00:00
|
|
|
|
* Gets the stage title.
|
|
|
|
|
*
|
|
|
|
|
* Return value: pointer to the title string for the stage. The
|
|
|
|
|
* returned string is owned by the actor and should not
|
|
|
|
|
* be modified or freed.
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2007-06-19 09:10:37 +00:00
|
|
|
|
**/
|
Eliminate G_CONST_RETURN
The G_CONST_RETURN define in GLib is, and has always been, a bit fuzzy.
We always used it to conform to the platform, at least for public-facing
API.
At first I assumed it has something to do with brain-damaged compilers
or with weird platforms where const was not really supported; sadly,
it's something much, much worse: it's a define that can be toggled at
compile-time to remove const from the signature of public API. This is a
truly terrifying feature that I assume was added in the past century,
and whose inception clearly had something to do with massive doses of
absynthe and opium — because any other explanation would make the
existence of such a feature even worse than assuming drugs had anything
to do with it.
Anyway, and pleasing the gods, this dubious feature is being
removed/deprecated in GLib; see bug:
https://bugzilla.gnome.org/show_bug.cgi?id=644611
Before deprecation, though, we should just remove its usage from the
whole API. We should especially remove its usage from Cally's internals,
since there it never made sense in the first place.
2011-06-07 14:49:20 +00:00
|
|
|
|
const gchar *
|
2007-06-19 09:10:37 +00:00
|
|
|
|
clutter_stage_get_title (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), NULL);
|
|
|
|
|
|
|
|
|
|
return stage->priv->title;
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-13 20:48:01 +00:00
|
|
|
|
static void
|
2012-02-13 08:45:22 +00:00
|
|
|
|
on_key_focus_destroy (ClutterActor *actor,
|
|
|
|
|
ClutterStage *stage)
|
2007-08-13 20:48:01 +00:00
|
|
|
|
{
|
2012-02-13 08:45:22 +00:00
|
|
|
|
/* unset the key focus */
|
2007-10-02 14:03:36 +00:00
|
|
|
|
clutter_stage_set_key_focus (stage, NULL);
|
2007-08-13 20:48:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-11-23 13:11:10 +00:00
|
|
|
|
/**
|
|
|
|
|
* clutter_stage_set_key_focus:
|
|
|
|
|
* @stage: the #ClutterStage
|
2009-08-13 09:49:39 +00:00
|
|
|
|
* @actor: (allow-none): the actor to set key focus to, or %NULL
|
2007-11-23 13:11:10 +00:00
|
|
|
|
*
|
|
|
|
|
* Sets the key focus on @actor. An actor with key focus will receive
|
|
|
|
|
* all the key events. If @actor is %NULL, the stage will receive
|
|
|
|
|
* focus.
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2007-11-23 13:11:10 +00:00
|
|
|
|
*/
|
2007-08-13 20:48:01 +00:00
|
|
|
|
void
|
2007-10-02 14:03:36 +00:00
|
|
|
|
clutter_stage_set_key_focus (ClutterStage *stage,
|
|
|
|
|
ClutterActor *actor)
|
2007-08-13 20:48:01 +00:00
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
|
|
|
|
g_return_if_fail (actor == NULL || CLUTTER_IS_ACTOR (actor));
|
|
|
|
|
|
|
|
|
|
priv = stage->priv;
|
|
|
|
|
|
2012-09-03 23:06:27 +00:00
|
|
|
|
/* normalize the key focus. NULL == stage */
|
|
|
|
|
if (actor == CLUTTER_ACTOR (stage))
|
|
|
|
|
actor = NULL;
|
|
|
|
|
|
2012-02-13 08:45:22 +00:00
|
|
|
|
/* avoid emitting signals and notifications if we're setting the same
|
|
|
|
|
* actor as the key focus
|
|
|
|
|
*/
|
2007-08-13 20:48:01 +00:00
|
|
|
|
if (priv->key_focused_actor == actor)
|
|
|
|
|
return;
|
|
|
|
|
|
2012-02-13 08:45:22 +00:00
|
|
|
|
if (priv->key_focused_actor != NULL)
|
2007-08-13 20:48:01 +00:00
|
|
|
|
{
|
2009-04-24 15:43:39 +00:00
|
|
|
|
ClutterActor *old_focused_actor;
|
|
|
|
|
|
|
|
|
|
old_focused_actor = priv->key_focused_actor;
|
|
|
|
|
|
|
|
|
|
/* set key_focused_actor to NULL before emitting the signal or someone
|
|
|
|
|
* might hide the previously focused actor in the signal handler and we'd
|
|
|
|
|
* get re-entrant call and get glib critical from g_object_weak_unref
|
|
|
|
|
*/
|
2012-02-13 08:45:22 +00:00
|
|
|
|
g_signal_handlers_disconnect_by_func (priv->key_focused_actor,
|
|
|
|
|
G_CALLBACK (on_key_focus_destroy),
|
|
|
|
|
stage);
|
2007-10-02 14:03:36 +00:00
|
|
|
|
priv->key_focused_actor = NULL;
|
2009-04-24 15:43:39 +00:00
|
|
|
|
|
|
|
|
|
g_signal_emit_by_name (old_focused_actor, "key-focus-out");
|
2007-08-13 20:48:01 +00:00
|
|
|
|
}
|
2007-10-02 14:03:36 +00:00
|
|
|
|
else
|
2009-05-06 16:56:40 +00:00
|
|
|
|
g_signal_emit_by_name (stage, "key-focus-out");
|
2007-08-13 20:48:01 +00:00
|
|
|
|
|
2009-04-24 15:43:39 +00:00
|
|
|
|
/* Note, if someone changes key focus in focus-out signal handler we'd be
|
|
|
|
|
* overriding the latter call below moving the focus where it was originally
|
|
|
|
|
* intended. The order of events would be:
|
|
|
|
|
* 1st focus-out, 2nd focus-out (on stage), 2nd focus-in, 1st focus-in
|
|
|
|
|
*/
|
2012-02-13 08:45:22 +00:00
|
|
|
|
if (actor != NULL)
|
2007-08-13 20:48:01 +00:00
|
|
|
|
{
|
2007-10-02 14:03:36 +00:00
|
|
|
|
priv->key_focused_actor = actor;
|
|
|
|
|
|
2012-02-13 08:45:22 +00:00
|
|
|
|
g_signal_connect (actor,
|
|
|
|
|
"destroy", G_CALLBACK (on_key_focus_destroy),
|
|
|
|
|
stage);
|
2009-05-06 16:56:40 +00:00
|
|
|
|
g_signal_emit_by_name (priv->key_focused_actor, "key-focus-in");
|
2007-08-13 20:48:01 +00:00
|
|
|
|
}
|
2007-10-02 14:03:36 +00:00
|
|
|
|
else
|
2009-05-06 16:56:40 +00:00
|
|
|
|
g_signal_emit_by_name (stage, "key-focus-in");
|
2010-02-01 11:04:59 +00:00
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (stage), "key-focus");
|
2007-08-13 20:48:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-11-23 13:11:10 +00:00
|
|
|
|
/**
|
|
|
|
|
* clutter_stage_get_key_focus:
|
|
|
|
|
* @stage: the #ClutterStage
|
|
|
|
|
*
|
|
|
|
|
* Retrieves the actor that is currently under key focus.
|
|
|
|
|
*
|
2009-02-17 00:25:20 +00:00
|
|
|
|
* Return value: (transfer none): the actor with key focus, or the stage
|
2007-11-23 13:11:10 +00:00
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2007-11-23 13:11:10 +00:00
|
|
|
|
*/
|
2007-10-02 14:03:36 +00:00
|
|
|
|
ClutterActor *
|
|
|
|
|
clutter_stage_get_key_focus (ClutterStage *stage)
|
2007-08-13 20:48:01 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), NULL);
|
|
|
|
|
|
2007-10-02 14:03:36 +00:00
|
|
|
|
if (stage->priv->key_focused_actor)
|
|
|
|
|
return stage->priv->key_focused_actor;
|
2007-08-13 20:48:01 +00:00
|
|
|
|
|
2007-10-02 14:03:36 +00:00
|
|
|
|
return CLUTTER_ACTOR (stage);
|
2007-08-13 20:48:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-11-21 11:55:26 +00:00
|
|
|
|
/*** Perspective boxed type ******/
|
|
|
|
|
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
static gpointer
|
|
|
|
|
clutter_perspective_copy (gpointer data)
|
2007-03-26 23:18:39 +00:00
|
|
|
|
{
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
if (G_LIKELY (data))
|
|
|
|
|
return g_slice_dup (ClutterPerspective, data);
|
2007-03-26 23:18:39 +00:00
|
|
|
|
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
return NULL;
|
2007-03-26 23:18:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-11-21 11:55:26 +00:00
|
|
|
|
static void
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
clutter_perspective_free (gpointer data)
|
2007-03-26 23:18:39 +00:00
|
|
|
|
{
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
|
if (G_LIKELY (data))
|
|
|
|
|
g_slice_free (ClutterPerspective, data);
|
2007-03-26 23:18:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-08 14:21:57 +00:00
|
|
|
|
G_DEFINE_BOXED_TYPE (ClutterPerspective, clutter_perspective,
|
|
|
|
|
clutter_perspective_copy,
|
|
|
|
|
clutter_perspective_free);
|
2007-05-25 10:56:09 +00:00
|
|
|
|
|
2008-03-28 22:50:55 +00:00
|
|
|
|
/**
|
2008-04-04 15:02:11 +00:00
|
|
|
|
* clutter_stage_new:
|
2008-03-28 22:50:55 +00:00
|
|
|
|
*
|
|
|
|
|
* Creates a new, non-default stage. A non-default stage is a new
|
|
|
|
|
* top-level actor which can be used as another container. It works
|
|
|
|
|
* exactly like the default stage, but while clutter_stage_get_default()
|
|
|
|
|
* will always return the same instance, you will have to keep a pointer
|
2010-11-18 14:14:37 +00:00
|
|
|
|
* to any #ClutterStage returned by clutter_stage_new().
|
2008-03-28 22:50:55 +00:00
|
|
|
|
*
|
|
|
|
|
* The ability to support multiple stages depends on the current
|
|
|
|
|
* backend. Use clutter_feature_available() and
|
|
|
|
|
* %CLUTTER_FEATURE_STAGE_MULTIPLE to check at runtime whether a
|
|
|
|
|
* backend supports multiple stages.
|
|
|
|
|
*
|
|
|
|
|
* Return value: a new stage, or %NULL if the default backend does
|
|
|
|
|
* not support multiple stages. Use clutter_actor_destroy() to
|
2008-04-04 15:02:11 +00:00
|
|
|
|
* programmatically close the returned stage.
|
2008-03-28 22:50:55 +00:00
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2008-03-28 22:50:55 +00:00
|
|
|
|
*/
|
2008-04-04 15:02:11 +00:00
|
|
|
|
ClutterActor *
|
|
|
|
|
clutter_stage_new (void)
|
2008-03-28 22:50:55 +00:00
|
|
|
|
{
|
2008-06-03 20:15:11 +00:00
|
|
|
|
return g_object_new (CLUTTER_TYPE_STAGE, NULL);
|
2008-03-28 22:50:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* clutter_stage_ensure_current:
|
|
|
|
|
* @stage: the #ClutterStage
|
|
|
|
|
*
|
|
|
|
|
* This function essentially makes sure the right GL context is
|
|
|
|
|
* current for the passed stage. It is not intended to
|
|
|
|
|
* be used by applications.
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2008-03-28 22:50:55 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
clutter_stage_ensure_current (ClutterStage *stage)
|
|
|
|
|
{
|
2009-06-17 16:59:54 +00:00
|
|
|
|
ClutterBackend *backend;
|
2008-03-28 22:50:55 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
|
|
|
|
|
2009-06-17 16:59:54 +00:00
|
|
|
|
backend = clutter_get_default_backend ();
|
|
|
|
|
_clutter_backend_ensure_context (backend, stage);
|
2008-03-28 22:50:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-01-12 11:18:11 +00:00
|
|
|
|
/**
|
|
|
|
|
* clutter_stage_ensure_viewport:
|
|
|
|
|
* @stage: a #ClutterStage
|
|
|
|
|
*
|
|
|
|
|
* Ensures that the GL viewport is updated with the current
|
|
|
|
|
* stage window size.
|
|
|
|
|
*
|
|
|
|
|
* This function will queue a redraw of @stage.
|
|
|
|
|
*
|
|
|
|
|
* This function should not be called by applications; it is used
|
|
|
|
|
* when embedding a #ClutterStage into a toolkit with another
|
|
|
|
|
* windowing system, like GTK+.
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2009-01-12 11:18:11 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
clutter_stage_ensure_viewport (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
|
|
|
|
|
2010-09-07 12:10:55 +00:00
|
|
|
|
_clutter_stage_dirty_viewport (stage);
|
2009-01-12 11:18:11 +00:00
|
|
|
|
|
2009-02-17 17:22:02 +00:00
|
|
|
|
clutter_actor_queue_redraw (CLUTTER_ACTOR (stage));
|
2009-01-12 11:18:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-06 16:40:57 +00:00
|
|
|
|
/* This calculates a distance into the view frustum to position the
|
|
|
|
|
* stage so there is a decent amount of space to position geometry
|
|
|
|
|
* between the stage and the near clipping plane.
|
|
|
|
|
*
|
|
|
|
|
* Some awkward issues with this problem are:
|
|
|
|
|
* - It's not possible to have a gap as large as the stage size with
|
|
|
|
|
* a fov > 53° which is basically always the case since the default
|
|
|
|
|
* fov is 60°.
|
|
|
|
|
* - This can be deduced if you consider that this requires a
|
|
|
|
|
* triangle as wide as it is deep to fit in the frustum in front
|
|
|
|
|
* of the z_near plane. That triangle will always have an angle
|
|
|
|
|
* of 53.13° at the point sitting on the z_near plane, but if the
|
|
|
|
|
* frustum has a wider fov angle the left/right clipping planes
|
|
|
|
|
* can never converge with the two corners of our triangle no
|
|
|
|
|
* matter what size the triangle has.
|
|
|
|
|
* - With a fov > 53° there is a trade off between maximizing the gap
|
|
|
|
|
* size relative to the stage size but not loosing depth precision.
|
|
|
|
|
* - Perhaps ideally we wouldn't just consider the fov on the y-axis
|
|
|
|
|
* that is usually used to define a perspective, we would consider
|
|
|
|
|
* the fov of the axis with the largest stage size so the gap would
|
|
|
|
|
* accommodate that size best.
|
|
|
|
|
*
|
|
|
|
|
* After going around in circles a few times with how to handle these
|
|
|
|
|
* issues, we decided in the end to go for the simplest solution to
|
|
|
|
|
* start with instead of an elaborate function that handles arbitrary
|
|
|
|
|
* fov angles that we currently have no use-case for.
|
|
|
|
|
*
|
|
|
|
|
* The solution assumes a fovy of 60° and for that case gives a gap
|
|
|
|
|
* that's 85% of the stage height. We can consider more elaborate
|
|
|
|
|
* functions if necessary later.
|
|
|
|
|
*
|
|
|
|
|
* One guide we had to steer the gap size we support is the
|
|
|
|
|
* interactive test, test-texture-quality which expects to animate an
|
|
|
|
|
* actor to +400 on the z axis with a stage size of 640x480. A gap
|
|
|
|
|
* that's 85% of the stage height gives a gap of 408 in that case.
|
|
|
|
|
*/
|
|
|
|
|
static float
|
|
|
|
|
calculate_z_translation (float z_near)
|
|
|
|
|
{
|
|
|
|
|
/* This solution uses fairly basic trigonometry, but is seems worth
|
|
|
|
|
* clarifying the particular geometry we are looking at in-case
|
|
|
|
|
* anyone wants to develop this further later. Not sure how well an
|
|
|
|
|
* ascii diagram is going to work :-)
|
|
|
|
|
*
|
|
|
|
|
* |--- stage_height ---|
|
|
|
|
|
* | stage line |
|
|
|
|
|
* ╲━━━━━━━━━━━━━━━━━━━━━╱------------
|
|
|
|
|
* ╲. (2) │ .╱ | |
|
|
|
|
|
* C ╲ . │ . ╱ gap| |
|
|
|
|
|
* =0.5°╲ . a │ . ╱ | |
|
|
|
|
|
* b╲(1). D│ . ╱ | |
|
|
|
|
|
* ╲ B.│. ╱near plane | |
|
|
|
|
|
* A= ╲━━━━━━━━━╱------------- |
|
|
|
|
|
* 120° ╲ c │ ╱ | z_2d
|
|
|
|
|
* ╲ │ ╱ z_near |
|
|
|
|
|
* left ╲ │ ╱ | |
|
|
|
|
|
* clip 60°fovy | |
|
|
|
|
|
* plane ╳----------------------
|
|
|
|
|
* |
|
|
|
|
|
* |
|
|
|
|
|
* origin line
|
|
|
|
|
*
|
|
|
|
|
* The area of interest is the triangle labeled (1) at the top left
|
|
|
|
|
* marked with the ... line (a) from where the origin line crosses
|
|
|
|
|
* the near plane to the top left where the stage line cross the
|
|
|
|
|
* left clip plane.
|
|
|
|
|
*
|
|
|
|
|
* The sides of the triangle are a, b and c and the corresponding
|
|
|
|
|
* angles opposite those sides are A, B and C.
|
|
|
|
|
*
|
|
|
|
|
* The angle of C is what trades off the gap size we have relative
|
|
|
|
|
* to the stage size vs the depth precision we have.
|
|
|
|
|
*
|
|
|
|
|
* As mentioned above we arove at the angle for C is by working
|
|
|
|
|
* backwards from how much space we want for test-texture-quality.
|
|
|
|
|
* With a stage_height of 480 we want a gap > 400, ideally we also
|
|
|
|
|
* wanted a somewhat round number as a percentage of the height for
|
|
|
|
|
* documentation purposes. ~87% or a gap of ~416 is the limit
|
|
|
|
|
* because that's where we approach a C angle of 0° and effectively
|
|
|
|
|
* loose all depth precision.
|
|
|
|
|
*
|
|
|
|
|
* So for our test app with a stage_height of 480 if we aim for a
|
|
|
|
|
* gap of 408 (85% of 480) we can get the angle D as
|
|
|
|
|
* atan (stage_height/2/408) = 30.5°.
|
|
|
|
|
*
|
|
|
|
|
* That gives us the angle for B as 90° - 30.5° = 59.5°
|
|
|
|
|
*
|
|
|
|
|
* We can already determine that A has an angle of (fovy/2 + 90°) =
|
|
|
|
|
* 120°
|
|
|
|
|
*
|
|
|
|
|
* Therefore C = 180 - A - B = 0.5°
|
|
|
|
|
*
|
|
|
|
|
* The length of c = z_near * tan (30°)
|
|
|
|
|
*
|
|
|
|
|
* Now we can use the rule a/SinA = c/SinC to calculate the
|
|
|
|
|
* length of a. After some rearranging that gives us:
|
|
|
|
|
*
|
|
|
|
|
* a c
|
|
|
|
|
* ---------- = ----------
|
|
|
|
|
* sin (120°) sin (0.5°)
|
|
|
|
|
*
|
|
|
|
|
* c * sin (120°)
|
|
|
|
|
* a = --------------
|
|
|
|
|
* sin (0.5°)
|
|
|
|
|
*
|
|
|
|
|
* And with that we can determine z_2d = cos (D) * a =
|
|
|
|
|
* cos (30.5°) * a + z_near:
|
|
|
|
|
*
|
|
|
|
|
* c * sin (120°) * cos (30.5°)
|
|
|
|
|
* z_2d = --------------------------- + z_near
|
|
|
|
|
* sin (0.5°)
|
|
|
|
|
*/
|
|
|
|
|
#define _DEG_TO_RAD (G_PI / 180.0)
|
|
|
|
|
return z_near * tanf (30.0f * _DEG_TO_RAD) *
|
|
|
|
|
sinf (120.0f * _DEG_TO_RAD) * cosf (30.5f * _DEG_TO_RAD) /
|
|
|
|
|
sinf (0.5f * _DEG_TO_RAD) +
|
|
|
|
|
z_near;
|
|
|
|
|
#undef _DEG_TO_RAD
|
|
|
|
|
/* We expect the compiler should boil this down to z_near * CONSTANT */
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-07 12:10:55 +00:00
|
|
|
|
void
|
|
|
|
|
_clutter_stage_maybe_setup_viewport (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv = stage->priv;
|
|
|
|
|
|
|
|
|
|
if (priv->dirty_viewport)
|
|
|
|
|
{
|
2011-02-08 14:46:31 +00:00
|
|
|
|
ClutterPerspective perspective;
|
2011-06-06 16:40:57 +00:00
|
|
|
|
float z_2d;
|
2011-02-08 14:46:31 +00:00
|
|
|
|
|
2010-09-07 12:10:55 +00:00
|
|
|
|
CLUTTER_NOTE (PAINT,
|
2011-02-01 16:51:58 +00:00
|
|
|
|
"Setting up the viewport { w:%f, h:%f }",
|
2010-09-07 12:10:55 +00:00
|
|
|
|
priv->viewport[2], priv->viewport[3]);
|
|
|
|
|
|
|
|
|
|
cogl_set_viewport (priv->viewport[0],
|
|
|
|
|
priv->viewport[1],
|
|
|
|
|
priv->viewport[2],
|
|
|
|
|
priv->viewport[3]);
|
|
|
|
|
|
2011-02-08 14:46:31 +00:00
|
|
|
|
perspective = priv->perspective;
|
2011-04-04 17:42:52 +00:00
|
|
|
|
|
|
|
|
|
/* Ideally we want to regenerate the perspective matrix whenever
|
2011-06-06 16:40:57 +00:00
|
|
|
|
* the size changes but if the user has provided a custom matrix
|
|
|
|
|
* then we don't want to override it */
|
2011-04-04 17:42:52 +00:00
|
|
|
|
if (!priv->has_custom_perspective)
|
|
|
|
|
{
|
|
|
|
|
perspective.aspect = priv->viewport[2] / priv->viewport[3];
|
2011-06-06 16:40:57 +00:00
|
|
|
|
z_2d = calculate_z_translation (perspective.z_near);
|
|
|
|
|
|
|
|
|
|
#define _DEG_TO_RAD (G_PI / 180.0)
|
|
|
|
|
/* NB: z_2d is only enough room for 85% of the stage_height between
|
|
|
|
|
* the stage and the z_near plane. For behind the stage plane we
|
|
|
|
|
* want a more consistent gap of 10 times the stage_height before
|
|
|
|
|
* hitting the far plane so we calculate that relative to the final
|
|
|
|
|
* height of the stage plane at the z_2d_distance we got... */
|
|
|
|
|
perspective.z_far = z_2d +
|
|
|
|
|
tanf ((perspective.fovy / 2.0f) * _DEG_TO_RAD) * z_2d * 20.0f;
|
|
|
|
|
#undef _DEG_TO_RAD
|
|
|
|
|
|
2011-04-04 17:42:52 +00:00
|
|
|
|
clutter_stage_set_perspective_internal (stage, &perspective);
|
|
|
|
|
}
|
2011-06-06 16:40:57 +00:00
|
|
|
|
else
|
|
|
|
|
z_2d = calculate_z_translation (perspective.z_near);
|
2011-02-08 14:46:31 +00:00
|
|
|
|
|
|
|
|
|
cogl_matrix_init_identity (&priv->view);
|
|
|
|
|
cogl_matrix_view_2d_in_perspective (&priv->view,
|
|
|
|
|
perspective.fovy,
|
|
|
|
|
perspective.aspect,
|
|
|
|
|
perspective.z_near,
|
2011-06-06 16:40:57 +00:00
|
|
|
|
z_2d,
|
2011-02-08 14:46:31 +00:00
|
|
|
|
priv->viewport[2],
|
|
|
|
|
priv->viewport[3]);
|
2010-12-13 17:21:58 +00:00
|
|
|
|
|
|
|
|
|
priv->dirty_viewport = FALSE;
|
2010-09-07 12:10:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (priv->dirty_projection)
|
2010-12-13 17:21:58 +00:00
|
|
|
|
{
|
|
|
|
|
cogl_set_projection_matrix (&priv->projection);
|
|
|
|
|
|
|
|
|
|
priv->dirty_projection = FALSE;
|
|
|
|
|
}
|
2010-09-07 12:10:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-06-09 15:29:29 +00:00
|
|
|
|
/**
|
|
|
|
|
* clutter_stage_ensure_redraw:
|
|
|
|
|
* @stage: a #ClutterStage
|
|
|
|
|
*
|
|
|
|
|
* Ensures that @stage is redrawn
|
|
|
|
|
*
|
|
|
|
|
* This function should not be called by applications: it is
|
|
|
|
|
* used when embedding a #ClutterStage into a toolkit with
|
|
|
|
|
* another windowing system, like GTK+.
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2009-06-09 15:29:29 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
clutter_stage_ensure_redraw (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
ClutterMasterClock *master_clock;
|
|
|
|
|
ClutterStagePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
|
|
|
|
|
|
|
|
|
priv = stage->priv;
|
2012-11-08 17:42:24 +00:00
|
|
|
|
|
|
|
|
|
if (!priv->relayout_pending && !priv->redraw_pending)
|
|
|
|
|
_clutter_stage_schedule_update (stage);
|
|
|
|
|
|
2010-09-07 19:08:00 +00:00
|
|
|
|
priv->relayout_pending = TRUE;
|
2009-06-09 15:29:29 +00:00
|
|
|
|
priv->redraw_pending = TRUE;
|
|
|
|
|
|
|
|
|
|
master_clock = _clutter_master_clock_get_default ();
|
|
|
|
|
_clutter_master_clock_start_running (master_clock);
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-04 15:02:11 +00:00
|
|
|
|
void
|
|
|
|
|
_clutter_stage_set_window (ClutterStage *stage,
|
|
|
|
|
ClutterStageWindow *stage_window)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE_WINDOW (stage_window));
|
|
|
|
|
|
Try to mop up the default stage mess
The default stage was a neat concept when we started Clutter out,
somewhere in the Jurassic era; a singleton instance that gets created at
initialization time, and remains the same for the entire duration of the
process.
Worked well enough when Clutter was a small library meant to be used to
write fullscreen media browsers, but since the introduction of multiple
stages, and Clutter being used to create all sorts of applications, the
default stage is just a vestigial remainder of that past, like an
appendix; something that complicates the layout of the code and
introduces weird behaviour, so that you notice its existence only when
something goes wrong.
Some platforms we do support, though, only have one framebuffer, so it
makes sense for them to have only one stage.
At this point, the only sane thing to do is to go through the same code
paths on all platforms, and that code path is the stage instance
creation and initialization — i.e. clutter_stage_new() (or
g_object_new() with CLUTTER_TYPE_STAGE).
For platforms that support multiple stages, nothing has changed: the stage
created by clutter_stage_get_default() will be set as the default one;
if nobody calls it, the default stage is never created, and it just
lives on as a meaningless check.
For platforms that only support one stage, clutter_stage_new() and
clutter_stage_get_default() will behave exactly the same the first time
they are called: both will create a stage, and set it as the default.
Calling clutter_stage_new() a second time is treated as a programmer
error, and will result in Clutter aborting. This is a behavioural change
because the existing behaviour or creating a new ClutterStage instance
with the same ClutterStageWindow private implementation is, simply put,
utterly braindamaged and I should have *never* had written it, and I
apologize for it. In my defence, I didn't know any better at the time.
This is the first step towards the complete deprecation of
clutter_stage_get_default() and clutter_stage_is_default(), which will
come later.
2011-11-09 14:04:05 +00:00
|
|
|
|
if (stage->priv->impl != NULL)
|
2008-04-04 15:02:11 +00:00
|
|
|
|
g_object_unref (stage->priv->impl);
|
|
|
|
|
|
2009-08-13 11:34:07 +00:00
|
|
|
|
stage->priv->impl = stage_window;
|
2008-04-04 15:02:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ClutterStageWindow *
|
|
|
|
|
_clutter_stage_get_window (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), NULL);
|
|
|
|
|
|
|
|
|
|
return CLUTTER_STAGE_WINDOW (stage->priv->impl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ClutterStageWindow *
|
|
|
|
|
_clutter_stage_get_default_window (void)
|
|
|
|
|
{
|
2011-11-14 11:46:02 +00:00
|
|
|
|
ClutterStageManager *manager = clutter_stage_manager_get_default ();
|
|
|
|
|
ClutterStage *stage;
|
|
|
|
|
|
|
|
|
|
stage = clutter_stage_manager_get_default_stage (manager);
|
|
|
|
|
if (stage == NULL)
|
|
|
|
|
return NULL;
|
2008-04-04 15:02:11 +00:00
|
|
|
|
|
2011-11-14 11:46:02 +00:00
|
|
|
|
return _clutter_stage_get_window (stage);
|
2008-04-04 15:02:11 +00:00
|
|
|
|
}
|
2009-07-14 12:47:35 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* clutter_stage_set_throttle_motion_events:
|
|
|
|
|
* @stage: a #ClutterStage
|
|
|
|
|
* @throttle: %TRUE to throttle motion events
|
|
|
|
|
*
|
|
|
|
|
* Sets whether motion events received between redraws should
|
|
|
|
|
* be throttled or not. If motion events are throttled, those
|
|
|
|
|
* events received by the windowing system between redraws will
|
|
|
|
|
* be compressed so that only the last event will be propagated
|
|
|
|
|
* to the @stage and its actors.
|
|
|
|
|
*
|
|
|
|
|
* This function should only be used if you want to have all
|
|
|
|
|
* the motion events delivered to your application code.
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2009-07-14 12:47:35 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
clutter_stage_set_throttle_motion_events (ClutterStage *stage,
|
|
|
|
|
gboolean throttle)
|
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
|
|
|
|
|
|
|
|
|
priv = stage->priv;
|
|
|
|
|
|
|
|
|
|
if (priv->throttle_motion_events != throttle)
|
|
|
|
|
priv->throttle_motion_events = throttle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* clutter_stage_get_throttle_motion_events:
|
|
|
|
|
* @stage: a #ClutterStage
|
|
|
|
|
*
|
|
|
|
|
* Retrieves the value set with clutter_stage_set_throttle_motion_events()
|
|
|
|
|
*
|
|
|
|
|
* Return value: %TRUE if the motion events are being throttled,
|
|
|
|
|
* and %FALSE otherwise
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2009-07-14 12:47:35 +00:00
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
clutter_stage_get_throttle_motion_events (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE);
|
|
|
|
|
|
|
|
|
|
return stage->priv->throttle_motion_events;
|
|
|
|
|
}
|
2009-12-09 02:04:56 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* clutter_stage_set_use_alpha:
|
|
|
|
|
* @stage: a #ClutterStage
|
|
|
|
|
* @use_alpha: whether the stage should honour the opacity or the
|
|
|
|
|
* alpha channel of the stage color
|
|
|
|
|
*
|
|
|
|
|
* Sets whether the @stage should honour the #ClutterActor:opacity and
|
|
|
|
|
* the alpha channel of the #ClutterStage:color
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2009-12-09 02:04:56 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
clutter_stage_set_use_alpha (ClutterStage *stage,
|
|
|
|
|
gboolean use_alpha)
|
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
|
|
|
|
|
|
|
|
|
priv = stage->priv;
|
|
|
|
|
|
|
|
|
|
if (priv->use_alpha != use_alpha)
|
|
|
|
|
{
|
|
|
|
|
priv->use_alpha = use_alpha;
|
|
|
|
|
|
|
|
|
|
clutter_actor_queue_redraw (CLUTTER_ACTOR (stage));
|
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (stage), "use-alpha");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* clutter_stage_get_use_alpha:
|
|
|
|
|
* @stage: a #ClutterStage
|
|
|
|
|
*
|
|
|
|
|
* Retrieves the value set using clutter_stage_set_use_alpha()
|
|
|
|
|
*
|
|
|
|
|
* Return value: %TRUE if the stage should honour the opacity and the
|
|
|
|
|
* alpha channel of the stage color
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2009-12-09 02:04:56 +00:00
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
clutter_stage_get_use_alpha (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE);
|
|
|
|
|
|
|
|
|
|
return stage->priv->use_alpha;
|
|
|
|
|
}
|
2010-02-06 11:23:37 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* clutter_stage_set_minimum_size:
|
|
|
|
|
* @stage: a #ClutterStage
|
|
|
|
|
* @width: width, in pixels
|
|
|
|
|
* @height: height, in pixels
|
|
|
|
|
*
|
2010-02-27 18:56:34 +00:00
|
|
|
|
* Sets the minimum size for a stage window, if the default backend
|
|
|
|
|
* uses #ClutterStage inside a window
|
|
|
|
|
*
|
|
|
|
|
* This is a convenience function, and it is equivalent to setting the
|
|
|
|
|
* #ClutterActor:min-width and #ClutterActor:min-height on @stage
|
|
|
|
|
*
|
|
|
|
|
* If the current size of @stage is smaller than the minimum size, the
|
|
|
|
|
* @stage will be resized to the new @width and @height
|
|
|
|
|
*
|
|
|
|
|
* This function has no effect if @stage is fullscreen
|
2010-02-06 11:23:37 +00:00
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2010-02-06 11:23:37 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
clutter_stage_set_minimum_size (ClutterStage *stage,
|
|
|
|
|
guint width,
|
|
|
|
|
guint height)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
|
|
|
|
g_return_if_fail ((width > 0) && (height > 0));
|
|
|
|
|
|
2010-02-26 18:36:38 +00:00
|
|
|
|
g_object_set (G_OBJECT (stage),
|
2010-02-27 18:56:34 +00:00
|
|
|
|
"min-width", (gfloat) width,
|
|
|
|
|
"min-height", (gfloat )height,
|
2010-02-26 18:36:38 +00:00
|
|
|
|
NULL);
|
2010-02-06 11:23:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* clutter_stage_get_minimum_size:
|
|
|
|
|
* @stage: a #ClutterStage
|
2010-02-27 18:56:34 +00:00
|
|
|
|
* @width: (out): return location for the minimum width, in pixels,
|
|
|
|
|
* or %NULL
|
|
|
|
|
* @height: (out): return location for the minimum height, in pixels,
|
|
|
|
|
* or %NULL
|
2010-02-06 11:23:37 +00:00
|
|
|
|
*
|
2010-02-27 18:56:34 +00:00
|
|
|
|
* Retrieves the minimum size for a stage window as set using
|
|
|
|
|
* clutter_stage_set_minimum_size().
|
2010-02-06 11:23:37 +00:00
|
|
|
|
*
|
2010-02-27 18:56:34 +00:00
|
|
|
|
* The returned size may not correspond to the actual minimum size and
|
|
|
|
|
* it is specific to the #ClutterStage implementation inside the
|
|
|
|
|
* Clutter backend
|
2010-02-06 11:23:37 +00:00
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2010-02-06 11:23:37 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
clutter_stage_get_minimum_size (ClutterStage *stage,
|
2010-02-26 18:36:38 +00:00
|
|
|
|
guint *width_p,
|
|
|
|
|
guint *height_p)
|
2010-02-06 11:23:37 +00:00
|
|
|
|
{
|
2010-02-26 18:36:38 +00:00
|
|
|
|
gfloat width, height;
|
|
|
|
|
gboolean width_set, height_set;
|
|
|
|
|
|
2010-02-06 11:23:37 +00:00
|
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
|
|
|
|
|
2010-02-26 18:36:38 +00:00
|
|
|
|
g_object_get (G_OBJECT (stage),
|
|
|
|
|
"min-width", &width,
|
|
|
|
|
"min-width-set", &width_set,
|
|
|
|
|
"min-height", &height,
|
|
|
|
|
"min-height-set", &height_set,
|
|
|
|
|
NULL);
|
|
|
|
|
|
2010-02-27 18:56:34 +00:00
|
|
|
|
/* if not width or height have been set, then the Stage
|
|
|
|
|
* minimum size is defined to be 1x1
|
|
|
|
|
*/
|
2010-02-26 18:36:38 +00:00
|
|
|
|
if (!width_set)
|
|
|
|
|
width = 1;
|
2010-02-27 18:56:34 +00:00
|
|
|
|
|
2010-02-26 18:36:38 +00:00
|
|
|
|
if (!height_set)
|
|
|
|
|
height = 1;
|
|
|
|
|
|
|
|
|
|
if (width_p)
|
2010-02-27 18:56:34 +00:00
|
|
|
|
*width_p = (guint) width;
|
|
|
|
|
|
2010-02-26 18:36:38 +00:00
|
|
|
|
if (height_p)
|
2010-02-27 18:56:34 +00:00
|
|
|
|
*height_p = (guint) height;
|
2010-02-06 11:23:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-11-08 17:42:24 +00:00
|
|
|
|
void
|
|
|
|
|
_clutter_stage_schedule_update (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
ClutterStageWindow *stage_window;
|
|
|
|
|
|
|
|
|
|
if (CLUTTER_ACTOR_IN_DESTRUCTION (stage))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
stage_window = _clutter_stage_get_window (stage);
|
|
|
|
|
if (stage_window == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
return _clutter_stage_window_schedule_update (stage_window,
|
|
|
|
|
stage->priv->sync_delay);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Returns the earliest time the stage is ready to update */
|
|
|
|
|
gint64
|
|
|
|
|
_clutter_stage_get_update_time (ClutterStage *stage)
|
2009-11-12 20:37:01 +00:00
|
|
|
|
{
|
2010-02-15 12:04:50 +00:00
|
|
|
|
ClutterStageWindow *stage_window;
|
|
|
|
|
|
2010-07-21 15:10:46 +00:00
|
|
|
|
if (CLUTTER_ACTOR_IN_DESTRUCTION (stage))
|
2010-02-15 12:04:50 +00:00
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
stage_window = _clutter_stage_get_window (stage);
|
|
|
|
|
if (stage_window == NULL)
|
|
|
|
|
return 0;
|
|
|
|
|
|
2012-11-08 17:42:24 +00:00
|
|
|
|
return _clutter_stage_window_get_update_time (stage_window);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_clutter_stage_clear_update_time (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
ClutterStageWindow *stage_window;
|
|
|
|
|
|
|
|
|
|
stage_window = _clutter_stage_get_window (stage);
|
|
|
|
|
if (stage_window)
|
|
|
|
|
_clutter_stage_window_clear_update_time (stage_window);
|
2009-11-12 20:37:01 +00:00
|
|
|
|
}
|
2010-04-16 14:34:36 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* clutter_stage_set_no_clear_hint:
|
|
|
|
|
* @stage: a #ClutterStage
|
|
|
|
|
* @no_clear: %TRUE if the @stage should not clear itself on every
|
|
|
|
|
* repaint cycle
|
|
|
|
|
*
|
|
|
|
|
* Sets whether the @stage should clear itself at the beginning
|
|
|
|
|
* of each paint cycle or not.
|
|
|
|
|
*
|
|
|
|
|
* Clearing the #ClutterStage can be a costly operation, especially
|
|
|
|
|
* if the stage is always covered - for instance, in a full-screen
|
|
|
|
|
* video player or in a game with a background texture.
|
|
|
|
|
*
|
|
|
|
|
* <note><para>This setting is a hint; Clutter might discard this
|
|
|
|
|
* hint depending on its internal state.</para></note>
|
|
|
|
|
*
|
|
|
|
|
* <warning><para>If parts of the stage are visible and you disable
|
|
|
|
|
* clearing you might end up with visual artifacts while painting the
|
|
|
|
|
* contents of the stage.</para></warning>
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2010-04-16 14:34:36 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
clutter_stage_set_no_clear_hint (ClutterStage *stage,
|
|
|
|
|
gboolean no_clear)
|
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv;
|
|
|
|
|
ClutterStageHint new_hints;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
|
|
|
|
|
|
|
|
|
priv = stage->priv;
|
|
|
|
|
new_hints = priv->stage_hints;
|
|
|
|
|
|
|
|
|
|
if (no_clear)
|
|
|
|
|
new_hints |= CLUTTER_STAGE_NO_CLEAR_ON_PAINT;
|
|
|
|
|
else
|
|
|
|
|
new_hints &= ~CLUTTER_STAGE_NO_CLEAR_ON_PAINT;
|
|
|
|
|
|
|
|
|
|
if (priv->stage_hints == new_hints)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
priv->stage_hints = new_hints;
|
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (stage), "no-clear-hint");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* clutter_stage_get_no_clear_hint:
|
|
|
|
|
* @stage: a #ClutterStage
|
|
|
|
|
*
|
|
|
|
|
* Retrieves the hint set with clutter_stage_set_no_clear_hint()
|
|
|
|
|
*
|
|
|
|
|
* Return value: %TRUE if the stage should not clear itself on every paint
|
|
|
|
|
* cycle, and %FALSE otherwise
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2010-04-16 14:34:36 +00:00
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
clutter_stage_get_no_clear_hint (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE);
|
|
|
|
|
|
|
|
|
|
return (stage->priv->stage_hints & CLUTTER_STAGE_NO_CLEAR_ON_PAINT) != 0;
|
|
|
|
|
}
|
2010-09-10 23:29:05 +00:00
|
|
|
|
|
2010-09-07 17:04:19 +00:00
|
|
|
|
ClutterPaintVolume *
|
|
|
|
|
_clutter_stage_paint_volume_stack_allocate (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
GArray *paint_volume_stack = stage->priv->paint_volume_stack;
|
|
|
|
|
|
|
|
|
|
g_array_set_size (paint_volume_stack,
|
|
|
|
|
paint_volume_stack->len+1);
|
|
|
|
|
|
|
|
|
|
return &g_array_index (paint_volume_stack,
|
|
|
|
|
ClutterPaintVolume,
|
|
|
|
|
paint_volume_stack->len - 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_clutter_stage_paint_volume_stack_free_all (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
GArray *paint_volume_stack = stage->priv->paint_volume_stack;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < paint_volume_stack->len; i++)
|
|
|
|
|
{
|
|
|
|
|
ClutterPaintVolume *pv =
|
|
|
|
|
&g_array_index (paint_volume_stack, ClutterPaintVolume, i);
|
|
|
|
|
clutter_paint_volume_free (pv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_array_set_size (paint_volume_stack, 0);
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-07 21:21:28 +00:00
|
|
|
|
/* The is an out-of-band paramater available while painting that
|
|
|
|
|
* can be used to cull actors. */
|
2011-02-01 18:32:08 +00:00
|
|
|
|
const ClutterPlane *
|
2010-09-07 21:21:28 +00:00
|
|
|
|
_clutter_stage_get_clip (ClutterStage *stage)
|
|
|
|
|
{
|
2011-02-01 18:32:08 +00:00
|
|
|
|
return stage->priv->current_clip_planes;
|
2010-09-07 21:21:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-09-10 00:33:02 +00:00
|
|
|
|
/* When an actor queues a redraw we add it to a list on the stage that
|
|
|
|
|
* gets processed once all updates to the stage have been finished.
|
|
|
|
|
*
|
|
|
|
|
* This deferred approach to processing queue_redraw requests means
|
|
|
|
|
* that we can avoid redundant transformations of clip volumes if
|
|
|
|
|
* something later triggers a full stage redraw anyway. It also means
|
|
|
|
|
* we can be more sure that all the referenced actors will have valid
|
|
|
|
|
* allocations improving the chance that we can determine the actors
|
|
|
|
|
* paint volume so we can clip the redraw request even if the user
|
|
|
|
|
* didn't explicitly do so.
|
|
|
|
|
*/
|
|
|
|
|
ClutterStageQueueRedrawEntry *
|
|
|
|
|
_clutter_stage_queue_actor_redraw (ClutterStage *stage,
|
|
|
|
|
ClutterStageQueueRedrawEntry *entry,
|
|
|
|
|
ClutterActor *actor,
|
|
|
|
|
ClutterPaintVolume *clip)
|
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv = stage->priv;
|
|
|
|
|
|
2011-02-01 18:32:08 +00:00
|
|
|
|
CLUTTER_NOTE (CLIPPING, "stage_queue_actor_redraw (actor=%s, clip=%p): ",
|
2011-04-14 16:58:15 +00:00
|
|
|
|
_clutter_actor_get_debug_name (actor), clip);
|
2011-02-01 18:32:08 +00:00
|
|
|
|
|
2010-09-10 00:33:02 +00:00
|
|
|
|
if (!priv->redraw_pending)
|
|
|
|
|
{
|
|
|
|
|
ClutterMasterClock *master_clock;
|
|
|
|
|
|
2011-02-18 14:38:54 +00:00
|
|
|
|
CLUTTER_NOTE (PAINT, "First redraw request");
|
|
|
|
|
|
2012-11-08 17:42:24 +00:00
|
|
|
|
_clutter_stage_schedule_update (stage);
|
2010-09-10 00:33:02 +00:00
|
|
|
|
priv->redraw_pending = TRUE;
|
|
|
|
|
|
|
|
|
|
master_clock = _clutter_master_clock_get_default ();
|
|
|
|
|
_clutter_master_clock_start_running (master_clock);
|
|
|
|
|
}
|
2011-02-18 14:38:54 +00:00
|
|
|
|
#ifdef CLUTTER_ENABLE_DEBUG
|
2010-09-10 00:33:02 +00:00
|
|
|
|
else
|
2011-02-18 14:38:54 +00:00
|
|
|
|
{
|
|
|
|
|
CLUTTER_NOTE (PAINT, "Redraw request number %lu",
|
|
|
|
|
priv->redraw_count + 1);
|
|
|
|
|
|
|
|
|
|
priv->redraw_count += 1;
|
|
|
|
|
}
|
|
|
|
|
#endif /* CLUTTER_ENABLE_DEBUG */
|
2010-09-10 00:33:02 +00:00
|
|
|
|
|
2011-03-15 13:17:04 +00:00
|
|
|
|
/* We have an optimization in _clutter_stage_do_pick to detect when
|
|
|
|
|
* the scene is static so we can cache a full, un-clipped pick
|
|
|
|
|
* buffer to avoid continuous pick renders.
|
2010-09-10 00:33:02 +00:00
|
|
|
|
*
|
|
|
|
|
* Currently the assumption is that actors queue a redraw when some
|
|
|
|
|
* state changes that affects painting *or* picking so we can use
|
|
|
|
|
* this point to invalidate any currently cached pick buffer.
|
|
|
|
|
*/
|
2010-10-27 17:02:47 +00:00
|
|
|
|
_clutter_stage_set_pick_buffer_valid (stage, FALSE, -1);
|
2010-09-10 00:33:02 +00:00
|
|
|
|
|
|
|
|
|
if (entry)
|
|
|
|
|
{
|
|
|
|
|
/* Ignore all requests to queue a redraw for an actor if a full
|
|
|
|
|
* (non-clipped) redraw of the actor has already been queued. */
|
|
|
|
|
if (!entry->has_clip)
|
2011-02-01 18:32:08 +00:00
|
|
|
|
{
|
|
|
|
|
CLUTTER_NOTE (CLIPPING, "Bail from stage_queue_actor_redraw (%s): "
|
|
|
|
|
"Unclipped redraw of actor already queued",
|
2011-04-14 16:58:15 +00:00
|
|
|
|
_clutter_actor_get_debug_name (actor));
|
2011-02-01 18:32:08 +00:00
|
|
|
|
return entry;
|
|
|
|
|
}
|
2010-09-10 00:33:02 +00:00
|
|
|
|
|
|
|
|
|
/* If queuing a clipped redraw and a clipped redraw has
|
|
|
|
|
* previously been queued for this actor then combine the latest
|
|
|
|
|
* clip together with the existing clip */
|
|
|
|
|
if (clip)
|
|
|
|
|
clutter_paint_volume_union (&entry->clip, clip);
|
2010-09-30 17:42:40 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
clutter_paint_volume_free (&entry->clip);
|
|
|
|
|
entry->has_clip = FALSE;
|
|
|
|
|
}
|
2010-09-10 00:33:02 +00:00
|
|
|
|
return entry;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
entry = g_slice_new (ClutterStageQueueRedrawEntry);
|
|
|
|
|
entry->actor = g_object_ref (actor);
|
|
|
|
|
|
|
|
|
|
if (clip)
|
|
|
|
|
{
|
|
|
|
|
entry->has_clip = TRUE;
|
2011-02-01 18:32:08 +00:00
|
|
|
|
_clutter_paint_volume_init_static (&entry->clip, actor);
|
2010-09-10 00:33:02 +00:00
|
|
|
|
_clutter_paint_volume_set_from_volume (&entry->clip, clip);
|
|
|
|
|
}
|
2010-09-29 22:43:30 +00:00
|
|
|
|
else
|
|
|
|
|
entry->has_clip = FALSE;
|
2010-09-10 00:33:02 +00:00
|
|
|
|
|
|
|
|
|
stage->priv->pending_queue_redraws =
|
|
|
|
|
g_list_prepend (stage->priv->pending_queue_redraws, entry);
|
|
|
|
|
|
|
|
|
|
return entry;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
free_queue_redraw_entry (ClutterStageQueueRedrawEntry *entry)
|
|
|
|
|
{
|
2010-10-30 22:11:03 +00:00
|
|
|
|
if (entry->actor)
|
|
|
|
|
g_object_unref (entry->actor);
|
2010-09-10 00:33:02 +00:00
|
|
|
|
if (entry->has_clip)
|
|
|
|
|
clutter_paint_volume_free (&entry->clip);
|
|
|
|
|
g_slice_free (ClutterStageQueueRedrawEntry, entry);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2010-10-15 15:05:44 +00:00
|
|
|
|
_clutter_stage_queue_redraw_entry_invalidate (ClutterStageQueueRedrawEntry *entry)
|
2010-09-10 00:33:02 +00:00
|
|
|
|
{
|
2010-10-15 15:05:44 +00:00
|
|
|
|
if (entry == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (entry->actor != NULL)
|
|
|
|
|
{
|
|
|
|
|
g_object_unref (entry->actor);
|
|
|
|
|
entry->actor = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-10 00:33:02 +00:00
|
|
|
|
if (entry->has_clip)
|
2010-09-29 22:43:30 +00:00
|
|
|
|
{
|
|
|
|
|
clutter_paint_volume_free (&entry->clip);
|
|
|
|
|
entry->has_clip = FALSE;
|
|
|
|
|
}
|
2010-09-10 00:33:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
_clutter_stage_maybe_finish_queue_redraws (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
/* Note: we have to repeat until the pending_queue_redraws list is
|
|
|
|
|
* empty because actors are allowed to queue redraws in response to
|
|
|
|
|
* the queue-redraw signal. For example Clone actors or
|
|
|
|
|
* texture_new_from_actor actors will have to queue a redraw if
|
|
|
|
|
* their source queues a redraw.
|
|
|
|
|
*/
|
|
|
|
|
while (stage->priv->pending_queue_redraws)
|
|
|
|
|
{
|
|
|
|
|
GList *l;
|
|
|
|
|
/* XXX: we need to allow stage->priv->pending_queue_redraws to
|
|
|
|
|
* be updated while we process the current entries in the list
|
|
|
|
|
* so we steal the list pointer and then reset it to an empty
|
|
|
|
|
* list before processing... */
|
|
|
|
|
GList *stolen_list = stage->priv->pending_queue_redraws;
|
|
|
|
|
stage->priv->pending_queue_redraws = NULL;
|
|
|
|
|
|
|
|
|
|
for (l = stolen_list; l; l = l->next)
|
|
|
|
|
{
|
|
|
|
|
ClutterStageQueueRedrawEntry *entry = l->data;
|
2010-10-25 12:08:52 +00:00
|
|
|
|
ClutterPaintVolume *clip;
|
2010-09-10 00:33:02 +00:00
|
|
|
|
|
|
|
|
|
/* NB: Entries may be invalidated if the actor gets destroyed */
|
2010-10-30 22:11:03 +00:00
|
|
|
|
if (G_LIKELY (entry->actor != NULL))
|
|
|
|
|
{
|
|
|
|
|
clip = entry->has_clip ? &entry->clip : NULL;
|
2010-09-10 00:33:02 +00:00
|
|
|
|
|
2010-10-30 22:11:03 +00:00
|
|
|
|
_clutter_actor_finish_queue_redraw (entry->actor, clip);
|
|
|
|
|
}
|
2010-09-10 00:33:02 +00:00
|
|
|
|
|
|
|
|
|
free_queue_redraw_entry (entry);
|
|
|
|
|
}
|
|
|
|
|
g_list_free (stolen_list);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-28 17:37:18 +00:00
|
|
|
|
/**
|
2011-01-18 14:46:02 +00:00
|
|
|
|
* clutter_stage_set_accept_focus:
|
2010-12-28 17:37:18 +00:00
|
|
|
|
* @stage: a #ClutterStage
|
|
|
|
|
* @accept_focus: %TRUE to accept focus on show
|
|
|
|
|
*
|
|
|
|
|
* Sets whether the @stage should accept the key focus when shown.
|
|
|
|
|
*
|
|
|
|
|
* This function should be called before showing @stage using
|
|
|
|
|
* clutter_actor_show().
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2010-12-28 17:37:18 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
clutter_stage_set_accept_focus (ClutterStage *stage,
|
|
|
|
|
gboolean accept_focus)
|
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
|
|
|
|
|
|
|
|
|
accept_focus = !!accept_focus;
|
|
|
|
|
|
|
|
|
|
priv = stage->priv;
|
|
|
|
|
|
|
|
|
|
if (priv->accept_focus != accept_focus)
|
|
|
|
|
{
|
|
|
|
|
_clutter_stage_window_set_accept_focus (priv->impl, accept_focus);
|
|
|
|
|
g_object_notify (G_OBJECT (stage), "accept-focus");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* clutter_stage_get_accept_focus:
|
|
|
|
|
* @stage: a #ClutterStage
|
|
|
|
|
*
|
|
|
|
|
* Retrieves the value set with clutter_stage_set_accept_focus().
|
|
|
|
|
*
|
|
|
|
|
* Return value: %TRUE if the #ClutterStage should accept focus, and %FALSE
|
|
|
|
|
* otherwise
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2010-12-28 17:37:18 +00:00
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
clutter_stage_get_accept_focus (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), TRUE);
|
|
|
|
|
|
|
|
|
|
return stage->priv->accept_focus;
|
|
|
|
|
}
|
2011-01-27 17:26:16 +00:00
|
|
|
|
|
2011-06-20 10:41:28 +00:00
|
|
|
|
/**
|
|
|
|
|
* clutter_stage_set_motion_events_enabled:
|
|
|
|
|
* @stage: a #ClutterStage
|
|
|
|
|
* @enabled: %TRUE to enable the motion events delivery, and %FALSE
|
|
|
|
|
* otherwise
|
|
|
|
|
*
|
|
|
|
|
* Sets whether per-actor motion events (and relative crossing
|
|
|
|
|
* events) should be disabled or not.
|
|
|
|
|
*
|
|
|
|
|
* The default is %TRUE.
|
|
|
|
|
*
|
|
|
|
|
* If @enable is %FALSE the following events will not be delivered
|
|
|
|
|
* to the actors children of @stage.
|
|
|
|
|
*
|
|
|
|
|
* <itemizedlist>
|
|
|
|
|
* <listitem><para>#ClutterActor::motion-event</para></listitem>
|
|
|
|
|
* <listitem><para>#ClutterActor::enter-event</para></listitem>
|
|
|
|
|
* <listitem><para>#ClutterActor::leave-event</para></listitem>
|
|
|
|
|
* </itemizedlist>
|
|
|
|
|
*
|
|
|
|
|
* The events will still be delivered to the #ClutterStage.
|
|
|
|
|
*
|
|
|
|
|
* The main side effect of this function is that disabling the motion
|
|
|
|
|
* events will disable picking to detect the #ClutterActor underneath
|
|
|
|
|
* the pointer for each motion event. This is useful, for instance,
|
|
|
|
|
* when dragging a #ClutterActor across the @stage: the actor underneath
|
|
|
|
|
* the pointer is not going to change, so it's meaningless to perform
|
|
|
|
|
* a pick.
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2011-06-20 10:41:28 +00:00
|
|
|
|
*/
|
Store the motion event deliver flag in ClutterStage
Once upon a time, the land of Clutter had a stage singleton. It was
created automatically at initialization time and stayed around even
after the main loop was terminated. The singleton was content in
being all there was. There also was a global API to handle the
configuration of the stage singleton that would affect the behaviour
on other classes, signals and properties.
Then, an evil wizard came along and locked the stage singleton in his
black tower, and twisted it until it was possible to create new stages.
These new stages were pesky, and didn't have the same semantics of the
singleton: they didn't stay around when closed, or terminate the main
loop on delete events.
The evil wizard also started moving all the stage-related API from the
global context into class-specific methods.
Finally, the evil wizard cast a spell, and the stage singleton was
demoted to creation on demand - and until somebody called the
clutter_stage_get_default() function, the singleton remained in a limbo
of NULL pointers and undefined memory areas.
There was a last bit - literally - of information still held by the
global API; a tiny, little flag that disabled per-actor motion events.
The evil wizard added private accessors for it, and stored it inside the
stage private structure, in preparation for a deprecation that would
come in a future development cycle.
The evil wizard looked down upon the land of Clutter from the height of
his black tower; the lay of the land had been reshaped into a crucible
of potential, and the last dregs of the original force of creation were
either molted into new, useful shapes, or blasted away by the sheer fury
of his will.
All was good.
2011-02-18 17:19:04 +00:00
|
|
|
|
void
|
2011-06-20 10:41:28 +00:00
|
|
|
|
clutter_stage_set_motion_events_enabled (ClutterStage *stage,
|
|
|
|
|
gboolean enabled)
|
Store the motion event deliver flag in ClutterStage
Once upon a time, the land of Clutter had a stage singleton. It was
created automatically at initialization time and stayed around even
after the main loop was terminated. The singleton was content in
being all there was. There also was a global API to handle the
configuration of the stage singleton that would affect the behaviour
on other classes, signals and properties.
Then, an evil wizard came along and locked the stage singleton in his
black tower, and twisted it until it was possible to create new stages.
These new stages were pesky, and didn't have the same semantics of the
singleton: they didn't stay around when closed, or terminate the main
loop on delete events.
The evil wizard also started moving all the stage-related API from the
global context into class-specific methods.
Finally, the evil wizard cast a spell, and the stage singleton was
demoted to creation on demand - and until somebody called the
clutter_stage_get_default() function, the singleton remained in a limbo
of NULL pointers and undefined memory areas.
There was a last bit - literally - of information still held by the
global API; a tiny, little flag that disabled per-actor motion events.
The evil wizard added private accessors for it, and stored it inside the
stage private structure, in preparation for a deprecation that would
come in a future development cycle.
The evil wizard looked down upon the land of Clutter from the height of
his black tower; the lay of the land had been reshaped into a crucible
of potential, and the last dregs of the original force of creation were
either molted into new, useful shapes, or blasted away by the sheer fury
of his will.
All was good.
2011-02-18 17:19:04 +00:00
|
|
|
|
{
|
2011-06-20 10:41:28 +00:00
|
|
|
|
ClutterStagePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
|
|
|
|
|
|
|
|
|
priv = stage->priv;
|
Store the motion event deliver flag in ClutterStage
Once upon a time, the land of Clutter had a stage singleton. It was
created automatically at initialization time and stayed around even
after the main loop was terminated. The singleton was content in
being all there was. There also was a global API to handle the
configuration of the stage singleton that would affect the behaviour
on other classes, signals and properties.
Then, an evil wizard came along and locked the stage singleton in his
black tower, and twisted it until it was possible to create new stages.
These new stages were pesky, and didn't have the same semantics of the
singleton: they didn't stay around when closed, or terminate the main
loop on delete events.
The evil wizard also started moving all the stage-related API from the
global context into class-specific methods.
Finally, the evil wizard cast a spell, and the stage singleton was
demoted to creation on demand - and until somebody called the
clutter_stage_get_default() function, the singleton remained in a limbo
of NULL pointers and undefined memory areas.
There was a last bit - literally - of information still held by the
global API; a tiny, little flag that disabled per-actor motion events.
The evil wizard added private accessors for it, and stored it inside the
stage private structure, in preparation for a deprecation that would
come in a future development cycle.
The evil wizard looked down upon the land of Clutter from the height of
his black tower; the lay of the land had been reshaped into a crucible
of potential, and the last dregs of the original force of creation were
either molted into new, useful shapes, or blasted away by the sheer fury
of his will.
All was good.
2011-02-18 17:19:04 +00:00
|
|
|
|
|
|
|
|
|
enabled = !!enabled;
|
|
|
|
|
|
|
|
|
|
if (priv->motion_events_enabled != enabled)
|
2011-06-20 10:41:28 +00:00
|
|
|
|
priv->motion_events_enabled = enabled;
|
Store the motion event deliver flag in ClutterStage
Once upon a time, the land of Clutter had a stage singleton. It was
created automatically at initialization time and stayed around even
after the main loop was terminated. The singleton was content in
being all there was. There also was a global API to handle the
configuration of the stage singleton that would affect the behaviour
on other classes, signals and properties.
Then, an evil wizard came along and locked the stage singleton in his
black tower, and twisted it until it was possible to create new stages.
These new stages were pesky, and didn't have the same semantics of the
singleton: they didn't stay around when closed, or terminate the main
loop on delete events.
The evil wizard also started moving all the stage-related API from the
global context into class-specific methods.
Finally, the evil wizard cast a spell, and the stage singleton was
demoted to creation on demand - and until somebody called the
clutter_stage_get_default() function, the singleton remained in a limbo
of NULL pointers and undefined memory areas.
There was a last bit - literally - of information still held by the
global API; a tiny, little flag that disabled per-actor motion events.
The evil wizard added private accessors for it, and stored it inside the
stage private structure, in preparation for a deprecation that would
come in a future development cycle.
The evil wizard looked down upon the land of Clutter from the height of
his black tower; the lay of the land had been reshaped into a crucible
of potential, and the last dregs of the original force of creation were
either molted into new, useful shapes, or blasted away by the sheer fury
of his will.
All was good.
2011-02-18 17:19:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-20 10:41:28 +00:00
|
|
|
|
/**
|
|
|
|
|
* clutter_stage_get_motion_events_enabled:
|
|
|
|
|
* @stage: a #ClutterStage
|
|
|
|
|
*
|
|
|
|
|
* Retrieves the value set using clutter_stage_set_motion_events_enabled().
|
|
|
|
|
*
|
|
|
|
|
* Return value: %TRUE if the per-actor motion event delivery is enabled
|
|
|
|
|
* and %FALSE otherwise
|
|
|
|
|
*
|
2012-08-27 08:48:36 +00:00
|
|
|
|
*
|
2011-06-20 10:41:28 +00:00
|
|
|
|
*/
|
Store the motion event deliver flag in ClutterStage
Once upon a time, the land of Clutter had a stage singleton. It was
created automatically at initialization time and stayed around even
after the main loop was terminated. The singleton was content in
being all there was. There also was a global API to handle the
configuration of the stage singleton that would affect the behaviour
on other classes, signals and properties.
Then, an evil wizard came along and locked the stage singleton in his
black tower, and twisted it until it was possible to create new stages.
These new stages were pesky, and didn't have the same semantics of the
singleton: they didn't stay around when closed, or terminate the main
loop on delete events.
The evil wizard also started moving all the stage-related API from the
global context into class-specific methods.
Finally, the evil wizard cast a spell, and the stage singleton was
demoted to creation on demand - and until somebody called the
clutter_stage_get_default() function, the singleton remained in a limbo
of NULL pointers and undefined memory areas.
There was a last bit - literally - of information still held by the
global API; a tiny, little flag that disabled per-actor motion events.
The evil wizard added private accessors for it, and stored it inside the
stage private structure, in preparation for a deprecation that would
come in a future development cycle.
The evil wizard looked down upon the land of Clutter from the height of
his black tower; the lay of the land had been reshaped into a crucible
of potential, and the last dregs of the original force of creation were
either molted into new, useful shapes, or blasted away by the sheer fury
of his will.
All was good.
2011-02-18 17:19:04 +00:00
|
|
|
|
gboolean
|
2011-06-20 10:41:28 +00:00
|
|
|
|
clutter_stage_get_motion_events_enabled (ClutterStage *stage)
|
Store the motion event deliver flag in ClutterStage
Once upon a time, the land of Clutter had a stage singleton. It was
created automatically at initialization time and stayed around even
after the main loop was terminated. The singleton was content in
being all there was. There also was a global API to handle the
configuration of the stage singleton that would affect the behaviour
on other classes, signals and properties.
Then, an evil wizard came along and locked the stage singleton in his
black tower, and twisted it until it was possible to create new stages.
These new stages were pesky, and didn't have the same semantics of the
singleton: they didn't stay around when closed, or terminate the main
loop on delete events.
The evil wizard also started moving all the stage-related API from the
global context into class-specific methods.
Finally, the evil wizard cast a spell, and the stage singleton was
demoted to creation on demand - and until somebody called the
clutter_stage_get_default() function, the singleton remained in a limbo
of NULL pointers and undefined memory areas.
There was a last bit - literally - of information still held by the
global API; a tiny, little flag that disabled per-actor motion events.
The evil wizard added private accessors for it, and stored it inside the
stage private structure, in preparation for a deprecation that would
come in a future development cycle.
The evil wizard looked down upon the land of Clutter from the height of
his black tower; the lay of the land had been reshaped into a crucible
of potential, and the last dregs of the original force of creation were
either molted into new, useful shapes, or blasted away by the sheer fury
of his will.
All was good.
2011-02-18 17:19:04 +00:00
|
|
|
|
{
|
2011-06-20 10:41:28 +00:00
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE);
|
|
|
|
|
|
Store the motion event deliver flag in ClutterStage
Once upon a time, the land of Clutter had a stage singleton. It was
created automatically at initialization time and stayed around even
after the main loop was terminated. The singleton was content in
being all there was. There also was a global API to handle the
configuration of the stage singleton that would affect the behaviour
on other classes, signals and properties.
Then, an evil wizard came along and locked the stage singleton in his
black tower, and twisted it until it was possible to create new stages.
These new stages were pesky, and didn't have the same semantics of the
singleton: they didn't stay around when closed, or terminate the main
loop on delete events.
The evil wizard also started moving all the stage-related API from the
global context into class-specific methods.
Finally, the evil wizard cast a spell, and the stage singleton was
demoted to creation on demand - and until somebody called the
clutter_stage_get_default() function, the singleton remained in a limbo
of NULL pointers and undefined memory areas.
There was a last bit - literally - of information still held by the
global API; a tiny, little flag that disabled per-actor motion events.
The evil wizard added private accessors for it, and stored it inside the
stage private structure, in preparation for a deprecation that would
come in a future development cycle.
The evil wizard looked down upon the land of Clutter from the height of
his black tower; the lay of the land had been reshaped into a crucible
of potential, and the last dregs of the original force of creation were
either molted into new, useful shapes, or blasted away by the sheer fury
of his will.
All was good.
2011-02-18 17:19:04 +00:00
|
|
|
|
return stage->priv->motion_events_enabled;
|
|
|
|
|
}
|
2011-03-10 22:05:03 +00:00
|
|
|
|
|
|
|
|
|
/* NB: The presumption shouldn't be that a stage can't be comprised
|
|
|
|
|
* of multiple internal framebuffers, so instead of simply naming
|
|
|
|
|
* this function _clutter_stage_get_framebuffer(), the "active"
|
|
|
|
|
* infix is intended to clarify that it gets the framebuffer that
|
|
|
|
|
* is currently in use/being painted.
|
|
|
|
|
*/
|
|
|
|
|
CoglFramebuffer *
|
|
|
|
|
_clutter_stage_get_active_framebuffer (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
return stage->priv->active_framebuffer;
|
|
|
|
|
}
|
2011-04-11 13:11:39 +00:00
|
|
|
|
|
|
|
|
|
gint32
|
|
|
|
|
_clutter_stage_acquire_pick_id (ClutterStage *stage,
|
|
|
|
|
ClutterActor *actor)
|
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv = stage->priv;
|
|
|
|
|
|
|
|
|
|
g_assert (priv->pick_id_pool != NULL);
|
|
|
|
|
|
|
|
|
|
return _clutter_id_pool_add (priv->pick_id_pool, actor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_clutter_stage_release_pick_id (ClutterStage *stage,
|
|
|
|
|
gint32 pick_id)
|
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv = stage->priv;
|
|
|
|
|
|
|
|
|
|
g_assert (priv->pick_id_pool != NULL);
|
|
|
|
|
|
|
|
|
|
_clutter_id_pool_remove (priv->pick_id_pool, pick_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ClutterActor *
|
|
|
|
|
_clutter_stage_get_actor_by_pick_id (ClutterStage *stage,
|
|
|
|
|
gint32 pick_id)
|
|
|
|
|
{
|
|
|
|
|
ClutterStagePrivate *priv = stage->priv;
|
|
|
|
|
|
|
|
|
|
g_assert (priv->pick_id_pool != NULL);
|
|
|
|
|
|
|
|
|
|
return _clutter_id_pool_lookup (priv->pick_id_pool, pick_id);
|
|
|
|
|
}
|
2011-06-17 15:51:05 +00:00
|
|
|
|
|
|
|
|
|
void
|
2012-06-13 15:02:05 +00:00
|
|
|
|
_clutter_stage_add_pointer_drag_actor (ClutterStage *stage,
|
|
|
|
|
ClutterInputDevice *device,
|
|
|
|
|
ClutterActor *actor)
|
2011-06-17 15:51:05 +00:00
|
|
|
|
{
|
|
|
|
|
GHashTable *drag_actors;
|
|
|
|
|
|
2012-06-13 15:02:05 +00:00
|
|
|
|
drag_actors = g_object_get_data (G_OBJECT (stage),
|
|
|
|
|
"__clutter_stage_pointer_drag_actors");
|
2011-06-17 15:51:05 +00:00
|
|
|
|
if (drag_actors == NULL)
|
|
|
|
|
{
|
|
|
|
|
drag_actors = g_hash_table_new (NULL, NULL);
|
2012-06-13 15:02:05 +00:00
|
|
|
|
g_object_set_data_full (G_OBJECT (stage),
|
|
|
|
|
"__clutter_stage_pointer_drag_actors",
|
2011-06-17 15:51:05 +00:00
|
|
|
|
drag_actors,
|
|
|
|
|
(GDestroyNotify) g_hash_table_destroy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_hash_table_replace (drag_actors, device, actor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ClutterActor *
|
2012-06-13 15:02:05 +00:00
|
|
|
|
_clutter_stage_get_pointer_drag_actor (ClutterStage *stage,
|
|
|
|
|
ClutterInputDevice *device)
|
2011-06-17 15:51:05 +00:00
|
|
|
|
{
|
|
|
|
|
GHashTable *drag_actors;
|
|
|
|
|
|
2012-06-13 15:02:05 +00:00
|
|
|
|
drag_actors = g_object_get_data (G_OBJECT (stage),
|
|
|
|
|
"__clutter_stage_pointer_drag_actors");
|
2011-06-17 15:51:05 +00:00
|
|
|
|
if (drag_actors == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
return g_hash_table_lookup (drag_actors, device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2012-06-13 15:02:05 +00:00
|
|
|
|
_clutter_stage_remove_pointer_drag_actor (ClutterStage *stage,
|
|
|
|
|
ClutterInputDevice *device)
|
2011-06-17 15:51:05 +00:00
|
|
|
|
{
|
|
|
|
|
GHashTable *drag_actors;
|
|
|
|
|
|
2012-06-13 15:02:05 +00:00
|
|
|
|
drag_actors = g_object_get_data (G_OBJECT (stage),
|
|
|
|
|
"__clutter_stage_pointer_drag_actors");
|
2011-06-17 15:51:05 +00:00
|
|
|
|
if (drag_actors == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
g_hash_table_remove (drag_actors, device);
|
|
|
|
|
|
|
|
|
|
if (g_hash_table_size (drag_actors) == 0)
|
2012-06-13 15:02:05 +00:00
|
|
|
|
g_object_set_data (G_OBJECT (stage),
|
|
|
|
|
"__clutter_stage_pointer_drag_actors",
|
|
|
|
|
NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_clutter_stage_add_touch_drag_actor (ClutterStage *stage,
|
|
|
|
|
ClutterEventSequence *sequence,
|
|
|
|
|
ClutterActor *actor)
|
|
|
|
|
{
|
|
|
|
|
GHashTable *drag_actors;
|
|
|
|
|
|
|
|
|
|
drag_actors = g_object_get_data (G_OBJECT (stage),
|
|
|
|
|
"__clutter_stage_touch_drag_actors");
|
|
|
|
|
if (drag_actors == NULL)
|
|
|
|
|
{
|
|
|
|
|
drag_actors = g_hash_table_new (NULL, NULL);
|
|
|
|
|
g_object_set_data_full (G_OBJECT (stage),
|
|
|
|
|
"__clutter_stage_touch_drag_actors",
|
|
|
|
|
drag_actors,
|
|
|
|
|
(GDestroyNotify) g_hash_table_destroy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_hash_table_replace (drag_actors, sequence, actor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ClutterActor *
|
|
|
|
|
_clutter_stage_get_touch_drag_actor (ClutterStage *stage,
|
|
|
|
|
ClutterEventSequence *sequence)
|
|
|
|
|
{
|
|
|
|
|
GHashTable *drag_actors;
|
|
|
|
|
|
|
|
|
|
drag_actors = g_object_get_data (G_OBJECT (stage),
|
|
|
|
|
"__clutter_stage_touch_drag_actors");
|
|
|
|
|
if (drag_actors == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
return g_hash_table_lookup (drag_actors, sequence);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_clutter_stage_remove_touch_drag_actor (ClutterStage *stage,
|
|
|
|
|
ClutterEventSequence *sequence)
|
|
|
|
|
{
|
|
|
|
|
GHashTable *drag_actors;
|
|
|
|
|
|
|
|
|
|
drag_actors = g_object_get_data (G_OBJECT (stage),
|
|
|
|
|
"__clutter_stage_touch_drag_actors");
|
|
|
|
|
if (drag_actors == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
g_hash_table_remove (drag_actors, sequence);
|
|
|
|
|
|
|
|
|
|
if (g_hash_table_size (drag_actors) == 0)
|
|
|
|
|
g_object_set_data (G_OBJECT (stage),
|
|
|
|
|
"__clutter_stage_touch_drag_actors",
|
|
|
|
|
NULL);
|
2011-06-17 15:51:05 +00:00
|
|
|
|
}
|
2012-01-25 21:24:47 +00:00
|
|
|
|
|
|
|
|
|
/*< private >
|
|
|
|
|
* _clutter_stage_get_state:
|
|
|
|
|
* @stage: a #ClutterStage
|
|
|
|
|
*
|
|
|
|
|
* Retrieves the current #ClutterStageState flags associated to the @stage.
|
|
|
|
|
*
|
|
|
|
|
* Return value: a bitwise OR of #ClutterStageState flags
|
|
|
|
|
*/
|
|
|
|
|
ClutterStageState
|
|
|
|
|
_clutter_stage_get_state (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
return stage->priv->current_state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*< private >
|
|
|
|
|
* _clutter_stage_is_activated:
|
|
|
|
|
* @stage: a #ClutterStage
|
|
|
|
|
*
|
|
|
|
|
* Checks whether the @stage state includes %CLUTTER_STAGE_STATE_ACTIVATED.
|
|
|
|
|
*
|
|
|
|
|
* Return value: %TRUE if the @stage is active
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
_clutter_stage_is_activated (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
return (stage->priv->current_state & CLUTTER_STAGE_STATE_ACTIVATED) != 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*< private >
|
|
|
|
|
* _clutter_stage_is_fullscreen:
|
|
|
|
|
* @stage: a #ClutterStage
|
|
|
|
|
*
|
|
|
|
|
* Checks whether the @stage state includes %CLUTTER_STAGE_STATE_FULLSCREEN.
|
|
|
|
|
*
|
|
|
|
|
* Return value: %TRUE if the @stage is fullscreen
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
_clutter_stage_is_fullscreen (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
return (stage->priv->current_state & CLUTTER_STAGE_STATE_FULLSCREEN) != 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*< private >
|
|
|
|
|
* _clutter_stage_update_state:
|
|
|
|
|
* @stage: a #ClutterStage
|
|
|
|
|
* @unset_flags: flags to unset
|
|
|
|
|
* @set_flags: flags to set
|
|
|
|
|
*
|
|
|
|
|
* Updates the state of @stage, by unsetting the @unset_flags and setting
|
|
|
|
|
* the @set_flags.
|
|
|
|
|
*
|
|
|
|
|
* If the stage state has been changed, this function will queue a
|
|
|
|
|
* #ClutterEvent of type %CLUTTER_STAGE_STATE.
|
|
|
|
|
*
|
|
|
|
|
* Return value: %TRUE if the state was updated, and %FALSE otherwise
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
_clutter_stage_update_state (ClutterStage *stage,
|
|
|
|
|
ClutterStageState unset_flags,
|
|
|
|
|
ClutterStageState set_flags)
|
|
|
|
|
{
|
|
|
|
|
ClutterStageState new_state;
|
|
|
|
|
ClutterEvent *event;
|
|
|
|
|
|
|
|
|
|
new_state = stage->priv->current_state;
|
|
|
|
|
new_state |= set_flags;
|
|
|
|
|
new_state &= ~unset_flags;
|
|
|
|
|
|
|
|
|
|
if (new_state == stage->priv->current_state)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
event = clutter_event_new (CLUTTER_STAGE_STATE);
|
|
|
|
|
clutter_event_set_stage (event, stage);
|
|
|
|
|
|
|
|
|
|
event->stage_state.new_state = new_state;
|
|
|
|
|
event->stage_state.changed_mask = new_state ^ stage->priv->current_state;
|
|
|
|
|
|
|
|
|
|
stage->priv->current_state = new_state;
|
|
|
|
|
|
|
|
|
|
_clutter_event_push (event, FALSE);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2012-11-08 17:42:24 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* clutter_stage_set_sync_delay:
|
|
|
|
|
* @stage: a #ClutterStage
|
|
|
|
|
* @sync_delay: number of milliseconds after frame presentation to wait
|
|
|
|
|
* before painting the next frame. If less than zero, restores the
|
|
|
|
|
* default behavior where redraw is throttled to the refresh rate but
|
|
|
|
|
* not synchronized to it.
|
|
|
|
|
*
|
|
|
|
|
* This function enables an alternate behavior where Clutter draws at
|
|
|
|
|
* a fixed point in time after the frame presentation time (also known
|
|
|
|
|
* as the VBlank time). This is most useful when the application
|
|
|
|
|
* wants to show incoming data with predictable latency. (The primary
|
|
|
|
|
* example of this would be a window system compositor.) By synchronizing
|
|
|
|
|
* to provide new data before Clutter redraws, an external source of
|
|
|
|
|
* updates (in the compositor, an application) can get a reliable latency.
|
|
|
|
|
*
|
|
|
|
|
* The appropriate value of @sync_delay depends on the complexity of
|
|
|
|
|
* drawing the stage's scene graph - in general a value of between 0
|
|
|
|
|
* and 8 ms (up to one-half of a typical 60hz frame rate) is appropriate.
|
|
|
|
|
* using a larger value will reduce latency but risks skipping a frame if
|
|
|
|
|
* drawing the stage takes too long.
|
|
|
|
|
*
|
|
|
|
|
* Stability: unstable
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
clutter_stage_set_sync_delay (ClutterStage *stage,
|
|
|
|
|
gint sync_delay)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
|
|
|
|
|
|
|
|
|
stage->priv->sync_delay = sync_delay;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* clutter_stage_skip_sync_delay:
|
|
|
|
|
* @stage: a #ClutterStage
|
|
|
|
|
*
|
|
|
|
|
* Causes the next frame for the stage to be drawn as quickly as
|
|
|
|
|
* possible, ignoring any delay that clutter_stage_set_sync_delay()
|
|
|
|
|
* would normally cause.
|
|
|
|
|
*
|
|
|
|
|
* Stability: unstable
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
clutter_stage_skip_sync_delay (ClutterStage *stage)
|
|
|
|
|
{
|
|
|
|
|
ClutterStageWindow *stage_window;
|
|
|
|
|
|
|
|
|
|
stage_window = _clutter_stage_get_window (stage);
|
|
|
|
|
if (stage_window)
|
|
|
|
|
_clutter_stage_window_schedule_update (stage_window, -1);
|
|
|
|
|
}
|