Commit Graph

91 Commits

Author SHA1 Message Date
Kristian Høgsberg db1fccb3d8 input: Send leave and enter pair when the surface moves under the cursor
The client needs to know that the pointer is at a different position in
its surface.  We can't send motion as that corresponds to the pointer
actually moving.  Leaving the surface and entering at the new position
is a better semantic match and doesn't correspond to pointer motion
or user input.

https://bugs.freedesktop.org/show_bug.cgi?id=71927
2014-02-18 13:47:41 -08:00
Kristian Høgsberg e11ef64534 compositor: Drop core ping_handler callout
This was always a little iffy.  At least it could have been a signal,
but we now have focus signal, so lets just use that.  We lose
the ability to detect unresponsive clients at key event time, but we
could add that back by adding a key_signal.
2014-02-11 16:35:22 -08:00
Kristian Høgsberg c896401209 input: Run touch binding before calling touch grab
We don't want to send events if the binding is going to handle the touch
event.  Also, this restricts touch bindings to only trigger on touch down.
For gesture bindings we want something similar to the motion signal we
have for the pointer.
2014-02-05 17:01:33 -08:00
Kristian Høgsberg c988362a39 input: Transform to surface coordinates outside resource for loop
When we send the pointer motion event, the transform from compositor to
surface coordinates doesn't depend on the resource.  Transform the
coordinates up front instead of everytime we send to a resource.
2014-02-05 13:36:02 -08:00
Ander Conselvan de Oliveira f84327aef2 input: Remove exported function weston_pointer_verify()
Instead, add a compositor signal that an output has been destroyed and
handle that case locally in input.c.
2014-02-01 01:36:05 -08:00
Ander Conselvan de Oliveira 4d363cfcf6 input: Fix weston_seat_init_keyboard() error path
The pointer seat->keyboard was set before some possible error returns.
That pointer was left unchanged in case of failure, pointing to an
uninitialized keyboard struct (that was also leaked). If a client sent
a wl_seat::get_keyboard request, that would cause Weston to crash.

Fix this by setting the seat->keyboard pointer only after the keymap
initialization is done and there is no more possibilities for failure.
Also plug the memory leaks on the error path.

https://bugs.freedesktop.org/show_bug.cgi?id=74035
2014-02-01 01:14:22 -08:00
Ander Conselvan de Oliveira 23900f70e5 input: Empty the current input region when configuring pointer surfaces
The input region of the cursor surface is set to empty in
pointer_cursor_surface_configure(). Since during the commit process
this function is called before the pending input region is made
current, it empties surface->pending.input instead of surface->input.

But pointer_cursor_surface_configure() is also called from
pointer_set_cursor() in order to map the cursor even if there isn't a
subsequent attach and commit to the cursor surface. In that case,
surface->input is never emptied, since the configure function emptied
only the pending input region and there wasn't a commit that made it
effective.

Fix this by emptying both pending and current input regions. The latter
shouldn't cause problems since the surface can't have a role prior to
being assigned the cursor role, so it shouldn't be mapped in the first
place.

Also change toytoolkit so that it triggers the bug.

https://bugs.freedesktop.org/show_bug.cgi?id=73711
2014-02-01 01:12:24 -08:00
Jonas Ådahl 1afb2383ea input: Unlink saved kbd focus listener when releasing seat
Not doing this would leave a invalid list item in the view's destroy
signal listener list if destroying a seat that had previously lost
keyboard focus.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-01-27 21:14:25 -08:00
Kristian Høgsberg a30e29af2e input: Ignore touch up events if num_tp is 0
This can happen if we start out with one or more fingers on the touch
screen, in which case we didn't get the corresponding down event.

Closes: https://bugs.freedesktop.org/show_bug.cgi?id=73367
2014-01-08 22:29:25 -08:00
Rui Matos 73d9395e68 input: Don't leak the initial keymap
weston_xkb_info_create() takes ownership of the xkb_keymap instance so
we should drop our reference or we would leak it later if the keymap
was changed.
2014-01-08 21:40:32 -08:00
Ander Conselvan de Oliveira 54e90c7e1e compositor: Make pointers visible when an output is unplugged
Previously, if a pointer was inside an output that was unplugged, it
could potentialy end up outside any valid output forever. With this
patch, the pointer is moved to the "closest" output to the pointer.
2013-12-16 17:23:08 -08:00
Giulio Camuffo 65a07f8aef input: make sure the devices get the resource destruction signal
The device may not have a resource for the client yet, but install
the listeners nevertheless.
Fixes https://bugs.freedesktop.org/show_bug.cgi?id=65726
2013-12-06 11:19:38 -08:00
Jonas Ådahl 91fed5419c input: Reset keyboard state when releasing last seat keyboard
Don't rely on the input driver to properly send button-up events for
every pressed key.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-12-03 08:39:55 -08:00
Jonas Ådahl 7395ea05c7 input: Move the xkb fields from weston_seat to weston_keyboard
XKB integration is a keyboard feature and should as such be kept track
of in the keyboard struct.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-12-03 08:38:25 -08:00
Jason Ekstrand 918f2dd4cf Remove the weston_view.geometry.width/height fields
This has a couple of additional implications for the internal weston API:
 1) weston_view_configure no longer exists.  Use weston_view_set_position
    instead.
 2) The weston_surface.configure callback no longer takes a width and
    height.  If you need these, surface.width/height are set before
    configure is called.  If you need to know when the width/height
    changes, you must track that yourself.
2013-12-02 22:17:58 -08:00
Jonas Ådahl 3e12e63f03 input: Reset pointer state when last pointer device was removed
Reset pointer button count in case the driver did not emit appropriate
number of number button released events.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-12-02 15:24:36 -08:00
Jonas Ådahl cbfa7f7b22 input: Reset touch state when last touch device was removed
Reset the touch point count in case the driver did not emit appropriate
number of touch up events.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-12-02 15:24:22 -08:00
Jonas Ådahl 9484b695b9 input: Keep track of number of touch points inside touch struct
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-12-02 15:24:05 -08:00
Pekka Paalanen ba34165ce2 compositor: do not recompute size on pointer_set_cursor
This removes the calls to weston_surface_buffer_width/height() from
input.c, which are the last external calls to them.

Instead, use the cached values from weston_surface::width,height. These
have already been set by weston_surface_commit(), because that is the
only way a weston_surface can get a buffer.
2013-11-28 14:14:08 -08:00
Kristian Høgsberg ebd5fd4753 input: Cancel pointer grabs when compositor loses kb focus
This makes sure we pop down popups when the X backend loses keyboard
focus or when the kms backend vt-switches away.
2013-11-22 21:12:19 -08:00
Giulio Camuffo 576fe2af4b input: set the focus to NULL when the focus's resource is destroyed
with the surface ref-count feature a surface may live on after its
resource was destroyed. so listen for the resource destroy signal
and set the focus to NULL.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2013-11-20 16:59:00 -08:00
Jason Ekstrand 42133d47d3 input: Fix a segfault in focus checking
Without this, weston will segfault whenever the focus is a non-client
surface such as the black surface in fullscreen.
2013-11-19 13:23:40 -08:00
Emilio Pozuelo Monfort aa7a4761f6 input: Don't send leave events to destroyed views
If a view which has focus is destroyed, we would send a leave
event while changing focus, causing a segfault. Prevent this
by listening to the view's destroy signal and removing it from
the pointer focus.

Signed-off-by: Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
2013-11-19 11:49:40 -08:00
Daniel Stone 96d47c0ef7 Add modifier-only binding
Add the ability to bind to modifiers; the binding is armed when a key
which sets the requested modifier is pressed, and triggered if the key
is released with no other keys having been pressed in the meantime, as
well as mouse buttons or scroll axes.

This only works for direct modifiers (e.g. Shift and Alt), not modifiers
which latch or lock.

[pochu: rebased]
2013-11-19 11:49:25 -08:00
Giulio Camuffo cdb4d29096 compositor: add a way to override the default pointer grab 2013-11-15 16:17:51 -08:00
Giulio Camuffo 1959ab8d22 input: let the pointer motion handlers move the pointer
this allows to implement pointer barriers by using a custom handler
2013-11-15 16:17:51 -08:00
Giulio Camuffo 412b024be8 zoom: use the new pointer motion signal to move the zoom frame. 2013-11-15 16:17:51 -08:00
Giulio Camuffo 6fcb378c01 input: add a motion signal to weston_pointer
The signal will be emitted after the pointer is moved. A shell plugin
can listen to the signal and activate certain effects when the pointer
touches the screen corners, for instance.
2013-11-15 16:17:51 -08:00
Kristian Høgsberg b27901c5a7 input.c: Rename default grab functions to be consistent
Jonas recent patches made the inconsistency obvious, this patch fixes it.
2013-10-28 15:32:02 -07:00
Jonas Ådahl 1ea343e1be Add cancel function to grab interfaces
A grab can potentially allocate memory and would normally end the grab
itself, freeing the allocated memory in the process. However at in some
situations the compositor may want to abort a grab. The grab owner still
needs to free some memory and abort the grab properly. To do this a new
function 'cancel' is introduced in all the grab interfaces instructing
the grabs owner to abort the grab.

This patch also hooks up grab cancelling to seat device releasing and
when the compositor looses focus, which would potentially leak memory
before.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-10-28 14:44:06 -07:00
Jonas Ådahl b18018867b input: Remove unused variable
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-10-28 14:38:38 -07:00
Kristian Høgsberg c3244d7abc input: Properly handle setting touch focus to NULL
This happens on TOUCH_UP, and we unconditionally dereference view->surface.
2013-10-24 14:21:53 -07:00
Rui Matos 65196bc0b9 input: Add core API to update the keymap
How and when to update the keymap is left to each backend.

The new keymap only becomes effective when no keys are pressed and we
keep latched and locked modifiers from the previous state.
2013-10-22 15:24:55 -07:00
Jason Ekstrand a7af70436b Split the geometry information from weston_surface out into weston_view
The weston_surface structure is split into two structures:

 * The weston_surface structure storres everything required for a
   client-side or server-side surface.  This includes buffers; callbacks;
   backend private data; input, damage, and opaque regions; and a few other
   bookkeeping bits.

 * The weston_view structure represents an entity in the scenegraph and
   storres all of the geometry information.  This includes clip region,
   alpha, position, and the transformation list as well as all of the
   temporary information derived from the geometry state.  Because a view,
   and not a surface, is a scenegraph element, the view is what is placed
   in layers and planes.

There are a few things worth noting about the surface/view split:

 1. This is *not* a modification to the protocol.  It is, instead, a
    modification to Weston's internal scenegraph to allow a single surface
    to exist in multiple places at a time.  Clients are completely unaware
    of how many views to a particular surface exist.

 2. A view is considered a direct child of a surface and is destroyed when
    the surface is destroyed.  Because of this, the view.surface pointer is
    always valid and non-null.

 3. The compositor's surface_list is replaced with a view_list.  Due to
    subsurfaces, building the view list is a little more complicated than
    it used to be and involves building a tree of views on the fly whenever
    subsurfaces are used.  However, this means that backends can remain
    completely subsurface-agnostic.

 4. Surfaces and views both keep track of which outputs they are on.

 5. The weston_surface structure now has width and height fields.  These
    are populated when a new buffer is attached before surface.configure
    is called.  This is because there are many surface-based operations
    that really require the width and height and digging through the views
    didn't work well.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-10-22 13:34:11 -07:00
Kristian Høgsberg 10ddd97ecf compositor: Remove redundant and not well-defined focus field
It was never clear what this field really did.
2013-10-22 12:40:54 -07:00
Jonas Ådahl 3042ffe011 udev-seat: Repick seat after a new device was added
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-10-21 13:47:05 -07:00
Jonas Ådahl a493274442 input: Unmap pointer sprite when no more pointer devices are connected
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-10-21 13:46:44 -07:00
Jonas Ådahl 630bae8672 input: Unset focus of seat device when releasing last reference
When the last input device with a certain capability is removed, unset
the focus of the seat device associated with the capability.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-10-21 13:46:33 -07:00
Jonas Ådahl d6e1c34405 evdev: Reference count input device's seat capabilities
When the only input device of a certain seat capability is unplugged,
stop advertising the capability.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-10-21 13:45:03 -07:00
Neil Roberts 306fe0838b Only update the touch grab position for the first finger
Previously if you add a second finger while moving a window with a
touch grab then the position will keep jumping between the position of
each finger as you move them around. This patch changes it so that it
keeps track of the first touch id that starts the grab and only
updates the grab position when that finger moves.
2013-10-14 13:53:14 -07:00
Neil Roberts a28c69358c Add a touch binding to activate a surface
Adds a new binding type for touch events via the new function
weston_compositor_add_touch_binding. The binding can only be added for
a touch down with the first finger. The shell now uses this to install
a binding to activate the current surface.
2013-10-14 13:53:08 -07:00
Kristian Høgsberg cb406f1afd input: Don't send modifiers if client doesn't have a pointer resource
This fixes an uninitialized serial error, were we could send out the
modifier event even if the client didn't have a pointer resource.  We
send out the modifier event to let clients know the modifer mask when
they receive a pointer button event.  Thus, if the client doesn't have
a pointer we don't need to send the modifier event.

Additionally we would send out the modifier event with an
uninitialized serial number.

Finally, this commit restores the order of sending the modifier event
before the enter, like it used to be.  Not likely to be an issue,
since the client will always receive the modifier event before any
button event, but it's a little nicer to give the client the modifier
events before it receives any pointer events.
2013-10-09 15:01:18 -07:00
Giulio Camuffo 0481054c58 input: check that the new focus surface has a valid resource
Here too we must make sure the surface has a valid resource, as
there are some (xwayland, surfaces created by the shell) that
don't have it.
Fix a Weston crash when setting a mpv window fullscreen on drm.
2013-09-23 10:09:37 -07:00
Neil Roberts 96d790e74b input: Emit events on all resources for a client
The Wayland protocol permits a client to request the pointer, keyboard
and touch multiple times from the seat global. This is very useful in a
component like Clutter-GTK where we are combining two libraries that use
Wayland together.

This change migrates the weston input handling code to emit the
events for all the resources for the client by using the newly added
wl_resource_for_each macro to iterate over the resources that are
associated with the focused surface's client.

We maintain a list of focused resources on the pointer and keyboard
which is updated when the focus changes. However since we can have
resources created after the focus has already been set we must add the
resources to the right list and also update any state.

Additionally when setting the pointer focus it will now send the
keyboard modifiers regardless of whether the focused client has a
pointer resource. This is important because otherwise if the client
gets the pointer later than you getting the keyboard then the
modifiers might not be up-to-date.

Co-author: Neil Roberts <neil@linux.intel.com>
2013-09-21 20:56:55 -07:00
Stefan Schmidt fda265268d input: Fix trailing whitspaces and indent.
Just some cosmetics to conform to the wayland coding style.

Signed-off-by: Stefan Schmidt <s.schmidt@samsung.com>
2013-09-21 11:18:45 -07:00
Rob Bradford 6e737f590b input: Use new wl_resource_for_each for sending updated seat caps 2013-09-11 11:57:28 -07:00
Andrew Wedgbury 9a6f02a6b1 Copying xkb_info when creating a seat causes problems
Hi Kristian,

Here's a new patch for ref counting weston_xkb_info, as suggested.
So a seat created with a NULL keymap will now point to the global xkb_info.
2013-09-11 10:06:23 -07:00
Kristian Høgsberg 69e25fc538 compositor: Implement release request for input interfaces
v2 (Rob Bradford): Update the version numbering for this change
2013-08-30 14:53:17 -07:00
Daniel Stone 8e7a8bdeea Add more missing config.h includes
config.h includes were missing in a few files, including input.c, the
lack of which caused the X11 backend to segfault instantly due to not
having an xkbcommon context.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2013-08-16 10:56:00 -07:00
Rob Bradford 880ebc7ed9 input: For serial generation get the display from the compositor
This removes the use of wl_client_get_display() where the client is
derived from the focussed resource. This starts the removal of the
assumption of a single resource on a client that would be notified about
events on the focussed surface.
2013-08-12 16:54:10 -07:00