Commit graph

39 commits

Author SHA1 Message Date
Xaver Hugl
33f3a13a1a wayland: show cursor if stylus is in proximity
While a stylus is in proximity we want to show its cursor. In this commit
it only gets shown on move because for a still unknown reason the position
is out of date before the first move event.

BUG: 443921
2021-11-29 17:37:58 +00:00
Vlad Zahorodnii
48f943bd75 Introduce explicit base render backend type
The main idea behind the render backend is to decouple low level bits
from scenes. The end goal is to make the render backend provide render
targets where the scene can render.

Design-wise, such a split is more flexible than the current state, for
example we could start experimenting with using qtquick (assuming that
the legacy scene is properly encapsulated) or creating multiple scenes,
for example for each output layer, etc.

So far, the RenderBackend class only contains one getter, more stuff will
be moved from the Scene as it makes sense.
2021-11-11 08:55:29 +00:00
Aleix Pol
bfe5c73541 Install the org.kde.KWin.TabletModeManager.xml 2021-11-10 14:20:56 +00:00
Xaver Hugl
e2a0863843 platforms/drm: more dynamic crtc assignment
Hardware constraints limit the number of crtcs and which connector + crtc
combinations can work together. The current code is searching for working
combinations when a hotplug happens but that's not enough, it also needs
to happen when the user enables or disables outputs and when modesets are
done, and the configuration change needs to be applied with a single atomic
commit.

This commit removes the hard dependency of DrmPipeline on crtcs by moving
the pending state of outputs from the drm objects to DrmPipeline itself,
which ensures that it's independent from the set of drm objects currently
used. It also changes requests from KScreen to be applied truly atomically.
2021-11-09 22:15:31 +01:00
Vlad Zahorodnii
aead97c39f Move scenes to the src directory
Similar to the backends, it's far more intuitive to have scenes in the
toplevel source directory rather than the plugins directory.
2021-11-08 10:22:07 +00:00
Vlad Zahorodnii
94de28bfbe Move input backends in their own directory 2021-11-01 16:27:16 +02:00
Vlad Zahorodnii
7f72e5627e wayland: Port fake input integration to InputDevice
This ensures that the cursor will be properly shown/hidden when a fake
pointer is added on a system with no physical pointer connected.
2021-11-01 16:27:16 +02:00
Vlad Zahorodnii
ef72bae42f Introduce base InputDevice class
The main motivation behind this change is to prepare input abstractions
for virtual input devices so the wl_seat can properly advertise caps or
the cursor getting properly mapped/unmapped when a fake pointer is
added/removed on a system without a hardware mouse connected.

With this, there are three abstractions - InputDevice, InputBackend, and
InputRedirection.

An InputDevice represents an input device such as a mouse, a keyboard, a
tablet, etc. The InputBackend class notifies the InputRedirection about
(dis-)connected devices. The InputRedirection manages the input devices.

Such design allows to unify the event flow for real and virtual input
devices.

There can be several input backends active. For example, the libinput
backend and an input backend that provides virtual input devices, e.g.
libeis or org_kde_kwin_fake_input.
2021-11-01 16:27:16 +02:00
Vlad Zahorodnii
d73610d6d6 scripting: Introduce VirtualDesktopModel
This can be useful for QML scripts that deal with virtual desktops.

The virtual desktop model keeps a copy of virtual desktop objects to
avoid hitting asserts in QAbstractItemModel (it has some asserts to
ensure that indices passed to beginInsertRows() or beginRemoveRows()
make sense).
2021-10-21 06:27:03 +00:00
Vlad Zahorodnii
141947d2e8 effects: Link builtin effects with executables
The main motivation behind this change is to prepare kwin for importing
kwayland-server code in libkwin.

As is, builtin effects are linked with libkwin. Some builtin effects
have wayland specific code. If we move wayland stuff in libkwin, there's
going to be a circular dependency between kwin4_effect_builtins and
libkwin targets.

This change intends to break that dependency by linking builtin effects
to kwin executable.

The main issue with that is that EffectLoader would need to discover the
effects indirectly. QStaticPlugin is used for that purpose.

Besides breaking the cyclic dependency, it makes builtin effects use the
same plugin infrastructure in libkwineffects that external effects use.

Metadata in src/effects/effect_builtins.cpp was converted in a list of
python dictionaries, which was fed to a python script that generated
main.cpp and metadata.json files.
2021-10-19 09:12:15 +00:00
Vlad Zahorodnii
5be593d4e4 wayland: Drop internal connection
It's practically unused now.
2021-10-07 13:28:08 +00:00
Vlad Zahorodnii
ca1c72dd16 wayland: Fix cross cursor in Xwayland apps
Startup code in plasmashell was changed so xsetroot is not called
anymore, which is sort of fine.

Unfortunately (or not?), it exposed a bug in kwin. Cursor::x11Cursor()
only works in the standalone X11 session.

On Wayland, Cursor::x11Cursor() will return XCB_NONE which results in
seeing cross cursor when there should be arrow cursor.

This change moves xcb_cursor_t look up code from X11Cursor to the base
Cursor class. In hindsight, I would like to introduce a window manager
class where the xcb cursor and other x11 specific code can be moved in
the future for better encapsulation of platform-specific code.

CCBUG: 442539
2021-09-23 13:52:51 +00:00
Méven Car
0a2c511489 Wayland: Add support for protocol kde-output-device_v2, allow to detect drm mode changes
CCBUG: 407058
2021-09-01 13:37:43 +00:00
Vlad Zahorodnii
5435865329 scripting: Introduce ClientModel V3
ClientModel V3 is much easier to extend and maintain than the one in V2.
2021-08-19 06:30:55 +00:00
Vlad Zahorodnii
cecf2ee7a1 scripting: Move old ClientModel in V2 namespace 2021-08-19 06:30:55 +00:00
David Edmundson
f541d851ed [kwin_wrapper] Transfer ownership of Xwayland socket creation and Xauthority to the wrapper
This way if kwin_wayland crashes we don't need to ensure that new
environment variables need to get synced across the new env.

This fixes an issue where spawning an xwayland application from a
wayland window that survives a crash would fail.

By moving the logic here we no longer need to wait for kwin_wayland to
start before starting plasmashell or even ksmserver as all environment
variables are set. As long as the wrapper is ready we can continue
starting and clients will just block on connect.

That should still allow for both a lot of optimisations both for speed
and cleaning up the startplasma-wayland scripts.

This will be addressed in follow up patches.

Use of kwin_wayland directly with xwayland is still supported for
testing.
2021-08-17 09:41:57 +01:00
Aleix Pol
1012adeaf7 Add support to DPMS to the Wayland Backend
Moves the DpmsInputEventFilter to libkwin, so that it can be used by
other backends other than DRM.
This mostly helps develop features around DPMS.
2021-07-09 02:41:26 +02:00
Vlad Zahorodnii
3427143017 Improve thumbnail item integration
Currently, thumbnail items are rendered by kwin. This means that qtquick
code cannot do things such as applying shader effects to window thumbnails
or simply draw custom controls on top of thumbnails.

With this change, task switchers and qml extensions will be able to
place their own contents on top of thumbnails and apply custom effects
to them.

In order to integrate window thumbnails, a window is rendered on kwin
side using its own opengl context. A fence is inserted in the command
stream to ensure that the qtquick machinery doesn't start using the
offscreen texture while there are still rendering commands being executed.

Thumbnails are rendered into offscreen textures as we don't have full
control over when qtquick windows render their contents and to work around
the fact that things such as VAOs can't be shared across OpenGL contexts.

WindowThumbnailItem and DesktopThumbnailItem act as texture providers.
2021-06-23 17:46:05 +03:00
Vlad Zahorodnii
1c94e1bfc4 scenes/opengl: Move out X11 explicit sync
This moves X11 specific code to a better place, which allows us make
item rendering code less platform specific and easier to change.
2021-06-14 13:14:54 +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
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
Aleix Pol
27e043920a xdg_activation_v1 implementation 2021-05-24 17:19:25 +02:00
Vlad Zahorodnii
a18cb8998e wayland: Remove direct session
Most distros use either systemd's logind or consolekit for session
management.

The main reason why there's direct session is because up to some point,
kwin had a class called VirtualTerminal which was kind of like a direct
session backend.

The VirtualTerminal was used in the fbdev backend in conjuction with the
logind session backend, which looked odd.

Since the drm backend supported only logind and consolekit for very
long time and we hadn't received any complaints about it, the fact that
direct session is unsupported should not be noticeable.

Given that, this change removes the support for direct session in order
to reduce the amount of platform-specific code and make it easier to
maintain kwin.
2021-05-24 06:23:00 +00:00
Aleix Pol
3b05823f1f libinput: bump required version
So we can remove ifdefs and weird cases to support versions that are far
too old to support anyway.
2021-05-14 17:47:46 +00:00
Vlad Zahorodnii
c27230719c wayland: Move Wayland-specific code out of AbstractWaylandOutput
Currently, output properties are looked up either on the wl_output
object or the output device object. This puts a hard dependency on the
wayland server in the platforms.

This change intends to fix some flaws in the current output
abstractions, and allow creating/destroying wayland-specific globals as
we wish.

With the work done in this patch, the need for the AbstractWaylandOutput
class is unclear, and it might be a good idea to merge it with the base
AbstractOutput class.
2021-04-07 14:23:16 +03:00
Andrey Butirsky
91f47c9092 fix global shortcuts for non-Latin symbols
Re-use Qt's implementation of handling non-Latin layouts here
For full ASCII range support (Alt+`, etc.) Qt needs to be patched still,
see QTBUG-90611

BUG: 375518
2021-04-05 19:39:06 +00:00
Vlad Zahorodnii
47113e09b8 scene: Introduce window items
Currently, dealing with sub-surfaces is very difficult due to the scene
design being heavily influenced by X11 requirements.

The goal of this change is to re-work scene abstractions to make improving
the wayland support easier.

The Item class is based on the QQuickItem class. My hope is that one day
we will be able to transition to QtQuick for painting scene, but in
meanwhile it makes more sense to have a minimalistic internal item class.

The WindowItem class represents a window. The SurfaceItem class represents
the contents of either an X11, or a Wayland, or an internal surface. The
DecorationItem and the ShadowItem class represent the server-side deco and
drop-shadow, respectively.

At the moment, the SurfaceItem is bound to the scene window, but the long
term plan is to break that connection so we could re-use the SurfaceItem
for things such as software cursors and drag-and-drop additional icons.

One of the responsibilities of the Item is to schedule repaints as needed.
Ideally, there shouldn't be any addRepaint() calls in the core code. The
Item class schedules repaints on geometry updates. In the future, it also
has to request an update if its opacity or visibility changes.
2021-03-31 13:56:55 +00:00
Vlad Zahorodnii
ade861d6de Refactor session code
At the moment, the session code is far from being extensible. If we
decide to add support for libseatd, it will be a challenging task with
the current design of session management code. The goal of this
refactoring is to fix that.

Another motivation behind this change is to prepare session related code
for upstreaming to kwayland-server where it belongs.
2021-03-23 08:01:19 +00:00
David Edmundson
0eb37563e9 Restore script DBus API
The Script class has a DBus API we want to export. At some point this
has got broken and the run method is not exported.

It's a bit messy with script subclasses also having other invokables
that we want to export to scripts, so an adaptor is used to keep things
separated.

The interface name has technically changed, but KWin was doing something
weird and using the same interface names for the manager. Fortunately
calling Plasma code doesn't specify an interface so this still works.
2021-03-09 09:14:13 +00:00
Nicolas Fella
ecd9e1c98d Use imported target for Threads 2021-03-04 15:11:30 +00:00
Aleix Pol
4638f2f309 inputmethod: Refactor VirtualKeyboardDBus to have its own InputMethpd
This way we can have it call methods directly instead of connecting to
its signals.
2021-03-02 13:55:35 +00:00
Aleix Pol
63a7b25801 inputmethod: Provide DBus API so the shell can integrate with it
It makes it possible to show if the virtual keyboard is being shown and
if it is to hide it.
2021-03-02 13:55:35 +00:00
Aleix Pol
b409f523f0 Revert "cmake: Get XKB information directly from PkgConfig"
This reverts commit 3c97cecdb0.

It seems to break on the CI and I don't understand why.
2021-03-02 02:14:39 +01:00
Aleix Pol
3c97cecdb0 cmake: Get XKB information directly from PkgConfig
Rather than having it abstracted in a local FindXKB package.
Makes the code more standard and removes a custom finder we ultimately
don't need.
2021-03-01 20:33:38 +01:00
Vlad Zahorodnii
bd4d17b3a1 Drop QtScript dependency
QtScript is not used anywhere anymore plus it's dropped in Qt 6.
2021-02-23 07:47:01 +00:00
David Edmundson
ae6e6dc63c [scripting] Port ScriptedEffects to QJSEngine
Summary:
QScriptEngine is deprecated for years and suffers bitrot.
Plasma hit one super major bug with it in 5.11.0 and has now ported
away.

Main porting notes:
- creating low level functions no longer exists
The old global functions are exposed on the ScriptedEffect instance
and then the QJSValue wrappers of the globalObject are modified to
trampoline the methods at a wrapper level.

- We can then use QJSEngine to automatically do argument error checking
rather than unmarshalling a QJSValue manually which significantly
reduces a lot of code.

- We can't make FPX2 a native type, so these are QJSValue args and
unboxed there.

Long term I want overloads for animate that take int/QSize/QPoint which
are native JS types, but that might be an API break.

Test Plan:
Hopefully comprehensive unit test which passes
Tested fade/fadeDesktop manually.

It's a very invasive change, so I expect some things will be broke
please help test any JS effects.

Reviewers: #kwin, mart, fvogt

Subscribers: fvogt, zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D14536
2021-02-23 07:47:01 +00:00
Vlad Zahorodnii
566d4aa27b scripting: Port Script to QJSEngine
QtScript is not well maintained and deprecated in favor of QJSEngine.
2021-02-23 07:47:01 +00:00
Vlad Zahorodnii
9f0f452702 xwayland: Manually create sockets
This provides kwin greater control over how X11 sockets are created for
Xwayland. For example, it can be used to ensure that the DISPLAY remains
the same across Xwayland server restarts or launching Xwayland on
demand.

Even though -listen <fd> option is deprecated, we still pass it because
older versions of Xwayland may not have the -listenfd option.
2021-02-11 15:10:01 +00:00
Vlad Zahorodnii
93e0265e4e Move source code to src/ directory
Once in a while, we receive complaints from other fellow KDE developers
about the file organization of kwin. This change addresses some of those
complaints by moving all of source code in a separate directory, src/,
thus making the project structure more traditional. Things such as tests
are kept in their own toplevel directories.

This change may wreak havoc on merge requests that add new files to kwin,
but if a patch modifies an already existing file, git should be smart
enough to figure out that the file has been relocated.

We may potentially split the src/ directory further to make navigating
the source code easier, but hopefully this is good enough already.
2021-02-10 15:31:43 +00:00