Commit graph

45 commits

Author SHA1 Message Date
Vlad Zahorodnii
44176c6a8c Lower default severity of logging categories
Warning messages are not the kind of messages that should be ignored,
they indicate that something is off or wrong.

Also, this makes triaging bugs easier as we no longer have to ask people
to run kwin with the QT_LOGGING_RULES environment variable set.
2021-01-25 14:03:14 +02:00
Vlad Zahorodnii
eaf94f465c Re-apply color transforms when session is re-activated
When our session is re-activated, we need to re-apply color transforms
as the current gamma ramps might be outdated.
2020-12-21 20:25:32 +02:00
Vlad Zahorodnii
6adfe3064f Drop Platform::createScreens()
Since the Screens class is a convenience wrapper around AbstractOutput
objects that come from the Platform, it should not be platform-specific.

By dropping createScreens(), output-related code becomes simpler.
2020-12-21 09:20:16 +00:00
Vlad Zahorodnii
64ad9a61d8 Introduce ColorManager component
This change introduces a new component - ColorManager that is
responsible for color management stuff.

At the moment, it's very naive. It is useful only for updating gamma
ramps. But in the future, it will be extended with more CMS-related
features.

The ColorManager depends on lcms2 library. This is an optional
dependency. If lcms2 is not installed, the color manager won't be built.

This also fixes the issue where colord and nightcolor overwrite each
other's gamma ramps. With this change, the ColorManager will resolve the
conflict between two.
2020-12-13 23:53:33 +02:00
Vlad Zahorodnii
3a7bce693e Explicitly destroy plugins
A plugin may need to access kwinApp() or kwinApp()->platform() during
tear down, but the problem is that plugins are destroyed after the
kwinApp() object. The plugin manager must be destroyed explicitly while
the application is still valid to ensure that no crash will occur
during compositor teardown.
2020-11-26 20:51:14 +02:00
Vlad Zahorodnii
c766e5da6d Introduce infrastructure for compositor extensions
The scripting api is not suitable for implementing all features that
should not be implemented in libkwin. For example, the krunner
integration or screencasting are the things that don't belong to be
compiled right into kwin and yet we don't have any other choice.

This change introduces a quick and dirty plugin infrastructure that
can be used to implement things such as colord integration, krunner
integration, etc.
2020-11-24 15:50:33 +00:00
Vlad Zahorodnii
0c266e760b Replace remaining usages of old connect syntax with new connect syntax
This change replaces the remaining usages of the old connect syntax with
the new connect syntax.

Unfortunately, there are still places where we have to use SIGNAL() and
SLOT() macros, for example the stuff that deals with d-bus business.

Clazy was used to create this change. There were a few cases that needed
manual intervention, the majority of those cases were about resolving
ambiguity caused by overloaded signals.
2020-09-24 09:33:45 +00:00
Vlad Zahorodnii
4ce853e8e4 Prettify license headers 2020-08-07 19:57:56 +00:00
Vlad Zahorodnii
1fb9f6f13a Switch to SPDX license markers
The main advantage of SPDX license identifiers over the traditional
license headers is that it's more difficult to overlook inappropriate
licenses for kwin, for example GPL 3. We also don't have to copy a
lot of boilerplate text.

In order to create this change, I ran licensedigger -r -c from the
toplevel source directory.
2020-08-07 19:57:56 +00:00
Vlad Zahorodnii
e7d02ad355 Introduce X11 default screen property in Application
This spares unnecessary looping through all available X11 screens.
2020-08-05 08:48:00 +00:00
Vlad Zahorodnii
19ad172584 Survive Xwayland crashes
If the Xwayland process crashes, it will bring down the entire session
together with itself. Obviously, we don't want that. At least, Wayland
clients should survive the crash.

This change refactors relevant X11 parts to handle Xwayland crashes in a
less fatal way.

In order to handle Xwayland crashes better, a pair of start() and stop()
methods had been introduced in the Xwayland class to allow starting and
stopping the Xwayland process at any moment.

If we detect that the Xwayland process has crashed, we will immediately
stop the Xwayland server, which in its turn will deactivate the socket
notifier and destroy all connected X11 clients. Unfortunately, a couple
of subtle changes in X11Client::releaseWindow() and Unmanaged::release()
had to be made to ensure that we are left with a valid state after the
Xwayland server has been stopped.
2020-08-05 08:48:00 +00:00
Vlad Zahorodnii
d1b35f306d Introduce started signal in Application
The new signal is emitted when the Application has fully been initialized.

It allows us to change the startup sequence, for example create workspace
before starting the Xwayland server, without making any adjustments in our
test suit.
2020-07-17 09:10:51 +00:00
Kai Uwe Broulik
be31101f12 Remove QSessionManager usage
Summary: Instead, have KSMServer talk to us directly on DBus.

Test Plan: Depends on D28616

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D28617
2020-04-06 11:51:47 +02:00
David Edmundson
996e840172 Drop kdeinit linking
Summary:
This wasn't used on startup (ksmserver calls KProcess)
Nor for the rules dialog (kwin invokes it with QProcess)

We may as well simplify the code and drop the dependency

See also T12140

Test Plan:
Restarted
Opened the rules dialog

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D26835
2020-01-22 12:46:10 +00:00
David Edmundson
ec610fd7ed Port one of session management connections state to a custom API
Summary:
Currently kwin opens a second ICE connection to ksmserver in order to
tell the state of kwin's whether we're logging out and saving clients or
not.

This requires that kwin launches after ksmserver to have the connection
which is a dependency I want to break.

Practically this code is already ksmserver specific as it relies on some
custom code that sends the first saveState request to kwin first.

Instead we can replace it with a bespoke IPC over DBus and siplify the
code both end. This will allow several other future enhancements that we
want with regards to handling the session state, as well as make an
effort platform agnostic session management, as well as cleaning up some
complex code.

Ksmserver calls into kwin, rather than having kwin watch ksmserver state
to allow us make sure it's race free.

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: romangg, zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D24862
2019-11-01 17:14:42 +00:00
David Edmundson
0c876cd93f Avoid event processing infinite loop
Summary:
Kwin on X11 overrides QCoreApplication::notify to get low level system
event.

If something handled by the low level filtering ever calls postEvent we
would end up in a loop. This was found when forwarding a key event into
a QQuickWindow in a similar manner that mouse events are forwarded.

Fortunately there's a flag to separate generated and core events

Test Plan:
No more infinite loop
Kwin X11 still works fine

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D24207
2019-09-25 14:27:16 +01:00
David Edmundson
a209ee7865 Don't notify ksplash in our wayland session
Summary:
KSplash doesn't expect a kwin notification on wayland as kwin is started
before ksplash.

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: broulik, zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D23770
2019-09-23 22:13:43 +02:00
Vlad Zahorodnii
2ad37c449f Port away from deprecated QString::sprintf
Test Plan: Compiles.

Reviewers: #kwin, apol

Reviewed By: apol

Subscribers: apol, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D24045
2019-09-18 16:20:06 +03:00
Vlad Zagorodniy
28a4337ad5 Don't use deprecated toAscii() method
Summary:
QChar::toAscii() and QString::toAscii() are deprecated in favor of
QChar::toLatin1() and QString::toLatin1() respectively.

Reviewers: #kwin, apol

Reviewed By: apol

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D22374
2019-07-10 22:50:00 +03:00
Roman Gilg
ead1b34563 KSelectionOwner usage in ApplicationX11 and Compositor classes
Summary:
Declare it in the source file for internal usage of ApplicationX11 and
Compositor classes. Additionally use modern style connect and do other
code style updates.

Test Plan: Manually in X session and Wayland windowed.

Reviewers: #kwin, zzag

Subscribers: davidedmundson, sbergeron, zzag, kwin

Tags: #kwin

Maniphest Tasks: T11071

Differential Revision: https://phabricator.kde.org/D21655
2019-06-27 18:08:12 +02:00
Erik Kurzinger
56cd5f5557 [platforms/X11] Disable VSync for QtQuick Windows
Summary:
QtQuick windows created by KWin currently use the default swap interval
of 1, meaning buffer swaps will block until vblank. However, this
results in a problematic interaction on hybrid graphics systems running
the proprietary NVIDIA driver.  VSync on such setups relies on a system
called "PRIME synchronization", where the xf86-video-modesetting driver
controlling the display will signal the NVIDIA driver when vblank has
occurred. The issue is that it will only do so if there has been damage
to the screen.

So, when KWin creates a QtQuick window, compositing will stop waiting on
the window to render, therefore no damage to the screen will occur. But
this means that no vblank notifications will be delivered to the NVIDIA
driver, so the glXSwapBuffers call by the QtQuick window will block
perpetually. The end result is a freeze of the desktop.

To get around this, we can simply disable vsync for QtQuick windows by
setting the swap interval for the default QSurfaceFormat to 0. Since
they are redirected, this shouldn't cause any tearing.

BUG: 406180
FIXED-IN: 5.16.2

Test Plan:
Using the proprietary NVIDIA driver on a hybrid graphics system, with
PRIME synchronization enabled (see
https://devtalk.nvidia.com/default/topic/957814/linux/prime-and-prime-synchronization/),
perform any action causing a QtQuick window to be created by KWin, for
example, triggering the application switcher dialogue with alt + tab.

Ensure the desktop does not temporarily freeze.

Note, this required a Qt build that includes commit
https://code.qt.io/cgit/qt/qtbase.git/commit/?id=0c1831178540462da31fd7a4b6d2e446bc84498b
resolving a bug that prevented the changing the swap interval.

Reviewers: #kwin, davidedmundson, zzag

Reviewed By: #kwin, davidedmundson, zzag

Subscribers: zzag, romangg, alexeymin, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D21808
2019-06-19 07:56:42 -07:00
David Edmundson
79ce5dac9a Also unset QT_SCALE_FACTOR
Summary:
Qt scaling and kwin on X11 is never going to work so it is disabled.

However, Qt uses multiple environment variables for subtly different
internal things. We don't set QT_SCALE_FACTOR in Plasma, using different ones.

An XFCE user was setting this, which kinda makes sense if your DE doesn't
have an appropriate UI.

I don't think it's relevant for main_wayland as wl_output.scale should
trump the environment variable.

BUG: 406195

Reviewers: zzag

Reviewed By: zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D20234
2019-04-04 02:03:26 +01:00
Martin Flöser
c2c92fab51 Ensure the Compositor does not start during termination
Summary:
The SceneOpenGLES test was starting to randomly crash on my system. On
investigation I observed that there was a graphics reset ("Attempting to
reset compositing.") which triggered a delayed restart of the
compositor. This even was only processed while waiting for XWayland to
terminate. Which resulted in a crash in KWin::getXServerVersion as the
xcb connection broke.

It makes no sense to setup the compositor again during application
shutdown. Thus the dtors set a flag that they are terminating the
application and Compositor::setup is checking for it.

Test Plan: Test no longer crashes, although it goes through the crashing path

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18015
2019-01-12 07:36:55 +01:00
David Edmundson
e7b183f886 Load QtQuick settings
Summary:
Loads settings on whether QtQuick uses GL or software rendering

Aurorae needed a fix. The rest "just works" with up-to-date plasma framework.

Test Plan:
Alt tabbed
Showed an OSD
Grepped kwin's QML for any custom shaders.
(which is the only part that doesn't work here)

Reviewers: #plasma, graesslin

Reviewed By: #plasma, graesslin

Subscribers: graesslin, plasma-devel, kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8040
2017-11-01 15:51:21 +00:00
Martin Gräßlin
16647c3a3c Require Qt 5.7 and remove pre-5.7 code
Summary:
Increases minimum Qt version to 5.7. This allows to drop the pre-5.7
virtual keyboard and various ifdefs for now unsupported versions.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D4485
2017-02-07 20:43:19 +01:00
Martin Gräßlin
fbab204968 [effects] Add a screenshot dbus method which takes a file descriptor
Summary:
The idea behind this mode is to support applications like spectacle
(see T4458). The calling application passes a file descriptor (created
through e.g. a pipe) and the screenshot effect writes the captured image
into that fd.

The advantage over the existing variant which writes to a file in the
/tmp directory is that this is peer-to-peer between the requesting
application and KWin. No other application can get to that image.

The change also includes setting SIGPIPE to ignore. It showed that when
the reading side already cancelled the read prior to KWin writing out
the image we get a SIGPIPE which results in application termination,
which is not what we want in case of a Wayland compositor. The sigpipe
can be ignored as Qt (and libpng) handles that error just fine at
runtime.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3412
2016-11-22 07:17:57 +01:00
Martin Gräßlin
346619aa36 Remove KWin::display from kwinglobals
Summary:
And finally nothing inside libkwineffects, libkwinglutils,
libkwinxrenderutils and kwineffect and kwin core uses KWin::display.
We are finally XLib free!

This change drops KWin::display and removes the include to QX11Info from
kwinglobals.h. And the libraries no longer need to link X11Extras.  Due
to that removal a few seeming unrelated changes are required to add the
include where needed and linkage to X11Extras.

The biggest change is to x11 platform plugin which still needs the
display and caches it in the Platform and passes it to various places in
a way that the code doesn't need to be adjusted.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3337
2016-11-16 18:00:00 +01:00
Martin Gräßlin
bd8f6d78f0 Move everything KCrash related from Application to ApplicationX11
Summary:
This change ensures that kwin_wayland does not pull in KCrash. We
don't want and need KCrash in the Wayland case. If KWin crashes the
session goes down - restarting doesn't make any sense, we need to
relogin.

Similar drkonqi just doesn't work as it doesn't have a windowing
system to connect to. After all the windowing system just crashed.

Also the AlternativeWM dialog doesn't make any sense on Wayland.
Similar thought: there is no windowing system to show this nice dialog.

Overall it's better to have system default behavior
(e.g. systemd-coredump) than using KCrash in the very special case of
kwin_wayland.

Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1550
2016-05-09 08:08:49 +02:00
Martin Gräßlin
8b148fa11a Load and init the KWinX11Platform plugin in main_x11
kwin_x11 now also loads a platform plugin and initializes it.
It doesn't do much except loading it and init it. Though it's also
set up to continue startup only when screens are queried.
2016-04-12 08:04:16 +02:00
Martin Gräßlin
5acf9abda8 Merge branch 'Plasma/5.5' 2016-02-25 08:07:30 +01:00
Martin Gräßlin
9e54cb5a1f Move global event filter from Application to ApplicationX11
The event filter is only used to let Qt compose a QKeyEvent from an
x11 event for grabbed key events. On Wayland we don't need it as we
can generate good QKeyEvents ourself. This means less event processing
as the events no longer need to pass through the
Workspace::workspaceEvent.

In addition it fixes a regression in LockScreenTest::testEffectsKeyboard
caused by the LockScreenEventFilter sending a QKeyEvent to KSldApp.
This event got intercepted by the global event filter making the test
rightfully fail.
2016-02-17 09:26:38 +01:00
David Edmundson
90112ef0cd Use new Qt flag to disable high DPI scaling on X
This flag was set for main_wayland but not X.

BUG: 357896
REVIEW: 126810
2016-01-26 17:01:41 +00:00
Thomas Lübking
69aa80750f force restart on crash
We don't want to actively release claims on segfaults, but then
drkonqi can stop us while we're still holding the WM privs.

=> If KWin performs a crash-restart, it forcefully takes WM privs
(since the old instance shall be replaced for quite sure)

BUG: 348834
BUG: 353030
BUG: 353428

REVIEW: 126741
FIXED-IN: 5.6
2016-01-14 23:40:27 +01:00
Martin Gräßlin
20a9a2a247 Introduce a --no-kactivities command line option
This change enables kactivities integration by default again on both
X11 and Wayland (as kactivities no longer blocks). As we have an
infrastructure to disable kactivities we can also make use of it and
offer a command line switch to disable kactivities. This might be
useful for using KWin outside of Plasma.

REVIEW: 126153
2015-12-16 10:42:14 +01:00
Martin Gräßlin
1998d5ac1a [wayland] Improve tear-down to not crash if X11 applications are still around
We need to destroy the compositor after Xwayland terminated and after
the internal Wayland connection is destroyed. This means when destroying
the Workspace we may no longer destroy the Compositor at the same time.
Also we need to ensure that other tear down functionality doesn't call
into the no longer existing internal client connection.

With this change kwin doesn't crash when exiting with Wayland and/or
X11 windows still open.
2015-11-10 08:56:32 +01:00
Martin Gräßlin
f7d317601e Install a categories file for kdebugsettings
Instead of setting our own filter rules we install a categories file
to allow to configure them. This seems to still have them enabled by
default, but should at least give distributions the possibility to
disable logging by default.
2015-07-15 12:02:31 +02:00
Thomas Lübking
3442664609 port session management to KF5
REVIEW: 123580
BUG: 341930
2015-06-18 00:18:53 +02:00
Boudewijn Rempt
e946e5e0db warnings--: helper needs to be created, but appears to be unused 2015-06-12 18:19:34 +02:00
David Edmundson
10f1dc3fcb Don't follow QT_DEVICE_PIXEL_RATIO
Setting this means we get scaled screen geometry from Qt, and everything
becomes confusing when commmunicating with apps that might not have
this set.

As we use plasma units for UI everything is scaled anyway.

REVIEW: 123115
2015-04-17 18:13:48 +02:00
Martin Gräßlin
0f945f53fe Move creation of InputRedirection, Cursor and Screens out of Workspace
Do not depend on Workspace and do not depend on X11 thus can be started
earlier allowing to get more things started prior to depending on
Workspace.
2015-03-17 10:20:19 +01:00
Martin Gräßlin
7369a2c3a5 [kwin_wayland] Support using platform wayland for the QPA
This reorders the startup sequence quite a bit:
1. Create QAbstractEventDispatcher and install it on QCoreApplication
2. Create Application
3. Start Xwayland, use thread to get when its ready
4. Create xcb connection
5. perform startup

For using the wayland QPA it needs a patch in QtWayland which will be
part of Qt 5.4.2, otherwise it blocks.
2015-03-17 10:20:19 +01:00
Martin Gräßlin
6c53137408 Merge branch 'Plasma/5.2' 2015-01-27 12:46:18 +01:00
Martin Gräßlin
8cb78b7df6 Use KWIN_DBUS_SERVICE_SUFFIX for multi-head service name wrangling
Adjust the KWIN_DBUS_SERVICE_SUFFIX env variable in a multi-head
scenario instead of adjusting the "org.kde.kwin" DBus service which
we actually don't use in 5.x any more.

REVIEW: 122217
2015-01-27 07:25:52 +01:00
Martin Gräßlin
1e41e3e674 Properly disconnect the test xcb connection
So far it only got disconnected in the multi-head situation.

REVIEW: 122218
2015-01-26 11:11:09 +01:00
Martin Gräßlin
f9a7b94ee7 Create dedicated kwin_x11 and kwin_wayland binaries
All of kwin except the main function goes into a new (private) library
called kwin. Two new kdeinit_executables are created:
* kwin_x11
* kwin_wayland

Both only use a dedicated main_x11.cpp and main_wayland.cpp with the
main function and a KWin::Application subclass and linking the new
kwin library.

The main idea behind this is to be able to perform more sane sanity
checks. E.g. on Wayland we don't need to first test whether we can
create an X11 connection. Instead we should abort if we cannot connect
to the Wayland display. Also the multi-head checks are not needed on
Wayland, etc. etc. As most of that code is in the main function to
simplify it's better to split.

This will also make it easier to diverge more easily in future. The
Wayland variant can introduce more suited command line arguments for
example. This already started by having the --replace option only
available in X11 variant. The Wayland backend is still a window manager,
but doesn't claim the manager selection.
2014-08-18 08:50:44 +02:00