Commit Graph

385 Commits

Author SHA1 Message Date
Neil Roberts
70292672c4 Add API to install an event filter
This adds clutter_event_add/remove_filter which adds a callback
function which will receive all Clutter events just before the event
signal is emitted for them. The event filter will be invoked
regardless of any grabs or captures. This will be used by Mutter which
wants to access the events at a lower level then the event bubbling
mechanism. It needs to see all mouse motion events even if there is a
grab in place.

https://bugzilla.gnome.org/show_bug.cgi?id=707560
2013-11-14 14:32:17 -05:00
Giovanni Campagna
da3e6988ad Add API to restrict the windowing backend to load
In situations when the default backend would fail (for example
when compiled with X11 support but run without DISPLAY), or
when the application is using backend specific code, it makes
sense to let the application choose the backend explicitly.

https://bugzilla.gnome.org/show_bug.cgi?id=707869
2013-09-11 09:54:35 +02:00
Bastien Nocera
bbb54f1aed clutter: Prefer the X11 backend to the Wayland one
If clutter is built with both X11 and Wayland support, prefer the
(more complete for now) X11 backend. This matches GTK+'s current
ordering.

This allows distributions to ship a clutter version with both backends
built, and using an envvar to switch to the wayland backend and test
applications.

In the future, applications would be able to choose which backend
they prefer and in which order.

https://bugzilla.gnome.org/show_bug.cgi?id=695838
2013-03-14 15:29:00 +01:00
Alejandro Piñeiro
9618f37b1d Add method clutter_disable_accessibility ()
https://bugzilla.gnome.org/show_bug.cgi?id=691468
2013-03-13 18:56:58 +01:00
Emanuele Aina
cea8ea06f3 events: Make _clutter_process_event() reentrant
The _clutter_process_event() function may get called while already
servicing a _clutter_process_event() invocation (eg. when generating
ENTER events before emitting TOUCH_BEGIN).

In these cases clutter_get_current_event() would return NULL after
the inner call to _clutter_process_event() has finished, thereafter
making the current event inaccessible during the remaining portion
of the outer event emission.

By stacking the current events in ClutterMainContext instead of
simply replacing them we do not lose track of the real current event.

Also update clutter_get_current_event_time() to be consistent from a
reentrancy perspective.

https://bugzilla.gnome.org/show_bug.cgi?id=688457
2012-12-18 01:27:32 +00:00
Emmanuele Bassi
1f3e99f886 Put g_type_init() under a version check
GLib 2.36 will deprecate g_type_init() in favour of automatic
initialization through a constructor function. We need to add the
version check to avoid a compiler warning.
2012-12-15 18:44:26 +00:00
Emanuele Aina
f57fc569d2 events: Fix and improve some touch events debug notes 2012-11-26 13:29:36 +01:00
Emanuele Aina
7f0bb8f92e events: Use the correct union field when setting the stage on touch events 2012-11-26 13:29:36 +01:00
Emanuele Aina
318d0d5965 events: Deliver touch events that continue off stage (soft grab)
If a button press happen on stage and the pointer is moved outside
the stage while holding the mouse button, the motion and release
events are still delivered to actors. Do the same X11 soft grab
emulation for touch events.

https://bugzilla.gnome.org/show_bug.cgi?id=685589
2012-10-10 20:34:51 +02:00
Emmanuele Bassi
0da0e5122e main: Do not release the lock if it hasn't been acquired
On various systems, trying to release a mutex that hasn't been acquired
will result in a run-time error.

In order to avoid this, we trylock() the Big Clutter Lock™ and
immediately unlock() it, regardless of the result; if the lock was
already acquired, trylock() will immediately fail, and we can release
it; if the lock was not acquired, trylock() will succeed, and we can
release the lock immediately.

This is necessary to maintain binary compatibility and invariants for
Clutter applications doing:

  clutter_init()
  clutter_threads_enter()
  ...
  clutter_main()
  ...
  clutter_threads_leave()

instead of the correct:

  clutter_init()
  clutter_threads_enter()
  ...
  clutter_threads_leave()
  clutter_main()
  clutter_threads_enter()
  ...
  clutter_threads_leave()

With Clutter ≥ 1.12, the idiomatic form is:

  clutter_init()
  ...
  clutter_main()

given that the public Big Clutter Lock™ acquire/release API has been
deprecated, and nobody should take the lock outside of Clutter itself.

https://bugzilla.gnome.org/show_bug.cgi?id=679439
2012-10-05 17:36:06 +01:00
Emmanuele Bassi
4578a87d1d Add debug note for text direction
It would be nice to have the text direction inside the debug log.
2012-09-19 11:39:41 +01:00
Lionel Landwerlin
d6a0f7eb61 input-device: don't reset a device's stage until all touch points are gone
803b3bafb6 introduced a new issue for
multi touch events.

In the case where 2 touch events for 2 different touch points are
processed in the same iteration, a call to
_clutter_stage_remove_device() when processing the first event will
remove the stage setting of the InputDevice. That means Clutter will
skip the second event, because it can't find a stage to which relate
the event, so no related actor and so no emission.

To fix this we move the _clutter_stage_(add/remove)_device() calls
into the input device. This way the input device can find out exactly
when to call these functions (i.e. when no touch point were previously
active or when no touch point remain active).

https://bugzilla.gnome.org/show_bug.cgi?id=682362
2012-09-03 21:50:24 +01:00
Tomeu Vizoso
d5332d1e4c stage: Remove tracking input devices, it's not used
https://bugzilla.gnome.org/show_bug.cgi?id=683126
2012-09-03 21:50:19 +01:00
Emmanuele Bassi
803b3bafb6 Associate the device to a stage on touch events
Just like we do for crossing events, we need to update the stage pointer
inside ClutterInputDevice on TOUCH_BEGIN and TOUCH_END.

https://bugzilla.gnome.org/show_bug.cgi?id=681074
2012-08-16 11:27:25 +01:00
Lionel Landwerlin
db74b184db events: process CLUTTER_TOUCH_CANCEL
These events might be emitted from the window manager/compositor, they
need to be transmitted to widgets.

https://bugzilla.gnome.org/show_bug.cgi?id=680752
2012-07-29 14:59:13 +02:00
Lionel Landwerlin
86e064597e events: honour clutter_stage_set_motion_events_enabled() for touch events
When dragging/scrolling using touch events, we want the same behaviour
than for motion events. We need to honor the user's calls to
clutter_stage_set_motion_events_enabled() to deactive event
bubbling/captured sequences on the actor located under the pointer and
just transmit events to the stage/grab actor.

https://bugzilla.gnome.org/show_bug.cgi?id=680751
2012-07-29 14:59:08 +02:00
Lionel Landwerlin
9e02ef459e input-device: add enter/leave events generation for touch events
This patch brings 'enter-event' and 'leave-event' generation for touch
based devices. This leads to adding a new API to retrieve coordinates
of a touch point.

https://bugzilla.gnome.org/show_bug.cgi?id=679797
2012-07-17 21:49:26 +01:00
Lionel Landwerlin
e2264c0484 Add rotate action
Allow rotation of an actor using 2 points (touch or pointers) events.

Also refactor the accumulators from various actions.

https://bugzilla.gnome.org/show_bug.cgi?id=678587
2012-07-17 16:52:41 +01:00
Emmanuele Bassi
9b7287e897 actor: Move event chain emission into ClutterActor
By moving the function that builds the event emission chain we can avoid
a bunch of checks and function calls.
2012-07-11 13:22:19 +01:00
Emmanuele Bassi
0e4c6d0a87 Deprecate clutter_threads_enter()/leave()
Acquiring the Clutter lock to mark critical sections is not portable,
and not recommended to implement threaded applications with Clutter.

The recommended pattern is to use worker threads, and schedule UI
updates inside idle or timeout handlers within the main loop. We should
enforce this pattern by deprecating the threads_enter()/leave()
functions. For compatibility concerns, we need internal API to acquire
the main lock during frame processing dispatch.

https://bugzilla.gnome.org/show_bug.cgi?id=679450
2012-07-11 13:22:19 +01:00
Emmanuele Bassi
550168eee3 Clean up deprecated header inclusion
The build should not add deprecated/ into the default INCLUDE paths, so
that deprecated headers are clearly separated; this will make it easier
to get rid of them when we branch out for 2.0.
2012-06-23 08:23:11 +01:00
Lionel Landwerlin
927624d92c input-device: add APIs to grab sequences of touch events
https://bugzilla.gnome.org/show_bug.cgi?id=678279
2012-06-22 21:48:58 +01:00
Evan Nemerson
252eafa520 introspection: assorted annotation fixes ported from Vala
https://bugzilla.gnome.org/show_bug.cgi?id=677778
2012-06-12 17:44:16 -07:00
Emmanuele Bassi
42b933eeaf debug: Group debug messages by timestamps
Instead of showing the full timestamp for debugging messages that happen
within a second, showing the delta from the previous full timestamp can
be more useful when debugging; this allows immediately seeing the time
difference, instead of doing the math in our heads.
2012-06-07 11:57:53 +01:00
Tomeu Vizoso
0ec01a2e42 events: Deliver touch events to actors
https://bugzilla.gnome.org/show_bug.cgi?id=677390
2012-06-05 15:59:52 +02:00
Emmanuele Bassi
07c95ebf0c Move examples from tests/interactive to a new top-level
The example code that is meant to be XIncluded into the API reference
should not be part of the interactive test suite: it's code that it is
meant to be used as a reference implementation - whereas the interactive
test suite should be allowed to be lean and test behaviour even in nasty
ways. In short: the test suite should not be the place where we show off
idiomatic code for educational purposes.
2012-05-01 19:00:35 +01:00
Emmanuele Bassi
0dd74ca3fb docs: Annotation fixes
The introspection scanner has become slightly more annoying, in the hope
that people start fixing their annotations. As it turns out, it was the
right move.
2012-04-30 17:17:41 +01:00
Emmanuele Bassi
26d8ad7479 Be resilient in case there is no device manager
It's possible to run Clutter with the 'null' input backend, which means
that clutter_device_manager_get_default() may return NULL. In the future
we may add a default dummy device manager, but right now it's safer to
just add a simple NULL check in the places where we ask for the device
manager.
2012-04-26 13:56:00 +01:00
Emmanuele Bassi
d15b828cc5 event: Add ClutterTouchEvent
The ClutterTouchEvent structure contains the data relative to a touch
event.
2012-03-19 14:29:24 +00:00
Emmanuele Bassi
2567049ce3 Fix missing/redundant declarations 2012-03-07 12:36:43 +00:00
Emmanuele Bassi
229607464b Improve repaint functions
It is sometimes useful to be able to have better control on when a
repaint function is called. Currently, all repaint functions are called
prior to the stages update phase of the frame processing.

We can introduce flags to represent the point in the frame update
process in which we wish Clutter called the repaint function.

As a bonus, we can also add a flag that causes adding a repaint function
to spin the master clock.
2012-03-06 12:09:00 +00:00
Emmanuele Bassi
7d4a9c6f1e Add diagnostic mode
GLib has a "diagnostic mode" switch that can be checked to enable debug
messages on deprecated properties and signals, as these are purely
run-time constructs, and as such cannot be caught by compiler warnings.
The diagnostic mode is toggled by a simple environment variable, and
can be used to ease porting of application code.

We can use something similar to mark deprecated virtual functions and
other run-time constructs; to avoid collisions, we should use our own
environment variable, CLUTTER_ENABLE_DIAGNOSTIC.
2011-12-28 09:37:53 +00:00
Jasper St. Pierre
f7bb1e879e main: Fix keyboard event emission for non-reactive actors
This is an innocent copy-paste issue that ended up breaking a few things

https://bugzilla.gnome.org/show_bug.cgi?id=664582
2011-12-01 13:05:22 -05:00
Neil Roberts
c687ece72d Fix building with profiling enabled
There was an #ifdef'd section of code for profiling that was using the
wrong variable name so it would not build.

Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
2011-11-28 16:27:57 +00:00
Emmanuele Bassi
8a4dc3c011 debug: Clean up profile/debug symbols
Since we have a _clutter_debug_message() function compiled in
unconditionally we have no further need for the equivalent conditional
version defined in clutter-profile.[ch]: we can simply do the work in
one function.
2011-11-18 17:44:42 +00:00
Emmanuele Bassi
2d76407016 debug: Remove CLUTTER_MARK
The debug macro is seldom used, and it's a bit lame at that.
2011-11-18 17:30:39 +00:00
Emmanuele Bassi
bf9339b8f4 Deprecate some more old, useless API
We still ship clutter_get_show_fps() and clutter_get_debug_enabled() as
public entry points. Yet another case of missing API review prior to the
1.0 release, so really the bucket stops around my desk.

Let's deprecate these two useless functions, and reduce the API
footprint of Clutter.
2011-11-15 17:58:25 +00:00
Emmanuele Bassi
66d46fd55e Deprecate clutter_get_timestamp()
This function should have never been made public in the first place; its
output depends on a configuration option of Clutter, and it's basically
useful only for internal debugging.
2011-11-15 17:47:00 +00:00
Emmanuele Bassi
59f395d856 Rework debug output
Make it consistent across the various build options (with or without
profiling enabled), and add a timestamp using the monotonic clock to
every debug message.
2011-11-15 17:39:49 +00:00
Emmanuele Bassi
c6e487a5c1 Remove CLUTTER_TIMESTAMP debug macro
It's pretty much unused, and it doesn't print out really informative
messages. We should make CLUTTER_NOTE print out a decent timestamp
instead.
2011-11-15 16:07:13 +00:00
Emmanuele Bassi
8b2df7ced9 Remove the GTimer used by clutter_get_timestamp()
Use g_get_monotonic_time() instead, which does the right thing.
2011-11-15 15:34:51 +00:00
Emmanuele Bassi
e8562089f6 main: Add a sync-to-vblank global flag
It replaces the per-backend CLUTTER_VBLANK environment variable.
2011-11-10 14:55:02 +00:00
Emmanuele Bassi
7b5e5b7727 main: Add a debug note when reading the settings file
So that's easier to track in the debug log.
2011-11-09 09:09:37 +00:00
Emmanuele Bassi
67d5a4993c main: Deprecate clutter_set_default_frame_rate()
Setting the default frame rate does not do anything even remotely
useful, unless synchronization to the vertical refresh rate is also
disabled - which can only be done through environment variable or
through configuration file. Having a programmatic way to change the
default frame rate is, thus, completely pointless.

Changing the default frame rate through environment variable and
configuration file is still allowed.
2011-11-07 20:31:15 +00:00
Emmanuele Bassi
8249e48802 Clean up the windowing system defines
Instead of defining new symbols for the windowing systems enabled at
configure time, we can reuse the same symbols for both the compile time
and run time checks, e.g.:

  #ifdef CLUTTER_WINDOWING_X11
    if (clutter_check_windowing_backend (CLUTTER_WINDOWING_X11))
      /* use the clutter_x11_* API */
    else
  #endif
  #ifdef CLUTTER_WINDOWING_WIN32
    if (clutter_check_windowing_backend (CLUTTER_WINDOWING_WIN32))
      /* use the clutter_win32_* API */
  #endif

This scheme allows us to ensure that the input system namespace is free
for us to use and select at run time in later versions of Clutter.
2011-11-03 13:45:20 +00:00
Emmanuele Bassi
98c177def5 Clean up the backend creation
Move it to its own function.
2011-11-03 13:45:20 +00:00
Emmanuele Bassi
405e72f2e4 egl: First attempt at cleaning up the EGL native backend
At least, let's make it compile when built along with the other
backends. In reality, it still needs to be verified as working.
2011-11-03 13:45:20 +00:00
Emmanuele Bassi
21a24c862e Allow checking the backend type at run-time
Portable code should be allowed to check type backend currently being
used, so that it can use platform-specific API (not just Clutter's).

We don't want to go down the GDK route, with public types for
ClutterBackend and ClutterStageWindow implementations, and use the type
system, e.g.:

  #ifdef GDK_WINDOWING_X11
    if (GDK_IS_WINDOW_X11 (window))
      use_x11_api (window);
    else
  #endif
  #ifdef GDK_WINDOWING_WIN32
    if (GDK_IS_WINDOW_WIN32 (window))
      use_win32_api (window);
    else
  #endif
    g_critical ("Unsupported backend");

This system would make us expose the backend system, and we want to
still reserve us the option to change the backend system to increase its
granularity — e.g. choosing different input event systems regardless of
the windowing system.

This commit adds a simple function that checks the backend type against
a symbolic constant — the same constant string that can be used to
select the backend at run-time through the CLUTTER_BACKEND environment
variable.
2011-11-03 13:45:19 +00:00
Emmanuele Bassi
a09bbffd92 Implement multi-backend support
The Clutter backend split is opaque enough that should allow us to just
build all possible backends inside the same shared object, and select
the wanted backend at initialization time.

This requires some work in the build system, as well as the
initialization code, to remove duplicate functions that might cause
conflicts at build and link time. We also need to defer all the checks
of the internal state of the platform-specific API to run-time type
checks.
2011-11-03 13:45:19 +00:00
Chun-wei Fan
8c196c9403 Bug 662071-[Win32]-Don't init the Big Clutter Lock
Since the Windows GUI system is assuming multithreadedness, initializing
locks after entering the GUI portion on Windows is likely to cause
problems[1][2], which results many Clutter programs to crash due to
releasing resources that they did not own.

[1]: Multi-threaded use of GTK+ on Win32 in README.win32 of GTK+
     source package
[2]: Explanation of Windows GUI system regarding its multithreadness
     assumptions-
     http://mail.gnome.org/archives/gtk-list/2011-June/msg00005.html
2011-10-25 01:27:51 +08:00