Commit Graph

67 Commits

Author SHA1 Message Date
Rui Matos
e70a0109f2 Avoid needless event copies when queueing from a backend to a stage
All backends follow the same pattern of queueing events first in
ClutterMainContext, then copying them to a ClutterStage queue and
immediately free them. Instead, we can just pass ownership of events
directly to ClutterStage thus avoiding the allocation and copy in
between.

https://bugzilla.gnome.org/show_bug.cgi?id=711857
2014-03-15 19:44:57 +00:00
Jasper St. Pierre
dcaf5686a2 evdev: Always create the main seat
There could be times when we may not necessarily see a device appear
at initialization time, like when we're VT switched away when we
initialize, and thus we can't ever rely on a main seat appearing.

Always create a main seat with logical pointer/keyboard devices, and
tie the first physical seat that comes in to the main seat.

https://bugzilla.gnome.org/show_bug.cgi?id=726199
2014-03-13 12:46:28 -04:00
Jasper St. Pierre
defe55ff09 evdev: Extract code for setting the libinput seat out
We're going to create the main seat at an earlier time, when
we don't have the physical libinput_seat yet, so we need to
do the association later.

https://bugzilla.gnome.org/show_bug.cgi?id=726199
2014-03-13 12:46:28 -04:00
Jasper St. Pierre
5facd710c8 evdev: Set the initial pointer position for all pointer devices
Rather than just those on the main seat.

https://bugzilla.gnome.org/show_bug.cgi?id=726199
2014-03-13 12:46:27 -04:00
Jasper St. Pierre
e23f77f1e6 evdev: Extend the device open callback with a close callback as well
We need to return the device to logind with ReleaseDevice().

https://bugzilla.gnome.org/show_bug.cgi?id=726199
2014-03-13 12:46:27 -04:00
Jasper St. Pierre
9b097eb4d8 device-manager-evdev: Make sure to reset released when reclaiming devices
Otherwise, Clutter will tell us that we forgot to call reclaim_devices
the next time we call release_devices... but we didn't!
2014-03-03 11:57:58 -05:00
Jasper St. Pierre
fdd553d2a9 evdev: Kill compile warning 2014-02-28 09:50:36 -05:00
Rui Matos
2c9a4fd220 evdev: Add missing 'Since' and 'Stability' doc tags 2014-02-27 11:31:34 +01:00
Rui Matos
458de1178d evdev: Set the initial core pointer coordinates to a sane value
ClutterInputDevice's default initial coordinates is (-1, -1) and since
they're updated from events in a relative way it means that the
pointer can go outside the stage right from the first event.

We usually let this up to higher layers to fix through the pointer
constraint callback but that doesn't work if the first event doesn't
put the pointer immediately inside the stage.

https://bugzilla.gnome.org/show_bug.cgi?id=725103
2014-02-27 11:31:33 +01:00
Rui Matos
d67b38f960 evdev: Make the keymap available
Make the keymap available so that consumers don't have to duplicate it
if they need it.

https://bugzilla.gnome.org/show_bug.cgi?id=725102
2014-02-27 11:31:33 +01:00
Rui Matos
2a7d5503d8 evdev: Don't update xkb state with pressed keys on keymap change
Doing so is unlikely to work reliably. Instead, switching the keymap
should be done at a time when no key is currently pressed down, but
let's leave that task to higher level code.

This allows us to remove key state tracking at yet another level in
the stack since higher level code likely already tracks this for other
purposes.

https://bugzilla.gnome.org/show_bug.cgi?id=725102
2014-02-27 10:59:16 +01:00
Rui Matos
945ee5764a evdev: Keep latched and locked modifier state when switching keymaps
https://bugzilla.gnome.org/show_bug.cgi?id=725102
2014-02-27 10:59:15 +01:00
Rui Matos
a6bd53ec42 evdev: Implement keyboard repeat
The kernel keyboard repeat functionality isn't configurable and
libinput rightfully ignores it.

This implements keyboard repeat in userspace allowing for consumers to
set the initial delay and repeat intervals.

https://bugzilla.gnome.org/show_bug.cgi?id=725102
2014-02-27 10:59:15 +01:00
Jonas Ådahl
dacb515e27 evdev: Port evdev input backend to libinput
Instead of having its own evdev input device processing implementation,
make clutter's evdev backend use libinput to do input device processing
for it.

Two GObject parameters of ClutterInputDeviceEvdev (sysfs-path and
device-path) are removed as they are not used any more.

Before ClutterDeviceManagerEvdev had one virtual core keyboard and one
virtual core pointer device. These are now instead separated into seats,
which all have one virtual core keyboard and pointer device respectively.

The 'global' core keyboard and pointer device are the core keyboard and
pointer device of the first seat that is created.

A ClutterInputDeviceEvdev can, as before, both represent a real physical
device or a virtual device, but is now instead created either via
_clutter_input_device_evdev_new() for real devices, and
_clutter_input_device_new_virtual() for virtual devices.

XKB state and button state is moved to the seat structure and is thus
separated per seat. Seats are not a concept exposed outside of clutter's
evdev backend.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>

https://bugzilla.gnome.org/show_bug.cgi?id=720566
2014-02-27 09:57:29 +01:00
Rui Matos
3cd9a70fea device-manager-evdev: Stop using deprecated libevdev API
Fixes compiler warnings with libevdev >= 0.4 and makes use of a new
function to set the clock id instead of doing the ioctl directly.

https://bugzilla.gnome.org/show_bug.cgi?id=712816
2013-11-21 19:34:15 +01:00
Rui Matos
05e6bcc666 device-manager-evdev: Fix a segfault on device removal
Master devices have a NULL sysfs path so use g_strcmp0 to handle them
without crashing.

https://bugzilla.gnome.org/show_bug.cgi?id=712812
2013-11-21 19:34:14 +01:00
Rui Matos
7d8f72a60e device-manager-evdev: Unref devices on removal
https://bugzilla.gnome.org/show_bug.cgi?id=712812
2013-11-21 19:34:14 +01:00
Emmanuele Bassi
a1d29abc38 evdev: Clean up debug and error messages
https://bugzilla.gnome.org/show_bug.cgi?id=707901
2013-09-19 22:51:52 +01:00
Emmanuele Bassi
9eb479aeef evdev: Cache the regexp
Instead of recreating it for every new device, we can cache the GRegex
and reuse it.

https://bugzilla.gnome.org/show_bug.cgi?id=707901
2013-09-19 22:51:52 +01:00
Giovanni Campagna
b29115e883 evdev: fix a crash when reclaiming devices
That was not how you iterate a list!

https://bugzilla.gnome.org/show_bug.cgi?id=707901
2013-09-16 00:18:01 +02:00
Giovanni Campagna
89cd3112fe evdev: add minimal support for touchpads
The added support is very very basic (single touch, motion only,
no acceleration, no pressure recognition), but anything more
complex requires a state machine that will be hopefully provided
by libinputcommon in the future.
And at least, with this patch the pointer moves, which will be
useful for people testing wayland in 3.10 without a physical mouse.

https://bugzilla.gnome.org/show_bug.cgi?id=706494
2013-09-12 09:50:12 +02:00
Giovanni Campagna
d4ddabeaad evdev: remove keyboard state accessor
It was a bad idea to add it, because clutter events are batched,
so by the time the application processes one, the keyboard state
internally tracked by clutter could be already different.
Instead, apps should use clutter_event_get_state_full()

https://bugzilla.gnome.org/show_bug.cgi?id=706494
2013-09-09 18:02:04 +02:00
Giovanni Campagna
15d036ea1e evdev: use EV_SYN/SYN_REPORT for dispatching motion events
We can't dispatch a motion event for EV_REL (because we don't
have yet the other half of the event), but we can't also queue
them at the end of processing (because we may lose some history
or have button/keys intermixed).
Instead, we use EV_SYN, which means "one logical event was
completed", and let the winsys-independent code do the actual
motion compression.

https://bugzilla.gnome.org/show_bug.cgi?id=706494
2013-09-09 13:24:23 +02:00
Giovanni Campagna
5e005b4298 evdev: implement horizontal scrolling
If the kernel reports REL_HWHELL, convert it to horizontal
scroll events.
Also reorganize a bit the recognition for the other event
enums.

https://bugzilla.gnome.org/show_bug.cgi?id=706494
2013-09-09 13:24:23 +02:00
Giovanni Campagna
d882366d11 evdev: implement setting leds
When the leds are changed in the keyboard state, propagate the
change to the actual devices.

https://bugzilla.gnome.org/show_bug.cgi?id=706494
2013-09-09 13:24:23 +02:00
Giovanni Campagna
cd1749a2a5 evdev: switch to libevdev for fetching the events
libevdev is a library that wraps the evdev subsystem, with
the ability to synchronize the state after a SYN_DROPPED event
from the kernel.

https://bugzilla.gnome.org/show_bug.cgi?id=706494
2013-09-09 13:24:19 +02:00
Giovanni Campagna
19536c8835 evdev: sync the keyboard state when releasing and reclaiming devices
When we release a device, we lose all the events after that point,
so our state can become stale. Similarly, we need to sync the
state with the effectively pressed keys when we reclaim.
This ensures that modifier keys don't get stuck when switching
VTs using a keybinding.

https://bugzilla.gnome.org/show_bug.cgi?id=706494
2013-09-09 13:18:27 +02:00
Giovanni Campagna
59f1e531f9 ClutterEvent: add API to query the full keyboard state when the event was generated
When talking to other applications or serializing the modifier
state (and in particular when implementing a wayland compositor),
the effective modifier state alone is not sufficient, one needs
to know the base, latched and locked modifiers.

Previously one could do with backend specific functionality
such as clutter_device_manager_evdev_get_xkb_state(), but the
problem is that the internal data structures are updated as
soon as the events are fetched from the upstream source, but
the events are reported to the application some time later,
and thus the two can get out of sync.
This way, on the other hand, the information is cached in the
event, and provided to the application with the value that
was current when the event was generated.

https://bugzilla.gnome.org/show_bug.cgi?id=706494
2013-09-09 13:18:23 +02:00
Giovanni Campagna
dd940a71b1 evdev: update the state of the core pointer and core keyboard for all events
These two devices are logically tied togheter, and their state
should always be the same. Also, we need to update them after
the event is queued, as the current modifier state (as opposed to the
modifier mask in the event) should include also the effect of the last
key press/release.

https://bugzilla.gnome.org/show_bug.cgi?id=706494
2013-09-09 13:18:23 +02:00
Giovanni Campagna
b73f513091 evdev: use monotonic times for the events
The monotonic clock is what X uses too, so this way the timestamps
can be compared.

https://bugzilla.gnome.org/show_bug.cgi?id=706543
2013-09-09 12:02:25 +02:00
Giovanni Campagna
aef3d0022c evdev: add callback to constrain the pointer position
Add a new callback that is called prior to emitting pointer
motion events and that can modify the new pointer position.
The main purpose is allowing multiscreen apps to prevent the
pointer for entering the dead area that exists when the screens
are not the same size, but it could also used to implement
pointer barriers.
A callback is needed to make sure that the hook is called early
enough and the Clutter state is always consistent.

https://bugzilla.gnome.org/show_bug.cgi?id=706652
2013-09-09 12:00:52 +02:00
Emmanuele Bassi
0d7bbc747f docs: Fix gtk-doc warnings 2013-08-19 23:30:09 +01:00
Giovanni Campagna
0e519e2b3b evdev: implement wheel events
Mouse wheel events come as EV_REL/REL_WHEEL, and we can convert
them to clutter events on the assumption that scrolling with
the wheel is always vertical.

https://bugzilla.gnome.org/show_bug.cgi?id=705710
2013-08-14 16:50:45 +02:00
Giovanni Campagna
7b780b0c38 evdev: don't update xkb state for autorepeated keys
xkb_state_update_key() needs to be called only on state transitions,
otherwise the state tracking gets confused and locks certain modifiers
forever.

https://bugzilla.gnome.org/show_bug.cgi?id=705710
2013-08-13 18:11:12 +02:00
Giovanni Campagna
8c358f18b1 evdev: allow hooking directly into libxkbcommon
A wayland compositor needs to have more keyboard state than
ClutterModifierState exposes, so it makes sense for it to use
xkb_state directly. Also, it makes sense for it to provide
it's own keymap, to ensure a consistent view between the compositor
and the wayland clients.

https://bugzilla.gnome.org/show_bug.cgi?id=705710
2013-08-13 17:51:33 +02:00
Giovanni Campagna
786532213b evdev: add master / slave device handling
All evdev devices are slave devices, which means that xkb state
and pointer position must be shared by emulating a core keyboard
and a core pointer. Also, we must make sure to add all modifier
state (keyboard and button) to our events.

https://bugzilla.gnome.org/show_bug.cgi?id=705710
2013-08-13 17:42:43 +02:00
Giovanni Campagna
d844cf5462 evdev: fix xkb_state handling
We must pass X11 keycodes, not evdev ones, to libxkbcommon,
otherwise the modifier state is wrong.

https://bugzilla.gnome.org/show_bug.cgi?id=705710
2013-08-13 09:41:44 +02:00
Giovanni Campagna
26b2852601 evdev: add a way for applications to tweak how devices are opened
In some cases, applications (or actually, wayland compositors)
don't have the required permissions to access evdev directly, but
can do so with an external helper like weston-launch.

Allow them to do so with a custom callback that replaces the regular
open() path.

https://bugzilla.gnome.org/show_bug.cgi?id=704269
2013-08-13 09:41:44 +02:00
Emmanuele Bassi
41bb03da2d Use the new macros for adding private data 2013-07-03 18:04:32 +01:00
Neil Roberts
d0d1b562bd evdev: Fix use of the common XKB code for the evdev device
In commit 8f4e39b6d7 the Wayland code was updated to use the new
xkbcommon API. This involved changing the common XKB code shared with
the evdev input backend. However the evdev input backend was not
modified so it wouldn't compile. This patch just makes a minor change
to update it.

https://bugzilla.gnome.org/show_bug.cgi?id=693348
2013-02-08 12:02:26 +00:00
Emmanuele Bassi
78a7a60b89 evdev: Fix missing ClutterEventSource member
https://bugzilla.gnome.org/show_bug.cgi?id=686692
2012-12-18 01:27:31 +00:00
Daniel Stone
8f4e39b6d7 Port to new Wayland and xkbcommon APIs
For Wayland, this is mostly the input protocol having changed, although
there's also the SHM pool API, the cursor API, as well as fullscreen and
ping.

Also port to the new (months-old) xkbcommon API, as used by Weston 0.95.
This involves having xkbcommon manage the state for us, where
appropriate.  Fans of multi-layout keyboards (or just caps lock) will no
doubt appreciate these changes.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-10-12 15:12:55 +01:00
Neil Roberts
99a7406d01 evdev: Swap the numbers for the middle and right buttons
The ordering of the evdev button numbers is the opposite of the
order in Clutter (the middle button is 3 instead of 2) so we need to
manually map the button numbers when creating a ClutterButtonEvent.

https://bugzilla.gnome.org/show_bug.cgi?id=680255
2012-09-03 21:58:25 +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
Neil Roberts
dee544645b wayland: Fix some missing includes
The commit 90e5088 added some extra compiler warning options that were
triggering warnings when enabling the wayland build due to missing
header includes. This adds those header includes in.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
2012-03-20 14:36:58 +00:00
Robert Bragg
3c6a0cdc61 evdev: Adds api to release/reclaim the evdev devices
Clutter applications using evdev are typically fullscreen applications
associated with a single virtual termainal. When switching away from
the applications associated tty then Clutter should stop managing all
evdev devices and re-probe for devices when the application regains
focus by switching back to the tty. To facilitate this, this patch
adds clutter_evdev_release_devices() and clutter_evdev_reclaim_devices()
functions.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
2012-03-01 11:41:51 +00:00
Neil Roberts
a3bbcff946 evdev: Associate devices with the first created stage
Because evdev isn't associated with the display system, it doesn't
have any easy way to associate an input device with a stage.
Previously Clutter would never set a stage for an input device and
leave it up to the application to set it. To make it easier for
applications which just have a single fullscreen stage (which is
probably the most common use case for evdev) the device manager now
associates all input devices with the first stage that is created
unless something has already set a stage.

Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
2012-03-01 11:41:51 +00:00
Robert Bragg
3e85ad6b95 build: make internal option_xkb_* symbols static
This makes the option_xkb_* symbols declared for the evdev device manager
and the wayland device manager private so we don't get symbol collisions
if both of these backends are enabled.

Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
2011-12-08 16:13:38 +00:00
Robert Bragg
602a89afa8 evdev: fixes evdev build issues + don't ref default stage
This updates the evdev input backend code to compile and also updates
the code to not refer to the default stage and instead check for a
stage to be associated with the input device. If no stage is currently
associated with a device generating events then the events are dropped
on the floor.

Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
2011-12-08 16:13:37 +00:00
Lionel Landwerlin
213e6e4a16 evdev: do not associate device with stage
Their might not be any stage at that time, so this avoids to create a
default one.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=651718
2011-11-10 15:41:41 +00:00