Commit graph

219 commits

Author SHA1 Message Date
Xaver Hugl
19f92d731a platforms/drm: fix modifiers detection
CCBUG: 437893
2021-06-08 16:38:52 +02:00
Vlad Zahorodnii
1b2c7b248b Run clazy with qt-keywords fixit
In C++20, there will be emit() class member, which can conflict with the
emit keyword. Given that, there are plans to enable QT_NO_KEYWORDS by
default in the future.

See also
https://lists.qt-project.org/pipermail/development/2020-February/038812.html
2021-06-08 10:49:42 +03:00
Alexander Lohnau
9c689d7ddb plugins: Port away from deprecated version checks
Task: https://phabricator.kde.org/T14302
2021-06-07 15:01:19 +00:00
Xaver Hugl
3c10398104 screencast: only use glGetTextureImage where supported 2021-06-07 14:11:07 +02:00
Xaver Hugl
0208f78336 platforms/drm: make context current for direct scanout 2021-06-07 13:45:50 +02:00
Xaver Hugl
cfd7af0179 platforms/drm: support NVidia as secondary GPU with CPU copy
BUG: 431062
2021-06-07 09:23:06 +02:00
Ömer Fadıl Usta
8fc3b024be Update dumb_swapchain.cpp 2021-06-05 04:59:02 +00:00
Vlad Zahorodnii
5498b37938 scenes/opengl: Delegate viewport setup to backend
Only the backend knows what the right viewport rect is. Furthermore,
setting up the viewport before rendering is less error-prone.
2021-06-04 16:18:34 +03:00
Vlad Zahorodnii
8b3e999fbf scenes/opengl: Properly destroy backend if initialization fails
SceneOpenGL takes the ownership of the backend. So, if the scene fails
to initialize, the backend will be deleted twice.
2021-06-04 07:39:51 +00:00
Ömer Fadıl Usta
6c97cd118d fix include 2021-06-02 17:41:10 +00:00
Xaver Hugl
b88b6f3bc3 platforms/drm: log when direct scanout starts and stops 2021-06-01 13:02:13 +02:00
Aleix Pol
aba3335ea6 Fix weird decoration glitch when using a scaled display
We used to get a weird line around the window decoration because the
clamping would hit the outside of the rendered decoration.
To make sure we fall inside take the displayPixelRatio into account.
Also on non-integer scales, make sure we are actually falling inside.
2021-05-31 13:01:25 +00:00
Xaver Hugl
7bf79090cf platforms/drm: add outputs on EglGbmBackend initialisation
BUG: 437761
2021-05-31 13:15:16 +02:00
Vlad Zahorodnii
33bb146861 scenes/opengl: Remove unused render node leaf type 2021-05-31 09:35:52 +03:00
Vlad Zahorodnii
048c732a4e scenes/opengl: Remove half-pixel correction workaround
It was needed to work around visual glitches in the wobbly windows
effect. Since the wobbly windows effect renders the animated window into
an offscreen texture, we don't need this workaround anymore.

Furthermore, rather than using half-pixel correction, it is more
desirable to use an offscreen texture as it results in simpler design.
Performance-wise, it's not that bad that we need to start looking for
other ways to get rid of the seams between window contents and deco.
2021-05-31 05:27:22 +00:00
Nicolas Fella
f910b0de97 Use version-less qt DBus macros
They work with both Qt5 and Qt6
2021-05-31 01:00:35 +02:00
Xaver Hugl
2742e5b422 Rearrange wayland startup sequence
The backend can now optionally wait for the scene to be created before
it updates its outputs, which is necessary for better atomic tests in
the DRM backend.
2021-05-27 13:41:40 +00:00
Aleix Pol
644dcbe173 screencasting: do not attempt to copy a null texture
It seldom happens, but it does happen.
2021-05-26 12:56:59 +00:00
Vlad Zahorodnii
870c1e5557 scenes/qpainter: Clean up includes
Wayland-specific code in the qpainter renderer was removed long time ago.
2021-05-26 09:36:20 +03:00
Vlad Zahorodnii
f46c7bae8d Move decoration renderer to decoration item
Currently, the implementation of the DecoratedClient and the decoration
renderer are strongly coupled. This poses a problem with the item based
design as the ultimate goal is to have scene items construct paint nodes
which are then fed to the renderer. The DecorationItem has to have
control over the decoration texture. Another issue is that the scene
cannot smoothly cross-fade between two window states if the decoration
is removed, e.g. from fullscreen mode to normal and vice versa.

This change moves the decoration renderer to the decoration item. With
the introduction of a generic scene texture atlas, we hope to get rid of
the decoration renderer altogether.
2021-05-26 06:35:03 +00:00
Vlad Zahorodnii
7f32594692 Port decoration renderers to Decoration::damaged signal 2021-05-26 06:35:03 +00:00
David Edmundson
600c1e0a54 platforms/drm: Make context current before EGLStreams calls
attachStreamConsumer and resetOutput are not called as part of the scene
render and as such the context might not be set.

All credit goes to Simon Spinner for his investigation.

BUG: 437573
2021-05-24 13:51:18 +00:00
Vlad Zahorodnii
1a464530bd scenes/xrender: Remove SceneXRenderShadow::buildQuads()
It's effectively the same as Shadow::buildQuads().
2021-05-24 06:22:28 +00:00
David Edmundson
af66f39f19 Support High DPI Aurorae decorations
With high DPI we can't use the image size as a logical size directly.

The other change is use of QPainter::drawImage(QRect target, QImage
image, QRect source)

This slightly confusing method uses logical pixels for the target, but
the source rect is in native pixels of the source.

BUG: 422342
2021-05-21 11:26:53 +00:00
Aleix Pol
22f2e3e43c No need to reset the damage for objects that we already know have none 2021-05-20 13:38:30 +00:00
Aleix Pol
848e9e2076 aurorae: Fix warning at startup
Give an opportunity to the settings to get initialized. Otherwise we set
an null object and qml scripts complain.
2021-05-20 13:36:04 +00:00
Vlad Zahorodnii
bc22b9e59e Fix build 2021-05-20 16:25:13 +03:00
Xaver Hugl
793cc5fa25 platforms/drm: replace pointer to egl backend with QPointer
If the egl backend gets deleted this leaves a dangling pointer. In
order to prevent crashes with QPainter or EglStreams also don't try
to create dmabuf textures without a EglGbmBackend.
2021-05-20 14:37:55 +02:00
Vlad Zahorodnii
e4ec955d88 Remove shadow related bits in Scene::Window 2021-05-19 14:13:47 +03:00
Aleix Pol
386814176b drm: Use KScreen's json files to set up the initial output composition
So far we had a composition setup within kwinrc and kscreen. This
produces flickering sometime and makes the state a bit more flimsy.
This patch changes the kwin's behaviour to use the files produced by
kscreen which are anyways available down the line.

THis simplifies our behaviour down to just one format that we write to
and feed from. This also allows us to leverage it further by using this
format for default setups (which consist in the right file in
~/.local/share/kscreen).
2021-05-18 14:18:38 +00:00
Xaver Hugl
7de0f1f2ad platforms/drm: CPU copy for multi-gpu
Not all GPUs can scan out linear buffers, so if import with a dmabuf
fails manually copy the data into a non-linear gbm buffer instead.

BUG: 432707
2021-05-18 14:54:05 +02:00
Aleix Pol
a20a4327f5 screencasting: Make sure we don't stream after we've stopped a stream
When doing some (intense) testing I've seen it crash. This will prevent
it for good.
2021-05-18 11:51:05 +00:00
Vlad Zahorodnii
0f2f69ad7c Decouple window pixmaps from scene windows
One of the scene redesign goals is to make wayland surface items
re-usable. So we have the same rendering path for drag-and-drop icons,
software cursors, and window surfaces.

The biggest issue at the moment is that window pixmaps are tightly
coupled with scene windows.

This change de-couples window pixmaps from scene windows. In order to
achieve that, some architecture changes were made.

The WindowPixmap class was replaced with the SurfacePixmap class. A
surface pixmap is created by a surface item.

Under the hood, a SurfacePixmap will create a PlatformSurfaceTexture
object, which contains all the information necessary for the renderer.

The SceneOpenGLTexture class was removed. However, the GLX and the EGL
on X11 backends still mess with GLTexture's internals.
2021-05-18 09:11:24 +00:00
l10n daemon script
18793f83d3 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"
2021-05-17 01:33:52 +00:00
Alexander Lohnau
8125f9137f
GIT_SILENT Remove obsolete KRunner property 2021-05-15 10:03:33 +02:00
Vlad Zahorodnii
77a9d38166 Make libdrm required dependency
As is, kwin with the drm backend results in the most pleasant user
experience on Wayland. Given that and the fbdev being about to be
dropped, making libdrm a required dependency seems a reasonable decision.
2021-05-14 18:00:40 +00:00
Aleix Pol
035ea75ab7 Use qAsConst in fors when there's a risk for it to detach 2021-05-14 01:35:33 +02:00
Aleix Pol
50dd08531e Make sure we do not get references on temporary objects 2021-05-14 01:35:33 +02:00
Aleix Pol
f70256931c --warning: treat unused variables so we are not warned about them 2021-05-14 01:35:33 +02:00
Aleix Pol
a06bf936bc --warning: Remove unnecessay cast 2021-05-14 01:35:33 +02:00
Aleix Pol
1754744297 Add switch case for impossible enum
It's already treated above and the compiler just does not see it.
2021-05-14 01:35:33 +02:00
Zhang Liang
837ef14e46 Change the argument name in function declaration
Change the name from "pipewireStream" to "stream",keep it same as definition.
2021-05-12 10:39:03 +00:00
Bhushan Shah
4e7c6b57a6 platforms/drm: put double tap timer behind config option
This feature was implemented in commit a66eb1a5b9 earlier

Double tap wake up is not a feature to be implemented at compositor
level but rather at the hardware/kernel level. Double tap timer here
means when screen is turned off, libinput will continue to poll the
touchscreen for new events.

double-tap-to-wakeup is generally interrupt at driver/hardware level
which have ability to wake system up even from the sleep.

Provide a option to disable the double tap timer on kwin side for
devices which makes use of suspend since when in suspend kwin can not
wake device up, and that provides confusing user experience.
2021-05-11 00:47:21 +00:00
Jan Grulich
caaabf84df Screencast: use dma-bufs only when client explicitly asks for it 2021-05-05 10:01:49 +02:00
Xaver Hugl
5bd938f0f0 platforms/drm: release gbm buffers before eglDestroySurface
BUG: 436500
2021-05-04 17:36:09 +00:00
Adriaan de Groot
49fcadb185 Fix build on 32-bit systems
The added comment explains it all, really: you can't fit a 32-bit
unsigned into a 32-bit (signed) time_t, but we don't care.
2021-05-04 12:34:07 +00:00
Xaver Hugl
bd4a8be319 platforms/drm: fix DrmOutput::updateMode 2021-05-04 10:01:55 +00:00
Xaver Hugl
089134d0bd platforms/drm: GPU power management
When a GPU has no outputs attached we need to release all resources and
close the fd to allow the driver to completely power down the GPU. This
is also required to allow the driver to be unloaded for VFIO.
2021-05-03 18:03:09 +02:00
l10n daemon script
31cdb8676d 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"
2021-05-03 01:21:56 +00:00
Ömer Fadıl Usta
a8d7e99874 [plugins/platforms/drm/drm_backend] Fix build for bsd 2021-05-01 19:43:00 +00:00
Vlad Zahorodnii
8d9e47ee22 platforms/drm: Introduce KWIN_DRM_DEVICES
This allows to instruct kwin what drm devices must be used explicitly.

BUG: 435467
2021-05-01 12:14:34 +00:00
Xaver Hugl
faddf0bf5f Wayland: variable refresh rate support
BUG: 405912
2021-04-30 16:18:39 +02:00
Vlad Zahorodnii
706eb16b3a Remove Platform::screenGeometries and Platform::screenScales
If you need screen geometries or scales, use AbstractOutput::geometry()
and AbstractOutput::scale(), respectively.
2021-04-29 11:31:31 +00:00
Vlad Zahorodnii
ac3c09ba75 Remove Platform::areOutputsEnabled()
This flag is redundant. If an output is disabled, the compositor won't
attempt to perform compositing on it.
2021-04-29 10:47:41 +00:00
Vlad Zahorodnii
f8c00a530f Remove Platform::prepareShutdown()
Platform::prepareShutdown() was introduced to work around the issue
where the platform accesses destroyed OutputDeviceInterface objects.

Since we no longer query OutputDeviceInterface for output info, the
Platform::prepareShutdown() function can be dropped.
2021-04-29 10:47:41 +00:00
Vlad Zahorodnii
2200f4ded9 windowsystem: Fix compilation with no deprecated build of KWindowSystem
Highlight window and present windows API has been deprecated in 5.82.
2021-04-29 10:46:39 +03:00
Vlad Zahorodnii
9e1de4522e platforms/drm: Remove unused defs and includes in drm_backend.cpp 2021-04-29 08:45:27 +03:00
Vlad Zahorodnii
c4c46a089f platforms/drm: Properly detect if there are no DRM devices
If no primary gpu can be found, we need to quit.
2021-04-29 05:34:19 +00:00
Vlad Zahorodnii
9f030ecd40 platforms/drm: Enable atomic modesetting in hot plugged gpus
At the moment, if a gpu is hot plugged, it won't have atomic modesetting
enabled.
2021-04-29 05:34:19 +00:00
Vlad Zahorodnii
03c38e02e9 platforms/drm: Remove DrmBackend::findOutput()
It's unused.
2021-04-29 08:10:37 +03:00
Vlad Zahorodnii
54a034b7cf platforms/drm: Use dev nums to find gpus
This way we don't need to convert strings to ints every time
udev_device_get_sysnum() is called.
2021-04-29 04:58:46 +00:00
Vlad Zahorodnii
fe0039091c platforms/drm: Don't search for gpus on add udev event
If a gpu is added, don't search for it pointlessly in m_gpus.
2021-04-29 04:58:46 +00:00
Vlad Zahorodnii
04c3bee803 Remove unused things in drm_backend.h 2021-04-28 22:12:58 +03:00
Xaver Hugl
9cd046f206 platforms/drm: add GPU hotplug support 2021-04-28 18:57:47 +02:00
Xaver Hugl
0284aeb7bb platforms/drm: Don't release drm buffers in EglGbmBackend
When we release the buffers that also removes the drm fbs.
This causes failing atomic commits that the atomic code
doesn't (yet) handle correctly, the result is a black
screen when compositing is restarted.
2021-04-28 13:51:06 +00:00
Xaver Hugl
40eb0e4f0e platforms/drm: only print error for direct scanout when useful
Most wayland-native apps provide buffers that aren't suitable
for direct scanout; the message usually only spams the log full
without proper reason or useful information
2021-04-27 15:22:20 +02:00
Aleix Pol
af6f95b2eb fb: remove unnecessary casts 2021-04-27 15:14:06 +02:00
Aleix Pol
4b3b5fa368 fb: make it easier to run on nomodeset
In the few cases where the framebuffer is needed, we'd get problems
because ioctl(KWIN_FB_NO_VSYNC) fails.
This removes the code entirely to just use a timer to refresh.

BUG: 436053
2021-04-26 12:46:55 +00:00
Vlad Zahorodnii
2c05229141 qpa: Set minimum device ratio of 1 for windows
This is to prevent rendering issues in the present windows close buttons
as Qt supports scale factors that are less than one poorly.
2021-04-26 11:41:37 +00:00
Vlad Zahorodnii
c9ac2e3fb8 decoration: Fix rendering issues with scale factors < 1
QPainter::setWindow() doesn't work as we expect if the device pixel
ratio of the paint device is less than 1, for example 0.5 or 0.75.

QPainter only allows the effective device pixel ratios that are greater
than or equal to 1. This restriction probably has to be lifted.

For the time being, this change introduces a helper function that can be
used to determine the scale factor by which QPainter::window() must be
multiplied.

BUG: 432766
2021-04-26 11:41:37 +00:00
Vlad Zahorodnii
c103eb8f5c qpa: Simplify backing store blitting
We can use QPainter::drawImage() to update the dirty area of the front
buffer. This way, we don't need to call std::copy().
2021-04-26 09:21:34 +00:00
Aleix Pol
b372de8c74 Fix startup when running with ASAN
We can't call kwinApp() before KWin::Application hasn't been properly
initialized.
2021-04-23 09:38:42 +00:00
l10n daemon script
6276c8882e 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"
2021-04-23 01:18:39 +00:00
Xaver Hugl
49c650eed2 platforms/drm: don't ignore blob properties without valid blobs
Instead of deleting all blob properties without a valid
blob check for the blob existing before using it. This is
necessary because some properties are needed even without
currently valid blobs.

BUG: 435786
2021-04-22 12:40:48 +00:00
Aleix Pol
b3ddb11b7c drm: hide the cursor as we are setting dpms off
It seems to crash amdgpu and it's consistent with how we're cleaning all
our planes.

BUG: 435941
2021-04-22 10:18:15 +00:00
Aleix Pol
633136d228 drm: remove unused attribute in DrmOutput 2021-04-22 10:17:29 +00:00
Vlad Zahorodnii
0d9185053c platforms/drm: Ignore udev events while session is inactive
While the session is inactive, the drm master permissions are revoked.
Therefore, we cannot perform things such as modesetting, etc. It also
makes no sense to create or destroy DrmOutput objects.

CCBUG: 435941
2021-04-21 23:17:54 +00:00
Aleix Pol
f7526f50fe build... 2021-04-21 17:42:55 +02:00
Aleix Pol
8d186efa08 drm: Do not check egl extensions before setting them up 2021-04-21 17:34:07 +02:00
Xaver Hugl
5a2177a51c platforms/drm: use surfaceless context
On multi-gpu systems it could happen that the primary GPU
has no working outputs attached, yet we still need the
egl context.
2021-04-21 09:06:17 +00:00
Vlad Zahorodnii
700028b37d Fix build 2021-04-20 14:37:43 +03:00
Vlad Zahorodnii
15f1b9792b Revert "platforms/drm: Introduce DrmPipeline"
This reverts commit 5a22deda3b.

We still need more work to finish the DrmPipeline. At the moment, there
are a few major issues, e.g. some outputs not turning on, output
transforms not working correctly, a crash when changing dpms mode.

Let's merge this change back once all major issues are fixed and after
more testing.
2021-04-20 11:34:04 +00:00
Aleix Pol
d999aa6c6a drm: destroy the gbm device after we are done with all of the objects
Just in case they still need to interact with gbm
2021-04-20 13:02:46 +02:00
Aleix Pol
300f28a5a9 drm: remember to clean up DrmGpu's outputs when destroying 2021-04-20 13:02:46 +02:00
Aleix Pol
d5ac0cf919 drm: Also release the pipeline buffer when DrmOutput::releaseBuffers() 2021-04-20 13:02:46 +02:00
Aleix Pol
b82840d7e0 drm: Don't call virtual methods from a parent class destructor
We'd be relying on AbstractEglDrmBackend on calling cleanup but we'd be
doing it when cleanupSurfaces cannot be reached out anymore, turning it
into a half-baked cleanup.

Instead call cleanup from the leaf class destructors.
2021-04-20 13:02:46 +02:00
Xaver Hugl
7a9676dc0a Introduce the legacy flag for drm properties
There are properties like for example rotation
that don't have the atomic flag, yet work and
are needed in atomic mode setting.
2021-04-20 09:22:50 +02:00
Xaver Hugl
0292c4a74c platforms/drm: Add support for setting overscan
BUG: 428201
2021-04-19 18:46:41 +02:00
Xaver Hugl
7dddcf202b platforms/drm: Don't create outputs without primary plane in AMS 2021-04-19 12:12:26 +00:00
Xaver Hugl
5a22deda3b platforms/drm: Introduce DrmPipeline
DrmPipeline is what now contains all the drm bits related to
modesetting and presentation, instead of that being in DrmOutput.
This gives a lot more freedom for managing drm resources and
enables far better usage of the atomic API with guaranteed
immutability for failed tests.
2021-04-16 20:26:34 +02:00
Aleix Pol
b68cd3110a Fix streaming of windows when we are using a mix of scales
At the moment a streamed screen when the screen scale was differnt
buffer scale would render wrong. This change addresses it by
compensating it.

This change compensates it resizing the rendered viewport to their
difference.

BUG: 428594
2021-04-16 17:18:56 +02:00
Aleix Pol
01f7ef35e7 drm: Make sure we read all pending udev events 2021-04-15 15:00:52 +00:00
Aleix Pol
b49c7497fa --warning: remove unused class member 2021-04-15 16:40:38 +02:00
Xaver Hugl
888a08530e Make DrmObject::Property flags const 2021-04-15 11:16:18 +00:00
David Edmundson
ab34fa348c Follow kwindoweffects::windowSizes deprecation 2021-04-15 05:55:46 +00:00
Alois Wohlschlager
59f6b77612
Fix crash when stopping PipeWire streaming
The stream object was deleted from a slot connected to its stopStreaming
signal. This is unsafe and can lead to memory corruption and ultimately
crashes when PipWwire streaming is stopped. Use deleteLater instead.

BUG: 428268 435588
2021-04-13 10:28:15 +02:00
Xaver Hugl
a461ff918d platforms/drm: replace dpms property hack with proper check
Instead of marking the dpms property as immutable, read the
DRM_MODE_PROP_ATOMIC flag and only add atomic properties to
atomic requests.
2021-04-12 19:30:17 +02:00
Xaver Hugl
18f857b1f3 platforms/drm: fix crash with multi-gpu 2021-04-11 20:52:08 +02:00
Vlad Zahorodnii
e88033f914 wayland: Fix blank window thumbnails
With the introduction of stripped down window items, the WindowPixmap
objects no longer form a hierarchy. WindowPixmap::children() method was
removed.

Surprisingly, the removal of the children() method didn't result in a
compilation error because the QObject class has a method with the same
name.

Currently, a window pixmap will have no QObject children even if the
associated wayland surface has child sub-surfaces. This may result in
blank thumbnails of apps that use sub-surfaces, e.g. Firefox. In order
to fix that issue, we need to check if there are child items instead.
2021-04-08 22:15:33 +03:00
Vlad Zahorodnii
24d865ea38 wayland: Generate valid output uuids
Currently, kwin generates invalid output uuids.
2021-04-08 19:04:17 +00:00