2013-06-17 11:35:45 +04: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 12:28:31 +04:00
|
|
|
// KWin
|
2015-03-20 16:41:03 +03:00
|
|
|
#include "abstract_backend.h"
|
2015-03-23 12:07:59 +03:00
|
|
|
#include <config-kwin.h>
|
2013-06-17 12:28:31 +04:00
|
|
|
#include <kwinglobals.h>
|
2013-06-17 11:35:45 +04:00
|
|
|
// Qt
|
|
|
|
#include <QHash>
|
2013-06-18 13:48:23 +04:00
|
|
|
#include <QImage>
|
2013-06-17 11:35:45 +04:00
|
|
|
#include <QObject>
|
|
|
|
#include <QPoint>
|
|
|
|
#include <QSize>
|
|
|
|
|
|
|
|
class QTemporaryFile;
|
2014-10-16 18:39:49 +04:00
|
|
|
struct wl_cursor_image;
|
2013-06-27 11:58:04 +04:00
|
|
|
struct wl_cursor_theme;
|
2013-06-17 11:35:45 +04:00
|
|
|
struct wl_buffer;
|
2014-08-21 13:30:56 +04:00
|
|
|
struct wl_display;
|
2014-08-13 14:54:02 +04:00
|
|
|
struct wl_event_queue;
|
2014-08-21 13:30:56 +04:00
|
|
|
struct wl_seat;
|
2013-06-17 11:35:45 +04:00
|
|
|
|
2014-09-19 15:59:51 +04:00
|
|
|
namespace KWayland
|
2013-06-17 11:35:45 +04:00
|
|
|
{
|
2014-09-19 15:59:51 +04:00
|
|
|
namespace Client
|
2013-06-17 11:35:45 +04:00
|
|
|
{
|
2014-10-15 16:29:26 +04:00
|
|
|
class Buffer;
|
2013-06-17 11:35:45 +04:00
|
|
|
class ShmPool;
|
2014-08-21 10:53:00 +04:00
|
|
|
class Compositor;
|
2014-08-13 14:54:02 +04:00
|
|
|
class ConnectionThread;
|
2014-09-23 15:15:49 +04:00
|
|
|
class EventQueue;
|
2014-08-19 11:31:31 +04:00
|
|
|
class FullscreenShell;
|
2014-08-21 13:20:03 +04:00
|
|
|
class Keyboard;
|
2014-08-19 18:08:02 +04:00
|
|
|
class Output;
|
2014-08-21 13:20:03 +04:00
|
|
|
class Pointer;
|
2014-08-18 16:05:35 +04:00
|
|
|
class Registry;
|
2014-08-21 13:20:03 +04:00
|
|
|
class Seat;
|
2014-08-20 13:27:09 +04:00
|
|
|
class Shell;
|
|
|
|
class ShellSurface;
|
2014-10-16 18:39:49 +04:00
|
|
|
class SubCompositor;
|
|
|
|
class SubSurface;
|
2014-08-20 16:06:58 +04:00
|
|
|
class Surface;
|
2015-03-25 16:50:14 +03:00
|
|
|
class Touch;
|
2014-09-19 15:59:51 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace Wayland
|
|
|
|
{
|
|
|
|
|
|
|
|
class WaylandBackend;
|
|
|
|
class WaylandSeat;
|
2013-06-17 11:35:45 +04:00
|
|
|
|
2015-03-23 12:07:59 +03:00
|
|
|
#if HAVE_WAYLAND_CURSOR
|
2014-10-16 18:39:49 +04:00
|
|
|
class WaylandCursorTheme : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2015-04-02 15:25:51 +03:00
|
|
|
explicit WaylandCursorTheme(KWayland::Client::ShmPool *shm, QObject *parent = nullptr);
|
2014-10-16 18:39:49 +04:00
|
|
|
virtual ~WaylandCursorTheme();
|
|
|
|
|
|
|
|
wl_cursor_image *get(Qt::CursorShape shape);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void loadTheme();
|
|
|
|
void destroyTheme();
|
|
|
|
wl_cursor_theme *m_theme;
|
2015-04-02 15:25:51 +03:00
|
|
|
KWayland::Client::ShmPool *m_shm = nullptr;
|
2014-10-16 18:39:49 +04:00
|
|
|
};
|
2015-03-23 12:07:59 +03:00
|
|
|
#endif
|
2014-10-16 18:39:49 +04:00
|
|
|
|
2013-06-27 11:58:04 +04:00
|
|
|
class WaylandSeat : public QObject
|
2013-06-17 11:35:45 +04:00
|
|
|
{
|
2013-06-27 11:58:04 +04:00
|
|
|
Q_OBJECT
|
2013-06-17 11:35:45 +04:00
|
|
|
public:
|
|
|
|
WaylandSeat(wl_seat *seat, WaylandBackend *backend);
|
|
|
|
virtual ~WaylandSeat();
|
|
|
|
|
2013-06-27 10:25:59 +04:00
|
|
|
void installCursorImage(wl_buffer *image, const QSize &size, const QPoint &hotspot);
|
2013-06-27 11:58:04 +04:00
|
|
|
void installCursorImage(Qt::CursorShape shape);
|
2015-02-27 19:46:41 +03:00
|
|
|
void installCursorImage(const QImage &image, const QPoint &hotspot);
|
2014-10-16 18:39:49 +04:00
|
|
|
void setInstallCursor(bool install);
|
|
|
|
bool isInstallCursor() const {
|
|
|
|
return m_installCursor;
|
|
|
|
}
|
2013-06-17 11:35:45 +04:00
|
|
|
private:
|
|
|
|
void destroyPointer();
|
|
|
|
void destroyKeyboard();
|
2015-03-25 16:50:14 +03:00
|
|
|
void destroyTouch();
|
2014-09-19 15:59:51 +04:00
|
|
|
KWayland::Client::Seat *m_seat;
|
|
|
|
KWayland::Client::Pointer *m_pointer;
|
|
|
|
KWayland::Client::Keyboard *m_keyboard;
|
2015-03-25 16:50:14 +03:00
|
|
|
KWayland::Client::Touch *m_touch;
|
2014-09-19 15:59:51 +04:00
|
|
|
KWayland::Client::Surface *m_cursor;
|
2015-03-23 12:07:59 +03:00
|
|
|
#if HAVE_WAYLAND_CURSOR
|
2014-10-16 18:39:49 +04:00
|
|
|
WaylandCursorTheme *m_theme;
|
2015-03-23 12:07:59 +03:00
|
|
|
#endif
|
2013-06-27 10:25:59 +04:00
|
|
|
uint32_t m_enteredSerial;
|
2013-06-17 11:35:45 +04:00
|
|
|
WaylandBackend *m_backend;
|
2014-10-16 18:39:49 +04:00
|
|
|
bool m_installCursor;
|
|
|
|
};
|
|
|
|
|
|
|
|
class WaylandCursor : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit WaylandCursor(KWayland::Client::Surface *parentSurface, WaylandBackend *backend);
|
|
|
|
|
|
|
|
void setHotSpot(const QPoint &pos);
|
|
|
|
const QPoint &hotSpot() const {
|
|
|
|
return m_hotSpot;
|
|
|
|
}
|
|
|
|
void setCursorImage(wl_buffer *image, const QSize &size, const QPoint &hotspot);
|
2015-02-27 19:46:41 +03:00
|
|
|
void setCursorImage(const QImage &image, const QPoint &hotspot);
|
2014-10-16 18:39:49 +04:00
|
|
|
void setCursorImage(Qt::CursorShape shape);
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void hotSpotChanged(const QPoint &);
|
|
|
|
|
|
|
|
private:
|
|
|
|
WaylandBackend *m_backend;
|
|
|
|
QPoint m_hotSpot;
|
|
|
|
KWayland::Client::SubSurface *m_subSurface;
|
2015-03-23 12:07:59 +03:00
|
|
|
#if HAVE_WAYLAND_CURSOR
|
2014-10-16 18:39:49 +04:00
|
|
|
WaylandCursorTheme *m_theme;
|
2015-03-23 12:07:59 +03:00
|
|
|
#endif
|
2013-06-17 11:35:45 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Class encapsulating all Wayland data structures needed by the Egl backend.
|
|
|
|
*
|
2014-08-12 02:16:26 +04: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 11:35:45 +04:00
|
|
|
*/
|
2015-03-20 16:41:03 +03:00
|
|
|
class KWIN_EXPORT WaylandBackend : public AbstractBackend
|
2013-06-17 11:35:45 +04:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2015-03-23 16:29:07 +03:00
|
|
|
explicit WaylandBackend(const QByteArray &display, QObject *parent = nullptr);
|
2013-06-17 11:35:45 +04:00
|
|
|
virtual ~WaylandBackend();
|
|
|
|
wl_display *display();
|
2014-09-19 15:59:51 +04:00
|
|
|
KWayland::Client::Compositor *compositor();
|
|
|
|
const QList<KWayland::Client::Output*> &outputs() const;
|
|
|
|
KWayland::Client::ShmPool *shmPool();
|
2014-10-16 18:39:49 +04:00
|
|
|
KWayland::Client::SubCompositor *subCompositor();
|
2013-06-17 11:35:45 +04:00
|
|
|
|
2014-09-19 15:59:51 +04:00
|
|
|
KWayland::Client::Surface *surface() const;
|
2014-08-20 13:27:09 +04:00
|
|
|
QSize shellSurfaceSize() const;
|
2015-03-20 16:41:03 +03:00
|
|
|
void installCursorImage(Qt::CursorShape shape) override;
|
|
|
|
void installCursorFromServer() override;
|
2015-02-21 11:30:22 +03:00
|
|
|
|
2015-03-27 09:52:59 +03:00
|
|
|
Screens *createScreens(QObject *parent = nullptr) override;
|
2015-03-27 10:51:56 +03:00
|
|
|
OpenGLBackend *createOpenGLBackend() override;
|
2015-03-27 11:05:03 +03:00
|
|
|
QPainterBackend *createQPainterBackend() override;
|
2015-03-27 09:52:59 +03:00
|
|
|
|
2015-02-21 11:30:22 +03:00
|
|
|
protected:
|
|
|
|
void connectNotify(const QMetaMethod &signal) override;
|
|
|
|
|
2013-06-17 11:35:45 +04:00
|
|
|
Q_SIGNALS:
|
|
|
|
void shellSurfaceSizeChanged(const QSize &size);
|
2013-07-03 13:56:05 +04:00
|
|
|
void systemCompositorDied();
|
|
|
|
void backendReady();
|
2013-07-05 13:11:25 +04:00
|
|
|
void outputsChanged();
|
2014-08-13 14:54:02 +04:00
|
|
|
void connectionFailed();
|
2013-06-17 11:35:45 +04:00
|
|
|
private:
|
2013-07-03 13:56:05 +04:00
|
|
|
void initConnection();
|
2013-06-17 11:35:45 +04:00
|
|
|
void createSurface();
|
2013-07-05 13:11:25 +04:00
|
|
|
void destroyOutputs();
|
2014-08-20 13:27:09 +04:00
|
|
|
void checkBackendReady();
|
2013-06-17 11:35:45 +04:00
|
|
|
wl_display *m_display;
|
2014-09-23 15:15:49 +04:00
|
|
|
KWayland::Client::EventQueue *m_eventQueue;
|
2014-09-19 15:59:51 +04: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;
|
2013-06-17 11:35:45 +04:00
|
|
|
QScopedPointer<WaylandSeat> m_seat;
|
2014-09-19 15:59:51 +04:00
|
|
|
KWayland::Client::ShmPool *m_shm;
|
|
|
|
QList<KWayland::Client::Output*> m_outputs;
|
|
|
|
KWayland::Client::ConnectionThread *m_connectionThreadObject;
|
2014-08-13 14:54:02 +04:00
|
|
|
QThread *m_connectionThread;
|
2014-09-19 15:59:51 +04:00
|
|
|
KWayland::Client::FullscreenShell *m_fullscreenShell;
|
2014-10-16 18:39:49 +04:00
|
|
|
KWayland::Client::SubCompositor *m_subCompositor;
|
|
|
|
WaylandCursor *m_cursor;
|
2015-02-21 11:30:22 +03:00
|
|
|
bool m_ready = false;
|
2013-06-17 11:35:45 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
inline
|
|
|
|
wl_display *WaylandBackend::display()
|
|
|
|
{
|
|
|
|
return m_display;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
2014-09-19 15:59:51 +04:00
|
|
|
KWayland::Client::Compositor *WaylandBackend::compositor()
|
2013-06-17 11:35:45 +04:00
|
|
|
{
|
|
|
|
return m_compositor;
|
|
|
|
}
|
|
|
|
|
2014-10-16 18:39:49 +04:00
|
|
|
inline
|
|
|
|
KWayland::Client::SubCompositor *WaylandBackend::subCompositor()
|
|
|
|
{
|
|
|
|
return m_subCompositor;
|
|
|
|
}
|
|
|
|
|
2013-06-17 11:35:45 +04:00
|
|
|
inline
|
2014-09-19 15:59:51 +04:00
|
|
|
KWayland::Client::ShmPool* WaylandBackend::shmPool()
|
2013-06-17 11:35:45 +04:00
|
|
|
{
|
2014-08-21 09:54:16 +04:00
|
|
|
return m_shm;
|
2013-06-17 11:35:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
2014-09-19 15:59:51 +04:00
|
|
|
KWayland::Client::Surface *WaylandBackend::surface() const
|
2013-06-17 11:35:45 +04:00
|
|
|
{
|
|
|
|
return m_surface;
|
|
|
|
}
|
|
|
|
|
2013-07-05 13:11:25 +04:00
|
|
|
inline
|
2014-09-19 15:59:51 +04:00
|
|
|
const QList< KWayland::Client::Output* >& WaylandBackend::outputs() const
|
2013-07-05 13:11:25 +04:00
|
|
|
{
|
|
|
|
return m_outputs;
|
|
|
|
}
|
|
|
|
|
2013-06-17 11:35:45 +04:00
|
|
|
} // namespace Wayland
|
|
|
|
} // namespace KWin
|
|
|
|
|
|
|
|
#endif // KWIN_WAYLAND_BACKEND_H
|