In the future, we want event translators to be the way to handle events
in backends. For this reason, they should be a part of the base abstract
ClutterBackend class, and not an X11-only concept.
Use both the MappingNotify event and the XKB XkbMapNotify event, if
we're compiled with XKB support.
This change is also useful for making ClutterKeymapX11 an event
translator and let it deal with XKB events internally like we do for
stage and input events.
Based on a patch by: Damien Lespiau <damien.lespiau@intel.com>
Signed-off by: Emmanuele Bassi <ebassi@linux.intel.com>
http://bugzilla.clutter-project.org/show_bug.cgi?id=2525
Since we need to find the stage from the X11 Window, it's better to use
a static hashmap that gets updated every time the ClutterStageX11:xwin
member is changed, instead of iterating over every stage handled by the
global ClutterStageManager singleton.
Clutter should just require that the windowing system used by a backend
adds a device to the stage when the device enters, and removes it from
the stage when the device leaves; with this information, we can
synthesize every crossing event and update the device state without
other intervention from the backend-specific code.
The generation of additional crossing events for actors that are
covering the stage at the coordinates of the crossing event should be
delegated to the event processing code.
The x11 and win32 backends need to be modified to relay the enter and
leave events from the windowing system.
Since we access it in order to get the X11 Display pointer, it makes
sense to have the ClutterBackendX11 already available inside the
ClutterStageX11 structure, and avoid the pattern:
ClutterBackend *backend = clutter_get_default_backend ();
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
which costs us a function call, a type cast and an unused variable.
When we receive a ConfigureNotify event that doesn't affect the size
of the window (only the position) then we were still calling
clutter_stage_ensure_viewport which ends up queueing a full stage
redraw. This patch makes it so that it only ensures the viewport when
the size changes as it already did for avoiding queueing a relayout.
It now also avoids setting the clipped redraws cool off period when
the window only moves under the assumption that it's only necessary
for size changes.
Since the XI2 device manager code is going to be compiled only on
POSIX compliant systems, we can safely assume the presence of stdint.h
and include it unconditionally.
Hierarchy and Device changed events come through with the X window set
to be the root window, not the stage window. We need to whitelist them
so that we can actually support hotplugging and device changes.
The x11 backend exposes a lot of symbols that are meant to only be used
when implementing a subclassed backend, like the glx and eglx ones.
The uninstalled headers are also filled with cruft declarations of
functions long since removed.
Let's try to clean up this mess.
Slave and floating devices should always be disabled, and not deliver
events to the scene. It is up to the user to enable non-master devices
and handle events coming from them.
ClutterInputDevice gets a new :enabled property, defaulting to FALSE;
when a device manager creates a new device it has to set it to TRUE if
the :device-mode property is set to CLUTTER_INPUT_MODE_MASTER.
The main event queue entry point, _clutter_event_push(), will
automatically discard events coming from disabled devices.
Undeprecate the XInput-related X11 API: since we don't enable XI support
by default we still need to ask for it, and see if we have it after the
backend initialization sequence.
Event translation is now done where it belongs: we don't need a massive
switch in a file with direct access to private structure members.
So long, event_translate(); and thanks for all the fish.
We ask XI2 to get the client pointer for CLUTTER_POINTER_DEVICE, and
we use the attached keyboard device for CLUTTER_KEYBOARD_DEVICE. For
everything else, we return NULL.
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
ClutterX11TexturePixmap watches for configure events to tell when it
needs to name a new pixmap for the window. However, ConfigureEvents
occur on moves in addition to resizes, and doing round trips and
naming new pixmaps every time a window is moved is a real performance
killer.
Add clutter_x11_texture_pixmap_sync_window_internal() that takes the
size/position of the window as arguments rather than always calling
XGetWindowAttributes. This allows us to bypass all work other than
notifying the window-x/window-y properties when we get a ConfigurEvent
for a move.
The last received width/height is saved to allow us to also omit
XGetWindowAttributes on MapNotify events.
The public clutter_x11_texture_pixmap_sync_window() becomes a bit less
efficient since we no longer combine the roundtrips for
XGetWindowAttributes() and XCompositeNameWindowPixmap(), but it appears
to have no callers in current publicly available code.
Several FIXME's are added for areas where there are still weird things
going on in the code or improvements could be made.
http://bugzilla.clutter-project.org/show_bug.cgi?id=2356
When we handle Expose events we try and queue a clipped redraw of the
stage, but for some reason we were also redundantly calling
clutter_actor_queue_redraw for the stage which would negate the request
to queue a clipped redraw.
The "watch" function functionality in xsettings-client.c is designed
for setups like GDK where filters are per-window. If we are going
to pass all events to _clutter_xsettings_client_process_event()
anyways, we can just pass in NULL for watch.
This avoids a nasty infinite loop where an event would get processed
triggering removing a filter and adding a new filter, which would
immediately run and remove a filter and add another and so on
ad-infinitum.
http://bugzilla.clutter-project.org/show_bug.cgi?id=2415
* private-cleanup:
Add copyright notices
Clean up clutter-private.h/6
Clean up clutter-private.h/5
Clean up clutter-private.h/4
Clean up clutter-private.h/3
Clean up clutter-private.h/2
Clean up clutter-private.h/1
There was an array whose length was define by a static const int
variable. GCC seems to consider this a variable-length array so it
will cause warnings now that -Wvla is enabled. We might as well make
this constant a #define instead to avoid the warning.
Move the private Backend API to a separate header.
This also allows us to finally move the class vtable and instance
structure to a separate file and plug the visibility hole that left
the Backend class bare for everyone to poke into.