2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 1999, 2000 Matthias Ettrich <ettrich@kde.org>
|
|
|
|
SPDX-FileCopyrightText: 2003 Lubos Lunak <l.lunak@kde.org>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2007-05-13 17:47:20 +00:00
|
|
|
#include "main.h"
|
2013-08-15 11:17:29 +00:00
|
|
|
// kwin
|
2016-04-07 07:24:17 +00:00
|
|
|
#include "platform.h"
|
2013-08-15 11:17:29 +00:00
|
|
|
#include "atoms.h"
|
2020-11-27 19:37:40 +00:00
|
|
|
#ifdef KWIN_BUILD_CMS
|
|
|
|
#include "colormanager.h"
|
|
|
|
#endif
|
2015-02-23 14:57:00 +00:00
|
|
|
#include "composite.h"
|
2015-02-20 13:53:03 +00:00
|
|
|
#include "cursor.h"
|
|
|
|
#include "input.h"
|
|
|
|
#include "logind.h"
|
2013-08-15 11:17:29 +00:00
|
|
|
#include "options.h"
|
2020-11-26 18:41:20 +00:00
|
|
|
#include "pluginmanager.h"
|
2015-02-20 13:53:03 +00:00
|
|
|
#include "screens.h"
|
2016-08-15 06:37:24 +00:00
|
|
|
#include "screenlockerwatcher.h"
|
2013-08-15 11:17:29 +00:00
|
|
|
#include "sm.h"
|
|
|
|
#include "workspace.h"
|
2015-02-19 08:59:21 +00:00
|
|
|
#include "xcbutils.h"
|
2013-08-15 11:17:29 +00:00
|
|
|
|
2016-08-26 13:24:00 +00:00
|
|
|
#include <kwineffects.h>
|
|
|
|
|
2013-08-15 11:17:29 +00:00
|
|
|
// KDE
|
2014-03-17 15:24:10 +00:00
|
|
|
#include <KAboutData>
|
|
|
|
#include <KLocalizedString>
|
2016-04-06 15:30:00 +00:00
|
|
|
#include <KPluginMetaData>
|
2020-04-29 15:18:41 +00:00
|
|
|
#include <KWaylandServer/surface_interface.h>
|
2013-08-15 11:17:29 +00:00
|
|
|
// Qt
|
2013-08-28 12:10:51 +00:00
|
|
|
#include <qplatformdefs.h>
|
2019-07-09 19:19:26 +00:00
|
|
|
#include <QCommandLineParser>
|
2013-10-25 11:00:50 +00:00
|
|
|
#include <QQuickWindow>
|
2013-08-15 11:17:29 +00:00
|
|
|
#include <QStandardPaths>
|
2019-09-23 20:13:43 +00:00
|
|
|
#include <QTranslator>
|
|
|
|
#include <QLibraryInfo>
|
2012-03-30 07:54:18 +00:00
|
|
|
|
2013-08-15 11:17:29 +00:00
|
|
|
// system
|
2012-03-30 07:54:18 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif // HAVE_UNISTD_H
|
|
|
|
|
|
|
|
#ifdef HAVE_MALLOC_H
|
|
|
|
#include <malloc.h>
|
|
|
|
#endif // HAVE_MALLOC_H
|
2007-09-27 16:22:29 +00:00
|
|
|
|
2015-02-19 08:59:21 +00:00
|
|
|
// xcb
|
|
|
|
#include <xcb/damage.h>
|
2015-02-25 10:10:31 +00:00
|
|
|
#ifndef XCB_GE_GENERIC
|
|
|
|
#define XCB_GE_GENERIC 35
|
|
|
|
#endif
|
2015-02-19 08:59:21 +00:00
|
|
|
|
2016-11-16 15:53:17 +00:00
|
|
|
Q_DECLARE_METATYPE(KSharedConfigPtr)
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
Options* options;
|
|
|
|
|
|
|
|
Atoms* atoms;
|
|
|
|
|
|
|
|
int screen_number = -1;
|
2011-05-08 18:39:27 +00:00
|
|
|
bool is_multihead = false;
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2007-09-27 14:53:52 +00:00
|
|
|
int Application::crashes = 0;
|
|
|
|
|
2014-08-12 07:08:48 +00:00
|
|
|
bool Application::isX11MultiHead()
|
|
|
|
{
|
|
|
|
return is_multihead;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Application::setX11MultiHead(bool multiHead)
|
|
|
|
{
|
|
|
|
is_multihead = multiHead;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Application::setX11ScreenNumber(int screenNumber)
|
|
|
|
{
|
|
|
|
screen_number = screenNumber;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Application::x11ScreenNumber()
|
|
|
|
{
|
|
|
|
return screen_number;
|
|
|
|
}
|
|
|
|
|
|
|
|
Application::Application(Application::OperationMode mode, int &argc, char **argv)
|
2013-08-28 12:10:51 +00:00
|
|
|
: QApplication(argc, argv)
|
2013-07-26 05:52:56 +00:00
|
|
|
, m_eventFilter(new XcbEventFilter())
|
2013-08-28 12:10:51 +00:00
|
|
|
, m_configLock(false)
|
2016-01-29 08:48:02 +00:00
|
|
|
, m_config()
|
2017-01-27 16:15:32 +00:00
|
|
|
, m_kxkbConfig()
|
2014-08-12 07:08:48 +00:00
|
|
|
, m_operationMode(mode)
|
2013-08-28 12:10:51 +00:00
|
|
|
{
|
2014-12-08 09:08:49 +00:00
|
|
|
qRegisterMetaType<Options::WindowOperation>("Options::WindowOperation");
|
2016-08-26 13:24:00 +00:00
|
|
|
qRegisterMetaType<KWin::EffectWindow*>();
|
2020-04-29 15:18:41 +00:00
|
|
|
qRegisterMetaType<KWaylandServer::SurfaceInterface *>("KWaylandServer::SurfaceInterface *");
|
2016-11-16 15:53:17 +00:00
|
|
|
qRegisterMetaType<KSharedConfigPtr>();
|
Introduce RenderLoop
At the moment, our frame scheduling infrastructure is still heavily
based on Xinerama-style rendering. Specifically, we assume that painting
is driven by a single timer, etc.
This change introduces a new type - RenderLoop. Its main purpose is to
drive compositing on a specific output, or in case of X11, on the
overlay window.
With RenderLoop, compositing is synchronized to vblank events. It
exposes the last and the next estimated presentation timestamp. The
expected presentation timestamp can be used by effects to ensure that
animations are synchronized with the upcoming vblank event.
On Wayland, every outputs has its own render loop. On X11, per screen
rendering is not possible, therefore the platform exposes the render
loop for the overlay window. Ideally, the Scene has to expose the
RenderLoop, but as the first step towards better compositing scheduling
it's good as is for the time being.
The RenderLoop tries to minimize the latency by delaying compositing as
close as possible to the next vblank event. One tricky thing about it is
that if compositing is too close to the next vblank event, animations
may become a little bit choppy. However, increasing the latency reduces
the choppiness.
Given that, there is no any "silver bullet" solution for the choppiness
issue, a new option has been added in the Compositing KCM to specify the
amount of latency. By default, it's "Medium," but if a user is not
satisfied with the upstream default, they can tweak it.
2020-11-19 08:52:29 +00:00
|
|
|
qRegisterMetaType<std::chrono::nanoseconds>();
|
2013-08-28 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Application::setConfigLock(bool lock)
|
|
|
|
{
|
|
|
|
m_configLock = lock;
|
|
|
|
}
|
|
|
|
|
2013-06-25 06:52:08 +00:00
|
|
|
Application::OperationMode Application::operationMode() const
|
|
|
|
{
|
|
|
|
return m_operationMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Application::setOperationMode(OperationMode mode)
|
|
|
|
{
|
|
|
|
m_operationMode = mode;
|
|
|
|
}
|
|
|
|
|
2013-06-25 07:53:45 +00:00
|
|
|
bool Application::shouldUseWaylandForCompositing() const
|
|
|
|
{
|
2017-09-30 13:09:06 +00:00
|
|
|
return m_operationMode == OperationModeWaylandOnly || m_operationMode == OperationModeXwayland;
|
2013-06-25 07:53:45 +00:00
|
|
|
}
|
|
|
|
|
2013-08-28 12:10:51 +00:00
|
|
|
void Application::start()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
setQuitOnLastWindowClosed(false);
|
2013-08-28 12:10:51 +00:00
|
|
|
|
2016-01-29 08:48:02 +00:00
|
|
|
if (!m_config) {
|
|
|
|
m_config = KSharedConfig::openConfig();
|
|
|
|
}
|
|
|
|
if (!m_config->isImmutable() && m_configLock) {
|
2009-10-05 06:59:10 +00:00
|
|
|
// TODO: This shouldn't be necessary
|
2008-12-18 15:01:25 +00:00
|
|
|
//config->setReadOnly( true );
|
2016-01-29 08:48:02 +00:00
|
|
|
m_config->reparseConfiguration();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2017-01-27 16:15:32 +00:00
|
|
|
if (!m_kxkbConfig) {
|
|
|
|
m_kxkbConfig = KSharedConfig::openConfig(QStringLiteral("kxkbrc"), KConfig::NoGlobals);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2014-08-12 07:08:48 +00:00
|
|
|
performStartup();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
Application::~Application()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
delete options;
|
2015-05-26 12:26:56 +00:00
|
|
|
destroyAtoms();
|
Fix crash in XRenderPictureData::~XRenderPictureData
Summary:
If the XRender scene has cross-faded a window, then, eventually, KWin/X11 will
crash in the destructor of the XRenderPictureData class during tear down with
the following message in the terminal
```
ASSERT: "qApp" in file /home/vlad/Workspace/KDE/src/kde/workspace/kwin/libkwineffects/kwinxrenderutils.cpp, line 163
```
The crash happens because X11StandalonePlatform attempts to clean up XRender
resources, including XRenderUtils::s_blendPicture, after the application object
has been destroyed.
In order to fix the crash, we have to destroy the platform object before the
destructor of QCoreApplication is executed.
Test Plan:
- Enable maximize effect
- Maximize a window
- Replace the current instance of KWin/X11 with another one
Without this patch, KWin/X11 crashes after the third step.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D25768
2019-12-12 12:06:20 +00:00
|
|
|
destroyPlatform();
|
2015-05-26 12:26:56 +00:00
|
|
|
}
|
|
|
|
|
2020-07-07 09:32:29 +00:00
|
|
|
void Application::notifyStarted()
|
|
|
|
{
|
|
|
|
emit started();
|
|
|
|
}
|
|
|
|
|
2015-05-26 12:26:56 +00:00
|
|
|
void Application::destroyAtoms()
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
delete atoms;
|
2015-05-26 12:26:56 +00:00
|
|
|
atoms = nullptr;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
Fix crash in XRenderPictureData::~XRenderPictureData
Summary:
If the XRender scene has cross-faded a window, then, eventually, KWin/X11 will
crash in the destructor of the XRenderPictureData class during tear down with
the following message in the terminal
```
ASSERT: "qApp" in file /home/vlad/Workspace/KDE/src/kde/workspace/kwin/libkwineffects/kwinxrenderutils.cpp, line 163
```
The crash happens because X11StandalonePlatform attempts to clean up XRender
resources, including XRenderUtils::s_blendPicture, after the application object
has been destroyed.
In order to fix the crash, we have to destroy the platform object before the
destructor of QCoreApplication is executed.
Test Plan:
- Enable maximize effect
- Maximize a window
- Replace the current instance of KWin/X11 with another one
Without this patch, KWin/X11 crashes after the third step.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D25768
2019-12-12 12:06:20 +00:00
|
|
|
void Application::destroyPlatform()
|
|
|
|
{
|
|
|
|
delete m_platform;
|
|
|
|
m_platform = nullptr;
|
|
|
|
}
|
|
|
|
|
2007-09-27 14:53:52 +00:00
|
|
|
void Application::resetCrashesCount()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-09-27 14:53:52 +00:00
|
|
|
crashes = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-09-27 14:53:52 +00:00
|
|
|
|
2013-08-28 12:10:51 +00:00
|
|
|
void Application::setCrashCount(int count)
|
|
|
|
{
|
|
|
|
crashes = count;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Application::wasCrash()
|
|
|
|
{
|
|
|
|
return crashes > 0;
|
|
|
|
}
|
|
|
|
|
2014-08-12 07:08:48 +00:00
|
|
|
static const char description[] = I18N_NOOP("KDE window manager");
|
|
|
|
|
|
|
|
void Application::createAboutData()
|
2013-07-26 05:52:56 +00:00
|
|
|
{
|
2014-08-12 07:08:48 +00:00
|
|
|
KAboutData aboutData(QStringLiteral(KWIN_NAME), // The program name used internally
|
|
|
|
i18n("KWin"), // A displayable program name string
|
|
|
|
QStringLiteral(KWIN_VERSION_STRING), // The program version string
|
|
|
|
i18n(description), // Short description of what the app does
|
|
|
|
KAboutLicense::GPL, // The license this code is released under
|
2019-12-01 09:46:59 +00:00
|
|
|
i18n("(c) 1999-2019, The KDE Developers")); // Copyright Statement
|
2014-08-12 07:08:48 +00:00
|
|
|
|
|
|
|
aboutData.addAuthor(i18n("Matthias Ettrich"), QString(), QStringLiteral("ettrich@kde.org"));
|
|
|
|
aboutData.addAuthor(i18n("Cristian Tibirna"), QString(), QStringLiteral("tibirna@kde.org"));
|
|
|
|
aboutData.addAuthor(i18n("Daniel M. Duley"), QString(), QStringLiteral("mosfet@kde.org"));
|
|
|
|
aboutData.addAuthor(i18n("Luboš Luňák"), QString(), QStringLiteral("l.lunak@kde.org"));
|
2018-12-02 18:23:07 +00:00
|
|
|
aboutData.addAuthor(i18n("Martin Flöser"), QString(), QStringLiteral("mgraesslin@kde.org"));
|
2019-12-01 09:46:59 +00:00
|
|
|
aboutData.addAuthor(i18n("David Edmundson"), QStringLiteral("Maintainer"), QStringLiteral("davidedmundson@kde.org"));
|
|
|
|
aboutData.addAuthor(i18n("Roman Gilg"), QStringLiteral("Maintainer"), QStringLiteral("subdiff@gmail.com"));
|
2020-01-14 16:17:18 +00:00
|
|
|
aboutData.addAuthor(i18n("Vlad Zahorodnii"), QStringLiteral("Maintainer"), QStringLiteral("vlad.zahorodnii@kde.org"));
|
2014-08-12 07:08:48 +00:00
|
|
|
KAboutData::setApplicationData(aboutData);
|
2013-07-26 05:52:56 +00:00
|
|
|
}
|
|
|
|
|
2014-08-12 07:08:48 +00:00
|
|
|
static const QString s_lockOption = QStringLiteral("lock");
|
|
|
|
static const QString s_crashesOption = QStringLiteral("crashes");
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2014-08-12 07:08:48 +00:00
|
|
|
void Application::setupCommandLine(QCommandLineParser *parser)
|
|
|
|
{
|
|
|
|
QCommandLineOption lockOption(s_lockOption, i18n("Disable configuration options"));
|
|
|
|
QCommandLineOption crashesOption(s_crashesOption, i18n("Indicate that KWin has recently crashed n times"), QStringLiteral("n"));
|
|
|
|
|
|
|
|
parser->setApplicationDescription(i18n("KDE window manager"));
|
|
|
|
parser->addOption(lockOption);
|
|
|
|
parser->addOption(crashesOption);
|
|
|
|
KAboutData::applicationData().setupCommandLine(parser);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2014-08-12 07:08:48 +00:00
|
|
|
void Application::processCommandLine(QCommandLineParser *parser)
|
|
|
|
{
|
2018-12-02 18:23:07 +00:00
|
|
|
KAboutData aboutData = KAboutData::applicationData();
|
|
|
|
aboutData.processCommandLine(parser);
|
2014-08-12 07:08:48 +00:00
|
|
|
setConfigLock(parser->isSet(s_lockOption));
|
|
|
|
Application::setCrashCount(parser->value(s_crashesOption).toInt());
|
|
|
|
}
|
|
|
|
|
|
|
|
void Application::setupTranslator()
|
|
|
|
{
|
2015-01-12 19:10:38 +00:00
|
|
|
QTranslator *qtTranslator = new QTranslator(qApp);
|
|
|
|
qtTranslator->load("qt_" + QLocale::system().name(),
|
|
|
|
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
|
|
|
installTranslator(qtTranslator);
|
2014-08-12 07:08:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Application::setupMalloc()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-03-30 07:54:18 +00:00
|
|
|
#ifdef M_TRIM_THRESHOLD
|
|
|
|
// Prevent fragmentation of the heap by malloc (glibc).
|
|
|
|
//
|
|
|
|
// The default threshold is 128*1024, which can result in a large memory usage
|
|
|
|
// due to fragmentation especially if we use the raster graphicssystem. On the
|
|
|
|
// otherside if the threshold is too low, free() starts to permanently ask the kernel
|
|
|
|
// about shrinking the heap.
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
const int pagesize = sysconf(_SC_PAGESIZE);
|
|
|
|
#else
|
|
|
|
const int pagesize = 4*1024;
|
|
|
|
#endif // HAVE_UNISTD_H
|
|
|
|
mallopt(M_TRIM_THRESHOLD, 5*pagesize);
|
|
|
|
#endif // M_TRIM_THRESHOLD
|
2014-08-12 07:08:48 +00:00
|
|
|
}
|
2011-05-21 12:32:30 +00:00
|
|
|
|
2014-08-12 07:08:48 +00:00
|
|
|
void Application::setupLocalizedString()
|
|
|
|
{
|
2014-04-29 06:51:04 +00:00
|
|
|
KLocalizedString::setApplicationDomain("kwin");
|
2014-08-12 07:08:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Application::createWorkspace()
|
|
|
|
{
|
|
|
|
// we want all QQuickWindows with an alpha buffer, do here as Workspace might create QQuickWindows
|
|
|
|
QQuickWindow::setDefaultAlphaBuffer(true);
|
2008-12-18 15:01:25 +00:00
|
|
|
|
2014-08-12 07:08:48 +00:00
|
|
|
// This tries to detect compositing options and can use GLX. GLX problems
|
|
|
|
// (X errors) shouldn't cause kwin to abort, so this is out of the
|
|
|
|
// critical startup section where x errors cause kwin to abort.
|
2010-06-13 20:22:50 +00:00
|
|
|
|
2014-08-12 07:08:48 +00:00
|
|
|
// create workspace.
|
2020-04-02 11:44:27 +00:00
|
|
|
(void) new Workspace();
|
2015-02-23 14:53:24 +00:00
|
|
|
emit workspaceCreated();
|
2014-08-12 07:08:48 +00:00
|
|
|
}
|
2014-03-09 11:37:21 +00:00
|
|
|
|
2020-12-21 18:17:56 +00:00
|
|
|
void Application::createSession()
|
|
|
|
{
|
|
|
|
LogindIntegration::create(this);
|
|
|
|
}
|
|
|
|
|
2015-02-20 13:53:03 +00:00
|
|
|
void Application::createInput()
|
|
|
|
{
|
2016-08-15 06:37:24 +00:00
|
|
|
ScreenLockerWatcher::create(this);
|
2015-06-26 11:47:08 +00:00
|
|
|
auto input = InputRedirection::create(this);
|
|
|
|
input->init();
|
2016-08-15 10:00:03 +00:00
|
|
|
m_platform->createPlatformCursor(this);
|
2015-02-20 13:53:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Application::createScreens()
|
|
|
|
{
|
|
|
|
if (Screens::self()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Screens::create(this);
|
2015-03-27 14:14:23 +00:00
|
|
|
emit screensCreated();
|
2015-02-20 13:53:03 +00:00
|
|
|
}
|
|
|
|
|
2014-08-12 07:08:48 +00:00
|
|
|
void Application::createAtoms()
|
|
|
|
{
|
|
|
|
atoms = new Atoms;
|
|
|
|
}
|
2013-08-28 12:10:51 +00:00
|
|
|
|
2014-08-12 07:08:48 +00:00
|
|
|
void Application::createOptions()
|
|
|
|
{
|
|
|
|
options = new Options;
|
|
|
|
}
|
2014-06-04 13:59:03 +00:00
|
|
|
|
2020-11-26 18:41:20 +00:00
|
|
|
void Application::createPlugins()
|
|
|
|
{
|
|
|
|
PluginManager::create(this);
|
|
|
|
}
|
|
|
|
|
2020-11-27 19:37:40 +00:00
|
|
|
void Application::createColorManager()
|
|
|
|
{
|
|
|
|
#ifdef KWIN_BUILD_CMS
|
|
|
|
ColorManager::create(this);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2020-07-20 08:07:08 +00:00
|
|
|
void Application::installNativeX11EventFilter()
|
2014-08-12 07:08:48 +00:00
|
|
|
{
|
|
|
|
installNativeEventFilter(m_eventFilter.data());
|
|
|
|
}
|
2013-08-28 12:10:51 +00:00
|
|
|
|
2020-07-20 08:07:08 +00:00
|
|
|
void Application::removeNativeX11EventFilter()
|
|
|
|
{
|
|
|
|
removeNativeEventFilter(m_eventFilter.data());
|
|
|
|
}
|
|
|
|
|
2014-08-12 07:08:48 +00:00
|
|
|
void Application::destroyWorkspace()
|
|
|
|
{
|
|
|
|
delete Workspace::self();
|
|
|
|
}
|
2013-08-28 12:10:51 +00:00
|
|
|
|
2015-05-27 07:09:05 +00:00
|
|
|
void Application::destroyCompositor()
|
|
|
|
{
|
|
|
|
delete Compositor::self();
|
2020-11-26 18:41:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Application::destroyPlugins()
|
|
|
|
{
|
|
|
|
delete PluginManager::self();
|
2015-05-27 07:09:05 +00:00
|
|
|
}
|
|
|
|
|
2020-11-27 19:37:40 +00:00
|
|
|
void Application::destroyColorManager()
|
|
|
|
{
|
|
|
|
#ifdef KWIN_BUILD_CMS
|
|
|
|
delete ColorManager::self();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-02-19 08:59:21 +00:00
|
|
|
void Application::updateX11Time(xcb_generic_event_t *event)
|
|
|
|
{
|
|
|
|
xcb_timestamp_t time = XCB_TIME_CURRENT_TIME;
|
|
|
|
const uint8_t eventType = event->response_type & ~0x80;
|
|
|
|
switch(eventType) {
|
|
|
|
case XCB_KEY_PRESS:
|
|
|
|
case XCB_KEY_RELEASE:
|
|
|
|
time = reinterpret_cast<xcb_key_press_event_t*>(event)->time;
|
|
|
|
break;
|
|
|
|
case XCB_BUTTON_PRESS:
|
|
|
|
case XCB_BUTTON_RELEASE:
|
|
|
|
time = reinterpret_cast<xcb_button_press_event_t*>(event)->time;
|
|
|
|
break;
|
|
|
|
case XCB_MOTION_NOTIFY:
|
|
|
|
time = reinterpret_cast<xcb_motion_notify_event_t*>(event)->time;
|
|
|
|
break;
|
|
|
|
case XCB_ENTER_NOTIFY:
|
|
|
|
case XCB_LEAVE_NOTIFY:
|
|
|
|
time = reinterpret_cast<xcb_enter_notify_event_t*>(event)->time;
|
|
|
|
break;
|
|
|
|
case XCB_FOCUS_IN:
|
|
|
|
case XCB_FOCUS_OUT:
|
|
|
|
case XCB_KEYMAP_NOTIFY:
|
|
|
|
case XCB_EXPOSE:
|
|
|
|
case XCB_GRAPHICS_EXPOSURE:
|
|
|
|
case XCB_NO_EXPOSURE:
|
|
|
|
case XCB_VISIBILITY_NOTIFY:
|
|
|
|
case XCB_CREATE_NOTIFY:
|
|
|
|
case XCB_DESTROY_NOTIFY:
|
|
|
|
case XCB_UNMAP_NOTIFY:
|
|
|
|
case XCB_MAP_NOTIFY:
|
|
|
|
case XCB_MAP_REQUEST:
|
|
|
|
case XCB_REPARENT_NOTIFY:
|
|
|
|
case XCB_CONFIGURE_NOTIFY:
|
|
|
|
case XCB_CONFIGURE_REQUEST:
|
|
|
|
case XCB_GRAVITY_NOTIFY:
|
|
|
|
case XCB_RESIZE_REQUEST:
|
|
|
|
case XCB_CIRCULATE_NOTIFY:
|
|
|
|
case XCB_CIRCULATE_REQUEST:
|
|
|
|
// no timestamp
|
|
|
|
return;
|
|
|
|
case XCB_PROPERTY_NOTIFY:
|
|
|
|
time = reinterpret_cast<xcb_property_notify_event_t*>(event)->time;
|
|
|
|
break;
|
|
|
|
case XCB_SELECTION_CLEAR:
|
|
|
|
time = reinterpret_cast<xcb_selection_clear_event_t*>(event)->time;
|
|
|
|
break;
|
|
|
|
case XCB_SELECTION_REQUEST:
|
|
|
|
time = reinterpret_cast<xcb_selection_request_event_t*>(event)->time;
|
|
|
|
break;
|
|
|
|
case XCB_SELECTION_NOTIFY:
|
|
|
|
time = reinterpret_cast<xcb_selection_notify_event_t*>(event)->time;
|
|
|
|
break;
|
|
|
|
case XCB_COLORMAP_NOTIFY:
|
|
|
|
case XCB_CLIENT_MESSAGE:
|
|
|
|
case XCB_MAPPING_NOTIFY:
|
|
|
|
case XCB_GE_GENERIC:
|
|
|
|
// no timestamp
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
// extension handling
|
|
|
|
if (Xcb::Extensions::self()) {
|
|
|
|
if (eventType == Xcb::Extensions::self()->shapeNotifyEvent()) {
|
|
|
|
time = reinterpret_cast<xcb_shape_notify_event_t*>(event)->server_time;
|
|
|
|
}
|
|
|
|
if (eventType == Xcb::Extensions::self()->damageNotifyEvent()) {
|
|
|
|
time = reinterpret_cast<xcb_damage_notify_event_t*>(event)->timestamp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
setX11Time(time);
|
|
|
|
}
|
|
|
|
|
2014-08-12 07:08:48 +00:00
|
|
|
bool XcbEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, long int *result)
|
|
|
|
{
|
|
|
|
Q_UNUSED(result)
|
2015-02-19 08:59:21 +00:00
|
|
|
if (eventType != "xcb_generic_event_t") {
|
2014-08-12 07:08:48 +00:00
|
|
|
return false;
|
2014-03-09 11:37:21 +00:00
|
|
|
}
|
2015-02-19 08:59:21 +00:00
|
|
|
auto event = static_cast<xcb_generic_event_t *>(message);
|
|
|
|
kwinApp()->updateX11Time(event);
|
|
|
|
if (!Workspace::self()) {
|
|
|
|
// Workspace not yet created
|
2014-08-12 07:08:48 +00:00
|
|
|
return false;
|
2014-03-09 11:37:21 +00:00
|
|
|
}
|
2015-02-19 08:59:21 +00:00
|
|
|
return Workspace::self()->workspaceEvent(event);
|
2010-05-31 21:24:40 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2014-08-15 12:03:52 +00:00
|
|
|
static bool s_useLibinput = false;
|
|
|
|
|
|
|
|
void Application::setUseLibinput(bool use)
|
|
|
|
{
|
|
|
|
s_useLibinput = use;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Application::usesLibinput()
|
|
|
|
{
|
|
|
|
return s_useLibinput;
|
|
|
|
}
|
|
|
|
|
2015-07-07 15:35:57 +00:00
|
|
|
QProcessEnvironment Application::processStartupEnvironment() const
|
|
|
|
{
|
|
|
|
return QProcessEnvironment::systemEnvironment();
|
|
|
|
}
|
|
|
|
|
2016-04-06 15:30:00 +00:00
|
|
|
void Application::initPlatform(const KPluginMetaData &plugin)
|
|
|
|
{
|
|
|
|
Q_ASSERT(!m_platform);
|
2016-04-07 07:18:10 +00:00
|
|
|
m_platform = qobject_cast<Platform *>(plugin.instantiate());
|
2016-04-06 15:30:00 +00:00
|
|
|
if (m_platform) {
|
|
|
|
m_platform->setParent(this);
|
|
|
|
// check whether it needs libinput
|
|
|
|
const QJsonObject &metaData = plugin.rawData();
|
|
|
|
auto it = metaData.find(QStringLiteral("input"));
|
|
|
|
if (it != metaData.end()) {
|
|
|
|
if ((*it).isBool()) {
|
|
|
|
if (!(*it).toBool()) {
|
|
|
|
qCDebug(KWIN_CORE) << "Platform does not support input, enforcing libinput support";
|
|
|
|
setUseLibinput(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-12-03 19:47:42 +00:00
|
|
|
emit platformCreated();
|
2016-04-06 15:30:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-22 00:20:16 +00:00
|
|
|
ApplicationWaylandAbstract::ApplicationWaylandAbstract(OperationMode mode, int &argc, char **argv)
|
|
|
|
: Application(mode, argc, argv)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ApplicationWaylandAbstract::~ApplicationWaylandAbstract()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-08-12 07:08:48 +00:00
|
|
|
} // namespace
|
|
|
|
|