28 Commits (08722ff386050bb53f295f0fc65c825134d476dd)

Author SHA1 Message Date
Aleix Pol 02fc40fa4a Make sure we don't leak the QPlatformFontDatabase using smart pointers
Found it when running KWin on ASAN
4 years ago
Méven Car 464203c60e Clean #if version check blocks
Since 08a21ae7b6 we now depend on Qt 5.14
4 years ago
Vlad Zahorodnii 55b4912004 Update my email address 5 years ago
Vlad Zahorodnii f93875535c Update my last name 5 years ago
Vlad Zagorodniy bebe81209c Port QPA away from Wayland
Summary:
So far wayland was used by internal clients to submit raster buffers
and position themselves on the screen. While we didn't have issues with
submitting raster buffers, there were some problems with positioning
task switchers. Mostly, because we had effectively two paths that may
alter geometry.

A better approach to deal with internal clients is to let our QPA use
kwin core api directly. This way we can eliminate unnecessary roundtrips
as well make geometry handling much easier and comprehensible.

The last missing piece is shadows. Both Plasma::Dialog and Breeze widget
style use platform-specific APIs to set and unset shadows. We need to
add shadows API to KWindowSystem. Even though some internal clients lack
drop-shadows at the moment, I don't consider it to be a blocker. We can
add shadows back later on.

CCBUG: 386304

Reviewers: #kwin, davidedmundson, romangg

Reviewed By: #kwin, romangg

Subscribers: romangg, kwin

Tags: #kwin

Maniphest Tasks: T9600

Differential Revision: https://phabricator.kde.org/D22810
5 years ago
Vlad Zagorodniy c8280963e5 [plugins/qpa] Code tidying
Summary: This change cleans up includes, fixes coding style issues, etc.

Test Plan: Compiles.

Reviewers: #kwin, romangg

Reviewed By: #kwin, romangg

Subscribers: romangg, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D22151
5 years ago
Vlad Zagorodniy f5b66a583d [plugins/qpa] Implement native offscreen surface
Summary:
Depending on whether the underlying platform supports offscreen surfaces,
QOffscreenSurface may create an invisible QWindow. In our case that's the
case, for each offscreen surface a native window is created. This may
lead to some funky results related to window decorations, see bug 407612.

There are several ways to implement offscreen surfaces - either use pbuffers
or utilize a surfaceless context extension. For the sake of simplicity
this change sticks with pbuffers, but it's a good idea to support both
methods.

CCBUG: 407612

Reviewers: #kwin, romangg

Reviewed By: #kwin, romangg

Subscribers: romangg, alexeymin, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D22150
5 years ago
Jimi Huotari 3cc39ba35e Fix plugins/qpa build with Qt 5.13
Summary:
Upstream moved screen maintenance functions from
QPlatformIntegration to QWSI.

BUG: 406056
See also: https://code.qt.io/cgit/qt/qtbase.git/commit/?h=5.13&id=01e1df90

Test Plan: Built fine with Qt 5.12.2 and Qt 5.13 stable branch.

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: zzag, arojas, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D20239
6 years ago
Martin Flöser e48d9df14f [qpa] Drop PlatformContextWayland which uses wayland egl for OpenGL
Summary:
Using the Wayland protocol for OpenGL is no longer used or useful. KWin
internal windows only use OpenGL through QtQuick. We either have the
sharing context (KWin uses OpenGL for compositing) or we have the
QPainter compositor which also turns QtQuick to use software renderer.

Thus a situation where the Wayland platform context is useful doesn't
exist any more. Removing it helps getting the QPA plugin Wayland free.

Test Plan:
Run nested KWin triggering Outline once with OpenGL and once
with QPainter compositor.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D19012
6 years ago
Frederik Gladhorn 456cbb9bf7 Remove unused private Qt include
Summary:
Ideally KWin would not depend on private headers... but at least we can
remove unused ones.

Test Plan: still builds, I don't see anything requiring the header.

Reviewers: zzag

Reviewed By: zzag

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16655
6 years ago
David Edmundson 6724955a76 [qpa] Always keep a at least one screen
Summary:
Qt does not like having no screens. Both Qt XCB and Wayland QPAs have
systems pretend there's always at least 1 screen
present.

Kwin already uses a dummy screen on startup, this patch reinserts the
dummy screen if the platform states that all real screens are removed.

BUG: 399564

Test Plan:
Logged in, everything still worked
Did not reproduce the original bug

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16096
6 years ago
David Edmundson a3cff85e7a Remove Qt module declarations in includes
Summary:
Test Plan: Compiles

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D13359
6 years ago
Martin Flöser a5b17b2228 Require Qt 5.9
Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8331
7 years ago
Martin Flöser abedb464d5 [QPA] Implement Screen on top of internal Screens API
Summary:
The test DontCrashUseractionsMenu (Waylandonly) found an issue in our
screen handling implementation in the QPA. The code exposed a short time
frame between the dummy screen getting destroyed and the first screen
being added. This could result in a crash of KWin.

There is actually no need to implement Screen on top of Wayland screen.
KWin has all the knowledge, so we can also base this on top of the
Screens API.

Advantages:
 * no delays due to Wayland roundtrips
 * handle screen getting removed (was a TODO)
 * handle resolution changes (was a TODO)

The new implementation has a disadvantage that it destroys and readds
all screens whenever something around the screen changes. This shouldn't
be an issue in practice as it's only for the internal QPA and thus only
affects KWin internal windows which is placed in global coordinates
anyway. If it turns out to be a problem we need to track better the
screen changes - so far those were not tracked at all.

Test Plan: Run a few unit tests which change screens

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8345
7 years ago
Martin Gräßlin e713df1886 [plugins/qpa] Drop unused variable AbstractPlatformContext::m_integration
Credits to clang for finding unused private variable. This allowed to
similify the ctor and remove a const_cast.
7 years ago
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
8 years ago
Takahiro Hashimoto 052fa2e4ee [plugins/qpa] support use of modularized qtplatformsupport from Qt 5.8
REVIEW: 129268
8 years ago
Martin Gräßlin acb4336932 [plugins/qpa] Properly clean up the created KWayland::Client::Outputs
On build.kde.org the autotests started to crash on tear down due to a
newer Wayland library. The reason is that the KWayland::Client::Outputs
are destroyed after the internal Wayland connection is destroyed.

This change parents the created Outputs to the Registry like the other
objects. To ensure that the KWin::QPA::Screen doesn't have a problem
with that, it is changed to a QPointer - nullptr checks are already in
place.

Hopefully that will fix the crashes on build.kde.org, but there is a
chance that more errors are hidden.
8 years ago
Martin Gräßlin 44843f462f [plugins/qpa] Support SharingPlatformContext on the existing eglSurface and eglconfig
Summary:
So far SharingPlatformContext was only used if the OpenGL context
supports EGL_KHR_surfaceless_context. If not supported, KWin tried to
create a context through the Wayland API. Unfortunately on hwcomposer
platform this results in a crash as libhybris only supports the init
of EGLDisplay for one native platform.

This change tries to also use the SharingPlatformContext if there is
an OpenGL context in general. It reuses the native EGLSurface created
for the compositing scene and makes its own OpenGL context current on
that surface, too. As KWin creates an FBO, it never renders to it, so
it shouldn't matter at all.

In order to prevent EGL_BAD_MATCH errors when making Qt's OpenGL context
current also the EGLConfig from the scene is used to create the context.

Test Plan: Tested on Nexus5 with qtvirtualkeyboard in KWin

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D2231
8 years ago
Martin Gräßlin 5344bf1619 [plugins/qpa] Handle case that qtvirtualkeyboard plugin is not available more gracefully
We didn't check whether creating the QPlatfromInputContext worked and
accessed the m_inputContext unconditionally which obviously crashed.

Now the connects related to QInputMethods are not setup if we failed
to create the QPlatfromInputContext.

Reviewed-By: bshah
8 years ago
Martin Gräßlin f26f2fe181 Integrate QtVirtualKeyboard into KWin/Wayland
Summary:
The idea is to have KWin provide a virtual keyboard. To support this
KWin uses the QT_IM_MODULE qtvirtualkeyboard and makes sure that the
QPA plugin loads it.

KWin has a new class VirtualKeyboard which acts as the focus object and
the "proxy" for input methods. The QPA plugin ensures that this is the
focusObject, so that all input method related events are sent to this
class. From there it will be possible to delegate to other applications
through the Wayland interfaces.

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1638
8 years ago
Martin Gräßlin d31e9e88b4 Rename abstract_backend.(h|cpp) to platform.(h|cpp)
Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1340
9 years ago
Martin Gräßlin 146af48f22 waylandServer()->backend() replaced by kwinApp()->platform() 9 years ago
Martin Gräßlin 68683873e3 [plugins/qpa] Fix build with Qt 5.4
PlatformIntegration::destroyScreen got added in 5.5.
9 years ago
Martin Gräßlin 51ee514227 [plugins/qpa] Add a dummy screen on startup
Qt has problems initializing everything correctly if there is no screen
at startup. E.g. the breeze widget style tries to initialize some pixmaps
and this fails. In worst case hitting asserts in Qt (debug build).

This change creates a dummy screen which gets destroyed as soon as there
is a real screen.

Reviewed-By: notmart and sebas
9 years ago
Martin Gräßlin 8175562a7a [wayland] Fix cleanup handling on tear down
ASAN righly complained: we need to delete our Wayland objects before
we destroy the internal client connection. Solved by better setting
parent relationships in the QPA plugin and correctly delete objects
in destroy of internal client connection.
9 years ago
Martin Gräßlin abb9bf1355 [wayland] Create event dispatcher in QPA plugin
We no longer need to have the event dispatcher created before starting
the QApplication, thus we can leave it to the QPA plugin to creat it.

Also we don't need to implement our own dispatcher any more but can
use one from Qt5PlatformSupport as we link it anyways. The special
need for dispatching the WaylandServer is no longer needed as we can
explicitly dispatch it from the QPA plugin if needed.
9 years ago
Martin Gräßlin 26b3569a0b [wayland] Add a QPA plugin for kwin_wayland
This introduces an own QPA plugin for KWin. QtWayland's plugin is not
a good solution for KWin as QtWayland is meant for Wayland clients and
not for a Wayland server. Given that it makes more sense to have a very
minimal QPA plugin which supports the use cases we actually have.

With our own QPA plugin we should be able to improve the following
areas:
* no need to create Wayland server before QApplication
* Qt::BypassWindowManagerHint can be supported
* no workaround for creating OpenGL context in main thread
* sharing OpenGL context with Qt
* OpenGL context for Qt on libhybris backend

The plugin supports so far the following features:
* creating a QPlatformWindow using KWayland::Client (ShellSurface)
* creating a QPlatformBackingStore using a ShmPool
* creating a QPlatformOpenGLContext with Wayland::EGL
* or creating a QPlatformOpenGLContext which shares with KWin's scene
* creating a QPlatformScreen for each KWayland::Client::Output
* QPlatformNativeInterface compatible to QtWayland
9 years ago