Commit Graph

1979 Commits

Author SHA1 Message Date
Alexander Orzechowski ef4baea0e2 Use wl_signal_emit_mutable 2022-08-18 07:16:16 -04:00
yiqiang 3621c14b82 wlr_scene: fix color value when filtering black boxes
Signed-off-by: yiqiang <yiqiang@kylinos.cn>
2022-08-16 10:52:03 +08:00
Alexander Orzechowski bea4bd43e3 wlr_scene: Use wlr_box_equal 2022-08-15 07:37:09 -04:00
Alexander Orzechowski bcf7a79357 wlr_scene: Use wlr_fbox_equals 2022-08-15 06:14:59 -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 ce57485e6a wlr_scene: Calculate output intersections based on node visibility
This has a few benefits one of them crucial for proper operation:
 - The primary output will be based on the largest area that is actually
 visible to the user. Presentation and frame done events are based on
 this state. This is important to do since we cull frame done events.
 If we happen to be in a situation where a surface sits mostly on output
 A and some on output B but is completely obstructed by for instance a
 fullscreen surface on output A we will erroneously send frame_done
 events based on output A. If we base things as they are in reality
 (visibility) the primary output will instead be output B and things will
 work properly.
 - The primary output will be NULL if the surface is completely hidden.
 Due to quirks with wayland, on a surface commit, frame done events are
 required to be sent. Therefore, a new frame will be submitted for rendering
 on the primary output. We can improve adaptive sync on completely hidden
 but enabled surfaces if we null out the primary output in this state.
 - The client will be more likely to choose better metadata to use
 for rendering to an output's optimal rendering characteristics.
2022-08-14 02:38:51 -04:00
Alexander Orzechowski 342830e99c wlr_scene/surface: Hook through opaque metadata 2022-08-14 02:38:50 -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 14f4cfffba wlr_scene: Don't render non visible parts of textures/rects
We can also get rid of the intersection checks in the rendering functions
because we are guaranteed to already be in the node do to the prior
intersection checking of the node visibility.
2022-08-14 02:38:50 -04:00
Alexander Orzechowski d16d341381 wlr_scene: Only send frame done events for visible buffers 2022-08-14 02:38:50 -04:00
Alexander Orzechowski 6d62300324 wlr_scene_set_buffer_with_damage: Only damage the visible parts of the node 2022-08-14 02:38:50 -04:00
Alexander Orzechowski c6246272fd wlr_scene: Rework damage handling
Simplify damage handling by using our cached visibility state.
Damaging can happen in one step because since we can use the old visibility
state which represent what portions of the screen the scene node was. This
way we can damage everything in one step after the fact.
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
Alexander Orzechowski f411ca040e wlr_scene: Damage scene on node destroy by disabling node
This removes one trivial call of scene_node_damage_whole. It's easier
to disable the node later than it is to do the damage dance later.
2022-08-14 01:39:20 -04:00
Alexander Orzechowski 7f17774d18 wlr_scene: Introduce scene_nodes_in_box
Will query the scene for all nodes that appear in the given wlr_box.
The nodes will be sent to the iterator from closest to farthest from the
eye.

Refactor wlr_scene_node_at to use this new function.
2022-08-14 01:39:20 -04:00
Simon Ser c2359d0321 surface: implement wl_surface.offset
References: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/123
2022-08-12 11:27:33 +02: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
Kenny Levinsen 3baf2a6bcf scene/layer_shell: Ignore unmapped exclusion zone
Only the exclusion zone for mapped layer shell surfaces should be respected. In
particular, a layer shell surface that was mapped with an exclusion zone but is
now unmapped should not adjust the usable area.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3471
2022-08-06 00:23:44 +02:00
Kenny Levinsen 7abe8352db xdg_shell: Destroy popups after unmap event
This aligns with wlr_layer_shell_v1, and better matches how we normally use
teardown signals.
2022-08-06 00:20:42 +02:00
Kenny Levinsen 668b2740ff Set mapped before firing map/unmap events
This allows whatever the user calls from the signal handlers to react to observe
the new state rather than the old, e.g. that a surface is no longer mapped in
the unmap handler.
2022-08-06 00:19:38 +02: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
Quantum 30bf8a4303 seat/pointer: fix uninitialized variable warning
This results in the following warning, which in release mode causes an
error due to -Werror:

../types/seat/wlr_seat_pointer.c: In function ‘wlr_seat_pointer_send_axis’:
../types/seat/wlr_seat_pointer.c:344:25: error: ‘low_res_value_discrete’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  343 |   if (version < WL_POINTER_AXIS_VALUE120_SINCE_VERSION &&
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  344 |     value_discrete != 0 && low_res_value_discrete == 0) {
      |     ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
2022-07-28 02:25:31 -04:00
Kirill Primak 7298c42139 seat/pointer: rework sending axis events
This commit fixes:
- sending discrete scrolling events to multiple pointer resources
- sending events to clients which don't support wl_pointer.axis_discrete
2022-07-27 14:26:56 +00: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 40dc5121aa seat: support high-resolution clients
Upgrade the seat protocol to version 8 and handle clients that support
high-resolution scroll wheel events.

Since the backend already sends discrete values in the 120 range,
forwarding them is enough.
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
Alexander Orzechowski fdfdd01a79 wlr_scene: Use direct assignment for damage indicator timestamps 2022-07-03 12:21:39 -04: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
Simon Ser 10a821a87d output: fix missing buffer when using direct scanout
When using direct scanout back_buffer is NULL. We'd emit a commit
event with WLR_OUTPUT_STATE_BUFFER set but with a NULL buffer field,
which is non-sensical.
2022-06-29 17:42:57 +02: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
Kirill Primak 8d2fa15e9d xdg-toplevel: post no memory on strdup() fail 2022-06-21 17:37:45 +03:00
Kirill Primak ec8b49c93f subcompositor: consider map on creation
wl_subsurface description states:

A sub-surface becomes mapped, when a non-NULL wl_buffer is applied and
the parent surface is mapped.

Note that this doesn't require an explicit commit, which means that a
newly created subsurface with a mapped parent and a buffer already
attached must be mapped immediately. This can happen with the following
sequence of events:

- subcompositor.get_subsurface(subsurface, surface, parent)
- surface.attach(buffer)
- surface.commit()
- subsurface.destroy()
- subcompositor.get_subsurface(subsurface, surface, parent)

Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3449
2022-06-21 14:00:48 +03:00
Rouven Czerwinski 2a1d7d40f4 cursor: re-enable NULL buffer for cursor
The previous wlr_output_cursor_set_image() allows setting a NULL buffer for the
cursor to hide it. This functionality was used by sway to hide the cursor,
restore the original semantics by allowing NULL buffers again by avoiding the
wlr_buffer allocation in case we have NULL pixels and handing a NULL wlr_buffer
to wlr_output_cursor_set_buffer().
2022-06-20 10:20:55 +02: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
Kirill Primak e7b217efb9 xdg-shell: improve shell version check 2022-06-11 20:22:54 +03:00
Johan Malm d57d2e0e36 scene/layer_shell_v1.c: fix bug in width/height calculations
...in wlr_scene_layer_surface_v1_configure()

Reproduce bug with waybar by setting `"margin": 5,`
in ~/.config/waybar/config. It will result in the right edge of the panel
extending outside the edge of the output.

The bug can also be reproduced with gtk-layer-demo by anchoring
left/right/top/bottom and setting respective margins

Relates-to: https://github.com/labwc/labwc/issues/382
2022-06-08 20:13:55 +00: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 c2e4ba1dd0 output: use state setters in wlr_output_set_* 2022-06-08 18:29:58 +02:00
Simon Ser 43a9b0fbb9 output: compare state before commit
Before calling wlr_output_impl.{test,commit}, perform a cheap
comparison between the current and candidate state. Unset any
fields which didn't change.
2022-06-08 18:29:58 +02: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