Commit Graph

958 Commits

Author SHA1 Message Date
Simon Ser 475d9701e2 Remove reference to the announce mailing list
The mailing list has never been used.

I think listing the deprecated functions in the release notes is
enough. I'd rather not add the burden of maintaining a separate
communication medium.
2021-07-05 09:24:24 -04:00
Simon Ser a38baec1f8 buffer: make enum wlr_buffer_cap public
Custom backends and renderers need to implement
wlr_backend_impl.get_buffer_caps and
wlr_renderer_impl.get_render_buffer_caps. They can't if enum
wlr_buffer_cap isn't made public.
2021-07-01 16:40:19 -04:00
Simon Ser 57b70a478c Drop wlr_list 2021-07-01 10:35:39 -04:00
Simon Ser 5888c96da8 tablet: stop using wlr_list 2021-07-01 10:35:39 -04:00
Simon Ser dbb0e2f75b Remove unused wlr_list.h includes 2021-07-01 10:35:39 -04:00
Simon Ser 1b4fb4b537 touch: document event data types 2021-06-30 11:24:08 +02:00
Simon Ser bcbdee43f7 pointer: document event data types 2021-06-30 11:23:50 +02:00
Simon Ser 7cbcc65ad0 surface: make wlr_subsurface_create private
Same as [1], but for wlr_subsurface.

[1]: https://github.com/swaywm/wlroots/pull/2814
2021-06-29 10:32:17 -04:00
Simon Ser 69477051cc matrix: deprecate wlr_matrix_projection
This function has baked-in GL assumptions. Compositors shouldn't
need to use it.
2021-06-07 22:55:46 +02:00
Simon Ser 1a06ea7750 output: make attach_render and rollback_render optional
If these aren't provided by the backend, allocate a swapchain for the
output.
2021-06-07 15:42:38 +02:00
Simon Ser 38ba5881a0 buffer: replace get_data_ptr with {begin,end}_data_ptr_access
This new API allows buffer implementations to know when a user is
actively accessing the buffer's underlying storage. This is
important for the upcoming client-backed wlr_buffer implementation.
2021-06-07 09:22:56 -04:00
Simon Ser 9e58301df7 surface: allow placing subsurfaces below parent
Prior to this commit, subsurfaces could only be placed above their
parent. Any place_{above,below} request involving the parent would
fail with a protocol error.

However the Wayland protocol allows using the parent surface in the
place_{above,below} requests, and allows subsurfaces to be placed
below their parent.

Weston's implementation adds a dummy wl_list node in the subsurface
list. However this is potentially dangerous: iterating the list
requires making sure the dummy wl_list node is checked for, otherwise
memory corruption will happen.

Instead, split the list in two: one for subsurfaces above the parent,
the other for subsurfaces below.

Tested with wleird's subsurfaces demo client.

Closes: https://github.com/swaywm/wlroots/issues/1865
2021-06-03 14:04:07 +02:00
zccrs 11040d4942 Make the xdg_popup_get_position to public
Rename the xdg_popup_get_position to
wlr_xdg_popup_get_position
2021-06-03 09:50:54 +02:00
Simon Ser 76f51a949f xdg-activation-v1: add token timeout
There isn't always a good time to prune old tokens. Compositors
which only implement a "give focus on activation" logic can prune
tokens on focus change. However other compositors might want to
implement other semantics, e.g. "mark urgent on activation". In this
case a focus change shouldn't invalidate other tokens.

Additionally, some tokens aren't necessarily tied to a seat.

To avoid ending up with an ever-growing list of tokens, add a timeout.
2021-06-02 11:18:25 +02:00
Simon Ser 8ff435831f xdg-activation-v1: new protocol implementation
This implements the new xdg-activation-v1 protocol [1].

[1]: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/50
2021-06-02 11:18:25 +02:00
Simon Ser 2b0a1aeed5 output: take a wlr_buffer in set_cursor
Instead of passing a wlr_texture to the backend, directly pass a
wlr_buffer. Use get_cursor_size and get_cursor_formats to create
a wlr_buffer that can be used as a cursor.

We don't want to pass a wlr_texture because we want to remove as
many rendering bits from the backend as possible.
2021-06-02 11:08:52 +02:00
Simon Ser 6f39574ff5 linux-dmabuf-v1: implement wlr_buffer
This allows the DMA-BUF wl_buffer objects to be used directly as
wlr_buffers, without having to use wlr_client_buffer_import.
2021-05-17 16:22:43 +02:00
Simon Ser 24fde77c62 buffer: add format param to get_data_ptr
Allow wlr_buffer_impl.get_data_ptr to return a format.

This allows the Pixman renderer to not care about get_dmabuf/get_shm,
and only care about get_data_ptr. This will also help with [1], because
client wl_shm buffers can't implement get_shm.

[1]: https://github.com/swaywm/wlroots/pull/2892

References: https://github.com/swaywm/wlroots/issues/2864
2021-04-27 20:36:03 +02:00
Simon Ser e8df7c367a linux-dmabuf-v1: split params and buffer
Previously, the same struct was used for linux-dmabuf-v1 params
and buffer. This made the whole logic a little bit awkward, because
a wlr_dmabuf_v1_buffer could either be still being constructed, or
be a complete buffer.

Introduce a separate wlr_linux_buffer_params_v1 struct for buffer
params still being constructed. Once the params are complete (ie.
once the create request is sent), the params struct is destroyed
and the buffer struct is created.

This will help with [1] as well.

[1]: https://github.com/swaywm/wlroots/issues/2664
2021-04-19 18:09:13 +02:00
Simon Ser f64ed60c7b linux-dmabuf-v1: drop some from_resource helpers
Drop wlr_dmabuf_v1_buffer_from_params_resource and
wlr_linux_dmabuf_v1_from_resource. Contrary to wl_buffer, these
resources are internal linux-dmabuf-v1 implementation details and
should not be shared with other interfaces.
2021-04-19 18:09:13 +02:00
Simon Ser 6c61de996c buffer: introduce wlr_buffer_get_shm
References: https://github.com/swaywm/wlroots/issues/2399#issuecomment-769408708
2021-04-17 09:54:39 +02:00
Simon Zeni 0b9288ec0b buffer: introduce wlr_buffer_get_data_ptr
The function has been place in an internal header for API stability
reasons.
2021-04-17 09:54:39 +02:00
Benoit Gschwind ee3640363e Document the wlr_output_layout_get function 2021-04-11 10:19:00 +02:00
Isaac Freund 78befa59f9 gtk-primary-selection: drop support
The standard primary-selection protocol is now widely supported.
2021-04-08 09:50:18 +02:00
Simon Ser c430cd7d53 surface: make wlr_surface_create private
This is not meant to be exposed in the public API, just like
wlr_region_create [1].

[1]: https://github.com/swaywm/wlroots/pull/2662
2021-04-06 14:57:44 +02:00
zccrs e76583f1ad Use absolute paths in include in header files
To unify the code style of the project, absolute paths have been used in
some places, such as '#include "render/allocator.h"' in
"render/gbm_allocator.h". Except for include the wayland protocol
headers should be consistent.
2021-04-06 10:40:56 +02:00
Simon Ser 8ecc557ab0 subsurface: use cached surface state 2021-03-25 19:34:47 +01:00
Simon Ser e0258f4506 surface: introduce cached states
Cached states allow a surface commit to be delayed. They are useful for:

- Subsurfaces
- The upcoming transactions protocol [1]
- Explicit synchronization

[1]: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/26
2021-03-25 19:34:47 +01:00
Simon Ser 7ac76aba8a surface: introduce commit sequence numbers
Very similar to output commit sequence numbers. Can be useful to
reference a specific commit.
2021-03-25 19:34:47 +01:00
Simon Ser cf5b09ede2 Remove unnecessary wayland-server-protocol.h includes 2021-02-23 16:09:26 +01:00
Simon Ser 00bf6674b3 output: use DRM format in wlr_output_preferred_read_format 2021-02-23 16:09:26 +01:00
Tadeo Kondrak 78685ec6aa text_input_v3: correct typo in enum field 2021-02-15 16:33:05 +01:00
Manuel Stoeckl a290d7a78d Make implementation function lists static const
This requires a change to the type of `struct wlr_tablet` and
`wlr_tablet_init` signature, both of which are part of the unstable API.
2021-02-05 10:04:20 +01:00
Simon Ser 45f992b27b region: make wlr_region_create private
This function should only be called from the handler for
wl_compositor.create_region requests.
2021-02-02 23:42:53 +01:00
Simon Ser 1fb9535e99 output-damage: stop relying on output pending state on commit
References: https://github.com/swaywm/wlroots/issues/2098
2021-01-16 09:06:27 +01:00
Simon Ser cc56b4f073 output: remove scale/transform events
Instead, the commit event should be used.
2021-01-15 10:18:56 +01:00
Simon Ser f6f46b4ee2 output-damage: stop listening to scale/transform events
Only listen to the commit event.
2021-01-15 10:18:56 +01:00
Daniel Kondor b7dc4f2990 layer-shell: allow new values for keyboard-interactivity
Value is now an enum with a new value ("on-demand") that compositors can use to allow "normal" keyboard focus semantics regardless of the layer the client surface is on. An error is sent for invalid keyboard interactivity values. The old behavior is retained for clients using the previous version of the protocol.

Also adjusted the layer-shell example program to use the new keyboard interactivity options.
2021-01-12 20:13:52 +01:00
Isaac Freund 07111828c5 layer shell: rename popup iterator for consistency
This iterates over the subsurfaces of popups as well, so rename it to
match wlr_xdg_surface_for_each_popup_surface().
2021-01-12 11:26:08 +01:00
Isaac Freund f574ca934c xdg shell: remove wlr_xdg_surface_for_each_popup()
This function is inferior to wlr_xdg_surface_for_each_popup_surface()
for rendering as it does not iterate over subsurfaces. Furthermore,
no compositor is known to use this to iterate popups for any purpose
other than rendering. Therefore remove the function, which may of course
be reintroduced at a later date if a use-case is found.
2021-01-12 11:25:55 +01:00
Isaac Freund d6890cb847 output-management: use same types as wlr_output
This is more correct and also makes things much nicer for languages
that don't allow implicit conversions between these types.
2021-01-10 16:28:19 +01:00
Isaac Freund 4ee4a36c0c layer shell: add wlr_layer_surface_v1_popup_surface_at()
This function will allow compositors to implement input handling in a
way consistent with rendering more easily.

Calling wlr_layer_surface_v1_surface_at() and checking if the result is
a wlr_xdg_popup is flawed as there may be subsurfaces in the popup tree.
2021-01-08 12:05:13 +01:00
Isaac Freund 8f63557ed7 xdg shell: add wlr_xdg_surface_popup_surface_at()
This function will allow compositors to implement input handling in a
way consistent with rendering more easily.

Calling wlr_xdg_surface_surface_at() and checking if the result is a
wlr_xdg_popup is flawed as there may be subsurfaces in the popup tree.
2021-01-08 12:05:13 +01:00
Isaac Freund c5c5ab9724 xdg shell: add wlr_xdg_surface_for_each_popup_surface()
When rendering, it is necessary to iterate the subsurfaces as well,
so add a function that makes this easy.
2021-01-08 10:33:16 +01:00
Isaac Freund 129e02b57d xdg shell: make unconstrain_from_box arg const 2021-01-07 21:28:55 +01:00
Andri Yngvason e136a4168b types/seat: Clear focus in wlr_seat_destroy()
This fixes use-after-free in surface destroy signal listeners.
2021-01-07 14:35:08 +01:00
Ilia Bozhinov 01dcfb360e types: add wlr_xdg_foreign_v2
Co-authored-by: Jason Francis <cycl0ps@tuta.io>
2021-01-05 20:32:56 +01:00
Ilia Bozhinov 162f160def types: add wlr_xdg_foreign_v1
Co-authored-by: Jason Francis <cycl0ps@tuta.io>
2021-01-05 20:32:56 +01:00
Ilia Bozhinov 37602e153b types: add wlr_xdg_foreign_registry 2021-01-05 20:32:56 +01:00
Ilia Bozhinov 42d033e738 xdg-shell: add wlr_xdg_toplevel_set_parent
Co-authored-by: Jason Francis <cycl0ps@tuta.io>
2021-01-05 20:32:56 +01:00
Isaac Freund 83fdfa511d docs: wlr_surface_from_resource cannot return NULL
Surfaces never become inert.
2021-01-05 12:22:47 +01:00
Isaac Freund f6fc4c2883 subsurface: handle NULL parent in get_root_surface 2020-12-22 15:55:05 +01:00
Isaac Freund c9760569ae docs: fix error in wlr_output_set_damage() comment
output-buffer-local coordinates are neither scaled nor transformed
2020-12-07 20:45:36 +01:00
Kenny Levinsen ebecc5404b surface: Make send_enter store entered outputs
wlr_surface_send_enter now stores outputs that have been entered.
Combined with a new 'bind' event on wlr_output, this allows us to delay
enter events as necessary until the respective wl_output global has been
bound.

Closes: https://github.com/swaywm/wlroots/issues/2466
2020-11-23 10:58:50 +01:00
Simon Ser 0b40d09a21 buffer: add wlr_client_buffer_get 2020-11-15 22:48:42 +01:00
Isaac Freund e06c9e43af Remove unneeded includes from wlr_input_device.h
This uncovered many places where we were using things without directly
including them.
2020-11-11 15:40:47 +01:00
Isaac Freund 7693f61d81 Replace wlr_key_state with wl_keyboard_key_state
There's no reason to have duplicate enums
2020-11-11 10:58:38 +01:00
Simon Ser 51fc7ddb29 screencopy: perform DMA-BUF copy on output commit 2020-11-05 09:43:42 +01:00
Simon Ser f0945e112f export-dmabuf: export DMA-BUF on output commit
We were previously exporting DMA-BUFs when receiving the capture_output
request, and sending a done event on wlr_output.events.precommit. Instead,
export and send done on wlr_output.events.commit.
2020-11-05 09:43:42 +01:00
Simon Ser 8c8164c4a6 output: add when field to wlr_output_event_commit
Similar to the one already present in wlr_output_event_precommit.
2020-11-05 09:43:42 +01:00
Simon Ser ccd313e01a output: update docs to reflect reality
The docs were outdated and weren't matching what the DRM backend does
(the only implementor of wlr_output_export_dmabuf).
2020-11-05 09:43:42 +01:00
Simon Ser c2db691cad gamma-control-v1: apply gamma LUT when output gets enabled
Closes: https://github.com/swaywm/wlroots/issues/2372
2020-11-03 17:47:04 +01:00
Tudor Brindus 0fdb41fe7c types/wlr_output_layout: use bitmask for wlr_direction 2020-10-31 23:15:21 +01:00
Tudor Brindus 7c6e06fd13 types/wlr_keyboard: use bitmasks for wlr_keyboard_led and wlr_keyboard_modifier enums 2020-10-31 23:15:21 +01:00
Daniel Kondor 36395e5b1c
foreign-toplevel-management: report parent toplevel
Based on the wlr-protocols PR:
https://github.com/swaywm/wlr-protocols/pull/52
2020-10-18 17:14:35 +02:00
Isaac Freund e410ff8dd4 wlr_drag: remove unused point_destroy field 2020-10-18 15:17:28 +02:00
Isaac Freund 616f06c25c xdg_positioner: remove unused field
The resource field of wlr_xdg_positioner is never initialized or
accessed within wlroots. The wl_resource for this interface is stored
in the wlr_xdg_positioner_resource struct.
2020-10-16 12:49:37 +02:00
Isaac Freund 8ad2cc39eb layer-shell: add for_each_popup
This brings the layer-shell api in line with that of xdg-shell and
avoids reimplementing this function in every compositor in order to
render layer shell popups correctly.
2020-09-10 17:44:55 +02:00
Drew DeVault a9cbfd950e Remove xdg-shell v6
Ding dong the witch is dead

Fixes #2381
2020-09-03 00:01:10 +02:00
Simon Ser b0144c7ded output-power-management-v1: listen to output commit 2020-08-27 13:54:19 -06:00
Simon Ser c674241ec0 output: introduce wlr_output_event_commit
This event contains a `committed` bitfield, which allows callers to know
which output fields changed during the commit.

This allows users to setup a single atomic commit listener, instead of
setting up one listener for each event (mode, scale, transform, and so
on).

References: https://github.com/swaywm/wlroots/issues/2098
2020-08-27 13:54:19 -06:00
Isaac Freund 2072d59da5 xdg-shell: split last-acked and current state
These states are distinct in the time period between the ack_configure
and the next commit on the surface. Splitting these states avoids the
following race for example:

- client starts at 1000x1000
- wlr_xdg_toplevel_set_size 500x500
- size is different -> configure sent
- client acks the configure
- wlr_xdg_toplevel_set_size 1000x1000
- compare_xdg_toplevel_state returns true since there is no pending
  configure and the currently committed size is still 1000x1000
- no new configure is sent
- client commits at the size it last acked, 500x500
2020-08-27 12:36:29 +02:00
Tudor Brindus a145430afa
input/pointer: add wlr_seat_pointer_wrap
It allows a compositor to do things like skip motion events on pointer
constraint unlock.

References: https://github.com/swaywm/sway/pull/5431
2020-07-15 19:31:13 +02:00
xdavidwu 595f324f8b input-method: implement keyboard grabs 2020-07-08 11:21:57 +02:00
xdavidwu 61e2ebac90 virtual-keyboard: add wlr_input_device_get_virtual_keyboard 2020-07-08 11:21:57 +02:00
Isaac Freund 92c85858a9 layer-shell: remove unused surface list
This was rendered useless in 5cde359.
2020-07-07 12:11:31 +02:00
Simon Ser 9e68ed2159 viewporter: new protocol implementation
Closes: https://github.com/swaywm/wlroots/issues/633
2020-06-17 09:10:54 -06:00
Simon Ser c618a76540 surface: introduce wlr_surface_get_buffer_source_box
This helper allows compositors to retrieve the buffer source box in
buffer-local coordinates.
2020-06-17 09:10:54 -06:00
Simon Ser eb22ae97b0 surface: add wlr_surface_state.viewport
This field contains the viewport source and destination parameters. It's
intended to be updated by a third-party protocol, for instance
viewporter.
2020-06-17 09:10:54 -06:00
Simon Ser 9814213a91 box: add wlr_fbox
Same as wlr_box, but for floating-point numbers.
2020-06-17 09:10:54 -06:00
Simon Ser 79e03c7d45 output: document wlr_output_export_dmabuf 2020-06-09 07:12:43 -06:00
Simon Ser a8a4a12c4b buffer: document wlr_buffer_get_dmabuf DMA-BUF lifetime 2020-06-09 07:12:43 -06:00
Andri Yngvason ea83957ecc screencopy: Implement copying into linux-dmabuf 2020-06-08 20:49:41 +02:00
Thomas Hebb dcae6f1431 Allow keyboard and pointer grabs to hook clear_focus()
This is necessary for some grabs, which currently have no way of knowing
when the pointer/keyboard focus has left a surface. For example, without
this, a drag-and-drop grab can erroneously drop into a window that the
cursor is no longer over.

This is the plumbing needed to properly fix swaywm/sway#5220. The
existing fix, swaywm/sway#5222, relies on every grab's `enter()` hook
allowing a `NULL` surface. This is not guaranteed by the API and, in
fact, is not the case for the xdg-shell popup grab and results in a
crash when the cursor leaves a surface and does not immediately enter
another one while a popup is open (#2161).

This fix also adds an assertion to wlr_seat_pointer_notify_enter() that
ensures it's never called with a `NULL` surface. This will make Sway
crash much more until it fixes its usage of the API, so we should land
this at the same time as a fix in Sway (which I haven't posted yet).
2020-06-05 17:20:26 +02:00
Thomas Hebb 8bf9f5bb8b wlr_seat: Clarify wording of non-grab-respecting function comments
I found the previous wording a bit confusing when I first read it.
Reword these comments to explicitly say that the grab-respecting
variants should be used in most cases.

This change has no functional effect.
2020-06-05 17:20:26 +02:00
Thomas Hebb e8c00e918a wlr_seat: Declare functions in the same order for pointer, keyboard, and touch
These three APIs are very similar to one another, but they all had
slightly different function orderings. For consistency, always declare
the non_`notify` functions first, then the `notify` functions, then
`{start,end,has}_grab`.

This change has no functional effect.
2020-06-05 17:20:26 +02:00
Brian Ashworth 32148808ad wlr_keyboard_group: introduce enter and leave
This introduces the enter and leave events for wlr_keyboard_group.

The enter event is emitted when a keyboard is added to the group while a
key is pressed that is not pressed by any other keyboard in the group.
The data is a wl_array of the pressed key codes unique to the keyboard
that should now be considered pressed.

Similarly the leave event is emitted when a keyboard is removed from the
group while at least one key is pressed that is not pressed by any other
keyboard in the group. The data is a wl_array of the pressed key codes
unique to the keyboard that should now be considered released.

The purpose of these events are to allow the compositor to update its
state to avoid corruption. Additionally, for the leave event, the
focused surface may have been notified of a key press for some or all of
the key codes and needs to be notified of a key release to avoid state
corruption.

These were previously emitted as normal key events, but they are not
normal key events. There is no actual key press or release associated
with the events. It's purely for state keeping purposes. Emitting them
as separate events allows the compositor to handle them differently.
Since these are purely for state keeping purposes and are not associated
with an actual key being pressed or released, bindings should not be
triggered as a result of these events.
2020-05-31 17:28:18 -04:00
Kenny Levinsen 5e0ef70cc0 seat: Create inert objects for missing capabilities
We should throw a protocol error if the relevant capability has never
existed when get_(pointer|keyboard|touch) is called. Otherwise, it
should succeed, even if the capability is not currently present.

This follows the spec, and avoids possible races with the client when
capabilities are lost.

Closes: https://github.com/swaywm/wlroots/issues/2227
2020-05-28 09:53:50 +02:00
Isaac Freund 666498db01 Make wlr_xcursor_manager_load() return a bool
This is currently inconsistent with the rest of the library and a bit of
a footgun for new compositors. However, this breaks the API in a very
unfortunate way for existing compositors.
2020-05-18 16:48:44 +02:00
Simon Ser 347bdb6d9a output: make wlr_output_set_gamma atomic
wlr_output_set_gamma is now double-buffered and applies the gamma LUT on
the next output commit.
2020-05-14 20:09:28 +02:00
Tudor Brindus 7693fdb8a7 tablet: expose wlr_tablet_tool_v2_has_implicit_grab function
This is necessary so that sway can determine when to start emulating
pointer events -- it shouldn't start doing so during an implicit grab,
even if the pen is over a surface that doesn't bind tablet input.

Refs swaywm/sway#5302.
2020-05-14 18:45:19 +02:00
Tudor Brindus 8b18d389b3 input/pointer: notify compositor when constraint region changes
This allows a compositor to know when warping back into the region is
appropriate.

Refs swaywm/sway#5268.
2020-05-13 20:38:12 +02:00
Tudor Brindus 064f64dbf7 input/keyboard: expose keymap matching helper
sway needs this logic too, and currently ships a version that has fallen
behind in terms of bugfixes (b1a63bc).
2020-05-07 23:10:03 -04:00
Tudor Brindus 16af1972d6 wlr/types: use bitshifts for tablet axes enum 2020-05-04 21:52:33 +02:00
David96 e3343cf7d1 Add wlr_surface_accepts_touch 2020-05-02 18:25:47 +02:00
Simon Ser 455a9bd0ef output_layout: improve docs 2020-04-22 22:14:29 +02:00
Isaac Freund 85e299e6c5 Document the events of wlr_layer_surface 2020-04-17 15:44:07 +02:00
Tudor Roman ffcf25cc25
seat: add selection event docs 2020-04-15 17:04:40 +02:00
Simon Ser 6977f3a843 output: check buffer in wlr_output_test
Check that buffer can be scanned out in wlr_output_test instead of
wlr_output_attach_buffer. This allows the backend to have access to the
whole pending state when performing the check.

This brings the wlr_output API more in line with the KMS API.

This removes the need for wlr_output_attach_buffer to return a value,
and for wlr_output_impl.attach_buffer.
2020-04-08 16:31:21 +02:00
Simon Ser e041158988 output: introduce wlr_output_test 2020-04-08 16:31:21 +02:00
Simon Ser 1fa9e0203b buffer: add width and height 2020-04-02 15:03:43 +02:00
Simon Ser 6595db6409 buffer: add a release event
Consumers call wlr_buffer_lock. Once all consumers are done with the
buffer, only the producer should have a reference to the buffer. In this
case, we can release the buffer (and let the producer re-use it).
2020-04-02 15:03:43 +02:00
Simon Ser 1674ca725c buffer: add destroy event 2020-04-02 15:03:43 +02:00
Simon Ser 7516a98167 Gracefully handle inert wl_output resources
Closes: https://github.com/swaywm/wlroots/issues/2088
2020-03-29 20:57:28 +02:00
Isaac Freund 8707a9b7ec Return false on wlr_keyboard_set_keymap() failure
This allows users of the library to handle or ignore the error as they
see fit.
2020-03-24 00:22:50 +01:00
Simon Ser e0bbafc253 output: replace wlr_output.damage with a damage event
This patch disambiguates the needs_frame event by uncoupling it from
damage. A new separate damage event is emitted when the backend damages
the output (this happens e.g. VT is changed or software cursors are
used). The event specifies the damaged region.

The wlr_output.damage field is removed. wlr_output is no longer
responsible for tracking its own damage, this is wlr_output_damage's
job.

This is a breaking change, but wlr_output_damage users shouldn't need an
update.

Bugs fixed:

- Screen flashes on VT switch
- Cursor damage issues on the X11 and headless backends

Closes: https://github.com/swaywm/sway/issues/5086
2020-03-12 22:47:59 +01:00
Simon Ser 41f9916ae5 buffer: remove unused wlr_client_buffer fields
Forgot to remove these, they are superseded by fields in wlr_buffer. Some
functions were still using them.

Fixes: 8afc1ed68c ("Introduce wlr_client_buffer")
Closes: https://github.com/swaywm/sway/issues/5087
2020-03-09 19:26:12 +01:00
Simon Ser 7017fa95b8 output: add adaptive_sync_enabled property 2020-03-06 21:32:58 +01:00
Simon Ser 8afc1ed68c Introduce wlr_client_buffer
Split out the client/resource handling out of wlr_buffer by introducing
wlr_client_buffer. Make wlr_buffer an interface so that compositors can
create their own wlr_buffers (e.g. backed by GBM, like glider [1]).

[1]: c66847dd1c/include/gbm_allocator.h (L7)
2020-03-06 21:32:06 +01:00
Michael Weiser 471b873de3 keyboard-shortcuts-inhibit: Implement the protocol
The keyboard shortcuts inhibitor protocol is useful for remote desktop
and virtualization software in order to request all keyboard events to
be passed to it and (almost) none being resonded to by the compositor.
This allows the session at the other end of the remote desktop
connection or inside the virtual machine to be interacted with as usual
(e.g. Alt+Tab to switch windows on the remote system instead of
locally).

Add the wayland protocol to the meson build files.

Copy'n'search'n'replace the very similar idle inhibit protocol
implementation. This already provides all the basic functionality:
- creating and destroying inhibitors upon request by a client,
- destruction in reaction to destruction of surfaces or displays,
- a list of inhibitors to search through for existing ones as well as
- a signal to be sent to the compositor upon registration of a new
  inhibitor.

Beyond that we add the active and inactive events to be sent to the
client and wire those to activate and deactivate functions for the
compositor to call in confirmation of activation of a new inhibitor or
(un-)suspending of an existing inhibitor e.g. in response to a special
key combination entered by the user as suggested by the protocol.

As mandated by the protocol, we check the existance of an inhibitor for
a given surface and seat upon creation and return the error provided by
the protocol for that purpose.

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>

Closes: https://github.com/swaywm/wlroots/issues/1817
2020-02-20 21:40:34 +01:00
Guido Günther ba14e196f6 Implement wlr-output-power-management-v1
Co-authored-by: Simon Ser <contact@emersion.fr>
2020-02-20 16:23:45 +01:00
Dorota Czaplejewicz 37adcac5d1 text_input_v3: Note features supported by the text field
With this information, consumers can realize they will never retrieve some state, and adjust their strategy.
2020-02-20 16:21:44 +01:00
Ilia Bozhinov f416efa918 output-management: add current_configuration_dirty
Previously, if the current configuration contains an output X which is
destroyed, its head is automatically removed. If the compositor submits
the new configuration after X was removed, the current output
configuration is incorrectly detected to be the same as the previous
one, and no done event is sent. To prevent this, we can just keep track
of whether the current configuration is dirty, i.e whether we have sent
a done event for it.
2020-02-19 11:40:23 +01:00
Andri Yngvason 273b280f46 virtual-pointer: Add request for mapping to specific output 2020-02-10 21:01:38 +01:00
Josef Gajdusek a7b538008b virtual-pointer: Add support for the wlr-virtual-pointer-unstable-v1 2019-12-31 10:29:02 +01:00
Simon Ser 7e521fed97 xdg-shell: fix inert xdg_surface handling
Closes: https://github.com/swaywm/sway/issues/4834
Closes: https://github.com/swaywm/wlroots/issues/1890
2019-12-30 14:24:35 -07:00
Simon Ser 8fc16890c7 output: refuse to commit a buffer or modeset a disabled output
References: https://github.com/swaywm/wlroots/issues/1780#issuecomment-518938390
2019-12-30 11:21:11 -07:00
Simon Ser 5d1ba0f446 output: re-introduce atomic mode, enabled, scale and transform
This reverts commit 01f903874b and re-applies
commit ee5f98ad49.

Updates: https://github.com/swaywm/wlroots/issues/1640 (Atomic output updates issue)
See also: https://github.com/swaywm/wlroots/pull/1762 (Atomic output updates original PR)
See also: https://github.com/swaywm/wlroots/issues/1780 (Issue caused by atomic output updates)
See also: https://github.com/swaywm/sway/issues/4419 (Issue caused by atomic output updates)
See also: https://github.com/swaywm/wlroots/pull/1781 (Revert PR)
2019-12-30 11:21:11 -07:00
Simon Ser 1f799c1cbd xdg-output-v1: use wlr_output.description
Since [1], the xdg-output description is mutable. Listen to output
description changes and send the new output description when updated.

[1]: 048102f21a
2019-12-29 12:35:22 -05:00
Simon Ser 4da4a15d6b output: add description
wlr_output.description is a string containing a human-readable string
identifying the output. Compositors can customise it via
wlr_output_set_description, for instance to make the name more
user-friendly.

References: https://github.com/swaywm/wlroots/issues/1623
2019-12-29 12:35:22 -05:00
Scott Anderson cff1c2f740 meson: Various improvements
Bumps minimum version to 0.51.0

- Remove all intermediate static libraries.
  They serve no purpose and are just add a bunch of boilerplate for
  managing dependencies and options. It's now managed as a list of
  files which are compiled into libwlroots directly.

- Use install_subdir instead of installing headers individually.
  I've changed my mind since I did that. Listing them out is annoying as
  hell, and it's easy to forget to do it.

- Add not_found_message for all of our optional dependencies that have a
  meson option. It gives some hints about what option to pass and what
  the optional dependency is for.

- Move all backend subdirectories into their own meson.build. This
keeps some of the backend-specific build logic (especially rdp and
session) more neatly separated off.

- Don't overlink example clients with code they're not using.
  This was done by merging the protocol dictionaries and setting some
  variables containing the code and client header file.
  Example clients now explicitly mention what extension protocols they
  want to link to.

- Split compositor example logic from client example logic.

- Minor formatting changes
2019-12-23 07:48:29 -05:00
Simon Ser dc6ef658b6 Revert "output: add block_idle_frame"
This reverts commit cbb2781fed.

In [1], we found issues with block_idle_frame and replaced it with
frame_pending. block_idle_frame is now unused.

[1]: https://github.com/swaywm/sway/pull/4772
2019-12-01 10:25:34 -05:00
Simon Ser 5cde35923c Simplify globals implementation by removing destructors
Some globals are static and it doesn't make sense to destroy them before
the wl_display. For instance, wl_compositor should be created before the
display is started and shouldn't be destroyed.

For these globals, we can simplify the code by removing the destructor
and stop keeping track of wl_resources (these will be destroyed with the
wl_display by libwayland).
2019-11-25 09:01:46 -05:00
Jason e8855ee462 Amend typos 2019-11-23 10:33:47 -05:00
Simon Ser 2122e49bea presentation-time: add helper for common case
Most of the time, compositors just display the surface's current buffer
on an output. Add an helper to make it easy to support presentation-time
in this case.
2019-11-21 11:03:43 -05:00
Simon Ser 533ea6d7ef presentation-time: make API more flexible
The wlr_presentation_feedback struct now tracks presentation feedback
for multiple resources (but still a single surface content update). This
allows the compositor to properly send presentation events even when
there is more than one frame of latency or when it references a
surface's buffer.
2019-11-21 11:03:43 -05:00
Simon Ser 6c649bab53 output: add wlr_output_event_present.commit_seq
This is set to the value of wlr_output.commit_seq when the frame has
been submitted. This allows tracking presentation with more then 1 full
frame of latency.

References: https://github.com/swaywm/wlroots/issues/1917
2019-11-17 00:12:59 +01:00
Brian Ashworth f2d3b1000f Introduce wlr_keyboard_group
A wlr_keyboard_group allows for multiple keyboard devices to be
combined into one logical keyboard. Each keyboard device can only be
added to one keyboard group. This helps with the situation where one
physical keyboard is exposed as multiple keyboard devices. It is up to
the compositors on how they group keyboards together, if at all.

Since a wlr_keyboard_group is one logical keyboard, the keys are a set.
This means that if a key is pressed on multiple keyboard devices, the
key event will only be emitted once, but the internal state will count
the number of devices that the key is pressed on. Likewise, the key
release will not be emitted until the key is released from all devices.
If the compositor wants access to which keys are pressed and released
on each keyboard device, the events for those devices can be listened
to, as they currently are, in addition to the group keyboard's events.

Also, all keyboard devices in the group must share the same keymap. If
the keymap's differ, the keyboard device will not be able to be added
to the group. Once in the group, if the keymap or effective layout for
one keyboard device changes, it will be synced to all keyboard devices
in the group. The repeat info and keyboard modifiers are also synced
2019-11-05 20:05:49 +01:00
Andri Yngvason 61a6f2b928 screencopy: Implement damage reporting 2019-10-22 10:41:32 -04:00
Andri Yngvason 5d8bd4d343 output: Add commit sequence number
This allows synchronisation between different instances of commit/precommit
callbacks.
2019-10-22 10:41:32 -04:00
Timidger 1724261910 layer_shell: set layer of existing surface 2019-10-16 09:41:13 -04:00
Ivan Molodetskikh cbb2781fed output: add block_idle_frame 2019-10-16 09:35:07 -04:00
Markus Ongyerth ebeef0fbe8 Clean up wayland backend tablet support
Mostly address feedback from emersion on PR #1694
Remove const qualifier from char *name, to allow free() call
2019-09-26 19:41:19 +03:00
Ivan Molodetskikh 020a33e057 presentation_feedback: add the sampled state 2019-09-19 19:44:19 +03:00
Sebastian Krzyszkowiak a14d650864 wlr_seat_touch: Destroy the touchpoint on client destroy
Since e26217c51e3a5e1d7dfc95a8a76299e056497981, touchpoints can outlive
surfaces. This works fine as long as the client stays around, but fails
horribly otherwise; therefore we have to make sure that touchpoints don't
outlive their clients.

Fixes #1788
2019-09-14 16:19:07 +03:00
Brian Ashworth 9914784594 wlr_xdg_toplevel: reparent on parent unmap
From the xdg-shell specification:
	If the parent is unmapped then its children are managed as
	though the parent of the now-unmapped parent has become the
	parent of this surface. If no parent exists for the now-unmapped
	parent then the children are managed as though they have no
	parent surface.
2019-08-15 11:19:06 +03:00
Sebastian Krzyszkowiak 78d96009e4 wlr_xdg_popup: grab touch events alongside pointer and keyboard
Fixes #933
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
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 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 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
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 91752e8285 layer-shell: Remove unused event source 2019-07-16 17:38:11 +03: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
Dorota Czaplejewicz 0b1f9439ba virtual_keyboard: Require keymap before accepting keycodes 2019-06-24 17:16:37 +03: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 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