Commit graph

61 commits

Author SHA1 Message Date
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
Rusty Lynch f1407ff81d input: Store touch position and time when we start an implicit touch grab 2013-08-08 22:01:42 -07:00
Peter Hutterer f3d62276d2 malloc + memset -> zalloc
And for clients using the xmalloc helper, use xzalloc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-08-08 13:46:13 -07:00
Kristian Høgsberg 0ff7908767 compositor: Check wl_resource_create() return value
This fixes a number of call-sites to properly check for NULL and return
the no memory event when allocation fail.
2013-08-06 16:46:25 -07:00
Michael Fu a2bb7919de Reset touch focus in unmap
Otherwise, there will be race condition of visiting invalid surface data.
2013-07-29 16:31:47 -07:00
Kristian Høgsberg 919cddb0ab Convert to wl_global_create/destroy() 2013-07-09 02:02:11 -04:00
Kristian Høgsberg aaadc774a7 input: Remove wl_seat global when a seat is destroyed
The input code was relying on compositor destruction to clean up the
global, but that doesn't work when the global comes and goes dynamically.

https://bugs.freedesktop.org/show_bug.cgi?id=65913
2013-07-08 16:20:31 -04:00
Giulio Camuffo 708b8af018 input: check if the resource is valid in seat_get_pointer
seat->pointer->focus->resource can be NULL, if the surface was
created with weston_surface_create.
2013-07-08 13:22:08 -04:00
Kristian Høgsberg da751b8f9a input: Don't cache pointer grab interface between calls to focus and motion
The focus callback for the current grab can change the grab, so we have
to make sure we call the motion callback for the currently active grab.

https://bugs.freedesktop.org/show_bug.cgi?id=65961
2013-07-04 01:00:16 -04:00
Jason Ekstrand a85118c1b8 Use wl_resource_create() for creating resources
This commit sets the version numbers for all added/created objects.  The
wl_compositor.create_surface implementation was altered to create a surface
with the same version as the underlying wl_compositor.  Since no other
"child interfaces" have version greater than 1, they were all hard-coded to
version 1.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-07-03 14:52:06 -04:00
Rob Bradford 382ff46ffb build: Make libxkbcommon build-time optional in the compositor
v2: Incorporate review feedback from Daniel Stone - improved configure
message about the purpose of this option and reorganisation of #ifdefs.
2013-06-28 19:56:41 -04:00
Matt Roper 01a9273bd2 input: Add support for making libxkbcommon optional
In embedded environments, devices that appear as evdev "keyboards" often
have no resemblence to PC-style keyboards.  It is not uncommon for such
environments to have no concept of modifier keys and no need for XKB key
mapping; in these cases libxkbcommon initialization becomes unnecessary
startup overhead.  On some SOC platforms, xkb keymap compilation can
account for as much as 1/3 - 1/2 of the total compositor startup time.

This patch introduces a 'use_xkbcommon' flag in the core compositor
structure that indicates whether the compositor is running in "raw
keyboard" mode.  In raw keyboard mode, the compositor bypasses all
libxkbcommon initialization and processing.  'key' events containing the
integer keycode will continue to be delivered via the wl_keyboard
interface, but no 'keymap' event will be sent to clients.  No modifier
handling or keysym mapping is performed in this mode.

Note that upstream sample apps (e.g., weston-terminal or the
desktop-shell client) will not recognize raw keycodes and will not react
to keypresses when the compositor is operating in raw keyboard mode.
This is expected behavior; key events are still being sent to the
client, the client (and/or its toolkit) just isn't written to handle
keypresses without doing xkb keysym mapping.  Applications written
specifically for such embedded environments would be handling keypresses
via the raw keycode delivered as part of the 'key' event rather than
using xkb keysym mapping.

Whether to use xkbcommon is a global option that applies to all
compositor keyboard devices on the system; it is an all-or-nothing flag.
This patch simply adds conditional checks on whether xkbcommon is to be
used or not.

v3 don't send zero as the file descriptor - instead send the result of
opening /dev/null

v2 by Rob Bradford <rob@linux.intel.com>: the original version of the
patch used a "raw_keycodes" flag instead of the "use_xkbcommon" used in
this patch.

v1: Reviewed-by: Singh, Satyeshwar <satyeshwar.singh@intel.com>
v1: Reviewed-by: Bob Paauwe <bob.j.paauwe@intel.com>
2013-06-28 19:55:29 -04:00
Rob Bradford 66bd9f5baf compositor-drm: Enable seat constraining when configured in weston.ini
This change tweaks weston_pointer_clamp to take into consideration if a
seat is constrained to a particular output by only considering the
pointer position valid if it is within the output we a constrained to.
This function is also used for the initial warping of the pointer when a
constraint is first established.

The other two changes are the application of the constraint when either
a new device added or a new output created and therefore outputs and
input devices can be brought up in either order.

v2: the code in create_output_for_connector has been spun off into a
new function setup_output_seat_constraint (Ander). The inappropriate
warping behaviour has been resolved by using weston_pointer_clamp
(Pekka).
2013-06-28 13:36:14 -04:00
Rob Bradford 806d8c0b78 input: Add weston_pointer_clamp function to ensure pointer visible
This refactors the code out from clip_pointer_motion into a function of
its own which can then be used elsewhere to clamp the pointer
coordinates to the range of the outputs.

This change also makes the caller of clip_pointer_motion use this new
function.
2013-06-25 16:28:04 -04:00
Kristian Høgsberg 6c8d778646 compositor: Remove double free()s in resource destructors
With the change to move free()ing of the wl_resource into wayland-server, we now have
a few cases where we double free the resource in the destructor.  This patch
removes those.
2013-06-25 10:29:30 -04:00
Giulio Camuffo 1fd4b01d10 input: check if the focus surface has a valid resource
the resource can be NULL in some cases, like when the focus is
taken by the black_surface used in shell.c as fullscreen background.
2013-06-20 15:22:35 -04:00
Jason Ekstrand 44a3863a17 input: Use wl_resource_get accessor functions for resources
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-06-14 16:49:11 -04:00
Jason Ekstrand 0f2ef7ebd3 Use wl_resource_get_user_data for weston_surface resources
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-06-14 15:58:29 -04:00
Jason Ekstrand 26ed73cee8 Change weston_surface.resource to a wl_resource pointer.
This is the first in what will be a series of weston patches to convert
instances of wl_resource to pointers so we can make wl_resource opaque.
This patch handles weston_surface and should be the most invasive of the
entire series.  I am sending this one out ahead of the rest for review.

Specifically, my machine is not set up to build XWayland so I have no
ability to test it fully.  Could someone please test with XWayland and let
me know if this causes problems?

Because a surface may be created from XWayland, the resource may not always
exist.  Therefore, a destroy signal was added to weston_surface and
everything used to listen to surface->resource.destroy_signal now listens
to surface->destroy_signal.
2013-06-12 15:04:49 -04:00
Rob Bradford e445ae69f2 input: Send the seat name if the client advertises verson 2 of wl_seat 2013-06-05 00:17:43 -04:00
Rob Bradford 9af5f9e0fe input: Add a seat name parameter to weston_seat_init 2013-06-05 00:17:38 -04:00
Alexander Larsson bcd18d9b09 input: Fix possible crash in clip_pointer_motion
It was erronously using output->current->height in one
place where it should use output->height. This may cause
it to create an invalid clipped coordinate in case of output
scaling or transform, because the next round "prev" would
end up NULL.
2013-05-28 16:14:34 -04:00
Kristian Høgsberg 6848c25677 input: Move surface picking into the pointer grab focus callback
Currently the core input code does surface picking before calling into
the focus callback of the current grab.  Not all grabs need to pick a
surface however, so we're doing work we don't have to in those cases.

For example, the shell move and resize grabs don't need to pick and the
default grab in implicit grab mode doesn't either.

With this change, the pointer grab mechanism is now very simple:
the focus callback is called whenever the pointer may have a new focus,
the motion callback is called whenever the pointer moves and
the button callback whenever a button is pressed or released.
2013-05-08 22:03:45 -04:00
Kristian Høgsberg be6403ed5c input: Get rid of grab focus concept
This was another complication that we had to have to support the
split between libwayland-server and weston.  Different grabs want to send
events relative to different surfaces at different times.  The default
grab switches between sending coordinates relative to the 'current' surface,
that is the surface the pointer is currently above, or the 'clicked'
surface, in case of an implicit grab.

The grab focus was set by the grab implementation and the core input code
would transform the pointer position to surface relative coordinates for the
grab focus and store in grab->x/y.

Now we can just let the grab implementation transform the pointer
coordinates itself, leaving the implementation free to transform
according to whichever surface it wants.  Or not transform at all if
it doesn't need surface relative coordinates (like the shell move and resize
grabs).
2013-05-08 21:03:23 -04:00
Kristian Høgsberg e122b7ba58 input: Remove 'current' and related fields from weston_pointer
The current surface field was used to track the surface the pointer was
currently over along with pointer position relative to that surface,
regardless of implicit or explicit grabs.  The main purpose was to restore
the default grab when another grab terminated.  We can now just repick in
that case and avoid keeping that state around, with the destroy listener
overhead that involves.

There was one other use case - we used to optimize out calls to
weston_pointer_set_focus() if the focus didn't actually change.  We can
still do that, but we have to do that in the default_grab_focus() handler
and compare against weston_pointer->focus instead.
2013-05-08 16:47:06 -04:00
Kristian Høgsberg 195b869f0e input: Move sprite fields into weston_pointer from weston_seat 2013-05-08 15:58:49 -04:00
Kristian Høgsberg fe7aa90ed4 compositor: Adapt to wl_surface going away
struct weston_surface is now the only surface type we have (in core, shell.c
has shell_surface, of course).  A lot of code gets simpler and we never
have to try to guess whether an API takes a wl_surface or a weston_surface.
2013-05-08 09:54:37 -04:00
Kristian Høgsberg a4036bbd23 input: Allocate pointer/keyboard/touch structs 2013-05-07 23:52:07 -04:00
Kristian Høgsberg 2bf876282f input: Eliminate weston_seat::has_pointer/keyboard/touch
We can just look at weston_seat::pointer/keyboard/touch now.
2013-05-07 23:40:26 -04:00
Kristian Høgsberg aad8099c2f data-device: Update drag icon position from configure and motion handlers
We can now update the drag icon position directly from the configure
handler or the grab motion handler, and no longer need
weston_seat_update_drag_surface().
2013-05-07 22:57:15 -04:00
Kristian Høgsberg 624d8f2293 data-device: Don't emit a signal for drag icon changes
The signal used to be in libwayland-server and the listener in weston, but
now they're both in the same file, so lets stop using signal.
2013-05-07 20:46:04 -04:00