We currently allow a weston_buffer to outlive the underlying wl_buffer
iff the renderer/backend has cached it. Currently the 'is this buffer
valid?' test relies on looking for the validity of the weston_buffer
itself; shift these tests to looking at the validity of the underlying
resource.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Otherwise, the client will assume that dragging is in progress and remains in
that state forever.
This can happen when weston processes the mouse up event just before the
start_drag() arrives.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
pointer/touch drag-n-drop operations could happen if there's no keyboard
hooked up or when it is unplugged.
Fixes: #235
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This change fixes the "touch-up" operation to clear "data_source"
by setting "seat" to NULL. This operation is done in the mouse button
release operation, but seems to have been forgotten in the "touch up"
case.
Forgetting this operation causes weston to send a "premature finish
request" error to the client which causes the client to exit.
This issue can be reproduced with the "weston-dnd" program by performing
a drag-and-drop operation with a touch input device. Once the drag
is released, the weston-dnd program will exit with an error.
Signed-off-by: Jonathan Marler <johnnymarler@gmail.com>
Found mutable global variables with
$ grep -P '^static (?!const).*[=;]' -- compositor libweston shared
Mutable global or static variables make it harder to run several
compositor instances in the same process. That is what the test suite
would probably need to do to test wayland-backend.
This one variable does not need to be mutable.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Fixes missing prototypes compilation warnings emitted when a function
is defined before its prototype is declared.
These warnings were introduced over time since the switch to meson
because the -Wmissing-protoypes was not included in the compilation
arguments.
Signed-off-by: Guillaume Champagne <champagne.guillaume.c@gmail.com>
This was caused by weston_wm_handle_xfixes_selection_notify() calling
weston_seat_set_selection() with a NULL source, apparently only
sometimes when closing an Xwayland window.
The documentation of wl_data_offer::finish states that it should be
used to signify that a drag and drop operation is completed. So send
WL_DATA_OFFER_ERROR_INVALID_FINISH when the client calls the finish
request but the operation isn't dnd.
Signed-off-by: Harish Krupo <harishkrupo@gmail.com>
The main idea is to make libweston users use the form
#include <libweston/libweston.h>
instead of the plain
#include <compositor.h>
which is prone to name conflicts. This is reflected both in the installed
files, and the internal header search paths so that Weston would use the exact
same form as an external project using libweston would.
The public headers are moved under a new top-level directory include/ to make
them clearly stand out as special (public API).
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Ensure the server can safely handle client requests for wl_seat resource
that have become inert due to weston_seat object release and subsequent
destruction.
The clean-up involves, among other things, unsetting the destroyed
weston_seat object from the user data of wl_seat resources, and handling
this NULL user data case where required.
The list of sites extracting and using weston_seat object from wl_seat
resources which were audited for this patch are:
Legend:
N/A = Not Applicable (not implemented by weston)
FIXED = Fixed in the commit
OK = Already works correctly
== keyboard_shortcuts_inhibit_unstable_v1 ==
[N/A] zwp_keyboard_shortcuts_inhibit_manager_v1.inhibit_shortcuts
== tablet_input_unstable_v{1,2} ==
[N/A] zwp_tablet_manager_v{1,2}.get_tablet_seat
== text_input_unstable_v1 ==
[FIXED] zwp_text_input_v1.activate
[FIXED] zwp_text_input_v1.deactivate
== wl_data_device ==
[FIXED] wl_data_device_manager.get_data_device
[OK] wl_data_device.start_drag
[FIXED] wl_data_device.set_selection
[OK] wl_data_device.release
== wl_shell ==
[FIXED] wl_shell_surface.move
[FIXED] wl_shell_surface.resize
[FIXED] wl_shell_surface.set_popup
== xdg_shell and xdg_shell_unstable_v6 ==
[FIXED] xdg_toplevel.show_window_menu
[FIXED] xdg_toplevel.move
[FIXED] xdg_toplevel.resize
[FIXED] xdg_popup.grab
== xdg_shell_unstable_v5 ==
[FIXED] xdg_shell.get_xdg_popup
[FIXED] xdg_surface.show_window_menu
[FIXED] xdg_surface.move
[FIXED] xdg_surface.resize
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Change code related to touch motion events to use struct timespec to
represent time.
This commit is part of a larger effort to transition the Weston codebase
to struct timespec.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Change code related to touch up events to use struct timespec to represent
time.
This commit is part of a larger effort to transition the Weston codebase
to struct timespec.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Change code related to touch down events to use struct timespec to
represent time.
This commit is part of a larger effort to transition the Weston codebase
to struct timespec.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Change code related to key events to use struct timespec to represent
time.
This commit is part of a larger effort to transition the Weston codebase
to struct timespec.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Change code related to axis events to use struct timespec to represent
time.
This commit is part of a larger effort to transition the Weston codebase
to struct timespec.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Change code related to button events to use struct timespec to represent
time.
This commit is part of a larger effort to transition the Weston codebase
to struct timespec.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Change code related to motion events to use struct timespec to represent
time.
This commit is part of a larger effort to transition the Weston codebase
to struct timespec.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Currently, weston assumes a surface/view is mapped if
it has an output assigned. In a zero outputs scenario,
this isn't really desirable.
This patch introduces a new flag to weston_surface and
weston_view, which has to be set manually to indicate
that a surface/view is mapped.
v2:
- Remove usage of new flags from
weston_{view,surface}_is_mapped at this point. They
will be added after all the implicit mappings have
been introduced
- Unmap a surface before unmapping a view so the input
foci is cleaned up properly
- Remove implicit view mapping from view_list_add
- Cosmetic fixes
v3:
- Rebased to apply on git master
Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This clarifies what is supposed to be the libweston code.
v2: screen-share.c is already in compositor/ instead.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Tested-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Tested-by: Benoit Gschwind <gschwind@gnu-log.net>
Acked-by: Benoit Gschwind <gschwind@gnu-log.net>
[Pekka: rebased]
If the version of the source object is old enough to not have
wl_data_source.set_actions() the current action would never be updated
since source->set_actions would never be set.
To fix this, instead of checking whether source->set_actions before
proceeding with updating the current action, just always update the
action when we know all parts are valid dnd data device objects.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Mike Blumenkrantz <zmike@osg.samsung.com>
Reviewed-by: Carlos Garnacho <carlosg@gnome.org>
We're not always dealing with weston_data_sources that have a
wl_resource, or data_sources that belong to drag-and-drop. Check
harder for these on the drag-and-drop code paths triggered from
common code.
Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
Set up a keyboard grab during drag-and-drop, so we can translate
modifiers into preferred actions. The compositor chosen action
is stored in the current weston_data_source in order to make it
accessible to the source/offer at the time of calculating the new
action, but would conceptually be part of weston_drag.
The mapping has been made similar to what GTK+/QT usually do, the
shift key defaults to "move" and ctrl defaults to "copy".
Changes since v2:
- Use enum types and values for the compositor action. Fix
code formatting issues.
Changes since v1:
- Handle the keyboard grab being cancelled. Initialize new
wl_data_source fields.
Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
The policy in weston in order to determine the chosen DnD action is
deliberately simple, and is probably the minimals that any compositor
should be doing here.
Besides honoring the set_actions requests on both wl_data_source and
wl_data_offer, weston now will emit the newly added "action" events
notifying both source and dest of the chosen action.
The "dnd" client has been updated too (although minimally), so it
notifies the compositor of a "move" action on both sides.
Changes since v8:
- Add back wl_data_offer.source_actions emission, gone during last
code shuffling. Fix nits found in review.
Changes since v7:
- Fixes spotted during review. Add client-side version checks.
Implement .action emission as specified in protocol patch v11.
Changes since v6:
- Emit errors as defined in DnD actions patch v10.
Changes since v5:
- Use enum types and values for not-a-bitfield stored values.
handle errors when finding unexpected dnd_actions values.
Changes since v4:
- Added compositor-side version checks. Spaces vs tabs fixes.
Fixed resource versioning. Initialized new weston_data_source/offer
fields.
Changes since v3:
- Put data_source.action to use in the dnd client, now updates
the dnd surface like data_source.target events do.
Changes since v2:
- Split from DnD progress notification changes.
Changes since v1:
- Updated to v2 of DnD actions protocol changes, implement
wl_data_offer.source_actions.
- Fixed coding style issues.
Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
Reviewed-by: Michael Catanzaro <mcatanzaro@igalia.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Weston now sends wl_data_source.dnd_drop_performed and .dnd_finished in
order to notify about the different phases of DnD.
wl_data_source.cancelled is also used as mentioned in the docs, being
emitted also on DnD when the operation is meant to fail (eg. source
and dest didn't agree on a mimetype).
The dnd demo is also fixed so the struct dnd_drag isn't leaked.
https://bugs.freedesktop.org/show_bug.cgi?id=91943https://bugs.freedesktop.org/show_bug.cgi?id=91944
Changes since v6:
- Add client-side version checks. Minor code shuffling.
Changes since v5:
- Dissociate source and offer after cancel. Updated to
apply on top of c9f8f8a7f.
Changes since v4:
- Make wl_data_offer.finish with the wrong state an error.
Changes since v3:
- Fixed wl_data_source.dnd_finished vs cancelled emission on
when interoperating with version < 3 drag destinations.
Changes since v2:
- Handle wl_data_offer.finish. Fixed commit log inconsistencies.
Added version checks. Spaces vs tabs fixes. Fixed resource
versioning.
Changes since v1:
- Updated to protocol v2.
Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
Reviewed-by: Michael Catanzaro <mcatanzaro@igalia.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
[jonas: only send focus wl_pointer.frame if resource supports it]
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Use an event struct to pass axis events around. This helps dealing with the
upcoming axis discrete changes.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Noticed this while working on primary selection, in the event we run out
of memory when trying to create a new data source, there's a chance
we'll fail on wl_resource_create() and crash from source->resource being
set to NULL.
Signed-off-by: Lyude <cpaul@redhat.com>
Reviewed-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Instead of only passing absolute pointer coordinates, effectively
loosing motion event data, pass a struct that can potentially contain
different types of motion events, currently being absolute and relative.
A helper function to get resulting absolute coordinates was added for
when previous callbacks simply used the (x, y) coordinates.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Don't only send motions and buttons but also axis events through the
pointer grab interface.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
Valgrind has shown that in at least one place (default_grab_pointer_focus)
we're testing uninitialized values coming out of weston_compositor_pick_view.
This is happening when default_grab_pointer_focus is called when there is
nothing on the view list, and during the first repaint when only the black
surface with no input region exists.
This patch adds a function to clear pointer focus and also set the sx,sy
co-ordinates to a sentinel value we shouldn't compute with.
Assertions are added to make sure any time pointer focus is set to NULL
these values are used.
weston_compositor_pick_view() now returns these values too.
Now the values are always initialized, even when no view exists, and
they're initialized in such a way that actually doing computation
with them should fail in an obvious way, but we can compare them
safely for equality.
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
This makes it consistent with the pointer grab, which also gets
global coordinates and not surface relative ones, and allows to
easily filter out gestures based on compositor global hotspots.
Reviewed-by: Daniel Stone <daniels@collabora.com>
Keyboards and pointers aren't freed when devices are removed, so we should
really be testing keyboard_device_count and pointer_device_count in most
cases, not the actual pointers. Otherwise we end up with different
behaviour after removing a device than we had before it was inserted.
This commit renames the touch/keyboard/pointer pointers and adds helper
functions to get them that hide this complexity and return NULL when
*_device_count is 0.
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Removed duplicate definitions of the container_of() macro and
refactored sources to use the single implementation.
Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
As we do for the input interfaces such as wl_pointer, we must send the
selection event to all the wl_data_device resources the client created for
a specified seat.
Reviewed-by: Daniel Stone <daniels@collabora.com>
This commit adds a new exported function, weston_seat_send_selection(),
which sends the current selection to a specified client. This is
useful e.g. to implement a clipboard manager as a special client.
Reviewed-by: Daniel Stone <daniels@collabora.com>
When printing out logs from Weston's actions, mainly for debugging, it
can be very difficult to identify the different surfaces. Inspecting
the configure function pointer is not useful, as the configure functions
may live in modules.
Add vfunc get_label to weston_surface, which will produce a short,
human-readable description of the surface, which allows identifying it
better, rather than just looking at the surface size, for instance.
Set the label function from most parts of Weston, to identify cursors and
drag icons, and panels, backgrounds, screensavers and lock surfaces, and
the desktop shell's application surfaces.
v2: renamed 'description' to 'label', so we get
weston_surface_set_label_func().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
With the more accurate definition of wl_surface roles in Wayland,
enforce the restriction: a role is always set permanently, and
attempting to change it is a protocol error.
This patch is based on Jasper's patch:
http://lists.freedesktop.org/archives/wayland-devel/2014-August/016811.html
The difference in this patch compared to his are:
- send role errors on the interface whose request triggers it, not on
wl_surface
- an interface could have several requests assigning different roles,
cannot use wl_interface as the unique key; use an arbitary string
instead
- ensure in window-manager.c that create_shell_surface() ->
create_common_surface() is never called with surface->configure set,
to avoid compositor abort
- use wl_resource_post_no_memory() where appropriate instead of
hand-rolling it with wl_resource_post_error()
Ideally we would not add weston_surface::role_name field, but use
weston_surface::configure. At the moment this is not possible though,
because at least shell.c uses several different roles with the same
configure function. Drag'n'drop uses two configure functions for the
same role. The configure hook is also reset in several places,
which is not good for role tracking.
This patch overlooks the wl_surface roles assigned in privileged
extensions: screensaver, panel, background, lock, input panel.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
This introduces a new struct, weston_layer_entry, which is now used
in place of wl_list to keep the link for the layer list in weston_view
and the head of the list in weston_layer.
weston_layer_entry also has a weston_layer*, which points to the layer
the view is in or, in the case the entry it's the head of the list, to
the layer itself.
Previoiusly, we had a mess of logic that was repeated with one of the
repeats negated. Not only was this unnecisaraly confusing, but it
segfaulted and one of the negations was wrong. This cleans the whole mess
up and should fix bug #79725.
The commit "Remove the weston_view.geometry.width/height fields" changed
the type of the surface configure callback function, but did not change
the callbacks in data-device.c. This commit fixes the type of the
functions left needed to be changed.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
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.
Adding the drag and drop grab interface for touch screen in
src/data-device.c, so the server can handle touch screen
drag and drop operation.
Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com>
Reviewed-by: Kristian Hogsberg <hoegsberg@gmail.com>