Commit Graph

505 Commits

Author SHA1 Message Date
Loïc Molinari d1ee47361c helpers: Add FALLTHROUGH macro
Use gcc and clang's 'fallthrough' attribute instead of a comment to
fall through switch statements. This allows to request fall through
inside a block and prevents issues with preprocessed files.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-07-04 14:15:04 +00:00
Marius Vlad cc3542b574 desktop-shell: Use the correct link iterator
Mistakenly used weston_seat as opposed to shell_seat when iterating over
the shell seats. This unfortunately takes down the compositor upon switching
back.

Fixes: 4c100ca1d7 ('desktop-shell: Add session listener')

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-07-03 10:16:05 +00:00
Marius Vlad 4c100ca1d7 desktop-shell: Add session listener
And use it to perform keyboard activation on the currently focused
window. Similar to what kiosk-shell does, with the note that we go
over all seats in the system rather than picking the first one
available.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-06-21 13:21:27 +00:00
Witold Lipieta 215cceb45d desktop-shell: shell: Capture input on fade animation curtain
Shell fades out and in depending on user interactions. When screen
is faded out, first interaction wakes up the shell from idle and screen
fades back in. However, this first interaction is applied to whatever
is "behind" faded screen and it may trigger unwanted actions (first
touch or mouse click on active GUI elements). Behavior is the same for
both idle and lock screen (because unlock dialog is created after the
first interaction).

Update fade animation curtain creation function to capture inputs in
order to prevent unwanted interactions within faded or locked shell.

Fixes issues #147 and #569.

Signed-off-by: Witold Lipieta <witold.lipieta@thaumatec.com>
2024-02-29 15:29:23 +01:00
Paul Pu 4eee3c816d Fix segfault when using fullscreen when just hotplugging the display
Set the fullscreen_output to NULL when output gets destroyed. Otherwise,
a use-after-free case can happen, which result in a SEGFAULT crash.

Fixes #766

Signed-off-by: Paul Pu <hui.pu@gehealthcare.com>
2024-02-21 17:22:31 +08:00
Jeffy Chen 5dbf96fb6c desktop-shell: Avoid using maximized size in fullscreen state
The fullscreen should take precedence if the client requests both
window states at the same time.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
2024-02-02 19:44:31 +08:00
Marius Vlad 04d9f7e738 libweston/animation: Remove weston_fade_run unused argument
And with it, bump libweston to next major version, 14. We seems like
we never used that argument so better just removed it.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-01-09 13:15:16 +02:00
Pekka Paalanen 336f7fabec Rename compositor/ to frontend/
"Frontend" is a much more descriptive name for the code that is in the
directory called "compositor".

Fixes: https://gitlab.freedesktop.org/wayland/weston/-/issues/633

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2023-12-18 15:34:26 +00:00
Arnaud Vrac 03fa71f153 desktop-shell: set proper curtain size when no output is created yet
In this case the curtain width and height would be calculated using
uninitialized values, triggering warnings in pixman calls.

Signed-off-by: Arnaud Vrac <avrac@freebox.fr>
2023-12-01 12:43:27 +01:00
Arnaud Vrac 14e0fff19a desktop-shell: clamp view alpha correctly
Clamping of the alpha value is not done properly since the introduction of the
weston_view_set_alpha() helper.

Signed-off-by: Arnaud Vrac <avrac@freebox.fr>
2023-12-01 12:43:27 +01:00
Daniel Stone 40fdffdced desktop-shell: Create lock surface view when mapped
Wait until the lock surface is mapped until we create the view.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-10-04 11:44:10 +03:00
Daniel Stone 7205e88e60 desktop-shell: Use consistent surface-has-content check for lock
Rather than checking if the surface has width 0, use our helper to see
if the surface has an attached buffer.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-10-04 11:44:10 +03:00
Daniel Stone 3e156720a9 desktop-shell: Inline configure_static_view for panels
This is pretty trivial, so why not.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-10-04 11:44:10 +03:00
Daniel Stone de243918e3 desktop-shell: Inline configure_static_view for background
This is a pretty trivial case which just sets up one static view.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-10-04 11:44:10 +03:00
Daniel Stone 82d25f3ce7 desktop-shell: Use saved panel position
Don't look it up from the view every time, but instead just work
completely from global co-ordinates.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-10-04 11:44:10 +03:00
Daniel Stone aae1abb8df desktop-shell: Regularise panel position
Calculate everything in global co-ordinates and make it more consistent.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-10-04 11:44:10 +03:00
Daniel Stone a80a008479 desktop-shell: Directly look up output panel view
We don't need to traverse the layer-view list to find our view for an
output's panel.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-10-04 11:44:10 +03:00
Daniel Stone e165f15219 desktop-shell: Pass shell_output as special-surface private
We need to know which output we're on, and the surface type plus output
uniquely identifies us, so just pass that in.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-10-04 11:44:10 +03:00
Daniel Stone 36d04b0347 desktop-shell: Store pointers to special-surface views
We only have one of those per output, and we need to dig them out later,
so just store a direct pointer to them.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-10-04 11:44:10 +03:00
Daniel Stone 7f54341377 desktop-shell: Clean up surface/view mapping for special surfaces
Make background and panel surfaces do the right thing: map the surface
when it first gets content applied to it, and only move the view around
when required.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-10-04 11:44:10 +03:00
Daniel Stone 2cb4feb6c2 desktop-shell: Remove useless surface-gone messages
We expect this to happen at shutdown, so don't act surprised when it
does.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-10-04 11:44:10 +03:00
Daniel Stone a54bc37c6c desktop-shell: Don't allow multiple special surfaces
We only want one background and/or panel per output. If another one
comes up, tell the client it's done something very bad, rather than
trying to gently negotiate our way out of the situation.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-10-04 11:44:10 +03:00
Daniel Stone 22175a6a59 desktop-shell: Don't lose track of background/panel views
If our background and/or panel surface already has a view, something
extraordinarily weird has gone on. Don't try to deal with it.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-10-04 11:44:10 +03:00
Derek Foreman cec0ab7d23 libweston: Make better use of global coord helpers
Use wesotn_coord_sub/add() in many more places.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-10-03 18:19:17 +00:00
Marius Vlad b0b24ab375 desktop-shell: Branch out the set_maxime/unset_full
And move it back to its place, as we can't differentiante between two
different states: coming back from unmaxized (which makes it so we send
out a widthXheight size matching that of maximized whereas we should send
out 0, 0) and that we're no longer fullscreen. We land basically in the
same spot in both cases, and trying one issue, creates a new one.

Moving the corner case in set_fullscreen makes it so we don't reach both
cases in the same time and avoid introducing other issues.

Fixes: #801

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-09-27 13:26:22 +03:00
Derek Foreman d62c1b7f7b shell-utils: Use weston_coord in curtain params
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-09-18 20:35:37 +00:00
Derek Foreman 7dfc209824 desktop-shell: Use weston_coord for constrain_position
Update the desktop-shell specific cursor confinement code to use
weston_coord

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-09-18 20:35:37 +00:00
Derek Foreman 9e12250707 shells: Use weston_coord for shell API
Replaces a lot of x, y pairs with weston_coord.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-09-18 20:35:37 +00:00
Derek Foreman 5fa3ef26c9 libweston: Use weston_coord for touch interfaces
Most of these don't use the parameter that changes at all, but some get
a nice simplification.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-09-18 20:35:37 +00:00
Derek Foreman 8eed64c7df libweston: Add weston_view_set_position_with_offset
There are many times when we want to set a global position with a surface
offset added.

It's a fairly nasty operation, and most places in the code currently do
it naively, ignoring the painful existence of freeform window rotations
and other complex transforms that could be in play (but probably aren't)

Add a helper for this and convert existing usage.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-09-18 20:35:37 +00:00
Derek Foreman 8ac621d672 desktop-shell: Don't try to notice disappearing outputs during fade
This is a trap - it's not harmful to let the animation complete - it is
harmful to call weston_shell_utils_curtain_destroy() in mid animation. It
results in immediately completing the animation, which attempts to destroy
the curtain a second time.

Fixes a crash when (on a multi-output system) the display is disconnected
during the fade out, then reconnected before the fade-in starts.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-09-15 07:00:31 +00:00
Derek Foreman dd956e5b8b desktop-shell: Use the combined size of all outputs for the fade curtain
Instead of trying to cover the desktop with an arbitrarily larger
rectangle, actually calculate the appropriate size.

Fixes the old (but recently reintroduced) bug where the curtain isn't
always large enough.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-09-15 07:00:31 +00:00
Derek Foreman 06930c7138 desktop-shell: Revert 'Enable per-output fade animations'
This essentially reverts 9ad4de1f7a, though much has changed in the
interim to make a simple 'git revert' impossible.

Per-output fade animations were a precursor to implementing support for
zwp_idle_inhibit_v1. Nobody ever followed up on that. Now that we have
the ability to create overlapping outputs, per output curtains don't
make sense - the curtains can overlap and look weird.

This re-introduces the bug where a desktop larger than 8192 pixels in any
direction isn't properly covered by the fade.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-09-15 07:00:31 +00:00
Derek Foreman 59b6e6973e desktop-shell: assert if the shell startup animation type is unsupported
We've already validated this, so if we can't get here with an invalid
type. Just assert() instead.

This lets us remove the very strange tear down of curtains that presumably
couldn't have been created in the first place??

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-09-15 07:00:31 +00:00
Derek Foreman d215dc8319 desktop-shell: Remove useless setting of shell_fade output
weston_view_move_to_layer() recalculates the output, so this can do no
good.

This output is only ever used to test against NULL anyway, so we don't
need to try to set it "properly".

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-09-15 07:00:31 +00:00
Joshua Watt 617bb9afc9 Check weston_head_from_resource for NULL return
If the compositor is disabling a weston_output,
weston_head_from_resource can return NULL, so the return code must be
checked where used.

Fixes #638

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
2023-09-14 13:31:06 +03:00
Alexandros Frantzis 7dcde16f22 desktop-shell: Don't process surfaces under destruction during output resize
An output resize may occur while a shell surface is in the process of
being destroyed, e.g., while the destruction fade-out animation is in
progress. In such cases although the shell surface exists, it's missing
the backing weston_desktop_surface, so ensure to check for that.

Fixes: #805
Fixes: eefd8ae2e0
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2023-09-13 15:21:55 +00:00
Daniel Stone f7d8095352 desktop-shell: Use weston_view_move_to_layer() in switcher
Use our new helper instead of doing this by hand.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone fb64b00da7 desktop-shell: Remove manual damage for minimised surfaces
We don't need to inflict any damage here, because it's been done for us
when we move the layers.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone 73050c358d desktop-shell: Don't open-code animate_focus_change()
It already does what we want, so just use it when we're losing focus.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone f17581fdd2 desktop-shell: Regularise focus_animation_type checks
Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone 72a52454ad desktop-shell: Reject invalid focus types in configuration
Just refuse to start up if someone passes an incorrect focus type.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone fca71ff4bb desktop-shell: Initialise lists earlier
Make sure that we can exit cleanly if we have to fail.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone f04e1ec9ab desktop-shell: Clean up animate_focus_change()
Now that we're not allocating surfaces on demand, animate_focus_change()
becomes a lot more straightforward and common, and using some local
variables sure does cut out a lot of typing.

Knowing that both from and to cannot both be NULL (because we check if
from == to), we can change the juggling to be extremely simple:
calculate where we need the curtains to be in the view list, put them
there, and set up the fade.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone 42334db41e desktop-shell: Create focus surfaces for animation up front
Rather than creating them the first time we need to switch focus, just
create them at startup if we're going to be needing them at some point.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone a168dc0659 desktop-shell: Don't set alpha for unused views
We don't need to be setting this because it isn't (yet) used anywhere.
It will get set when it is used.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone 6738c738ab desktop-shell: Use weston_view_move_to_layer for focus animation
Rather than juggling our layers manually, just use
weston_view_move_to_layer. This obviates the need for manually marking
the view as mapped.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone db97820919 desktop-shell: Simplify condition for focus change
We must have (from || to), because if (!from && !to), we would've caught
the if (from == to) early-return case.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone 77b9dbb730 desktop-shell: Remove yet another center_on_output()
However many times you thought this might reasonably be called when
setting up for fullscreen, there were more.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00
Daniel Stone e32557131e desktop-shell: Simplify confusing conditional
The only place we ever set shsurf->fullscreen.black_view is when we're
going into fullscreen, and we destroy it when we're going out of
fullscreen. Hence if we do ever have a fullscreen black view, we should
move it out of the way.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-08-11 14:10:45 +03:00