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
|
|
|
*/
|
2012-03-06 12:09:00 +00:00
|
|
|
|
2006-06-21 22:34:25 +00:00
|
|
|
/**
|
|
|
|
* SECTION:clutter-main
|
2014-03-17 23:07:58 +00:00
|
|
|
* @short_description: Various 'global' Clutter functions.
|
2006-06-21 22:34:25 +00:00
|
|
|
*
|
2006-06-22 14:36:05 +00:00
|
|
|
* Functions to retrieve various global Clutter resources and other utility
|
|
|
|
* functions for mainloops, events and threads
|
2009-12-02 14:15:43 +00:00
|
|
|
*
|
2014-03-17 23:07:58 +00:00
|
|
|
* ## The Clutter Threading Model
|
2009-12-02 14:15:43 +00:00
|
|
|
*
|
2014-03-17 23:07:58 +00:00
|
|
|
* Clutter is *thread-aware*: all operations performed by Clutter are assumed
|
|
|
|
* to be under the Big Clutter Lock, which is created when the threading is
|
|
|
|
* initialized through clutter_init(), and entered when calling user-related
|
|
|
|
* code during event handling and actor drawing.
|
2009-12-02 14:15:43 +00:00
|
|
|
*
|
2014-03-17 23:07:58 +00:00
|
|
|
* The only safe and portable way to use the Clutter API in a multi-threaded
|
|
|
|
* environment is to only access the Clutter API from a thread that did called
|
|
|
|
* clutter_init() and clutter_main().
|
2009-12-02 14:15:43 +00:00
|
|
|
*
|
2014-03-17 23:07:58 +00:00
|
|
|
* The common pattern for using threads with Clutter is to use worker threads
|
|
|
|
* to perform blocking operations and then install idle or timeout sources with
|
|
|
|
* the result when the thread finishes, and update the UI from those callbacks.
|
2009-12-02 14:15:43 +00:00
|
|
|
*
|
2014-03-17 23:07:58 +00:00
|
|
|
* For a working example of how to use a worker thread to update the UI, see
|
|
|
|
* [threads.c](https://git.gnome.org/browse/clutter/tree/examples/threads.c?h=clutter-1.18)
|
2006-06-21 22:34:25 +00:00
|
|
|
*/
|
|
|
|
|
2023-08-07 15:38:12 +02:00
|
|
|
#include "clutter/clutter-build-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 <stdlib.h>
|
2022-05-09 11:29:11 +02:00
|
|
|
#include <glib/gi18n-lib.h>
|
2023-01-02 23:11:37 +01:00
|
|
|
#include <hb-glib.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
|
|
|
|
2023-08-07 15:38:12 +02:00
|
|
|
#include "clutter/clutter-actor-private.h"
|
|
|
|
#include "clutter/clutter-backend-private.h"
|
|
|
|
#include "clutter/clutter-debug.h"
|
|
|
|
#include "clutter/clutter-event-private.h"
|
|
|
|
#include "clutter/clutter-input-device-private.h"
|
|
|
|
#include "clutter/clutter-input-pointer-a11y-private.h"
|
|
|
|
#include "clutter/clutter-graphene.h"
|
|
|
|
#include "clutter/clutter-main.h"
|
|
|
|
#include "clutter/clutter-mutter.h"
|
|
|
|
#include "clutter/clutter-paint-node-private.h"
|
|
|
|
#include "clutter/clutter-private.h"
|
|
|
|
#include "clutter/clutter-settings-private.h"
|
|
|
|
#include "clutter/clutter-stage.h"
|
|
|
|
#include "clutter/clutter-stage-manager.h"
|
|
|
|
#include "clutter/clutter-stage-private.h"
|
|
|
|
#include "clutter/clutter-backend-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
|
|
|
|
2023-08-07 15:38:12 +02:00
|
|
|
#include "cogl/cogl.h"
|
|
|
|
#include "cogl-pango/cogl-pango.h"
|
2007-05-28 18:49:34 +00:00
|
|
|
|
2018-05-23 11:04:56 +02:00
|
|
|
#include "cally/cally.h" /* For accessibility support */
|
2010-04-26 19:33:49 +02:00
|
|
|
|
2007-08-08 10:20:14 +00:00
|
|
|
/* main context */
|
2008-12-23 16:40:26 +00:00
|
|
|
static ClutterMainContext *ClutterCntx = NULL;
|
2007-08-08 10:20:14 +00:00
|
|
|
|
2009-02-23 13:08:59 +00:00
|
|
|
/* command line options */
|
2008-12-23 16:40:26 +00:00
|
|
|
static gboolean clutter_is_initialized = FALSE;
|
|
|
|
static gboolean clutter_show_fps = FALSE;
|
2009-02-23 13:08:59 +00:00
|
|
|
static gboolean clutter_disable_mipmap_text = FALSE;
|
2010-04-26 19:33:49 +02:00
|
|
|
static gboolean clutter_enable_accessibility = TRUE;
|
2011-11-04 16:35:38 +00:00
|
|
|
static gboolean clutter_sync_to_vblank = TRUE;
|
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
|
|
|
|
2010-11-15 15:36:41 +00:00
|
|
|
static ClutterTextDirection clutter_text_direction = CLUTTER_TEXT_DIRECTION_LTR;
|
2009-02-23 13:08:59 +00:00
|
|
|
|
2011-10-10 15:42:36 +01:00
|
|
|
/* debug flags */
|
|
|
|
guint clutter_debug_flags = 0;
|
2010-02-16 20:08:35 +00:00
|
|
|
guint clutter_paint_debug_flags = 0;
|
2011-10-10 15:42:36 +01:00
|
|
|
guint clutter_pick_debug_flags = 0;
|
2010-02-16 20:08:35 +00:00
|
|
|
|
2020-11-28 22:15:02 +03:00
|
|
|
/* A constant added to heuristic max render time to account for variations
|
|
|
|
* in the estimates.
|
|
|
|
*/
|
2022-07-08 12:52:03 +02:00
|
|
|
int clutter_max_render_time_constant_us = 1000;
|
2020-11-28 22:15:02 +03:00
|
|
|
|
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
|
|
|
#ifdef CLUTTER_ENABLE_DEBUG
|
|
|
|
static const GDebugKey clutter_debug_keys[] = {
|
|
|
|
{ "misc", CLUTTER_DEBUG_MISC },
|
|
|
|
{ "actor", CLUTTER_DEBUG_ACTOR },
|
|
|
|
{ "texture", CLUTTER_DEBUG_TEXTURE },
|
|
|
|
{ "event", CLUTTER_DEBUG_EVENT },
|
|
|
|
{ "paint", CLUTTER_DEBUG_PAINT },
|
2010-08-23 11:33:22 +01:00
|
|
|
{ "pick", CLUTTER_DEBUG_PICK },
|
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
|
|
|
{ "pango", CLUTTER_DEBUG_PANGO },
|
2007-04-28 00:37:11 +00:00
|
|
|
{ "backend", CLUTTER_DEBUG_BACKEND },
|
2007-06-07 23:51:53 +00:00
|
|
|
{ "scheduler", CLUTTER_DEBUG_SCHEDULER },
|
2007-10-08 15:03:22 +00:00
|
|
|
{ "script", CLUTTER_DEBUG_SCRIPT },
|
2007-12-05 21:15:19 +00:00
|
|
|
{ "shader", CLUTTER_DEBUG_SHADER },
|
2009-04-15 17:25:50 +01:00
|
|
|
{ "animation", CLUTTER_DEBUG_ANIMATION },
|
2011-02-01 18:32:08 +00:00
|
|
|
{ "layout", CLUTTER_DEBUG_LAYOUT },
|
2011-09-19 12:36:52 +01:00
|
|
|
{ "clipping", CLUTTER_DEBUG_CLIPPING },
|
2011-09-28 14:24:57 +02:00
|
|
|
{ "oob-transforms", CLUTTER_DEBUG_OOB_TRANSFORMS },
|
2021-01-13 09:32:44 +03:00
|
|
|
{ "frame-timings", CLUTTER_DEBUG_FRAME_TIMINGS },
|
2021-02-03 00:04:02 +01:00
|
|
|
{ "detailed-trace", CLUTTER_DEBUG_DETAILED_TRACE },
|
2022-04-06 12:19:27 +02:00
|
|
|
{ "grabs", CLUTTER_DEBUG_GRABS },
|
2022-12-15 12:18:52 +01:00
|
|
|
{ "frame-clock", CLUTTER_DEBUG_FRAME_CLOCK },
|
2010-02-16 20:08:35 +00:00
|
|
|
};
|
|
|
|
#endif /* CLUTTER_ENABLE_DEBUG */
|
|
|
|
|
|
|
|
static const GDebugKey clutter_pick_debug_keys[] = {
|
2009-09-24 12:49:17 +01:00
|
|
|
{ "nop-picking", CLUTTER_DEBUG_NOP_PICKING },
|
2010-02-16 20:08:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const GDebugKey clutter_paint_debug_keys[] = {
|
2009-11-30 17:47:55 +00:00
|
|
|
{ "disable-swap-events", CLUTTER_DEBUG_DISABLE_SWAP_EVENTS },
|
|
|
|
{ "disable-clipped-redraws", CLUTTER_DEBUG_DISABLE_CLIPPED_REDRAWS },
|
2010-09-07 18:50:29 +01:00
|
|
|
{ "redraws", CLUTTER_DEBUG_REDRAWS },
|
|
|
|
{ "paint-volumes", CLUTTER_DEBUG_PAINT_VOLUMES },
|
2011-06-06 18:22:20 +01:00
|
|
|
{ "disable-culling", CLUTTER_DEBUG_DISABLE_CULLING },
|
2011-09-23 15:12:44 +01:00
|
|
|
{ "disable-offscreen-redirect", CLUTTER_DEBUG_DISABLE_OFFSCREEN_REDIRECT },
|
2011-10-13 11:38:27 +01:00
|
|
|
{ "continuous-redraw", CLUTTER_DEBUG_CONTINUOUS_REDRAW },
|
|
|
|
{ "paint-deform-tiles", CLUTTER_DEBUG_PAINT_DEFORM_TILES },
|
2018-08-10 01:03:54 -03:00
|
|
|
{ "damage-region", CLUTTER_DEBUG_PAINT_DAMAGE_REGION },
|
2020-11-28 16:46:03 +03:00
|
|
|
{ "disable-dynamic-max-render-time", CLUTTER_DEBUG_DISABLE_DYNAMIC_MAX_RENDER_TIME },
|
2020-11-27 21:49:19 +03:00
|
|
|
{ "max-render-time", CLUTTER_DEBUG_PAINT_MAX_RENDER_TIME },
|
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
|
|
|
};
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2011-11-15 17:58:25 +00:00
|
|
|
gboolean
|
|
|
|
_clutter_context_get_show_fps (void)
|
|
|
|
{
|
|
|
|
ClutterMainContext *context = _clutter_context_get_default ();
|
|
|
|
|
|
|
|
return context->show_fps;
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
2010-04-26 19:33:49 +02:00
|
|
|
/**
|
|
|
|
* clutter_get_accessibility_enabled:
|
|
|
|
*
|
|
|
|
* Returns whether Clutter has accessibility support enabled. As
|
|
|
|
* least, a value of TRUE means that there are a proper AtkUtil
|
|
|
|
* implementation available
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if Clutter has accessibility support enabled
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
clutter_get_accessibility_enabled (void)
|
|
|
|
{
|
|
|
|
return cally_get_cally_initialized ();
|
|
|
|
}
|
|
|
|
|
2013-03-01 10:58:54 +01:00
|
|
|
/**
|
|
|
|
* clutter_disable_accessibility:
|
|
|
|
*
|
|
|
|
* Disable loading the accessibility support. It has the same effect
|
|
|
|
* as setting the environment variable
|
|
|
|
* CLUTTER_DISABLE_ACCESSIBILITY. For the same reason, this method
|
|
|
|
* should be called before clutter_init().
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_disable_accessibility (void)
|
|
|
|
{
|
|
|
|
if (clutter_is_initialized)
|
|
|
|
{
|
|
|
|
g_warning ("clutter_disable_accessibility() can only be called before "
|
|
|
|
"initializing Clutter.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
clutter_enable_accessibility = FALSE;
|
|
|
|
}
|
|
|
|
|
2011-02-18 15:47:35 +00:00
|
|
|
static CoglPangoFontMap *
|
|
|
|
clutter_context_get_pango_fontmap (void)
|
2010-06-09 11:53:58 +01:00
|
|
|
{
|
2011-02-18 15:47:35 +00:00
|
|
|
ClutterMainContext *self;
|
2010-06-09 11:53:58 +01:00
|
|
|
CoglPangoFontMap *font_map;
|
|
|
|
gdouble resolution;
|
|
|
|
gboolean use_mipmapping;
|
|
|
|
|
2011-02-18 15:47:35 +00:00
|
|
|
self = _clutter_context_get_default ();
|
2010-06-09 11:53:58 +01:00
|
|
|
if (G_LIKELY (self->font_map != NULL))
|
|
|
|
return self->font_map;
|
|
|
|
|
|
|
|
font_map = COGL_PANGO_FONT_MAP (cogl_pango_font_map_new ());
|
|
|
|
|
|
|
|
resolution = clutter_backend_get_resolution (self->backend);
|
|
|
|
cogl_pango_font_map_set_resolution (font_map, resolution);
|
|
|
|
|
|
|
|
use_mipmapping = !clutter_disable_mipmap_text;
|
|
|
|
cogl_pango_font_map_set_use_mipmapping (font_map, use_mipmapping);
|
|
|
|
|
|
|
|
self->font_map = font_map;
|
|
|
|
|
|
|
|
return self->font_map;
|
|
|
|
}
|
|
|
|
|
2022-05-09 11:29:11 +02:00
|
|
|
ClutterTextDirection
|
2008-12-23 16:40:26 +00:00
|
|
|
clutter_get_text_direction (void)
|
2008-06-13 09:10:39 +00:00
|
|
|
{
|
2011-10-11 23:42:23 +01:00
|
|
|
ClutterTextDirection dir = CLUTTER_TEXT_DIRECTION_LTR;
|
2009-01-06 12:35:19 +00:00
|
|
|
const gchar *direction;
|
2008-12-23 16:40:26 +00:00
|
|
|
|
|
|
|
direction = g_getenv ("CLUTTER_TEXT_DIRECTION");
|
|
|
|
if (direction && *direction != '\0')
|
|
|
|
{
|
|
|
|
if (strcmp (direction, "rtl") == 0)
|
2009-11-06 16:50:53 +00:00
|
|
|
dir = CLUTTER_TEXT_DIRECTION_RTL;
|
2009-01-06 12:35:19 +00:00
|
|
|
else if (strcmp (direction, "ltr") == 0)
|
2009-11-06 16:50:53 +00:00
|
|
|
dir = CLUTTER_TEXT_DIRECTION_LTR;
|
2008-12-23 16:40:26 +00:00
|
|
|
}
|
|
|
|
else
|
2009-01-06 12:35:19 +00:00
|
|
|
{
|
2023-01-02 23:11:37 +01:00
|
|
|
PangoLanguage *language;
|
|
|
|
const PangoScript *scripts;
|
|
|
|
int n_scripts, i;
|
|
|
|
|
|
|
|
language = pango_language_get_default ();
|
|
|
|
scripts = pango_language_get_scripts (language, &n_scripts);
|
|
|
|
|
|
|
|
for (i = 0; i < n_scripts; i++)
|
|
|
|
{
|
|
|
|
hb_script_t script;
|
|
|
|
hb_direction_t text_dir;
|
|
|
|
|
|
|
|
script = hb_glib_script_to_script ((GUnicodeScript) scripts[i]);
|
|
|
|
text_dir = hb_script_get_horizontal_direction (script);
|
|
|
|
|
|
|
|
if (text_dir == HB_DIRECTION_LTR)
|
|
|
|
dir = CLUTTER_TEXT_DIRECTION_LTR;
|
|
|
|
else if (text_dir == HB_DIRECTION_RTL)
|
|
|
|
dir = CLUTTER_TEXT_DIRECTION_RTL;
|
|
|
|
else
|
|
|
|
continue;
|
|
|
|
}
|
2009-01-06 12:35:19 +00:00
|
|
|
}
|
2008-12-23 16:40:26 +00:00
|
|
|
|
2012-09-19 11:39:41 +01:00
|
|
|
CLUTTER_NOTE (MISC, "Text direction: %s",
|
|
|
|
dir == CLUTTER_TEXT_DIRECTION_RTL ? "rtl" : "ltr");
|
|
|
|
|
2008-12-23 16:40:26 +00:00
|
|
|
return dir;
|
|
|
|
}
|
|
|
|
|
2010-11-06 20:00:39 +00:00
|
|
|
gboolean
|
|
|
|
_clutter_threads_dispatch (gpointer data)
|
2007-08-08 10:20:14 +00:00
|
|
|
{
|
|
|
|
ClutterThreadsDispatch *dispatch = data;
|
|
|
|
gboolean ret = FALSE;
|
|
|
|
|
|
|
|
if (!g_source_is_destroyed (g_main_current_source ()))
|
|
|
|
ret = dispatch->func (dispatch->data);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-11-06 20:00:39 +00:00
|
|
|
void
|
|
|
|
_clutter_threads_dispatch_free (gpointer data)
|
2007-08-08 10:20:14 +00:00
|
|
|
{
|
|
|
|
ClutterThreadsDispatch *dispatch = data;
|
|
|
|
|
2007-08-22 10:12:15 +00:00
|
|
|
/* XXX - we cannot hold the thread lock here because the main loop
|
|
|
|
* might destroy a source while still in the dispatcher function; so
|
|
|
|
* knowing whether the lock is being held or not is not known a priori.
|
|
|
|
*
|
|
|
|
* see bug: http://bugzilla.gnome.org/show_bug.cgi?id=459555
|
|
|
|
*/
|
2007-08-08 10:20:14 +00:00
|
|
|
if (dispatch->notify)
|
|
|
|
dispatch->notify (dispatch->data);
|
|
|
|
|
2020-10-19 19:57:45 +02:00
|
|
|
g_free (dispatch);
|
2007-08-08 10:20:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-12-03 13:43:36 +00:00
|
|
|
* clutter_threads_add_idle_full: (rename-to clutter_threads_add_idle)
|
2007-08-08 10:20:14 +00:00
|
|
|
* @priority: the priority of the timeout source. Typically this will be in the
|
|
|
|
* range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE
|
|
|
|
* @func: function to call
|
|
|
|
* @data: data to pass to the function
|
2023-08-10 01:44:52 +02:00
|
|
|
* @notify: function to call when the idle source is removed
|
2007-08-08 10:20:14 +00:00
|
|
|
*
|
|
|
|
* Adds a function to be called whenever there are no higher priority
|
2008-08-04 10:36:37 +00:00
|
|
|
* events pending. If the function returns %FALSE it is automatically
|
2007-08-08 10:20:14 +00:00
|
|
|
* removed from the list of event sources and will not be called again.
|
|
|
|
*
|
2008-08-04 10:36:37 +00:00
|
|
|
* This function can be considered a thread-safe variant of g_idle_add_full():
|
|
|
|
* it will call @function while holding the Clutter lock. It is logically
|
|
|
|
* equivalent to the following implementation:
|
2007-08-08 10:20:14 +00:00
|
|
|
*
|
2022-05-25 18:41:48 +02:00
|
|
|
* ```c
|
2007-08-08 10:20:14 +00:00
|
|
|
* static gboolean
|
2008-08-04 10:36:37 +00:00
|
|
|
* idle_safe_callback (gpointer data)
|
2007-08-08 10:20:14 +00:00
|
|
|
* {
|
2008-08-04 10:36:37 +00:00
|
|
|
* SafeClosure *closure = data;
|
|
|
|
* gboolean res = FALSE;
|
2007-08-08 10:20:14 +00:00
|
|
|
*
|
2014-03-17 23:07:58 +00:00
|
|
|
* // the callback does not need to acquire the Clutter
|
|
|
|
* / lock itself, as it is held by the this proxy handler
|
|
|
|
* //
|
2008-08-04 10:36:37 +00:00
|
|
|
* res = closure->callback (closure->data);
|
|
|
|
*
|
|
|
|
* return res;
|
2007-08-08 10:20:14 +00:00
|
|
|
* }
|
2008-08-04 10:36:37 +00:00
|
|
|
* static gulong
|
|
|
|
* add_safe_idle (GSourceFunc callback,
|
|
|
|
* gpointer data)
|
2007-08-08 10:20:14 +00:00
|
|
|
* {
|
2008-08-04 10:36:37 +00:00
|
|
|
* SafeClosure *closure = g_new0 (SafeClosure, 1);
|
|
|
|
*
|
2014-03-17 23:07:58 +00:00
|
|
|
* closure->callback = callback;
|
|
|
|
* closure->data = data;
|
2008-08-04 10:36:37 +00:00
|
|
|
*
|
2011-10-10 15:42:36 +01:00
|
|
|
* return g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
|
2008-08-04 10:36:37 +00:00
|
|
|
* idle_safe_callback,
|
|
|
|
* closure,
|
|
|
|
* g_free)
|
2007-08-08 10:20:14 +00:00
|
|
|
* }
|
2022-05-25 18:41:48 +02:00
|
|
|
* ```
|
2007-08-08 10:20:14 +00:00
|
|
|
*
|
2008-08-04 10:36:37 +00:00
|
|
|
* This function should be used by threaded applications to make sure
|
|
|
|
* that @func is emitted under the Clutter threads lock and invoked
|
|
|
|
* from the same thread that started the Clutter main loop. For instance,
|
|
|
|
* it can be used to update the UI using the results from a worker
|
|
|
|
* thread:
|
|
|
|
*
|
2022-05-25 18:41:48 +02:00
|
|
|
* ```c
|
2008-08-04 10:36:37 +00:00
|
|
|
* static gboolean
|
|
|
|
* update_ui (gpointer data)
|
2007-08-08 10:20:14 +00:00
|
|
|
* {
|
2008-08-04 10:36:37 +00:00
|
|
|
* SomeClosure *closure = data;
|
|
|
|
*
|
2014-03-17 23:07:58 +00:00
|
|
|
* // it is safe to call Clutter API from this function because
|
|
|
|
* / it is invoked from the same thread that started the main
|
|
|
|
* / loop and under the Clutter thread lock
|
|
|
|
* //
|
|
|
|
* clutter_label_set_text (CLUTTER_LABEL (closure->label),
|
|
|
|
* closure->text);
|
2008-08-04 10:36:37 +00:00
|
|
|
*
|
2014-03-17 23:07:58 +00:00
|
|
|
* g_object_unref (closure->label);
|
2008-08-04 10:36:37 +00:00
|
|
|
* g_free (closure);
|
|
|
|
*
|
|
|
|
* return FALSE;
|
2007-08-08 10:20:14 +00:00
|
|
|
* }
|
2008-08-04 10:36:37 +00:00
|
|
|
*
|
2014-03-17 23:07:58 +00:00
|
|
|
* // within another thread //
|
2008-08-04 10:36:37 +00:00
|
|
|
* closure = g_new0 (SomeClosure, 1);
|
2014-03-17 23:07:58 +00:00
|
|
|
* // always take a reference on GObject instances //
|
|
|
|
* closure->label = g_object_ref (my_application->label);
|
|
|
|
* closure->text = g_strdup (processed_text_to_update_the_label);
|
2008-08-04 10:36:37 +00:00
|
|
|
*
|
|
|
|
* clutter_threads_add_idle_full (G_PRIORITY_HIGH_IDLE,
|
|
|
|
* update_ui,
|
|
|
|
* closure,
|
|
|
|
* NULL);
|
2022-05-25 18:41:48 +02:00
|
|
|
* ```
|
2007-08-08 10:20:14 +00:00
|
|
|
*
|
|
|
|
* Return value: the ID (greater than 0) of the event source.
|
|
|
|
*/
|
|
|
|
guint
|
|
|
|
clutter_threads_add_idle_full (gint priority,
|
|
|
|
GSourceFunc func,
|
|
|
|
gpointer data,
|
|
|
|
GDestroyNotify notify)
|
|
|
|
{
|
|
|
|
ClutterThreadsDispatch *dispatch;
|
|
|
|
|
|
|
|
g_return_val_if_fail (func != NULL, 0);
|
|
|
|
|
2020-10-19 19:57:45 +02:00
|
|
|
dispatch = g_new0 (ClutterThreadsDispatch, 1);
|
2007-08-08 10:20:14 +00:00
|
|
|
dispatch->func = func;
|
|
|
|
dispatch->data = data;
|
|
|
|
dispatch->notify = notify;
|
|
|
|
|
|
|
|
return g_idle_add_full (priority,
|
2010-11-06 20:00:39 +00:00
|
|
|
_clutter_threads_dispatch, dispatch,
|
|
|
|
_clutter_threads_dispatch_free);
|
2007-08-08 10:20:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-09-08 16:41:47 +01:00
|
|
|
* clutter_threads_add_idle: (skip)
|
2007-08-08 10:20:14 +00:00
|
|
|
* @func: function to call
|
|
|
|
* @data: data to pass to the function
|
|
|
|
*
|
2008-08-04 10:36:37 +00:00
|
|
|
* Simple wrapper around clutter_threads_add_idle_full() using the
|
|
|
|
* default priority.
|
2007-08-08 10:20:14 +00:00
|
|
|
*
|
|
|
|
* Return value: the ID (greater than 0) of the event source.
|
|
|
|
*/
|
|
|
|
guint
|
|
|
|
clutter_threads_add_idle (GSourceFunc func,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (func != NULL, 0);
|
|
|
|
|
|
|
|
return clutter_threads_add_idle_full (G_PRIORITY_DEFAULT_IDLE,
|
|
|
|
func, data,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-12-03 13:43:36 +00:00
|
|
|
* clutter_threads_add_timeout_full: (rename-to clutter_threads_add_timeout)
|
2007-08-08 10:20:14 +00:00
|
|
|
* @priority: the priority of the timeout source. Typically this will be in the
|
|
|
|
* range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.
|
|
|
|
* @interval: the time between calls to the function, in milliseconds
|
|
|
|
* @func: function to call
|
|
|
|
* @data: data to pass to the function
|
|
|
|
* @notify: function to call when the timeout source is removed
|
|
|
|
*
|
2008-08-04 10:36:37 +00:00
|
|
|
* Sets a function to be called at regular intervals holding the Clutter
|
|
|
|
* threads lock, with the given priority. The function is called repeatedly
|
|
|
|
* until it returns %FALSE, at which point the timeout is automatically
|
|
|
|
* removed and the function will not be called again. The @notify function
|
|
|
|
* is called when the timeout is removed.
|
2007-08-08 10:20:14 +00:00
|
|
|
*
|
2008-08-04 10:36:37 +00:00
|
|
|
* The first call to the function will be at the end of the first @interval.
|
2007-08-08 10:20:14 +00:00
|
|
|
*
|
2008-08-04 10:36:37 +00:00
|
|
|
* It is important to note that, due to how the Clutter main loop is
|
|
|
|
* implemented, the timing will not be accurate and it will not try to
|
2011-10-10 15:42:36 +01:00
|
|
|
* "keep up" with the interval.
|
2008-08-04 10:36:37 +00:00
|
|
|
*
|
|
|
|
* See also clutter_threads_add_idle_full().
|
2007-08-08 10:20:14 +00:00
|
|
|
*
|
|
|
|
* Return value: the ID (greater than 0) of the event source.
|
|
|
|
*/
|
|
|
|
guint
|
|
|
|
clutter_threads_add_timeout_full (gint priority,
|
|
|
|
guint interval,
|
|
|
|
GSourceFunc func,
|
|
|
|
gpointer data,
|
|
|
|
GDestroyNotify notify)
|
|
|
|
{
|
|
|
|
ClutterThreadsDispatch *dispatch;
|
|
|
|
|
|
|
|
g_return_val_if_fail (func != NULL, 0);
|
|
|
|
|
2020-10-19 19:57:45 +02:00
|
|
|
dispatch = g_new0 (ClutterThreadsDispatch, 1);
|
2007-08-08 10:20:14 +00:00
|
|
|
dispatch->func = func;
|
|
|
|
dispatch->data = data;
|
|
|
|
dispatch->notify = notify;
|
|
|
|
|
|
|
|
return g_timeout_add_full (priority,
|
|
|
|
interval,
|
2010-11-06 20:00:39 +00:00
|
|
|
_clutter_threads_dispatch, dispatch,
|
|
|
|
_clutter_threads_dispatch_free);
|
2007-08-08 10:20:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-09-08 16:41:47 +01:00
|
|
|
* clutter_threads_add_timeout: (skip)
|
2007-08-08 10:20:14 +00:00
|
|
|
* @interval: the time between calls to the function, in milliseconds
|
|
|
|
* @func: function to call
|
|
|
|
* @data: data to pass to the function
|
|
|
|
*
|
|
|
|
* Simple wrapper around clutter_threads_add_timeout_full().
|
|
|
|
*
|
|
|
|
* Return value: the ID (greater than 0) of the event source.
|
|
|
|
*/
|
|
|
|
guint
|
|
|
|
clutter_threads_add_timeout (guint interval,
|
|
|
|
GSourceFunc func,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (func != NULL, 0);
|
|
|
|
|
|
|
|
return clutter_threads_add_timeout_full (G_PRIORITY_DEFAULT,
|
|
|
|
interval,
|
|
|
|
func, data,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2009-06-19 14:09:42 +01:00
|
|
|
gboolean
|
|
|
|
_clutter_context_is_initialized (void)
|
|
|
|
{
|
|
|
|
if (ClutterCntx == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return ClutterCntx->is_initialized;
|
|
|
|
}
|
|
|
|
|
2020-05-23 22:50:43 +02:00
|
|
|
ClutterMainContext *
|
|
|
|
_clutter_context_get_default (void)
|
2011-10-17 13:25:15 +01:00
|
|
|
{
|
Explicitly create the clutter context and backend
This changes the setup phase of clutter to not be result of calling an
init function that sets up a few global singletons, via global singleton
setup vfuncs.
The way it worked was that mutter first did some initial setup
(connecting to the X11 server), then set a "custom backend" setup vfunc
global, before calling clutter_init().
During the clutter_init() call, the context and backend was setup by
calling the global singleton getters, which implicitly created the
backend and context on-demand.
This has now changed to mutter explicitly creating a `ClutterContext`
(which is actually a `ClutterMainContext`, but with the name shortened to
be consistent with `CoglContext` and `MetaContext`), calling it with a
backend constructor vfunc and user data pointer.
This function now explicitly creates the backend, without having to go
via the previously set global vfunc.
This changes the behavior of some "get_default()" like functions, which
will now fail if called after mutter has shut down, as when it does so,
it now destroys the backends and contexts, not only its own, but the
clutter ones too.
The "ownership" of the clutter backend is also moved to
`ClutterContext`, and MetaBackend is changed to fetch it via the clutter
context.
This also removed the unused option parsing that existed in clutter.
In some places, NULL checks for fetching the clutter context, or
backend, and fetching the cogl context from the clutter backend, had to
be added.
The reason for this is that some code that handles EGL contexts attempts
to restore the cogl EGL context tracking so that the right EGL context
is used by cogl the next time. This makes no sense to do before Cogl and
Clutter are even initialized, which was the case. It wasn't noticed
because the relevant singletons were initialized on demand via their
"getters".
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-09-16 11:38:49 +02:00
|
|
|
g_assert (ClutterCntx);
|
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
|
|
|
return ClutterCntx;
|
|
|
|
}
|
|
|
|
|
Explicitly create the clutter context and backend
This changes the setup phase of clutter to not be result of calling an
init function that sets up a few global singletons, via global singleton
setup vfuncs.
The way it worked was that mutter first did some initial setup
(connecting to the X11 server), then set a "custom backend" setup vfunc
global, before calling clutter_init().
During the clutter_init() call, the context and backend was setup by
calling the global singleton getters, which implicitly created the
backend and context on-demand.
This has now changed to mutter explicitly creating a `ClutterContext`
(which is actually a `ClutterMainContext`, but with the name shortened to
be consistent with `CoglContext` and `MetaContext`), calling it with a
backend constructor vfunc and user data pointer.
This function now explicitly creates the backend, without having to go
via the previously set global vfunc.
This changes the behavior of some "get_default()" like functions, which
will now fail if called after mutter has shut down, as when it does so,
it now destroys the backends and contexts, not only its own, but the
clutter ones too.
The "ownership" of the clutter backend is also moved to
`ClutterContext`, and MetaBackend is changed to fetch it via the clutter
context.
This also removed the unused option parsing that existed in clutter.
In some places, NULL checks for fetching the clutter context, or
backend, and fetching the cogl context from the clutter backend, had to
be added.
The reason for this is that some code that handles EGL contexts attempts
to restore the cogl EGL context tracking so that the right EGL context
is used by cogl the next time. This makes no sense to do before Cogl and
Clutter are even initialized, which was the case. It wasn't noticed
because the relevant singletons were initialized on demand via their
"getters".
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-09-16 11:38:49 +02:00
|
|
|
static gboolean
|
2021-09-14 16:51:57 +02:00
|
|
|
clutter_init_real (ClutterMainContext *clutter_context,
|
|
|
|
GError **error)
|
2008-09-19 13:22:12 +00:00
|
|
|
{
|
2008-09-23 07:03:35 +00:00
|
|
|
ClutterBackend *backend;
|
2008-09-19 13:22:12 +00:00
|
|
|
|
|
|
|
/* Note, creates backend if not already existing, though parse args will
|
|
|
|
* have likely created it
|
|
|
|
*/
|
2021-09-14 16:51:57 +02:00
|
|
|
backend = clutter_context->backend;
|
2008-09-23 07:03:35 +00:00
|
|
|
|
2021-09-14 16:51:57 +02:00
|
|
|
if (!_clutter_backend_finish_init (backend, error))
|
Explicitly create the clutter context and backend
This changes the setup phase of clutter to not be result of calling an
init function that sets up a few global singletons, via global singleton
setup vfuncs.
The way it worked was that mutter first did some initial setup
(connecting to the X11 server), then set a "custom backend" setup vfunc
global, before calling clutter_init().
During the clutter_init() call, the context and backend was setup by
calling the global singleton getters, which implicitly created the
backend and context on-demand.
This has now changed to mutter explicitly creating a `ClutterContext`
(which is actually a `ClutterMainContext`, but with the name shortened to
be consistent with `CoglContext` and `MetaContext`), calling it with a
backend constructor vfunc and user data pointer.
This function now explicitly creates the backend, without having to go
via the previously set global vfunc.
This changes the behavior of some "get_default()" like functions, which
will now fail if called after mutter has shut down, as when it does so,
it now destroys the backends and contexts, not only its own, but the
clutter ones too.
The "ownership" of the clutter backend is also moved to
`ClutterContext`, and MetaBackend is changed to fetch it via the clutter
context.
This also removed the unused option parsing that existed in clutter.
In some places, NULL checks for fetching the clutter context, or
backend, and fetching the cogl context from the clutter backend, had to
be added.
The reason for this is that some code that handles EGL contexts attempts
to restore the cogl EGL context tracking so that the right EGL context
is used by cogl the next time. This makes no sense to do before Cogl and
Clutter are even initialized, which was the case. It wasn't noticed
because the relevant singletons were initialized on demand via their
"getters".
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-09-16 11:38:49 +02:00
|
|
|
return FALSE;
|
2008-09-23 07:03:35 +00:00
|
|
|
|
2010-09-07 23:07:52 +01:00
|
|
|
/* If we are displaying the regions that would get redrawn with clipped
|
|
|
|
* redraws enabled we actually have to disable the clipped redrawing
|
|
|
|
* because otherwise we end up with nasty trails of rectangles everywhere.
|
|
|
|
*/
|
|
|
|
if (clutter_paint_debug_flags & CLUTTER_DEBUG_REDRAWS)
|
|
|
|
clutter_paint_debug_flags |= CLUTTER_DEBUG_DISABLE_CLIPPED_REDRAWS;
|
|
|
|
|
2010-09-07 18:50:29 +01:00
|
|
|
/* The same is true when drawing the outlines of paint volumes... */
|
|
|
|
if (clutter_paint_debug_flags & CLUTTER_DEBUG_PAINT_VOLUMES)
|
2011-06-16 17:24:26 +01:00
|
|
|
{
|
|
|
|
clutter_paint_debug_flags |=
|
|
|
|
CLUTTER_DEBUG_DISABLE_CLIPPED_REDRAWS | CLUTTER_DEBUG_DISABLE_CULLING;
|
|
|
|
}
|
2010-09-07 18:50:29 +01:00
|
|
|
|
2018-08-10 01:03:54 -03:00
|
|
|
if (clutter_paint_debug_flags & CLUTTER_DEBUG_PAINT_DAMAGE_REGION)
|
|
|
|
g_message ("Enabling damaged region");
|
|
|
|
|
2021-09-17 23:17:24 +02:00
|
|
|
if (!_clutter_backend_create_context (clutter_context->backend, error))
|
Explicitly create the clutter context and backend
This changes the setup phase of clutter to not be result of calling an
init function that sets up a few global singletons, via global singleton
setup vfuncs.
The way it worked was that mutter first did some initial setup
(connecting to the X11 server), then set a "custom backend" setup vfunc
global, before calling clutter_init().
During the clutter_init() call, the context and backend was setup by
calling the global singleton getters, which implicitly created the
backend and context on-demand.
This has now changed to mutter explicitly creating a `ClutterContext`
(which is actually a `ClutterMainContext`, but with the name shortened to
be consistent with `CoglContext` and `MetaContext`), calling it with a
backend constructor vfunc and user data pointer.
This function now explicitly creates the backend, without having to go
via the previously set global vfunc.
This changes the behavior of some "get_default()" like functions, which
will now fail if called after mutter has shut down, as when it does so,
it now destroys the backends and contexts, not only its own, but the
clutter ones too.
The "ownership" of the clutter backend is also moved to
`ClutterContext`, and MetaBackend is changed to fetch it via the clutter
context.
This also removed the unused option parsing that existed in clutter.
In some places, NULL checks for fetching the clutter context, or
backend, and fetching the cogl context from the clutter backend, had to
be added.
The reason for this is that some code that handles EGL contexts attempts
to restore the cogl EGL context tracking so that the right EGL context
is used by cogl the next time. This makes no sense to do before Cogl and
Clutter are even initialized, which was the case. It wasn't noticed
because the relevant singletons were initialized on demand via their
"getters".
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-09-16 11:38:49 +02:00
|
|
|
return FALSE;
|
2008-09-19 13:22:12 +00:00
|
|
|
|
Fully integrates CoglMaterial throughout the rest of Cogl
This glues CoglMaterial in as the fundamental way that Cogl describes how to
fill in geometry.
It adds cogl_set_source (), which is used to set the material which will be
used by all subsequent drawing functions
It adds cogl_set_source_texture as a convenience for setting up a default
material with a single texture layer, and cogl_set_source_color is now also
a convenience for setting up a material with a solid fill.
"drawing functions" include, cogl_rectangle, cogl_texture_rectangle,
cogl_texture_multiple_rectangles, cogl_texture_polygon (though the
cogl_texture_* funcs have been renamed; see below for details),
cogl_path_fill/stroke and cogl_vertex_buffer_draw*.
cogl_texture_rectangle, cogl_texture_multiple_rectangles and
cogl_texture_polygon no longer take a texture handle; instead the current
source material is referenced. The functions have also been renamed to:
cogl_rectangle_with_texture_coords, cogl_rectangles_with_texture_coords
and cogl_polygon respectivly.
Most code that previously did:
cogl_texture_rectangle (tex_handle, x, y,...);
needs to be changed to now do:
cogl_set_source_texture (tex_handle);
cogl_rectangle_with_texture_coords (x, y,....);
In the less likely case where you were blending your source texture with a color
like:
cogl_set_source_color4ub (r,g,b,a); /* where r,g,b,a isn't just white */
cogl_texture_rectangle (tex_handle, x, y,...);
you will need your own material to do that:
mat = cogl_material_new ();
cogl_material_set_color4ub (r,g,b,a);
cogl_material_set_layer (mat, 0, tex_handle));
cogl_set_source_material (mat);
Code that uses the texture coordinates, 0, 0, 1, 1 don't need to use
cog_rectangle_with_texure_coords since these are the coordinates that
cogl_rectangle will use.
For cogl_texture_polygon; as well as dropping the texture handle, the
n_vertices and vertices arguments were transposed for consistency. So
code previously written as:
cogl_texture_polygon (tex_handle, 3, verts, TRUE);
need to be written as:
cogl_set_source_texture (tex_handle);
cogl_polygon (verts, 3, TRUE);
All of the unit tests have been updated to now use the material API and
test-cogl-material has been renamed to test-cogl-multitexture since any
textured quad is now technically a test of CoglMaterial but this test
specifically creates a material with multiple texture layers.
Note: The GLES backend has not been updated yet; that will be done in a
following commit.
2009-01-23 16:15:40 +00:00
|
|
|
clutter_text_direction = clutter_get_text_direction ();
|
|
|
|
|
2008-09-19 13:22:12 +00:00
|
|
|
clutter_is_initialized = TRUE;
|
2021-09-14 16:51:57 +02:00
|
|
|
clutter_context->is_initialized = TRUE;
|
2008-09-19 13:22:12 +00:00
|
|
|
|
2010-04-26 19:33:49 +02:00
|
|
|
/* Initialize a11y */
|
|
|
|
if (clutter_enable_accessibility)
|
|
|
|
cally_accessibility_init ();
|
|
|
|
|
2020-02-23 17:27:08 -08:00
|
|
|
/* Initialize types required for paint nodes */
|
Explicitly create the clutter context and backend
This changes the setup phase of clutter to not be result of calling an
init function that sets up a few global singletons, via global singleton
setup vfuncs.
The way it worked was that mutter first did some initial setup
(connecting to the X11 server), then set a "custom backend" setup vfunc
global, before calling clutter_init().
During the clutter_init() call, the context and backend was setup by
calling the global singleton getters, which implicitly created the
backend and context on-demand.
This has now changed to mutter explicitly creating a `ClutterContext`
(which is actually a `ClutterMainContext`, but with the name shortened to
be consistent with `CoglContext` and `MetaContext`), calling it with a
backend constructor vfunc and user data pointer.
This function now explicitly creates the backend, without having to go
via the previously set global vfunc.
This changes the behavior of some "get_default()" like functions, which
will now fail if called after mutter has shut down, as when it does so,
it now destroys the backends and contexts, not only its own, but the
clutter ones too.
The "ownership" of the clutter backend is also moved to
`ClutterContext`, and MetaBackend is changed to fetch it via the clutter
context.
This also removed the unused option parsing that existed in clutter.
In some places, NULL checks for fetching the clutter context, or
backend, and fetching the cogl context from the clutter backend, had to
be added.
The reason for this is that some code that handles EGL contexts attempts
to restore the cogl EGL context tracking so that the right EGL context
is used by cogl the next time. This makes no sense to do before Cogl and
Clutter are even initialized, which was the case. It wasn't noticed
because the relevant singletons were initialized on demand via their
"getters".
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-09-16 11:38:49 +02:00
|
|
|
clutter_paint_node_init_types (clutter_context->backend);
|
2020-02-23 17:27:08 -08:00
|
|
|
|
Explicitly create the clutter context and backend
This changes the setup phase of clutter to not be result of calling an
init function that sets up a few global singletons, via global singleton
setup vfuncs.
The way it worked was that mutter first did some initial setup
(connecting to the X11 server), then set a "custom backend" setup vfunc
global, before calling clutter_init().
During the clutter_init() call, the context and backend was setup by
calling the global singleton getters, which implicitly created the
backend and context on-demand.
This has now changed to mutter explicitly creating a `ClutterContext`
(which is actually a `ClutterMainContext`, but with the name shortened to
be consistent with `CoglContext` and `MetaContext`), calling it with a
backend constructor vfunc and user data pointer.
This function now explicitly creates the backend, without having to go
via the previously set global vfunc.
This changes the behavior of some "get_default()" like functions, which
will now fail if called after mutter has shut down, as when it does so,
it now destroys the backends and contexts, not only its own, but the
clutter ones too.
The "ownership" of the clutter backend is also moved to
`ClutterContext`, and MetaBackend is changed to fetch it via the clutter
context.
This also removed the unused option parsing that existed in clutter.
In some places, NULL checks for fetching the clutter context, or
backend, and fetching the cogl context from the clutter backend, had to
be added.
The reason for this is that some code that handles EGL contexts attempts
to restore the cogl EGL context tracking so that the right EGL context
is used by cogl the next time. This makes no sense to do before Cogl and
Clutter are even initialized, which was the case. It wasn't noticed
because the relevant singletons were initialized on demand via their
"getters".
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-09-16 11:38:49 +02:00
|
|
|
return TRUE;
|
2008-09-19 13:22:12 +00:00
|
|
|
}
|
|
|
|
|
2021-09-14 16:51:57 +02:00
|
|
|
static void
|
|
|
|
init_clutter_debug (ClutterMainContext *clutter_context)
|
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
|
|
|
{
|
|
|
|
const char *env_string;
|
2006-05-29 08:59:36 +00:00
|
|
|
|
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
|
|
|
#ifdef CLUTTER_ENABLE_DEBUG
|
|
|
|
env_string = g_getenv ("CLUTTER_DEBUG");
|
|
|
|
if (env_string != NULL)
|
|
|
|
{
|
|
|
|
clutter_debug_flags =
|
|
|
|
g_parse_debug_string (env_string,
|
|
|
|
clutter_debug_keys,
|
|
|
|
G_N_ELEMENTS (clutter_debug_keys));
|
|
|
|
env_string = NULL;
|
|
|
|
}
|
|
|
|
#endif /* CLUTTER_ENABLE_DEBUG */
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2010-02-16 20:08:35 +00:00
|
|
|
env_string = g_getenv ("CLUTTER_PICK");
|
|
|
|
if (env_string != NULL)
|
|
|
|
{
|
|
|
|
clutter_pick_debug_flags =
|
|
|
|
g_parse_debug_string (env_string,
|
|
|
|
clutter_pick_debug_keys,
|
|
|
|
G_N_ELEMENTS (clutter_pick_debug_keys));
|
|
|
|
env_string = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
env_string = g_getenv ("CLUTTER_PAINT");
|
|
|
|
if (env_string != NULL)
|
|
|
|
{
|
|
|
|
clutter_paint_debug_flags =
|
|
|
|
g_parse_debug_string (env_string,
|
|
|
|
clutter_paint_debug_keys,
|
|
|
|
G_N_ELEMENTS (clutter_paint_debug_keys));
|
|
|
|
env_string = NULL;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
env_string = g_getenv ("CLUTTER_SHOW_FPS");
|
|
|
|
if (env_string)
|
|
|
|
clutter_show_fps = TRUE;
|
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-02-23 13:08:59 +00:00
|
|
|
env_string = g_getenv ("CLUTTER_DISABLE_MIPMAPPED_TEXT");
|
|
|
|
if (env_string)
|
|
|
|
clutter_disable_mipmap_text = TRUE;
|
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
|
|
|
}
|
|
|
|
|
Explicitly create the clutter context and backend
This changes the setup phase of clutter to not be result of calling an
init function that sets up a few global singletons, via global singleton
setup vfuncs.
The way it worked was that mutter first did some initial setup
(connecting to the X11 server), then set a "custom backend" setup vfunc
global, before calling clutter_init().
During the clutter_init() call, the context and backend was setup by
calling the global singleton getters, which implicitly created the
backend and context on-demand.
This has now changed to mutter explicitly creating a `ClutterContext`
(which is actually a `ClutterMainContext`, but with the name shortened to
be consistent with `CoglContext` and `MetaContext`), calling it with a
backend constructor vfunc and user data pointer.
This function now explicitly creates the backend, without having to go
via the previously set global vfunc.
This changes the behavior of some "get_default()" like functions, which
will now fail if called after mutter has shut down, as when it does so,
it now destroys the backends and contexts, not only its own, but the
clutter ones too.
The "ownership" of the clutter backend is also moved to
`ClutterContext`, and MetaBackend is changed to fetch it via the clutter
context.
This also removed the unused option parsing that existed in clutter.
In some places, NULL checks for fetching the clutter context, or
backend, and fetching the cogl context from the clutter backend, had to
be added.
The reason for this is that some code that handles EGL contexts attempts
to restore the cogl EGL context tracking so that the right EGL context
is used by cogl the next time. This makes no sense to do before Cogl and
Clutter are even initialized, which was the case. It wasn't noticed
because the relevant singletons were initialized on demand via their
"getters".
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-09-16 11:38:49 +02:00
|
|
|
ClutterContext *
|
|
|
|
clutter_context_new (ClutterBackendConstructor backend_constructor,
|
|
|
|
gpointer user_data,
|
|
|
|
GError **error)
|
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
|
|
|
{
|
2021-09-14 16:51:57 +02:00
|
|
|
ClutterMainContext *clutter_context;
|
2008-09-23 07:03:35 +00:00
|
|
|
|
Explicitly create the clutter context and backend
This changes the setup phase of clutter to not be result of calling an
init function that sets up a few global singletons, via global singleton
setup vfuncs.
The way it worked was that mutter first did some initial setup
(connecting to the X11 server), then set a "custom backend" setup vfunc
global, before calling clutter_init().
During the clutter_init() call, the context and backend was setup by
calling the global singleton getters, which implicitly created the
backend and context on-demand.
This has now changed to mutter explicitly creating a `ClutterContext`
(which is actually a `ClutterMainContext`, but with the name shortened to
be consistent with `CoglContext` and `MetaContext`), calling it with a
backend constructor vfunc and user data pointer.
This function now explicitly creates the backend, without having to go
via the previously set global vfunc.
This changes the behavior of some "get_default()" like functions, which
will now fail if called after mutter has shut down, as when it does so,
it now destroys the backends and contexts, not only its own, but the
clutter ones too.
The "ownership" of the clutter backend is also moved to
`ClutterContext`, and MetaBackend is changed to fetch it via the clutter
context.
This also removed the unused option parsing that existed in clutter.
In some places, NULL checks for fetching the clutter context, or
backend, and fetching the cogl context from the clutter backend, had to
be added.
The reason for this is that some code that handles EGL contexts attempts
to restore the cogl EGL context tracking so that the right EGL context
is used by cogl the next time. This makes no sense to do before Cogl and
Clutter are even initialized, which was the case. It wasn't noticed
because the relevant singletons were initialized on demand via their
"getters".
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-09-16 11:38:49 +02:00
|
|
|
if (ClutterCntx)
|
|
|
|
{
|
|
|
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
|
|
"Currently only creating one clutter context is supported");
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-02-20 14:16:54 +00:00
|
|
|
|
Explicitly create the clutter context and backend
This changes the setup phase of clutter to not be result of calling an
init function that sets up a few global singletons, via global singleton
setup vfuncs.
The way it worked was that mutter first did some initial setup
(connecting to the X11 server), then set a "custom backend" setup vfunc
global, before calling clutter_init().
During the clutter_init() call, the context and backend was setup by
calling the global singleton getters, which implicitly created the
backend and context on-demand.
This has now changed to mutter explicitly creating a `ClutterContext`
(which is actually a `ClutterMainContext`, but with the name shortened to
be consistent with `CoglContext` and `MetaContext`), calling it with a
backend constructor vfunc and user data pointer.
This function now explicitly creates the backend, without having to go
via the previously set global vfunc.
This changes the behavior of some "get_default()" like functions, which
will now fail if called after mutter has shut down, as when it does so,
it now destroys the backends and contexts, not only its own, but the
clutter ones too.
The "ownership" of the clutter backend is also moved to
`ClutterContext`, and MetaBackend is changed to fetch it via the clutter
context.
This also removed the unused option parsing that existed in clutter.
In some places, NULL checks for fetching the clutter context, or
backend, and fetching the cogl context from the clutter backend, had to
be added.
The reason for this is that some code that handles EGL contexts attempts
to restore the cogl EGL context tracking so that the right EGL context
is used by cogl the next time. This makes no sense to do before Cogl and
Clutter are even initialized, which was the case. It wasn't noticed
because the relevant singletons were initialized on demand via their
"getters".
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-09-16 11:38:49 +02:00
|
|
|
clutter_graphene_init ();
|
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
|
|
|
|
Explicitly create the clutter context and backend
This changes the setup phase of clutter to not be result of calling an
init function that sets up a few global singletons, via global singleton
setup vfuncs.
The way it worked was that mutter first did some initial setup
(connecting to the X11 server), then set a "custom backend" setup vfunc
global, before calling clutter_init().
During the clutter_init() call, the context and backend was setup by
calling the global singleton getters, which implicitly created the
backend and context on-demand.
This has now changed to mutter explicitly creating a `ClutterContext`
(which is actually a `ClutterMainContext`, but with the name shortened to
be consistent with `CoglContext` and `MetaContext`), calling it with a
backend constructor vfunc and user data pointer.
This function now explicitly creates the backend, without having to go
via the previously set global vfunc.
This changes the behavior of some "get_default()" like functions, which
will now fail if called after mutter has shut down, as when it does so,
it now destroys the backends and contexts, not only its own, but the
clutter ones too.
The "ownership" of the clutter backend is also moved to
`ClutterContext`, and MetaBackend is changed to fetch it via the clutter
context.
This also removed the unused option parsing that existed in clutter.
In some places, NULL checks for fetching the clutter context, or
backend, and fetching the cogl context from the clutter backend, had to
be added.
The reason for this is that some code that handles EGL contexts attempts
to restore the cogl EGL context tracking so that the right EGL context
is used by cogl the next time. This makes no sense to do before Cogl and
Clutter are even initialized, which was the case. It wasn't noticed
because the relevant singletons were initialized on demand via their
"getters".
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-09-16 11:38:49 +02:00
|
|
|
clutter_context = g_new0 (ClutterMainContext, 1);
|
2021-09-14 16:51:57 +02:00
|
|
|
init_clutter_debug (clutter_context);
|
|
|
|
clutter_context->show_fps = clutter_show_fps;
|
Explicitly create the clutter context and backend
This changes the setup phase of clutter to not be result of calling an
init function that sets up a few global singletons, via global singleton
setup vfuncs.
The way it worked was that mutter first did some initial setup
(connecting to the X11 server), then set a "custom backend" setup vfunc
global, before calling clutter_init().
During the clutter_init() call, the context and backend was setup by
calling the global singleton getters, which implicitly created the
backend and context on-demand.
This has now changed to mutter explicitly creating a `ClutterContext`
(which is actually a `ClutterMainContext`, but with the name shortened to
be consistent with `CoglContext` and `MetaContext`), calling it with a
backend constructor vfunc and user data pointer.
This function now explicitly creates the backend, without having to go
via the previously set global vfunc.
This changes the behavior of some "get_default()" like functions, which
will now fail if called after mutter has shut down, as when it does so,
it now destroys the backends and contexts, not only its own, but the
clutter ones too.
The "ownership" of the clutter backend is also moved to
`ClutterContext`, and MetaBackend is changed to fetch it via the clutter
context.
This also removed the unused option parsing that existed in clutter.
In some places, NULL checks for fetching the clutter context, or
backend, and fetching the cogl context from the clutter backend, had to
be added.
The reason for this is that some code that handles EGL contexts attempts
to restore the cogl EGL context tracking so that the right EGL context
is used by cogl the next time. This makes no sense to do before Cogl and
Clutter are even initialized, which was the case. It wasn't noticed
because the relevant singletons were initialized on demand via their
"getters".
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-09-16 11:38:49 +02:00
|
|
|
clutter_context->is_initialized = FALSE;
|
|
|
|
|
|
|
|
clutter_context->backend = backend_constructor (user_data);
|
|
|
|
clutter_context->settings = clutter_settings_get_default ();
|
|
|
|
_clutter_settings_set_backend (clutter_context->settings,
|
|
|
|
clutter_context->backend);
|
|
|
|
|
2023-01-31 10:15:57 +01:00
|
|
|
clutter_context->events_queue =
|
|
|
|
g_async_queue_new_full ((GDestroyNotify) clutter_event_free);
|
Explicitly create the clutter context and backend
This changes the setup phase of clutter to not be result of calling an
init function that sets up a few global singletons, via global singleton
setup vfuncs.
The way it worked was that mutter first did some initial setup
(connecting to the X11 server), then set a "custom backend" setup vfunc
global, before calling clutter_init().
During the clutter_init() call, the context and backend was setup by
calling the global singleton getters, which implicitly created the
backend and context on-demand.
This has now changed to mutter explicitly creating a `ClutterContext`
(which is actually a `ClutterMainContext`, but with the name shortened to
be consistent with `CoglContext` and `MetaContext`), calling it with a
backend constructor vfunc and user data pointer.
This function now explicitly creates the backend, without having to go
via the previously set global vfunc.
This changes the behavior of some "get_default()" like functions, which
will now fail if called after mutter has shut down, as when it does so,
it now destroys the backends and contexts, not only its own, but the
clutter ones too.
The "ownership" of the clutter backend is also moved to
`ClutterContext`, and MetaBackend is changed to fetch it via the clutter
context.
This also removed the unused option parsing that existed in clutter.
In some places, NULL checks for fetching the clutter context, or
backend, and fetching the cogl context from the clutter backend, had to
be added.
The reason for this is that some code that handles EGL contexts attempts
to restore the cogl EGL context tracking so that the right EGL context
is used by cogl the next time. This makes no sense to do before Cogl and
Clutter are even initialized, which was the case. It wasn't noticed
because the relevant singletons were initialized on demand via their
"getters".
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-09-16 11:38:49 +02:00
|
|
|
clutter_context->last_repaint_id = 1;
|
2011-03-04 23:55:02 +00:00
|
|
|
|
Explicitly create the clutter context and backend
This changes the setup phase of clutter to not be result of calling an
init function that sets up a few global singletons, via global singleton
setup vfuncs.
The way it worked was that mutter first did some initial setup
(connecting to the X11 server), then set a "custom backend" setup vfunc
global, before calling clutter_init().
During the clutter_init() call, the context and backend was setup by
calling the global singleton getters, which implicitly created the
backend and context on-demand.
This has now changed to mutter explicitly creating a `ClutterContext`
(which is actually a `ClutterMainContext`, but with the name shortened to
be consistent with `CoglContext` and `MetaContext`), calling it with a
backend constructor vfunc and user data pointer.
This function now explicitly creates the backend, without having to go
via the previously set global vfunc.
This changes the behavior of some "get_default()" like functions, which
will now fail if called after mutter has shut down, as when it does so,
it now destroys the backends and contexts, not only its own, but the
clutter ones too.
The "ownership" of the clutter backend is also moved to
`ClutterContext`, and MetaBackend is changed to fetch it via the clutter
context.
This also removed the unused option parsing that existed in clutter.
In some places, NULL checks for fetching the clutter context, or
backend, and fetching the cogl context from the clutter backend, had to
be added.
The reason for this is that some code that handles EGL contexts attempts
to restore the cogl EGL context tracking so that the right EGL context
is used by cogl the next time. This makes no sense to do before Cogl and
Clutter are even initialized, which was the case. It wasn't noticed
because the relevant singletons were initialized on demand via their
"getters".
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-09-16 11:38:49 +02:00
|
|
|
if (!clutter_init_real (clutter_context, error))
|
2021-10-25 00:18:39 +02:00
|
|
|
{
|
|
|
|
g_free (clutter_context);
|
|
|
|
return NULL;
|
|
|
|
}
|
Explicitly create the clutter context and backend
This changes the setup phase of clutter to not be result of calling an
init function that sets up a few global singletons, via global singleton
setup vfuncs.
The way it worked was that mutter first did some initial setup
(connecting to the X11 server), then set a "custom backend" setup vfunc
global, before calling clutter_init().
During the clutter_init() call, the context and backend was setup by
calling the global singleton getters, which implicitly created the
backend and context on-demand.
This has now changed to mutter explicitly creating a `ClutterContext`
(which is actually a `ClutterMainContext`, but with the name shortened to
be consistent with `CoglContext` and `MetaContext`), calling it with a
backend constructor vfunc and user data pointer.
This function now explicitly creates the backend, without having to go
via the previously set global vfunc.
This changes the behavior of some "get_default()" like functions, which
will now fail if called after mutter has shut down, as when it does so,
it now destroys the backends and contexts, not only its own, but the
clutter ones too.
The "ownership" of the clutter backend is also moved to
`ClutterContext`, and MetaBackend is changed to fetch it via the clutter
context.
This also removed the unused option parsing that existed in clutter.
In some places, NULL checks for fetching the clutter context, or
backend, and fetching the cogl context from the clutter backend, had to
be added.
The reason for this is that some code that handles EGL contexts attempts
to restore the cogl EGL context tracking so that the right EGL context
is used by cogl the next time. This makes no sense to do before Cogl and
Clutter are even initialized, which was the case. It wasn't noticed
because the relevant singletons were initialized on demand via their
"getters".
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-09-16 11:38:49 +02:00
|
|
|
|
|
|
|
ClutterCntx = clutter_context;
|
|
|
|
|
|
|
|
return clutter_context;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
clutter_context_free (ClutterMainContext *clutter_context)
|
|
|
|
{
|
|
|
|
g_clear_pointer (&clutter_context->events_queue, g_async_queue_unref);
|
|
|
|
g_clear_pointer (&clutter_context->backend, clutter_backend_destroy);
|
|
|
|
ClutterCntx = NULL;
|
|
|
|
g_free (clutter_context);
|
|
|
|
}
|
|
|
|
|
|
|
|
ClutterBackend *
|
|
|
|
clutter_context_get_backend (ClutterContext *clutter_context)
|
|
|
|
{
|
|
|
|
return clutter_context->backend;
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
2007-03-23 09:44:21 +00:00
|
|
|
|
|
|
|
gboolean
|
2007-10-02 14:03:36 +00:00
|
|
|
_clutter_boolean_handled_accumulator (GSignalInvocationHint *ihint,
|
|
|
|
GValue *return_accu,
|
|
|
|
const GValue *handler_return,
|
|
|
|
gpointer dummy)
|
2007-03-23 09:44:21 +00:00
|
|
|
{
|
|
|
|
gboolean continue_emission;
|
|
|
|
gboolean signal_handled;
|
2008-02-20 14:16:54 +00:00
|
|
|
|
2007-03-23 09:44:21 +00:00
|
|
|
signal_handled = g_value_get_boolean (handler_return);
|
|
|
|
g_value_set_boolean (return_accu, signal_handled);
|
|
|
|
continue_emission = !signal_handled;
|
2007-04-19 15:27:46 +00:00
|
|
|
|
2007-03-23 09:44:21 +00:00
|
|
|
return continue_emission;
|
|
|
|
}
|
2007-05-16 15:00:41 +00:00
|
|
|
|
2012-06-22 02:38:21 +01:00
|
|
|
gboolean
|
|
|
|
_clutter_boolean_continue_accumulator (GSignalInvocationHint *ihint,
|
|
|
|
GValue *return_accu,
|
|
|
|
const GValue *handler_return,
|
|
|
|
gpointer dummy)
|
|
|
|
{
|
|
|
|
gboolean continue_emission;
|
|
|
|
|
|
|
|
continue_emission = g_value_get_boolean (handler_return);
|
|
|
|
g_value_set_boolean (return_accu, continue_emission);
|
|
|
|
|
|
|
|
return continue_emission;
|
|
|
|
}
|
|
|
|
|
2008-07-01 11:51:20 +00:00
|
|
|
/*
|
|
|
|
* Emits a pointer event after having prepared the event for delivery (setting
|
2021-09-27 21:46:07 +02:00
|
|
|
* source, generating enter/leave etc.).
|
2008-07-01 11:51:20 +00:00
|
|
|
*/
|
|
|
|
|
2008-02-20 14:16:54 +00:00
|
|
|
static inline void
|
2023-08-01 02:23:17 +03:00
|
|
|
emit_event (ClutterStage *stage,
|
|
|
|
ClutterEvent *event)
|
2007-11-16 13:41:07 +00:00
|
|
|
{
|
2023-08-04 12:28:04 +02:00
|
|
|
ClutterEventType event_type;
|
|
|
|
|
|
|
|
event_type = clutter_event_type (event);
|
|
|
|
|
|
|
|
if (event_type == CLUTTER_KEY_PRESS ||
|
|
|
|
event_type == CLUTTER_KEY_RELEASE)
|
2023-08-02 17:53:21 +02:00
|
|
|
cally_snoop_key_event (stage, (ClutterKeyEvent *) event);
|
2020-06-23 16:04:40 +02:00
|
|
|
|
2023-08-01 02:23:17 +03:00
|
|
|
clutter_stage_emit_event (stage, event);
|
2007-11-15 17:30:30 +00:00
|
|
|
}
|
|
|
|
|
2021-06-04 12:06:43 +02:00
|
|
|
static ClutterActor *
|
|
|
|
update_device_for_event (ClutterStage *stage,
|
|
|
|
ClutterEvent *event,
|
|
|
|
gboolean emit_crossing)
|
|
|
|
{
|
|
|
|
ClutterInputDevice *device = clutter_event_get_device (event);
|
2023-02-01 17:37:59 +01:00
|
|
|
ClutterInputDevice *source_device = clutter_event_get_source_device (event);
|
2021-06-04 12:06:43 +02:00
|
|
|
ClutterEventSequence *sequence = clutter_event_get_event_sequence (event);
|
2021-06-25 19:50:26 +02:00
|
|
|
ClutterDeviceUpdateFlags flags = CLUTTER_DEVICE_UPDATE_NONE;
|
2021-06-04 12:06:43 +02:00
|
|
|
graphene_point_t point;
|
|
|
|
uint32_t time_ms;
|
|
|
|
|
|
|
|
clutter_event_get_coords (event, &point.x, &point.y);
|
|
|
|
time_ms = clutter_event_get_time (event);
|
|
|
|
|
2021-06-25 19:50:26 +02:00
|
|
|
if (emit_crossing)
|
|
|
|
flags |= CLUTTER_DEVICE_UPDATE_EMIT_CROSSING;
|
2021-06-04 12:06:43 +02:00
|
|
|
|
2021-06-25 19:50:26 +02:00
|
|
|
return clutter_stage_pick_and_update_device (stage,
|
|
|
|
device,
|
|
|
|
sequence,
|
2023-02-01 17:37:59 +01:00
|
|
|
source_device,
|
2021-06-25 19:50:26 +02:00
|
|
|
flags,
|
|
|
|
point,
|
|
|
|
time_ms);
|
2021-06-04 12:06:43 +02:00
|
|
|
}
|
|
|
|
|
2022-03-29 13:19:24 +02:00
|
|
|
static void
|
2022-11-16 13:22:53 +01:00
|
|
|
maybe_remove_device_for_event (ClutterStage *stage,
|
|
|
|
ClutterEvent *event,
|
|
|
|
gboolean emit_crossing)
|
2022-03-29 13:19:24 +02:00
|
|
|
{
|
|
|
|
ClutterInputDevice *device = clutter_event_get_device (event);
|
|
|
|
ClutterEventSequence *sequence = clutter_event_get_event_sequence (event);
|
|
|
|
graphene_point_t point;
|
|
|
|
uint32_t time;
|
|
|
|
|
2023-08-04 12:28:04 +02:00
|
|
|
if (clutter_event_type (event) == CLUTTER_DEVICE_REMOVED)
|
2022-11-16 13:22:53 +01:00
|
|
|
{
|
|
|
|
ClutterInputDeviceType device_type =
|
|
|
|
clutter_input_device_get_device_type (device);
|
|
|
|
|
|
|
|
if (device_type != CLUTTER_POINTER_DEVICE &&
|
|
|
|
device_type != CLUTTER_TABLET_DEVICE &&
|
|
|
|
device_type != CLUTTER_PEN_DEVICE &&
|
|
|
|
device_type != CLUTTER_ERASER_DEVICE &&
|
|
|
|
device_type != CLUTTER_CURSOR_DEVICE)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-03-29 13:19:24 +02:00
|
|
|
clutter_event_get_coords (event, &point.x, &point.y);
|
|
|
|
time = clutter_event_get_time (event);
|
|
|
|
|
|
|
|
clutter_stage_update_device (stage,
|
|
|
|
device, sequence,
|
2023-02-01 17:37:59 +01:00
|
|
|
NULL,
|
2022-03-29 13:19:24 +02:00
|
|
|
point,
|
|
|
|
time,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
TRUE);
|
|
|
|
|
|
|
|
clutter_stage_remove_device_entry (stage, device, sequence);
|
|
|
|
}
|
|
|
|
|
2008-02-20 14:16:54 +00:00
|
|
|
/**
|
2023-08-01 02:02:15 +03:00
|
|
|
* clutter_stage_handle_event:
|
|
|
|
* @stage: a #ClutterStage.
|
2007-10-03 09:28:16 +00:00
|
|
|
* @event: a #ClutterEvent.
|
|
|
|
*
|
2011-02-03 11:30:10 +00:00
|
|
|
* Processes an event.
|
|
|
|
*
|
|
|
|
* The @event must be a valid #ClutterEvent and have a #ClutterStage
|
|
|
|
* associated to it.
|
|
|
|
*
|
|
|
|
* This function is only useful when embedding Clutter inside another
|
|
|
|
* toolkit, and it should never be called by applications.
|
2007-10-03 09:28:16 +00:00
|
|
|
*/
|
|
|
|
void
|
2023-08-01 02:02:15 +03:00
|
|
|
clutter_stage_handle_event (ClutterStage *stage,
|
|
|
|
ClutterEvent *event)
|
2009-06-06 19:10:41 -04:00
|
|
|
{
|
2022-03-07 15:16:03 +01:00
|
|
|
ClutterContext *context = _clutter_context_get_default();
|
2022-03-05 23:43:29 +01:00
|
|
|
ClutterActor *event_actor = NULL;
|
2023-08-04 12:28:04 +02:00
|
|
|
ClutterEventType event_type;
|
2022-11-16 17:58:48 +01:00
|
|
|
gboolean filtered;
|
2022-03-05 23:43:29 +01:00
|
|
|
|
2023-08-01 02:02:15 +03:00
|
|
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
|
|
|
g_return_if_fail (event != NULL);
|
|
|
|
|
2011-02-03 11:30:10 +00:00
|
|
|
/* stages in destruction do not process events */
|
2023-08-01 02:02:15 +03:00
|
|
|
if (CLUTTER_ACTOR_IN_DESTRUCTION (stage))
|
2009-06-06 19:10:41 -04:00
|
|
|
return;
|
|
|
|
|
2023-08-04 12:28:04 +02:00
|
|
|
event_type = clutter_event_type (event);
|
|
|
|
|
|
|
|
switch (event_type)
|
clutter: Move event filter handling to happen before throttling
As event handling goes:
1) Events get generated and queued by the seat (from another thread in
native, in the same thread in X11)
2) The MetaBackend gets those events and forwards them to Clutter
via clutter_do_event()
3) The events get queued in the ClutterStage
4) At the time of processing a frame, the input events are processed,
5) Motion events are throttled, only the last is effectively handled
6) Events are filtered, wayland and WM handling happens here
7) Events maybe reach to clutter
This commit moves 6 to happen between 2 and 3. The end result is that:
- Throttling only applies to Clutter event handling, The wayland event
forwarding bits will handle the event stream as soon as it comes, as
timely as possible.
- WM event handling is also unthrottled, but that's more of a side
effect.
- This all still happens on the main thread, so there's the possibility
that other busy areas (e.g. relayout) temporarily block this event
forwarding.
- Sending events unthrottled inherently means more CPU, probably
dependent on input devices' frequency. The impact is not measured.
This should bring the best of both worlds with e.g. 1000Hz mice, wayland
clients get unthrottled events, while GNOME Shell UI still behaves like
it used to do.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2020-10-27 19:43:50 +01:00
|
|
|
{
|
2022-02-25 16:19:52 +01:00
|
|
|
case CLUTTER_ENTER:
|
|
|
|
case CLUTTER_MOTION:
|
|
|
|
case CLUTTER_BUTTON_PRESS:
|
|
|
|
case CLUTTER_TOUCH_BEGIN:
|
|
|
|
case CLUTTER_TOUCH_UPDATE:
|
2023-08-21 16:08:07 +02:00
|
|
|
case CLUTTER_TOUCHPAD_PINCH:
|
|
|
|
case CLUTTER_TOUCHPAD_SWIPE:
|
|
|
|
case CLUTTER_TOUCHPAD_HOLD:
|
2023-08-21 16:53:01 +02:00
|
|
|
case CLUTTER_PROXIMITY_IN:
|
2023-08-01 02:02:15 +03:00
|
|
|
update_device_for_event (stage, event, TRUE);
|
2022-02-25 16:19:52 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
clutter: Move event filter handling to happen before throttling
As event handling goes:
1) Events get generated and queued by the seat (from another thread in
native, in the same thread in X11)
2) The MetaBackend gets those events and forwards them to Clutter
via clutter_do_event()
3) The events get queued in the ClutterStage
4) At the time of processing a frame, the input events are processed,
5) Motion events are throttled, only the last is effectively handled
6) Events are filtered, wayland and WM handling happens here
7) Events maybe reach to clutter
This commit moves 6 to happen between 2 and 3. The end result is that:
- Throttling only applies to Clutter event handling, The wayland event
forwarding bits will handle the event stream as soon as it comes, as
timely as possible.
- WM event handling is also unthrottled, but that's more of a side
effect.
- This all still happens on the main thread, so there's the possibility
that other busy areas (e.g. relayout) temporarily block this event
forwarding.
- Sending events unthrottled inherently means more CPU, probably
dependent on input devices' frequency. The impact is not measured.
This should bring the best of both worlds with e.g. 1000Hz mice, wayland
clients get unthrottled events, while GNOME Shell UI still behaves like
it used to do.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2020-10-27 19:43:50 +01:00
|
|
|
}
|
|
|
|
|
2023-08-04 12:28:04 +02:00
|
|
|
if (event_type != CLUTTER_DEVICE_ADDED &&
|
|
|
|
event_type != CLUTTER_DEVICE_REMOVED &&
|
|
|
|
event_type != CLUTTER_NOTHING &&
|
|
|
|
event_type != CLUTTER_EVENT_LAST)
|
2022-03-05 23:43:29 +01:00
|
|
|
{
|
2023-08-01 02:02:15 +03:00
|
|
|
event_actor = clutter_stage_get_event_actor (stage, event);
|
2022-03-05 23:43:29 +01:00
|
|
|
}
|
|
|
|
|
2022-03-07 15:16:03 +01:00
|
|
|
context->current_event = g_slist_prepend (context->current_event, event);
|
|
|
|
|
2022-11-16 17:58:48 +01:00
|
|
|
filtered = _clutter_event_process_filters (event, event_actor);
|
2022-03-29 13:19:24 +02:00
|
|
|
|
2022-11-16 17:58:48 +01:00
|
|
|
context->current_event =
|
|
|
|
g_slist_delete_link (context->current_event, context->current_event);
|
2022-03-07 15:16:03 +01:00
|
|
|
|
2022-08-03 17:57:13 +02:00
|
|
|
if (filtered)
|
|
|
|
{
|
2023-08-04 12:28:04 +02:00
|
|
|
if (event_type == CLUTTER_MOTION ||
|
|
|
|
event_type == CLUTTER_BUTTON_RELEASE ||
|
|
|
|
event_type == CLUTTER_TOUCH_UPDATE ||
|
|
|
|
event_type == CLUTTER_TOUCH_END ||
|
|
|
|
event_type == CLUTTER_TOUCH_CANCEL)
|
2022-08-03 17:57:13 +02:00
|
|
|
{
|
|
|
|
ClutterInputDevice *device = clutter_event_get_device (event);
|
|
|
|
ClutterEventSequence *sequence = clutter_event_get_event_sequence (event);
|
|
|
|
|
2023-08-01 02:02:15 +03:00
|
|
|
clutter_stage_maybe_lost_implicit_grab (stage, device, sequence);
|
2022-08-03 17:57:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-08-01 02:02:15 +03:00
|
|
|
_clutter_stage_queue_event (stage, event, TRUE);
|
2022-08-03 17:57:13 +02:00
|
|
|
}
|
clutter: Process device removing events immediately when they come in
Having the stage device list be responsible for delivering the
same events twice (first immediately to clients, then later to Clutter)
was expected to be tricky, a sneaky problem with it right now is the
following case:
While collecting events for a stage update cycle, we get three touch
events from the backend: TOUCH_BEGIN(seq=1) -> TOUCH_END(seq=1) ->
TOUCH_BEGIN(seq=1)
What we do right now when we see a TOUCH_BEGIN event is adding a device
to the stage right when it comes in from the backend. And when we see
a TOUCH_END, we remove the device from the stage not immediately but
only after it went through the queue.
In the case of the three events mentioned above, with the current
behavior, this will happen when they come in from the backend:
- TOUCH_BEGIN(seq=1): device gets added to the stage with seq 1, event
gets queued
- TOUCH_END(seq=1): Nothing happens, event gets queued
- TOUCH_BEGIN(seq=1): we try to add device to the stage, but seq 1 is
already there, event gets queued
Now when we go through the queue and see the TOUCH_END, the device with
seq 1 gets removed, but on the subsequent TOUCH_BEGIN, we won't add a
new device, so this event (and all events with seq=1 that are still in
the queue) is now ignored by Clutter because it has no device.
What we want to do here is to cut short once the TOUCH_END event comes
in: Process queued events immediately and make sure the device is
removed from the stage list before a new device can be added. Same goes
for any other events that will lead to devices getting removed.
Small note: Since this leads to clutter_stage_get_device_actor()
returning NULL, I was wondering why we never crash because of this:
Turns out _clutter_actor_handle_event() handles self = NULL just fine
without crashing...
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2696>
2022-11-05 21:16:20 +01:00
|
|
|
|
2023-08-04 12:28:04 +02:00
|
|
|
if (event_type == CLUTTER_TOUCH_END ||
|
|
|
|
event_type == CLUTTER_TOUCH_CANCEL ||
|
|
|
|
event_type == CLUTTER_DEVICE_REMOVED)
|
2022-11-16 17:58:48 +01:00
|
|
|
{
|
2023-08-01 02:02:15 +03:00
|
|
|
_clutter_stage_process_queued_events (stage);
|
|
|
|
maybe_remove_device_for_event (stage, event, TRUE);
|
2022-11-16 17:58:48 +01:00
|
|
|
}
|
2009-06-06 19:10:41 -04:00
|
|
|
}
|
|
|
|
|
2009-11-12 17:33:15 -05:00
|
|
|
static void
|
|
|
|
_clutter_process_event_details (ClutterActor *stage,
|
|
|
|
ClutterMainContext *context,
|
|
|
|
ClutterEvent *event)
|
2007-10-03 09:28:16 +00:00
|
|
|
{
|
2023-08-04 12:28:04 +02:00
|
|
|
switch (clutter_event_type (event))
|
2007-10-03 09:28:16 +00:00
|
|
|
{
|
2007-11-16 13:41:07 +00:00
|
|
|
case CLUTTER_NOTHING:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_KEY_PRESS:
|
|
|
|
case CLUTTER_KEY_RELEASE:
|
2016-05-10 16:59:34 +02:00
|
|
|
case CLUTTER_PAD_BUTTON_PRESS:
|
|
|
|
case CLUTTER_PAD_BUTTON_RELEASE:
|
|
|
|
case CLUTTER_PAD_STRIP:
|
|
|
|
case CLUTTER_PAD_RING:
|
2020-02-17 10:43:29 +01:00
|
|
|
case CLUTTER_IM_COMMIT:
|
|
|
|
case CLUTTER_IM_DELETE:
|
|
|
|
case CLUTTER_IM_PREEDIT:
|
2011-01-27 17:26:16 +00:00
|
|
|
case CLUTTER_ENTER:
|
|
|
|
case CLUTTER_LEAVE:
|
2007-11-16 13:41:07 +00:00
|
|
|
case CLUTTER_MOTION:
|
|
|
|
case CLUTTER_BUTTON_PRESS:
|
|
|
|
case CLUTTER_BUTTON_RELEASE:
|
|
|
|
case CLUTTER_SCROLL:
|
2015-05-22 18:30:09 +02:00
|
|
|
case CLUTTER_TOUCHPAD_PINCH:
|
|
|
|
case CLUTTER_TOUCHPAD_SWIPE:
|
2021-04-16 08:57:55 +02:00
|
|
|
case CLUTTER_TOUCHPAD_HOLD:
|
2012-03-19 13:47:19 +00:00
|
|
|
case CLUTTER_TOUCH_UPDATE:
|
2012-07-28 15:36:23 +02:00
|
|
|
case CLUTTER_TOUCH_BEGIN:
|
2012-07-28 15:48:56 +02:00
|
|
|
case CLUTTER_TOUCH_CANCEL:
|
2012-03-19 13:47:19 +00:00
|
|
|
case CLUTTER_TOUCH_END:
|
2015-01-14 14:31:13 +01:00
|
|
|
case CLUTTER_PROXIMITY_IN:
|
|
|
|
case CLUTTER_PROXIMITY_OUT:
|
2023-08-01 02:23:17 +03:00
|
|
|
emit_event (CLUTTER_STAGE (stage), event);
|
2015-01-14 14:31:13 +01:00
|
|
|
break;
|
|
|
|
|
2020-12-14 17:14:59 +01:00
|
|
|
case CLUTTER_DEVICE_REMOVED:
|
clutter: Move event filter handling to happen before throttling
As event handling goes:
1) Events get generated and queued by the seat (from another thread in
native, in the same thread in X11)
2) The MetaBackend gets those events and forwards them to Clutter
via clutter_do_event()
3) The events get queued in the ClutterStage
4) At the time of processing a frame, the input events are processed,
5) Motion events are throttled, only the last is effectively handled
6) Events are filtered, wayland and WM handling happens here
7) Events maybe reach to clutter
This commit moves 6 to happen between 2 and 3. The end result is that:
- Throttling only applies to Clutter event handling, The wayland event
forwarding bits will handle the event stream as soon as it comes, as
timely as possible.
- WM event handling is also unthrottled, but that's more of a side
effect.
- This all still happens on the main thread, so there's the possibility
that other busy areas (e.g. relayout) temporarily block this event
forwarding.
- Sending events unthrottled inherently means more CPU, probably
dependent on input devices' frequency. The impact is not measured.
This should bring the best of both worlds with e.g. 1000Hz mice, wayland
clients get unthrottled events, while GNOME Shell UI still behaves like
it used to do.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2020-10-27 19:43:50 +01:00
|
|
|
case CLUTTER_DEVICE_ADDED:
|
2012-03-19 13:47:19 +00:00
|
|
|
case CLUTTER_EVENT_LAST:
|
|
|
|
break;
|
2007-10-03 09:28:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-10 15:48:43 +01:00
|
|
|
/*
|
2023-08-01 02:21:58 +03:00
|
|
|
* clutter_stage_process_event
|
2009-11-12 17:33:15 -05:00
|
|
|
* @event: a #ClutterEvent.
|
|
|
|
*
|
|
|
|
* Does the actual work of processing an event that was queued earlier
|
2023-08-01 02:02:15 +03:00
|
|
|
* out of clutter_stage_handle_event().
|
2009-11-12 17:33:15 -05:00
|
|
|
*/
|
|
|
|
void
|
2023-08-01 02:21:58 +03:00
|
|
|
clutter_stage_process_event (ClutterStage *stage,
|
|
|
|
ClutterEvent *event)
|
2009-11-12 17:33:15 -05:00
|
|
|
{
|
2010-02-11 15:13:40 +00:00
|
|
|
ClutterMainContext *context;
|
2021-03-10 01:13:34 +01:00
|
|
|
ClutterSeat *seat;
|
2009-11-12 17:33:15 -05:00
|
|
|
|
|
|
|
context = _clutter_context_get_default ();
|
2021-03-10 01:13:34 +01:00
|
|
|
seat = clutter_backend_get_default_seat (context->backend);
|
2009-11-12 17:33:15 -05:00
|
|
|
|
2012-11-16 15:33:00 +00:00
|
|
|
/* push events on a stack, so that we don't need to
|
2012-06-24 09:58:12 +01:00
|
|
|
* add an event parameter to all signals that can be emitted within
|
|
|
|
* an event chain
|
|
|
|
*/
|
2012-11-16 15:33:00 +00:00
|
|
|
context->current_event = g_slist_prepend (context->current_event, event);
|
2012-06-24 09:58:12 +01:00
|
|
|
|
2021-03-10 01:13:34 +01:00
|
|
|
clutter_seat_handle_event_post (seat, event);
|
2023-08-01 02:21:58 +03:00
|
|
|
_clutter_process_event_details (CLUTTER_ACTOR (stage), context, event);
|
2012-06-24 09:58:12 +01:00
|
|
|
|
2012-11-16 15:33:00 +00:00
|
|
|
context->current_event = g_slist_delete_link (context->current_event, context->current_event);
|
2009-11-12 17:33:15 -05:00
|
|
|
}
|
|
|
|
|
2008-10-30 17:11:29 +00:00
|
|
|
/**
|
|
|
|
* clutter_get_font_map:
|
|
|
|
*
|
|
|
|
* Retrieves the #PangoFontMap instance used by Clutter.
|
|
|
|
* You can use the global font map object with the COGL
|
|
|
|
* Pango API.
|
|
|
|
*
|
2009-02-16 19:25:20 -05:00
|
|
|
* Return value: (transfer none): the #PangoFontMap instance. The returned
|
|
|
|
* value is owned by Clutter and it should never be unreferenced.
|
2008-10-30 17:11:29 +00:00
|
|
|
*/
|
|
|
|
PangoFontMap *
|
|
|
|
clutter_get_font_map (void)
|
|
|
|
{
|
2011-02-18 15:47:35 +00:00
|
|
|
return PANGO_FONT_MAP (clutter_context_get_pango_fontmap ());
|
2008-10-30 17:11:29 +00:00
|
|
|
}
|
2009-03-30 13:49:03 +01:00
|
|
|
|
|
|
|
typedef struct _ClutterRepaintFunction
|
|
|
|
{
|
|
|
|
guint id;
|
2012-03-06 12:09:00 +00:00
|
|
|
ClutterRepaintFlags flags;
|
2009-03-30 13:49:03 +01:00
|
|
|
GSourceFunc func;
|
|
|
|
gpointer data;
|
|
|
|
GDestroyNotify notify;
|
|
|
|
} ClutterRepaintFunction;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_threads_remove_repaint_func:
|
|
|
|
* @handle_id: an unsigned integer greater than zero
|
|
|
|
*
|
|
|
|
* Removes the repaint function with @handle_id as its id
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_threads_remove_repaint_func (guint handle_id)
|
|
|
|
{
|
|
|
|
ClutterRepaintFunction *repaint_func;
|
|
|
|
ClutterMainContext *context;
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
g_return_if_fail (handle_id > 0);
|
|
|
|
|
2020-05-23 22:50:43 +02:00
|
|
|
context = _clutter_context_get_default ();
|
2009-03-30 13:49:03 +01:00
|
|
|
l = context->repaint_funcs;
|
|
|
|
while (l != NULL)
|
|
|
|
{
|
|
|
|
repaint_func = l->data;
|
|
|
|
|
|
|
|
if (repaint_func->id == handle_id)
|
|
|
|
{
|
|
|
|
context->repaint_funcs =
|
|
|
|
g_list_remove_link (context->repaint_funcs, l);
|
|
|
|
|
|
|
|
g_list_free (l);
|
|
|
|
|
|
|
|
if (repaint_func->notify)
|
|
|
|
repaint_func->notify (repaint_func->data);
|
|
|
|
|
2020-10-19 19:57:45 +02:00
|
|
|
g_free (repaint_func);
|
2009-03-30 13:49:03 +01:00
|
|
|
|
2011-09-01 17:12:46 +01:00
|
|
|
break;
|
2009-03-30 13:49:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
l = l->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_threads_add_repaint_func:
|
|
|
|
* @func: the function to be called within the paint cycle
|
|
|
|
* @data: data to be passed to the function, or %NULL
|
|
|
|
* @notify: function to be called when removing the repaint
|
|
|
|
* function, or %NULL
|
|
|
|
*
|
2012-03-06 12:09:00 +00:00
|
|
|
* Adds a function to be called whenever Clutter is processing a new
|
|
|
|
* frame.
|
|
|
|
*
|
2009-03-30 13:49:03 +01:00
|
|
|
* If the function returns %FALSE it is automatically removed from the
|
|
|
|
* list of repaint functions and will not be called again.
|
|
|
|
*
|
|
|
|
* This function is guaranteed to be called from within the same thread
|
2012-03-06 12:09:00 +00:00
|
|
|
* that called clutter_main(), and while the Clutter lock is being held;
|
|
|
|
* the function will be called within the main loop, so it is imperative
|
|
|
|
* that it does not block, otherwise the frame time budget may be lost.
|
2009-03-30 13:49:03 +01:00
|
|
|
*
|
|
|
|
* A repaint function is useful to ensure that an update of the scenegraph
|
2019-11-12 19:38:08 +01:00
|
|
|
* is performed before the scenegraph is repainted. By default, a repaint
|
2012-03-06 12:09:00 +00:00
|
|
|
* function added using this function will be invoked prior to the frame
|
|
|
|
* being processed.
|
|
|
|
*
|
|
|
|
* Adding a repaint function does not automatically ensure that a new
|
|
|
|
* frame will be queued.
|
2009-03-30 13:49:03 +01:00
|
|
|
*
|
|
|
|
* When the repaint function is removed (either because it returned %FALSE
|
|
|
|
* or because clutter_threads_remove_repaint_func() has been called) the
|
|
|
|
* @notify function will be called, if any is set.
|
|
|
|
*
|
2012-03-06 12:09:00 +00:00
|
|
|
* See also: clutter_threads_add_repaint_func_full()
|
|
|
|
*
|
2009-03-30 13:49:03 +01:00
|
|
|
* Return value: the ID (greater than 0) of the repaint function. You
|
|
|
|
* can use the returned integer to remove the repaint function by
|
|
|
|
* calling clutter_threads_remove_repaint_func().
|
|
|
|
*/
|
|
|
|
guint
|
|
|
|
clutter_threads_add_repaint_func (GSourceFunc func,
|
|
|
|
gpointer data,
|
|
|
|
GDestroyNotify notify)
|
2012-03-06 12:09:00 +00:00
|
|
|
{
|
|
|
|
return clutter_threads_add_repaint_func_full (CLUTTER_REPAINT_FLAGS_PRE_PAINT,
|
|
|
|
func,
|
|
|
|
data, notify);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_threads_add_repaint_func_full:
|
|
|
|
* @flags: flags for the repaint function
|
|
|
|
* @func: the function to be called within the paint cycle
|
|
|
|
* @data: data to be passed to the function, or %NULL
|
|
|
|
* @notify: function to be called when removing the repaint
|
|
|
|
* function, or %NULL
|
|
|
|
*
|
|
|
|
* Adds a function to be called whenever Clutter is processing a new
|
|
|
|
* frame.
|
|
|
|
*
|
|
|
|
* If the function returns %FALSE it is automatically removed from the
|
|
|
|
* list of repaint functions and will not be called again.
|
|
|
|
*
|
|
|
|
* This function is guaranteed to be called from within the same thread
|
|
|
|
* that called clutter_main(), and while the Clutter lock is being held;
|
|
|
|
* the function will be called within the main loop, so it is imperative
|
|
|
|
* that it does not block, otherwise the frame time budget may be lost.
|
|
|
|
*
|
|
|
|
* A repaint function is useful to ensure that an update of the scenegraph
|
2019-11-12 19:38:08 +01:00
|
|
|
* is performed before the scenegraph is repainted. The @flags passed to this
|
2012-03-06 12:09:00 +00:00
|
|
|
* function will determine the section of the frame processing that will
|
|
|
|
* result in @func being called.
|
|
|
|
*
|
|
|
|
* Adding a repaint function does not automatically ensure that a new
|
|
|
|
* frame will be queued.
|
|
|
|
*
|
|
|
|
* When the repaint function is removed (either because it returned %FALSE
|
|
|
|
* or because clutter_threads_remove_repaint_func() has been called) the
|
|
|
|
* @notify function will be called, if any is set.
|
|
|
|
*
|
|
|
|
* Return value: the ID (greater than 0) of the repaint function. You
|
|
|
|
* can use the returned integer to remove the repaint function by
|
|
|
|
* calling clutter_threads_remove_repaint_func().
|
|
|
|
*/
|
|
|
|
guint
|
|
|
|
clutter_threads_add_repaint_func_full (ClutterRepaintFlags flags,
|
|
|
|
GSourceFunc func,
|
|
|
|
gpointer data,
|
|
|
|
GDestroyNotify notify)
|
2009-03-30 13:49:03 +01:00
|
|
|
{
|
|
|
|
ClutterMainContext *context;
|
|
|
|
ClutterRepaintFunction *repaint_func;
|
|
|
|
|
|
|
|
g_return_val_if_fail (func != NULL, 0);
|
|
|
|
|
2020-05-23 22:50:43 +02:00
|
|
|
context = _clutter_context_get_default ();
|
2009-03-30 13:49:03 +01:00
|
|
|
|
2020-10-19 19:57:45 +02:00
|
|
|
repaint_func = g_new0 (ClutterRepaintFunction, 1);
|
2009-03-30 13:49:03 +01:00
|
|
|
|
2011-09-01 17:12:46 +01:00
|
|
|
repaint_func->id = context->last_repaint_id++;
|
2012-03-06 12:09:00 +00:00
|
|
|
|
2020-05-23 19:51:12 +02:00
|
|
|
repaint_func->flags = flags;
|
2009-03-30 13:49:03 +01:00
|
|
|
repaint_func->func = func;
|
|
|
|
repaint_func->data = data;
|
|
|
|
repaint_func->notify = notify;
|
|
|
|
|
|
|
|
context->repaint_funcs = g_list_prepend (context->repaint_funcs,
|
|
|
|
repaint_func);
|
|
|
|
|
|
|
|
return repaint_func->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* _clutter_run_repaint_functions:
|
2012-03-06 12:09:00 +00:00
|
|
|
* @flags: only run the repaint functions matching the passed flags
|
2009-03-30 13:49:03 +01:00
|
|
|
*
|
|
|
|
* Executes the repaint functions added using the
|
|
|
|
* clutter_threads_add_repaint_func() function.
|
|
|
|
*
|
2012-03-06 12:09:00 +00:00
|
|
|
* Must be called with the Clutter thread lock held.
|
2009-03-30 13:49:03 +01:00
|
|
|
*/
|
|
|
|
void
|
2012-03-06 12:09:00 +00:00
|
|
|
_clutter_run_repaint_functions (ClutterRepaintFlags flags)
|
2009-03-30 13:49:03 +01:00
|
|
|
{
|
2011-02-18 15:47:35 +00:00
|
|
|
ClutterMainContext *context = _clutter_context_get_default ();
|
2009-03-30 13:49:03 +01:00
|
|
|
ClutterRepaintFunction *repaint_func;
|
2011-09-01 17:12:46 +01:00
|
|
|
GList *invoke_list, *reinvoke_list, *l;
|
2009-03-30 13:49:03 +01:00
|
|
|
|
|
|
|
if (context->repaint_funcs == NULL)
|
|
|
|
return;
|
|
|
|
|
2011-09-01 17:12:46 +01:00
|
|
|
/* steal the list */
|
|
|
|
invoke_list = context->repaint_funcs;
|
|
|
|
context->repaint_funcs = NULL;
|
|
|
|
|
2009-03-30 13:49:03 +01:00
|
|
|
reinvoke_list = NULL;
|
|
|
|
|
|
|
|
/* consume the whole list while we execute the functions */
|
2011-09-01 17:12:46 +01:00
|
|
|
while (invoke_list != NULL)
|
2009-03-30 13:49:03 +01:00
|
|
|
{
|
|
|
|
gboolean res = FALSE;
|
|
|
|
|
2011-09-01 17:12:46 +01:00
|
|
|
repaint_func = invoke_list->data;
|
2009-03-30 13:49:03 +01:00
|
|
|
|
2011-09-01 17:12:46 +01:00
|
|
|
l = invoke_list;
|
|
|
|
invoke_list = g_list_remove_link (invoke_list, invoke_list);
|
2009-03-30 13:49:03 +01:00
|
|
|
|
|
|
|
g_list_free (l);
|
|
|
|
|
2012-03-06 12:09:00 +00:00
|
|
|
if ((repaint_func->flags & flags) != 0)
|
|
|
|
res = repaint_func->func (repaint_func->data);
|
|
|
|
else
|
|
|
|
res = TRUE;
|
2009-03-30 13:49:03 +01:00
|
|
|
|
|
|
|
if (res)
|
|
|
|
reinvoke_list = g_list_prepend (reinvoke_list, repaint_func);
|
|
|
|
else
|
|
|
|
{
|
2011-09-01 17:12:46 +01:00
|
|
|
if (repaint_func->notify != NULL)
|
2009-03-30 13:49:03 +01:00
|
|
|
repaint_func->notify (repaint_func->data);
|
|
|
|
|
2020-10-19 19:57:45 +02:00
|
|
|
g_free (repaint_func);
|
2009-03-30 13:49:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-01 17:12:46 +01:00
|
|
|
if (context->repaint_funcs != NULL)
|
|
|
|
{
|
|
|
|
context->repaint_funcs = g_list_concat (context->repaint_funcs,
|
|
|
|
g_list_reverse (reinvoke_list));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
context->repaint_funcs = g_list_reverse (reinvoke_list);
|
2009-03-30 13:49:03 +01:00
|
|
|
}
|
2009-10-30 11:02:35 +00:00
|
|
|
|
2009-12-07 19:00:55 +00:00
|
|
|
/**
|
|
|
|
* clutter_get_default_text_direction:
|
|
|
|
*
|
|
|
|
* Retrieves the default direction for the text. The text direction is
|
2015-03-11 15:39:42 +00:00
|
|
|
* determined by the locale and/or by the `CLUTTER_TEXT_DIRECTION`
|
2011-09-12 13:12:14 +01:00
|
|
|
* environment variable.
|
2009-12-07 19:00:55 +00:00
|
|
|
*
|
|
|
|
* The default text direction can be overridden on a per-actor basis by using
|
2022-05-25 18:41:48 +02:00
|
|
|
* [method@Actor.set_text_direction].
|
2009-12-07 19:00:55 +00:00
|
|
|
*
|
|
|
|
* Return value: the default text direction
|
|
|
|
*/
|
2009-11-06 16:50:53 +00:00
|
|
|
ClutterTextDirection
|
|
|
|
clutter_get_default_text_direction (void)
|
|
|
|
{
|
|
|
|
return clutter_text_direction;
|
|
|
|
}
|
2011-02-09 12:38:10 +00:00
|
|
|
|
|
|
|
/*< private >
|
|
|
|
* clutter_clear_events_queue:
|
|
|
|
*
|
|
|
|
* Clears the events queue stored in the main context.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
_clutter_clear_events_queue (void)
|
|
|
|
{
|
|
|
|
ClutterMainContext *context = _clutter_context_get_default ();
|
2020-08-11 19:01:12 +02:00
|
|
|
ClutterEvent *event;
|
|
|
|
GAsyncQueue *events_queue;
|
2011-02-09 12:38:10 +00:00
|
|
|
|
2020-08-11 19:01:12 +02:00
|
|
|
if (!context->events_queue)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_async_queue_lock (context->events_queue);
|
|
|
|
|
|
|
|
while ((event = g_async_queue_try_pop_unlocked (context->events_queue)))
|
|
|
|
clutter_event_free (event);
|
|
|
|
|
|
|
|
events_queue = context->events_queue;
|
|
|
|
context->events_queue = NULL;
|
|
|
|
|
|
|
|
g_async_queue_unlock (events_queue);
|
|
|
|
g_async_queue_unref (events_queue);
|
2011-02-09 12:38:10 +00:00
|
|
|
}
|
|
|
|
|
2019-03-21 11:49:04 +00:00
|
|
|
/**
|
|
|
|
* clutter_add_debug_flags: (skip)
|
|
|
|
*
|
|
|
|
* Adds the debug flags passed to the list of debug flags.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_add_debug_flags (ClutterDebugFlag debug_flags,
|
|
|
|
ClutterDrawDebugFlag draw_flags,
|
|
|
|
ClutterPickDebugFlag pick_flags)
|
|
|
|
{
|
|
|
|
clutter_debug_flags |= debug_flags;
|
|
|
|
clutter_paint_debug_flags |= draw_flags;
|
|
|
|
clutter_pick_debug_flags |= pick_flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_remove_debug_flags: (skip)
|
|
|
|
*
|
|
|
|
* Removes the debug flags passed from the list of debug flags.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_remove_debug_flags (ClutterDebugFlag debug_flags,
|
|
|
|
ClutterDrawDebugFlag draw_flags,
|
|
|
|
ClutterPickDebugFlag pick_flags)
|
|
|
|
{
|
|
|
|
clutter_debug_flags &= ~debug_flags;
|
|
|
|
clutter_paint_debug_flags &= ~draw_flags;
|
|
|
|
clutter_pick_debug_flags &= ~pick_flags;
|
|
|
|
}
|
|
|
|
|
2020-11-28 22:15:02 +03:00
|
|
|
void
|
|
|
|
clutter_debug_set_max_render_time_constant (int max_render_time_constant_us)
|
|
|
|
{
|
|
|
|
clutter_max_render_time_constant_us = max_render_time_constant_us;
|
|
|
|
}
|
|
|
|
|
2021-05-10 19:57:37 +02:00
|
|
|
void
|
|
|
|
clutter_get_debug_flags (ClutterDebugFlag *debug_flags,
|
|
|
|
ClutterDrawDebugFlag *draw_flags,
|
|
|
|
ClutterPickDebugFlag *pick_flags)
|
|
|
|
{
|
|
|
|
if (debug_flags)
|
|
|
|
*debug_flags = clutter_debug_flags;
|
|
|
|
if (draw_flags)
|
|
|
|
*draw_flags = clutter_paint_debug_flags;
|
|
|
|
if (pick_flags)
|
|
|
|
*pick_flags = clutter_pick_debug_flags;
|
|
|
|
}
|
|
|
|
|
2013-12-12 18:11:03 +00:00
|
|
|
void
|
|
|
|
_clutter_set_sync_to_vblank (gboolean sync_to_vblank)
|
|
|
|
{
|
|
|
|
clutter_sync_to_vblank = !!sync_to_vblank;
|
|
|
|
}
|
|
|
|
|
2011-11-15 17:39:49 +00:00
|
|
|
void
|
|
|
|
_clutter_debug_messagev (const char *format,
|
|
|
|
va_list var_args)
|
|
|
|
{
|
2012-06-07 11:51:33 +01:00
|
|
|
static gint64 last_debug_stamp;
|
2011-11-15 17:39:49 +00:00
|
|
|
gchar *stamp, *fmt;
|
2012-06-07 11:51:33 +01:00
|
|
|
gint64 cur_time, debug_stamp;
|
|
|
|
|
|
|
|
cur_time = g_get_monotonic_time ();
|
|
|
|
|
|
|
|
/* if the last debug message happened less than a second ago, just
|
|
|
|
* show the increments instead of the full timestamp
|
|
|
|
*/
|
|
|
|
if (last_debug_stamp == 0 ||
|
|
|
|
cur_time - last_debug_stamp >= G_USEC_PER_SEC)
|
|
|
|
{
|
|
|
|
debug_stamp = cur_time;
|
|
|
|
last_debug_stamp = debug_stamp;
|
|
|
|
|
|
|
|
stamp = g_strdup_printf ("[%16" G_GINT64_FORMAT "]", debug_stamp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
debug_stamp = cur_time - last_debug_stamp;
|
|
|
|
|
|
|
|
stamp = g_strdup_printf ("[%+16" G_GINT64_FORMAT "]", debug_stamp);
|
|
|
|
}
|
2011-11-15 17:39:49 +00:00
|
|
|
|
|
|
|
fmt = g_strconcat (stamp, ":", format, NULL);
|
|
|
|
g_free (stamp);
|
|
|
|
|
|
|
|
g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, fmt, var_args);
|
|
|
|
|
|
|
|
g_free (fmt);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_clutter_debug_message (const char *format, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
va_start (args, format);
|
|
|
|
_clutter_debug_messagev (format, args);
|
|
|
|
va_end (args);
|
|
|
|
}
|
2011-12-20 15:17:54 +00:00
|
|
|
|
|
|
|
gboolean
|
|
|
|
_clutter_diagnostic_enabled (void)
|
|
|
|
{
|
|
|
|
static const char *clutter_enable_diagnostic = NULL;
|
|
|
|
|
|
|
|
if (G_UNLIKELY (clutter_enable_diagnostic == NULL))
|
|
|
|
{
|
|
|
|
clutter_enable_diagnostic = g_getenv ("CLUTTER_ENABLE_DIAGNOSTIC");
|
|
|
|
|
|
|
|
if (clutter_enable_diagnostic == NULL)
|
|
|
|
clutter_enable_diagnostic = "0";
|
|
|
|
}
|
|
|
|
|
|
|
|
return *clutter_enable_diagnostic != '0';
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_clutter_diagnostic_message (const char *format, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
char *fmt;
|
|
|
|
|
|
|
|
fmt = g_strconcat ("[DIAGNOSTIC]: ", format, NULL);
|
|
|
|
|
|
|
|
va_start (args, format);
|
|
|
|
g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, fmt, args);
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
g_free (fmt);
|
|
|
|
}
|