Commit graph

19034 commits

Author SHA1 Message Date
Vlad Zahorodnii
6a26540065 wayland: Query pkg-config if Xwayland supports listenfd
-listen <fd> option is deprecated in favor of the -listenfd option. This
change makes kwin query whether Xwayland supports the -listenfd option
at build time. If the pkg-config file is missing, we'll use the old listen
option.
2021-03-02 13:29:22 +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
Aleix Pol
618c330ca8 Do not attempt to compare iterators of potentially different containers
I got this crash after leaving my system unattended:
```
0  std::__atomic_base<int>::load(std::memory_order) const (this=0x0, __m=std::memory_order_relaxed) at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../include/c++/10.2.0/bits/atomic_base.h:426
1  QAtomicOps<int>::loadRelaxed<int>(std::atomic<int> const&) (_q_value=...) at /home/apol/devel/kde5/include/QtCore/qatomic_cxx11.h:239
2  QBasicAtomicInteger<int>::loadRelaxed() const (this=0x0) at /home/apol/devel/kde5/include/QtCore/qbasicatomic.h:107
3  QtPrivate::RefCount::isShared() const (this=0x0) at /home/apol/devel/kde5/include/QtCore/qrefcount.h:101
4  QMap<KWin::Group*, KWin::Layer>::detach() (this=0x7f1b577b7870 <qt_array+48>) at /home/apol/devel/kde5/include/QtCore/qmap.h:357
5  QMap<KWin::Group*, KWin::Layer>::find(KWin::Group* const&) (this=0x7f1b577b7870 <qt_array+48>, akey=<optimized out>) at /home/apol/devel/kde5/include/QtCore/qmap.h:861
6  KWin::Workspace::constrainedStackingOrder() (this=this@entry=0x564b368c6290) at /home/apol/devel/frameworks/kwin/src/layers.cpp:502
7  0x00007f1b5708d027 in KWin::Workspace::updateStackingOrder(bool) (this=0x564b368c6290, propagate_new_clients=false) at /home/apol/devel/frameworks/kwin/src/layers.cpp:110
8  0x00007f1b571629be in KWin::X11Client::setFrameGeometry(QRect const&, KWin::AbstractClient::ForceGeometry_t) (this=0x564b374b4e60, rect=<optimized out>, force=<optimized out>) at /home/apol/devel/frameworks/kwin/src/x11client.cpp:4193
9  0x00007f1b57003fbf in KWin::AbstractClient::blockGeometryUpdates(bool) (this=this@entry=0x564b374b4e60, block=<optimized out>) at /home/apol/devel/frameworks/kwin/src/abstract_client.cpp:871
10 0x00007f1b570054f1 in KWin::GeometryUpdatesBlocker::~GeometryUpdatesBlocker() (this=<optimized out>) at /home/apol/devel/frameworks/kwin/src/abstract_client.h:1334
11 KWin::AbstractClient::checkWorkspacePosition(QRect, int, QRect) (this=0x564b374b4e60, oldGeometry=..., oldDesktop=1, oldClientGeometry=...) at /home/apol/devel/frameworks/kwin/src/abstract_client.cpp:3189
12 0x00007f1b571409e0 in KWin::Workspace::updateClientArea(bool) (this=<optimized out>, this@entry=0x564b368c6290, force=false) at /home/apol/devel/frameworks/kwin/src/workspace.cpp:2234
13 0x00007f1b57138fc6 in KWin::Workspace::updateClientArea() (this=0x564b368c6290) at /home/apol/devel/frameworks/kwin/src/workspace.cpp:2243
14 KWin::Workspace::desktopResized() (this=0x564b368c6290) at /home/apol/devel/frameworks/kwin/src/workspace.cpp:1980
15 0x00007f1b57707806 in QtPrivate::QSlotObjectBase::call(QObject*, void**) (a=0x7fff671a2e50, r=0x564b368c6290, this=0x564b372f1860) at ../../include/QtCore/../../../../../devel/frameworks/qt5/qtbase/src/corelib/kernel/qobjectdefs_impl.h:398
16 doActivate<false>(QObject*, int, void**) (sender=0x564b368a0fe0, signal_index=4, argv=0x7fff671a2e50) at /home/apol/devel/frameworks/qt5/qtbase/src/corelib/kernel/qobject.cpp:3886
17 0x00007f1b57707806 in QtPrivate::QSlotObjectBase::call(QObject*, void**) (a=0x7fff671a2f30, r=0x564b368a0fe0, this=0x564b368a10f0) at ../../include/QtCore/../../../../../devel/frameworks/qt5/qtbase/src/corelib/kernel/qobjectdefs_impl.h:398
18 doActivate<false>(QObject*, int, void**) (sender=0x564b36775640, signal_index=3, argv=0x7fff671a2f30) at /home/apol/devel/frameworks/qt5/qtbase/src/corelib/kernel/qobject.cpp:3886
19 0x00007f1b4ee2f9c3 in KWin::DrmBackend::updateOutputs() (this=this@entry=0x564b36775640) at /home/apol/devel/frameworks/kwin/src/plugins/platforms/drm/drm_backend.cpp:374
20 0x00007f1b4ee31d54 in KWin::DrmBackend::openDrm()::$_2::operator()() const (this=<optimized out>) at /home/apol/devel/frameworks/kwin/src/plugins/platforms/drm/drm_backend.cpp:328
```
2021-03-01 15:11:52 +00:00
Aleix Pol
3b2b9e01f2 Fix GlobalShortcutsTest::testWaylandClientShortcut() 2021-03-01 14:21:15 +00:00
Aleix Pol
e4bed6ea27 Still mark setUnresponsive(false) when the pings arrive late
It usually means that the client was busy and couldn't answer the ping
as early as we'd hoped but there's a good chance the process is healthy
again.
2021-03-01 14:10:46 +01:00
Yuri Chornoivan
b5f9d9fda8 Fix disambiguation found by gettext 0.21 2021-02-28 11:59:10 +02:00
l10n daemon script
7b557527f5 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-02-27 06:24:41 +01:00
Xaver Hugl
1f7e794b82 DrmGpu: add gbm device nullptr check
BUG: 433145
2021-02-25 19:14:02 +01:00
Vlad Zahorodnii
37c145e94b wayland: Fix PrepareForSleep dbus connection
This is a typo. We must use the path of the manager rather than the
session path, which is not initialized yet.
2021-02-25 07:34:27 +00:00
Đoàn Trần Công Danh
5ba3284712 ftrace: use quint32 for context counter
Some old platforms don't have atomic integer supports for 64-bit wise
integer.

As indicated in GPUVis:

	// Erase all knowledge of this ctx so it can be reused

We can reuse numbers after end_ctx, so with we should be fine with
32-bit integer.

Let's use a 32 bit integer for context.
2021-02-24 23:45:19 +00:00
Đoàn Trần Công Danh
5cc062c77c 3rdparty/xcursor: build with _DEFAULT_SOURCE
For both DT_UNKNOWN and DT_LNK.
2021-02-24 16:36:49 +00:00
Đoàn Trần Công Danh
7800f15587 helper: wl-socket: fix build for musl
bind(2) expects its second parameters is a "const struct sockaddr*",
let's cast the "struct sockaddr_un*" to "struct sockaddr*" before
passing into bind(2).

SUN_LEN is a BSD extension that also implemented by GNU, let's define
_DEFAULT_SOURCE before including "sys/un.h".
2021-02-24 16:36:49 +00:00
Vlad Zahorodnii
9977f21980 wayland: Honor NoPlugin option
If decorations are disabled, don't send xdg-toplevel-decoration
configure events requesting ssd mode.
2021-02-24 10:44:29 +00:00
Vlad Zahorodnii
6c9e0781cd Simplify code that destroys plugins and color manager
This reduces some code duplication and ensures that plugins and the
color manager are destroyed while Platform is still valid.
2021-02-24 09:38:56 +00:00
Vlad Zahorodnii
e1279e516c wayland: Track already existing subsurfaces in SubSurfaceMonitor
When the monitor is created, the surface may already have child
sub-surfaces. The childSubSurfaceAdded signal won't be emitted for them,
we need to handle this case explicitly.

BUG: 433511
FIXED-IN: 5.21.2
2021-02-24 10:25:36 +02:00
Vlad Zahorodnii
73dd65f452 Fix build 2021-02-23 15:21:04 +02:00
Aleix Pol
65ad7ffb27 inputmethod: do not cover panels with the input method (e.g. virtual keyboard)
This way we can adapt the panels themselves to show useful UX like
hiding the keyboard or switching.
2021-02-23 12:10:28 +00:00
Vlad Zahorodnii
220a1e0441 Add QDebug stream operator for AbstractOutput
This can be useful for debugging purposes.
2021-02-23 12:47:16 +02:00
Vlad Zahorodnii
33ba2974eb effects: Properly copy previous geometry
In QJSEngine, QRect is an Object, which is correct. This means that we
cannot use simple assignment operator to copy geometries, we need to use
standard ways to copy Objects, such as Object.assign() or the spread
operator, which is not available in QJSEngine yet.
2021-02-23 07:47:01 +00: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
Bhushan Shah
28d2650f24 [platforms/drm] include missing errno.h include
CCMAIL: Xaver Hugl <xaver.hugl@gmail.com>
2021-02-23 12:07:17 +05:30
Xaver Hugl
6703bc9d24 Improve teardown of DrmGpu 2021-02-22 21:56:03 +01:00
Bhushan Shah
ae8e69b4bb [platforms/drm] accept both keypress and keyrelease event in filter
We don't want to pass out either of key press or release event to other
filters.
2021-02-22 21:52:57 +05:30
Vlad Zahorodnii
58bee8e38a Fix build 2021-02-22 18:11:06 +02:00
Vlad Zahorodnii
94b63c16f2 autotests: Register virtual keyboard service
Otherwise the input method test seems to fail with the following error

"The name org.kde.kwin.testvirtualkeyboard was not provided by any
.service files"
2021-02-22 16:08:14 +00:00
Bhushan Shah
b24fc72969 [platforms/drm] only enable output on key press not release
Otherwise if powerdevil for example is configured to turn screen off on
the power key press, we will turn it right back on when we get key
release event.

Suggested-by: David Edmundson <kde@davidedmundson.co.uk>
2021-02-22 21:16:00 +05:30
Vlad Zahorodnii
ea4acb5763 autotests: Make PointerInputTest more robust
According to the spec, when the pointer enters a surface, the contents
of the cursor becomes undefined. The client should call set_cursor() to
make sure that the cursor image is correct.
2021-02-22 15:49:48 +02:00
Vlad Zahorodnii
4061cbc97d Create Xcursor sprites with correct format
"ARGB32" is a typo, it needs to be "ARGB32_Premultiplied."
2021-02-22 15:28:50 +02:00
l10n daemon script
553b6d39c6 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-02-22 06:57:46 +01:00
Vlad Zahorodnii
33e3b92946 effects/wobblywindows: Allow model geometry and real geometry get out of sync
Currently, the wobbly windows effect assumes that the window data will
be updated on every repaint. However, there are legit cases when the
time diff between frames can be 0, for example when per screen rendering
is on.

If we are unlucky enough and the geometry of the window changes in that
very short moment, the mapping between window quads and the bezier
patch will be wrong. The window will most likely bounce back and forth.

In order to improve handling of that tricky case, this change makes the
computeBezierPoint() function take the "uv" coordinates rather than the
absolute "xy" coordinates of window vertices. This loosens the
connection between the real geometry of the window and the cached bezier
patch, and overall makes the effect's timing code more robust.

This can be also useful if the wobbly windows effect starts accumulating
time diffs and performing the integration step every N msecs with the
purpose of maintaining uniform "wobbliness" across different refresh rates.

BUG: 433187
2021-02-19 16:34:15 +00:00
Vlad Zahorodnii
823692abc1 effects/wobblywindows: Refactor the update loop
This way, the code is more tidier.
2021-02-19 17:53:47 +02:00
Vlad Zahorodnii
45979ed460 x11: Introduce an envvar to force software vsync
This can be useful for debugging purposes and for people wishing to ramp
up the refresh rate on their setups with different refresh rates.

BUG: 433094
2021-02-19 14:59:47 +00:00
Vlad Zahorodnii
fb93037ca7 x11: Introduce an envvar to prevent sync'ing to vblanks
This can be useful if you want to ensure that the buffer swap operation
won't block.

CCBUG: 433094
2021-02-19 14:59:47 +00:00
Vlad Zahorodnii
e179fb697d platforms/drm: Refactor event dispatching code
There are a couple of reasons not to use the lambda:

* It is unnecessary. The DrmGpu has the DRM file descriptor
* If a crash occurs somewhere in the lambda, the backtrace will be hard
  to read
* Instead of processing events in the destructor of the DrmBackend
  class, we should keep dispatching events without involving
  QCoreApplication::processEvents() until all page flips are completed.
2021-02-19 13:40:07 +00:00
Aleix Pol
d8cb48e6b7 inputmethod: honour SNI disabled state
At the moment we were sending activation signals even if it's disabled.
2021-02-19 13:18:55 +00:00
Xaver Hugl
79ccfaddf0 Properly clean up DrmGpu
CCBUG: 433145
2021-02-19 13:19:21 +01:00
Vlad Zahorodnii
6053bbd2d0 Sprinkle static keywords
There is no need to query the environment variables every time kwin
tries to determine the current compositing refresh rate.
2021-02-19 11:16:50 +02:00
David Faure
abab1660aa Define -DQT_NO_CAST_TO_ASCII and fix compilation 2021-02-19 11:00:27 +02:00
Jan Blackquill
c6b638267a Fix crash on pasting too soon after copying from XWayland
There seems to be an interval between when you copy something from a Wayland
client and when you attempt to paste it into an X client where m_chunks.first().first
is empty, and trying to access its .data() will cause an assertion. While we can't
really gracefully handle this situation, we can at least terminate the function early
and turn the paste operation into a noop instead of a crash.
2021-02-19 07:24:23 +00:00
Aleix Pol
04465e996c Prevent layershell from crashing when rearranging when we shouldn't
Here's the backtrace that prompted the MR:
```
0  QVector<KWin::VirtualDesktop*>::count() const (this=0x10) at
/home/apol/devel/kde5/include/QtCore/qvector.h:241
1  KWin::VirtualDesktopManager::count() const (this=0x0) at
/home/apol/devel/frameworks/kwin/src/virtualdesktops.h:687
2  KWin::Workspace::updateClientArea(bool) (this=0x0, force=false) at
/home/apol/devel/frameworks/kwin/src/workspace.cpp:2089
3  0x00007fef12a180b3 in KWin::LayerShellV1Integration::rearrange()
(this=<optimized out>) at
/home/apol/devel/frameworks/kwin/src/layershellv1integration.cpp:208
4  0x00007fef13094806 in QtPrivate::QSlotObjectBase::call(QObject*,
void**) (a=0x7ffcf9674f70, r=0x5569d2981a40, this=0x5569d2981e50) at
../../include/QtCore/../../../../../devel/frameworks/qt5/qtbase/src/corelib/kernel/qobjectdefs_impl.h:398
5  doActivate<false>(QObject*, int, void**) (sender=0x5569d2981dc0,
signal_index=3, argv=argv@entry=0x7ffcf9674f70) at
/home/apol/devel/frameworks/qt5/qtbase/src/corelib/kernel/qobject.cpp:3886
6  0x00007fef1308db60 in QMetaObject::activate(QObject*, QMetaObject
const*, int, void**) (sender=<optimized out>, m=m@entry=0x7fef1332d280
<QTimer::staticMetaObject>,
local_signal_index=local_signal_index@entry=0,
argv=argv@entry=0x7ffcf9674f70) at
/home/apol/devel/frameworks/qt5/qtbase/src/corelib/kernel/qobject.cpp:3946
7  0x00007fef1309871a in QTimer::timeout(QTimer::QPrivateSignal)
(this=<optimized out>, _t1=...) at .moc/moc_qtimer.cpp:205
```
2021-02-19 00:25:20 +01:00
Aleix Pol
4fb2493826 --warning: Don't try to connect to a null object
It happens when running without libinput.
2021-02-18 20:03:06 +01:00
Aleix Pol
8950b78121 pipewire: Don't crash if we're passed a null spa_data
I just had that crash, this is what coredumpctl suggested it was
happening.
We don't need to make sure we're in dmabuf mode to remove the buffer.
Worst case scenario it won't remove anything. Check the spa_data before
querying in case it's null.
2021-02-18 17:13:36 +00:00
Méven Car
11c3ada121 DrmGpu fix atomicModeSetting try 2021-02-18 16:26:18 +00:00
Vlad Zahorodnii
cf2486d643 x11: Properly detect whether swap events have to disabled
qEnvironmentVariableIntValue() will return 0 if the specified variable
is not set.

This means that swap events will be disabled on AMD GPUs unless the env
var is set explicitly to 1.
2021-02-18 12:04:27 +00:00
Bhushan Shah
892b8cf6cb inputmethod: toggle the inputmethod if we get second show request
This is in a way working around bad protocol, input-method-unstable-v1
and also input-method-unstable-v2 does not have a way for input-method
to mark itself as "deactivated". This can happen when e.g. user closes
the virtual keyboard using swiping down or "close keyboard" button in
keyboard.

When this happens, the state between compositor, text_input and
input_method gets out of sync, compositor does not know that input
method got deactivated and hence it will continue sending various events
to it. The quick way around it is to change focus, which makes
compositor send deactivate request to input-method, that puts compositor
and input-method in sync again.

This patch aims to solve this by tracking the last state of input
method, If we know that input method is active and text input sends us
the show event, we toggle the input-method.

I will re-iterate that this is in no way proper solution, ideally
input-method-unstable-v3 or input-method-unstable-v2 even (since it is
not upstream anyway) gains the new request which essentially allows
input-method to sync enabled/disabled state with compositor.
2021-02-18 10:36:39 +05:30
Vlad Zahorodnii
378ecbc88c wayland: Implement maximized horizontal/vertical states
BUG: 407793
2021-02-17 14:39:24 +00:00
Vlad Zahorodnii
dd1b45d828 x11: Simplify X11Client::damageNotifyEvent()
The contents of the if branch is identical to the implementation of the
Toplevel::damageNotifyEvent() function and setReadyForPainting() will
never be called because m_syncRequest.isPending can be true only if the
window supports sync counters.
2021-02-17 12:09:23 +00:00