2019-02-19 08:50:20 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright 2019 Roman Gilg <subdiff@gmail.com>
|
2020-07-20 08:07:08 +00:00
|
|
|
Copyright (C) 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
2019-02-19 08:50:20 +00:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
#ifndef KWIN_XWL_XWAYLAND
|
|
|
|
#define KWIN_XWL_XWAYLAND
|
|
|
|
|
2018-08-22 12:36:11 +00:00
|
|
|
#include "xwayland_interface.h"
|
2019-02-19 08:50:20 +00:00
|
|
|
|
2020-07-20 08:07:08 +00:00
|
|
|
#include <QProcess>
|
|
|
|
#include <QSocketNotifier>
|
|
|
|
|
2018-08-21 20:06:42 +00:00
|
|
|
#include <xcb/xproto.h>
|
|
|
|
|
2019-02-19 08:50:20 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
2018-08-22 00:20:16 +00:00
|
|
|
class ApplicationWaylandAbstract;
|
2019-02-19 08:50:20 +00:00
|
|
|
|
|
|
|
namespace Xwl
|
|
|
|
{
|
2018-08-21 20:06:42 +00:00
|
|
|
class DataBridge;
|
2019-02-19 08:50:20 +00:00
|
|
|
|
2018-08-22 12:36:11 +00:00
|
|
|
class Xwayland : public XwaylandInterface
|
2019-02-19 08:50:20 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2019-07-02 19:56:03 +00:00
|
|
|
|
2019-02-19 08:50:20 +00:00
|
|
|
public:
|
2019-07-02 19:56:03 +00:00
|
|
|
static Xwayland *self();
|
2018-08-21 20:06:42 +00:00
|
|
|
|
2018-08-22 00:20:16 +00:00
|
|
|
Xwayland(ApplicationWaylandAbstract *app, QObject *parent = nullptr);
|
2019-07-02 19:56:03 +00:00
|
|
|
~Xwayland() override;
|
2019-02-19 08:50:20 +00:00
|
|
|
|
2018-08-21 20:06:42 +00:00
|
|
|
const xcb_query_extension_reply_t *xfixes() const {
|
|
|
|
return m_xfixes;
|
|
|
|
}
|
2019-02-19 08:50:20 +00:00
|
|
|
|
2020-07-20 08:07:08 +00:00
|
|
|
/**
|
|
|
|
* Returns the associated Xwayland process or @c null if the Xwayland server is inactive.
|
|
|
|
*/
|
2020-07-20 07:44:13 +00:00
|
|
|
QProcess *process() const override;
|
|
|
|
|
2020-07-20 08:07:08 +00:00
|
|
|
public Q_SLOTS:
|
|
|
|
/**
|
|
|
|
* Starts the Xwayland server.
|
|
|
|
*
|
|
|
|
* This method will spawn an Xwayland process and will establish a new XCB connection to it.
|
|
|
|
* If a fatal error has occurred during the startup, the criticalError() signal is going to
|
|
|
|
* be emitted. If the Xwayland server has started successfully, the started() signal will be
|
|
|
|
* emitted.
|
|
|
|
*
|
|
|
|
* @see started(), stop()
|
|
|
|
*/
|
|
|
|
void start();
|
|
|
|
/**
|
|
|
|
* Stops the Xwayland server.
|
|
|
|
*
|
|
|
|
* This method will destroy the existing XCB connection as well all connected X11 clients.
|
|
|
|
*
|
|
|
|
* A SIGTERM signal will be sent to the Xwayland process. If Xwayland doesn't shut down
|
|
|
|
* within a reasonable amount of time (5 seconds), a SIGKILL signal will be sent and thus
|
|
|
|
* the process will be killed for good.
|
|
|
|
*
|
|
|
|
* If the Xwayland process crashes, the server will be stopped automatically.
|
|
|
|
*
|
|
|
|
* @see start()
|
|
|
|
*/
|
|
|
|
void stop();
|
|
|
|
|
2019-02-19 08:50:20 +00:00
|
|
|
Q_SIGNALS:
|
2020-07-20 08:07:08 +00:00
|
|
|
/**
|
|
|
|
* This signal is emitted when the Xwayland server has been started successfully and it is
|
|
|
|
* ready to accept and manage X11 clients.
|
|
|
|
*/
|
|
|
|
void started();
|
2019-02-19 08:50:20 +00:00
|
|
|
void criticalError(int code);
|
|
|
|
|
2020-07-20 08:07:08 +00:00
|
|
|
private Q_SLOTS:
|
|
|
|
void dispatchEvents();
|
|
|
|
|
|
|
|
void handleXwaylandStarted();
|
|
|
|
void handleXwaylandFinished(int exitCode);
|
|
|
|
void handleXwaylandError(QProcess::ProcessError error);
|
|
|
|
|
2019-02-19 08:50:20 +00:00
|
|
|
private:
|
2020-07-20 08:07:08 +00:00
|
|
|
void installSocketNotifier();
|
|
|
|
void uninstallSocketNotifier();
|
|
|
|
|
2019-02-19 08:50:20 +00:00
|
|
|
void createX11Connection();
|
2020-07-07 10:05:39 +00:00
|
|
|
void destroyX11Connection();
|
2019-02-19 08:50:20 +00:00
|
|
|
void continueStartupWithX();
|
|
|
|
|
2019-07-02 19:56:03 +00:00
|
|
|
DragEventReply dragMoveFilter(Toplevel *target, const QPoint &pos) override;
|
2018-08-22 12:56:48 +00:00
|
|
|
|
2020-07-20 08:07:08 +00:00
|
|
|
int m_displayFileDescriptor = -1;
|
2019-02-19 08:50:20 +00:00
|
|
|
int m_xcbConnectionFd = -1;
|
|
|
|
QProcess *m_xwaylandProcess = nullptr;
|
2018-08-21 20:06:42 +00:00
|
|
|
const xcb_query_extension_reply_t *m_xfixes = nullptr;
|
|
|
|
DataBridge *m_dataBridge = nullptr;
|
2020-07-20 08:07:08 +00:00
|
|
|
QSocketNotifier *m_socketNotifier = nullptr;
|
2018-08-22 00:20:16 +00:00
|
|
|
ApplicationWaylandAbstract *m_app;
|
2019-07-02 19:56:03 +00:00
|
|
|
|
|
|
|
Q_DISABLE_COPY(Xwayland)
|
2019-02-19 08:50:20 +00:00
|
|
|
};
|
|
|
|
|
2019-07-02 19:56:03 +00:00
|
|
|
} // namespace Xwl
|
|
|
|
} // namespace KWin
|
2019-02-19 08:50:20 +00:00
|
|
|
|
|
|
|
#endif
|