.gitignore | 15 COPYING | 44 Makefile.am | 682 +++++-- README | 149 + clients/calibrator.c | 38 clients/clickdot.c | 34 clients/cliptest.c | 33 clients/desktop-shell.c | 164 - clients/dnd.c | 209 +- clients/editor.c | 326 ++- clients/eventdemo.c | 99 - clients/flower.c | 39 clients/fullscreen.c | 97 - clients/gears.c | 37 clients/glmatrix.c | 1062 ------------ clients/image.c | 39 clients/ivi-shell-user-interface.c | 89 - clients/keyboard.c | 221 +- clients/matrix3.xpm | 692 ------- clients/multi-resource.c | 35 clients/nested-client.c | 46 clients/nested.c | 38 clients/presentation-shm.c | 96 - clients/resizor.c | 33 clients/scaler.c | 33 clients/screenshot.c | 56 clients/simple-damage.c | 178 +- clients/simple-dmabuf-intel.c | 588 ++++++ clients/simple-dmabuf-v4l.c | 944 ++++++++++ clients/simple-egl.c | 50 clients/simple-shm.c | 57 clients/simple-touch.c | 38 clients/smoke.c | 35 clients/stacking.c | 38 clients/subsurfaces.c | 51 clients/terminal.c | 163 + clients/transformed.c | 37 clients/weston-info.c | 74 clients/weston-simple-im.c | 163 - clients/window.c | 556 ++++-- clients/window.h | 89 - clients/wscreensaver-glue.c | 148 - clients/wscreensaver-glue.h | 120 - clients/wscreensaver.c | 348 --- clients/wscreensaver.h | 63 configure.ac | 172 + data/wayland.svg | 36 desktop-shell/exposay.c | 109 - desktop-shell/input-panel.c | 58 desktop-shell/shell.c | 1506 ++++++++--------- desktop-shell/shell.h | 54 doc/doxygen/devtools.dox | 51 doc/doxygen/tooldev.doxygen.in | 12 doc/doxygen/tools.dox | 31 doc/doxygen/tools.doxygen.in | 11 doc/doxygen/tools_arch_new.gv | 85 doc/doxygen/tools_arch_old.gv | 53 fullscreen-shell/fullscreen-shell.c | 141 - ivi-shell/README | 2 ivi-shell/hmi-controller.c | 746 +++++--- ivi-shell/input-panel-ivi.c | 57 ivi-shell/ivi-layout-export.h | 72 ivi-shell/ivi-layout-private.h | 52 ivi-shell/ivi-layout-transition.c | 87 ivi-shell/ivi-layout.c | 1386 +++++++-------- ivi-shell/ivi-shell.c | 234 +- ivi-shell/ivi-shell.h | 37 ivi-shell/weston.ini.in | 43 man/weston.ini.man | 50 man/weston.man | 52 notes.txt | 10 protocol/desktop-shell.xml | 138 - protocol/fullscreen-shell.xml | 206 -- protocol/input-method.xml | 273 --- protocol/ivi-application.xml | 35 protocol/ivi-hmi-controller.xml | 33 protocol/presentation_timing.xml | 38 protocol/scaler.xml | 38 protocol/screenshooter.xml | 12 protocol/text.xml | 346 --- protocol/wayland-test.xml | 62 protocol/weston-desktop-shell.xml | 135 + protocol/weston-screenshooter.xml | 12 protocol/weston-test.xml | 126 + protocol/workspaces.xml | 27 protocol/xdg-shell.xml | 422 ---- releasing.txt | 72 shared/cairo-util.c | 38 shared/cairo-util.h | 39 shared/config-parser.c | 60 shared/config-parser.h | 40 shared/file-util.c | 121 + shared/file-util.h | 43 shared/frame.c | 52 shared/helpers.h | 96 + shared/image-loader.c | 38 shared/image-loader.h | 35 shared/matrix.c | 35 shared/matrix.h | 35 shared/option-parser.c | 35 shared/os-compatibility.c | 57 shared/os-compatibility.h | 38 shared/platform.h | 134 + shared/timespec-util.h | 75 shared/zalloc.h | 35 src/animation.c | 40 src/bindings.c | 264 ++- src/clipboard.c | 40 src/cms-colord.c | 94 - src/cms-helper.c | 35 src/cms-helper.h | 37 src/cms-static.c | 41 src/compositor-drm.c | 1301 +++++++++----- src/compositor-fbdev.c | 394 +--- src/compositor-headless.c | 149 - src/compositor-rdp.c | 419 +++- src/compositor-rpi.c | 210 +- src/compositor-wayland.c | 822 ++++++--- src/compositor-x11.c | 734 ++++---- src/compositor.c | 2111 ++++++++++++------------ src/compositor.h | 396 +++- src/data-device.c | 555 +++++- src/dbus.c | 35 src/dbus.h | 35 src/gl-renderer.c | 1081 +++++++++++- src/gl-renderer.h | 69 src/input.c | 886 +++++++--- src/launcher-direct.c | 315 +++ src/launcher-impl.h | 45 src/launcher-logind.c | 839 +++++++++ src/launcher-util.c | 477 ----- src/launcher-util.h | 38 src/launcher-weston-launch.c | 300 +++ src/libbacklight.c | 2 src/libbacklight.h | 32 src/libinput-device.c | 186 +- src/libinput-device.h | 35 src/libinput-seat.c | 87 src/libinput-seat.h | 35 src/linux-dmabuf.c | 497 +++++ src/linux-dmabuf.h | 88 + src/log.c | 42 src/logind-util.c | 953 ---------- src/logind-util.h | 120 - src/main.c | 892 ++++++++++ src/noop-renderer.c | 35 src/pixman-renderer.c | 592 ++++-- src/pixman-renderer.h | 35 src/rpi-renderer.c | 116 - src/rpi-renderer.h | 35 src/screen-share.c | 122 - src/screenshooter.c | 70 src/spring-tool.c | 35 src/systemd-notify.c | 123 + src/text-backend.c | 479 +++-- src/timeline-object.h | 35 src/timeline.c | 72 src/timeline.h | 35 src/vaapi-recorder.c | 51 src/vaapi-recorder.h | 35 src/version.h.in | 41 src/vertex-clipping.c | 35 src/vertex-clipping.h | 35 src/weston-egl-ext.h | 48 src/weston-launch.c | 53 src/weston-launch.h | 35 src/zoom.c | 182 -- tests/bad-buffer-test.c | 39 tests/buffer-count-test.c | 53 tests/button-test.c | 43 tests/config-parser-test.c | 406 +++- tests/devices-test.c | 312 +++ tests/event-test.c | 59 tests/internal-screenshot-test.c | 128 + tests/internal-screenshot.ini | 3 tests/ivi-shell-app-test.c | 75 tests/ivi-test.h | 41 tests/ivi_layout-internal-test.c | 1208 +++++++++++++ tests/ivi_layout-test-plugin.c | 1073 ++++++++++++ tests/ivi_layout-test.c | 469 +++++ tests/keyboard-test.c | 56 tests/matrix-test.c | 37 tests/presentation-test.c | 38 tests/reference/internal-screenshot-bad-00.png |binary tests/reference/internal-screenshot-good-00.png |binary tests/roles-test.c | 39 tests/setbacklight.c | 35 tests/subsurface-test.c | 65 tests/surface-global-test.c | 37 tests/surface-screenshot.c | 221 ++ tests/surface-test.c | 37 tests/text-test.c | 95 - tests/vertex-clip-test.c | 38 tests/weston-test-client-helper.c | 640 ++++++- tests/weston-test-client-helper.h | 126 + tests/weston-test-runner.c | 35 tests/weston-test-runner.h | 39 tests/weston-test.c | 375 +++- tests/weston-tests-env | 85 tests/xwayland-test.c | 37 tools/zunitc/doc/zunitc.dox | 220 ++ tools/zunitc/inc/zunitc/zunitc.h | 743 ++++++++ tools/zunitc/inc/zunitc/zunitc_impl.h | 105 + tools/zunitc/src/main.c | 58 tools/zunitc/src/zuc_base_logger.c | 404 ++++ tools/zunitc/src/zuc_base_logger.h | 38 tools/zunitc/src/zuc_collector.c | 427 ++++ tools/zunitc/src/zuc_collector.h | 58 tools/zunitc/src/zuc_context.h | 58 tools/zunitc/src/zuc_event.h | 86 tools/zunitc/src/zuc_event_listener.h | 174 + tools/zunitc/src/zuc_junit_reporter.c | 471 +++++ tools/zunitc/src/zuc_junit_reporter.h | 38 tools/zunitc/src/zuc_types.h | 80 tools/zunitc/src/zunitc_impl.c | 1589 ++++++++++++++++++ tools/zunitc/test/fixtures_test.c | 106 + tools/zunitc/test/zunitc_test.c | 464 +++++ wcap/main.c | 39 wcap/wcap-decode.c | 39 wcap/wcap-decode.h | 35 weston.ini.in | 8 xwayland/dnd.c | 40 xwayland/launcher.c | 36 xwayland/selection.c | 58 xwayland/window-manager.c | 399 ++-- xwayland/xwayland.h | 38 226 files changed, 30195 insertions(+), 14864 deletions(-)
New commits: commit 0cc4e986695decb384cbbb8ce0e5cd08d2905249 Author: Bryce Harrington <[email protected]> Date: Tue Feb 2 15:34:56 2016 -0800 configure.ac: bump to version 1.9.92 for the beta release diff --git a/configure.ac b/configure.ac index 107c155..bff6380 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ m4_define([weston_major_version], [1]) m4_define([weston_minor_version], [9]) -m4_define([weston_micro_version], [91]) +m4_define([weston_micro_version], [92]) m4_define([weston_version], [weston_major_version.weston_minor_version.weston_micro_version]) commit 2c40d1d30eabe46706822a8b5c94579aeba58e84 Author: Bryce Harrington <[email protected]> Date: Tue Feb 2 10:18:48 2016 -0800 input: Fix crash when touchscreen generates out of screen coordinate With change 61ed7b6b, global touch coordinates are being passed to the touch grab. However, touch->grab is undefined in certain circumstances such as when the touch screen raises an axis X value larger than the maximum expected. Move the check for this condition earlier, before our first use of the pointer. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=92736 Reviewed-by: Bryce Harrington <[email protected]> Reviewed-by: Derek Foreman <[email protected]> diff --git a/src/input.c b/src/input.c index 2539fa7..8c106dd 100644 --- a/src/input.c +++ b/src/input.c @@ -446,11 +446,14 @@ default_grab_touch_down(struct weston_touch_grab *grab, uint32_t time, struct wl_list *resource_list; wl_fixed_t sx, sy; + if (!touch->focus) + return; + weston_view_from_global_fixed(touch->focus, x, y, &sx, &sy); resource_list = &touch->focus_resource_list; - if (!wl_list_empty(resource_list) && touch->focus) { + if (!wl_list_empty(resource_list)) { serial = wl_display_next_serial(display); wl_resource_for_each(resource, resource_list) wl_touch_send_down(resource, serial, time, commit 4061e2b67e62d5d2a635f0b87098f331082e8145 Author: Carlos Garnacho <[email protected]> Date: Mon Feb 1 20:28:16 2016 +0100 data-device: Check harder for selection/non-wayland sources We're not always dealing with weston_data_sources that have a wl_resource, or data_sources that belong to drag-and-drop. Check harder for these on the drag-and-drop code paths triggered from common code. Signed-off-by: Carlos Garnacho <[email protected]> diff --git a/src/data-device.c b/src/data-device.c index 2cfdcfe..862a4e0 100644 --- a/src/data-device.c +++ b/src/data-device.c @@ -100,6 +100,9 @@ data_offer_destroy(struct wl_client *client, struct wl_resource *resource) static void data_source_notify_finish(struct weston_data_source *source) { + if (!source->actions_set) + return; + if (source->offer->in_ask && wl_resource_get_version(source->resource) >= WL_DATA_SOURCE_ACTION_SINCE_VERSION) { @@ -157,7 +160,7 @@ data_offer_update_action(struct weston_data_offer *offer) { uint32_t action; - if (!offer->source) + if (!offer->source || !offer->source->actions_set) return; action = data_offer_choose_action(offer); @@ -268,7 +271,8 @@ destroy_data_offer(struct wl_resource *resource) if (wl_resource_get_version(offer->resource) < WL_DATA_OFFER_ACTION_SINCE_VERSION) { data_source_notify_finish(offer->source); - } else if (wl_resource_get_version(offer->source->resource) >= + } else if (offer->source->resource && + wl_resource_get_version(offer->source->resource) >= WL_DATA_SOURCE_DND_FINISHED_SINCE_VERSION) { wl_data_source_send_cancelled(offer->source->resource); } commit beb7a9f92d00e83712c762fd8e2abd6f65773858 Author: Carlos Garnacho <[email protected]> Date: Mon Feb 1 20:28:15 2016 +0100 xwayland: zalloc the x11_data_sources The wrapped weston_data_source struct has new fields which were left uninitialized, so its access is unreliable. The data source in xwayland/dnd.c should be eventually setting the drag-and-drop actions, but it is a lot more incomplete than that (read: completely), so falls out of the scope of this patch. Signed-off-by: Carlos Garnacho <[email protected]> diff --git a/xwayland/dnd.c b/xwayland/dnd.c index a036b30..f17e4cd 100644 --- a/xwayland/dnd.c +++ b/xwayland/dnd.c @@ -162,7 +162,7 @@ handle_enter(struct weston_wm *wm, xcb_client_message_event_t *client_message) xcb_get_property_cookie_t cookie; xcb_get_property_reply_t *reply; - source = malloc(sizeof *source); + source = zalloc(sizeof *source); if (source == NULL) return; diff --git a/xwayland/selection.c b/xwayland/selection.c index 25ec848..3fcd578 100644 --- a/xwayland/selection.c +++ b/xwayland/selection.c @@ -197,7 +197,7 @@ weston_wm_get_selection_targets(struct weston_wm *wm) return; } - source = malloc(sizeof *source); + source = zalloc(sizeof *source); if (source == NULL) { free(reply); return; commit 15902bf47a91b42b6f9196861c94ab9cdb6b7cf2 Author: Carlos Garnacho <[email protected]> Date: Mon Feb 1 20:28:14 2016 +0100 clipboard: zalloc the clipboard_source The wrapped weston_data_source struct has new fields which were left uninitialized, so its access is unreliable. Signed-off-by: Carlos Garnacho <[email protected]> Reviewed-by: Derek Foreman <[email protected] Tested-by: Derek Foreman <[email protected]> diff --git a/src/clipboard.c b/src/clipboard.c index da7dbb6..54a578f 100644 --- a/src/clipboard.c +++ b/src/clipboard.c @@ -141,7 +141,7 @@ clipboard_source_create(struct clipboard *clipboard, struct clipboard_source *source; char **s; - source = malloc(sizeof *source); + source = zalloc(sizeof *source); if (source == NULL) return NULL; commit 8efa31b289a1b176db4b07d5c773a1a63934879d Author: Derek Foreman <[email protected]> Date: Fri Jan 29 10:29:46 2016 -0600 input: Don't try to send pointer frames if no focus_client Prevents a segfault when mousing into clients that don't get_pointer like weston-simple-shm and weston-simple-damage. Signed-off-by: Derek Foreman <[email protected]> Reviewed-by: Jonas Ådahl <[email protected]> Reviewed-by: Marek Chalupa <[email protected]> diff --git a/src/input.c b/src/input.c index 91813ec..2539fa7 100644 --- a/src/input.c +++ b/src/input.c @@ -390,6 +390,9 @@ weston_pointer_send_frame(struct weston_pointer *pointer) struct wl_resource *resource; struct wl_list *resource_list; + if (!pointer->focus_client) + return; + resource_list = &pointer->focus_client->pointer_resources; wl_resource_for_each(resource, resource_list) pointer_send_frame(resource); commit 1abf5e43b56fca493888f43e3261126b320e5cbb Author: Bryce Harrington <[email protected]> Date: Wed Jan 20 11:50:12 2016 -0800 releasing: register_release now inserts the email announcement urls diff --git a/releasing.txt b/releasing.txt index fe6aa59..2467e8e 100644 --- a/releasing.txt +++ b/releasing.txt @@ -58,7 +58,7 @@ To make a release of Weston and/or Wayland, follow these steps. 5. Compose the release announcements. The script will generate - *.x.y.0.announce files with a list of changes and tags, one for + *.x.y.z.announce files with a list of changes and tags, one for wayland, one for weston. Prepend these with a human-readable listing of the most notable changes. For x.y.0 releases, indicate the schedule for the x.y+1.0 release. @@ -66,10 +66,7 @@ To make a release of Weston and/or Wayland, follow these steps. 6. pgp sign the the release announcements and send them to [email protected] - 7. Get your freshly posted release email URL from - http://lists.freedesktop.org/archives/wayland-devel/ - - 8. Update releases.html in wayland-web with links to tarballs and + 7. Update releases.html in wayland-web with links to tarballs and the release email URL. The register_release script in wayland-web will generate an HTML @@ -79,11 +76,11 @@ To make a release of Weston and/or Wayland, follow these steps. Once satisfied: - $ git commit ./releases.html -m "Add ${RELEASE_NUMBER} release" + $ git commit ./releases.html -m "releases: Add ${RELEASE_NUMBER} release" $ git push $ ./deploy - 9. Update topic in #wayland to point to the release announcement URL + 8. Update topic in #wayland to point to the release announcement URL For x.y.0 releases, also create the release series x.y branch. The x.y branch is for bug fixes and conservative changes to the x.y.0 release, commit 51e892000ebb2298b9841b657e99def9ad188e37 Author: Bryce Harrington <[email protected]> Date: Tue Jan 19 15:23:41 2016 -0800 configure.ac: bump to version for the release diff --git a/configure.ac b/configure.ac index 97cbfe5..107c155 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ m4_define([weston_major_version], [1]) m4_define([weston_minor_version], [9]) -m4_define([weston_micro_version], [90]) +m4_define([weston_micro_version], [91]) m4_define([weston_version], [weston_major_version.weston_minor_version.weston_micro_version]) @@ -59,7 +59,7 @@ AC_CHECK_HEADERS([execinfo.h]) AC_CHECK_FUNCS([mkostemp strchrnul initgroups posix_fallocate]) -COMPOSITOR_MODULES="wayland-server >= 1.9.90 pixman-1 >= 0.25.2" +COMPOSITOR_MODULES="wayland-server >= 1.9.91 pixman-1 >= 0.25.2" AC_CONFIG_FILES([doc/doxygen/tools.doxygen doc/doxygen/tooldev.doxygen]) @@ -321,7 +321,7 @@ AC_SUBST(JPEG_LIBS) PKG_CHECK_MODULES(CAIRO, [cairo]) -PKG_CHECK_MODULES(TEST_CLIENT, [wayland-client >= 1.9.90]) +PKG_CHECK_MODULES(TEST_CLIENT, [wayland-client >= 1.9.91]) AC_ARG_ENABLE(simple-clients, AS_HELP_STRING([--disable-simple-clients], commit f377535aff4f2cac0c529c338c0eafd4d045ff4e Author: Carlos Garnacho <[email protected]> Date: Fri Jan 15 21:14:27 2016 +0100 dnd: Turn into a full blown example In order to keep things simple, weston-dnd made a few choices that turn out to be unrealistic, a few tweaks have been done to make it less of a playground demo: - It now caters for copy/move operations, instead of just move, which still remains the default nonetheless. - As "move" operations are no longer assumed, the item isn't removed on start_drag, instead it is made translucent until the drag operation finishes (and we know whether the item is to be removed after transfer or left as is) - For the same reasons, "Drop nowhere to delete item" no longer happens. Drag-and-drop is a failable operation and must not result in data loss. - As multiple actions are now allowed, we set the pointer icon surface accordingly to the current operation. This makes weston-dnd a better example of what applications usually want to do here. Changes since v2: - Updated to behave alright-ish with version < 3. Changes since v1: - Remove unneeded include. Remove extra newlines. Other minor code fixes. Signed-off-by: Carlos Garnacho <[email protected]> Reviewed-by: Jonas Ådahl <[email protected]> diff --git a/clients/dnd.c b/clients/dnd.c index d32655d..e6c3147 100644 --- a/clients/dnd.c +++ b/clients/dnd.c @@ -190,7 +190,7 @@ dnd_redraw_handler(struct widget *widget, void *data) struct dnd *dnd = data; struct rectangle allocation; cairo_t *cr; - cairo_surface_t *surface; + cairo_surface_t *surface, *item_surface; unsigned int i; surface = window_get_surface(dnd->window); @@ -210,7 +210,13 @@ dnd_redraw_handler(struct widget *widget, void *data) for (i = 0; i < ARRAY_LENGTH(dnd->items); i++) { if (!dnd->items[i]) continue; - cairo_set_source_surface(cr, dnd->items[i]->surface, + + if (dnd->current_drag && dnd->items[i] == dnd->current_drag->item) + item_surface = dnd->current_drag->translucent; + else + item_surface = dnd->items[i]->surface; + + cairo_set_source_surface(cr, item_surface, dnd->items[i]->x + allocation.x, dnd->items[i]->y + allocation.y); cairo_paint(cr); @@ -266,6 +272,30 @@ dnd_get_item(struct dnd *dnd, int32_t x, int32_t y) return NULL; } +static int +lookup_dnd_cursor(uint32_t dnd_action) +{ + if (dnd_action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE) + return CURSOR_DND_MOVE; + else if (dnd_action == WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY) + return CURSOR_DND_COPY; + + return CURSOR_DND_FORBIDDEN; +} + +static void +dnd_drag_update_cursor(struct dnd_drag *dnd_drag) +{ + int cursor; + + if (dnd_drag->mime_type == NULL) + cursor = CURSOR_DND_FORBIDDEN; + else + cursor = lookup_dnd_cursor(dnd_drag->dnd_action); + + input_set_pointer_image(dnd_drag->input, cursor); +} + static void dnd_drag_update_surface(struct dnd_drag *dnd_drag) { @@ -293,6 +323,7 @@ data_source_target(void *data, dnd_drag->mime_type = mime_type; dnd_drag_update_surface(dnd_drag); + dnd_drag_update_cursor(dnd_drag); } static void @@ -326,13 +357,27 @@ data_source_send(void *data, struct wl_data_source *source, } static void -dnd_drag_destroy(struct dnd_drag *dnd_drag) +dnd_drag_destroy(struct dnd_drag *dnd_drag, bool delete_item) { + struct dnd *dnd = dnd_drag->dnd; + unsigned int i; + wl_data_source_destroy(dnd_drag->data_source); - /* Destroy the item that has been dragged out */ - cairo_surface_destroy(dnd_drag->item->surface); - free(dnd_drag->item); + if (delete_item) { + for (i = 0; i < ARRAY_LENGTH(dnd->items); i++) { + if (dnd_drag->item == dnd->items[i]) { + dnd->items[i] = NULL; + break; + } + } + + /* Destroy the item that has been dragged out */ + cairo_surface_destroy(dnd_drag->item->surface); + free(dnd_drag->item); + } + + dnd->current_drag = NULL; wl_surface_destroy(dnd_drag->drag_surface); @@ -345,11 +390,13 @@ static void data_source_cancelled(void *data, struct wl_data_source *source) { struct dnd_drag *dnd_drag = data; + struct dnd *dnd = dnd_drag->dnd; /* The 'cancelled' event means that the source is no longer in * use by the drag (or current selection). We need to clean * up the drag object created and the local state. */ - dnd_drag_destroy(dnd_drag); + dnd_drag_destroy(dnd_drag, false); + window_schedule_redraw(dnd->window); } static void @@ -361,11 +408,17 @@ static void data_source_dnd_finished(void *data, struct wl_data_source *source) { struct dnd_drag *dnd_drag = data; + struct dnd *dnd = dnd_drag->dnd; + bool delete_item; - /* The operation is already finished, we can destroy all - * related data. - */ - dnd_drag_destroy(dnd_drag); + delete_item = + dnd_drag->dnd_action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE; + + /* The operation is already finished, we can destroy all + * related data. + */ + dnd_drag_destroy(dnd_drag, delete_item); + window_schedule_redraw(dnd->window); } static void @@ -375,6 +428,7 @@ data_source_action(void *data, struct wl_data_source *source, uint32_t dnd_actio dnd_drag->dnd_action = dnd_action; dnd_drag_update_surface(dnd_drag); + dnd_drag_update_cursor(dnd_drag); } static const struct wl_data_source_listener data_source_listener = { @@ -432,6 +486,7 @@ create_drag_source(struct dnd *dnd, unsigned int i; uint32_t serial; cairo_surface_t *icon; + uint32_t actions; widget_get_allocation(dnd->widget, &allocation); item = dnd_get_item(dnd, x, y); @@ -449,12 +504,8 @@ create_drag_source(struct dnd *dnd, dnd_drag->dnd_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE; dnd_drag->mime_type = NULL; - for (i = 0; i < ARRAY_LENGTH(dnd->items); i++) { - if (item == dnd->items[i]){ - dnd->items[i] = 0; - break; - } - } + actions = WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE | + WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY; display = window_get_display(dnd->window); compositor = display_get_compositor(display); @@ -462,6 +513,21 @@ create_drag_source(struct dnd *dnd, dnd_drag->drag_surface = wl_compositor_create_surface(compositor); + if (display_get_data_device_manager_version(display) < + WL_DATA_SOURCE_SET_ACTIONS_SINCE_VERSION) { + /* Data sources version < 3 will not get action + * nor dnd_finished events, as we can't honor + * the "move" action at the time of finishing + * drag-and-drop, do it preemptively here. + */ + for (i = 0; i < ARRAY_LENGTH(dnd->items); i++) { + if (item == dnd->items[i]){ + dnd->items[i] = NULL; + break; + } + } + } + if (dnd->self_only) { dnd_drag->data_source = NULL; } else { @@ -478,8 +544,7 @@ create_drag_source(struct dnd *dnd, if (display_get_data_device_manager_version(display) >= WL_DATA_SOURCE_SET_ACTIONS_SINCE_VERSION) { - wl_data_source_set_actions(dnd_drag->data_source, - WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE); + wl_data_source_set_actions(dnd_drag->data_source, actions); } wl_data_device_start_drag(input_get_data_device(input), @@ -591,8 +656,6 @@ dnd_enter_handler(struct widget *widget, struct dnd *dnd = data; struct pointer *new_pointer = malloc(sizeof *new_pointer); - dnd->current_drag = NULL; - if (new_pointer) { new_pointer->input = input; new_pointer->dragging = false; @@ -703,7 +766,6 @@ dnd_drop_handler(struct window *window, struct input *input, message.x_offset = dnd->current_drag->x_offset; message.y_offset = dnd->current_drag->y_offset; dnd_receive_func(&message, sizeof message, x, y, dnd); - dnd->current_drag = NULL; } else { fprintf(stderr, "ignoring drop from another client\n"); } commit b288988e831cee3deb7f8bb1a3f440c86230dd9f Author: Carlos Garnacho <[email protected]> Date: Fri Jan 15 21:14:26 2016 +0100 data-device: Implement compositor-chosen actions Set up a keyboard grab during drag-and-drop, so we can translate modifiers into preferred actions. The compositor chosen action is stored in the current weston_data_source in order to make it accessible to the source/offer at the time of calculating the new action, but would conceptually be part of weston_drag. The mapping has been made similar to what GTK+/QT usually do, the shift key defaults to "move" and ctrl defaults to "copy". Changes since v2: - Use enum types and values for the compositor action. Fix code formatting issues. Changes since v1: - Handle the keyboard grab being cancelled. Initialize new wl_data_source fields. Signed-off-by: Carlos Garnacho <[email protected]> Reviewed-by: Jonas Ådahl <[email protected]> Reviewed-by: Bryce Harrington <[email protected]> diff --git a/src/compositor.h b/src/compositor.h index 8303a5f..58ae94b 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -336,6 +336,7 @@ struct weston_data_source { bool actions_set; uint32_t dnd_actions; enum wl_data_device_manager_dnd_action current_dnd_action; + enum wl_data_device_manager_dnd_action compositor_action; void (*accept)(struct weston_data_source *source, uint32_t serial, const char *mime_type); diff --git a/src/data-device.c b/src/data-device.c index 75a4424..2cfdcfe 100644 --- a/src/data-device.c +++ b/src/data-device.c @@ -44,6 +44,7 @@ struct weston_drag { struct weston_view *icon; struct wl_listener icon_destroy_listener; int32_t dx, dy; + struct weston_keyboard_grab keyboard_grab; }; struct weston_pointer_drag { @@ -139,6 +140,10 @@ data_offer_choose_action(struct weston_data_offer *offer) if (!available_actions) return WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE; + if (offer->source->seat && + offer->source->compositor_action & available_actions) + return offer->source->compositor_action; + /* If the dest side has a preferred DnD action, use it */ if ((preferred_action & available_actions) != 0) return preferred_action; @@ -611,9 +616,11 @@ static void data_device_end_pointer_drag_grab(struct weston_pointer_drag *drag) { struct weston_pointer *pointer = drag->grab.pointer; + struct weston_keyboard *keyboard = drag->base.keyboard_grab.keyboard; data_device_end_drag_grab(&drag->base, pointer->seat); weston_pointer_end_grab(pointer); + weston_keyboard_end_grab(keyboard); free(drag); } @@ -706,9 +713,11 @@ static void data_device_end_touch_drag_grab(struct weston_touch_drag *drag) { struct weston_touch *touch = drag->grab.touch; + struct weston_keyboard *keyboard = drag->base.keyboard_grab.keyboard; data_device_end_drag_grab(&drag->base, touch->seat); weston_touch_end_grab(touch); + weston_keyboard_end_grab(keyboard); free(drag); } @@ -800,6 +809,61 @@ static const struct weston_touch_grab_interface touch_drag_grab_interface = { }; static void +drag_grab_keyboard_key(struct weston_keyboard_grab *grab, + uint32_t time, uint32_t key, uint32_t state) +{ +} + +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 +}; + +static void destroy_pointer_data_device_source(struct wl_listener *listener, void *data) { struct weston_pointer_drag *drag = container_of(listener, @@ -824,12 +888,15 @@ weston_pointer_start_drag(struct weston_pointer *pointer, struct wl_client *client) { struct weston_pointer_drag *drag; + struct weston_keyboard *keyboard = + weston_seat_get_keyboard(pointer->seat); drag = zalloc(sizeof *drag); if (drag == NULL) return -1; drag->grab.interface = &pointer_drag_grab_interface; + drag->base.keyboard_grab.interface = &keyboard_drag_grab_interface; drag->base.client = client; drag->base.data_source = source; @@ -859,7 +926,10 @@ weston_pointer_start_drag(struct weston_pointer *pointer, } weston_pointer_clear_focus(pointer); + weston_keyboard_set_focus(keyboard, NULL); + weston_pointer_start_grab(pointer, &drag->grab); + weston_keyboard_start_grab(keyboard, &drag->base.keyboard_grab); return 0; } @@ -880,6 +950,8 @@ weston_touch_start_drag(struct weston_touch *touch, struct wl_client *client) { struct weston_touch_drag *drag; + struct weston_keyboard *keyboard = + weston_seat_get_keyboard(touch->seat); drag = zalloc(sizeof *drag); if (drag == NULL) @@ -914,7 +986,10 @@ weston_touch_start_drag(struct weston_touch *touch, &drag->base.data_source_listener); } + weston_keyboard_set_focus(keyboard, NULL); + weston_touch_start_grab(touch, &drag->grab); + weston_keyboard_start_grab(keyboard, &drag->base.keyboard_grab); drag_grab_touch_focus(drag); @@ -1172,6 +1247,7 @@ create_data_source(struct wl_client *client, source->actions_set = false; source->dnd_actions = 0; source->current_dnd_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE; + source->compositor_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE; wl_array_init(&source->mime_types); commit 5ccf0476c3319f468f303d47c5d9bf25e314558c Author: Carlos Garnacho <[email protected]> Date: Fri Jan 15 21:14:25 2016 +0100 client: Add DnD cursors to the managed cursors list That way we'll be able to set the corresponding pointer surface to a current DnD operation. Signed-off-by: Carlos Garnacho <[email protected]> Reviewed-by: Jonas Ådahl <[email protected]> diff --git a/clients/window.c b/clients/window.c index 5cd33dd..35261b6 100644 --- a/clients/window.c +++ b/clients/window.c @@ -1265,6 +1265,19 @@ static const char *watches[] = { "0426c94ea35c87780ff01dc239897213" }; +static const char *move_draggings[] = { + "dnd-move" +}; + +static const char *copy_draggings[] = { + "dnd-copy" +}; + +static const char *forbidden_draggings[] = { + "dnd-none", + "dnd-no-drop"

