Commit graph

48 commits

Author SHA1 Message Date
Vlad Zahorodnii
e83af181f7 Remove some code duplication in cursor layer code
Move some generic properties to the OutputLayer class and add a cursor
layer getter in the RenderBackend class. That allows us to get rid of
some code duplication. And we could use this work to move more cursor layer
code from backends to Compositor.
2023-01-20 08:22:18 +00:00
Vlad Zahorodnii
9f100e8292 core: Make Output::setCursor() take CursorSource
It decouples the contents of the cursor from QImage.
2023-01-04 09:19:12 +00:00
Xaver Hugl
f6b6d3051b use std::chrono::microseconds for time in input events 2022-12-21 21:07:15 +01:00
Xaver Hugl
f90ec209d4 core/renderlayerdelegate: remove QObject parent
Managing an object with both std::unique_ptr and a QObject parent at the
same time is unnecessary and potentially dangerous
2022-12-20 23:38:46 +01:00
Vlad Zahorodnii
23bef7601e core: Move surface texture factory functions to RenderBackend
The goal is to create surface items for things that are not in the
workspace scene. RenderBackend perhaps is not a great place for these
factory functions. On the other hand, this change merely rewires code
from Scene to RenderBackend. I think that in distant future we could
make surface items pick surface texture type on their own, for what it's
worth that's what we would do in QtQuick.
2022-12-17 21:35:40 +00:00
Xaver Hugl
3204d6ac3c port all headers to pragma once 2022-12-16 20:58:17 +00:00
Vlad Zahorodnii
f7a8635b10 Move scene related bits into src/scene/ directory
We've got quite a few scene related files, move them in a directory to
group related code together.
2022-12-16 19:15:35 +00:00
Xaver Hugl
2a6e3b7ad8 core/outputconfiguration: use std::weak_ptr for storing the mode
Otherwise an unplugged output can cause use-after-free problems on OutputChangeSet
destruction
2022-12-14 15:33:02 +01:00
Xaver Hugl
20b94c9025 wayland/outputmanagement: reject configurations if outputs change
The meaning of the request is questionable after an output gets added
or removed, and it's an easy way to prevent dangling pointers.

BUG: 460953
2022-12-10 00:39:19 +01:00
Vlad Zahorodnii
35a99ec9ad Add explicit output cursor manipulation api
Currently, output backends track the cursor behind the scenes. This
results in some amount of code duplication, for example the handling of
hidden cursors, every backend handles in its own unique way, some don't
do it correctly. Another issue is that output backend interact with
other components behind the back. This can be a problem for tasks such
as backing the cursor with an output layer.

This change introduces explicit output cursor manipulation APIs in the
Output class. There's a good chance that it's going to be revised more
in the future as part of streamlining output layer manipulation apis.

With the proposed changes, the workspace would need to call
Output::setCursor() or Output::moveCursor() to set/unset or move the
cursor, respectively.
2022-12-07 12:05:26 +02:00
Xaver Hugl
bd26f57e18 backends/drm: allow using both adaptive sync and tearing at the same time
The driver will translate that to adaptive sync in the vrr range, and tearing
above it
2022-12-06 11:49:59 +00:00
Xaver Hugl
909378e6fd kcmkwin/kwincompositing: add option to toggle tearing on Wayland 2022-12-05 12:52:18 +00:00
Xaver Hugl
b85550ab41 backends/drm: use tearing presentation where possible and appropriate 2022-12-05 12:52:18 +00:00
Aleix Pol
df77fcd9e0 x11window: Calculate the native floor from the begining of the output
If this function is useful to make sure we are properly aligned with the
output's pixels, we should start with the output's 0, otherwise we'll be
carrying over the rounding errors increasingly as our workspace grows.

BUG: 459373
2022-11-21 14:16:33 +00:00
Xaver Hugl
cdeacdbdad backends/libinput: update screens on Workspace::outputsChanged
Using OutputBackend::outputsQueried can cause problems because it's emitted
before output settings like enablement get adjusted to the new output configuration.
It also doesn't react to output changes initiated by KScreen and is in the
way of plans to use multiple output backends at the same time.

BUG: 461901
2022-11-21 14:25:24 +01:00
Vlad Zahorodnii
8655cc76e8 core: Drop initial window state properties in OutputBackend
Relevant output backends take these properties using their (xyz)Options
struct now.
2022-11-17 14:20:44 +00:00
Vlad Zahorodnii
be3146873f core: Drop OutputBackend::isReady()
OutputBackend has a concept of readiness. When the host compositor goes
down, the OutputBackend will be marked as not ready, and when it
reappears, the output backend will be marked ready again.

On the other hand, host compositor going down is a niche case, it's not
something that often happens and it's hard to justify adding more moving
parts to the startup code. It's easier to call initialize() and check
whether it fails rather than call initialize() and then monitor isReady.

Therefore, this change drops OutputBackend::isReady() to make startup
simpler.
2022-11-16 14:47:25 +00:00
Xaver Hugl
65e886cde2 backends/drm: support the panel orientation property 2022-11-15 13:25:19 +00:00
Vlad Zahorodnii
b830d408af core: Rename Platform to OutputBackend 2022-11-10 10:10:28 +02:00
Vlad Zahorodnii
72883df2aa core: Move workspace bits from Platform to Application
Platform will become OutputBackend so some workspace bits, e.g. the
effects handler, have to move a layer above.
2022-11-10 10:10:28 +02:00
Vlad Zahorodnii
f1369a40f9 core: Drop Platform::supportsNativeFence()
Use Scene::supportsNativeFence() directly.
2022-11-10 10:10:28 +02:00
Vlad Zahorodnii
5762b9a4cc core: Drop Platform::supportsGammaControl()
If the platform doesn't support setting gamma ramps, let the request
fail. In long term, we need a software fallback too so this property is
not that relevant.
2022-11-05 09:03:39 +00:00
Vlad Zahorodnii
084f92bd7a backends/x11: Make OverlayWindow factory function private to the backend
The concept of an overlay window is specific to X11 and it's not present
on other platforms.
2022-11-05 08:44:58 +00:00
Vlad Zahorodnii
78ed1e2add Move OpenGL safe point handling to Compositor/CompositorX11
It's not something that output backends care about, so move it to
Compositor.
2022-11-03 12:09:16 +00:00
Vlad Zahorodnii
364c2f3a14 Drop Platform::requiresCompositing()
It doesn't seem to be used elsewhere other than
Options::isUseCompositing(), which is quite X11-specific.
2022-11-03 12:09:16 +00:00
Vlad Zahorodnii
c76563b174 core: Drop Platform::warpPointer()
It's odd to manipulate host cursor position and it's not highly
important, for example we haven't had a need to warp the cursor on
wayland.

The main motivation behind this change is to slim down the Platform to
make it more output oriented.
2022-11-03 10:35:30 +00:00
Xaver Hugl
84635c71ec plugins/screencast: centralize format querying into the RenderBackend
BUG: 460563
2022-11-02 17:10:10 +01:00
Vlad Zahorodnii
29188eb7b2 Move InputDevice::{outputName,setOutputName} implementation to cpp file
Removes the need for Q_UNUSED macro.
2022-10-31 19:07:30 +00:00
Vlad Zahorodnii
7fffe99328 build: Add -Wno-unused-parameter compiler option
Due to being a compositor, kwin has to conform to some certain
interfaces. It means a lot of virtual functions and function tables to
integrate with C APIs. Naturally, we not always want to use every
argument in such functions.

Since we get -Wunused-parameter from -Wall, we have to plumb those
unused arguments in order to suppress compiler warnings at the moment.

However, I don't think that extra work is worth it. We cannot change or
alter prototypes in any way to fix the warning the desired way. Q_UNUSED
and similar macros are not good indicators of whether an argument is
used too, we tend to overlook putting or removing those macros. I've
also noticed that Q_UNUSED are not used to guide us with the removal no
longer needed parameters.

Therefore, I think it's worth adding -Wno-unused-parameter compiler
option to stop the compiler producing warnings about unused parameters.
It changes nothing except that we don't need to put Q_UNUSED anymore,
which can be really cumbersome sometimes. Note that it doesn't affect
unused variables, you'll still get a -Wunused-variable compiler warning
if a variable is unused.
2022-10-31 15:50:37 +00:00
Aleix Pol
47c3c2d143 libinput: Support switching the targetted output with a shortcut
I was told it's how artists are used to using these tablets so it makes
sense to support the workflow.
2022-10-29 22:30:03 +00:00
Vlad Zahorodnii
8fa1883cd9 effects/invert: Make it fully responsible for inverting the screen
The X11 standalone backend has an obscure fallback to hw screen
inversion if compositing is disabled. While it's great, it conflicts
with existing features such as night color.

In order to make code cleaner and clean up dependencies, this change
moves screen inversion shortcut to the invert effect. While it can
potentially affect users that don't use compositing, I think the number
of such affected people is very small.

In hindsight, preferring hw over sw transform is nice, but I think we
need to analyze it first and then come up with a proper solution that
integrates with color management and works great both on x11 and wayland.
2022-10-26 18:18:36 +03:00
Vlad Zahorodnii
daa351a398 Remove KGlobalAccel bits from Platform
With the addition of KGlobalAccel::globalShortcutActiveChanged(),
there's a way to monitor all triggered actions without adding any
boilerplate code.

This change removes the KGlobalAccel bits from the Platform class. This
reduces the amount of boilerplate code; currently we need to be careful
about ensuring that Platform::setupActionForKGlobalAccel() is called.
Another reason behind this change is to simplify the api of Platform and
remove things that don't have anything to do with outputs.
2022-10-26 07:04:47 +00:00
John Brooks
a1191bea18 wayland: Fix missing relative motion events
Use isNull on QSizeF to check for a zero delta instead of comparing it
with a default-constructed QSizeF, which in practice initializes to
(-1.0,-1.0). This caused relative motion events to be omitted if the
delta happened to be equal to (-1.0,-1.0), causing mouse jumping in some
applications.

BUG: 444510

Signed-off-by: John Brooks <john@fastquake.com>
2022-10-25 08:18:45 +00:00
Vlad Zahorodnii
5a227bf69d Make Compositor responsible for locking compositing type
It's something that Compositor cares, not necessarily the output backend.
2022-10-24 08:02:27 +00:00
Xaver Hugl
ceae717500 output: don't round geometry as often
CCBUG: 459373
2022-10-23 20:06:38 +00:00
Volker Krause
0ce90f4335 Add Qt 6 Linux CI
The CI now has the ability to limit the passing unit test requirements
to more specific platform configurations, so the not yet working Qt 6
unit tests shouldn't block this anymore.
2022-10-21 20:25:10 +00:00
Xaver Hugl
e9e97e49bf backends/drm: set drm content type when available 2022-10-20 13:46:58 +02:00
Xaver Hugl
b99ae81b08 wayland: implement the content-type protocol 2022-10-20 13:46:58 +02:00
Vlad Zahorodnii
c147340878 wayland: Add support for high resolution scrolling
In libinput 1.19, three new pointer axis events were added in order to
provide support for high-resolution scrolling.

LIBINPUT_EVENT_POINTER_AXIS is de-facto deprecated and new users of
libinput should use instead SCROLL_WHEEL, SCROLL_FINGER, and
SCROLL_CONTINUOUS.

Discrete deltas were replaced with v120 delta values. 120 corresponds to
a single discrete delta. Smaller values correspond to "partial" wheel
ticks.

https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/72
2022-10-11 14:04:13 +03:00
Vlad Zahorodnii
f950cbd3d1 Move Platform::updateX11Time() to Application
Platform can be viewed as an output backend and updating X11 time has
nothing common with that.
2022-10-11 06:43:25 +00:00
Xaver Hugl
e482556d58 screenedge: modernize some code 2022-10-07 14:50:10 +02:00
Vlad Zahorodnii
d32aebb747 Lower severity of "Got invalid timestamp" message
BUG: 459405
2022-09-20 10:59:08 +03:00
Xaver Hugl
297971006b backends/x11: port away from most remaining manual memory management 2022-09-12 20:55:32 +00:00
Vlad Zahorodnii
d1de19e212 Make Workspace process batched output updates
Currently the Workspace processes output updates as they occur, e.g.
when the drm backend scans connectors, the Workspace will handle
hotplugged outputs one by one or if an output configuration changes the
mode of several outputs, the workspace will process output layout
updates one by one instead of handling it in one pass. The main reason
for the current behavior is simplicity.

However, that can create issues because it's possible that the output
layout will be temporarily in degenerate state and features such as
sticking windows to their outputs will be broken.

In order to fix that, this change makes the Workspace process batched
output updates. There are several challenges - disconnected outputs have
to be alive when the outputsQueried signal is emitted, the workspace
needs to determine what outputs have been added or removed on its own.
2022-09-12 08:03:48 +00:00
Vlad Zahorodnii
e0945886ed Rename Platform::screensQueried() to Platform::outputsQueried()
It makes the vocabulary consistent. We use the word "output" more than
"screen."
2022-09-12 08:03:48 +00:00
Vlad Zahorodnii
d8ea87a9ea Add dummy placeholder output type
Placeholder outputs are not rendered so they don't need render data.
Also, this simplifies the control flow when the last real output is
removed. The Platform::screensQueried signal won't be emitted inside a
Platform::screensQueried slot.
2022-09-06 10:36:33 +00:00
Vlad Zahorodnii
1b5814c0f2 Remove unused core/platform.h includes 2022-09-06 11:21:40 +03:00
Vlad Zahorodnii
d2fb4147fc Move multi-purpose code in its own directory
Things such as Output, InputDevice and so on are made to be
multi-purpose. In order to make this separation more clear, this change
moves that code in the core directory. Some things still link to the
abstraction level above (kwin), they can be tackled in future refactors.
Ideally code in core/ should depend either on other code in core/ or
system libs.
2022-09-06 11:21:40 +03:00