Commit Graph

1446 Commits

Author SHA1 Message Date
Sebastian Krzyszkowiak 40d17c1305 wlr_seat_touch: add a way for a grab to ignore a touch point 2019-08-12 09:31:49 +09:00
Drew DeVault 94f65e354d Add libinput-1.14 support
This libinput version adds a new tablet tool type.
2019-08-11 19:39:47 +09:00
Sebastian Krzyszkowiak 913cac1835 wlr_input_method_v2: Remove input method's resource from the list on destroy
It's added to manager->input_methods list in manager_get_input_method, but
wasn't removed anywhere, leading to possible use-after-free in
wlr_input_method_manager_v2_destroy.
2019-08-09 08:05:55 +09:00
Rouven Czerwinski 01f903874b Revert "output: atomic mode"
This reverts commit ee5f98ad49.

This intoduced problems where outputs could not be turned off because
they had flips pending.
2019-08-07 16:22:11 +09:00
Simon Ser 6396710976 xdg-output: add support for xdg-output-unstable-v1 version 3
This adds support for xdg-output-unstable-v1 version 3, added in [1].

The xdg_output.done event is now deprecated and is replaced with
wl_output.done.

[1]: 962dd53537
2019-08-02 10:02:33 -04:00
Simon Ser ee5f98ad49 output: atomic mode, enabled, scale and transform
This commit makes more output properties (mode, enabled, scale and transform)
atomic. This means that they are double-buffered and only applied on commit.

Compositors now need to call wlr_output_commit after setting any of those
properties.

Internally, backends still apply properties sequentially. The behaviour should
be exactly the same as before. Future commits will update some backends to take
advantage of the atomic interface. Some backends are non-atomic by design, e.g.
the X11 backend or the legacy DRM backend.

Updates: https://github.com/swaywm/wlroots/issues/1640
2019-08-02 10:01:29 -04:00
Jason Francis d20aee6c9d export-dmabuf-v1: fix segfault on output disable 2019-08-01 19:00:48 +03:00
Jason Francis 724b5e1b8d screencopy: send failed after output disconnect
This prevents screencopy applications from hanging because a failed
event never got sent when the output was disconnected or disabled after
the call to buffer().
2019-08-01 19:00:48 +03:00
Jason Francis ce3e413e83 screencopy: fix segfault on disabled output
Disconnecting or disabling an output between capture_output() and
ready() could cause either a NULL dereference or an incorrect
attach_render_locks count.
2019-08-01 19:00:48 +03:00
Simon Ser ca45f4490c Remove all wayland-server.h includes
The documentation for wayland-server.h says:

> Use of this header file is discouraged. Prefer including
> wayland-server-core.h instead, which does not include the server protocol
> header and as such only defines the library PI, excluding the deprecated API
> below.

Replacing wayland-server.h with wayland-server-core.h allows us to drop the
WL_HIDE_DEPRECATED declaration.
2019-07-27 15:49:32 -04:00
Simon Ser 76ef089f52 output: drop wlr_output_mode.flags
AFAIK this was always set to zero. Instead, compute wl_output mode flags on the
fly.

Technically this is a breaking change, but I don't think anybody uses this
field.
2019-07-21 12:33:32 -04:00
Sebastian Krzyszkowiak 2d4bc66f11 wlr_touch: Declare wlr_touch_impl usage as const
This brings it in line with wlr_keyboard and wlr_pointer
2019-07-17 09:23:10 -04:00
Guido Günther 692a16cef7 layer-shell: Reject requests on gone surfaces
When the surface was destroyed but the resource is still around
we might dereference a null pointer otherwise.
2019-07-16 17:38:11 +03:00
Guido Günther 91752e8285 layer-shell: Remove unused event source 2019-07-16 17:38:11 +03:00
Guido Günther df3f0ffbb0 wlr_seat_touch: Don't destroy touch point with surface
When the surface is destroyed clear it's reference but wait for the up
event to destroy the touch point via wlr_seat_touch_notify_up().

If the surface is destroyed before the up event we end up with
incomplete sequences sent to the client like

[915821.276] wl_touch@3.down(146, 2475027, wl_surface@38, 0, 236.000000, 515.000000)
[915821.608] wl_touch@3.frame()
[915821.637] wl_touch@3.motion(2475027, 0, 236.000000, 515.000000)
[915821.779] wl_touch@3.frame()

so there's never an up event. While it should be something like

[2461229.051] wl_touch@3.down(81, 3236959, wl_surface@34, 0, 218.000000, 478.000000)
[2461229.435] wl_touch@3.frame()
[2461229.484] wl_touch@3.motion(3236959, 0, 218.000000, 478.000000)
[2461229.636] wl_touch@3.frame()
[2461277.520] wl_touch@3.up(82, 3237007, 0)
[2461277.681] wl_touch@3.frame()

this confuses toolkits intepreting the next down event incorrectly. So
don't destroy the touch point too early.
2019-07-04 14:45:58 +03:00
Manuel Stoeckl c2fb8a84a2 wlr_seat: special-case first serial set use 2019-06-30 15:01:05 -04:00
Manuel Stoeckl 1ef0c03a46 wlr_tablet_v2: Register event serials 2019-06-30 15:01:05 -04:00
Manuel Stoeckl 1d78bae19d wlr_pointer_gestures: Register event serials 2019-06-30 15:01:05 -04:00
Manuel Stoeckl ded441ffd5 wlr_seat: Fix edge cases with serial validation 2019-06-30 15:01:05 -04:00
Manuel Stoeckl edb30a6828 Implement serial validation for selection requests
This change tracks, for each wlr_seat_client, the most recent serial
numbers which were sent to the client. When the client makes a
selection request, wlroots now verifies that the serial number
associated with the selection request was actually provided to that
specific client. This ensures that the client that was most
recently interacted with always has priority for its copy selection
requests, and that no other clients can incorrectly use a larger serial
value and "steal" the role of having the copy selection.

Also, the code used to determine when a given selection is superseded
by a newer request uses < instead of <= to allow clients to make
multiple selection requests with the same serial number and have the
last one hold.

To limit memory use, a ring buffer is used to store runs of sequential
serial numbers, and all serial numbers earlier than the start of the
ring buffer are assumed to be valid. Faking very old serials is
unlikely to be disruptive.

Assuming all clients are correctly written, the only additional
constraint which this patch should impose is that serial numbers
are now bound to seats: clients may not receive a serial number
from an input event on one seat and then use that to request
copy-selection on another seat.
2019-06-30 15:01:05 -04:00
Ilia Bozhinov fb739b8293 output-damage: set needs swap only when we have new damage
An output needs swap when there is new damage. If the damage is only
accumulated from the last frame, we could simply skip drawing.
2019-06-27 21:49:19 +03:00
Dorota Czaplejewicz 0b1f9439ba virtual_keyboard: Require keymap before accepting keycodes 2019-06-24 17:16:37 +03:00
Simon Ser ce3f4c3fe1 output: remove wlr_output_impl.transform
The backend doesn't need to handle transform changes, since everything is done
in software. In fact, all of the implementations were all identical and just
set the transform.

We could add support for hardware transforms, but:

- This would require a different field (something like hardware_transform)
- Not all combinations are possible because there often are hardware
  limitations
- The Wayland protocol isn't ready for this (in particular xdg-output, see [1])

This belongs to a different patch series anyway.

[1]: https://patchwork.freedesktop.org/series/52324/
2019-06-16 10:51:49 -04:00
Simon Ser 33127c545b output: reset the pending state on failed commit
It can be surprising for callers to stash pending changes, commit, get a
failure, then set some other pending changes, commit again, and get another
failure because of the previously-pending changes.

Instead, make commit reset the pending state on failure.
2019-06-16 10:51:49 -04:00
Ashkan Kiani 06a13203dd Use a set to track pointer button state.
In addition to `button_count`, we keep track of the current buttons
pressed just as in `wlr_keyboard`.

Add `set_add` and `set_remove` to assist with this. These functions can
only be used with values greater than 0 (such as the button/key masks
for keyboards and pointers).

Partially addresses:
- https://github.com/swaywm/wlroots/issues/1716
- https://github.com/swaywm/wlroots/issues/1593
2019-06-16 00:59:53 +03:00
Simon Ser e07ffaa249 output-damage: support direct scan-out
In case direct scan-out is used, we still need to accumulate damage for the
render-buffers.
2019-06-07 09:06:11 -04:00
Simon Ser 6c659da98b output: introduce wlr_output_lock_attach_render
This allows screen shooters and screen grabbers to ensure rendering will be
used instead of direct scan-out.
2019-06-07 09:06:11 -04:00
Simon Ser e554c593f9 output: refuse to scan-out if software cursors are used 2019-06-07 09:06:11 -04:00
Simon Ser ff6b352d75 output: save buffer in pending state 2019-06-07 09:06:11 -04:00
Simon Ser afe7b207d5 output: fix attach_buffer semantics 2019-06-07 09:06:11 -04:00
Simon Ser 1d222309b8 output: change set_dmabuf to attach_buffer 2019-06-07 09:06:11 -04:00
Simon Ser 493804e421 buffer: add wlr_buffer_get_dmabuf 2019-06-07 09:06:11 -04:00
emersion 96d6fde5dc backend/drm: add basic support for direct scan-out 2019-06-07 09:06:11 -04:00
Simon Ser 3dec88e455 Remove orbital screenshooter and gamma-control
These are undocumented, outdated protocols that have a better wlr-protocols
equivalent.
2019-06-02 09:30:47 -04:00
Brian Ashworth 6dfe238ff1 zwp_virtual-keyboard: fix mmap error handling
If mmap fails, it will return MAP_FAILED not NULL. Since the error
handling was incorrectly checking for NULL, MAP_FAILED was being passed
to xkb_keymap_new_from_string, on mmap failure, causing a segfault.
This just fixes the error checking.
2019-05-31 07:58:31 +03:00
Rouven Czerwinski a5e32f652b wlr_output: remove idle_done on output destroy
If an output is destroyed while an idle_done event is scheduled, it
results in the following Address Sanitizer Output:

==1469==ERROR: AddressSanitizer: heap-use-after-free on address 0x6170000bb668 at pc 0x7f49aaa0c348 bp 0x7ffed5da35b0 sp 0x7ffed5da35a0
WRITE of size 8 at 0x6170000bb668 thread T0
    #0 0x7f49aaa0c347 in schedule_done_handle_idle_timer ../subprojects/wlroots/types/wlr_output.c:265
    #1 0x7f49aa2f875b in wl_event_loop_dispatch_idle (/usr/lib/libwayland-server.so.0+0xa75b)
    #2 0x7f49aa2f8815 in wl_event_loop_dispatch (/usr/lib/libwayland-server.so.0+0xa815)
    #3 0x7f49aa2f739b in wl_display_run (/usr/lib/libwayland-server.so.0+0x939b)
    #4 0x556622dadd51 in server_run ../sway/server.c:216
    #5 0x556622dac25d in main ../sway/main.c:397
    #6 0x7f49aa0d0ce2 in __libc_start_main (/usr/lib/libc.so.6+0x23ce2)
    #7 0x556622d8d09d in _start (/usr/local/bin/sway+0x3909d)

0x6170000bb668 is located 488 bytes inside of 672-byte region [0x6170000bb480,0x6170000bb720)
freed by thread T0 here:
    #0 0x7f49aabc8f89 in __interceptor_free /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:66
    #1 0x7f49aa968fc2 in drm_connector_destroy ../subprojects/wlroots/backend/drm/drm.c:829
    #2 0x7f49aaa0cc52 in wlr_output_destroy ../subprojects/wlroots/types/wlr_output.c:357
    #3 0x7f49aa96d2e9 in scan_drm_connectors ../subprojects/wlroots/backend/drm/drm.c:1265
    #4 0x7f49aa961a59 in drm_invalidated ../subprojects/wlroots/backend/drm/backend.c:135
    #5 0x7f49aaa2e1e9 in wlr_signal_emit_safe ../subprojects/wlroots/util/signal.c:29
    #6 0x7f49aa98319f in udev_event ../subprojects/wlroots/backend/session/session.c:52
    #7 0x7f49aa2f87f1 in wl_event_loop_dispatch (/usr/lib/libwayland-server.so.0+0xa7f1)

previously allocated by thread T0 here:
    #0 0x7f49aabc95a1 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:95
    #1 0x7f49aa96b7a2 in scan_drm_connectors ../subprojects/wlroots/backend/drm/drm.c:1114
    #2 0x7f49aa961a59 in drm_invalidated ../subprojects/wlroots/backend/drm/backend.c:135
    #3 0x7f49aaa2e1e9 in wlr_signal_emit_safe ../subprojects/wlroots/util/signal.c:29
    #4 0x7f49aa98319f in udev_event ../subprojects/wlroots/backend/session/session.c:52
    #5 0x7f49aa2f87f1 in wl_event_loop_dispatch (/usr/lib/libwayland-server.so.0+0xa7f1)

SUMMARY: AddressSanitizer: heap-use-after-free ../subprojects/wlroots/types/wlr_output.c:265 in schedule_done_handle_idle_timer
Shadow bytes around the buggy address:
  0x0c2e8000f670: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2e8000f680: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2e8000f690: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c2e8000f6a0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c2e8000f6b0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
=>0x0c2e8000f6c0: fd fd fd fd fd fd fd fd fd fd fd fd fd[fd]fd fd
  0x0c2e8000f6d0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c2e8000f6e0: fd fd fd fd fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2e8000f6f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2e8000f700: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2e8000f710: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb

Remove the idle_done idle timer when the output is destroyed
2019-05-30 09:14:46 +03:00
Ilia Bozhinov 03346cb28f output: clear output->damage on successful commit 2019-05-13 18:45:22 +03:00
Ilia Bozhinov 4e6c17a7c9 foreign-toplevel: support fullscreen state and request 2019-04-29 00:00:53 +03:00
Simon Ser a656e486f4 seat: fallback to v6 if libwayland 1.17 isn't available
See https://github.com/swaywm/wlroots/pull/1675#issuecomment-487300445
2019-04-27 11:26:34 -06:00
Simon Ser d7ef3a1f38 xdg-output: schedule a wl_output.done event on update
Xwayland expects an xdg_output.done event to always be sent with a
wl_output.done event.
2019-04-27 10:02:21 -06:00
Simon Ser bde5a1f4ea output: introduce wlr_output_schedule_done
This commit introduces wlr_output_schedule_done and refactors the mechanism
used to send wl_output events to clients.

wlr_output_schedule_done schedules a wl_output.done event. This allows clients
to see wlr_output property changes as atomic.

This function is also useful for add-on interfaces like xdg_output which need
to trigger a wl_output.done event to apply their new state.
2019-04-27 10:02:21 -06:00
Drew DeVault 736632ad4e Remove wlr_wl_shell 2019-04-26 18:23:25 +03:00
Scott Anderson a671fc51d2 Advertise wl_seat version 7
This does not require any code changes, as we already copy the keymap
data separately for each client.

For details, see 905c0a341d
2019-04-26 07:57:37 -06:00
Simon Ser 8d3369d70f output-damage: fix segfault after destroy
Fixes: 5e6766a165
2019-04-25 11:39:51 +03:00
Simon Ser 20690346c7 output: rename needs_commit to needs_frame
This new name makes more sense, since it is a request from the backend to get
a new frame. In the future a commit may not convey a new frame.
2019-04-23 14:34:30 -06:00
Simon Ser 5e6766a165 output-damage: refactor API
wlr_output_damage_make_current has been renamed to
wlr_output_damage_attach_render, since it's just a wrapper for
wlr_output_attach_render.

wlr_output_damage_swap_buffers has been removed completely. Instead,
wlr_output_damage now listens to successful wlr_output commits and updates its
internal state accordingly.
2019-04-23 14:34:30 -06:00
Simon Ser 31dcecbfa9 output: rename swap_buffers event to precommit
Also remove damage from the event data since it's no longer tied to commits.
2019-04-23 14:34:30 -06:00
Simon Ser 9a0f8a194c output: refactor backend API
This updates the backend part of the output API. This is mostly renaming:
make_current becomes attach_render and swap_buffers becomes commit.

This also fixes the RDP backend to support NULL damage.
2019-04-23 14:34:30 -06:00
Simon Ser 23e37e7b1d output: refactor frame submission API
This is necessary for direct scan-out and other upcoming features. This patch
changes the output API to look like the wl_surface API.

Outputs now have some double-buffered state: the frame to be submitted
(currently only wlr_renderer frames are supported) and the damaged region.
To attach a pending frame, use wlr_output_attach_render. To set the pending
damaged region, use wlr_output_set_damage.

To submit the pending state, call wlr_output_commit. This will submit the
pending frame to the backend.

To migrate from the old API to the new one:

- Replace wlr_output_make_current calls by wlr_output_attach_render
- Replace wlr_output_swap_buffers calls by wlr_output_set_damage and
  wlr_output_commit
2019-04-23 14:34:30 -06:00
Simon Ser 8acbf449cc output: introduce wlr_output_preferred_mode 2019-04-22 11:15:38 -06:00
Simon Ser 4207f05030 data-device: ignore accept for selection offers
It doesn't make sense for clients to send "accept" requests to offers that
aren't drag-and-drop. I discussed with Daniel Stone to make it a protocol
error [1] but too many clients send it (e.g. GTK+). Let's just log it for now.

[1]: https://gitlab.freedesktop.org/wayland/wayland/merge_requests/11#note_149710
2019-04-19 13:24:41 -06:00
Ilia Bozhinov d6615e0e84 idle: enable the compositors to add custom idle timeouts (#1655)
* idle: enable the compositors to add custom idle timeouts

* idle: add a private constructor which also creates the resource

* idle: move resource creation to the idle implementation callback
2019-04-17 08:48:43 +03:00
Ilia Bozhinov dc5d1d08ef output: do nothing in output_set_image if backend has no renderer
This is useful when using the noop backend for example.
2019-04-14 19:35:23 +03:00
emersion 1515c56cae output: remove lx, ly
Fixes https://github.com/swaywm/wlroots/issues/1610
2019-04-13 08:31:30 -06:00
emersion 930e37eae9 output-management-v1: add more docs 2019-04-11 09:19:57 -06:00
Guido Günther 524f5c8425 Emit preferred mode 2019-04-11 09:19:57 -06:00
emersion ab3446091b output-management-v1: update protocol, add set_custom_mode 2019-04-11 09:19:57 -06:00
emersion fc0ba3ea22 output-management-v1: support outputs without modes 2019-04-11 09:19:57 -06:00
emersion 81e1489e79 output-management-v1: fix wl_fixed_t conversion 2019-04-11 09:19:57 -06:00
emersion 8136605cfb output-management-v1: support applying configuration 2019-04-11 09:19:57 -06:00
emersion d71ebde545 output-management-v1: add support for position, transform and scale 2019-04-11 09:19:57 -06:00
emersion ef68d7d4d1 output-management-v1: add support for modes 2019-04-11 09:19:57 -06:00
emersion e873c652bf output-management-v1: various fixes 2019-04-11 09:19:57 -06:00
emersion d695003498 Add apply and test events to manager 2019-04-11 09:19:57 -06:00
emersion 0b64ecc162 Split wlr_output_configuration_head_v1 2019-04-11 09:19:57 -06:00
emersion 3a233b3fcc Add support for wlr-output-management-unstable-v1 2019-04-11 09:19:57 -06:00
Guido Günther 9faea17c73
Merge pull request #1642 from emersion/format-set
Introduce wlr_format_set
2019-04-08 10:58:18 +02:00
emersion e42178d03f
render: switch wlr_renderer to wlr_drm_format_set 2019-04-01 19:18:04 +03:00
Markus Ongyerth 09b2833dcd send proximity_out in proximity in for tablet_v2
When the proximity_in event is sent for tablet_v2 and there's already a
surface that currently has tablet (tool) focus, it should be told that
this is no longer the case, so we need to send the proximity_out event.
2019-03-31 20:16:03 +03:00
Stuart Dilts 08454adada types/meson.build: Add compile args for libinput to lib_wlr_types (#1636)
* Add compile args for libinput to lib_wlr_types

Fixes the build on openSUSE Tumbleweed

* Remove libinput include from wlr_tablet_v2.c

+ libinput isn't used in the file
+ Also remove libinput dependency from types/meson.build
2019-03-27 19:31:20 +02:00
Brian Ashworth 17f688735f wlr_xdg_toplevel_v6: store pending fullscreen output
Since the fullscreen request may be made before the toplevel's surface
is mapped, the requested fullscreen output needs to be stored so it
can be retrieved on map (along with the existing fullscreen property).

This commit makes the required changes for wlr_xdg_toplevel_v6.
2019-03-27 10:04:10 +02:00
Brian Ashworth 4e614683b7 wlr_xdg_toplevel: store pending fullscreen output
Since the fullscreen request may be made before the toplevel's surface
is mapped, the requested fullscreen output needs to be stored so it
can be retrieved on map (along with the existing fullscreen property).

This commit makes the required changes for wlr_xdg_toplevel.
2019-03-27 10:04:10 +02:00
Ryan Walklin 4453757fc9 s/lid_switch/switch_device
Rename lid_switch to switch_device to disambiguate lid and tablet mode switches.
2019-03-19 22:45:58 -04:00
Brian Ashworth aa5c369910 wlr_output_layout_get_box: handle empty layout
If there were no outputs in the output layout,
wlr_output_layout_get_box would return the box:

{
  .x = INT_MIN,
  .y = INT_MIN,
  .width = INT_MIN - INT_MAX,
  .height = INT_MIN - INT_MAX
}

which results in an integer underflow for both the width and height.

This changes the logic to have the box be all zeroes, since an empty
output layout does not have a width or height and the location of
something without a size is irrelevant so this just uses the origin.
2019-03-08 09:45:22 +01:00
emersion 30d3426164 seat: add debug logs when validating grab serials
Makes it easier to debug when something goes wrong, e.g. button_count stuck
to 2 because the compositor ate a button release event.
2019-03-04 21:27:14 -07:00
Ian Fan 2e1dd4ae36 seat: fix remaining wlr_button_state enum rename 2019-03-01 21:49:04 +01:00
emersion e8f012c993 seat: only store serial if pressing a button
The grab serial can be used to start a pointer grab. A button pressed event
should be used for this purpose.

Thus, we should only save the grab serial if it's the first button pressed
event we send. This commit makes it so the serial is not saved if a button is
released while another button is still pressed.
2019-03-01 12:36:19 -07:00
emersion 2fde5c95d8 seat: use wlr_button_state enum instead of uint32_t 2019-03-01 12:36:03 -07:00
emersion 4135fafecd seat: guard against button count corruption
This is still a compositor bug, and bad events will be sent to clients. We'll
need to track each button separately to handle this in wlroots.
2019-02-28 23:00:57 -05:00
emersion d425206719 data-device: check if there's a source before sending dnd_finish
This could cause a segfault in data_offer_destroy if the offer has version < 3.
2019-02-24 19:40:10 -05:00
emersion d6de640440
data-device: unbreak wl_data_source.cancel during drag-and-drop 2019-02-20 18:42:34 +01:00
emersion 7d367a9e21
data-offer: send WL_DATA_OFFER_ERROR_INVALID_FINISH 2019-02-20 18:42:34 +01:00
emersion 44ec3afb27
data-device: fix drag cleanup if not started 2019-02-20 18:42:34 +01:00
emersion 6291e84532
data-device: refactor wlr_drag 2019-02-20 18:42:29 +01:00
Drew DeVault ea28887a23
Merge pull request #1493 from emersion/primary-selection-v1
primary-selection-v1: copy from gtk-primary-selection
2019-02-19 08:59:20 -05:00
Markus Ongyerth fc9838b15e Prevent NULL dereference in tablet_tool handler
In case a tool was removed, but not yet destroyed by the client, the
tool_client's tool can be NULL. We have to check that as well in the
set_cursor handler to prevent using inert resources
2019-02-19 08:51:10 +01:00
Drew DeVault b455df3b91
Merge pull request #1557 from emersion/inert-offers
data-device: make old offers inert before sending selection
2019-02-18 15:27:09 -05:00
emersion 07e1bedb08
data-device: make old offers inert before sending selection
Fixes https://github.com/swaywm/wlroots/issues/1383
2019-02-18 16:36:23 +01:00
emersion 81ed1efe4f
xwayland, data-device: fix surface state on unmap
This commit makes sure surface->mapped is true when the unmapped event is
emitted. This is necessary because listeners can only damage surfaces that are
mapped. This is similar to the fact that the destroy event is emitted before
any destruction is actually made.

Fixes https://github.com/swaywm/sway/issues/3568
2019-02-18 13:14:35 +01:00
emersion 943e918a96
subsurface: add map/unmap events
Fixes https://github.com/swaywm/wlroots/issues/1414
2019-02-17 12:01:15 +01:00
Brian Ashworth 3c9f791d0e wlr_output: do not modeset to current mode
There is no point in modesetting an output to a mode that it is already
set to. Modesetting will cause the output to briefly flicker which is
undesirable for a noop. This prevents modesetting any wlr_output,
regardless of the backend, to it's currently set mode.
2019-02-17 00:12:59 +01:00
Drew DeVault 8b203c28f8
Merge pull request #1548 from emersion/error-invalid-transform
surface: error out on invalid transform
2019-02-15 15:28:00 +01:00
Ivan Molodetskikh b59370088e Update data-control 2019-02-15 11:58:33 +01:00
emersion d238cc9f56
surface: error out on invalid transform 2019-02-15 00:50:18 +01:00
Sebastian Krzyszkowiak 69b9e2ae8f Post protocol error on invalid wl_surface scale
Letting the scale be set to 0 causes division by zero errors.
2019-02-15 00:45:12 +01:00
emersion 8163f7e1e2
primary-selection-v1: copy from gtk-primary-selection 2019-02-13 19:28:25 +01:00
Geoff Greer 5c8d2da0a1 Add a wlr_output_set_subpixel()
drmModeConnector.subpixel doesn't seem to detect subpixel order on many displays (especially laptops). Allow subpixel order to be manually set.

The corresponding PR for sway adds a subpixel output option: https://github.com/swaywm/sway/pull/3645

Once both are merged, https://github.com/swaywm/sway/issues/3163 will be fixed.
2019-02-13 19:20:29 +01:00
Ivan Molodetskikh 9e49ceb129 data-control: add primary selection support
data-control: separate out a data_offer struct

This is a prerequisite to adding primary selection support.

data-control: separate out data_control_source

This is a prerequisite to adding primary selection support, since that
doesn't use wlr_data_source, but rather wlr_primary_selection_source.

Update the data-control protocol

data-control: add primary selection support

Merge create_offer and create_primary_offer

Extract code into data_control_source_destroy()

Fix pointer style

Move resource neutralization to destructor

Store wl_resource in the data_offer

Extract data_offer destruction into a function
2019-02-10 17:12:05 +01:00
Drew DeVault 20d404a091
Merge pull request #1529 from emersion/better-dnd-fix
data-device: destroy previous source when starting drag
2019-02-06 14:39:55 +01:00
emersion 7f5967234c
xdg-shell: destroy child popups on unmap
It doesn't make sense to keep popups opened when unmapped. We also need to do
so in wlr_xdg_popup_destroy so that popups are destroyed in the correct order.
2019-02-05 19:29:00 +01:00
emersion 556bf3ac31
data-device: destroy previous source when starting drag
This supersedes f24e17259e and
04c9ca4198. These commits were manually removing
wlr_data_source destroy handlers when starting a new drag. This is error-prone.

Instead, this commit destroys the previous source whenever we start a new drag.
2019-02-05 18:43:06 +01:00
Connor E c1d0729d9a Make popup inert when destroyed. 2019-02-04 10:43:51 +01:00
John Chen f24e17259e Fix swaywm/sway#3545. 2019-02-02 14:05:31 +01:00
Drew DeVault 28f11aec31
Merge pull request #1523 from emersion/set-same-selection-crash
data-device: fix crash when setting the same selection twice
2019-02-01 09:41:02 +01:00
Drew DeVault 16a93eddfb
Merge pull request #1519 from emersion/dedup-source-mime-type
De-duplicate data source MIME types
2019-02-01 09:40:47 +01:00
emersion f1d3aeff9a
data-device: fix crash when setting the same selection twice 2019-01-31 20:33:48 +01:00
emersion 790f0c52a1
De-duplicate data source MIME types 2019-01-30 22:10:52 +01:00
emersion 7defb30781
relative-pointer-v1: time is in usec, not msec 2019-01-30 21:25:42 +01:00
emersion 29952dee19
data-device: only allow one drag at a time 2019-01-30 15:24:18 +01:00
emersion d6de329d98
seat: don't send motion if pointer hasn't moved 2019-01-30 15:24:17 +01:00
emersion c505ce3019
data-device: fix use-after-free on drop 2019-01-30 15:24:14 +01:00
emersion 2624f667bf
Add missing frame events to shell pointer grabs 2019-01-30 10:31:53 +01:00
emersion 75371d2c88
Require libdrm >= 2.4.95 2019-01-29 19:33:38 +01:00
Greg V 9fe8e37961 Implement the pointer-gestures-unstable-v1 protocol
This protocol relays touchpad gesture events produced by libinput to
supporting clients (e.g. Evince, Eye of GNOME).
2019-01-28 22:06:36 +01:00
Drew DeVault 018727b1fc
Merge pull request #1503 from emersion/pointer-frame
pointer: add a frame event
2019-01-27 10:22:06 -05:00
emersion 5fdf22b5d3
data-control-v1: handle NULL sources in set_selection 2019-01-26 11:25:39 +01:00
emersion 5de26ad8ed
pointer: add a frame event
Frame events group logically connected pointer events. It makes sense to make
the backend responsible for sending frame events, since once the events are
split (ie. once the frame events are stripped) it's not easy to figure out
which events belongs to which frame again.

This is also how Weston handles frame events.

Fixes https://github.com/swaywm/wlroots/issues/1468
2019-01-26 11:04:05 +01:00
emersion a1f9d7ad9e
data-device: keep track of wlr_data_offer in wlr_seat lists 2019-01-24 12:18:41 +01:00
emersion 909b3b16f3
data-device: add wlr_data_offer.type 2019-01-24 12:18:40 +01:00
emersion 3f82eb1853
data-device: make device inert when seat is destroyed 2019-01-24 12:18:39 +01:00
emersion 9d6cb85b2d
seat: simplify data source destroy 2019-01-24 12:18:00 +01:00
emersion c20d413f8a
data-device: fix missing listener removal 2019-01-24 12:18:00 +01:00
emersion 703a160078
data-control-v1: use new wlr_data_source API 2019-01-24 12:15:18 +01:00
emersion 0040f7089f
data-device: unexport wlr_seat_client_send_selection 2019-01-24 12:15:18 +01:00
emersion 1a2727cc38
data-device: send offer on get_data_device 2019-01-24 12:12:55 +01:00
emersion 84f278eca1
data-device: remove data_source_send_offer 2019-01-24 12:12:55 +01:00
emersion 1150ff13ce
data-device: make sources inert, rename cancel to destroy 2019-01-24 12:12:55 +01:00
emersion 4cb0697e57 data-device, primary-selection: add request_set_selection
This makes compositors able to block and/or customize set_selection requests
coming from clients. For instance, it's possible for a compositor to disable
rich selection content (by removing all MIME types except text/plain). This
commit implements the design proposed in [1].

Two new events are added to wlr_seat: request_set_selection and
request_set_primary_selection. Compositors need to listen to these events and
either destroy the source or effectively set the selection.

Fixes https://github.com/swaywm/wlroots/issues/1138

[1]: https://github.com/swaywm/wlroots/issues/1367#issuecomment-442403454
2019-01-24 11:38:23 +01:00
Ian Fan c41d01306d wlr_xdg_output_v1: move where name & description are sent 2019-01-22 22:58:52 +01:00
Brian Ashworth f3ff40a0eb wlr_xdg_output_v1: only send name/description once
The xdg-output protocol states that name and description should only be
sent once per output since they do not change.
2019-01-22 21:53:33 +01:00
emersion 365a75139c
Merge pull request #1485 from emersion/data-device-serial
primary-selection: add a serial argument
2019-01-22 20:13:01 +01:00
Ilya Trukhanov c4ce3d0a49 Check if client understands wl_pointer::frame
Fixes a crash in SDL2 applications when using locked pointer.

SDL2 expects a wl_pointer v1 interface and doesn't provide a handler for
the wl_pointer::frame event. This results in a "listener function for
opcode 5 of wl_pointer is NULL" abort in wayland-client.

Tested on Xonotic v0.8.2 with libSDL2 v2.0.9. Xonotic needs to be ran
with "SDL_VIDEODRIVER=wayland xonotic-sdl" for SDL2 to use the wayland
backend.
2019-01-22 19:50:01 +02:00
emersion 06467d2e12
primary-selection: add a serial argument
The serial needs to be bumped when X11 clients set the selection, otherwise
some Wayland clients (e.g. GTK) will overwrite it when they gain focus.
2019-01-21 19:23:40 +01:00
emersion a4eb90315e
Fix indentation in various files 2019-01-21 17:56:19 +01:00
Drew DeVault d4de2bd708
Merge pull request #1476 from emersion/fullscreen-shell
fullscreen-shell-v1: initial protocol implementation
2019-01-20 09:30:52 -05:00
Drew DeVault 0db2a687b7
Merge pull request #1479 from emersion/lost-crtc-state
backend/drm: fix state for outputs loosing their CRTC
2019-01-20 09:02:00 -05:00
emersion d4ffa5b7a6
backend/drm: fix state for outputs loosing their CRTC
When there aren't enough CRTCs for all outputs, we try to move a CRTC from a
disabled output to an enabled one. When this happens, the old output's state
wasn't changed, so the compositor thought it was still enabled and rendering.

This commit marks the old output as WLR_DRM_CONN_NEEDS_MODESET and sets its
current mode to NULL.
2019-01-19 10:18:03 +01:00
Ilya Trukhanov 268cc450b6 Fix segfault in get_relative_pointer
Occurs on subsequent calls to
relative_pointer_manager_v1_handle_get_relative_pointer()

Steps to reproduce:
- run rootston
- run examples/relative-pointer
- switch to relative pointer more than once

Note: if done fast enough it may take more than two switches to crash.
2019-01-18 22:53:32 +02:00
Connor E b1cdd2b4b3 Use assertions instead of guard. 2019-01-14 16:05:24 +00:00
Connor E e7fff4f560 Remove wlr_xdg_surface_send_close. 2019-01-13 14:22:49 +00:00
emersion 0fafab87e3
Fix a few typos 2019-01-10 09:30:14 +01:00
Drew DeVault e61ea7706b
Merge pull request #1423 from emersion/data-control
Implement data-control-unstable-v1
2019-01-06 22:41:35 -05:00
emersion f71cf15aad
relative-pointer-v1: move pointer iteration in wlroots
This makes sure we always send events to the right client.
2019-01-06 12:17:31 +01:00
emersion 86f263a0b8
fullscreen-shell-v1: initial protocol implementation 2019-01-06 12:12:06 +01:00
emersion 610f5bfc77
Merge pull request #1432 from ForTheReallys/relative-pointers
Relative pointers
2019-01-04 13:42:53 +01:00
emersion 69e7fd61b7
data-control-v1: update to latest protocol proposal 2018-12-30 02:52:03 +01:00
emersion 340281b48a
data-control-v1: fix data source not properly destroyed 2018-12-30 02:48:04 +01:00
emersion a28167c255
data-control-v1: allow clearing selection 2018-12-30 02:48:03 +01:00
emersion ae1dd635b1
data-device: fix dangling listener in seat_client_selection_source_destroy 2018-12-30 02:48:03 +01:00
emersion aa2dafb7c8
data-control-v1: fix crash in manager_handle_get_data_control 2018-12-30 02:48:03 +01:00
emersion 1e581ad95c
data-control-v1: fix crash after wlr_data_control_v1_destroy 2018-12-30 02:48:03 +01:00
emersion 99d879c887
data-control-v1: initial protocol implementation 2018-12-30 02:48:03 +01:00
Alex Maese b8460f448c Rename some variables for clarity 2018-12-23 06:50:39 -06:00
Timidger 9af0c5338f
Standardize the wlr_box input paramaters
Fixes #1094
2018-12-21 13:56:10 -05:00
Alex Maese 5999d0322b Add a listener for when the pointer gets destroyed 2018-12-21 12:20:48 -06:00
Alex Maese 12d9edc0c9 Address more of @emersion's comments 2018-12-21 12:20:48 -06:00
Alex Maese a803a007fb Address @emersion's comments 2018-12-21 12:20:48 -06:00
Alex Maese f5ea393bca Remove pointer resource from relative pointer 2018-12-21 12:20:48 -06:00
Alex Maese 09bdbf24f4 Removed relative pointers from wlr_seat 2018-12-21 12:20:48 -06:00
Alex Maese f4cf3c0886 Remove wl_client from wlr_relative_pointer_v1 2018-12-21 12:20:48 -06:00
random human 68137dca3f relative_pointer: implementation and code fixes
In particular, modified public creator and destructor function names,
added a display destroy listener, safely extract user data from
resources, send correct time (in usecs) in rootston, etc.
2018-12-21 12:20:48 -06:00
random human fb44ce9fa8 relative_pointer: send frame event to pointer for Xwayland 2018-12-21 12:20:48 -06:00
random human 6fa1777f94 relative_pointer: code formatting fixes 2018-12-21 12:20:48 -06:00
random human d020344675 relative_pointer: implement protocol events
Implement zwp_relative_pointer_v1.relative_motion event, along with some
glue code in wlr_seat_pointer and rootston.
2018-12-21 12:20:48 -06:00
random human ba5b1676df relative_pointer: implement protocol requests
Flesh out the details of the structs, signals, callback functions, and
so on. weston-resizer silently works at this point (no events sent).
2018-12-21 12:20:48 -06:00
random human 3a3d1b6617 relative_pointer: create skeleton and build
Add protocol, header and type files to build. Create skeleton structs,
creator and destroyer, and define implementations.
2018-12-21 12:20:47 -06:00
Ryan Walklin 2a3c62b4d2 [WIP][DONTMERGE]Add support for libinput_switch input devices
These are used primarily by laptops to signal
the state of the lid (open/closed) and tablet
mode if supported, based on ACPI events.
2018-12-15 14:42:35 +11:00
Drew DeVault ef9506b0bc
Merge pull request #1433 from ammen99/fix-layer-shell-unconstrain
xdg-popup: fix wlr_xdg_popup_get_toplevel_coords()
2018-12-12 07:48:21 -05:00
Ilia Bozhinov 07865104e1 xdg-popup: fix wlr_xdg_popup_get_toplevel_coords()
The previous code resulted in a crash when we try to unconstrain a popup
which is part of a layer-shell surface popup tree.

Fixes #1425
2018-12-12 08:51:13 +01:00
emersion c2113decb3
gtk-primary-selection: warn when offering MIME type after set_selection 2018-12-09 12:42:27 +01:00
emersion 8c573bc7c6
gtk-primary-selection: basic serial validation 2018-12-09 12:38:35 +01:00
Ilia Bozhinov 5b1b9657bf types: implement wlr_foreign_toplevel_management_v1 2018-12-08 14:09:30 +01:00
emersion 1256314afe
export-dmabuf-v1: add missing destroy request handler
Also document lists in the header file.
2018-12-06 19:08:28 +01:00
Drew DeVault fdb67ff63b
Merge pull request #1415 from emersion/tablet-seat-leak
tablet-v2: fix wlr_tablet_seat_v2 leak
2018-12-04 18:20:46 -05:00
emersion 3ca7ca5306
tablet-v2: fix wlr_tablet_seat_v2 leak 2018-12-04 20:06:38 +01:00
emersion 5515faa197
xdg-shell: emit xdg_surface destroy when role object is destroyed
Fixes https://github.com/swaywm/wlroots/issues/1407
2018-12-04 13:42:29 +01:00
Drew DeVault 273e110b74
Merge pull request #1403 from emersion/swap-buffers-damage-coords
output: switch swap_buffers damage to output-buffer-local coords
2018-12-02 13:17:24 -05:00
emersion 6aaefad40d
output: switch swap_buffers damage to output-buffer-local coords
This is one more step towards [1]. This gives more freedom to the compositor
wrt. how it handles damage.

[1]: https://github.com/swaywm/wlroots/issues/1363
2018-12-01 10:56:35 +01:00
emersion 9f0720c03a
primary-selection: introduce wlr_primary_selection_source
This is a common interface that can be used for all primary selection
protocols, as discussed in [1]. A new function wlr_seat_set_primary_selection
is added to set the primary selection for all protocols.

The seat now owns again the source, and resets the selection to NULL when
destroyed.

[1]: https://github.com/swaywm/wlroots/issues/1367#issuecomment-442403454
2018-11-29 19:40:28 +01:00
emersion 658b590567
gtk-primary-selection: fix segfault when no focus 2018-11-27 21:09:41 +01:00
emersion bfa7f4ee0d
gtk-primary-selection: use impl pattern for sources 2018-11-27 20:16:55 +01:00
emersion cbe42d1006
gtk-primary-selection: remove offer struct
We don't need it, we can use the device instead.
2018-11-27 19:45:39 +01:00
emersion f001f98cef
gtk-primary-selection: refactor everything, untie from seat
This commits completely refactors wlr_gtk_primary_selection. The goal is to
remove gtk-primary-selection state from the seat and better handle inert
resources where it makes sense.

wlr_seat_client.primary_selection_devices has been removed and replaced by
wlr_gtk_primary_selection_device. This allows us to make offers inert when the
current selection is replaced.

wlr_seat_set_primary_selection has been removed because it relied on wlr_seat
instead of wlr_gtk_primary_selection_device_manager. A new function,
wlr_gtk_primary_selection_device_manager_set_selection (candidate for the
longest function name in wlroots) has been added. It doesn't take a serial
anymore as serial checking only makes sense for set_selection requests coming
from Wayland clients (serial checking is now done in the Wayland interface
implementation).

Since wlr_gtk_primary_selection_device_manager is now required to set the
selection, a new function wlr_xwayland_set_gtk_primary_selection_device_manager
(candidate number two for longest function name) has been added.

Devices are now made inert when the seat goes away.

Future work includes removing the last primary selection bits from the seat,
mainly wlr_seat.primary_selection_source and wlr_seat.events.primary_selection,
replacing those with new fields in wlr_gtk_primary_selection_device. Or maybe
we could keep those in the seat and replace them with a re-usable interface
(for future zwp_primary_selection_v1 support). We need to think how we'll sync
these three protocols (GTK, X11 and wayland-protocols).

See https://github.com/swaywm/wlroots/issues/1388
2018-11-27 18:57:26 +01:00
Drew DeVault 05bb440786
Merge pull request #1387 from emersion/rename-gtk-primary-selection
Rename wlr_primary_selection to wlr_gtk_primary_selection
2018-11-26 18:36:23 -05:00
Drew DeVault a2b8d47ff2
Merge pull request #1384 from emersion/data-multiple-devices
data-device: allow multiple devices for the same seat
2018-11-26 18:25:59 -05:00
emersion a5b8ea90d2
surface: fix destroyed subsurfaces handling
wlr_subsurface_from_wlr_surface can return NULL if the wl_surface is still
alive and if the wl_subsurface has been destroyed. Make sure we check for NULL.

Fixes https://github.com/swaywm/sway/issues/3195
2018-11-26 23:17:52 +01:00
emersion 4423f88fac
data-device: never cancel the source when offer is destroyed
The source could be used in another offer.
2018-11-26 12:35:49 +01:00
emersion 5d26da9d15
data-device: allow multiple devices for the same seat
This commit makes it possible for a single client to have multiple data devices
for the same seat. This fixes issues with Firefox.

This mainly removes wlr_data_source.offer. We make sure we create one data
offer per device. We now make the offer inert when the source is destroyed.

Fixes the second half of https://github.com/swaywm/wlroots/issues/1041
2018-11-26 12:35:48 +01:00
emersion 27d1910bec
text-input-v3: remove newline in log message 2018-11-26 12:15:34 +01:00
Drew DeVault 90f1a34d2c
Merge pull request #1375 from emersion/tablet-segfault
tablet-v2: fix segfault on display destroy
2018-11-25 17:30:31 -05:00
Ilia Bozhinov fb5691b6cc output: add wlr_output_preferred_read_format()
The read format is dependent on the output, so we first need to make it
current. This fixes a race condition in wlr-screencopy-v1 where a dmabuf
client would cause EGL_NO_SURFACE to be bound at the time when
screencopy needs to query for the preferred format, causing GL errors.
2018-11-24 10:54:25 +01:00
emersion 811a4d997b
Rename wlr_primary_selection to wlr_gtk_primary_selection 2018-11-23 11:58:56 +01:00
emersion eaafd65a12
gtk-primary-selection: track resources 2018-11-21 11:16:31 +01:00
emersion b9a2e4ba4c
gtk-primary-selection: support multiple devices
When a client was creating multiple data devices for the same seat, we were
only creating one resource. This is a protocol error.

Instead, create one offer per data device.

This commit also makes offers inert when their source is destroyed.

Fixes part of https://github.com/swaywm/wlroots/issues/1041
Supersedes https://github.com/swaywm/wlroots/pull/1113
2018-11-21 11:16:25 +01:00
emersion 1b9ebcf645
output: make wlr_egl flip the damage 2018-11-13 16:55:33 +01:00
emersion ca770995cc
output: add wlr_output_render_software_cursors
Rendering in wlr_output_swap_buffers has unfortunate side-effects.
2018-11-13 16:55:33 +01:00
emersion 57307b7aa7
output: remove wlr_output_set_fullscreen_surface
This wasn't using direct scan-out. Direct scan-out will probably
work differently with @ascent12's work anyway.
2018-11-13 16:55:33 +01:00
emersion 89ec624f81
tablet-v2: fix segfault on display destroy 2018-11-12 20:05:13 +01:00
emersion 95dfbe2962
xdg-shell: don't destroy xdg role state on role destroy
ie. don't destroy surface->toplevel on xdg_toplevel destroy. Instead do this on
xdg_surface destroy.

This allows compositors to add toplevel listeners when the surface appears and
remove them when the surface is destroyed.
2018-11-12 19:37:22 +01:00
Julio Galvan a31fa678e5
Fix compilation error on musl
_XOPEN_SOURCE is needed for the strings.h ffs function on the musl libc implementation
2018-11-09 04:27:06 +00:00