Commit graph

5212 commits

Author SHA1 Message Date
Vlad Zahorodnii
4de69f2ef7 wayland: Close internal popups instead of hiding
Hiding the QWindow handle confuses QWidget, which results in user
actions menu not showing up on second launch. Might be a Qt bug.

On the other hand, it makes sense to close dismissed popups, so let's do
it.
2023-03-31 11:32:11 +00:00
Vlad Zahorodnii
4578cf352b Revert "Revert "wayland: Update shadow immediately""
This reverts commit 08e392f368.

It appears like with RHI, user code can't mess with its current opengl
context, so let's update shadows immediately.

Just to be sure, shadow cleanup logic in ShadowItem has been hardened to
avoid disturbing the current opengl context unnecessarily.

BUG: 467926
2023-03-31 10:37:30 +00:00
Vlad Zahorodnii
072d5ff045 scene: Avoid changing current opengl context if the shadow has no texture
If there's nothing to be destroyed, do nothing.
2023-03-31 10:37:30 +00:00
Vlad Zahorodnii
fd5807ecb7 backends/drm: Fix enabled state
"props->enabled" checks whether std::optional has a value, that's not
what we want.
2023-03-31 11:38:45 +03:00
Vlad Zahorodnii
a04609b46f wayland: Fix output order sanitization in kde-output-management-v2
We need to remove disabled outputs.
2023-03-31 10:46:26 +03:00
Xaver Hugl
4f48258269 kscreenintegration: don't access optionals that may be missing a value 2023-03-31 10:34:18 +03:00
Xaver Hugl
f70be829c6 backends/drm: don't access nullptr output configs 2023-03-31 10:34:18 +03:00
Vlad Zahorodnii
050336e421 Minor cosmetic improvements in Window
This change reorders some things in Window header so related things are
kept spatially close to make the code easier to navigate.
2023-03-31 06:56:47 +00:00
Alexander Lohnau
fe935c0dc8 Adjust to new KPackage namespace for structures
See https://invent.kde.org/frameworks/kpackage/-/merge_requests/73
2023-03-31 04:35:11 +00:00
Aleix Pol
7a6c2ce36f screencasting: Support opaque drm video formats
Fixes a warning on the CI
2023-03-31 00:18:53 +02:00
Aleix Pol
aaae80a569 backends/virtual: Fix format
While we are using GL_RGB8, it seems to be using 32bit pixels.
2023-03-31 00:18:53 +02:00
Vlad Zahorodnii
abb9b0d2cd Reshuffle desktop and activity related code in Window
Keep virtual desktop and activity related code spatially close to
improve code readability.
2023-03-30 18:42:28 +00:00
Vlad Zahorodnii
712a23bd59 Move Window::desktop to X11Window
Window::desktop() is obsolete. On the other hand, X11 doesn't support
having a window on several virtual desktops, so we still need it. As a
compromise, this change moves it to X11Window instead.
2023-03-30 18:42:28 +00:00
Vlad Zahorodnii
0d11a09010 tabbox: Port away from Window::desktop 2023-03-30 18:42:28 +00:00
Vlad Zahorodnii
2c12a6a417 wayland: Avoid updating outputs of a closed window
BUG: 467954
2023-03-30 18:29:05 +00:00
Xaver Hugl
66495f9c79 wayland/outputmanagement: don't access nullptr changesets
Since 6b8e08dfa9, changesets can be nullptr
2023-03-30 18:17:16 +00:00
Vlad Zahorodnii
101e38527d kcms: Port away from org.kde.kcm.ConfigModule
org.kde.kcm.ConfigModule doesn't exist anymore. Its replacement lives in
org.kde.kcmutils module now.

Note that the replacement has no "quickHelp" property, so it's been
removed. While on this, also drop "ConfigModule.buttons". It still
exists in the new ConfigModule but the default buttons should be fine.
2023-03-30 17:21:14 +00:00
Vlad Zahorodnii
73c26baab4 scripting: Make WindowModel.desktop property return list of desktops
The X11 desktop id property is obsolete.
2023-03-30 16:55:42 +00:00
Vlad Zahorodnii
aebc361c45 Drop Window::isOnDesktop(int) 2023-03-30 15:42:31 +00:00
Vlad Zahorodnii
e306e1b287 tabbox: Port away from legacy desktop ids 2023-03-30 15:42:31 +00:00
Vlad Zahorodnii
222b23eaa3 Adjust to kdecoration api changes 2023-03-30 15:25:50 +00:00
Vlad Zahorodnii
d76527e7e6 Port window cascading from X11 desktop ids to VirtualDesktop 2023-03-30 12:21:05 +03:00
Vlad Zahorodnii
044e160a50 Cleanup includes in window.cpp 2023-03-30 11:44:30 +03:00
Vlad Zahorodnii
cd36bb82b2 Regroup methods and fields in Window
Group methods and fields together to make Window internals less chaotic.
2023-03-30 11:44:30 +03:00
Vlad Zahorodnii
ec31ab4980 Drop Window::resourceMatch()
Its body is trivial and it's used only once so it can be inlined.
2023-03-30 07:33:20 +00:00
Vlad Zahorodnii
25f284e68c Remove comments reminding to copy properties in copyToDeleted()
Window::copyToDeleted() is gone.
2023-03-30 07:12:10 +00:00
Nate Graham
fec40b7163 Revert "backends/libinput: don't multiply v120 value by scroll speed"
This reverts commit 9cd52b4060.

This commit broke the adjustable scroll speed feature on Wayland. That
feature may not have been implemented in the most technically ideal way,
but simply breaking it and leaving the mouse KCM with UI control that
does nothing isn't great. Besides, there was always a simple way to
avoid any scroll-related regressions caused by this feature: reset the
scroll speed to its default value, which internally is a multiplier of 1
and exercises the same codepath that 9cd52b40 imposes on everyone.

We can come up with a better implementation for Plasma 6.

BUG: 464592
FIXED-IN: 5.27.4
2023-03-29 15:55:07 +00:00
Vlad Zahorodnii
c6035115f9 Drop ReleaseReason enum 2023-03-29 14:03:42 +00:00
Vlad Zahorodnii
3e766e8d5e Move Window::{frameId,window} to X11Window 2023-03-29 13:18:01 +03:00
Vlad Zahorodnii
1334b38ee1 Move X11-specific "skip close animation" handling to X11Window 2023-03-29 12:53:21 +03:00
Vlad Zahorodnii
d35f88adee Move Window::wmClientLeader to X11Window 2023-03-29 12:49:28 +03:00
Vlad Zahorodnii
e403c5bf63 Move Window::info to X11Window 2023-03-29 12:39:10 +03:00
Vlad Zahorodnii
bf19234df3 Move Window::detectShape to X11Window 2023-03-29 11:10:51 +03:00
Vlad Zahorodnii
fa8bd5c0d9 Move Window::{opaqueRegion,shapeRegion} to X11Window 2023-03-29 11:10:51 +03:00
Vlad Zahorodnii
46d0c04f91 Move Window::{depth,hasAlpha,visual} to X11Window 2023-03-29 11:10:51 +03:00
Vlad Zahorodnii
87bfdcf1d6 scene: Port WindowItemX11 to X11Window 2023-03-29 11:10:51 +03:00
Vlad Zahorodnii
551e4a8233 Move Window::propertyNotifyEvent to X11Window 2023-03-29 06:50:53 +00:00
Vlad Zahorodnii
005b098707 Move xwayland surface association logic to X11Window 2023-03-29 06:50:53 +00:00
Vlad Zahorodnii
2d275e16ec Merge XwaylandWindow with X11Window 2023-03-29 06:50:53 +00:00
Friedrich W. H. Kossebau
c395afde9b KIdleTime plugin: adapt to new name KAbstractIdleTimePoller 2023-03-29 02:51:46 +00:00
l10n daemon script
4bf7fdf8e0 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2023-03-29 02:28:14 +00:00
Vlad Zahorodnii
dbbcf31d0d x11: Merge Unmanaged into X11Window
Currently, managed and override-redirect windows are split in two types:
X11Window and Unmanaged. While looking at it strictly from type
perspective, this is great. But it creates other problems, e.g. we need
to put shared X11-specific code in the base Window class or mess with
"base" classes.

As an alternative solution, this change merges the Unmanaged class into
the X11Window class and disables some functionality based on the value
of isUnmanaged().

X11Window::manage() is used to create a managed Window. X11Window::track()
is used to create an unmanaged Window.
2023-03-28 18:14:32 +00:00
Xaver Hugl
062f092f38 workspace: prevent dangling pointers in output order list
An output can be still enabled but also scheduled for deletion
2023-03-28 16:22:20 +02:00
Xaver Hugl
c51824b535 Add OutputManager for taking care of output settings in KWin
As a first step to move away from having an external service remember output settings
for KWin, this commit introduces an output manager that can load configuration files
and generate new output configurations.
2023-03-28 16:19:09 +02:00
Xaver Hugl
6b8e08dfa9 core/outputconfig: store output properties with std::optional 2023-03-28 16:19:09 +02:00
Vlad Zahorodnii
08bebd1c4a Drop supported_types parameter in Window::windowType()
It's unused mostly.
2023-03-28 12:08:20 +00:00
Vlad Zahorodnii
902c2feb12 scripting: Drop Window.shaped property
It should be irrelevant to the scripts and there's no matching
abstraction on wayland.

is_shape is made protected, but it will be eventually moved to an X11
specific subclass.
2023-03-28 13:09:52 +03:00
Vlad Zahorodnii
94f0e564be Move internal window fbo and pixmap to InternalWindow 2023-03-28 11:47:22 +03:00
Vlad Zahorodnii
10b5236cfa Unvirtualize some Window properties 2023-03-28 08:31:08 +00:00
Vlad Zahorodnii
e31ec802f4 Drop Deleted
Currently, the normal window lifecycle looks as follows: create Window,
wait until it's shown, add it to Workspace, wait until it's closed,
create a Deleted, copy properties from the original window to the
deleted one, destroy the original window, wait until the last deleted
window reference is dropped.

There are a couple of issues with this design: we can't nicely
encapsulate X11 or Wayland specific implementation details if they need
to be accessed for closed windows; manual copying of properties is
cumbersome and error prone and we've had a dozen of cases where effects
worked incorrectly because some properties had not been copied.

The goal of this patch is to drop Deleted and extend the lifetime of the
original window, but with a special state set: Window::isDeleted().

The main danger is that somebody can try to do something with deleted
windows that they should not do, but on the other hand, such code needs
to be guarded with relevant checks too.
2023-03-28 08:31:08 +00:00
Vlad Zahorodnii
5454cc47c3 Preserve stacking order constraints when closing a window
When closing a window, we may need to change parent-child relationship
between windows, but we need to preserve stacking order constraints so
dialogs are placed above their parents when they're closed.
2023-03-28 08:31:08 +00:00
Vlad Zahorodnii
2510bf0439 wayland: Cache WaylandWindow::isScreenLocker()
This is needed to ensure that Window::isScreenLocker() returns a good
value for closed windows. Also, it's needed to get rid of
ClientConnection::aboutToBeDestroyed() connection, which can cause
problems with window teardown.
2023-03-28 08:31:08 +00:00
Nicolas Fella
008bdd18e4 Remove wrong prefixes from includes 2023-03-28 08:13:01 +00:00
Alexander Lohnau
8fc8bf89b5 Remove unneeded KCMUtils prefix for KCModule include
This was a temporary fix that is no longer needed
2023-03-27 18:50:35 +02:00
Vlad Zahorodnii
70a5052587 Remove commented out code 2023-03-27 15:16:30 +00:00
Vlad Zahorodnii
d45d8b5f98 Simplify X11Window::removeTransient()
If a transient parent is removed, X11Window::removeTransient() will try
to upgrade the transient to a group transient.

On the other hand, that code is broken because Window::removeTransient()
will unset transientFor() so we never hit the code path in the if
statement.

While we could fix it, I think it's not worth it because transient
handling code is already mental and making group transients and normal
transients disjoint will help to keep the things simpler.
2023-03-27 15:16:30 +00:00
Aleix Pol
fb3018b711 dpms: Make sure we are not calling the interface after the output is gone
It seems it's possible at times, as described in the bug.

BUG: 466346
2023-03-27 13:36:36 +00:00
Vlad Zahorodnii
71956e1bb5 effects/mouseclick: Fix warning about unhandled QPointingDevice::PointerType enum
AllPointerTypes is used as a filter in pointing input device handlers in
QML. I don't think we should hit this case in real world.
2023-03-27 15:35:22 +03:00
Vlad Zahorodnii
a1703ab97e Remove kwincompositingdata.moc include 2023-03-27 12:05:18 +00:00
Vlad Zahorodnii
9e4ed75e8e Remove kwinoffscreenquickview.moc include
It's not needed anymore.
2023-03-27 12:05:18 +00:00
Vlad Zahorodnii
f20cf30693 Fix populating CMAKE_AUTOMOC_MACRO_NAMES with kwineffects macros
Apparently CMAKE_AUTOMOC_MACRO_NAMES modifications are not visible in
sibling directories. To work around that, populate
CMAKE_AUTOMOC_MACRO_NAMES with libkwineffects plugin macros in the
top level CMakeLists.txt file.
2023-03-27 12:05:18 +00:00
Vlad Zahorodnii
4b343698c3 scripting: Drop registerWindow() workaround
desktopchangeosd appears to stop updating because kwin fails to deselect
XShape events.
2023-03-27 11:05:34 +00:00
Vlad Zahorodnii
983a0bc599 Prefer QThreadPool over QtConcurrent where we don't care about result
QtConcurrent::run()'s return type is marked with [[nodiscard]], which is
not nice to code that just needs to move some tasks to a worker thread.

On the other hand, QThreadPool satisfies our needs too and Qt doesn't
need to construct futures that we won't use.

One remark about the screenshot plugin: the task lambda is mutable so it
cannot be represented using a std::function.
2023-03-27 10:00:22 +03:00
Vlad Zahorodnii
a9ad59b32a Improve Workspace::outputAt()
Workspace::outputAt() casts vectors to four rectangle corners and uses
the shortest one to decide which output is the closest to the given
point.

This works poorly on dual monitor setups where on the left side you have
a monitor with landscape orientation and one with portrait orientation
on the right hand side. In that case, outputAt() will prefer the left
monitor even though the right monitor is the closest one if you cast a
perpendicular from the given point to the right monitor.

In order to improve the handling of that case, this change makes
Workspace::outputAt() compute the closest point to the output geometry
rectangle and use the squared distance as the score.
2023-03-25 21:24:59 +00:00
Vlad Zahorodnii
cbd50a1e08 libkwineffects: Install headers in libkwineffects/
This improves the scoping of libkwineffects header files and it helps to
make `#include "libkwineffects/foobar.h"` code work in user code.
2023-03-25 21:05:12 +00:00
Vlad Zahorodnii
1211d8e3d6 Prefix more kwineffects includes with libkwineffects/ 2023-03-25 21:05:12 +00:00
Vlad Zahorodnii
c049d5afb1 tabbox: Provide raw window caption
Use "textFormat: Text.PlainText" in window switchers instead.
2023-03-25 22:47:53 +02:00
Vlad Zahorodnii
c5eabfa4d1 tabbox: Drop TabBoxClient
The indirection contributes unnecessary complexity. The usage of
std::weak_ptr and std::shared_ptr complicates the things further, e.g.

![Screenshot_20230325_170226](/uploads/d8b68a9eff47c93c4463bb230b5bbe49/Screenshot_20230325_170226.png)

---

Ideally, same should be done with TabBox and TabBoxHandler, but that can be done in another MR.
2023-03-25 20:46:54 +00:00
Vlad Zahorodnii
fc890340d9 Fix warning about duplicate names in debug_console.ui
"label" is already used.

    Warning: The name 'label' (QLabel) is already in use, defaulting to 'label1'.
    Warning: The name 'label' (QLabel) is already in use, defaulting to 'label2'.
2023-03-25 18:33:24 +00:00
Xaver Hugl
67dc0c5c48 backends/drm: restrict common mode generation to drivers that support scaling
Also set the scaling mode property to "full aspect", which should reduce
the number of cases where the feature can cause issues
2023-03-25 18:52:15 +01:00
Vlad Zahorodnii
cf1d66ef59 tabbox: Drop support for _KDE_FIRST_IN_WINDOWLIST
LXR search shows that _KDE_FIRST_IN_WINDOWLIST is not used anywhere in
KDE codebase besides KWin.
2023-03-25 11:14:09 +00:00
Vlad Zahorodnii
09cc312f31 Drop irrelevant Deleted cleanup in Workspace
Deleted windows are no longer destroyed using deleteLater(). They will
be destroyed immediately as Workspace goes through the window list
because the effects will be unloaded by that time.
2023-03-25 07:53:41 +00:00
Vlad Zahorodnii
1f43605329 Drop Workspace::clientList() 2023-03-24 22:28:46 +00:00
Vlad Zahorodnii
4a1e7df599 tabbox: Drop desktop switching
Tabbox supports two operation modes: switching between windows and
desktops. Switching between windows is more commonly used. Desktop
switching is not exposed in user settings and it requires some advanced
knowledge of kwin's internals to enable it.

On the other hand, over the past years, we've double downed on effects
like desktop grid and overview to provide graphical means to switch
between virtual desktops.

This change drops desktop switching because it's effectively unused to
simplify the tabbox code, which can be very handy for the future
refactorings of window switching.
2023-03-24 22:01:12 +00:00
Ismael Asensio
7b25c8525e kcms/rules: Remove custom executable
The `kwin_rules_dialog` executable was used to launch the rules
KCM on a specific window when called from the window menu
because we couldn't depend on the `kde-cli-tools` repo

Since now `kcmshell6` lives on KCMUtils we can call it directly
2023-03-24 20:40:54 +01:00
Ismael Asensio
6082de1345 kcms/rules: Make Comboboxes bordered again
The property `flat: true`was set since the QML redesign and remained
unnoticed because it didn't actually work.

Now that the qqc2-desktop style has been fixed and correctly draws
flat (non-bordered) comboboxes let's remove it for a nicer look
(just the same as the have had all this time)
2023-03-24 19:20:56 +01:00
Xaver Hugl
ec593a2364 backends/drm: consider color property changes as failed when the output is off
The atomic test it does will succeed even when it shouldn't, which can make
enabling the output again fail
2023-03-24 14:10:36 +00:00
Vlad Zahorodnii
3c96b21b32 effects: Fix dialogparent installation 2023-03-23 16:51:49 +02:00
Vlad Zahorodnii
e88a4e34a3 Remove some include_directories()
It seems we've settled on dir/dir/header.h includes, so let's use them
consistently.
2023-03-23 14:37:48 +02:00
Vlad Zahorodnii
82ef63a3d4 wayland: Use correct signal to get notified when to destroy InputPanelV1Window
The window should be destroyed when the associated surface role is about
to be destroyed. QObject::destroyed is too late.
2023-03-23 11:24:20 +02:00
Vlad Zahorodnii
bffeae89c7 Drop unused X11Window::wasOriginallyGroupTransient() 2023-03-23 09:48:07 +02:00
Vlad Zahorodnii
017906541b Refactor compositing teardown in X11Window and Unmanaged
Currently, X11Window and Unmanaged call finishCompositing(), which tries
to destroy the window item and other associated compositing data.

Usually, it has no any effect on the window item and the effect window
because they are moved to the Deleted. However, it has some effect on
the XDamage handle.

If the X11 window is unmapped, it will destroy the XDamage handle. If
the X11 window is destroyed, it will do nothing. Why does it behave like
that? Because that's how the XDamage spec is written.

This change removes the call to finishCompositing() and refactors how
the XDamage is handled so Window::finishCompositing() is more generic.

If the X11 window is destroyed, SurfaceItemX11::forgetDamage() will be
called and SurfaceItemX11::~SurfaceItemX11() won't attempt to destroy
the damage handle.

If the X11 window is unmapped, SurfaceItemX11::destroyDamage() will be
called and destroyDamage() in SurfaceItemX11::~SurfaceItemX11() will
noop.

If compositing has been restarted, destroyDamage() in
SurfaceItemX11::~SurfaceItemX11() will destroy the damage handle.
2023-03-22 19:15:19 +00:00
Vlad Zahorodnii
48cf6a75cc Allow creating Deleted on shutdown
It helps to reduce the number of cases that have to be taken into
account when closing a window. Deleted is cheap to create too.
2023-03-22 19:15:19 +00:00
Vlad Zahorodnii
ad42cfecc1 wayland: Disable text-input-v3 when it's destroyed
Destroying a zwp_text_input_v3 object should be viewed as disabling it.

isEnabled property is cached because it cannot be computed in
_destroy_resource() handler. By that time, the resource no longer will
be in resourceMap(), so TextInputV3InterfacePrivate::isEnabled() will
erroneously return false even though we expect true.
2023-03-22 17:59:22 +00:00
Xaver Hugl
71ebaebe9b backends/drm: remove unused variable 2023-03-22 17:50:20 +01:00
Xaver Hugl
54e338eaed backends/drm: remove egl config handling
Without gbm_surface, egl configs aren't needed anymore
2023-03-22 17:50:20 +01:00
Xaver Hugl
629fb00341 platformsupport/scenes/opengl: filter out external formats properly
Using a hardcoded list is error prone and doesn't work on NVidia
2023-03-22 17:50:14 +01:00
Vlad Zahorodnii
c5f08d62d1 Use proper signal to get notified when to reset virtual keyboard geometry
Currently, input method relies on the fact that QObject::destroyed and
Window::closed are equivalent. But it's going to change, so make the
input method use a signal that's semantically better.
2023-03-22 15:59:34 +02:00
Vlad Zahorodnii
2dca6cd003 Extend lifetime of decoration to lifetime of Deleted
When a window is closed, a Deleted object will be constructed and the
Window's properties will be copied over to it. The long term plan is to
stop doing that, i.e. keep the Window alive but just flip a few flags to
indicate that it's been closed.

In order to unify decoration management, this change ensures that it's
okay to have decorations live as long as the Deleted.
2023-03-22 11:25:58 +00:00
Vlad Zahorodnii
d563382350 Fix destruction order of alive and deleted windows
It's needed to work around the cleanup logic of decorations.

Currently, decorations have a valid QObject parent and they're managed
using std::shared_ptr. That's not a perfect combination, but changing it
is also going to be an involved task because the QObject parent is used
to look up the Window.

In long term, it won't matter since we want to get rid of Deleted.

For what it's worth, it restores the order in which Deleted and normal
windows used to be destroyed prior to
995d509e45.
2023-03-22 11:25:58 +00:00
Vlad Zahorodnii
16a07d5df2 wayland: Handle xdg_wm_base being destroyed before surface role
If a client owns several windows (for example it can be the case with
plasmashell) and it crashes, it's possible to encounter the following
case:

- xdg_wm_base resources are destroyed
- xdg_toplevel is destroyed
- another xdg_toplevel is destroyed

When kwin processes the destruction of the first xdg_toplevel, it may
ping the second xdg_toplevel. But the xdg_wm_base is already free()d by
that time, so kwin can access already released memory.

In order to prevent that, make the associated XdgSurfaceInterface
objects inert. Since XdgToplevelInterface and XdgPopupInterface will
become useless after destroying XdgSurfaceInterface, make them inert too.

As the spec states, it's illegal to destroy a bound xdg_wm_base object
while there are still alive xdg surfaces created by it so destroying the
surface role objects should be fine.
2023-03-22 10:56:38 +00:00
Vlad Zahorodnii
1f7975e271 effects/screenshot: Provide screenshot scale information 2023-03-22 10:35:55 +00:00
Vlad Zahorodnii
1b1f0c6b32 effects/screenshot: Provide information about captured window or screen
This can be useful for the screenshot capture tool if it needs some
information about the captured window or screen, for example to generate
the file name.
2023-03-22 10:35:55 +00:00
Vlad Zahorodnii
5e63f9afc9 Drop Qt::Network dependency
We used it primarily for QHostInfo, but as QHostInfo::localHostName()
docs indicate, QSysInfo::machineHostName() returns the same info.
2023-03-22 07:23:24 +00:00
Vlad Zahorodnii
07b9588bd6 kcms/scripts: Remove unused stuff 2023-03-21 18:54:13 +00:00
Vlad Zahorodnii
2c0acdca11 Drop unused kitemviews dependency
Seems unused. KWin compiles fine without it.
2023-03-21 20:32:04 +02:00
Vlad Zahorodnii
1b5d2e9998 Drop Workspace::internalWindows() 2023-03-21 17:01:20 +00:00
David Edmundson
6f30a33033 Add a runtime guard that offscreen windows do not generate platform windows
It's come up before, and it's very very difficult to debug without a
backtrace even when you know what's going wrong.
2023-03-21 16:09:56 +00:00
David Edmundson
82b2fa37c2 Avoid accidental creation of backing stores for offscreen surfaces
Aurorae decorations and several effects are powered by QQuickWindows
that render into offscreen surfaces.

Iterating through all windows and then calling winId() will create a
platform window including for our Aurorae decorations.

Not only is this wasteful but it caused an issue with resizing windows.
QWindow code updates the internal state directly if there's no
underlying platform window, if there is it delegates responsiblity to
the backend. Our own QPA didn't update geometry whilst hidden.

The result of that is Aurorae decorations "randomly" stop resizing
correctly as the contentItem stops resizing to the window size.

BUG: 465790
2023-03-21 15:43:35 +00:00
Vlad Zahorodnii
4aec002d13 effects: Make -DTRANSLATION_DOMAIN target specific
This makes effect specific cmake code more encapsulated. It's also more
readable if the translation domain is specified explicitly rather than
having it implicitly set by add_definitions().
2023-03-21 10:12:26 +02:00
Vlad Zahorodnii
1f24b0f7cb Drop Workspace::unmanagedList()
It reduces the number of window lists to make the api of the workspace
cleaner.
2023-03-21 07:49:38 +00:00
Vlad Zahorodnii
49607b6eab cmake: Tidy scripted effect CMakeLists.txt code 2023-03-21 07:18:27 +00:00
Vlad Zahorodnii
dc2d8c875f cmake: install_scripted_effect -> kwin_add_scripted_effect 2023-03-21 07:18:27 +00:00
Vlad Zahorodnii
d6d3c0114e cmake: kwin4_add_effect_module -> kwin_add_builtin_effect 2023-03-21 07:18:27 +00:00
Aleix Pol
07f6241cd7 inputmethod: Properly report that it's not visible
Window::isShown only checks that it's not hidden, in this case it's not
that it's hidden it's that it's neither shown or hidden. Take the
readyForPainting attribute into account.
2023-03-20 21:24:19 +01:00
Xaver Hugl
a60d8941b6 port more stuff to standard smart pointers 2023-03-20 14:16:37 +01:00
Xaver Hugl
3e94a3945c src/tabbox: port to standard smart pointers 2023-03-20 14:05:29 +01:00
l10n daemon script
1cb3fa96b3 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2023-03-20 02:35:00 +00:00
Vlad Zahorodnii
871a1a460c scripting: Refactor generic scripted config
Currently it makes an assumption that the name of a scripted effect
starts with "kwin4_effect_" prefix, which has its issues. For example,
it will stop working if we choose to use simpler naming scheme.

This change reworks how the generic scripting kcmodule is constructed.
Instead of guessing kpackage type, make relevant kcms pass it explicitly
via the arg list.
2023-03-19 22:36:12 +02:00
Xaver Hugl
e83c593fda adapt to kdecoration changes 2023-03-19 15:26:15 +00:00
Vlad Zahorodnii
9aebfcb2ff Include src/ directory in the proper place
There's other code that includes headers starting from src/ directory,
so putting the corresponding include_directory() in src/effects/ is
inappropriate.
2023-03-17 21:14:14 +00:00
Vlad Zahorodnii
ed87ac837b Stop including src/effects directory in kcmkwincommon target 2023-03-17 21:14:14 +00:00
Vlad Zahorodnii
f288212869 Stop kcm_kwin4_genericscripted linking with libkwineffects 2023-03-17 21:14:14 +00:00
Vlad Zahorodnii
ffce2a61f1 Drop service type desktop files
They're irrelevant now.
2023-03-17 22:07:51 +02:00
Vlad Zahorodnii
25440385e7 Port to KPluginMetaData::fromJsonFile()
KPluginMetaData::KPluginMetaData(QString) assumes that the file
specified in the string corresponds to a binary plugin now, not a
metadata file.

This fixes scripted effect kcms not working.
2023-03-17 14:54:36 +00:00
David Edmundson
f88ff99d82 wayland: Truncate strings sent via plasmawindowmanager interface
Wayland has a limited size for strings in arguments. We should truncate
any strings that come from user-defined data before sending.

We keep the full title around within kwin as it keeps logic simpler.
Size length logic is lifted from QWaylandWindow's setTitle

BUG: 465775
2023-03-17 12:21:48 +00:00
Alexander Lohnau
1f7ec93954 Adjust to new KCM classes
Depends on https://invent.kde.org/frameworks/kcmutils/-/merge_requests/121
2023-03-16 13:50:16 +00:00
David Redondo
d5679ee82c Port some connections to Qt::SingleShotConnection 2023-03-16 11:03:07 +01:00
Vlad Zahorodnii
3704c0a945 backends/drm: Remove some gbm_surface,gbm_device forward declarations 2023-03-16 09:49:06 +02:00
Vlad Zahorodnii
7dbb06d80c Fix picking drag target
The normal stacking order contains managed and unmanaged windows now.
This kind of breaks dragging from X11 to Wayland clients.

When an X11 client is the drag source, it's going to create an override
redirect window for the drag icon, which is beneath the pointer.

findManagedToplevel() will return the drag icon instead of the window
beneath the drag icon.

The root problem is that normal event processing has different needs. It
doesn't care about window type except when the screen is locked, while
dnd does. Perhaps it also makes sense to check whether the window accepts
focus.

This change introduces a specialized helper to pick the drag target.
Unfortunately, it amounts to some code duplication. On the other hand,
not sure that other options (such as adding flags to findToplevel()) are
better.
2023-03-15 15:45:33 +00:00
Vlad Zahorodnii
bcc299c3fe Drop unused Workspace::deletedList()
It's unused, and there should not be any usecases for it outside the
Workspace.
2023-03-15 14:10:44 +02:00
Vlad Zahorodnii
8f21d444c6 Make Workspace::allClientList() return all windows
Currently windows are scattered in a few separate lists. If you need to
go through the windows, you have to do it piece by piece. On the other
hand, with the overhaul of window types, we've started converging
towards one universal type: Window. Keeping windows in the separate
buckets goes against this design.

Workspace::stackingOrder() already contains all windows. This change
repurposes Workspace::allClientList() from a list of "normal" windows to
all windows, i.e. Workspace::windows(), to be consistent.

There's one API change though. Scripting API will expose other window
types too. This is an intentional change so scripted effects could
operate with all windows. It also matches the current behavior observed
in libkwineffects, which exposes all windows as well.
2023-03-15 11:52:01 +00:00
Vlad Zahorodnii
392fb4eb01 Add explicit Window::isClient() checks
This is needed to prepare for introducing Workspace::windows().
2023-03-15 11:52:01 +00:00
Xaver Hugl
f433213bd6 backends/drm: simplify how atomic commits are done
Instead of having every DrmProperty store pending values, store the data
for the next commit in a separate and temporary type. This simplifies the
code and makes it possible to do commits in a separate thread
2023-03-15 12:09:12 +01:00
Jan Grulich
3807b41c66 Screencast: avoid using DMABufs exclusively to allow renegotiation
Using DMABufs only will not allow clients to fallback to MemFD buffers
in case they fail to import DMABufs for whatever reason and completely
break screen sharing in such case.
2023-03-14 19:50:07 +00:00
Alexander Lohnau
4e9303a6cc Adapt to KPackage API changes for install/uninstall
This simplifies the code, because we can access the package after installing it.

Depends on https://invent.kde.org/frameworks/kpackage/-/merge_requests/68
2023-03-14 20:18:39 +01:00
Xaver Hugl
d9077e36c5 backends/drm: use a common base class for property blobs
This simplifies the code a bit and makes more generic handling of blobs
possible
2023-03-14 19:23:17 +01:00
Vlad Zahorodnii
f3dc057c71 x11: Disable NETWinInfo in X11Window
This piece of logic belongs in X11Window rather than Deleted as the
latter is merely a representation of a closed window.
2023-03-14 17:52:50 +00:00
Nate Graham
a42f7f4807 kcms/effects: Add "tile"-related keywords
Ultimately the best solution would be to implement
https://bugs.kde.org/show_bug.cgi?id=462722, but that hasn't been done
yet, so for now let's use the existing approach of adding the names of
effects into the keywords list for this KCM to surface those effects at
the system level so e.g. people can find them with KRunner.

BUG: 467279
FIXED-IN: 6.0
2023-03-14 11:03:09 -06:00
Vlad Zahorodnii
88db280f2a Fix -Wdeprecated-enum-enum-conversion
Even though zwp_text_input_v2_content_hint and
QtWaylandServer::zwp_text_input_v2::content_hint represent the same
values, they are not the same from the compiler perspective.
2023-03-14 16:29:36 +00:00
Vlad Zahorodnii
af4397581a Fix warning about comparing different enums
QEventPoint::state() returns a QEventPoint::State value, not
a Qt::TouchPointState value.
2023-03-14 14:32:27 +00:00
Friedrich W. H. Kossebau
b2a50cffd8 Adapt to Qt6 name of QAccessibilityClient 2023-03-14 13:33:16 +00:00
Vlad Zahorodnii
b9daa38da1 Drop Application::setupTranslator()
KI18n already does the same for us in its Q_COREAPP_STARTUP_FUNCTION
hook and setupTranslator() produces a compiler warning.
2023-03-14 12:55:31 +02:00
Vlad Zahorodnii
8eaebe5b7d Get rid of compiler warnings about unused getEglErrorString() 2023-03-14 10:21:11 +00:00
Vlad Zahorodnii
d6309eb605 Fix -Wformat
QVector::count()'s return type is qsizetype. On a 64 bit platform, it's
equivalent to qint64, so "%d" does not suffice.

There are two ways to fix it: use PRIdQSIZETYPE or switch to the stream
operator. Since the warning format is not complex, this takes the latter
approach.
2023-03-14 09:19:41 +00:00
Vlad Zahorodnii
328cf606d4 Fix compiler warning about unused captured variable 2023-03-14 11:04:30 +02:00
Vlad Zahorodnii
1dde9a7b22 Remove unused X11WindowedEglLayerSwapchain::m_backend field 2023-03-14 10:42:20 +02:00
Vlad Zahorodnii
301d749e74 Remove unused RenderTarget::m_texture field 2023-03-14 10:42:20 +02:00
Vlad Zahorodnii
c8ed324a3d Remove unused functions 2023-03-14 09:57:18 +02:00
Vlad Zahorodnii
c91b90c58a Tidy Window::windowClosed() signal
"window" is redundant, so remove it. Also remove the original window
argument to improve the API consistency.
2023-03-14 07:15:56 +00:00
Vlad Zahorodnii
b4413f4b8b scene: Rework window elevation
The order in which windows are painted is computed dynamically every
frame. On the other hand, with the introduction of items, it's desired
to avoid doing that so repaints can be scheduled as needed. The
unification also opens the possibilities for more rendering related
refactors to make the code nicer and more reusable.
2023-03-13 17:27:15 +00:00
Aleix Pol
1cbc9185fb screencast: Properly detect the fallback
Do not check an it that is the container's end()
2023-03-13 16:49:06 +00:00
Vlad Zahorodnii
bacc35c236 backends/virtual: Provide vertically mirrored layer buffers
This makes the behavior of the virtual backend more consistent with
wayland, x11, and drm backends. However, the main advantage is that it's
more nicer to memfd fallback code path in screencasting plugin.
2023-03-13 15:34:36 +00:00
Vlad Zahorodnii
2f56cdc3fe Replace Deleted with Window where possible
With this, Window and Deleted can be interchanged, which makes merging
the two easier.
2023-03-13 14:41:44 +02:00
Vlad Zahorodnii
149db99c6a Make Window ref'able 2023-03-13 14:41:44 +02:00
Vlad Zahorodnii
995d509e45 Allow destroying Deleted immediately
Currently Deleted are destroyed with a delay to avoid dangling pointers
within the middle of painting.

On the other hand, it's reasonable to require not to delete windows when
kwin starts painting the screen.

Over the years, we refactored how deleted windows. They are always
unreferenced after finishing the current frame. So it should be fine to
destroy Deleted immediately now.
2023-03-13 14:41:41 +02:00
Vlad Zahorodnii
cdd18cd393 effects/slidingpopups: Prevent potential use-after-free 2023-03-13 12:15:23 +00:00
Vlad Zahorodnii
58ac7888e9 backends/x11: Split EglOnXBackend
The differences between windowed and host flavors of the X11 backend
have become too big, so let's split EglOnXBackend to avoid abstracting
something that makes little sense.
2023-03-13 11:36:06 +00:00
Vlad Zahorodnii
3bec3abb3f Use "window" instead of "toplevel" in Workspace 2023-03-13 10:37:01 +00:00
Vlad Zahorodnii
5b18cba3a0 Drop Workspace::{findAbstractClient,forEachAbstractClient} 2023-03-13 10:37:01 +00:00
Vlad Zahorodnii
497ba4a62a Stop including deleted windows in Workspace::forEachToplevel 2023-03-13 10:37:01 +00:00
Xaver Hugl
7f619e7770 colordevice: default the simple transformations to 1 2023-03-13 07:30:51 +00:00
Xaver Hugl
96b625f7d7 backends/drm: fail commits if nonexistent properties would be set 2023-03-13 07:30:51 +00:00
l10n daemon script
a92a4a9f20 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2023-03-13 02:48:29 +00:00
Xaver Hugl
4df1b3a219 backends/drm: ignore opaque formats for the cursor plane
The kernel may expose an opaque format that we normally prefer, so to
prevent picking an opaque format for the cursor, filter those out.
2023-03-12 18:18:50 +00:00
Vlad Zahorodnii
166b5f96fc effects/screenshot: Use more FileDescriptor
It helps to express the ownership of the pipe fd in ScreenShotSinkPipe2
better.

ScreenShotSinkPipe2 is not made to take a FileDescriptor too because
it's complicated by CaptureInteractive().
2023-03-12 14:52:18 +00:00
Vlad Zahorodnii
4148be0d27 Port to versionless QML module imports
It's more convenient and Qt upstream seems to encourage to use it too,
e.g. example import statements have no version.
2023-03-12 14:18:34 +00:00
Vlad Zahorodnii
18a9b3b25a Adjust to KDecoration API changes 2023-03-12 13:29:36 +00:00
l10n daemon script
e4da7fed68 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2023-03-11 02:58:17 +00:00
Vlad Zahorodnii
86e1305e80 rules: Make wmclass matching case sensitive
WM_CLASS is case sensitive.
2023-03-10 14:16:32 +00:00
Vlad Zahorodnii
11eac9d431 x11: Use WM_CLASS with original casing
WM_CLASS is case sensitive.
2023-03-10 14:16:32 +00:00
Vlad Zahorodnii
2d10212d82 backends/x11: Remove stray metadata file 2023-03-10 10:45:00 +02:00
Vlad Zahorodnii
0fd4d821ca libkwineffects: Forward declare RenderTarget and RenderViewport in kwineffects.h
kwineffects.h is included in many files and not everyone needs the
RenderTarget and RenderViewport, so forward declare them to reduce the
amount of parsing work for the compiler.
2023-03-10 07:19:33 +00:00
Weng Xuetian
a03b6fa08f Forward keymap and modifier change to input method keyboard grab when changed. 2023-03-09 20:39:26 +00:00
Vlad Zahorodnii
bd91f77212 backends/x11: Use more UniqueCPtr 2023-03-09 15:56:46 +00:00
Vlad Zahorodnii
19fec2a657 backends/x11: Use DRI3 directly
At the moment, the buffers for wsi are allocated implicitly by the EGL
implementation, which is fine for "normal" use cases. But we start
hitting the ceiling the moment we need to something more advanced. For
example the EGL backend creates a dummy fbo object wrapping the default
framebuffer, meaning that we cannot pass it to qtquick (because it can
use its own opengl context).

Another reason for using explicit buffers is that it lets us to clean up
some output related abstractions.
2023-03-09 15:56:46 +00:00
Aleix Pol
d34cf36bfa inputmethod: Show the input method even if it was dismissed
Reset the current context in case we receive a show() event from the
client, meaning that they really want to see that virtual keyboard.

BUG: 466969
2023-03-09 14:18:57 +00:00
Vlad Zahorodnii
472b88d02a backends/wayland: Port away from ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT
There are proper abstractions to ask the scene level to render with y
axis inverted so let's use it instead.
2023-03-09 13:22:53 +00:00
Xaver Hugl
ba85512f21 effects: remove rendertarget scale from WindowPaintData
If an effect needs to override the rendertarget scale, it should use RenderViewport
to do that
2023-03-09 13:22:53 +00:00
Xaver Hugl
125c141b7d effects: remove ScreenPaintData
The only purpose ScreenPaintData had was to pass around a copy of the viewport
projection matrix and the effectscreen, which can be handled in a simpler
way separately.
2023-03-09 13:22:53 +00:00
Xaver Hugl
e4938297e6 scene: fix texture inversion with the drm backend
Specify the render target to buffer transformation and take that into
account in effects and when calculating the projection matrix.
2023-03-09 13:22:53 +00:00
Xaver Hugl
2417a0381f backends/drm: port from gbm_surface to a custom swapchain using gbm buffers 2023-03-09 13:22:53 +00:00
Xaver Hugl
9eb8c3fcfb effects/blur: use a texture per screen on Wayland
This simplifies the effect and reduces its VRAM usage with multi monitor
setups
2023-03-09 13:22:53 +00:00
Xaver Hugl
5eb7ad37e5 effects/blur: manage render targets with std::unique_ptr 2023-03-09 13:22:53 +00:00
Xaver Hugl
d737ed6687 effects: introduce RenderTarget and RenderViewport
Instead of calling effects->renderTargetRect() and effects->renderTargetScale(),
pass the actually used render target and viewport in all the necessary methods.
This ensures that if an effect renders a screen with a modified scale or
projection matrix, the modified values get used instead of the "global" ones
2023-03-09 13:22:53 +00:00
Vlad Zahorodnii
c1eca80190 wayland: Remove implicit slide constraint adjustment
Panel sets constraint adjustments so let's remove the implicit slide
constraint adjustment to adhere more closely to the spec.
2023-03-09 13:05:42 +00:00
Vlad Zahorodnii
e38807b282 effects: Use scripting QML engine
Qt would need to allocate fewer "tainted" data objects, and using the
same engine both in effects and in kwin is vital for features such as
QML based effects.
2023-03-09 08:10:42 +00:00
Natalie Clarius
39cea49a8f placement: don't cascade for the sake of windows that are already covered
When checking for overlap with other windows when placing a new window and cascading to avoid complete overlap, ignore those windows that are already covered by other windows further on the top anyway.

The computation of the covered area is not entirely accurate as it uses the bounding rect rather than the combined rects of the windows, but okay enough for our use case imo.

BUG: 466135
2023-03-08 19:04:57 +00:00
Nate Graham
a2bf59005e virtualdesktops: use Meta key for axis shortcuts
These shortcuts currently don't use the Meta key, which allows them to
block app shortcuts (for example, in the Reaper DAW app). In general
it's a good idea for global shortcuts to use the Meta key to avoid
these kinds of conflicts since apps typically don't use the Meta key
for their own shortcuts. Other axis shortcuts set by KWin components
already do this, so let's do the same thing here.

BUG: 466915
FIXED-IN: 6.0
2023-03-08 17:43:21 +00:00
Vlad Zahorodnii
02fd869106 xwayland: Prevent potential file descriptor leak 2023-03-08 17:21:45 +00:00
Vlad Zahorodnii
1e0d5bba71 wayland: Prevent leaking --wayland-fd and --xwayland-fd to child processes
fcntl() expects FD_CLOEXEC instead of conventional O_CLOEXEC.
2023-03-08 16:55:49 +00:00
Vlad Zahorodnii
0e3bf29e3b helper: Don't leak lock file to kwin_wayland
The wrapper owns the socket, so kwin_wayland doesn't need to care about
the lock file.
2023-03-08 17:55:00 +02:00
Vlad Zahorodnii
1260e63305 backends/wayland: Don't leak renderD128 fd 2023-03-08 17:21:17 +02:00
Vlad Zahorodnii
318d126664 backends/wayland: Don't leak WaylandEventThread's pipe fds 2023-03-08 17:21:10 +02:00
Weng Xuetian
06ed58cb31 Fix text-input-v1 compatibility with 111.0.5563.64-1
While the documentation is not clear, it seems that preedit_cursor is
always required for every preedit_string event. Send preedit_cursor for
the preedit_string event we generate upon commit_string.
2023-03-08 12:30:00 +00:00
Vlad Zahorodnii
bc79d76ef6 effects/wobblywindows: Don't mess with clip region
Scene used to use the clip region as is even if the window is
transformed. That's no longer the case, so stop mutating the clip region
in favor of a more declarative approach to handling window painting.
2023-03-08 09:20:04 +00:00
Xaver Hugl
f2417a8523 backends/drm: support CTM for simple color transformations
In order to work around hardware and drivers that aren't capable of applying
a LUT, calculate a per-channel factor for brightness and color temperature
modification. While this ignores color calibration, this makes night color
work until a proper shader based color pipeline is implemented.

BUG: 455720
2023-03-07 17:03:40 +01:00
Vlad Zahorodnii
f4a35ed619 libkwineffects: Remove window tabbing leftovers 2023-03-07 14:46:45 +00:00
Vlad Zahorodnii
c0ff9526f9 Remove leftover from old times in PopupInputFilter
The windowShown connection is leftover from the times when kwin used to
not destroy the window object if the associated wl_surface has been
unmapped.
2023-03-07 14:15:18 +00:00
Vlad Zahorodnii
9ed1f28d0f scripting: Drop registerShortcut() function in QML API
Use ShortcutHandler type instead.
2023-03-07 13:57:38 +00:00
Vlad Zahorodnii
c121253d10 scripting: Introduce ShortcutHandler
The ShortcutHandler type provides scripts QML idiomatic way to register
global shortcuts.

There's one caveat about this API though. Since KGlobalAccel does not
allow to change the shortcut by repeating KGlobalAccel::setShortcut(),
the ShortcutHandler requires the default shortcut to be set before it's
constructed.
2023-03-07 13:57:38 +00:00
Vlad Zahorodnii
c191902026 wayland: Setup compositing when window is mapped ready for painting
This prevents creating a WindowItem until we know that the window is
actually going to be visible on the screen.
2023-03-07 13:44:03 +00:00
Vlad Zahorodnii
5cd99b27fd Apply 1 suggestion(s) to 1 file(s) 2023-03-07 13:23:52 +00:00
Xaver Hugl
ca78157a2d Apply 2 suggestion(s) to 1 file(s) 2023-03-07 13:23:52 +00:00
Vlad Zahorodnii
42e05def40 effects/screenshot: Port to QPromise
QFutureInterface is technically internal Qt API and the screenshot uses
it solely because we knew that there won't be any future Qt 5 releases
and it won't be removed in 5.15 patch releases.

In Qt 6, we have proper public API. Unlike QFutureInterface, QPromise is
not copyable, therefore this change also ports some parts of the screenshot
effect from QVector, which uses copy-on-write, to std::vector.
2023-03-07 13:23:52 +00:00
Vlad Zahorodnii
51a8e486b4 Remove X11 specific properties
Scripts should not rely on X11 or Wayland specific properties, but
rather use common abstractions. So remove X11 window specific properties.
2023-03-07 13:06:06 +00:00
Vlad Zahorodnii
34f46be823 Remove window arg in Window::activitiesChanged signal
This change removes the window argument to make window signals more
consistent. If you need the window, either use QObject::sender() or
capture it using a lambda.
2023-03-07 12:38:43 +00:00
Vlad Zahorodnii
0c0605abb9 Merge Window::minimize and Window::unminimize
Code of Window::minimize() and Window::unminimize() is mostly the same
with the exception of some state checks, so merge the two to tidy the
code.
2023-03-07 12:20:07 +00:00
Aleix Pol
4bc8cd6c54 input: Make sure input backends are initialised when the workspace is set up
The outputs already present upon workspace setup wouldn't signal. This
was easily triggered running a standalone kwin session on a tty, it
would manifest with the touchscreen not working complaining that it
didn't have an output assigned yet.

BUG: 466721
2023-03-07 12:53:05 +01:00
Vlad Zahorodnii
9a4ca5ec2b Drop MoveMinimizedWindowsToEndOfTabBoxFocusChain
Use OrderMinimizedMode option in [TabBox] instead.
2023-03-07 10:02:32 +00:00