2013-04-18 23:07:39 +04:00
|
|
|
/*
|
|
|
|
* Copyright © 2011 Kristian Høgsberg
|
|
|
|
*
|
2015-06-12 01:35:43 +03:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
2013-04-18 23:07:39 +04:00
|
|
|
*
|
2015-06-12 01:35:43 +03:00
|
|
|
* The above copyright notice and this permission notice (including the
|
|
|
|
* next paragraph) shall be included in all copies or substantial
|
|
|
|
* portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
2013-04-18 23:07:39 +04:00
|
|
|
*/
|
|
|
|
|
2013-08-15 04:10:24 +04:00
|
|
|
#include "config.h"
|
|
|
|
|
2013-04-18 23:07:39 +04:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
2016-07-19 14:16:27 +03:00
|
|
|
#include <stdint.h>
|
2013-04-18 23:07:39 +04:00
|
|
|
#include <stdio.h>
|
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-13 07:38:11 +04:00
|
|
|
#include <assert.h>
|
2013-04-18 23:07:39 +04:00
|
|
|
|
2019-03-28 17:28:47 +03:00
|
|
|
#include <libweston/libweston.h>
|
2020-01-28 04:14:29 +03:00
|
|
|
#include "libweston-internal.h"
|
2015-06-16 01:37:10 +03:00
|
|
|
#include "shared/helpers.h"
|
2017-11-24 19:01:46 +03:00
|
|
|
#include "shared/timespec-util.h"
|
2013-04-18 23:07:39 +04:00
|
|
|
|
2013-05-08 23:27:47 +04:00
|
|
|
struct weston_drag {
|
|
|
|
struct wl_client *client;
|
2013-07-26 02:52:14 +04:00
|
|
|
struct weston_data_source *data_source;
|
2013-05-08 23:27:47 +04:00
|
|
|
struct wl_listener data_source_listener;
|
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-13 07:38:11 +04:00
|
|
|
struct weston_view *focus;
|
2013-05-08 23:27:47 +04:00
|
|
|
struct wl_resource *focus_resource;
|
|
|
|
struct wl_listener focus_listener;
|
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-13 07:38:11 +04:00
|
|
|
struct weston_view *icon;
|
2013-05-08 23:30:42 +04:00
|
|
|
struct wl_listener icon_destroy_listener;
|
2013-05-08 23:27:47 +04:00
|
|
|
int32_t dx, dy;
|
2016-01-15 23:14:26 +03:00
|
|
|
struct weston_keyboard_grab keyboard_grab;
|
2013-05-08 23:27:47 +04:00
|
|
|
};
|
|
|
|
|
2013-11-25 14:42:49 +04:00
|
|
|
struct weston_pointer_drag {
|
|
|
|
struct weston_drag base;
|
|
|
|
struct weston_pointer_grab grab;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct weston_touch_drag {
|
|
|
|
struct weston_drag base;
|
|
|
|
struct weston_touch_grab grab;
|
|
|
|
};
|
|
|
|
|
2016-01-19 01:52:12 +03:00
|
|
|
#define ALL_ACTIONS (WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY | \
|
|
|
|
WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE | \
|
|
|
|
WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK)
|
|
|
|
|
2013-04-18 23:07:39 +04:00
|
|
|
static void
|
|
|
|
data_offer_accept(struct wl_client *client, struct wl_resource *resource,
|
|
|
|
uint32_t serial, const char *mime_type)
|
|
|
|
{
|
2013-07-26 03:09:37 +04:00
|
|
|
struct weston_data_offer *offer = wl_resource_get_user_data(resource);
|
2013-04-18 23:07:39 +04:00
|
|
|
|
2016-01-15 23:14:23 +03:00
|
|
|
/* Protect against untimely calls from older data offers */
|
|
|
|
if (!offer->source || offer != offer->source->offer)
|
|
|
|
return;
|
|
|
|
|
2013-04-18 23:07:39 +04:00
|
|
|
/* FIXME: Check that client is currently focused by the input
|
|
|
|
* device that is currently dragging this data source. Should
|
|
|
|
* this be a wl_data_device request? */
|
|
|
|
|
2016-01-15 23:14:23 +03:00
|
|
|
offer->source->accept(offer->source, serial, mime_type);
|
|
|
|
offer->source->accepted = mime_type != NULL;
|
2013-04-18 23:07:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
data_offer_receive(struct wl_client *client, struct wl_resource *resource,
|
|
|
|
const char *mime_type, int32_t fd)
|
|
|
|
{
|
2013-07-26 03:09:37 +04:00
|
|
|
struct weston_data_offer *offer = wl_resource_get_user_data(resource);
|
2013-04-18 23:07:39 +04:00
|
|
|
|
2016-01-15 23:14:23 +03:00
|
|
|
if (offer->source && offer == offer->source->offer)
|
2013-04-18 23:07:39 +04:00
|
|
|
offer->source->send(offer->source, mime_type, fd);
|
|
|
|
else
|
|
|
|
close(fd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
data_offer_destroy(struct wl_client *client, struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
wl_resource_destroy(resource);
|
|
|
|
}
|
|
|
|
|
2016-01-15 23:14:23 +03:00
|
|
|
static void
|
|
|
|
data_source_notify_finish(struct weston_data_source *source)
|
|
|
|
{
|
2016-02-01 22:28:16 +03:00
|
|
|
if (!source->actions_set)
|
|
|
|
return;
|
|
|
|
|
2016-01-19 01:52:12 +03:00
|
|
|
if (source->offer->in_ask &&
|
|
|
|
wl_resource_get_version(source->resource) >=
|
|
|
|
WL_DATA_SOURCE_ACTION_SINCE_VERSION) {
|
|
|
|
wl_data_source_send_action(source->resource,
|
|
|
|
source->current_dnd_action);
|
|
|
|
}
|
|
|
|
|
2016-01-15 23:14:23 +03:00
|
|
|
if (wl_resource_get_version(source->resource) >=
|
|
|
|
WL_DATA_SOURCE_DND_FINISHED_SINCE_VERSION) {
|
|
|
|
wl_data_source_send_dnd_finished(source->resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
source->offer = NULL;
|
|
|
|
}
|
|
|
|
|
2016-01-19 01:52:12 +03:00
|
|
|
static uint32_t
|
|
|
|
data_offer_choose_action(struct weston_data_offer *offer)
|
|
|
|
{
|
|
|
|
uint32_t available_actions, preferred_action = 0;
|
|
|
|
uint32_t source_actions, offer_actions;
|
|
|
|
|
|
|
|
if (wl_resource_get_version(offer->resource) >=
|
|
|
|
WL_DATA_OFFER_ACTION_SINCE_VERSION) {
|
|
|
|
offer_actions = offer->dnd_actions;
|
|
|
|
preferred_action = offer->preferred_dnd_action;
|
|
|
|
} else {
|
|
|
|
offer_actions = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wl_resource_get_version(offer->source->resource) >=
|
|
|
|
WL_DATA_SOURCE_ACTION_SINCE_VERSION)
|
|
|
|
source_actions = offer->source->dnd_actions;
|
|
|
|
else
|
|
|
|
source_actions = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
|
|
|
|
|
|
|
|
available_actions = offer_actions & source_actions;
|
|
|
|
|
|
|
|
if (!available_actions)
|
|
|
|
return WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
|
|
|
|
|
2016-01-15 23:14:26 +03:00
|
|
|
if (offer->source->seat &&
|
|
|
|
offer->source->compositor_action & available_actions)
|
|
|
|
return offer->source->compositor_action;
|
|
|
|
|
2016-01-19 01:52:12 +03:00
|
|
|
/* If the dest side has a preferred DnD action, use it */
|
|
|
|
if ((preferred_action & available_actions) != 0)
|
|
|
|
return preferred_action;
|
|
|
|
|
|
|
|
/* Use the first found action, in bit order */
|
|
|
|
return 1 << (ffs(available_actions) - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
data_offer_update_action(struct weston_data_offer *offer)
|
|
|
|
{
|
|
|
|
uint32_t action;
|
|
|
|
|
2016-03-15 10:23:50 +03:00
|
|
|
if (!offer->source)
|
2016-01-19 01:52:12 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
action = data_offer_choose_action(offer);
|
|
|
|
|
|
|
|
if (offer->source->current_dnd_action == action)
|
|
|
|
return;
|
|
|
|
|
|
|
|
offer->source->current_dnd_action = action;
|
|
|
|
|
|
|
|
if (offer->in_ask)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (wl_resource_get_version(offer->source->resource) >=
|
|
|
|
WL_DATA_SOURCE_ACTION_SINCE_VERSION)
|
|
|
|
wl_data_source_send_action(offer->source->resource, action);
|
|
|
|
|
|
|
|
if (wl_resource_get_version(offer->resource) >=
|
|
|
|
WL_DATA_OFFER_ACTION_SINCE_VERSION)
|
|
|
|
wl_data_offer_send_action(offer->resource, action);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
data_offer_set_actions(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
uint32_t dnd_actions, uint32_t preferred_action)
|
|
|
|
{
|
|
|
|
struct weston_data_offer *offer = wl_resource_get_user_data(resource);
|
|
|
|
|
|
|
|
if (dnd_actions & ~ALL_ACTIONS) {
|
|
|
|
wl_resource_post_error(offer->resource,
|
|
|
|
WL_DATA_OFFER_ERROR_INVALID_ACTION_MASK,
|
|
|
|
"invalid action mask %x", dnd_actions);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (preferred_action &&
|
|
|
|
(!(preferred_action & dnd_actions) ||
|
|
|
|
__builtin_popcount(preferred_action) > 1)) {
|
|
|
|
wl_resource_post_error(offer->resource,
|
|
|
|
WL_DATA_OFFER_ERROR_INVALID_ACTION,
|
|
|
|
"invalid action %x", preferred_action);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
offer->dnd_actions = dnd_actions;
|
|
|
|
offer->preferred_dnd_action = preferred_action;
|
|
|
|
data_offer_update_action(offer);
|
|
|
|
}
|
|
|
|
|
2016-01-15 23:14:23 +03:00
|
|
|
static void
|
|
|
|
data_offer_finish(struct wl_client *client, struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
struct weston_data_offer *offer = wl_resource_get_user_data(resource);
|
|
|
|
|
|
|
|
if (!offer->source || offer->source->offer != offer)
|
|
|
|
return;
|
|
|
|
|
2019-04-19 19:36:37 +03:00
|
|
|
if (offer->source->set_selection) {
|
|
|
|
wl_resource_post_error(offer->resource,
|
|
|
|
WL_DATA_OFFER_ERROR_INVALID_FINISH,
|
|
|
|
"finish only valid for drag n drop");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-01-15 23:14:23 +03:00
|
|
|
/* Disallow finish while we have a grab driving drag-and-drop, or
|
|
|
|
* if the negotiation is not at the right stage
|
|
|
|
*/
|
|
|
|
if (offer->source->seat ||
|
|
|
|
!offer->source->accepted) {
|
|
|
|
wl_resource_post_error(offer->resource,
|
|
|
|
WL_DATA_OFFER_ERROR_INVALID_FINISH,
|
|
|
|
"premature finish request");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-01-19 01:52:12 +03:00
|
|
|
switch (offer->source->current_dnd_action) {
|
|
|
|
case WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE:
|
|
|
|
case WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK:
|
|
|
|
wl_resource_post_error(offer->resource,
|
|
|
|
WL_DATA_OFFER_ERROR_INVALID_OFFER,
|
|
|
|
"offer finished with an invalid action");
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-01-15 23:14:23 +03:00
|
|
|
data_source_notify_finish(offer->source);
|
|
|
|
}
|
|
|
|
|
2013-04-18 23:07:39 +04:00
|
|
|
static const struct wl_data_offer_interface data_offer_interface = {
|
|
|
|
data_offer_accept,
|
|
|
|
data_offer_receive,
|
|
|
|
data_offer_destroy,
|
2016-01-15 23:14:23 +03:00
|
|
|
data_offer_finish,
|
2016-01-19 01:52:12 +03:00
|
|
|
data_offer_set_actions,
|
2013-04-18 23:07:39 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
destroy_data_offer(struct wl_resource *resource)
|
|
|
|
{
|
2013-07-26 03:09:37 +04:00
|
|
|
struct weston_data_offer *offer = wl_resource_get_user_data(resource);
|
2013-04-18 23:07:39 +04:00
|
|
|
|
2016-01-15 23:14:23 +03:00
|
|
|
if (!offer->source)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
wl_list_remove(&offer->source_destroy_listener.link);
|
|
|
|
|
|
|
|
if (offer->source->offer != offer)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* If the drag destination has version < 3, wl_data_offer.finish
|
|
|
|
* won't be called, so do this here as a safety net, because
|
|
|
|
* we still want the version >=3 drag source to be happy.
|
|
|
|
*/
|
|
|
|
if (wl_resource_get_version(offer->resource) <
|
|
|
|
WL_DATA_OFFER_ACTION_SINCE_VERSION) {
|
|
|
|
data_source_notify_finish(offer->source);
|
2016-02-01 22:28:16 +03:00
|
|
|
} else if (offer->source->resource &&
|
|
|
|
wl_resource_get_version(offer->source->resource) >=
|
2016-01-15 23:14:23 +03:00
|
|
|
WL_DATA_SOURCE_DND_FINISHED_SINCE_VERSION) {
|
|
|
|
wl_data_source_send_cancelled(offer->source->resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
offer->source->offer = NULL;
|
|
|
|
out:
|
2013-04-18 23:07:39 +04:00
|
|
|
free(offer);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
destroy_offer_data_source(struct wl_listener *listener, void *data)
|
|
|
|
{
|
2013-07-26 03:09:37 +04:00
|
|
|
struct weston_data_offer *offer;
|
2013-04-18 23:07:39 +04:00
|
|
|
|
2013-07-26 03:09:37 +04:00
|
|
|
offer = container_of(listener, struct weston_data_offer,
|
2013-04-18 23:07:39 +04:00
|
|
|
source_destroy_listener);
|
|
|
|
|
|
|
|
offer->source = NULL;
|
|
|
|
}
|
|
|
|
|
2016-03-15 10:23:50 +03:00
|
|
|
static struct weston_data_offer *
|
2013-07-26 02:52:14 +04:00
|
|
|
weston_data_source_send_offer(struct weston_data_source *source,
|
|
|
|
struct wl_resource *target)
|
2013-04-18 23:07:39 +04:00
|
|
|
{
|
2013-07-26 03:09:37 +04:00
|
|
|
struct weston_data_offer *offer;
|
2013-04-18 23:07:39 +04:00
|
|
|
char **p;
|
|
|
|
|
|
|
|
offer = malloc(sizeof *offer);
|
|
|
|
if (offer == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2013-06-28 05:17:02 +04:00
|
|
|
offer->resource =
|
|
|
|
wl_resource_create(wl_resource_get_client(target),
|
2016-01-15 23:14:23 +03:00
|
|
|
&wl_data_offer_interface,
|
|
|
|
wl_resource_get_version(target), 0);
|
2013-08-06 21:24:04 +04:00
|
|
|
if (offer->resource == NULL) {
|
|
|
|
free(offer);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-06-28 05:17:02 +04:00
|
|
|
wl_resource_set_implementation(offer->resource, &data_offer_interface,
|
|
|
|
offer, destroy_data_offer);
|
2013-04-18 23:07:39 +04:00
|
|
|
|
2016-01-19 01:52:12 +03:00
|
|
|
offer->in_ask = false;
|
|
|
|
offer->dnd_actions = 0;
|
|
|
|
offer->preferred_dnd_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
|
2013-04-18 23:07:39 +04:00
|
|
|
offer->source = source;
|
|
|
|
offer->source_destroy_listener.notify = destroy_offer_data_source;
|
2013-06-14 19:07:55 +04:00
|
|
|
wl_signal_add(&source->destroy_signal,
|
2013-04-18 23:07:39 +04:00
|
|
|
&offer->source_destroy_listener);
|
|
|
|
|
2013-06-14 19:07:55 +04:00
|
|
|
wl_data_device_send_data_offer(target, offer->resource);
|
2013-04-18 23:07:39 +04:00
|
|
|
|
|
|
|
wl_array_for_each(p, &source->mime_types)
|
2013-06-14 19:07:55 +04:00
|
|
|
wl_data_offer_send_offer(offer->resource, *p);
|
2013-04-18 23:07:39 +04:00
|
|
|
|
2016-01-15 23:14:23 +03:00
|
|
|
source->offer = offer;
|
|
|
|
source->accepted = false;
|
|
|
|
|
2016-03-15 10:23:50 +03:00
|
|
|
return offer;
|
2013-04-18 23:07:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
data_source_offer(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
const char *type)
|
|
|
|
{
|
2013-07-26 02:52:14 +04:00
|
|
|
struct weston_data_source *source =
|
|
|
|
wl_resource_get_user_data(resource);
|
2013-04-18 23:07:39 +04:00
|
|
|
char **p;
|
|
|
|
|
|
|
|
p = wl_array_add(&source->mime_types, sizeof *p);
|
|
|
|
if (p)
|
|
|
|
*p = strdup(type);
|
|
|
|
if (!p || !*p)
|
|
|
|
wl_resource_post_no_memory(resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
data_source_destroy(struct wl_client *client, struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
wl_resource_destroy(resource);
|
|
|
|
}
|
|
|
|
|
2016-01-19 01:52:12 +03:00
|
|
|
static void
|
|
|
|
data_source_set_actions(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
uint32_t dnd_actions)
|
|
|
|
{
|
|
|
|
struct weston_data_source *source =
|
|
|
|
wl_resource_get_user_data(resource);
|
|
|
|
|
|
|
|
if (source->actions_set) {
|
|
|
|
wl_resource_post_error(source->resource,
|
|
|
|
WL_DATA_SOURCE_ERROR_INVALID_ACTION_MASK,
|
|
|
|
"cannot set actions more than once");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dnd_actions & ~ALL_ACTIONS) {
|
|
|
|
wl_resource_post_error(source->resource,
|
|
|
|
WL_DATA_SOURCE_ERROR_INVALID_ACTION_MASK,
|
|
|
|
"invalid action mask %x", dnd_actions);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (source->seat) {
|
|
|
|
wl_resource_post_error(source->resource,
|
|
|
|
WL_DATA_SOURCE_ERROR_INVALID_ACTION_MASK,
|
|
|
|
"invalid action change after "
|
|
|
|
"wl_data_device.start_drag");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
source->dnd_actions = dnd_actions;
|
|
|
|
source->actions_set = true;
|
|
|
|
}
|
|
|
|
|
2020-10-21 14:18:30 +03:00
|
|
|
static const struct wl_data_source_interface data_source_interface = {
|
2013-04-18 23:07:39 +04:00
|
|
|
data_source_offer,
|
2016-01-19 01:52:12 +03:00
|
|
|
data_source_destroy,
|
|
|
|
data_source_set_actions
|
2013-04-18 23:07:39 +04:00
|
|
|
};
|
|
|
|
|
2013-05-07 19:18:46 +04:00
|
|
|
static void
|
2013-11-25 14:42:49 +04:00
|
|
|
drag_surface_configure(struct weston_drag *drag,
|
2013-12-04 01:30:17 +04:00
|
|
|
struct weston_pointer *pointer,
|
|
|
|
struct weston_touch *touch,
|
|
|
|
struct weston_surface *es,
|
|
|
|
int32_t sx, int32_t sy)
|
2013-05-07 19:18:46 +04:00
|
|
|
{
|
2014-07-09 23:12:56 +04:00
|
|
|
struct weston_layer_entry *list;
|
2013-05-08 06:53:43 +04:00
|
|
|
float fx, fy;
|
2013-05-08 06:42:28 +04:00
|
|
|
|
2013-11-25 14:42:49 +04:00
|
|
|
assert((pointer != NULL && touch == NULL) ||
|
|
|
|
(pointer == NULL && touch != NULL));
|
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-13 07:38:11 +04:00
|
|
|
|
2013-05-08 06:42:28 +04:00
|
|
|
if (!weston_surface_is_mapped(es) && es->buffer_ref.buffer) {
|
2013-11-25 14:42:49 +04:00
|
|
|
if (pointer && pointer->sprite &&
|
|
|
|
weston_view_is_mapped(pointer->sprite))
|
2013-05-08 23:02:05 +04:00
|
|
|
list = &pointer->sprite->layer_link;
|
2013-05-08 06:42:28 +04:00
|
|
|
else
|
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-13 07:38:11 +04:00
|
|
|
list = &es->compositor->cursor_layer.view_list;
|
2013-05-08 06:42:28 +04:00
|
|
|
|
2014-07-09 23:12:56 +04:00
|
|
|
weston_layer_entry_remove(&drag->icon->layer_link);
|
|
|
|
weston_layer_entry_insert(list, &drag->icon->layer_link);
|
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-13 07:38:11 +04:00
|
|
|
weston_view_update_transform(drag->icon);
|
2014-06-26 21:37:36 +04:00
|
|
|
pixman_region32_clear(&es->pending.input);
|
2016-06-30 07:04:28 +03:00
|
|
|
es->is_mapped = true;
|
|
|
|
drag->icon->is_mapped = true;
|
2013-05-08 06:42:28 +04:00
|
|
|
}
|
2013-05-07 19:18:46 +04:00
|
|
|
|
2013-05-08 23:27:47 +04:00
|
|
|
drag->dx += sx;
|
|
|
|
drag->dy += sy;
|
2013-05-08 06:53:43 +04:00
|
|
|
|
2013-11-25 14:42:49 +04:00
|
|
|
/* init to 0 for avoiding a compile warning */
|
|
|
|
fx = fy = 0;
|
|
|
|
if (pointer) {
|
|
|
|
fx = wl_fixed_to_double(pointer->x) + drag->dx;
|
|
|
|
fy = wl_fixed_to_double(pointer->y) + drag->dy;
|
|
|
|
} else if (touch) {
|
|
|
|
fx = wl_fixed_to_double(touch->grab_x) + drag->dx;
|
|
|
|
fy = wl_fixed_to_double(touch->grab_y) + drag->dy;
|
|
|
|
}
|
2013-12-03 07:01:53 +04:00
|
|
|
weston_view_set_position(drag->icon, fx, fy);
|
2013-05-07 19:18:46 +04:00
|
|
|
}
|
|
|
|
|
compositor: add weston_surface_set_label_func()
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>
2014-08-06 20:36:51 +04:00
|
|
|
static int
|
|
|
|
pointer_drag_surface_get_label(struct weston_surface *surface,
|
|
|
|
char *buf, size_t len)
|
|
|
|
{
|
|
|
|
return snprintf(buf, len, "pointer drag icon");
|
|
|
|
}
|
|
|
|
|
2013-11-25 14:42:49 +04:00
|
|
|
static void
|
2016-08-12 11:41:33 +03:00
|
|
|
pointer_drag_surface_committed(struct weston_surface *es,
|
2013-12-04 01:30:17 +04:00
|
|
|
int32_t sx, int32_t sy)
|
2013-11-25 14:42:49 +04:00
|
|
|
{
|
2016-08-12 11:41:33 +03:00
|
|
|
struct weston_pointer_drag *drag = es->committed_private;
|
2013-11-25 14:42:49 +04:00
|
|
|
struct weston_pointer *pointer = drag->grab.pointer;
|
|
|
|
|
2016-08-12 11:41:33 +03:00
|
|
|
assert(es->committed == pointer_drag_surface_committed);
|
2013-11-25 14:42:49 +04:00
|
|
|
|
2013-12-04 01:30:17 +04:00
|
|
|
drag_surface_configure(&drag->base, pointer, NULL, es, sx, sy);
|
2013-11-25 14:42:49 +04:00
|
|
|
}
|
|
|
|
|
compositor: add weston_surface_set_label_func()
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>
2014-08-06 20:36:51 +04:00
|
|
|
static int
|
|
|
|
touch_drag_surface_get_label(struct weston_surface *surface,
|
|
|
|
char *buf, size_t len)
|
|
|
|
{
|
|
|
|
return snprintf(buf, len, "touch drag icon");
|
|
|
|
}
|
|
|
|
|
2013-11-25 14:42:49 +04:00
|
|
|
static void
|
2016-08-12 11:41:33 +03:00
|
|
|
touch_drag_surface_committed(struct weston_surface *es, int32_t sx, int32_t sy)
|
2013-11-25 14:42:49 +04:00
|
|
|
{
|
2016-08-12 11:41:33 +03:00
|
|
|
struct weston_touch_drag *drag = es->committed_private;
|
2013-11-25 14:42:49 +04:00
|
|
|
struct weston_touch *touch = drag->grab.touch;
|
|
|
|
|
2016-08-12 11:41:33 +03:00
|
|
|
assert(es->committed == touch_drag_surface_committed);
|
2013-11-25 14:42:49 +04:00
|
|
|
|
2013-12-04 01:30:17 +04:00
|
|
|
drag_surface_configure(&drag->base, NULL, touch, es, sx, sy);
|
2013-11-25 14:42:49 +04:00
|
|
|
}
|
|
|
|
|
2013-04-18 23:07:39 +04:00
|
|
|
static void
|
|
|
|
destroy_drag_focus(struct wl_listener *listener, void *data)
|
|
|
|
{
|
2013-05-08 23:27:47 +04:00
|
|
|
struct weston_drag *drag =
|
|
|
|
container_of(listener, struct weston_drag, focus_listener);
|
2013-04-18 23:07:39 +04:00
|
|
|
|
2013-05-08 23:27:47 +04:00
|
|
|
drag->focus_resource = NULL;
|
2013-04-18 23:07:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-11-25 14:42:49 +04:00
|
|
|
weston_drag_set_focus(struct weston_drag *drag,
|
|
|
|
struct weston_seat *seat,
|
|
|
|
struct weston_view *view,
|
|
|
|
wl_fixed_t sx, wl_fixed_t sy)
|
2013-04-18 23:07:39 +04:00
|
|
|
{
|
2016-01-15 23:14:23 +03:00
|
|
|
struct wl_resource *resource, *offer_resource = NULL;
|
2013-11-25 14:42:49 +04:00
|
|
|
struct wl_display *display = seat->compositor->wl_display;
|
2016-01-15 23:14:23 +03:00
|
|
|
struct weston_data_offer *offer;
|
2013-04-18 23:07:39 +04:00
|
|
|
uint32_t serial;
|
|
|
|
|
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-13 07:38:11 +04:00
|
|
|
if (drag->focus && view && drag->focus->surface == view->surface) {
|
|
|
|
drag->focus = view;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-08 23:27:47 +04:00
|
|
|
if (drag->focus_resource) {
|
|
|
|
wl_data_device_send_leave(drag->focus_resource);
|
|
|
|
wl_list_remove(&drag->focus_listener.link);
|
|
|
|
drag->focus_resource = NULL;
|
|
|
|
drag->focus = NULL;
|
2013-04-18 23:07:39 +04:00
|
|
|
}
|
|
|
|
|
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-13 07:38:11 +04:00
|
|
|
if (!view || !view->surface->resource)
|
2013-04-18 23:07:39 +04:00
|
|
|
return;
|
|
|
|
|
2013-06-07 07:34:41 +04:00
|
|
|
if (!drag->data_source &&
|
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-13 07:38:11 +04:00
|
|
|
wl_resource_get_client(view->surface->resource) != drag->client)
|
2013-04-18 23:07:39 +04:00
|
|
|
return;
|
|
|
|
|
2016-01-15 23:14:23 +03:00
|
|
|
if (drag->data_source &&
|
|
|
|
drag->data_source->offer) {
|
|
|
|
/* Unlink the offer from the source */
|
|
|
|
offer = drag->data_source->offer;
|
|
|
|
offer->source = NULL;
|
|
|
|
drag->data_source->offer = NULL;
|
|
|
|
wl_list_remove(&offer->source_destroy_listener.link);
|
|
|
|
}
|
|
|
|
|
2013-11-25 14:42:49 +04:00
|
|
|
resource = wl_resource_find_for_client(&seat->drag_resource_list,
|
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-13 07:38:11 +04:00
|
|
|
wl_resource_get_client(view->surface->resource));
|
2013-04-18 23:07:39 +04:00
|
|
|
if (!resource)
|
|
|
|
return;
|
|
|
|
|
|
|
|
serial = wl_display_next_serial(display);
|
|
|
|
|
2013-08-21 02:58:25 +04:00
|
|
|
if (drag->data_source) {
|
2016-01-15 23:14:23 +03:00
|
|
|
drag->data_source->accepted = false;
|
2016-03-15 10:23:50 +03:00
|
|
|
offer = weston_data_source_send_offer(drag->data_source, resource);
|
|
|
|
if (offer == NULL)
|
2013-08-21 02:58:25 +04:00
|
|
|
return;
|
2016-01-19 01:52:12 +03:00
|
|
|
|
2016-03-15 10:23:50 +03:00
|
|
|
data_offer_update_action(offer);
|
|
|
|
|
|
|
|
offer_resource = offer->resource;
|
2016-01-19 01:52:12 +03:00
|
|
|
if (wl_resource_get_version (offer_resource) >=
|
|
|
|
WL_DATA_OFFER_SOURCE_ACTIONS_SINCE_VERSION) {
|
|
|
|
wl_data_offer_send_source_actions (offer_resource,
|
|
|
|
drag->data_source->dnd_actions);
|
|
|
|
}
|
2013-08-21 02:58:25 +04:00
|
|
|
}
|
2013-04-18 23:07:39 +04:00
|
|
|
|
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-13 07:38:11 +04:00
|
|
|
wl_data_device_send_enter(resource, serial, view->surface->resource,
|
2016-01-15 23:14:23 +03:00
|
|
|
sx, sy, offer_resource);
|
2013-04-18 23:07:39 +04:00
|
|
|
|
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-13 07:38:11 +04:00
|
|
|
drag->focus = view;
|
2013-05-08 23:27:47 +04:00
|
|
|
drag->focus_listener.notify = destroy_drag_focus;
|
2013-06-14 19:07:55 +04:00
|
|
|
wl_resource_add_destroy_listener(resource, &drag->focus_listener);
|
2013-05-08 23:27:47 +04:00
|
|
|
drag->focus_resource = resource;
|
2013-04-18 23:07:39 +04:00
|
|
|
}
|
|
|
|
|
2013-05-09 06:02:59 +04:00
|
|
|
static void
|
|
|
|
drag_grab_focus(struct weston_pointer_grab *grab)
|
|
|
|
{
|
2013-11-25 14:42:49 +04:00
|
|
|
struct weston_pointer_drag *drag =
|
|
|
|
container_of(grab, struct weston_pointer_drag, grab);
|
2013-05-09 06:02:59 +04:00
|
|
|
struct weston_pointer *pointer = grab->pointer;
|
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-13 07:38:11 +04:00
|
|
|
struct weston_view *view;
|
2013-05-09 06:02:59 +04:00
|
|
|
wl_fixed_t sx, sy;
|
|
|
|
|
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-13 07:38:11 +04:00
|
|
|
view = weston_compositor_pick_view(pointer->seat->compositor,
|
|
|
|
pointer->x, pointer->y,
|
|
|
|
&sx, &sy);
|
2013-11-25 14:42:49 +04:00
|
|
|
if (drag->base.focus != view)
|
|
|
|
weston_drag_set_focus(&drag->base, pointer->seat, view, sx, sy);
|
2013-05-09 06:02:59 +04:00
|
|
|
}
|
|
|
|
|
2013-04-18 23:07:39 +04:00
|
|
|
static void
|
2017-11-24 19:01:46 +03:00
|
|
|
drag_grab_motion(struct weston_pointer_grab *grab,
|
|
|
|
const struct timespec *time,
|
2014-10-05 23:39:14 +04:00
|
|
|
struct weston_pointer_motion_event *event)
|
2013-04-18 23:07:39 +04:00
|
|
|
{
|
2013-11-25 14:42:49 +04:00
|
|
|
struct weston_pointer_drag *drag =
|
|
|
|
container_of(grab, struct weston_pointer_drag, grab);
|
2013-05-08 23:27:47 +04:00
|
|
|
struct weston_pointer *pointer = drag->grab.pointer;
|
2013-05-08 06:53:43 +04:00
|
|
|
float fx, fy;
|
2013-05-09 05:03:21 +04:00
|
|
|
wl_fixed_t sx, sy;
|
2017-11-24 19:01:46 +03:00
|
|
|
uint32_t msecs;
|
2013-05-08 06:53:43 +04:00
|
|
|
|
2014-10-05 23:39:14 +04:00
|
|
|
weston_pointer_move(pointer, event);
|
2013-11-15 02:42:52 +04:00
|
|
|
|
2013-11-25 14:42:49 +04:00
|
|
|
if (drag->base.icon) {
|
|
|
|
fx = wl_fixed_to_double(pointer->x) + drag->base.dx;
|
|
|
|
fy = wl_fixed_to_double(pointer->y) + drag->base.dy;
|
|
|
|
weston_view_set_position(drag->base.icon, fx, fy);
|
|
|
|
weston_view_schedule_repaint(drag->base.icon);
|
2013-05-08 06:53:43 +04:00
|
|
|
}
|
2013-04-18 23:07:39 +04:00
|
|
|
|
2013-11-25 14:42:49 +04:00
|
|
|
if (drag->base.focus_resource) {
|
2017-11-24 19:01:46 +03:00
|
|
|
msecs = timespec_to_msec(time);
|
2013-11-25 14:42:49 +04:00
|
|
|
weston_view_from_global_fixed(drag->base.focus,
|
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-13 07:38:11 +04:00
|
|
|
pointer->x, pointer->y,
|
|
|
|
&sx, &sy);
|
2013-05-09 05:03:21 +04:00
|
|
|
|
2017-11-24 19:01:46 +03:00
|
|
|
wl_data_device_send_motion(drag->base.focus_resource, msecs, sx, sy);
|
2013-05-09 05:03:21 +04:00
|
|
|
}
|
2013-04-18 23:07:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-11-25 14:42:49 +04:00
|
|
|
data_device_end_drag_grab(struct weston_drag *drag,
|
|
|
|
struct weston_seat *seat)
|
2013-04-18 23:07:39 +04:00
|
|
|
{
|
2013-05-08 23:47:52 +04:00
|
|
|
if (drag->icon) {
|
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-13 07:38:11 +04:00
|
|
|
if (weston_view_is_mapped(drag->icon))
|
|
|
|
weston_view_unmap(drag->icon);
|
2013-05-08 23:47:52 +04:00
|
|
|
|
2016-08-12 11:41:33 +03:00
|
|
|
drag->icon->surface->committed = NULL;
|
compositor: add weston_surface_set_label_func()
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>
2014-08-06 20:36:51 +04:00
|
|
|
weston_surface_set_label_func(drag->icon->surface, NULL);
|
2014-06-26 21:37:36 +04:00
|
|
|
pixman_region32_clear(&drag->icon->surface->pending.input);
|
2013-05-08 23:47:52 +04:00
|
|
|
wl_list_remove(&drag->icon_destroy_listener.link);
|
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-13 07:38:11 +04:00
|
|
|
weston_view_destroy(drag->icon);
|
2013-05-08 23:47:52 +04:00
|
|
|
}
|
2013-04-18 23:07:39 +04:00
|
|
|
|
2013-11-25 14:42:49 +04:00
|
|
|
weston_drag_set_focus(drag, seat, NULL, 0, 0);
|
|
|
|
}
|
2013-04-18 23:07:39 +04:00
|
|
|
|
2013-11-25 14:42:49 +04:00
|
|
|
static void
|
|
|
|
data_device_end_pointer_drag_grab(struct weston_pointer_drag *drag)
|
|
|
|
{
|
|
|
|
struct weston_pointer *pointer = drag->grab.pointer;
|
2016-01-15 23:14:26 +03:00
|
|
|
struct weston_keyboard *keyboard = drag->base.keyboard_grab.keyboard;
|
2013-04-18 23:07:39 +04:00
|
|
|
|
2013-11-25 14:42:49 +04:00
|
|
|
data_device_end_drag_grab(&drag->base, pointer->seat);
|
|
|
|
weston_pointer_end_grab(pointer);
|
2021-04-05 23:10:50 +03:00
|
|
|
if (keyboard)
|
|
|
|
weston_keyboard_end_grab(keyboard);
|
2013-05-08 23:27:47 +04:00
|
|
|
free(drag);
|
2013-04-18 23:07:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-05-07 06:15:05 +04:00
|
|
|
drag_grab_button(struct weston_pointer_grab *grab,
|
2017-11-16 19:20:55 +03:00
|
|
|
const struct timespec *time,
|
|
|
|
uint32_t button, uint32_t state_w)
|
2013-04-18 23:07:39 +04:00
|
|
|
{
|
2013-11-25 14:42:49 +04:00
|
|
|
struct weston_pointer_drag *drag =
|
|
|
|
container_of(grab, struct weston_pointer_drag, grab);
|
2013-05-08 23:27:47 +04:00
|
|
|
struct weston_pointer *pointer = drag->grab.pointer;
|
2013-04-18 23:07:39 +04:00
|
|
|
enum wl_pointer_button_state state = state_w;
|
2016-01-15 23:14:23 +03:00
|
|
|
struct weston_data_source *data_source = drag->base.data_source;
|
2013-04-18 23:07:39 +04:00
|
|
|
|
2016-01-15 23:14:23 +03:00
|
|
|
if (data_source &&
|
2013-05-08 23:27:47 +04:00
|
|
|
pointer->grab_button == button &&
|
2016-01-15 23:14:23 +03:00
|
|
|
state == WL_POINTER_BUTTON_STATE_RELEASED) {
|
|
|
|
if (drag->base.focus_resource &&
|
2016-01-19 01:52:12 +03:00
|
|
|
data_source->accepted &&
|
|
|
|
data_source->current_dnd_action) {
|
2016-01-15 23:14:23 +03:00
|
|
|
wl_data_device_send_drop(drag->base.focus_resource);
|
|
|
|
|
|
|
|
if (wl_resource_get_version(data_source->resource) >=
|
|
|
|
WL_DATA_SOURCE_DND_DROP_PERFORMED_SINCE_VERSION)
|
|
|
|
wl_data_source_send_dnd_drop_performed(data_source->resource);
|
|
|
|
|
2016-01-19 01:52:12 +03:00
|
|
|
data_source->offer->in_ask =
|
|
|
|
data_source->current_dnd_action ==
|
|
|
|
WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK;
|
|
|
|
|
2016-01-15 23:14:23 +03:00
|
|
|
data_source->seat = NULL;
|
|
|
|
} else if (wl_resource_get_version(data_source->resource) >=
|
|
|
|
WL_DATA_SOURCE_DND_FINISHED_SINCE_VERSION) {
|
|
|
|
wl_data_source_send_cancelled(data_source->resource);
|
|
|
|
}
|
|
|
|
}
|
2013-04-18 23:07:39 +04:00
|
|
|
|
2013-05-08 23:27:47 +04:00
|
|
|
if (pointer->button_count == 0 &&
|
2013-04-18 23:07:39 +04:00
|
|
|
state == WL_POINTER_BUTTON_STATE_RELEASED) {
|
2013-11-25 14:42:49 +04:00
|
|
|
if (drag->base.data_source)
|
|
|
|
wl_list_remove(&drag->base.data_source_listener.link);
|
|
|
|
data_device_end_pointer_drag_grab(drag);
|
2013-04-18 23:07:39 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-04 18:28:29 +04:00
|
|
|
static void
|
|
|
|
drag_grab_axis(struct weston_pointer_grab *grab,
|
2017-11-16 19:20:56 +03:00
|
|
|
const struct timespec *time,
|
|
|
|
struct weston_pointer_axis_event *event)
|
2014-10-04 18:28:29 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-01-18 09:38:22 +03:00
|
|
|
static void
|
|
|
|
drag_grab_axis_source(struct weston_pointer_grab *grab, uint32_t source)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
drag_grab_frame(struct weston_pointer_grab *grab)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-10-26 01:18:05 +04:00
|
|
|
static void
|
|
|
|
drag_grab_cancel(struct weston_pointer_grab *grab)
|
|
|
|
{
|
2013-11-25 14:42:49 +04:00
|
|
|
struct weston_pointer_drag *drag =
|
|
|
|
container_of(grab, struct weston_pointer_drag, grab);
|
2013-10-26 01:18:05 +04:00
|
|
|
|
2013-11-25 14:42:49 +04:00
|
|
|
if (drag->base.data_source)
|
|
|
|
wl_list_remove(&drag->base.data_source_listener.link);
|
2013-10-26 01:18:05 +04:00
|
|
|
|
2013-11-25 14:42:49 +04:00
|
|
|
data_device_end_pointer_drag_grab(drag);
|
2013-10-26 01:18:05 +04:00
|
|
|
}
|
|
|
|
|
2013-11-25 14:42:49 +04:00
|
|
|
static const struct weston_pointer_grab_interface pointer_drag_grab_interface = {
|
2013-04-18 23:07:39 +04:00
|
|
|
drag_grab_focus,
|
|
|
|
drag_grab_motion,
|
|
|
|
drag_grab_button,
|
2014-10-04 18:28:29 +04:00
|
|
|
drag_grab_axis,
|
2016-01-18 09:38:22 +03:00
|
|
|
drag_grab_axis_source,
|
|
|
|
drag_grab_frame,
|
2013-10-26 01:18:05 +04:00
|
|
|
drag_grab_cancel,
|
2013-04-18 23:07:39 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2017-11-16 19:20:58 +03:00
|
|
|
drag_grab_touch_down(struct weston_touch_grab *grab,
|
|
|
|
const struct timespec *time, int touch_id,
|
|
|
|
wl_fixed_t sx, wl_fixed_t sy)
|
2013-04-18 23:07:39 +04:00
|
|
|
{
|
2013-11-25 14:42:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
data_device_end_touch_drag_grab(struct weston_touch_drag *drag)
|
|
|
|
{
|
|
|
|
struct weston_touch *touch = drag->grab.touch;
|
2016-01-15 23:14:26 +03:00
|
|
|
struct weston_keyboard *keyboard = drag->base.keyboard_grab.keyboard;
|
2013-11-25 14:42:49 +04:00
|
|
|
|
|
|
|
data_device_end_drag_grab(&drag->base, touch->seat);
|
|
|
|
weston_touch_end_grab(touch);
|
2021-04-05 23:10:50 +03:00
|
|
|
if (keyboard)
|
|
|
|
weston_keyboard_end_grab(keyboard);
|
2013-11-25 14:42:49 +04:00
|
|
|
free(drag);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
drag_grab_touch_up(struct weston_touch_grab *grab,
|
2017-11-16 19:20:59 +03:00
|
|
|
const struct timespec *time, int touch_id)
|
2013-11-25 14:42:49 +04:00
|
|
|
{
|
|
|
|
struct weston_touch_drag *touch_drag =
|
|
|
|
container_of(grab, struct weston_touch_drag, grab);
|
|
|
|
struct weston_touch *touch = grab->touch;
|
|
|
|
|
|
|
|
if (touch_id != touch->grab_touch_id)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (touch_drag->base.focus_resource)
|
|
|
|
wl_data_device_send_drop(touch_drag->base.focus_resource);
|
2021-04-23 06:25:18 +03:00
|
|
|
if (touch_drag->base.data_source) {
|
|
|
|
touch_drag->base.data_source->seat = NULL;
|
2013-11-25 14:42:49 +04:00
|
|
|
wl_list_remove(&touch_drag->base.data_source_listener.link);
|
2021-04-23 06:25:18 +03:00
|
|
|
}
|
2013-11-25 14:42:49 +04:00
|
|
|
data_device_end_touch_drag_grab(touch_drag);
|
|
|
|
}
|
2013-04-18 23:07:39 +04:00
|
|
|
|
2013-11-25 14:42:49 +04:00
|
|
|
static void
|
|
|
|
drag_grab_touch_focus(struct weston_touch_drag *drag)
|
|
|
|
{
|
|
|
|
struct weston_touch *touch = drag->grab.touch;
|
|
|
|
struct weston_view *view;
|
|
|
|
wl_fixed_t view_x, view_y;
|
|
|
|
|
|
|
|
view = weston_compositor_pick_view(touch->seat->compositor,
|
|
|
|
touch->grab_x, touch->grab_y,
|
|
|
|
&view_x, &view_y);
|
|
|
|
if (drag->base.focus != view)
|
|
|
|
weston_drag_set_focus(&drag->base, touch->seat,
|
|
|
|
view, view_x, view_y);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-11-16 19:21:00 +03:00
|
|
|
drag_grab_touch_motion(struct weston_touch_grab *grab,
|
|
|
|
const struct timespec *time,
|
|
|
|
int touch_id, wl_fixed_t x, wl_fixed_t y)
|
2013-11-25 14:42:49 +04:00
|
|
|
{
|
|
|
|
struct weston_touch_drag *touch_drag =
|
|
|
|
container_of(grab, struct weston_touch_drag, grab);
|
|
|
|
struct weston_touch *touch = grab->touch;
|
|
|
|
wl_fixed_t view_x, view_y;
|
|
|
|
float fx, fy;
|
2017-11-16 19:21:00 +03:00
|
|
|
uint32_t msecs;
|
2013-11-25 14:42:49 +04:00
|
|
|
|
|
|
|
if (touch_id != touch->grab_touch_id)
|
|
|
|
return;
|
|
|
|
|
|
|
|
drag_grab_touch_focus(touch_drag);
|
|
|
|
if (touch_drag->base.icon) {
|
|
|
|
fx = wl_fixed_to_double(touch->grab_x) + touch_drag->base.dx;
|
|
|
|
fy = wl_fixed_to_double(touch->grab_y) + touch_drag->base.dy;
|
|
|
|
weston_view_set_position(touch_drag->base.icon, fx, fy);
|
|
|
|
weston_view_schedule_repaint(touch_drag->base.icon);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (touch_drag->base.focus_resource) {
|
2017-11-16 19:21:00 +03:00
|
|
|
msecs = timespec_to_msec(time);
|
2013-11-25 14:42:49 +04:00
|
|
|
weston_view_from_global_fixed(touch_drag->base.focus,
|
|
|
|
touch->grab_x, touch->grab_y,
|
|
|
|
&view_x, &view_y);
|
2017-11-16 19:21:00 +03:00
|
|
|
wl_data_device_send_motion(touch_drag->base.focus_resource,
|
|
|
|
msecs, view_x, view_y);
|
2013-11-25 14:42:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-12 11:39:51 +04:00
|
|
|
static void
|
|
|
|
drag_grab_touch_frame(struct weston_touch_grab *grab)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-11-25 14:42:49 +04:00
|
|
|
static void
|
|
|
|
drag_grab_touch_cancel(struct weston_touch_grab *grab)
|
|
|
|
{
|
|
|
|
struct weston_touch_drag *touch_drag =
|
|
|
|
container_of(grab, struct weston_touch_drag, grab);
|
|
|
|
|
|
|
|
if (touch_drag->base.data_source)
|
|
|
|
wl_list_remove(&touch_drag->base.data_source_listener.link);
|
|
|
|
data_device_end_touch_drag_grab(touch_drag);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct weston_touch_grab_interface touch_drag_grab_interface = {
|
|
|
|
drag_grab_touch_down,
|
|
|
|
drag_grab_touch_up,
|
|
|
|
drag_grab_touch_motion,
|
2014-04-12 11:39:51 +04:00
|
|
|
drag_grab_touch_frame,
|
2013-11-25 14:42:49 +04:00
|
|
|
drag_grab_touch_cancel
|
|
|
|
};
|
|
|
|
|
2016-01-15 23:14:26 +03:00
|
|
|
static void
|
|
|
|
drag_grab_keyboard_key(struct weston_keyboard_grab *grab,
|
2017-11-16 19:20:57 +03:00
|
|
|
const struct timespec *time, uint32_t key, uint32_t state)
|
2016-01-15 23:14:26 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
drag_grab_keyboard_modifiers(struct weston_keyboard_grab *grab,
|
|
|
|
uint32_t serial, uint32_t mods_depressed,
|
|
|
|
uint32_t mods_latched,
|
|
|
|
uint32_t mods_locked, uint32_t group)
|
|
|
|
{
|
|
|
|
struct weston_keyboard *keyboard = grab->keyboard;
|
|
|
|
struct weston_drag *drag =
|
|
|
|
container_of(grab, struct weston_drag, keyboard_grab);
|
|
|
|
uint32_t compositor_action;
|
|
|
|
|
|
|
|
if (mods_depressed & (1 << keyboard->xkb_info->shift_mod))
|
|
|
|
compositor_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
|
|
|
|
else if (mods_depressed & (1 << keyboard->xkb_info->ctrl_mod))
|
|
|
|
compositor_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
|
|
|
|
else
|
|
|
|
compositor_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
|
|
|
|
|
|
|
|
drag->data_source->compositor_action = compositor_action;
|
|
|
|
|
|
|
|
if (drag->data_source->offer)
|
|
|
|
data_offer_update_action(drag->data_source->offer);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
drag_grab_keyboard_cancel(struct weston_keyboard_grab *grab)
|
|
|
|
{
|
|
|
|
struct weston_drag *drag =
|
|
|
|
container_of(grab, struct weston_drag, keyboard_grab);
|
|
|
|
struct weston_pointer *pointer = grab->keyboard->seat->pointer_state;
|
|
|
|
struct weston_touch *touch = grab->keyboard->seat->touch_state;
|
|
|
|
|
|
|
|
if (pointer && pointer->grab->interface == &pointer_drag_grab_interface) {
|
|
|
|
struct weston_touch_drag *touch_drag =
|
|
|
|
(struct weston_touch_drag *) drag;
|
|
|
|
drag_grab_touch_cancel(&touch_drag->grab);
|
|
|
|
} else if (touch && touch->grab->interface == &touch_drag_grab_interface) {
|
|
|
|
struct weston_pointer_drag *pointer_drag =
|
|
|
|
(struct weston_pointer_drag *) drag;
|
|
|
|
drag_grab_cancel(&pointer_drag->grab);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct weston_keyboard_grab_interface keyboard_drag_grab_interface = {
|
|
|
|
drag_grab_keyboard_key,
|
|
|
|
drag_grab_keyboard_modifiers,
|
|
|
|
drag_grab_keyboard_cancel
|
|
|
|
};
|
|
|
|
|
2013-11-25 14:42:49 +04:00
|
|
|
static void
|
|
|
|
destroy_pointer_data_device_source(struct wl_listener *listener, void *data)
|
|
|
|
{
|
|
|
|
struct weston_pointer_drag *drag = container_of(listener,
|
|
|
|
struct weston_pointer_drag, base.data_source_listener);
|
|
|
|
|
|
|
|
data_device_end_pointer_drag_grab(drag);
|
2013-04-18 23:07:39 +04:00
|
|
|
}
|
|
|
|
|
2013-05-07 19:18:46 +04:00
|
|
|
static void
|
2013-05-08 23:30:42 +04:00
|
|
|
handle_drag_icon_destroy(struct wl_listener *listener, void *data)
|
2013-05-07 19:18:46 +04:00
|
|
|
{
|
2013-05-08 23:27:47 +04:00
|
|
|
struct weston_drag *drag = container_of(listener, struct weston_drag,
|
2013-05-08 23:30:42 +04:00
|
|
|
icon_destroy_listener);
|
2013-05-07 19:18:46 +04:00
|
|
|
|
2013-05-08 23:30:42 +04:00
|
|
|
drag->icon = NULL;
|
2013-05-07 19:18:46 +04:00
|
|
|
}
|
|
|
|
|
2013-09-05 07:44:26 +04:00
|
|
|
WL_EXPORT int
|
2013-11-25 14:42:49 +04:00
|
|
|
weston_pointer_start_drag(struct weston_pointer *pointer,
|
2013-09-05 07:44:26 +04:00
|
|
|
struct weston_data_source *source,
|
|
|
|
struct weston_surface *icon,
|
|
|
|
struct wl_client *client)
|
|
|
|
{
|
2013-11-25 14:42:49 +04:00
|
|
|
struct weston_pointer_drag *drag;
|
2016-01-15 23:14:26 +03:00
|
|
|
struct weston_keyboard *keyboard =
|
|
|
|
weston_seat_get_keyboard(pointer->seat);
|
2013-09-05 07:44:26 +04:00
|
|
|
|
|
|
|
drag = zalloc(sizeof *drag);
|
|
|
|
if (drag == NULL)
|
|
|
|
return -1;
|
|
|
|
|
2013-11-25 14:42:49 +04:00
|
|
|
drag->grab.interface = &pointer_drag_grab_interface;
|
2016-01-15 23:14:26 +03:00
|
|
|
drag->base.keyboard_grab.interface = &keyboard_drag_grab_interface;
|
2013-11-25 14:42:49 +04:00
|
|
|
drag->base.client = client;
|
|
|
|
drag->base.data_source = source;
|
2013-09-05 07:44:26 +04:00
|
|
|
|
|
|
|
if (icon) {
|
2013-11-25 14:42:49 +04:00
|
|
|
drag->base.icon = weston_view_create(icon);
|
|
|
|
if (drag->base.icon == NULL) {
|
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-13 07:38:11 +04:00
|
|
|
free(drag);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-11-25 14:42:49 +04:00
|
|
|
drag->base.icon_destroy_listener.notify = handle_drag_icon_destroy;
|
2013-09-05 07:44:26 +04:00
|
|
|
wl_signal_add(&icon->destroy_signal,
|
2013-11-25 14:42:49 +04:00
|
|
|
&drag->base.icon_destroy_listener);
|
2013-09-05 07:44:26 +04:00
|
|
|
|
2016-08-12 11:41:33 +03:00
|
|
|
icon->committed = pointer_drag_surface_committed;
|
|
|
|
icon->committed_private = drag;
|
compositor: add weston_surface_set_label_func()
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>
2014-08-06 20:36:51 +04:00
|
|
|
weston_surface_set_label_func(icon,
|
|
|
|
pointer_drag_surface_get_label);
|
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-13 07:38:11 +04:00
|
|
|
} else {
|
2013-11-25 14:42:49 +04:00
|
|
|
drag->base.icon = NULL;
|
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-13 07:38:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (source) {
|
2013-11-25 14:42:49 +04:00
|
|
|
drag->base.data_source_listener.notify = destroy_pointer_data_device_source;
|
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-13 07:38:11 +04:00
|
|
|
wl_signal_add(&source->destroy_signal,
|
2013-11-25 14:42:49 +04:00
|
|
|
&drag->base.data_source_listener);
|
2013-09-05 07:44:26 +04:00
|
|
|
}
|
|
|
|
|
2015-05-11 23:40:11 +03:00
|
|
|
weston_pointer_clear_focus(pointer);
|
2021-04-05 23:10:50 +03:00
|
|
|
if (keyboard)
|
|
|
|
weston_keyboard_set_focus(keyboard, NULL);
|
2016-01-15 23:14:26 +03:00
|
|
|
|
2013-11-25 14:42:49 +04:00
|
|
|
weston_pointer_start_grab(pointer, &drag->grab);
|
2021-04-05 23:10:50 +03:00
|
|
|
if (keyboard)
|
|
|
|
weston_keyboard_start_grab(keyboard, &drag->base.keyboard_grab);
|
2013-11-25 14:42:49 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
destroy_touch_data_device_source(struct wl_listener *listener, void *data)
|
|
|
|
{
|
|
|
|
struct weston_touch_drag *drag = container_of(listener,
|
|
|
|
struct weston_touch_drag, base.data_source_listener);
|
|
|
|
|
|
|
|
data_device_end_touch_drag_grab(drag);
|
|
|
|
}
|
|
|
|
|
|
|
|
WL_EXPORT int
|
|
|
|
weston_touch_start_drag(struct weston_touch *touch,
|
|
|
|
struct weston_data_source *source,
|
|
|
|
struct weston_surface *icon,
|
|
|
|
struct wl_client *client)
|
|
|
|
{
|
|
|
|
struct weston_touch_drag *drag;
|
2016-01-15 23:14:26 +03:00
|
|
|
struct weston_keyboard *keyboard =
|
|
|
|
weston_seat_get_keyboard(touch->seat);
|
2013-11-25 14:42:49 +04:00
|
|
|
|
|
|
|
drag = zalloc(sizeof *drag);
|
|
|
|
if (drag == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
drag->grab.interface = &touch_drag_grab_interface;
|
|
|
|
drag->base.client = client;
|
|
|
|
drag->base.data_source = source;
|
|
|
|
|
|
|
|
if (icon) {
|
|
|
|
drag->base.icon = weston_view_create(icon);
|
|
|
|
if (drag->base.icon == NULL) {
|
|
|
|
free(drag);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
drag->base.icon_destroy_listener.notify = handle_drag_icon_destroy;
|
|
|
|
wl_signal_add(&icon->destroy_signal,
|
|
|
|
&drag->base.icon_destroy_listener);
|
|
|
|
|
2016-08-12 11:41:33 +03:00
|
|
|
icon->committed = touch_drag_surface_committed;
|
|
|
|
icon->committed_private = drag;
|
compositor: add weston_surface_set_label_func()
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>
2014-08-06 20:36:51 +04:00
|
|
|
weston_surface_set_label_func(icon,
|
|
|
|
touch_drag_surface_get_label);
|
2013-11-25 14:42:49 +04:00
|
|
|
} else {
|
|
|
|
drag->base.icon = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (source) {
|
|
|
|
drag->base.data_source_listener.notify = destroy_touch_data_device_source;
|
|
|
|
wl_signal_add(&source->destroy_signal,
|
|
|
|
&drag->base.data_source_listener);
|
|
|
|
}
|
|
|
|
|
2021-04-05 23:10:50 +03:00
|
|
|
if (keyboard)
|
|
|
|
weston_keyboard_set_focus(keyboard, NULL);
|
2016-01-15 23:14:26 +03:00
|
|
|
|
2013-11-25 14:42:49 +04:00
|
|
|
weston_touch_start_grab(touch, &drag->grab);
|
2021-04-05 23:10:50 +03:00
|
|
|
if (keyboard)
|
|
|
|
weston_keyboard_start_grab(keyboard, &drag->base.keyboard_grab);
|
2013-11-25 14:42:49 +04:00
|
|
|
|
|
|
|
drag_grab_touch_focus(drag);
|
2013-09-11 20:42:26 +04:00
|
|
|
|
|
|
|
return 0;
|
2013-09-05 07:44:26 +04:00
|
|
|
}
|
|
|
|
|
2013-04-18 23:07:39 +04:00
|
|
|
static void
|
|
|
|
data_device_start_drag(struct wl_client *client, struct wl_resource *resource,
|
|
|
|
struct wl_resource *source_resource,
|
|
|
|
struct wl_resource *origin_resource,
|
|
|
|
struct wl_resource *icon_resource, uint32_t serial)
|
|
|
|
{
|
2013-06-14 19:08:01 +04:00
|
|
|
struct weston_seat *seat = wl_resource_get_user_data(resource);
|
2015-08-01 00:55:32 +03:00
|
|
|
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
|
|
|
|
struct weston_touch *touch = weston_seat_get_touch(seat);
|
2014-06-25 08:19:24 +04:00
|
|
|
struct weston_surface *origin = wl_resource_get_user_data(origin_resource);
|
2013-09-11 20:45:03 +04:00
|
|
|
struct weston_data_source *source = NULL;
|
2013-05-08 23:47:52 +04:00
|
|
|
struct weston_surface *icon = NULL;
|
2014-06-25 08:19:24 +04:00
|
|
|
int is_pointer_grab, is_touch_grab;
|
2013-11-25 14:42:49 +04:00
|
|
|
int32_t ret = 0;
|
2013-04-18 23:07:39 +04:00
|
|
|
|
2015-08-01 00:55:32 +03:00
|
|
|
is_pointer_grab = pointer &&
|
|
|
|
pointer->button_count == 1 &&
|
|
|
|
pointer->grab_serial == serial &&
|
|
|
|
pointer->focus &&
|
|
|
|
pointer->focus->surface == origin;
|
2014-06-25 08:19:24 +04:00
|
|
|
|
2015-08-01 00:55:32 +03:00
|
|
|
is_touch_grab = touch &&
|
|
|
|
touch->num_tp == 1 &&
|
|
|
|
touch->grab_serial == serial &&
|
|
|
|
touch->focus &&
|
|
|
|
touch->focus->surface == origin;
|
2014-06-25 08:19:24 +04:00
|
|
|
|
|
|
|
if (!is_pointer_grab && !is_touch_grab)
|
2013-05-08 23:53:42 +04:00
|
|
|
return;
|
2013-04-18 23:07:39 +04:00
|
|
|
|
|
|
|
/* FIXME: Check that the data source type array isn't empty. */
|
|
|
|
|
2013-09-05 07:44:26 +04:00
|
|
|
if (source_resource)
|
|
|
|
source = wl_resource_get_user_data(source_resource);
|
2013-05-08 23:47:52 +04:00
|
|
|
if (icon_resource)
|
2013-06-14 19:07:53 +04:00
|
|
|
icon = wl_resource_get_user_data(icon_resource);
|
compositor: send error for surface role resets
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>
2014-10-01 16:02:41 +04:00
|
|
|
|
|
|
|
if (icon) {
|
|
|
|
if (weston_surface_set_role(icon, "wl_data_device-icon",
|
|
|
|
resource,
|
|
|
|
WL_DATA_DEVICE_ERROR_ROLE) < 0)
|
|
|
|
return;
|
2013-05-08 23:47:52 +04:00
|
|
|
}
|
|
|
|
|
2014-06-25 08:19:24 +04:00
|
|
|
if (is_pointer_grab)
|
2015-08-01 00:55:32 +03:00
|
|
|
ret = weston_pointer_start_drag(pointer, source, icon, client);
|
2014-06-25 08:19:24 +04:00
|
|
|
else if (is_touch_grab)
|
2015-08-01 00:55:32 +03:00
|
|
|
ret = weston_touch_start_drag(touch, source, icon, client);
|
2013-11-25 14:42:49 +04:00
|
|
|
|
|
|
|
if (ret < 0)
|
2013-05-08 23:27:47 +04:00
|
|
|
wl_resource_post_no_memory(resource);
|
2016-01-15 23:14:23 +03:00
|
|
|
else
|
|
|
|
source->seat = seat;
|
2013-04-18 23:07:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
destroy_selection_data_source(struct wl_listener *listener, void *data)
|
|
|
|
{
|
2013-05-07 07:19:49 +04:00
|
|
|
struct weston_seat *seat = container_of(listener, struct weston_seat,
|
|
|
|
selection_data_source_listener);
|
2015-08-01 00:55:32 +03:00
|
|
|
struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
|
2013-04-18 23:07:39 +04:00
|
|
|
struct wl_resource *data_device;
|
2013-09-19 20:32:00 +04:00
|
|
|
struct weston_surface *focus = NULL;
|
2013-04-18 23:07:39 +04:00
|
|
|
|
|
|
|
seat->selection_data_source = NULL;
|
|
|
|
|
2015-08-01 00:55:32 +03:00
|
|
|
if (keyboard)
|
|
|
|
focus = keyboard->focus;
|
2013-09-19 20:32:00 +04:00
|
|
|
if (focus && focus->resource) {
|
2013-06-14 19:07:55 +04:00
|
|
|
data_device = wl_resource_find_for_client(&seat->drag_resource_list,
|
2013-09-19 20:32:00 +04:00
|
|
|
wl_resource_get_client(focus->resource));
|
2013-04-18 23:07:39 +04:00
|
|
|
if (data_device)
|
|
|
|
wl_data_device_send_selection(data_device, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_signal_emit(&seat->selection_signal, seat);
|
|
|
|
}
|
|
|
|
|
2015-05-01 12:59:35 +03:00
|
|
|
/** \brief Send the selection to the specified client
|
|
|
|
*
|
|
|
|
* This function creates a new wl_data_offer if there is a wl_data_source
|
|
|
|
* currently set as the selection and sends it to the specified client,
|
|
|
|
* followed by the wl_data_device.selection() event.
|
|
|
|
* If there is no current selection the wl_data_device.selection() event
|
|
|
|
* will carry a NULL wl_data_offer.
|
|
|
|
*
|
|
|
|
* If the client does not have a wl_data_device for the specified seat
|
|
|
|
* nothing will be done.
|
|
|
|
*
|
|
|
|
* \param seat The seat owning the wl_data_device used to send the events.
|
|
|
|
* \param client The client to which to send the selection.
|
|
|
|
*/
|
|
|
|
WL_EXPORT void
|
|
|
|
weston_seat_send_selection(struct weston_seat *seat, struct wl_client *client)
|
|
|
|
{
|
2016-03-15 10:23:50 +03:00
|
|
|
struct weston_data_offer *offer;
|
|
|
|
struct wl_resource *data_device;
|
2015-05-01 12:59:35 +03:00
|
|
|
|
2015-05-01 12:59:36 +03:00
|
|
|
wl_resource_for_each(data_device, &seat->drag_resource_list) {
|
|
|
|
if (wl_resource_get_client(data_device) != client)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (seat->selection_data_source) {
|
|
|
|
offer = weston_data_source_send_offer(seat->selection_data_source,
|
2016-03-15 10:23:50 +03:00
|
|
|
data_device);
|
|
|
|
wl_data_device_send_selection(data_device, offer->resource);
|
2015-05-01 12:59:36 +03:00
|
|
|
} else {
|
|
|
|
wl_data_device_send_selection(data_device, NULL);
|
|
|
|
}
|
2015-05-01 12:59:35 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-18 23:07:39 +04:00
|
|
|
WL_EXPORT void
|
2013-05-07 07:19:49 +04:00
|
|
|
weston_seat_set_selection(struct weston_seat *seat,
|
2013-07-26 02:52:14 +04:00
|
|
|
struct weston_data_source *source, uint32_t serial)
|
2013-04-18 23:07:39 +04:00
|
|
|
{
|
2013-09-19 20:32:00 +04:00
|
|
|
struct weston_surface *focus = NULL;
|
2015-08-01 00:55:32 +03:00
|
|
|
struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
|
2013-04-18 23:07:39 +04:00
|
|
|
|
|
|
|
if (seat->selection_data_source &&
|
|
|
|
seat->selection_serial - serial < UINT32_MAX / 2)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (seat->selection_data_source) {
|
|
|
|
seat->selection_data_source->cancel(seat->selection_data_source);
|
|
|
|
wl_list_remove(&seat->selection_data_source_listener.link);
|
|
|
|
seat->selection_data_source = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
seat->selection_data_source = source;
|
|
|
|
seat->selection_serial = serial;
|
2019-08-15 15:02:22 +03:00
|
|
|
|
|
|
|
if (source)
|
|
|
|
source->set_selection = true;
|
2013-04-18 23:07:39 +04:00
|
|
|
|
2015-08-01 00:55:32 +03:00
|
|
|
if (keyboard)
|
|
|
|
focus = keyboard->focus;
|
2013-09-19 20:32:00 +04:00
|
|
|
if (focus && focus->resource) {
|
2015-05-01 12:59:35 +03:00
|
|
|
weston_seat_send_selection(seat, wl_resource_get_client(focus->resource));
|
2013-04-18 23:07:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
wl_signal_emit(&seat->selection_signal, seat);
|
|
|
|
|
|
|
|
if (source) {
|
|
|
|
seat->selection_data_source_listener.notify =
|
|
|
|
destroy_selection_data_source;
|
2013-06-14 19:07:55 +04:00
|
|
|
wl_signal_add(&source->destroy_signal,
|
2013-04-18 23:07:39 +04:00
|
|
|
&seat->selection_data_source_listener);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
data_device_set_selection(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *source_resource, uint32_t serial)
|
|
|
|
{
|
2018-02-15 14:07:09 +03:00
|
|
|
struct weston_seat *seat = wl_resource_get_user_data(resource);
|
2016-01-19 01:52:12 +03:00
|
|
|
struct weston_data_source *source;
|
|
|
|
|
2018-02-15 14:07:09 +03:00
|
|
|
if (!seat || !source_resource)
|
2013-04-18 23:07:39 +04:00
|
|
|
return;
|
|
|
|
|
2016-01-19 01:52:12 +03:00
|
|
|
source = wl_resource_get_user_data(source_resource);
|
|
|
|
|
|
|
|
if (source->actions_set) {
|
|
|
|
wl_resource_post_error(source_resource,
|
|
|
|
WL_DATA_SOURCE_ERROR_INVALID_SOURCE,
|
|
|
|
"cannot set drag-and-drop source as selection");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-04-18 23:07:39 +04:00
|
|
|
/* FIXME: Store serial and check against incoming serial here. */
|
2018-02-15 14:07:09 +03:00
|
|
|
weston_seat_set_selection(seat, source, serial);
|
2013-04-18 23:07:39 +04:00
|
|
|
}
|
2014-10-20 10:17:15 +04:00
|
|
|
static void
|
|
|
|
data_device_release(struct wl_client *client, struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
wl_resource_destroy(resource);
|
|
|
|
}
|
2013-04-18 23:07:39 +04:00
|
|
|
|
|
|
|
static const struct wl_data_device_interface data_device_interface = {
|
|
|
|
data_device_start_drag,
|
|
|
|
data_device_set_selection,
|
2014-10-20 10:17:15 +04:00
|
|
|
data_device_release
|
2013-04-18 23:07:39 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
destroy_data_source(struct wl_resource *resource)
|
|
|
|
{
|
2013-07-26 02:52:14 +04:00
|
|
|
struct weston_data_source *source =
|
|
|
|
wl_resource_get_user_data(resource);
|
2013-04-18 23:07:39 +04:00
|
|
|
char **p;
|
|
|
|
|
2013-06-14 19:07:55 +04:00
|
|
|
wl_signal_emit(&source->destroy_signal, source);
|
|
|
|
|
2013-04-18 23:07:39 +04:00
|
|
|
wl_array_for_each(p, &source->mime_types)
|
|
|
|
free(*p);
|
|
|
|
|
|
|
|
wl_array_release(&source->mime_types);
|
|
|
|
|
2013-06-25 19:26:31 +04:00
|
|
|
free(source);
|
2013-04-18 23:07:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-07-26 02:52:14 +04:00
|
|
|
client_source_accept(struct weston_data_source *source,
|
2013-04-18 23:07:39 +04:00
|
|
|
uint32_t time, const char *mime_type)
|
|
|
|
{
|
2013-06-14 19:07:55 +04:00
|
|
|
wl_data_source_send_target(source->resource, mime_type);
|
2013-04-18 23:07:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-07-26 02:52:14 +04:00
|
|
|
client_source_send(struct weston_data_source *source,
|
2013-04-18 23:07:39 +04:00
|
|
|
const char *mime_type, int32_t fd)
|
|
|
|
{
|
2013-06-14 19:07:55 +04:00
|
|
|
wl_data_source_send_send(source->resource, mime_type, fd);
|
2013-04-18 23:07:39 +04:00
|
|
|
close(fd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-07-26 02:52:14 +04:00
|
|
|
client_source_cancel(struct weston_data_source *source)
|
2013-04-18 23:07:39 +04:00
|
|
|
{
|
2013-06-14 19:07:55 +04:00
|
|
|
wl_data_source_send_cancelled(source->resource);
|
2013-04-18 23:07:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
create_data_source(struct wl_client *client,
|
|
|
|
struct wl_resource *resource, uint32_t id)
|
|
|
|
{
|
2013-07-26 02:52:14 +04:00
|
|
|
struct weston_data_source *source;
|
2013-04-18 23:07:39 +04:00
|
|
|
|
|
|
|
source = malloc(sizeof *source);
|
|
|
|
if (source == NULL) {
|
|
|
|
wl_resource_post_no_memory(resource);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-01-05 19:18:30 +03:00
|
|
|
source->resource =
|
2016-01-15 23:14:23 +03:00
|
|
|
wl_resource_create(client, &wl_data_source_interface,
|
|
|
|
wl_resource_get_version(resource), id);
|
2016-01-05 19:18:30 +03:00
|
|
|
if (source->resource == NULL) {
|
|
|
|
free(source);
|
|
|
|
wl_resource_post_no_memory(resource);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-06-14 19:07:55 +04:00
|
|
|
wl_signal_init(&source->destroy_signal);
|
2013-04-18 23:07:39 +04:00
|
|
|
source->accept = client_source_accept;
|
|
|
|
source->send = client_source_send;
|
|
|
|
source->cancel = client_source_cancel;
|
2016-01-15 23:14:23 +03:00
|
|
|
source->offer = NULL;
|
|
|
|
source->accepted = false;
|
|
|
|
source->seat = NULL;
|
2016-01-19 01:52:12 +03:00
|
|
|
source->actions_set = false;
|
|
|
|
source->dnd_actions = 0;
|
|
|
|
source->current_dnd_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
|
2016-01-15 23:14:26 +03:00
|
|
|
source->compositor_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
|
2019-04-19 19:36:37 +03:00
|
|
|
source->set_selection = false;
|
2013-04-18 23:07:39 +04:00
|
|
|
|
|
|
|
wl_array_init(&source->mime_types);
|
2013-06-14 19:07:55 +04:00
|
|
|
|
2013-06-28 05:17:02 +04:00
|
|
|
wl_resource_set_implementation(source->resource, &data_source_interface,
|
|
|
|
source, destroy_data_source);
|
2013-04-18 23:07:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void unbind_data_device(struct wl_resource *resource)
|
|
|
|
{
|
2013-06-14 19:07:55 +04:00
|
|
|
wl_list_remove(wl_resource_get_link(resource));
|
2013-04-18 23:07:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
get_data_device(struct wl_client *client,
|
|
|
|
struct wl_resource *manager_resource,
|
|
|
|
uint32_t id, struct wl_resource *seat_resource)
|
|
|
|
{
|
2013-06-14 19:08:01 +04:00
|
|
|
struct weston_seat *seat = wl_resource_get_user_data(seat_resource);
|
2013-04-18 23:07:39 +04:00
|
|
|
struct wl_resource *resource;
|
|
|
|
|
2013-06-28 05:17:02 +04:00
|
|
|
resource = wl_resource_create(client,
|
2014-10-20 10:17:15 +04:00
|
|
|
&wl_data_device_interface,
|
|
|
|
wl_resource_get_version(manager_resource),
|
|
|
|
id);
|
2013-08-07 03:46:25 +04:00
|
|
|
if (resource == NULL) {
|
|
|
|
wl_resource_post_no_memory(manager_resource);
|
|
|
|
return;
|
|
|
|
}
|
2013-04-18 23:07:39 +04:00
|
|
|
|
2018-02-15 14:07:09 +03:00
|
|
|
if (seat) {
|
|
|
|
wl_list_insert(&seat->drag_resource_list,
|
|
|
|
wl_resource_get_link(resource));
|
|
|
|
} else {
|
|
|
|
wl_list_init(wl_resource_get_link(resource));
|
|
|
|
}
|
|
|
|
|
2013-06-28 05:17:02 +04:00
|
|
|
wl_resource_set_implementation(resource, &data_device_interface,
|
|
|
|
seat, unbind_data_device);
|
2013-04-18 23:07:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_data_device_manager_interface manager_interface = {
|
|
|
|
create_data_source,
|
|
|
|
get_data_device
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
bind_manager(struct wl_client *client,
|
|
|
|
void *data, uint32_t version, uint32_t id)
|
|
|
|
{
|
2013-06-28 05:17:02 +04:00
|
|
|
struct wl_resource *resource;
|
|
|
|
|
2014-10-20 10:17:15 +04:00
|
|
|
resource = wl_resource_create(client,
|
|
|
|
&wl_data_device_manager_interface,
|
|
|
|
version, id);
|
2013-08-07 03:46:25 +04:00
|
|
|
if (resource == NULL) {
|
|
|
|
wl_client_post_no_memory(client);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_resource_set_implementation(resource, &manager_interface,
|
|
|
|
NULL, NULL);
|
2013-04-18 23:07:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
WL_EXPORT void
|
2013-05-07 07:19:49 +04:00
|
|
|
wl_data_device_set_keyboard_focus(struct weston_seat *seat)
|
2013-04-18 23:07:39 +04:00
|
|
|
{
|
2013-09-19 20:32:00 +04:00
|
|
|
struct weston_surface *focus;
|
2015-08-01 00:55:32 +03:00
|
|
|
struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
|
2013-04-18 23:07:39 +04:00
|
|
|
|
2015-08-01 00:55:32 +03:00
|
|
|
if (!keyboard)
|
2013-04-18 23:07:39 +04:00
|
|
|
return;
|
|
|
|
|
2015-08-01 00:55:32 +03:00
|
|
|
focus = keyboard->focus;
|
2013-09-19 20:32:00 +04:00
|
|
|
if (!focus || !focus->resource)
|
2013-04-18 23:07:39 +04:00
|
|
|
return;
|
|
|
|
|
2015-05-01 12:59:35 +03:00
|
|
|
weston_seat_send_selection(seat, wl_resource_get_client(focus->resource));
|
2013-04-18 23:07:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
WL_EXPORT int
|
|
|
|
wl_data_device_manager_init(struct wl_display *display)
|
|
|
|
{
|
2013-07-09 03:03:57 +04:00
|
|
|
if (wl_global_create(display,
|
2016-01-15 23:14:23 +03:00
|
|
|
&wl_data_device_manager_interface, 3,
|
2013-07-09 03:03:57 +04:00
|
|
|
NULL, bind_manager) == NULL)
|
2013-04-18 23:07:39 +04:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|