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
|
2015-03-20 13:41:03 +00:00
|
|
|
#include "abstract_backend.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;
|
2014-10-16 14:39:49 +00:00
|
|
|
struct wl_cursor_image;
|
2013-06-27 07:58:04 +00:00
|
|
|
struct wl_cursor_theme;
|
2013-06-17 07:35:45 +00:00
|
|
|
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;
|
2014-08-13 10:54:02 +00:00
|
|
|
class ConnectionThread;
|
2014-09-23 11:15:49 +00:00
|
|
|
class EventQueue;
|
2014-08-19 07:31:31 +00:00
|
|
|
class FullscreenShell;
|
2014-08-21 09:20:03 +00:00
|
|
|
class Keyboard;
|
2014-08-19 14:08:02 +00:00
|
|
|
class Output;
|
2014-08-21 09:20:03 +00:00
|
|
|
class Pointer;
|
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-10-16 14:39:49 +00:00
|
|
|
class SubCompositor;
|
|
|
|
class SubSurface;
|
2014-08-20 12:06:58 +00:00
|
|
|
class Surface;
|
2015-03-25 13:50:14 +00:00
|
|
|
class Touch;
|
2014-09-19 11:59:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace Wayland
|
|
|
|
{
|
|
|
|
|
|
|
|
class WaylandBackend;
|
|
|
|
class WaylandSeat;
|
2013-06-17 07:35:45 +00:00
|
|
|
|
2015-03-23 09:07:59 +00:00
|
|
|
#if HAVE_WAYLAND_CURSOR
|
2014-10-16 14:39:49 +00:00
|
|
|
class WaylandCursorTheme : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit WaylandCursorTheme(WaylandBackend *backend, QObject *parent = nullptr);
|
|
|
|
virtual ~WaylandCursorTheme();
|
|
|
|
|
|
|
|
wl_cursor_image *get(Qt::CursorShape shape);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void loadTheme();
|
|
|
|
void destroyTheme();
|
|
|
|
wl_cursor_theme *m_theme;
|
|
|
|
WaylandBackend *m_backend;
|
|
|
|
};
|
2015-03-23 09:07:59 +00:00
|
|
|
#endif
|
2014-10-16 14:39:49 +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);
|
2013-06-27 07:58:04 +00:00
|
|
|
void installCursorImage(Qt::CursorShape shape);
|
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;
|
|
|
|
}
|
2013-06-17 07:35:45 +00:00
|
|
|
private:
|
|
|
|
void destroyPointer();
|
|
|
|
void destroyKeyboard();
|
2015-03-25 13:50:14 +00:00
|
|
|
void destroyTouch();
|
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;
|
2015-03-23 09:07:59 +00:00
|
|
|
#if HAVE_WAYLAND_CURSOR
|
2014-10-16 14:39:49 +00:00
|
|
|
WaylandCursorTheme *m_theme;
|
2015-03-23 09:07:59 +00:00
|
|
|
#endif
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
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 16:46:41 +00:00
|
|
|
void setCursorImage(const QImage &image, const QPoint &hotspot);
|
2014-10-16 14:39:49 +00: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 09:07:59 +00:00
|
|
|
#if HAVE_WAYLAND_CURSOR
|
2014-10-16 14:39:49 +00:00
|
|
|
WaylandCursorTheme *m_theme;
|
2015-03-23 09:07:59 +00:00
|
|
|
#endif
|
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
|
|
|
*/
|
2015-03-20 13:41:03 +00:00
|
|
|
class KWIN_EXPORT WaylandBackend : public AbstractBackend
|
2013-06-17 07:35:45 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2015-03-23 13:29:07 +00:00
|
|
|
explicit WaylandBackend(const QByteArray &display, QObject *parent = nullptr);
|
2013-06-17 07:35:45 +00:00
|
|
|
virtual ~WaylandBackend();
|
|
|
|
wl_display *display();
|
2014-09-19 11:59:51 +00:00
|
|
|
KWayland::Client::Compositor *compositor();
|
|
|
|
const QList<KWayland::Client::Output*> &outputs() const;
|
|
|
|
KWayland::Client::ShmPool *shmPool();
|
2014-10-16 14:39:49 +00:00
|
|
|
KWayland::Client::SubCompositor *subCompositor();
|
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-03-20 13:41:03 +00:00
|
|
|
void installCursorImage(Qt::CursorShape shape) override;
|
|
|
|
void installCursorFromServer() override;
|
2015-02-21 08:30:22 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void connectNotify(const QMetaMethod &signal) override;
|
|
|
|
|
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();
|
|
|
|
void backendReady();
|
2013-07-05 09:11:25 +00:00
|
|
|
void outputsChanged();
|
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();
|
2013-07-05 09:11:25 +00:00
|
|
|
void destroyOutputs();
|
2014-08-20 09:27:09 +00:00
|
|
|
void checkBackendReady();
|
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;
|
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;
|
|
|
|
QList<KWayland::Client::Output*> m_outputs;
|
|
|
|
KWayland::Client::ConnectionThread *m_connectionThreadObject;
|
2014-08-13 10:54:02 +00:00
|
|
|
QThread *m_connectionThread;
|
2014-09-19 11:59:51 +00:00
|
|
|
KWayland::Client::FullscreenShell *m_fullscreenShell;
|
2014-10-16 14:39:49 +00:00
|
|
|
KWayland::Client::SubCompositor *m_subCompositor;
|
|
|
|
WaylandCursor *m_cursor;
|
2015-02-21 08:30:22 +00:00
|
|
|
bool m_ready = 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;
|
|
|
|
}
|
|
|
|
|
2014-10-16 14:39:49 +00:00
|
|
|
inline
|
|
|
|
KWayland::Client::SubCompositor *WaylandBackend::subCompositor()
|
|
|
|
{
|
|
|
|
return m_subCompositor;
|
|
|
|
}
|
|
|
|
|
2013-06-17 07:35:45 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-07-05 09:11:25 +00:00
|
|
|
inline
|
2014-09-19 11:59:51 +00:00
|
|
|
const QList< KWayland::Client::Output* >& WaylandBackend::outputs() const
|
2013-07-05 09:11:25 +00:00
|
|
|
{
|
|
|
|
return m_outputs;
|
|
|
|
}
|
|
|
|
|
2013-06-17 07:35:45 +00:00
|
|
|
} // namespace Wayland
|
|
|
|
} // namespace KWin
|
|
|
|
|
|
|
|
#endif // KWIN_WAYLAND_BACKEND_H
|