Commit Graph

1379 Commits

Author SHA1 Message Date
Simon Ser bf623ec782 content-type-v1: add version param to wlr_content_type_manager_v1_create() 2022-11-15 16:43:04 +01:00
Simon Ser ff55663906 output: introduce request_state event
This allows backends to request the compositor to change the state
of an output.

References: https://github.com/swaywm/wlroots/issues/2300#issuecomment-761819673
2022-11-15 15:39:55 +00:00
Simon Ser 024627e872 content-type-v1: new protocol implementation
References: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/150
2022-11-15 15:36:09 +00:00
Simon Ser 258bf9be1e compositor: drop wlr_surface.{sx,sy}
The concept of a persistent accumulated surface offset is wrong
from a protocol point-of-view. wl_surface.offset is tied to a
commit, its interpretation depends on the surface role.

For example, with the following sequence:

    wl_surface@1.offset(1, 1)
    wl_surface@1.commit()
    wl_pointer@2.set_cursor(wl_surface@1, 42, 42)

The final cursor hotspot is (42, 42): the commit which happened
before the set_cursor request has no impact on the hotspot
computation.

The wlr_output_cursor logic already uses wlr_surface.current.{dx,dy}.
wlr_scene's drag icon doesn't, update it accordingly.
2022-11-15 13:41:09 +00:00
Alexander Orzechowski c8a5dfcc87 wlr_scene: Add drag icon helper 2022-11-14 15:44:43 +00:00
Simon Ser 9f793d3503 layer-shell-v1: specify version in constructor
This allows compositors to indicate which features they support,
and is required to eventually make this API stable.

References: https://github.com/swaywm/sway/issues/7260
2022-11-14 09:52:13 +01:00
Simon Ser 2b22a10478 scene: constify region APIs 2022-11-11 23:11:17 +00:00
Simon Ser c5d79bfb26 region: constify 2022-11-11 23:11:17 +00:00
Simon Ser fe4225d5de output: constify damage APIs 2022-11-11 23:11:17 +00:00
Simon Ser 9e10e9af7f output-damage: constify wlr_output_damage_add() 2022-11-11 23:11:17 +00:00
Simon Ser fb7bd920a6 damage-ring: constify wlr_damage_ring_add() 2022-11-11 23:11:17 +00:00
Simon Ser 93597952aa buffer: constify wlr_client_buffer_apply_damage() 2022-11-11 23:11:17 +00:00
Kirill Primak a707b7b101 output-damage: deprecate 2022-11-11 05:31:10 +00:00
Alexander Orzechowski ea40ba4f6a wlr_scene: Fix texture reuse
Add private interface to ignore a buffer that's locking a client_buffer
for damage tracking. This should eventually be replaced by wlr_raster.
2022-11-11 00:08:04 +00:00
Kirill Primak 4152db92ef damage-ring: add missing headers 2022-11-08 17:10:56 +00:00
Kirill Primak acd5a64fd1 xdg-shell: use role object destroy handler 2022-11-06 17:00:00 +03:00
Kirill Primak 92fbfda2ca drag-icon: use role object destroy handler 2022-11-06 17:00:00 +03:00
Kirill Primak 75af6a0a39 input-method: use role object destroy handler 2022-11-06 17:00:00 +03:00
Kirill Primak bcf6b2bbf8 session-lock: use role object destroy handler 2022-11-06 17:00:00 +03:00
Kirill Primak 2518ace573 subcompositor: use role object destroy handler 2022-11-06 17:00:00 +03:00
Kirill Primak 3da2cf3eb3 layer-shell: use role object destroy handler 2022-11-06 17:00:00 +03:00
Kirill Primak 756260ac05 compositor: introduce wlr_surface_destroy_role_object() 2022-11-06 14:16:05 +03:00
Kirill Primak 1243a855d4 xdg-shell: fix geometry types 2022-11-05 18:30:09 +00:00
Isaac Freund a773231c42 wlr-output-management: implement adaptive sync
Version 4 of the protocol adds support for reporting/setting adaptive
sync state of outputs. Implement these new requests/events in wlroots.
2022-10-24 16:19:25 +00:00
Simon Ser ccf4e04036 output: clarify custom modes warning
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3514
2022-10-20 10:43:50 +00:00
Simon Ser 3a949ea8eb idle-notify-v1: new protocol implementation
References: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/29
2022-10-14 13:36:15 +00:00
Kirill Primak a049d66dd7 xdg-toplevel: send invalid_parent error 2022-10-14 10:57:49 +00:00
Simon Ser 5c382f6344 drm-lease-v1: fix error codepath
We were crashing in the error codepath [1] when
wlr_drm_create_lease() fails.

To fix this, delay the creation of the wlr_drm_lease_v1 until the
request is granted. Previously we were allocating that struct early
without populating the drm_lease field. However that means we ended
up with a half-constructed struct in the error codepath which is
annoying to handle.

[1]: https://github.com/swaywm/sway/issues/7204#issuecomment-1269797356
2022-10-07 19:49:28 +00:00
Kirill Primak 46a686ce6b output-damage: drop unused pending_attach_render 2022-10-07 18:09:26 +03:00
Kirill Primak dd0665d822 output-damage: drop precommit listener 2022-10-07 17:43:50 +03:00
Consolatis e22aa2796c screencopy-v1: make sure wlr_buffer enum is visible
.. by including wlr_buffer.h
2022-10-01 18:53:36 +00:00
Simon Ser a0345f2854 output: add wlr_output_state.allow_artifacts
When starting up, the compositor might call wlr_output_set_mode()
with a mode which is already the current one. wlroots will detect
this and make the wlr_output_set_mode() call a no-op. During the
next wlr_output_commit() call, wlroots will perform an atomic
commit without the ALLOW_MODESET flag.

This is an issue, because some drivers need ALLOW_MODESET even if
the mode is the same. For instance, if the FB stride or modifier
changed, some drivers require a modeset.

Add a new flag "allow_artifacts" which is set when the compositor
calls mode-setting functions. Use this flag to figure out whether
we want to perform atomic commits with ALLOW_MODESET.

(The name "allow_artifacts" is picked because ALLOW_MODESET is a
misnomer, see [1].)

[1]: https://patchwork.freedesktop.org/patch/505107/

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3499
2022-09-30 10:58:17 +00:00
Simon Ser c153ae3c5d screencopy-v1: use wlr_buffer APIs
Instead of using low-level wl_shm_buffer and wlr_dmabuf_v1_buffer
APIs, use the unified wlr_buffer APIs. That way it doesn't matter
what the exact wlr_buffer implementation is used, any which provides
the necessary capabilities (data_ptr or dmabuf) would work.

Simplifies the logic a bit, and will make the transition to wlr_shm
easier.
2022-09-22 18:01:52 +00:00
Simon Ser f03da48491 screencopy-v1: rename wlr_screencopy_frame_v1.stride
Make it clear it's only about shm, not about DMA-BUFs.
2022-09-22 18:01:52 +00:00
Simon Ser 77b829e15f screencopy-v1: use DRM format code for shm buffers
Will allow us to simplify common shm/DMA-BUF logic later on.
2022-09-22 18:01:52 +00:00
Simon Ser 4885c08f38 screencopy-v1: rename wlr_screencopy_frame_v1.{format,fourcc}
Make it clear that one is for shm buffers only, and the other is
for DMA-BUF buffers only.
2022-09-22 18:01:52 +00:00
Simon Ser 2178573b0a output: add wlr_output_mode.picture_aspect_ratio
CTA-861-H defines a picture aspect ratio which may be attached to
each mode. This affects the way the sink will display the image.
See annexes H.1 and H.2 for examples.
2022-09-22 09:36:59 +02:00
Simon Ser 1465d238a4 single-pixel-buffer-v1: fix header guard name
Be consistent with other headers.
2022-09-17 09:18:11 +02:00
Kirill Primak 4cc3abb966 xdg-foreign-v2: s/unmap/destroy
Same as the previous commit.
2022-09-11 09:20:08 +03:00
Kirill Primak ba7bbab3ab xdg-foreign-v1: s/unmap/destroy
dac040f87f mistakenly renamed
xdg_surface_destroy listener, which was listening to *unmap* events, to
xdg_surface_unmap. The actual fix, however, is to listen to destroy
events. This fixes various crashes.
2022-09-11 09:20:08 +03:00
Simon Ser f8ae564906 compositor: fix wlr_surface_set_role return value docs
It returns a bool, not an int.
2022-09-05 15:34:19 +02:00
Isaac Freund fd0b0276c9 output: remove unknown adaptive sync state
This was previously used by the X11 backend but is no longer required
since the previous commit.
2022-08-30 17:53:50 +00:00
Simon Ser 8c70245d5f output: fail commits if adaptive sync cannot be enabled
Previously, adaptive sync was just a hint and wouldn't make any
atomic commit fail if the backend didn't support it. The main reason
is wlr_output_test wasn't supported at the time.

Now that we have a way for compositors to test whether a change can
work, let's remove the exception for adaptive sync and convert it to
a regular output state field.
2022-08-30 17:53:50 +00:00
Kenny Levinsen 7c575922c0 wlr_scene: Convert render_list to wl_array
This simplifies some of the growth logic, but uses array_realloc to shrink the
array if needed.
2022-08-19 19:38:33 +02:00
Alexander Orzechowski 59675347e6 wlr_scene: Remove unused typedef 2022-08-14 02:38:51 -04:00
Alexander Orzechowski 919e67da7d wlr_scene: Account for occlusion by other scene nodes when calculating visibility 2022-08-14 02:38:51 -04:00
Alexander Orzechowski 18417026be wlr_scene: Introduce buffer opaque region metadata 2022-08-14 02:38:50 -04:00
Alexander Orzechowski 0a9a941ba3 wlr_scene: Rewrite direct scan out logic to rely on visibility
Also make the regular rendering logic use the introduced
render list.
2022-08-14 02:38:50 -04:00
Alexander Orzechowski 028606512d wlr_scene: Add per scene node visibility 2022-08-14 01:39:20 -04:00
Simon Ser 42d68d7532 surface: add WLR_SURFACE_STATE_OFFSET
This indicates whether the surface offset has changed.
2022-08-12 11:20:44 +02:00
Simon Ser 98cf38601f render: replace wlr_texture_write_pixels with update_from_buffer
This lets the renderer handle the wlr_buffer directly, just like it
does in texture_from_buffer. This also allows the renderer to batch
the rectangle updates, and update more than the damage region if
desirable (e.g. too many rects), so can be more efficient.
2022-08-12 08:41:32 +00:00
Alexander Orzechowski f72aeacd6e wlr_scene: Add option to disable direct scanout
Closes: #3405
Supersedes: !3562

Co-authored-by: Xiao YaoBing <xiaoyaobing@qq.com>
2022-08-08 00:40:21 -04:00
Simon Ser b24b50ec0c single-pixel-buffer-v1: new protocol implementation
This implements the single-pixel-buffer-v1 protocol [1], to allow clients
to create 1x1 buffers with a single color.

[1]: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/104
2022-08-03 10:35:23 +00:00
Simon Ser f1e05a6493 xdg-shell: add support for v5
This version adds a wm_capabilities event.
2022-08-01 18:50:16 +02:00
José Expósito add44b3e2e seat: support low-resolution clients
When the client doesn't support high-resolution scroll, accumulate
deltas until we can notify a discrete event.

Some mice have a free spinning wheel, making possible to lock the wheel
when the accumulator value is not 0. To avoid synchronization issues
between the mouse wheel and the accumulators, store the last delta and
when the scroll direction changes, reset the accumulator.
2022-07-11 11:01:35 +02:00
José Expósito 65c436407f pointer: transform low-res to high-res axis events
Currently, the "wlr_event_pointer_axis" event stores low-resolution
values in its "delta_discrete" field. Low-resolution values are always
multiples of one, i.e., 1 for one wheel detent, 2 for two wheel
detents, etc.

In order to simplify internal handling of events, always transform in
the backend from the low-resolution value into the high-resolution
value.

The transformation is performed by multiplying by 120. The 120 magic
number is used by the kernel and it is exposed to clients in the
"WLR_POINTER_AXIS_DISCRETE_STEP" constant.
2022-07-11 11:01:35 +02:00
Alexander Orzechowski 5dc1d4671d wlr_scene: Maintain damage highlight regions per output
The logic doesn't support handling multiple outputs so let's not break
the assumption and handle damages per output much like how damage_ring
is done.
2022-07-03 12:21:52 -04:00
Isaac Freund ffb53a6103
Document NULL return value of foo_from_wlr_surface() functions
wlr_xdg_surface_from_wlr_surface() for example may return NULL even if
the surface has the xdg surface role if the corresponding xdg surface
has been destroyed.
2022-07-02 13:28:02 +02:00
Kirill Primak 694b8c6683 scene: add missing output damage listener
This is necessary to handle damage coming from the backend and software
cursors.
2022-06-29 21:19:38 +03:00
Kirill Primak 97f0347780 scene: switch to wlr_damage_ring 2022-06-29 18:54:27 +03:00
Kirill Primak e0accb2d50 types: add wlr_damage_ring
wlr_damage_ring is effectively wlr_output_damage untied from wlr_output.
2022-06-29 18:54:21 +03:00
Kenny Levinsen 03dc7e2df5 wlr_{keyboard,pointer,touch}: Update event docs
Events used by our input devices were recently renamed from wlr_event_* to
wlr_*_event, but the documentation and a single point of use was not updated
accordingly.

Regressed by: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3484
2022-06-28 09:50:30 +00:00
Isaac Freund 91943a68a6 wlr_input_device: remove anon union field
This union is unnecessary since the recent input device refactor and can
now be replaced by wlr_*_from_input_device() functions.
2022-06-21 18:42:07 +00:00
Kirill Primak 5c4384a133 xdg-popup: use configure fields 2022-06-21 15:14:37 +00:00
Simon Ser d89285f783 output-management-v1: add wlr_output_head_v1_state_apply()
This function applies a configuration sent by a client on a
struct wlr_output_state.
2022-06-17 21:05:51 +00:00
Simon Ser 29291cb47c render/texture: drop wlr_texture_is_opaque
Whether a texture is opaque or not doesn't depend on the renderer
at all, it just depends on the source buffer. Instead of forcing
all renderers to implement wlr_texture_impl.is_opaque, let's move
this in common code and use the wlr_buffer format to know whether
a texture will be opaque.
2022-06-16 14:43:24 +02:00
Simon Ser 96b594110d matrix: remove wlr_matrix_projection()
69477051cc ("matrix: deprecate wlr_matrix_projection") marked it
as deprecated. 1 year later, we can now remove it from our public
API.
2022-06-08 19:27:36 +00:00
Simon Ser 6688a3d9ea output: add output state setters
This ensures compositors don't forget to set the committed flag
or the mode_type when setting a field.
2022-06-08 18:22:32 +02:00
Simon Ser e383c1f1db xdg-shell: add support for v4
This adds a configure_bounds event to let the client know of the
preferred maximum window geometry size.
2022-06-01 18:18:54 +02:00
Kirill Primak 0c2eed533e scene/output-layout: improve ownership logic
This commit ensures that outputs that weren't created by the output
layout helper aren't destroyed on the output layout change.

Consider the following piece of logic:

// struct wlr_output *o1, *o2;
// struct wlr_scene *scene;
// struct wlr_output_layout *layout;
wlr_scene_attach_output_layout(scene, layout);
wlr_output_layout_add_auto(layout, o1);
struct wlr_scene_output *so2 = wlr_scene_output_create(scene, o2);
wlr_output_layout_move(layout, o1, 100, 200);
// so2 is invalid now
2022-06-01 09:49:25 +00:00
Kirill Primak d3bc17d5d1 scene: add wlr_scene_output.events.destroy 2022-06-01 09:49:25 +00:00
Kirill Primak ec328ca8cc scene/wlr_scene.h: fix indentation 2022-05-31 20:34:50 +03:00
Simon Ser 638c5cda51 output: drop wlr_output_cursor.events.destroy
Compositors can just listen to wlr_output.events.destroy instead.
2022-05-31 11:40:47 +00:00
Simon Ser 459a642e83 output: introduce wlr_output_cursor_set_buffer
This will supersede wlr_output_cursor_set_image, and then later
also supersede wlr_output_cursor_set_surface.
2022-05-31 11:40:47 +00:00
Alexander Orzechowski 71f8a48d38 wlr_scene: Move children list from wlr_scene_node to wlr_scene_tree 2022-05-31 09:14:28 +00:00
Alexander Orzechowski cb2dbc327e wlr_scene: Inline wlr_scene_node_state
This seems like nothing interesting was done with this. Let's simplify
and allow us some flexibility in the future.
2022-05-31 09:14:28 +00:00
Alexander Orzechowski ccd0f85c2a wlr_scene: Only allow parenting on a wlr_scene_tree 2022-05-31 09:14:28 +00:00
Alexander Orzechowski 9eb71146ae wlr_scene: Refactor wlr_scene (the root element) to encase a wlr_scene_tree
Co-authored-by: Isaac Freund <mail@isaacfreund.com>
2022-05-31 09:14:28 +00:00
Simon Ser d483dd2f4c output: add wlr_output_commit_state
Same as wlr_output_commit, but takes a wlr_output_state.
2022-05-30 11:40:34 +02:00
Simon Ser b21c26a1c9 output: add wlr_output_event_precommit.state 2022-05-30 11:34:57 +02:00
Simon Ser c4253fef9c output: add wlr_output_test_state
Same as wlr_output_test, but takes a wlr_output_state argument.
2022-05-30 11:34:57 +02:00
Kirill Primak 1761c3bbe2 xdg-popup: add reposition support 2022-05-27 13:31:30 +00:00
Kirill Primak 8a0835c59c xdg-positioner: add v3 parameters 2022-05-27 13:31:30 +00:00
Kirill Primak 6f1fce9cb4 xdg-popup: use current/pending state pattern 2022-05-27 13:31:30 +00:00
Kirill Primak 4a968576e4 xdg-popup: add proper configure flow 2022-05-27 13:31:30 +00:00
Simon Ser be86145322 output: turn make/model/serial into char *
This allows the make/model/serial to be NULL when unset, and allows
them to be longer than the hardcoded array length.

This is a breaking change: compositors need to handle the new NULL
case, and we stop setting make/model to useless "headless" or
"wayland" strings.
2022-05-26 13:36:06 +00:00
Simon Ser 28d89779af Reformat doc comments
Unify the way we document our APIs. See CONTRIBUTING.md for the
rules.
2022-05-25 14:22:58 +00:00
Alexander Orzechowski 41124592dd wlr_scene: Hook up HIGHLIGHT logic
This will display red translucent rectangles on the screen regions that
have been damaged. These rectangles will fade out over the span of 250
msecs. If the area is damaged again while the region is fading out,
the timer is reset.

Let's also disable direct scan out when this option is enabled, or else
we won't be able to render the highlight damage regions.
2022-05-23 15:58:49 -04:00
Alexander Orzechowski 17f5414b1a wlr_scene: Parse out WLR_SCENE_DEBUG_DAMAGE 2022-05-23 15:43:18 -04:00
Guido Günther 17b2b06633 seat: Allow to cancel touches
After cancelation we destroy the touch points associated with this
surface as the Wayland spec says:

No further events are sent to the clients from that particular gesture.
Touch cancellation applies to all touch points currently active on this
client's surface. The client is responsible for finalizing the touch
points, future touch points on this surface may re-use the touch point
ID.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/2999
2022-05-22 09:43:33 +00:00
Alexander Orzechowski dc9bc5683a wlr_scene: Refactor wlr_scene_surface to be a helper on top of wlr_scene_buffer 2022-05-19 14:26:50 -04:00
Alexander Orzechowski 5f43e1732a wlr_scene: Introduce addons to scene nodes 2022-05-19 14:25:34 -04:00
Alexander Orzechowski f2dbcc3358 wlr_scene: Make presentation object public 2022-05-19 14:24:05 -04:00
Alexander Orzechowski 20cc1ce0b9 wlr_scene: Change out surface specific iterator functions
Instead iterate over wlr_scene_buffer
2022-05-19 14:24:05 -04:00
Alexander Orzechowski 39c059b70e wlr_scene: Make scene_buffer_from_node public 2022-05-19 14:24:05 -04:00
Alexander Orzechowski 73a656e8ac wlr_scene: Add a function to also specify damage when applying a buffer to wlr_scene_buffer 2022-05-19 14:24:05 -04:00
Alexander Orzechowski 34be5da072 wlr_scene: Add a way to choose when input interactions happen on a buffer 2022-05-19 14:24:05 -04:00
Alexander Orzechowski 09c7fe0f90 wlr_scene: Add frame_done signal for wlr_scene_buffer
Let's also change the name of the function. Motivation [1].

[1] https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3496#note_1357824
2022-05-19 14:23:10 -04:00
Alexander Orzechowski a53eccf2af wlr_scene: Add primary_output property to wlr_scene_buffer 2022-05-19 14:21:22 -04:00
Alexander Orzechowski dfeb1309a8 wlr_scene: Add presentation signal for wlr_scene_buffer 2022-05-19 14:21:21 -04:00
Alexander Orzechowski 7e383c6a6a wlr_scene: Make wlr_scene_render_output private
This function sidesteps damage tracking and output awareness on
buffers/surfaces. This function isn't a great fit for the API.

Let's also inline the function and simplify it.
2022-05-19 14:17:51 -04:00
Alexander Orzechowski 933ff0e60c wlr_scene: Fix missing calls to scene_node_update_outputs
There were a couple places this was missing
 - on mode change of an output. If the resolution changes for example
   nodes may fall out of the view.
 - on commits on an output for scale or transform changes
 - when the transform of a buffer is changed. If the dest size is not
 set, the buffer may have been rotated potentially changing its size
 if the buffer width != height
2022-05-19 14:17:51 -04:00
Alexander Orzechowski c46b53d0b0 wlr_scene: Add output_enter/output_leave signals
When we destroy a scene buffer, let's make sure that we call
output_leave signals before we finish the node which will call destroy
listeners.
2022-05-19 14:17:51 -04:00
Alexander Orzechowski 61dab42c70 wlr_scene: Add setter for buffer of a wlr_scene_buffer 2022-05-19 14:17:51 -04:00
Alexander Orzechowski 039a31df9a wlr_scene: Allow buffer in wlr_scene_buffer to be NULL
This is useful to emulate an unmapped surface.
2022-05-19 14:16:52 -04:00
Simon Ser 8fe3aa29da xdg-shell: specify version in wlr_xdg_shell_create
With protocol additions such as [1], compositors currently have no
way to opt out of the version upgrade. The protocol upgrade will
always be backwards-compatible but may require new compositor
features.

The status quo doesn't make it possible to ship a protocol addition
without breaking the wlroots API. This will be an issue for API
stabilization [2].

To address this, let compositors provide a maximum version in the
function creating the global. We need to support all previous versions
of the interface anyways because of older clients.

This mechanism works the same way as Wayland clients passing a version
in wl_global.bind.

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3514
[2]: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/1008

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3397
2022-05-15 15:44:40 +00:00
Kirill Primak dec2565f2b xdg-toplevel: don't schedule configures on state requests 2022-04-13 17:00:06 +00:00
Kirill Primak 04aa44b4df xdg-foreign-v2: treat unmapped parents as NULL 2022-04-13 16:48:15 +00:00
Kirill Primak dac040f87f xdg-foreign-v1: treat unmapped parents as NULL 2022-04-13 16:48:15 +00:00
Leonardo Hernández Hernández 4519117a68 seat: take wlr_keyboard in wlr_seat_set_keyboard()
Signed-off-by: Leonardo Hernández Hernández <leohdz172@protonmail.com>
2022-03-23 13:08:41 +00:00
Guido Günther 4cc2a03620 layer-shell: Make wlr_layer_surface_v1_from_resource public
This allows compositors to leverage the `wl_instance_of` based type
check.
2022-03-23 09:19:43 +00:00
Simon Zeni aaf787ee56 types/wlr_touch: uniformize events name 2022-03-17 18:16:14 +00:00
Simon Zeni e732c5c895 types/wlr_tablet_tool: uniformize events name 2022-03-17 18:16:14 +00:00
Simon Zeni d1f543a9d8 types/wlr_tablet_pad: uniformize events name 2022-03-17 18:16:14 +00:00
Simon Zeni 13d7fa2f03 types/wlr_switch: uniformize events name 2022-03-17 18:16:14 +00:00
Simon Zeni 9a17200446 types/wlr_keyboard: uniformize events name 2022-03-17 18:16:14 +00:00
Simon Zeni bd6c000d14 types/wlr_pointer: uniformize events name 2022-03-17 18:16:14 +00:00
Simon Zeni 96ccc50c57 types/wlr_input_device: move width_mm and height_mm fields to wlr_tablet and wlr_touch 2022-03-17 13:44:19 -04:00
Simon Zeni a92e5f8d46 types/wlr_input_device: move output_name field to wlr_pointer and wlr_touch 2022-03-17 13:44:18 -04:00
Alexander Orzechowski 74381f3bc3 types/wlr_output: Handle subpixel hints through output commits 2022-03-16 18:41:49 +00:00
Simon Ser 68f2f8cf92 Revert "scene: try to import buffers as textures before rendering"
This reverts commit 3db1bcbe64.

Since [1], importing buffers as textures before wlr_renderer_begin isn't
necessary anymore.

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3464
2022-03-16 16:42:45 +00:00
Simon Zeni 4c8ecfcd4a types/wlr_virtual_pointer_v1: remove destroy event
The destroy event from the pointer base wlr_input_device must be used
2022-03-11 20:02:21 +00:00
Simon Zeni 45c8771735 types/wlr_virtual_keyboard_v1: remove destroy event
The destroy event from the keyboard base wlr_input_device must be used
2022-03-11 20:02:21 +00:00
Simon Zeni eae8952e17 types/wlr_keyboard: remove destroy event
The destroy event from the base wlr_input_device must be used
2022-03-11 20:02:21 +00:00
David96 7a2c96dcbd types/wlr_tablet_tool: remove name ambiguity
It wasn't clear in the backend whether to use name or base.name, change
it so base.name has to be used.

Fixes https://github.com/swaywm/sway/issues/6884
2022-03-11 11:49:41 +01:00
Isaac Freund 4792446ee8 wlr_switch: remove WLR_SWITCH_STATE_TOGGLE
This was originally added in 810c7b7 for use in rootston's input config
handling. It has never actually been part of the wlroots API and
shouldn't exist.
2022-03-08 13:45:10 +00:00
Simon Zeni cfed039c9a types/wlr_input_device: move init and finish function to private API 2022-03-07 16:37:41 +00:00
Simon Zeni 1bb2631c5c types/wlr_input_device: remove wlr_input_device_destroy 2022-03-07 16:37:41 +00:00
Simon Ser 39b68ea47a buffer: extract interface to separate header
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3389
2022-03-03 15:39:05 +01:00
Simon Zeni e279266f71 interfaces: remove wlr_input_device_impl 2022-02-22 14:23:46 -05:00
Simon Zeni 1acc931cf0 types/wlr_switch: constify impl 2022-02-21 13:53:40 -05:00
Simon Zeni f1181c34ed types/wlr_tablet_pad: constify impl 2022-02-21 13:53:40 -05:00
Kirill Primak 511f137f8f xdg-positioner: rewrite unconstraining, untie from xdg-popup 2022-02-21 17:26:51 +00:00
Kirill Primak 5879e77d68 xdg-positioner: rename structs
To be consistent with other wlr_xdg_* structs,
wlr_xdg_positioner_resource is renamed to wlr_xdg_positioner and made
public, and wlr_xdg_positioner is renamed to wlr_xdg_positioner_rules.
Functions which operated on wlr_xdg_positioner were renamed and updated
accordingly.
2022-02-21 17:26:51 +00:00
Simon Zeni edfb332b24 types/wlr_touch: add base wlr_input_device
wlr_touch now owns its wlr_input_device. It will be initialized when the
tablet tool is initialized, and finished when the touch is destroyed.
2022-02-21 17:11:32 +00:00
Simon Zeni 7dfee50350 types/wlr_tablet_tool: add base wlr_input_device
wlr_tablet_tool owns its wlr_input_device. It will be initialized when the
tablet tool is initialized, and finished when the tablet tool is destroyed.
2022-02-21 17:11:32 +00:00
Simon Zeni a662743610 types/wlr_tablet_pad: add base wlr_input_device
wlr_tablet_pad owns its wlr_input_device. It will be initialized when the
tablet pad is initialized, and finished when the tablet pad is destroyed.
2022-02-21 17:11:32 +00:00
Simon Zeni 0f3b38365d types/wlr_switch: add base wlr_input_device
wlr_switch owns its wlr_input_device. It will be initialized when the
switch is initialized, and finished when the switch is destroyed.
2022-02-21 17:11:32 +00:00
Simon Zeni d5480efc7a types/wlr_pointer: add base wlr_input_device
wlr_pointer owns its wlr_input_device. It will be initialized when the
pointer is initialized, and finished when the pointer is destroyed.
2022-02-21 17:11:32 +00:00
Simon Zeni a1978b1299 types/wlr_keyboard: add base wlr_input_device
wlr_keyboard owns its base wlr_input_device. It will be initialized when the
keyboard is initialized, and finished when the keyboard is destroyed.
2022-02-21 17:11:32 +00:00
Isaac Freund 252b2348bd
wlr_cursor: constify map to region box arguments 2022-02-05 16:32:38 +01:00
Kirill Primak 6ed3b02775 xdg-toplevel: fix `requested` doc
`requested` is also checked on state change requests.
2022-02-02 21:06:12 +03:00
Kirill Primak 34a71eae31 xdg-shell: drop wlr_xdg_toplevel_set_fullscreen_event
Instead, compositors can read relevant values from
wlr_xdg_toplevel.requested.
2022-02-02 21:06:12 +03:00
Kirill Primak e59aa3e0e7 xdg-toplevel: change object type in event structs
This commit replaces wlr_xdg_toplevel_*_event::surface with a toplevel
field.
2022-02-02 21:06:12 +03:00
Kirill Primak 1e4c1a3b58 xdg-toplevel: change parent type to xdg-toplevel
This commit changes wlr_xdg_toplevel::parent type from wlr_xdg_surface
to wlr_xdg_toplevel.
2022-02-02 21:06:12 +03:00
Kirill Primak 70d4a30be3 xdg-shell: remove "xdg" from docs 2022-02-02 21:06:12 +03:00
Kirill Primak 41412cadbe xdg-popup: fix functions' main argument type
With this commit, `wlr_xdg_popup_*()` functions now expect
a `wlr_xdg_popup` instead of a `wlr_xdg_surface`.
2022-02-02 21:06:12 +03:00
Kirill Primak affe0d8713 xdg-toplevel: fix functions' main argument type
With this commit, `wlr_xdg_toplevel_*()` functions now expect
a `wlr_xdg_toplevel` instead of a `wlr_xdg_surface`.
2022-02-02 21:06:11 +03:00
Isaac Freund 9de992b9fe
ext-session-lock-v1: new protocol implementation
This implements the new ext-session-lock-v1 protocol [1].

[1]: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/131
2022-02-02 15:22:02 +01:00
Kenny Levinsen 1e3662ce57 scene: Add layer_shell_v1 helper
This helper behaves similar to the xdg_shell helper, and additionally
provides a little assistance for positioning and exclusive_zone
management.
2022-02-01 13:31:26 +01:00
Simon Ser 3db1bcbe64 scene: try to import buffers as textures before rendering
The wlroots APIs currently don't allow importing/uploading a buffer
during rendering operations. Scene-graph buffer nodes need to turn
their wlr_buffer into a wlr_texture at some point. It's not always
possible to do so at wlr_scene_buffer creation time because the
scene-graph may have zero outputs at this point, thus no way to
grab a wlr_renderer.

Instead, add scene-graph buffers to a pending list and try to import
them in wlr_scene_output_commit.

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3354
2022-02-01 10:01:09 +00:00
Kirill Primak 49fa060442 output-layout: remove useless types/fields 2022-01-31 10:32:47 +00:00
Kirill Primak 498f30aad1 output-layout: make wlr_output_layout_get_box() take a box as parameter
Closes https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/812
2022-01-31 10:32:47 +00:00
Isaac Freund 1bd0ea3a80
foreign-toplevel: send enter if needed on output bind
Currently the output enter event is never sent if the client has not
yet bound the output, which happens every time the compositor creates a
new output.

To fix this, listen for the output bind event and inform clients as
if needed.
2022-01-17 19:11:08 +01:00
Kirill Primak 50827ed7f5 surface: improve role precommit hook
Now the role precommit hook is called before the commit, not on
wl_surface.commit request, and takes a state which is to be applied.
2022-01-13 15:15:54 +03:00
Kirill Primak 617eb4fb93 surface: deprecate wlr_surface.h 2022-01-13 10:06:41 +00:00
Kirill Primak e94e16ba5d surface: move decl to wlr_{sub,}compositor.h 2022-01-13 10:06:41 +00:00
Kirill Primak 4ec683ad1c surface: introduce events.client_commit
wlr_surface.events.client_commit is fired when wl_surface.commit
request is received.
2022-01-13 10:06:41 +00:00
Kirill Primak b6f43ab2e1 subcompositor: split out from compositor 2022-01-13 10:06:41 +00:00
Simon Ser 93e050c602 Remove wlr_box.h redirection
Compositors should've all been updated to use the new header by now.
2021-12-17 15:38:03 +01:00
Isaac Freund 92d137c78a layer-shell: fix type of margins
These currently use uint32_t while they are an int32_t in the protocol.
2021-12-17 10:57:21 +00:00
Isaac Freund 07ccc6e0b3
scene: add wlr_scene_set_presentation()
This helper automates sending presentation feedback to clients based on
the primary output of scene surfaces.
2021-12-14 21:34:02 +01:00
Guido Günther 4c59f7d46a xdg-activation: Allow to submit tokens
Allows the compositor to submit tokens to the pool of
currently active tokens. This can be useful when the
launcher doesn't use or support xdg-activation-v1 by
itself - e.g. when it is X11 based or use gtk_shell1.
2021-12-14 12:01:46 +01:00
Isaac Freund 1c3e0816f3
scene: fix wlr_scene_send_frame_done() API
This doesn't work if scene outputs are not used as the primary output of
scene surfaces will always be NULL.

Therefore, take a wlr_scene_output instead of separate wlr_scene and
wlr_output arguments and rename the function to
wlr_scene_output_send_frame_done().

The actual behavior of the function is unchanged.
2021-12-13 17:26:22 +01:00
Isaac Freund fecde72be3 scene: add wlr_scene_send_frame_done() 2021-12-13 15:21:05 +00:00
Isaac Freund fb1f613510 scene: add primary output to wlr_scene_surface
This allows compositors to avoid sending multiple frame done events
to a surface that is rendered on multiple outputs at once. This may
also be used in the same way for presentation feedback.
2021-12-13 15:21:05 +00:00
Isaac Freund 0215dffba5 scene: send surface enter/leave output events
Co-authored-by: Simon Ser <contact@emersion.fr>
2021-12-13 15:21:05 +00:00
Kirill Primak 0fcc842291 subsurface: don't add to parent list immediately 2021-12-09 18:26:56 +00:00
Kirill Primak 7964bdae76 surface: fix non-buffer damage handling
This commit fixes the way the damage that doesn't come directly from the
client is handled.
2021-12-09 18:26:56 +00:00
Simon Ser 36a2b19485 output: introduce wlr_output_set_name
wlroots picks names for all outputs, but it might be desirable for
compositor to override it.

For instance, Sway will use a headless output as a fallback in
case no outputs are connected. Sway wants to clearly label the
fallback output as such and label "real" headless outputs starting
from HEADLESS-1.
2021-12-09 15:46:46 +01:00
Simon Ser c50c4fc5cc linux-dmabuf-v1: add per-surface feedback 2021-12-07 15:18:19 +01:00
Simon Ser 1d8340754b linux-dmabuf-v1: implement v4
Implement a basic version of linux-dmabuf-unstable-v1 version 4.
Only default hints are implemented.

The new wlr_linux_dmabuf_feedback_v1 data structure will allow
compositors to define their own custom hints in the future. This
data structure makes it easy to describe feedback metadata.

It's converted to a "compiled" form suitable for marshalling over
the Wayland socket via feedback_compile.
2021-12-07 15:18:16 +01:00
Simon Ser efeb8346cf output: drop front_buffer
This lets backends immediately release committed buffers if they
want to.
2021-12-03 14:56:17 +00:00
Simon Ser f016eca97c output: add wlr_output_event_commit.buffer
This allows output commit listeners to access the newly committed
buffer. Currently wlr_output.front_buffer is used but it'll get
removed in the next commit.
2021-12-03 14:56:17 +00:00
Simon Ser ba974a4e9f scene: add wlr_scene_get_scene_output
This allows getting a wlr_scene_output from a wlr_output. Since an
output can only be added once to a scene-graph there's no ambiguity.

This is useful for compositors using wlr_scene_attach_output_layout:
the output layout integration automatically creates a scene-graph
output for each wlr_output added to the layout.
2021-11-30 20:16:24 +00:00
Simon Ser 697a1cd0f5 output: add wlr_output_get_primary_formats
This allows compositors to get primary formats without manually
calling wlr_output_impl.get_primary_formats.

For example, the Sway patch for linux-dmabuf feedback [1] needs
this.

[1]: https://github.com/swaywm/sway/pull/6313
2021-11-30 20:49:33 +01:00
Simon Ser 585a908a01 scene: add wlr_scene_xdg_surface_create
This allows compositors to easily add an xdg_surface to the
scene-graph while retaining the ability to unconstraint popups
and decide their final position.

Compositors can handle new popups with the wlr_xdg_shell.new_surface
event, get the parent scene-graph node via wlr_xdg_popup.parent.data,
create a new scene-graph node via wlr_scene_xdg_surface_tree_create,
and unconstraint the popup if they want to.
2021-11-25 18:53:12 +01:00
Simon Ser 1d9c1bcea6 input-device: remove wlr_input_device.link
This field's ownership is unclear: it's in wlr_input_device, but
it's not managed by the common code, it's up to each individual
backend to use it and clean it up.

Since this is a backend implementation detail, move it to the
backend-specific structs.
2021-11-23 14:14:18 +00:00
Simon Ser 3d73b899ff linux-dmabuf-v1: hide wlr_linux_buffer_params_v1
The parameters are used when the client is in the process of
building a buffer. There's no reason why this internal
implementation detail should be exposed in our public header.
2021-11-22 10:32:55 +01:00
Simon Ser 6bb8973309 drm-lease-v1: listen to lease destroy event 2021-11-19 16:06:07 +00:00
Simon Ser 86f5ecf468 backend/drm: introduce wlr_drm_lease
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3183
2021-11-19 16:06:07 +00:00
Manuel Stoeckl e879d566bb output: Add function to set preferred render format
This change introduces new double buffered state to the wlr_output,
corresponding to the buffer format to render to.

The format being rendered to does not control the bit depth of colors
being sent to the display; it does generally determine the format with
which screenshot data is provided. The DRM backend _may_ sent higher
bit depths if the render format depth is increased, but hardware and
other limitations may apply.
2021-11-19 15:51:46 +00:00
Simon Ser 142d10e591 output: add wlr_output_init_render
Co-authored-by: Simon Zeni <simon@bl4ckb0ne.ca>
2021-11-18 09:37:32 -05:00
Isaac Freund ab16861e86 text-input: fix type of send_preedit_string() args
The protocol uses a signed integer here, which is also what the
wlr_input_method_v2_preedit_string struct provides to compositors from
the input method protocol. Sway currently just passes those int32_t
values directly to this function leading to an implicit conversion.
2021-11-08 19:56:22 +00:00
Simon Ser 76bab68e70 output: drop wlr_output_export_dmabuf
Callers can access output->front_buffer instead.
2021-11-08 15:57:19 +00:00
Ronan Pigott e2aff8a9b0 xdg-activation-v1: add data field and emit token destroy events
The data field is useful to track metadata about a token. The destroy
events are useful for compositors that track application startup to
let them know they can stop doing that.
2021-10-31 10:33:14 +01:00
Ronan Pigott 6ad0f819e2 xdg-activation-v1: enable compositors to request their own tokens
These new functions allow a compositor to request new managed tokens
without participating in the xdg-activation procedure as a wayland
client.

This enables the compositor itself to behave as a launcher
application.
2021-10-31 10:33:14 +01:00
Simon Ser a4ccca0834 scene: add support for direct scan-out
Check if only a single node intersects with the output viewport
and all of its properties match. In this case, attempt direct
scan-out.
2021-10-23 00:49:07 +02:00
Simon Ser db4c93028d scene: add wlr_scene_output_for_each_surface
This allows compositors to more easily implement sending
wl_surface.frame callback done events.
2021-10-22 22:29:35 +02:00
Simon Ser 7c10a77e0a presentation-time: remove unused field 2021-10-22 06:44:39 -06:00
Kirill Primak 6c3a71d9f6 presentation-time: use a surface addon 2021-10-22 11:57:19 +02:00
Kirill Primak 2af8cc769a output: add presented flag to presentation event 2021-10-15 09:38:58 +02:00
Isaac Freund 4fae8f7be3 scene: add functions to place node on top/bottom
These are very common operations for compositors (including tinywl)
to perform.
2021-10-14 21:10:03 +02:00
Isaac Freund 2a8d385386 scene: assert that node != sibling in place above/below
Currently these functions remove the node from the scene if the sibling
argument is the same node as the node. To prevent confusion when
misusing this API, assert that the nodes are distinct and document this.
2021-10-14 21:10:03 +02:00
Kirill Primak c3e54021f8 xdg-decoration: refactor configure/state flow
The same logic/motivation as xdg-toplevel.
2021-10-07 07:27:51 -06:00
tiosgz ce66244fd2 surface_at: check if surfaces are mapped 2021-10-02 11:38:40 +02:00
tiosgz 893434b2d4 for_each_surface: only iterate mapped surfaces
These functions are used mostly for rendering, where including unmapped
surfaces is undesired.

This is a breaking change. However, few to no usages will have to be
updated.
2021-10-02 11:38:40 +02:00
Elyes HAOUAS dc3d1530bf Fix spelling errors
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
2021-10-02 10:22:13 +02:00
Simon Ser 665a164f27 xdg-shell: rename wlr_xdg_surface.next_configure_serial
Rename it to scheduled_serial for consistency with the rest of
wlroots.
2021-09-30 23:17:32 +03:00
Simon Ser 0e34208344 xdg-shell: introduce wlr_xdg_surface.current
This holds the current state, and avoids having ad-hoc fields in
wlr_xdg_surface.
2021-09-30 23:17:32 +03:00
Kirill Primak db4afc2408 xdg-surface: add pending state
struct wlr_xdg_surface_state is introduced to hold the geometry
and configure serial to be applied on next wl_surface.commit.

This commit fixes our handling for ack_configure: instead of making
the request mutate our current state, it mutates the pending state
only.

Co-authored-by: Simon Ser <contact@emersion.fr>
2021-09-30 23:17:32 +03:00
José Expósito 20d9448257 wlr_pointer_gestures: hold gestures (protocol v3)
Update the pointer gestures protocol to version 3 allowing to send hold
gestures to clients.
2021-09-27 15:30:31 +02:00
José Expósito 4c3e307ec8 cursor: emit hold gesture events
Recevie the hold gesture events from the libinput or Wayland backends,
abstracted as pointer signals, and re-emit them from the cursor
interface.
2021-09-27 15:30:31 +02:00
José Expósito d069a783bc pointer: add hold pointer event definition
As touchpad touches are generally fully abstracted, a client cannot
currently know when a user is interacting with the touchpad without
moving. This is solved by hold gestures.

Hold gestures are notifications about one or more fingers being held
down on the touchpad without significant movement.

Hold gestures are primarily designed for two interactions:

 - Hold to interact: where a hold gesture is active for some time a
   menu could pop up, some object could be selected, etc.
 - Hold to cancel: where e.g. kinetic scrolling is currently active,
   the start of a hold gesture can be used to stop the scroll.

Unlike swipe and pinch, hold gestures, by definition, do not have
movement, so there is no need for an "update" stage in the gesture.

Create two structs, wlr_event_pointer_hold_begin and
wlr_event_pointer_hold_end, to represent hold gesture events and the
signals to emit them: wlr_pointer->pointer.hold_begin/hold_end.
2021-09-27 15:30:31 +02:00
Kirill Primak 754f40f9cb layer-shell: add `committed` bitmask 2021-09-24 14:38:32 +02:00
Kirill Primak 59fa3637c3 layer-shell: refactor configure/state flow
Same logic as xdg-toplevel.
2021-09-23 21:22:41 +02:00
Simon Ser 3c26244340 scene: add wlr_scene_buffer_set_transform 2021-09-22 10:45:39 -06:00
Simon Ser 43833fba64 scene: add wlr_scene_buffer_set_dest_size 2021-09-22 10:45:39 -06:00
Simon Ser 63040d6744 scene: add wlr_scene_buffer_set_source_box 2021-09-22 10:45:39 -06:00
Simon Ser 7939bf8cc6 scene: add wlr_scene_buffer
This new scene-graph node displays a wlr_buffer.

Closes: https://github.com/swaywm/wlroots/issues/3161
2021-09-22 10:45:39 -06:00
Tadeo Kondrak 30d3c76817 Implement input_method_v2 popups 2021-09-22 09:42:14 +02:00
Simon Ser 2e590026e9 scene: add wlr_scene_subsurface_tree_create 2021-09-21 16:48:31 +02:00
Simon Ser 597ba2b932 surface: add addon set 2021-09-21 16:48:31 +02:00
Simon Ser 211b3b760e scene: add wlr_scene_tree 2021-09-21 16:48:31 +02:00
Kirill Primak b72a217fcc xdg-toplevel: refactor configure/state flow
Previously, `wlr_xdg_toplevel` didn't follow the usual "current state +
pending state" pattern and instead had confusingly named
`client_pending` and `server_pending`. This commit removes them, and
instead introduces `wlr_xdg_toplevel.scheduled` to store the properties
that are yet to be sent to a client, and `wlr_xdg_toplevel.requested`
to store the properties that a client has requested. They have different
types to emphasize that they aren't actual states.
2021-09-21 10:09:09 +02:00
Simon Zeni 9579d62a16 types/buffer: make {begin,end}_data_ptr_access part of the public API 2021-09-15 11:50:44 +02:00
Simon Ser 4e7a8707cc buffer: add data_ptr access flags
This allows callers to specify the operations they'll perform on
the returned data pointer. The motivations for this are:

- The upcoming Linux MAP_NOSIGBUS flag may only be usable on
  read-only mappings.
- gbm_bo_map with GBM_BO_TRANSFER_READ hurts performance.
2021-09-10 13:16:10 -04:00
Andri Yngvason 105fdecd0c screencopy: Handle shm copy in commit event handler
This simplifies the implementation considerably.
2021-09-10 10:37:18 +02:00
Simon Ser a181a37b12 scene: add wlr_scene_attach_output_layout
This is a helper to integrate wlr_scene with wlr_output_layout.
2021-09-09 12:04:35 +02:00
Simon Ser 44f0f7a0a7 scene: add damage tracking support 2021-09-08 09:50:08 -04:00
Simon Ser 9195b77e14 scene: add wlr_scene_node_coords 2021-09-08 09:50:08 -04:00
Simon Ser 04d105760d scene: add wlr_scene_output_commit 2021-09-08 09:50:08 -04:00
Simon Ser 968c1df7e9 scene: add scene outputs
These allow describing an output's viewport inside the scene-graph.
2021-09-08 09:50:08 -04:00
Simon Zeni 3984c81faa types: introduce wlr_drm_lease_v1 2021-09-08 11:09:07 +02:00
Simon Zeni e5a949a955 backend/drm: implement drm lease function 2021-09-08 11:09:07 +02:00
Simon Ser ba0525c5c0 surface: drop wlr_surface_state.buffer_resource
Instead, use wlr_surface_state.buffer only.
2021-09-06 14:21:23 -04:00
Simon Ser 0fe3b45361 viewporter: hide wlr_viewport
This is an internal struct.
2021-09-06 19:19:45 +02:00
Simon Ser 24c397dbf8 viewporter: add doc comment explaining compositor requirements 2021-09-06 19:19:45 +02:00
Simon Ser bb82b6dada buffer: make wlr_client_buffer_apply_damage return a bool
We always return the same wlr_client_buffer as the one passed in,
so no need to return anything.
2021-09-06 18:10:26 +02:00
Simon Ser cbe099dcc7 buffer: take a wlr_buffer in wlr_client_buffer_apply_damage
Instead of taking a wl_resource as argument, take a wlr_buffer.
2021-09-06 18:10:26 +02:00
Kirill Primak 90e62390d9 surface: move subsurface lists to state 2021-09-06 17:37:08 +02:00
Simon Ser 3ac99fa4dc subsurface: move parent link to state
Move the wlr_subsurface parent link to the subsurface state.

This is a dumb find/replace operation. This shouldn't result in
any behavior change.
2021-09-06 17:37:08 +02:00
Simon Ser 56b6b80b9a subsurface: rename wlr_subsurface_state to wlr_subsurface_parent_state
Add a comment to explain the difference.
2021-09-06 17:37:08 +02:00
Simon Ser 62924cc523 keyboard: add wlr_keyboard.keymap_fd
This exposes a read-only FD with the keymap.
2021-09-05 22:06:25 +02:00
Devin J. Pohly 9ed16e39fa scene: replace surface_at() with node_at()
With the addition of a non-surface node type, it was unclear how such
nodes should interact with scene_node_surface_at().  For example, if the
topmost node at the given point is a RECT, should the function treat
that node as transparent and continue searching, or as opaque and return
(probably) NULL?

Instead, replace the function with one returning a scene_node, which
will allow for more consistent behavior across different node types.
Compositors can downcast scene_surface nodes via the now-public
wlr_scene_surface_from_node() if they need access to the surface itself.
2021-09-02 19:05:02 +02:00
Devin J. Pohly b7cd06e8fa scene: add RECT node type
RECT is a solid-colored rectangle, useful for simple borders or other
decoration.  This can be rendered directly using the wlr_renderer,
without needing to create a surface.
2021-09-02 19:05:02 +02:00
Devin J. Pohly 526652a554 scene: iterate nodes instead of surfaces when rendering
This will allow us to create node types which are rendered but not
surface-based, such as a solid color or image.
2021-09-02 19:05:02 +02:00
Devin J. Pohly a1d462fa81 scene: add node reparent function
If nodes are arranged in a tree rather than at a single level, then it
makes sense that there should be a way to move them to a completely
different parent in addition to moving up or down among siblings.
2021-08-30 16:43:18 +02:00
Simon Ser e4d0ec9ee1 scene: add wlr_scene_node_surface_at 2021-08-26 21:12:28 +02:00
Simon Ser 501b29db03 scene: add user data pointer to wlr_scene_node
This allows compositors to attach arbitrary data to the scene-graph
nodes.
2021-08-26 21:12:28 +02:00
Simon Ser 86e9309808 scene: add wlr_scene_node_toggle
This allows compositors to easily enable or disable a scene-graph node.
This can be used to show/hide a surface when the xdg_surface is
mapped/unmapped.
2021-08-26 21:12:28 +02:00
Simon Ser c7d489b5b6 Introduce new scene-graph API
A new wlr_scene API has been added, following the design ideas from [1].
The new API contains the minimal set of features required to make the
API useful. The goal is to design a solid fundation and add more
features in the future.

[1]: https://github.com/swaywm/wlroots/issues/1826#issuecomment-564601757
2021-08-26 21:12:28 +02:00
Isaac Freund 3364eec07e layer-shell: replace close() with destroy()
The protocol specifies that all requests (aside from destroy) are
ignored after the compositor sends the closed event. Therefore,
destroying the wlroots object and rendering the resource inert
when sending the closed event keeps things simpler for wlroots and
compositors.
2021-08-14 20:25:46 +02:00
Simon Ser 93964012e6 buffer: add addon set
This allows wlr_buffer users to extend it with tjeir own state.
2021-08-12 10:22:19 +02:00
Simon Ser 3f9e4f7a44 surface: kill wlr_surface.previous
This wlr_surface_state field was a special case because we don't
want to save the whole current state: for instance, the wlr_buffer
must not be saved or else wouldn't get released soon enough.

Let's just inline the state fields we need instead.
2021-08-11 18:13:12 +02:00
Kirill Primak debd6c5f0b wlr_output_layout: use wlr_addons 2021-08-10 19:15:48 +02:00
Kirill Primak 11f799e88e wlr_outputs: add wlr_addon_set 2021-08-10 19:15:48 +02:00
Simon Ser 3132c0ab10 output: drop wlr_output_state.buffer_type
This is now unconditionally set to WLR_OUTPUT_STATE_BUFFER_SCANOUT.
2021-07-29 09:48:33 -04:00
Simon Ser f211bc983a output-damage: stop using enum wlr_output_state_buffer_type
This enum will get dropped in the next commit.
2021-07-29 09:48:33 -04:00
Simon Zeni 646a25667e types/wlr_buffer: introduce wlr_buffer_resource_interface
Adds `wlr_buffer_resource_interface` and `wlr_buffer_register_resource_interface`,
which allows a user to register a way to create a wlr_buffer from a specific
wl_resource.
2021-07-22 22:28:24 +02:00
Simon Zeni f09c88c1b7 types/wlr_buffer: remove wlr_renderer argument from wlr_buffer_from_resource 2021-07-22 22:28:24 +02:00
Vyivel a93b18dbd5 input/pointer: send axis source once per frame
Only one wl_pointer.axis_source event is permitted per frame, according
to the Wayland specification.

Fixes https://github.com/swaywm/wlroots/issues/2973
2021-07-19 12:00:31 +02:00
Simon Ser 87e8c60faf output: add generic wlr_output_export_dmabuf implementation
When wlr_output manages its own swap-chain, there's no need to
hook into the backend to grab DMA-BUFs. Instead, maintain a
wlr_output.front_buffer field with the latest committed buffer.
2021-07-12 13:29:03 -04:00
Simon Ser 28aa803916 buffer: drop resource arg from wlr_client_buffer_create
This function doesn't need the wl_resource anymore.

In the failure paths, wlr_buffer_unlock in surface_apply_damage
will take care of sending wl_buffer.release.
2021-07-12 09:19:18 -04:00
Simon Ser 4554f17377 buffer: drop wlr_client_buffer.resource 2021-07-09 17:25:02 -04:00
Simon Ser a0baba4fa0 buffer: add wlr_client_buffer.source
This stores a weak reference to the source buffer.
2021-07-09 17:25:02 -04:00
Simon Ser 0abb67c478 buffer: stop using source resource in wlr_client_buffer_apply_damage
This is the first step towards dropping wlr_client_buffer.resource.
2021-07-09 17:25:02 -04:00
Simon Zeni 60f4d8f409 types/wlr_buffer: remove wlr_resource_get_buffer_size 2021-07-09 23:16:39 +02:00
Simon Zeni d086501fba types/wlr_surface: get buffer size from wlr_buffer_import 2021-07-09 23:16:39 +02:00
Simon Zeni 6d8029b07e types/wlr_buffer: split wlr_client_buffer_import function
`wlr_client_buffer_import` is splitted in two distincts function:
	- wlr_buffer_from_resource, which transforms a wl_resource into
	  a wlr_buffer
	- wlr_client_buffer_create, which creates a wlr_client_buffer
	  from a wlr_buffer by creating a texture from it and copying its
	  wl_resource
2021-07-09 23:16:39 +02:00
Simon Ser b934fbaf04 seat: add wlr_seat_touch_{send,notify}_frame
The wl_touch.frame event is used to group multiple touch events
together. Instead of sending it immediately after each touch event,
rely on the backend to send it (and on the compositor to relay it).

This is a breaking change because compositors now need to manually
send touch frame events instead of relying on wlr_seat to do it.
2021-07-08 09:12:17 +02:00
Simon Ser 22fd411bc3 cursor: add touch frame event 2021-07-08 09:12:17 +02:00
Simon Ser 84906a832f touch: add frame event 2021-07-08 09:12:17 +02:00
Simon Zeni e192d87731 move wlr_box from /types to /util 2021-07-06 21:43:17 +02:00
Simon Zeni d975f35bba types/wlr_box: remove unused wlr_box_from_pixman_box32 and wlr_box_rotated_bounds functions 2021-07-06 21:43:17 +02:00
Simon Ser 9a8097682b buffer: stop sending wl_buffer.release events from wlr_client_buffer
The specialized client buffer implementations take care of this.
2021-07-05 11:13:41 -04:00
Simon Ser d3d1c69aca buffer: remove renderer param from wlr_resource_get_buffer_size
The only reason we had this was because of EGL_WL_bind_wayland_display
support, which has been dropped.
2021-07-05 11:13:41 -04:00
Simon Ser c868e509b7 drm: add support for DMA-BUFs
Mesa's Vulkan WSI still uses wl_drm when modifiers aren't supported.
This has been fixed in [1] but will take some time to be propagated
to users. In the meantime, add a fallback.

[1]: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4942
2021-07-05 11:13:41 -04:00
Simon Ser f7e3d325fe Add a stub wl_drm implementation
This will allow us to remove all of our EGL wl_drm support code
and remove some weird stuff we need just for wl_drm support. In
particular, wl_drm buffers coming from the EGL implementation
can't easily be wrapped into a wlr_buffer properly.
2021-07-05 11:13:41 -04:00
Simon Ser e8c408b31b region: drop leftover reference to the mailing list
As per [1], the mailing list isn't used anymore.

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

Fixes: 82af6e7208 ("region: stabilize interface")
2021-07-05 10:32:50 -04:00
Simon Ser 82af6e7208 region: stabilize interface
References: https://github.com/swaywm/wlroots/issues/1008
2021-07-05 09:25:25 -04:00
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