2013-06-17 07:35:45 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2013 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
|
|
|
|
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_WAYLAND_BACKEND_H
|
|
|
|
#define KWIN_WAYLAND_BACKEND_H
|
2013-06-17 08:28:31 +00:00
|
|
|
// KWin
|
2016-04-07 07:24:17 +00:00
|
|
|
#include "platform.h"
|
2015-03-23 09:07:59 +00:00
|
|
|
#include <config-kwin.h>
|
2013-06-17 08:28:31 +00:00
|
|
|
#include <kwinglobals.h>
|
2013-06-17 07:35:45 +00:00
|
|
|
// Qt
|
|
|
|
#include <QHash>
|
2013-06-18 09:48:23 +00:00
|
|
|
#include <QImage>
|
2013-06-17 07:35:45 +00:00
|
|
|
#include <QObject>
|
|
|
|
#include <QPoint>
|
|
|
|
#include <QSize>
|
|
|
|
|
|
|
|
class QTemporaryFile;
|
|
|
|
struct wl_buffer;
|
2014-08-21 09:30:56 +00:00
|
|
|
struct wl_display;
|
2014-08-13 10:54:02 +00:00
|
|
|
struct wl_event_queue;
|
2014-08-21 09:30:56 +00:00
|
|
|
struct wl_seat;
|
2013-06-17 07:35:45 +00:00
|
|
|
|
2014-09-19 11:59:51 +00:00
|
|
|
namespace KWayland
|
2013-06-17 07:35:45 +00:00
|
|
|
{
|
2014-09-19 11:59:51 +00:00
|
|
|
namespace Client
|
2013-06-17 07:35:45 +00:00
|
|
|
{
|
2014-10-15 12:29:26 +00:00
|
|
|
class Buffer;
|
2013-06-17 07:35:45 +00:00
|
|
|
class ShmPool;
|
2014-08-21 06:53:00 +00:00
|
|
|
class Compositor;
|
2016-11-24 12:51:15 +00:00
|
|
|
class ConfinedPointer;
|
2014-08-13 10:54:02 +00:00
|
|
|
class ConnectionThread;
|
2014-09-23 11:15:49 +00:00
|
|
|
class EventQueue;
|
2014-08-21 09:20:03 +00:00
|
|
|
class Keyboard;
|
|
|
|
class Pointer;
|
2016-11-24 12:51:15 +00:00
|
|
|
class PointerConstraints;
|
2017-03-15 16:56:08 +00:00
|
|
|
class PointerGestures;
|
|
|
|
class PointerSwipeGesture;
|
|
|
|
class PointerPinchGesture;
|
2014-08-18 12:05:35 +00:00
|
|
|
class Registry;
|
2014-08-21 09:20:03 +00:00
|
|
|
class Seat;
|
2014-08-20 09:27:09 +00:00
|
|
|
class Shell;
|
|
|
|
class ShellSurface;
|
2014-08-20 12:06:58 +00:00
|
|
|
class Surface;
|
2015-03-25 13:50:14 +00:00
|
|
|
class Touch;
|
2016-07-11 07:59:05 +00:00
|
|
|
class XdgShell;
|
|
|
|
class XdgShellSurface;
|
2014-09-19 11:59:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
2015-05-05 11:02:16 +00:00
|
|
|
class WaylandCursorTheme;
|
2014-09-19 11:59:51 +00:00
|
|
|
|
|
|
|
namespace Wayland
|
|
|
|
{
|
|
|
|
|
|
|
|
class WaylandBackend;
|
|
|
|
class WaylandSeat;
|
2013-06-17 07:35:45 +00:00
|
|
|
|
2013-06-27 07:58:04 +00:00
|
|
|
class WaylandSeat : public QObject
|
2013-06-17 07:35:45 +00:00
|
|
|
{
|
2013-06-27 07:58:04 +00:00
|
|
|
Q_OBJECT
|
2013-06-17 07:35:45 +00:00
|
|
|
public:
|
|
|
|
WaylandSeat(wl_seat *seat, WaylandBackend *backend);
|
|
|
|
virtual ~WaylandSeat();
|
|
|
|
|
2013-06-27 06:25:59 +00:00
|
|
|
void installCursorImage(wl_buffer *image, const QSize &size, const QPoint &hotspot);
|
2015-02-27 16:46:41 +00:00
|
|
|
void installCursorImage(const QImage &image, const QPoint &hotspot);
|
2014-10-16 14:39:49 +00:00
|
|
|
void setInstallCursor(bool install);
|
|
|
|
bool isInstallCursor() const {
|
|
|
|
return m_installCursor;
|
|
|
|
}
|
2016-11-24 12:51:15 +00:00
|
|
|
|
|
|
|
KWayland::Client::Pointer *pointer() const {
|
|
|
|
return m_pointer;
|
|
|
|
}
|
|
|
|
|
2017-03-15 16:56:08 +00:00
|
|
|
void installGesturesInterface(KWayland::Client::PointerGestures *gesturesInterface) {
|
|
|
|
m_gesturesInterface = gesturesInterface;
|
|
|
|
setupPointerGestures();
|
|
|
|
}
|
|
|
|
|
2013-06-17 07:35:45 +00:00
|
|
|
private:
|
|
|
|
void destroyPointer();
|
|
|
|
void destroyKeyboard();
|
2015-03-25 13:50:14 +00:00
|
|
|
void destroyTouch();
|
2017-03-15 16:56:08 +00:00
|
|
|
void setupPointerGestures();
|
2014-09-19 11:59:51 +00:00
|
|
|
KWayland::Client::Seat *m_seat;
|
|
|
|
KWayland::Client::Pointer *m_pointer;
|
|
|
|
KWayland::Client::Keyboard *m_keyboard;
|
2015-03-25 13:50:14 +00:00
|
|
|
KWayland::Client::Touch *m_touch;
|
2014-09-19 11:59:51 +00:00
|
|
|
KWayland::Client::Surface *m_cursor;
|
2017-03-15 16:56:08 +00:00
|
|
|
KWayland::Client::PointerGestures *m_gesturesInterface = nullptr;
|
|
|
|
KWayland::Client::PointerPinchGesture *m_pinchGesture = nullptr;
|
|
|
|
KWayland::Client::PointerSwipeGesture *m_swipeGesture = nullptr;
|
2013-06-27 06:25:59 +00:00
|
|
|
uint32_t m_enteredSerial;
|
2013-06-17 07:35:45 +00:00
|
|
|
WaylandBackend *m_backend;
|
2014-10-16 14:39:49 +00:00
|
|
|
bool m_installCursor;
|
|
|
|
};
|
|
|
|
|
2013-06-17 07:35:45 +00:00
|
|
|
/**
|
|
|
|
* @brief Class encapsulating all Wayland data structures needed by the Egl backend.
|
|
|
|
*
|
2014-08-11 22:16:26 +00:00
|
|
|
* It creates the connection to the Wayland Compositor, sets up the registry and creates
|
|
|
|
* the Wayland surface and its shell mapping.
|
2013-06-17 07:35:45 +00:00
|
|
|
*/
|
2016-04-07 07:18:10 +00:00
|
|
|
class KWIN_EXPORT WaylandBackend : public Platform
|
2013-06-17 07:35:45 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2016-04-07 07:18:10 +00:00
|
|
|
Q_INTERFACES(KWin::Platform)
|
|
|
|
Q_PLUGIN_METADATA(IID "org.kde.kwin.Platform" FILE "wayland.json")
|
2013-06-17 07:35:45 +00:00
|
|
|
public:
|
2015-05-06 07:37:25 +00:00
|
|
|
explicit WaylandBackend(QObject *parent = nullptr);
|
2013-06-17 07:35:45 +00:00
|
|
|
virtual ~WaylandBackend();
|
2015-05-06 06:32:39 +00:00
|
|
|
void init() override;
|
2013-06-17 07:35:45 +00:00
|
|
|
wl_display *display();
|
2014-09-19 11:59:51 +00:00
|
|
|
KWayland::Client::Compositor *compositor();
|
|
|
|
KWayland::Client::ShmPool *shmPool();
|
2013-06-17 07:35:45 +00:00
|
|
|
|
2014-09-19 11:59:51 +00:00
|
|
|
KWayland::Client::Surface *surface() const;
|
2014-08-20 09:27:09 +00:00
|
|
|
QSize shellSurfaceSize() const;
|
2015-02-21 08:30:22 +00:00
|
|
|
|
2015-03-27 06:52:59 +00:00
|
|
|
Screens *createScreens(QObject *parent = nullptr) override;
|
2015-03-27 07:51:56 +00:00
|
|
|
OpenGLBackend *createOpenGLBackend() override;
|
2015-03-27 08:05:03 +00:00
|
|
|
QPainterBackend *createQPainterBackend() override;
|
2015-03-27 06:52:59 +00:00
|
|
|
|
2015-11-17 09:43:10 +00:00
|
|
|
QSize screenSize() const override {
|
|
|
|
return shellSurfaceSize();
|
|
|
|
}
|
|
|
|
|
2016-02-23 11:29:05 +00:00
|
|
|
void flush();
|
|
|
|
|
2016-11-24 12:51:15 +00:00
|
|
|
void togglePointerConfinement();
|
|
|
|
|
2013-06-17 07:35:45 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
void shellSurfaceSizeChanged(const QSize &size);
|
2013-07-03 09:56:05 +00:00
|
|
|
void systemCompositorDied();
|
2014-08-13 10:54:02 +00:00
|
|
|
void connectionFailed();
|
2013-06-17 07:35:45 +00:00
|
|
|
private:
|
2013-07-03 09:56:05 +00:00
|
|
|
void initConnection();
|
2013-06-17 07:35:45 +00:00
|
|
|
void createSurface();
|
2016-07-11 07:59:05 +00:00
|
|
|
template <class T>
|
|
|
|
void setupSurface(T *surface);
|
2016-11-24 12:51:15 +00:00
|
|
|
void updateWindowTitle();
|
2013-06-17 07:35:45 +00:00
|
|
|
wl_display *m_display;
|
2014-09-23 11:15:49 +00:00
|
|
|
KWayland::Client::EventQueue *m_eventQueue;
|
2014-09-19 11:59:51 +00:00
|
|
|
KWayland::Client::Registry *m_registry;
|
|
|
|
KWayland::Client::Compositor *m_compositor;
|
|
|
|
KWayland::Client::Shell *m_shell;
|
|
|
|
KWayland::Client::Surface *m_surface;
|
|
|
|
KWayland::Client::ShellSurface *m_shellSurface;
|
2016-07-11 07:59:05 +00:00
|
|
|
KWayland::Client::XdgShell *m_xdgShell = nullptr;
|
|
|
|
KWayland::Client::XdgShellSurface *m_xdgShellSurface = nullptr;
|
2013-06-17 07:35:45 +00:00
|
|
|
QScopedPointer<WaylandSeat> m_seat;
|
2014-09-19 11:59:51 +00:00
|
|
|
KWayland::Client::ShmPool *m_shm;
|
|
|
|
KWayland::Client::ConnectionThread *m_connectionThreadObject;
|
2016-11-24 12:51:15 +00:00
|
|
|
KWayland::Client::PointerConstraints *m_pointerConstraints = nullptr;
|
|
|
|
KWayland::Client::ConfinedPointer *m_pointerConfinement = nullptr;
|
2014-08-13 10:54:02 +00:00
|
|
|
QThread *m_connectionThread;
|
2016-11-24 12:51:15 +00:00
|
|
|
bool m_isPointerConfined = false;
|
2013-06-17 07:35:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
inline
|
|
|
|
wl_display *WaylandBackend::display()
|
|
|
|
{
|
|
|
|
return m_display;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
2014-09-19 11:59:51 +00:00
|
|
|
KWayland::Client::Compositor *WaylandBackend::compositor()
|
2013-06-17 07:35:45 +00:00
|
|
|
{
|
|
|
|
return m_compositor;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
2014-09-19 11:59:51 +00:00
|
|
|
KWayland::Client::ShmPool* WaylandBackend::shmPool()
|
2013-06-17 07:35:45 +00:00
|
|
|
{
|
2014-08-21 05:54:16 +00:00
|
|
|
return m_shm;
|
2013-06-17 07:35:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
2014-09-19 11:59:51 +00:00
|
|
|
KWayland::Client::Surface *WaylandBackend::surface() const
|
2013-06-17 07:35:45 +00:00
|
|
|
{
|
|
|
|
return m_surface;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Wayland
|
|
|
|
} // namespace KWin
|
|
|
|
|
|
|
|
#endif // KWIN_WAYLAND_BACKEND_H
|