Commit Graph

31 Commits

Author SHA1 Message Date
Nicolas Fella
80a047c0db Run clang-format 2024-04-21 17:50:57 +02:00
David Edmundson
2ac46d8d9d Drop now defunct code to sync resizes
This code was designed to make sure we didn't commit new buffers whilst
we were waiting for a configure. The way this worked failed in 6 after
kwin does not reply to desired_size changes immediately.

It is uneeded after kwin commit "wayland: Avoid rearranging layer
surfaces when wl_surface size changes" which means if we do submit
frames between size change requests, they'll be ignored. Meaning the
client will eventually get a configure event at the right size.
2024-04-11 17:57:14 +01:00
Vlad Zahorodnii
e8594be884 Use QWaylandWindow::windowContentGeometry() to set the initial preferred size
This matches the geometry used in the setWindowGeometry() function.
2024-04-04 14:18:38 +03:00
Vlad Zahorodnii
0a31923938 Update the desired size when the anchors change
When the anchor changes, the desired size should be updated to avoid
the compositor posting a protocol error.

BUG: 484990
2024-04-04 11:59:49 +03:00
Vlad Zahorodnii
127d817aa1 Guard against calling set_size while applying a configure event more explicitly
Depending on code path taken, geometry.size() == m_pendingSize can
produce incorrect results.

If a configure event is applied, it's fine.

If the window is resized by user, m_pendingSize will have outdated value,
and setWindowGeometry() can ignore future size updates that are valid.

In hindsight, we need special hooks in the QWaylandWindow to request and
apply new geometry. Rather than have one function that deals with all cases.
2024-04-03 15:15:37 +03:00
David Edmundson
17be1332cf Port to asynchronous roundtrip
When a resize is driven client side we wait for the compositor to have a
chance to reconfigure us before submitting the next frame.

Using a blocking round trip caused an issue. Instead block isExposed and
trigger an expose event whilst a sync is in progress.
2024-02-16 11:31:49 +00:00
David Edmundson
697c747c58 Synchronise client driven resizing
Qt's resizing is inherently synchronous. When an application calls
QWindow::setGeometry with a new size, we expect it to make that resize.
An expose event of the requested size will be generated.

Wayland is by default async, a client requests a size, and then will be
configured to that size, or potentially another size.

The simplest way to map the two APIs is to roundtrip when the client
wants to resize. This way we can guarantee that a call to
`setGeometry();  update()` will have the server configured size before
the paint.

In practice it's still not perfect due to other issues, but at least
will sort itself out within a frame.
2024-02-14 12:08:23 +00:00
Aleix Pol Gonzalez
5cf8ad46b1 Align layershell-qt with the rest of KDE frameworks at a licence level
Makes it possible to use in certain places that otherwise it couldn't
be.

Signed-off-by: Victoria Fischer <victoria.fischer@mbition.io>
2024-02-12 14:15:06 +00:00
David Edmundson
6427176da4 Fix build with Qt 6.7
This also fixes a hypothetical case of a layer shell with subsurfaces
and matches the call made by xdgshell after the first configure.
2024-02-08 10:04:27 +00:00
Marco Martin
ad5246f0d0 Add a new setExclusiveEdge call in the protocol
This can be used to disambiguate the exclusive edge when the anchors are
on a corner (so there  would be 2 candidates)

it's quite quick and dirty mostly to understand if we do want to push
for something along the lines
2024-01-26 11:38:44 +00:00
David Redondo
e3098a660a Fix constrained check
The value in parantheses was always zero.
2023-12-21 13:58:24 +00:00
Laurent Montel
8ae3b0aef8 Qt6 check code as apps is qt6 only. 2023-12-15 21:44:24 +01:00
David Edmundson
de9fdb3fb7 Support XDG activation
QWaylandLayerShellIntegration has virtual hooks for Xdg Activation.

This is important to hook up in layer shell because activation using
requestActivate in Qt will go through this path. It also means we have
support for us to drop the implementation in KWindowSystem in favour of
calling into Qt.
2023-11-06 12:41:20 +00:00
Vlad Zahorodnii
721c0ae334 Remove an inappropriate log message 2023-09-06 14:52:55 +03:00
Aleix Pol Gonzalez
143fd1755a Expose the Window interface to QML
If we are designing our UI's windows from QML, it makes sense that we
might want to configure how they're placed from the same place.

Everything was already in place but for a few technical bits which this
change adds.

Signed-off-by: Victoria Fischer <victoria.fischer@mbition.io>
2023-07-13 11:23:01 +02:00
Vlad Zahorodnii
5e88f449b0 Introduce Window::closeOnDismissed() flag
This can be used to control the sending of QEvent::Close event.
2023-05-16 17:58:48 +03:00
David Edmundson
1358743441 Call LayerShell::set_size when the window geometry changes
Without this when krunner expands, the frame after kwin will resize it
back to the last size the layer shell requested to be resized to.

To detect when we should not send an explicit size on window resize
events we check the anchors; if we're constrained on opposing edges we
want the compositor alone to set the size.
2023-05-01 14:38:36 +00:00
Fabian Vogt
49f31bb22d Replace Window::desiredOutput with a Window::screenConfiguration enum
To not overlap with QWindow::screen too much, introduce an enum to make it
more clear what the options and the resulting behaviour are.
2023-04-24 20:11:13 +00:00
Vlad Zahorodnii
511b92f4ab Port to QWaylandShellSurface::attachPopup() 2023-04-22 12:11:04 +03:00
Vlad Zahorodnii
2985398375 Port to QWaylandWindow::setShellIntegration()
With QWaylandWindow::setShellIntegration(), it's possible to use
xdg-shell and layer-shell protocols in the same process. It's important
for plasmashell, where we want to use the layer shell protocol for
special surfaces such as the desktop background, and the xdg shell
protocol for dialogs.

In order to make a QWindow use the layer shell protocol, you need to
call LayerShellQt::Window::get() before the window is mapped.
2023-04-22 12:11:01 +03:00
David Edmundson
7bd63669ea Use change signals on Window interface class.
QWaylandLayerSurface pulled data from the Window on startup. The Window
pushed data into the QWaylandLayerSurface on changes. Having two
patterns is a sign of something being off.

This moves everything to a single design, pulling from the public
interface. This allows us to drop a code path that meddles with
QWaylandWindow internals.
2022-06-30 08:09:21 +00:00
Julius Zint
9f8b8c9731 Add desiredScreen property to LayerShellQt::Window
If the property is set, the compositor will try to put the window on the
given output. If not set, the compositer will decide where to put the
window (usually the active output). The motivation for this change is the
ability for KRunner to always appear on the active output.
2022-01-26 09:04:14 +01:00
David Edmundson
4a439143ba Fix a crash when creating views on the placeholder screen
When a compositor has no outputs listed Qt creates a dummy placeholder
QScreen object that does not represent a wl_output.

This should still be fixed in the clients to not create a view, it's
wasteful and probably will still have plenty of other bugs, hence the
giant warning, but it's still worth guarding.

CCBUG: 439096
2021-09-15 22:55:35 +00:00
Vlad Zahorodnii
efd32eed53 Add missing parenthesis
This is to make the compiler happier.
2021-04-20 18:38:24 +03:00
Vlad Zahorodnii
11a811061f Introduce KeyboardInteractivity enum 2021-04-20 15:27:43 +03:00
David Edmundson
2b1219cfdd Ensure we can set per-window properties before the intial commit
In the current implementation we cannot use a LayerShellQt before the
shell surface is created.

At the moment a shell surface is created, the constructor is run and
then QtWayland commits the current state. This means the compositor
configures the window before a client has any chance to set anchors or
margins.

This works whilst we're just being a simple fullscreen window, but won't
scale for plasmashell in the future.

This patch makes LayerShellQt::Window always creatable, and we can set
and cache properties before the platform window is created, just like
one can on QWindow and XDGShell properties.

This also makes it less potentially crashy as ::get always returns a
valid result, and
sets up the public API to be QML-able as an attached property in future.

Co-authored on Aleix's patch for the unit test
2021-04-15 09:58:57 +01:00
David Edmundson
29d0078909 Ensure we can set per-window properties before the intial commit
In the current implementation we cannot use a LayerShellQt before the
shell surface is created.

At the moment a shell surface is created, the constructor is run and
then QtWayland commits the current state. This means the compositor
configures the window before a client has any chance to set anchors or
margins.

This works whilst we're just being a simple fullscreen window, but won't
scale for plasmashell in the future.

This patch makes LayerShellQt::Window always creatable, and we can set
and cache properties before the platform window is created, just like
one can on QWindow and XDGShell properties.

This also makes it less potentially crashy as ::get always returns a
valid result, and
sets up the public API to be QML-able as an attached property in future.

Co-authored on Aleix's patch for the unit test
2021-04-14 23:49:30 +01:00
Vlad Zahorodnii
b4c62f7926 Expose set_layer
The set_layer request allows to move a surface to another layer after
creating it.
2021-04-09 12:49:49 +00:00
Vlad Zahorodnii
9816f32bc4 Remove redundant includes
qwayland-wlr-layer-shell-unstable-v1.h is already included in
corresponding header files.
2021-04-07 16:49:31 +00:00
Aleix Pol
cd9b1a6fd3 Address code formatting 2021-04-06 13:39:27 +02:00
Aleix Pol
ea3e4b3139 Initial commit 2021-04-01 02:28:01 +02:00