Commit graph

446 commits

Author SHA1 Message Date
Xaver Hugl
1464028934 backends/drm: use FileDescriptor class for drm buffer fds 2022-08-11 21:27:33 +02:00
Xaver Hugl
6cd4d69644 dmabuf: make use of FileDescriptor class 2022-08-11 21:27:33 +02:00
Vlad Zahorodnii
c7293d95e0 backends/{x11,virtual}: Allocate render data for all available outputs
This makes the behavior of virtual and x11 backend consistent
with the drm and the wayland backend and reduces the number of users of
the Platform::outputEnabled signal.
2022-08-11 12:39:51 +00:00
Xaver Hugl
9f41620b77 backends/drm: don't crash if beginFrame fails
CCBUG: 455532
2022-08-09 22:18:58 +02:00
Nicolas Fella
9a34ebbffc [x11] Refactor output updates
The current code has multiple index-based for loops iterating over items we get from XCB

Dealing with raw indices is error-prone and not pretty

By using std::span we can replace these loops with range-based for loops

Also remove some intermediate containers that aren't neccesary
2022-08-06 02:26:39 +00:00
Xaver Hugl
97939ceae8 backends/drm: fix blob updating
Two things about the code were wrong:
1. m_current is used in updateBlob() but was only updated afterwards
2. the assumption that the property having the same ID means it has the
same blob contents is not always true

BUG: 449285
2022-08-04 15:48:32 +00:00
Xaver Hugl
8955a2420e replace all uses of QScopedPointer with std::unique_ptr 2022-08-04 12:30:09 +00:00
Xaver Hugl
43b78e40d8 screens: move singleton to Workspace 2022-08-02 21:37:41 +00:00
Xaver Hugl
9439e7719d screenedge: move singleton to Workspace 2022-08-02 21:37:41 +00:00
Xaver Hugl
3c56bd9723 refactor Outline and move its singleton into Workspace 2022-08-02 21:37:41 +00:00
Vlad Zahorodnii
c3d5c3db1d x11: Add a helper to get the default screen
Since the screen number is well-known, we can look up the default
screen on demand. Note that xcb_get_setup() is pretty cheap as it
simply returns a const pointer to pre-allocated data.
2022-07-29 14:15:12 +00:00
Nicolas Fella
e0a6d02984 [x11] Fix loading monitor edid
i is the counter for the crtc loop, not the monitor loop

This fixes loading the edid for all monitors and thus the output identifier effect
2022-07-29 01:41:06 +02:00
Vlad Zahorodnii
e604b6852f backends/drm: Remove Compositor dependency
This breaks cyclic dependency between Compositor and DRM backend, there
are still indirect dependencies though. However, fewer cyclic
dependencies should make the architecture more cleaner and easier to
tweak.
2022-07-28 08:56:47 +00:00
Aleix Pol
bbb4c20c8a libinput: Make sure config values get deleted
Switches to a shared pointer rather than a raw one. It would leak, which
in general is not a big problem but it would flood the output when
running tests with ASAN. Also it's the right thing to do.
2022-07-28 07:23:56 +00:00
Vlad Zahorodnii
a513b795ad backends/wayland: Fix a crash on shutdown
The wayland backend changes the dpms mode when the enabled state of the
output changes. This creates problems when destroying all outputs on
shut down. The wayland backend calls InputRedirection's methods, but
InputRedirection is already destroyed by that time.

While the crash can be fixed by guarding input() in createDpmsFilter()
with an if statement, changing dpms mode in updateEnablement() doesn't
seem like a good idea because Output changes unrelated states (enabled !=
dpms mode), so let's get rid of it.
2022-07-28 07:02:16 +00:00
Vlad Zahorodnii
a198516871 Drop Platform::enabledOutputs()
At the moment, a platform should provide two output lists - one that
lists all available outputs, and the other one that contains only
enabled outputs. In general, this amounts to some boilerplate code and
forces backends to be implemented in some certain way, which sometimes
is inconvenient, e.g. if an output is disabled or enabled, it will be
simpler if we only change Output::isEnabled(), otherwise we need to
start accounting for corner cases such as the order in which
Output::isEnabled() and Platform::enabledOutputs() are changed, etc.
2022-07-27 09:22:10 +00:00
Vlad Zahorodnii
2629007eef Make outputs disabled by default
This can be used to make our backends more multi-purpose. At the moment,
new outputs are enabled by default, but it makes sense to do otherwise.

For example, if an output is disabled by default, it would be possible
to delegate initial output configuration to layer above, to kwin.

In long term, the drm backend would need to scan connectors, create an
Output for every one of them, kwin sees new outputs and tries to apply
the initial output configuration, which includes the enabled status.
2022-07-27 09:22:10 +00:00
Vlad Zahorodnii
3ce24a0cbf Make OutputConfiguration take OutputMode
OutputMode provides a more robust way to refer to outputs. A mode can
have flags and things as such that are not taken into account with mode
+ refresh rate.
2022-07-27 07:26:48 +00:00
Xaver Hugl
5e602434c0 backends/drm: fix memory leak 2022-07-26 19:41:51 +00:00
Xaver Hugl
4be81e0176 backends/drm: make modeset tests explicit
Instead of checking for properties needing a modeset, do atomic tests
with ALLOW_MODESET where it makes sense, and do a second atomic test
afterwards without ALLOW_MODESET to check if the modeset can be skipped.

This should ensure that KWin always does a modeset when it needs to do one,
 and not do a modeset when it's not necessary. Doing this also allows
reducing the complexity of the drm backend a bit.
2022-07-26 19:03:33 +00:00
Vlad Zahorodnii
71a58231e8 backends/drm: Make DrmOutput::queueChanges() not touch active status
The DrmOutput synchronizes the enabled state with the active state,
which makes sense on one hand, but on the other hand, that's not good.
The drm backend makes a decision that should be ideally made by either
kscreen (turn on outputs before applying an output config), user, or
kwin itself.

This would also allow kwin to control the allocation of crtcs for
non-desktop outputs, which is a minor thing, but it might be useful in
the future.
2022-07-26 13:40:29 +00:00
Xaver Hugl
361fc0a38e backends/drm: remove drm lease layers
They just add more code and more potential problems, and the difference in
VRAM usage is very minimal
2022-07-26 09:57:06 +02:00
Xaver Hugl
b7d7a99fcb backends/drm: fix placeholder output check
Non-desktop outputs must be ignored
2022-07-26 07:06:30 +00:00
Aleix Pol
27f24d1449 input: Introduce a outputArea property for tablet devices
It's important for tablet devices to be able to specify to which section
of the display we'll be fitting the tablet. This setting allows to
specify this by providing some options that will do so relative to the
output size.

CCBUG: 433045
2022-07-25 23:29:07 +00:00
Vlad Zahorodnii
1b4258bf17 kwineffects: Move infiniteRegion() to kwinglobals.h
infiniteRegion() is useful not only to effects but also other kwin
components, so move it to kwinglobals.h in order to make backends stop
depending on libkwineffects
2022-07-25 10:52:03 +03:00
Vlad Zahorodnii
1baf39daf7 backends/drm: Improve device seat assignment handling
This fixes the drm backend adding hotplugged gpus that belong to other
seats and makes the udev helper depend on less stuff from the layer
above backends.
2022-07-24 19:36:50 +03:00
Vlad Zahorodnii
cf3fe003e6 Move ownership of Session to Application
The Session can be useful not only to the platform backend but also
input backends and for things such as vt switching, etc. Therefore it's
better to have the Application own the Session.
2022-07-24 19:14:26 +03:00
Vlad Zahorodnii
5e669aece9 backends/libinput: Take Session explicitly
The API will be more clear about what the libinput backend needs.
2022-07-24 19:14:26 +03:00
Vlad Zahorodnii
36e238cda5 backends/drm: Remove EdidOverwrite config option
This is a too niche feature. It also doesn't have to be implemented in
the compositor. The kernel provides a way to overwrite the edid blob,
which is not specific to the running compositor.
2022-07-24 15:37:44 +00:00
Vlad Zahorodnii
96f3a5eec2 backends/drm: Fix dangling connectors in m_allObjects
We add connectors to m_allObjects but never remove them.

CCBUG: 457002
2022-07-24 14:20:12 +00:00
Vlad Zahorodnii
5aef41663a backends/drm: Fix potential use-after-free
When the output is removed, there are legit cases when the connector can
be still accessed.

CCBUG: 457002
2022-07-24 14:20:12 +00:00
Xaver Hugl
f0d59b078b backends/drm: explicitly initialize all fields of drmModeModeInfo 2022-07-24 13:49:54 +00:00
Xaver Hugl
bf6990da45 backends/x11/windowed: rename files to be more consistent 2022-07-24 13:05:13 +00:00
Xaver Hugl
2420949628 backends/x11/common: rename files to be more consistent 2022-07-24 13:05:13 +00:00
Xaver Hugl
ff0e89b030 backends/x11/standalone: rename files to be more consistent 2022-07-24 13:05:13 +00:00
Xaver Hugl
d251d33402 backends/drm: rename files to be more consistent 2022-07-24 13:05:13 +00:00
Xaver Hugl
24b1eab228 backends/wayland: rename files to be more consistent 2022-07-24 13:05:13 +00:00
Xaver Hugl
9d3561faf8 backends/virtual: rename files to be more consistent 2022-07-24 13:05:13 +00:00
Vlad Zahorodnii
045da603a4 Make backends part of libkwin
Platform backends are provided as plugins. This is great for
extensibility, but the disadvantages of this design outweigh the
benefits.

The number of backends will be limited, it's safe to say that we will
have to maintain three backends for many years to come - kms/drm,
virtual, and wayland. The plugin system adds unnecessary complexity.

Startup logic is affected too. At the moment, platform backends provide
the session object, which is awkward as it starts adding dependencies
between backends. It will be nicer if the session is created depending
on the loaded session type.

In some cases, wayland code needs to talk to the backend directly, e.g.
for drm leasing, etc. With the plugin architecture it's hard to do that.
Not impossible though, we can approach it as in Qt 6, but it's still
harder than linking the code directly.

Of course, the main disadvantage of shipping backends in a lib is that
you will need to patch kwin if you need a custom platform, however such
cases will be rare.

Despite that disadvantage, I still think that it's a step in the right
direction where the goal is to have multi-purpose backends and other
reusable components of kwin.

The legacy X11 standalone platform is linked directly to kwin_x11
executable, while the remaining backends are linked to libkwin.
2022-07-23 11:52:42 +00:00
Vlad Zahorodnii
0fbd5fa377 backends/virtual: Provide own logging.h file
target_sources() doesn't work as expected with generated source files.
2022-07-23 11:52:42 +00:00
Vlad Zahorodnii
82c1cf3de2 backends/drm: Pass DrmGpu to page flip handler through user data
The page flip handler can be simpler if it gets the gpu through user
data. It also removes a usage of the Application singleton.
2022-07-22 12:02:47 +00:00
Vlad Zahorodnii
211d0c00fc Remove unused main.h includes 2022-07-22 13:13:14 +03:00
Xaver Hugl
4121d45c42 backends/libinput: remove global state 2022-07-21 15:16:40 +02:00
Vlad Zahorodnii
0a7661c9df backends/drm: Remove DrmGpu::{outputEnabled,outputDisabled}
They are unused.
2022-07-21 12:35:51 +00:00
Vlad Zahorodnii
724d6761cd backends/drm: Store desktop and non-desktop outputs in the same list
Now, the drm backend exposes all outputs. It's the job of the workspace
layer to filter out outputs it's not interested in.
2022-07-21 08:43:50 +00:00
Vlad Zahorodnii
8dabeb4709 backends/drm: Use DrmOutput to represent non-desktop outputs too
The main motivation behind this change is to make the drm backend
multi-purpose. That's it, to make it suitable for implementing all kinds
of compositors. At the moment, there's an artificial split between
"desktop" and "non-desktop" outputs, i.e. VR headsets, which stands in
the way of that and moving the remaining wayland code out of the drm
backend for better layering and architecture.
2022-07-21 08:43:50 +00:00
Vlad Zahorodnii
8f2748b1e1 Move udev.{h,cpp} to src/utils 2022-07-20 12:31:32 +03:00
David Redondo
499474ed66 Fetch and parse EDIDs on X11
This allows us to get more information about the outputs like vendor
and model and for example provide them to effects which might find
the extra info useful.
2022-07-20 07:01:05 +00:00
Vlad Zahorodnii
dd9b4aa37a backends/x11: Remove AbstractEglBackend::setSurface() call
KWin requires surfacesless contexts, so this setSurface() is not needed.
This ensures that makeCurrent() won't make the opengl context current
against a surface that belongs to a removed output.
2022-07-19 18:56:12 +00:00
Vlad Zahorodnii
42285bc659 backends/wayland: Remove AbstractEglBackend::setSurface() call
KWin requires surfacesless contexts, so this setSurface() is not needed.
This ensures that makeCurrent() won't make the opengl context current
against a surface that belongs to a removed output.
2022-07-19 18:56:12 +00:00
Vlad Zahorodnii
b81f16fbd5 x11: Remove unused field in EglOnXBackend 2022-07-19 17:19:40 +03:00
Vlad Zahorodnii
4dd9b0f15b x11: Drop support for multi-head
The main reason to drop multi-head support is that it has been simply
unmaintained for many many years. When implementing a feature, we don't
even bother checking if multi-head is broken, KCMs don't handle
multihead, window management features are written for Xinerama. KWin
is optimized for Xinerama-like operation mode in general, which is
provided out of the box.

If you use multihead for esoteric gpu stuff, consider using kwin_wayland!
2022-07-19 11:44:00 +00:00
Vlad Zahorodnii
faa006d76f backends/x11: Manage X11WindowedQPainterOutput using std::unique_ptr 2022-07-19 07:51:46 +00:00
Vlad Zahorodnii
c74fa4b571 backends/x11: Port windowed backend from Screens 2022-07-19 07:51:46 +00:00
Xaver Hugl
61b1eac5b8 platform, scenes: use std::unique_ptr for creation functions 2022-07-18 14:26:26 +00:00
Xaver Hugl
f50547de1e backends/drm: manage drm objects with std::unique_ptr
Also makes the connector detection code a bit more readable
2022-07-18 14:26:26 +00:00
Xaver Hugl
affa7386f8 backensd/drm: manage gpus with std::unique_ptr 2022-07-18 14:26:26 +00:00
Xaver Hugl
32c2ae15a4 backends/drm: manage drm properties with std::unique_ptr 2022-07-18 14:26:26 +00:00
Vlad Zahorodnii
64c71a37a0 backends/virtual: Use #pragma once 2022-07-18 08:36:04 +00:00
Vlad Zahorodnii
f80a14d4f6 backends/virtual: Make render backend naming consistent 2022-07-18 08:36:04 +00:00
Vlad Zahorodnii
5bf1332df5 backends/wayland: Use #pragma once 2022-07-18 08:36:04 +00:00
Vlad Zahorodnii
a56b09ab9d backends/wayland: Make render backend naming consistent 2022-07-18 08:36:04 +00:00
Vlad Zahorodnii
6db530bfde backends/x11: Use #pragma once 2022-07-18 08:36:04 +00:00
Vlad Zahorodnii
8dd719e4e2 backends/x11: Make render backend naming consistent 2022-07-18 08:36:04 +00:00
l10n daemon script
131b9d226a 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"
2022-07-17 01:46:18 +00:00
Xaver Hugl
636b411b31 backends/drm: don't crash if importing a texture fails
CCBUG: 456500
2022-07-15 13:42:48 +00:00
Aleix Pol
39f45ad70f WaylandOutput: Remove unused rendered attribute 2022-07-15 14:58:42 +02:00
Vlad Zahorodnii
d6646d25d0 Remove unused screens.h includes 2022-07-14 09:51:18 +03:00
Xaver Hugl
7f04ea578f backends/drm: handle broken legacy drivers better
Some legacy drivers either don't accept gbm buffers suitable for cursors,
or don't handle them properly. In order to work around that, always do a
CPU import with legacy and use dumb buffers instead.

BUG: 453860
CCBUG: 456306
2022-07-13 21:10:19 +02:00
Vlad Zahorodnii
5be18da8ac backends/virtual: Remove unused includes 2022-07-13 16:01:46 +00:00
Vlad Zahorodnii
728e369a4d backends/virtual: Remove eglSwapBuffers() call
It's noop, we use EGL_MESA_platform_surfaceless.
2022-07-13 16:01:46 +00:00
Xaver Hugl
9ac3c64d4c wayland/drmlease: split up DrmLeaseV1Interface::deny 2022-07-13 12:27:54 +00:00
Xaver Hugl
919b56e9a2 drmlease: send device done event correctly 2022-07-13 12:27:54 +00:00
Vlad Zahorodnii
71bfbe815c backends/virtual: Manage VirtualQPainterLayer using std::unique_ptr 2022-07-13 11:07:18 +00:00
Vlad Zahorodnii
26d4a06818 backends/virtual: Port from Screens 2022-07-13 11:07:18 +00:00
Vlad Zahorodnii
b3d3ca8c0f backends/drm: Remove unused screens.h includes 2022-07-13 10:21:44 +00:00
Vlad Zahorodnii
7d00766629 backends/drm: Make drm backend not touch output configuration if all outputs are disabled
This behavior was added in order to fix a crash reported in bug report
442990. However, the analysis was not 100% correct, kwin failed to
create a placeholder because the relevant check was incorrect. The drm
backend was checking the list of all connected outputs rather than the
list with enabled outputs to decide whether to create a placeholder output.

As a safety measure the proposed behavior makes sense, however the drm
backend is not the right layer to implement it. If the last enabled
output is disconnected, kscreen should view it as a new output
setup and re-enable outputs in order to ask user what desired output
configuration should be.
2022-07-12 09:54:50 +00:00
Xaver Hugl
0d302d5c66 backends/drm: also check for properties in DrmPipeline::needsModeset
Otherwise we may be missing situations where a modeset is needed

BUG: 455814
2022-07-11 14:31:55 +00:00
Xaver Hugl
2d43f3eee2 backends/drm: handle disconnected but not removed connector objects properly
The kernel doesn't disable connector objects that represent physical ports
when the output gets removed. If KWin tries to change the output configuration
without explicitly disabling the connector, atomic commits can fail.
2022-07-10 11:55:57 +00:00
Xaver Hugl
7d5d35928f backends/drm: don't create a new output every time 2022-07-06 09:52:49 +00:00
Xaver Hugl
a71146c999 backends/drm: don't remove connectors the kernel doesn't consider removed
Removing connectors that are still powered leads to a mismatch in atomic
commits: the crtc is still powered, but the connector also still there.
If KWin tries to disable the crtc afterwards, the atomic commits fail because
the connector needs to be disabled at the same time and it's missing from the
atomic commit request.

To fix this, whenever we fail to fetch information or get wrong data from
the kernel (like 0 modes), use the cached information instead and keep the
connector.

BUG: 456298
2022-07-05 19:11:33 +00:00
Aleix Pol
d5ddf55e9b gbm: Don't pass any flags when creating buffers with modifiers
It seems it doesn't bring much and it may backfire. Especially don't
pass GBM_BO_USE_LINEAR as it will limit a lot the buffers that can be
created and GBM_BO_USE_RENDERING use seems to be more harmful than
helpful on most cases.
2022-07-04 22:52:40 +00:00
l10n daemon script
c0307bb402 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"
2022-07-02 02:03:09 +00:00
Xaver Hugl
0c453739b1 backends/drm: fix common mode generation
The unit for refresh rate was wrong, which caused insanely high as well
as negative refresh rates

BUG: 455477
2022-06-29 20:53:55 +02:00
Xaver Hugl
da7dad1586 surfaceitem, surfacetexture: manage pixmaps and textures with std::unique_ptr 2022-06-29 13:18:51 +00:00
Xaver Hugl
1ff623e95e renderbackends: make SurfaceTexture creation methods use std::unique_ptr 2022-06-29 13:18:51 +00:00
Xaver Hugl
ef97158f96 backends/drm: suppress logging for direct scanout
BUG: 456089
2022-06-29 09:59:10 +02:00
Xaver Hugl
29625218d3 backends/drm: fix flicker with rotation on mobile
When we use a shadow buffer, we always render to the whole surface - setting
the damage region is incorrect and invokes undefined behavior. On the Lima
driver this caused flickering on screen rotation.
To fix this, don't set a damage region when we use a shadow buffer, which is
effectively setting the damage region to the full surface
2022-06-28 08:38:43 +00:00
Xaver Hugl
47c08d6f66 backends/drm: ensure modeset properties are reset properly
Without this, all atomic modeset commits fail on setups with a VR headset
2022-06-27 19:14:08 +00:00
Xaver Hugl
42c5e6bcf6 backends/drm: handle failing commits better
It can happen that the drm backend temporarily lacks permission to do atomic
commits, or that the cached drm property values become out of sync with
the real values held by the kernel. Instead of failing with both, attempt
to update property values and try the commits again at a later time.
2022-06-25 17:25:17 +02:00
Marco Martin
66a54d38d4 effects: Set timestamp for input events
Set the time for mouse and touch events. This is especially important
for the mouse is as the timestamp will be used to discriminate between
single and double click. Previously this was always sending the double
click event, making buttons work only every other click.

BUG: 454275
BUG: 449907
2022-06-24 17:54:55 +00:00
Vlad Zahorodnii
b62dd29210 backends/drm: Change the base class of DrmLeaseOutput
At the moment, the DrmLeaseOutput class inherits from the
KWaylandServer::DrmLeaseConnectionV1Interface class. While this works,
it's not a future-proof design. For example, kwin could also lease its
"desktop" outputs in order to let another wayland compositor run
alongside it.

Also, it's a good practice to prefer composition over inheritance.
2022-06-23 19:51:24 +00:00
Laurent Montel
c83568dfdd GIT_SILENT: remove extra ';' 2022-06-23 13:43:09 +02:00
Laurent Montel
d1837b8603 Remove extra ';' 2022-06-23 06:56:25 +02:00
Xaver Hugl
6d9d4c190a backends/drm: fix enabled+inactive check
When dpms disabled outputs get set active, they require a modeset. If after
that they are set inactive again without resetting the pipelines first,
they no longer require a modeset but still have the pending properties that
would enable a crtc - but without a framebuffer set.

To prevent this, first test the current setup as it is, and only then see
if the pipelines would work if enabled again.
2022-06-22 10:22:30 +02:00
Aleix Pol
9dbd0c4b36 backends/wayland: Offer the connector name as the model
It's more useful than ""
2022-06-22 01:54:19 +02:00
Xaver Hugl
3ea14d6e36 backends: use std::unique_ptr for RenderLoop 2022-06-21 17:50:49 +00:00
Xaver Hugl
a38a44cb2a libinput: use std::unique_ptr for events 2022-06-21 17:50:49 +00:00
Xaver Hugl
d2f7f75d39 manage Session with std::unique_ptr 2022-06-21 17:50:49 +00:00
Xaver Hugl
13d079cdd7 backends/x11: do less manual memory management 2022-06-21 17:50:49 +00:00