Move files to src/client
This commit is contained in:
parent
3725ba4c57
commit
8e54a479f9
25 changed files with 0 additions and 3229 deletions
|
@ -1,69 +0,0 @@
|
|||
/********************************************************************
|
||||
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/>.
|
||||
*********************************************************************/
|
||||
#include "buffer.h"
|
||||
#include "shm_pool.h"
|
||||
// system
|
||||
#include <string.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
namespace Wayland
|
||||
{
|
||||
|
||||
const struct wl_buffer_listener Buffer::s_listener = {
|
||||
Buffer::releasedCallback
|
||||
};
|
||||
|
||||
Buffer::Buffer(ShmPool *parent, wl_buffer *buffer, const QSize &size, int32_t stride, size_t offset)
|
||||
: m_shm(parent)
|
||||
, m_nativeBuffer(buffer)
|
||||
, m_released(false)
|
||||
, m_size(size)
|
||||
, m_stride(stride)
|
||||
, m_offset(offset)
|
||||
, m_used(false)
|
||||
{
|
||||
wl_buffer_add_listener(m_nativeBuffer, &s_listener, this);
|
||||
}
|
||||
|
||||
Buffer::~Buffer()
|
||||
{
|
||||
wl_buffer_destroy(m_nativeBuffer);
|
||||
}
|
||||
|
||||
void Buffer::releasedCallback(void *data, wl_buffer *buffer)
|
||||
{
|
||||
Buffer *b = reinterpret_cast<Buffer*>(data);
|
||||
Q_ASSERT(b->m_nativeBuffer == buffer);
|
||||
b->setReleased(true);
|
||||
}
|
||||
|
||||
void Buffer::copy(const void *src)
|
||||
{
|
||||
memcpy(address(), src, m_size.height()*m_stride);
|
||||
}
|
||||
|
||||
uchar *Buffer::address()
|
||||
{
|
||||
return reinterpret_cast<uchar*>(m_shm->poolAddress()) + m_offset;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,116 +0,0 @@
|
|||
/********************************************************************
|
||||
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_BUFFER_H
|
||||
#define KWIN_WAYLAND_BUFFER_H
|
||||
|
||||
#include <QSize>
|
||||
|
||||
#include <wayland-client-protocol.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
namespace Wayland
|
||||
{
|
||||
|
||||
class ShmPool;
|
||||
|
||||
class Buffer
|
||||
{
|
||||
public:
|
||||
~Buffer();
|
||||
void copy(const void *src);
|
||||
void setReleased(bool released);
|
||||
void setUsed(bool used);
|
||||
|
||||
wl_buffer *buffer() const;
|
||||
const QSize &size() const;
|
||||
int32_t stride() const;
|
||||
bool isReleased() const;
|
||||
bool isUsed() const;
|
||||
uchar *address();
|
||||
|
||||
operator wl_buffer*() {
|
||||
return m_nativeBuffer;
|
||||
}
|
||||
operator wl_buffer*() const {
|
||||
return m_nativeBuffer;
|
||||
}
|
||||
|
||||
static void releasedCallback(void *data, wl_buffer *wl_buffer);
|
||||
|
||||
private:
|
||||
friend class ShmPool;
|
||||
explicit Buffer(ShmPool *parent, wl_buffer *buffer, const QSize &size, int32_t stride, size_t offset);
|
||||
static const struct wl_buffer_listener s_listener;
|
||||
ShmPool *m_shm;
|
||||
wl_buffer *m_nativeBuffer;
|
||||
bool m_released;
|
||||
QSize m_size;
|
||||
int32_t m_stride;
|
||||
size_t m_offset;
|
||||
bool m_used;
|
||||
};
|
||||
|
||||
inline
|
||||
wl_buffer *Buffer::buffer() const
|
||||
{
|
||||
return m_nativeBuffer;
|
||||
}
|
||||
|
||||
inline
|
||||
const QSize &Buffer::size() const
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
inline
|
||||
int32_t Buffer::stride() const
|
||||
{
|
||||
return m_stride;
|
||||
}
|
||||
|
||||
inline
|
||||
bool Buffer::isReleased() const
|
||||
{
|
||||
return m_released;
|
||||
}
|
||||
|
||||
inline
|
||||
void Buffer::setReleased(bool released)
|
||||
{
|
||||
m_released = released;
|
||||
}
|
||||
|
||||
inline
|
||||
bool Buffer::isUsed() const
|
||||
{
|
||||
return m_used;
|
||||
}
|
||||
|
||||
inline
|
||||
void Buffer::setUsed(bool used)
|
||||
{
|
||||
m_used = used;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,75 +0,0 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2014 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/>.
|
||||
*********************************************************************/
|
||||
#include "compositor.h"
|
||||
#include "surface.h"
|
||||
|
||||
#include <wayland-client-protocol.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
namespace Wayland
|
||||
{
|
||||
|
||||
Compositor::Compositor(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_compositor(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
Compositor::~Compositor()
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
void Compositor::setup(wl_compositor *compositor)
|
||||
{
|
||||
Q_ASSERT(compositor);
|
||||
Q_ASSERT(!m_compositor);
|
||||
m_compositor = compositor;
|
||||
}
|
||||
|
||||
void Compositor::release()
|
||||
{
|
||||
if (!m_compositor) {
|
||||
return;
|
||||
}
|
||||
wl_compositor_destroy(m_compositor);
|
||||
m_compositor = nullptr;
|
||||
}
|
||||
|
||||
void Compositor::destroy()
|
||||
{
|
||||
if (!m_compositor) {
|
||||
return;
|
||||
}
|
||||
free(m_compositor);
|
||||
m_compositor = nullptr;
|
||||
}
|
||||
|
||||
Surface *Compositor::createSurface(QObject *parent)
|
||||
{
|
||||
Q_ASSERT(isValid());
|
||||
Surface *s = new Surface(parent);
|
||||
s->setup(wl_compositor_create_surface(m_compositor));
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2014 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_COMPOSITOR_H
|
||||
#define KWIN_WAYLAND_COMPOSITOR_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
struct wl_compositor;
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
namespace Wayland
|
||||
{
|
||||
|
||||
class Surface;
|
||||
|
||||
class Compositor : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Compositor(QObject *parent = nullptr);
|
||||
virtual ~Compositor();
|
||||
|
||||
bool isValid() const {
|
||||
return m_compositor != nullptr;
|
||||
}
|
||||
void setup(wl_compositor *compositor);
|
||||
void release();
|
||||
void destroy();
|
||||
|
||||
Surface *createSurface(QObject *parent = nullptr);
|
||||
|
||||
operator wl_compositor*() {
|
||||
return m_compositor;
|
||||
}
|
||||
operator wl_compositor*() const {
|
||||
return m_compositor;
|
||||
}
|
||||
|
||||
private:
|
||||
wl_compositor *m_compositor;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,146 +0,0 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2014 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/>.
|
||||
*********************************************************************/
|
||||
#include "connection_thread.h"
|
||||
// Qt
|
||||
#include <QDebug>
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QSocketNotifier>
|
||||
// Wayland
|
||||
#include <wayland-client-protocol.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
namespace Wayland
|
||||
{
|
||||
|
||||
ConnectionThread::ConnectionThread(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_display(nullptr)
|
||||
, m_socketName(QString::fromUtf8(qgetenv("WAYLAND_DISPLAY")))
|
||||
, m_runtimeDir(QString::fromUtf8(qgetenv("XDG_RUNTIME_DIR")))
|
||||
, m_socketNotifier(nullptr)
|
||||
, m_socketWatcher(nullptr)
|
||||
, m_serverDied(false)
|
||||
{
|
||||
if (m_socketName.isEmpty()) {
|
||||
m_socketName = QStringLiteral("wayland-0");
|
||||
}
|
||||
}
|
||||
|
||||
ConnectionThread::~ConnectionThread()
|
||||
{
|
||||
if (m_display) {
|
||||
wl_display_flush(m_display);
|
||||
wl_display_disconnect(m_display);
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectionThread::initConnection()
|
||||
{
|
||||
QMetaObject::invokeMethod(this, "doInitConnection", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void ConnectionThread::doInitConnection()
|
||||
{
|
||||
m_display = wl_display_connect(m_socketName.toUtf8().constData());
|
||||
if (!m_display) {
|
||||
qWarning() << "Failed connecting to Wayland display";
|
||||
emit failed();
|
||||
return;
|
||||
}
|
||||
qDebug() << "Connected to Wayland server at:" << m_socketName;
|
||||
|
||||
// setup socket notifier
|
||||
setupSocketNotifier();
|
||||
setupSocketFileWatcher();
|
||||
emit connected();
|
||||
}
|
||||
|
||||
void ConnectionThread::setupSocketNotifier()
|
||||
{
|
||||
const int fd = wl_display_get_fd(m_display);
|
||||
m_socketNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this);
|
||||
connect(m_socketNotifier, &QSocketNotifier::activated, this,
|
||||
[this]() {
|
||||
if (!m_display) {
|
||||
return;
|
||||
}
|
||||
wl_display_dispatch(m_display);
|
||||
emit eventsRead();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void ConnectionThread::setupSocketFileWatcher()
|
||||
{
|
||||
if (!m_runtimeDir.exists()) {
|
||||
return;
|
||||
}
|
||||
m_socketWatcher = new QFileSystemWatcher(this);
|
||||
m_socketWatcher->addPath(m_runtimeDir.absoluteFilePath(m_socketName));
|
||||
connect(m_socketWatcher, &QFileSystemWatcher::fileChanged, this,
|
||||
[this] (const QString &file) {
|
||||
if (QFile::exists(file) || m_serverDied) {
|
||||
return;
|
||||
}
|
||||
qWarning() << "Connection to server went away";
|
||||
m_serverDied = true;
|
||||
if (m_display) {
|
||||
free(m_display);
|
||||
m_display = nullptr;
|
||||
}
|
||||
delete m_socketNotifier;
|
||||
m_socketNotifier = nullptr;
|
||||
|
||||
// need a new filesystem watcher
|
||||
delete m_socketWatcher;
|
||||
m_socketWatcher = new QFileSystemWatcher(this);
|
||||
m_socketWatcher->addPath(m_runtimeDir.absolutePath());
|
||||
connect(m_socketWatcher, &QFileSystemWatcher::directoryChanged, this,
|
||||
[this]() {
|
||||
if (!m_serverDied) {
|
||||
return;
|
||||
}
|
||||
if (m_runtimeDir.exists(m_socketName)) {
|
||||
qDebug() << "Socket reappeared";
|
||||
delete m_socketWatcher;
|
||||
m_socketWatcher = nullptr;
|
||||
m_serverDied = false;
|
||||
initConnection();
|
||||
}
|
||||
}
|
||||
);
|
||||
emit connectionDied();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void ConnectionThread::setSocketName(const QString &socketName)
|
||||
{
|
||||
if (m_display) {
|
||||
// already initialized
|
||||
return;
|
||||
}
|
||||
m_socketName = socketName;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,109 +0,0 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2014 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_CONNECTION_THREAD_H
|
||||
#define KWIN_WAYLAND_CONNECTION_THREAD_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QDir>
|
||||
|
||||
struct wl_display;
|
||||
class QFileSystemWatcher;
|
||||
class QSocketNotifier;
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
namespace Wayland
|
||||
{
|
||||
|
||||
class ConnectionThread : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ConnectionThread(QObject *parent = nullptr);
|
||||
virtual ~ConnectionThread();
|
||||
|
||||
wl_display *display();
|
||||
/**
|
||||
* @returns the name of the socket it connects to.
|
||||
**/
|
||||
const QString &socketName() const;
|
||||
/**
|
||||
* Sets the @p socketName to connect to.
|
||||
* Only applies if called before calling initConnection.
|
||||
* The default socket name is derived from environment variable WAYLAND_DISPLAY
|
||||
* and if not set is hard coded to "wayland-0".
|
||||
**/
|
||||
void setSocketName(const QString &socketName);
|
||||
|
||||
public Q_SLOTS:
|
||||
void initConnection();
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* Emitted once a connection to a Wayland server is established.
|
||||
* Normally emitted after invoking initConnection(), but might also be
|
||||
* emitted after re-connecting to another server.
|
||||
**/
|
||||
void connected();
|
||||
/**
|
||||
* Emitted if connecting to a Wayland server failed.
|
||||
**/
|
||||
void failed();
|
||||
/**
|
||||
* Emitted whenever new events are ready to be read.
|
||||
**/
|
||||
void eventsRead();
|
||||
/**
|
||||
* Emitted if the Wayland server connection dies.
|
||||
* If the socket reappears, it is tried to reconnect.
|
||||
**/
|
||||
void connectionDied();
|
||||
|
||||
private Q_SLOTS:
|
||||
void doInitConnection();
|
||||
|
||||
private:
|
||||
void setupSocketNotifier();
|
||||
void setupSocketFileWatcher();
|
||||
wl_display *m_display;
|
||||
QString m_socketName;
|
||||
QDir m_runtimeDir;
|
||||
QSocketNotifier *m_socketNotifier;
|
||||
QFileSystemWatcher *m_socketWatcher;
|
||||
bool m_serverDied;
|
||||
};
|
||||
|
||||
inline
|
||||
const QString &ConnectionThread::socketName() const
|
||||
{
|
||||
return m_socketName;
|
||||
}
|
||||
|
||||
inline
|
||||
wl_display *ConnectionThread::display()
|
||||
{
|
||||
return m_display;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -1,105 +0,0 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2014 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/>.
|
||||
*********************************************************************/
|
||||
#include "fullscreen_shell.h"
|
||||
#include "surface.h"
|
||||
#include "output.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
namespace Wayland
|
||||
{
|
||||
|
||||
FullscreenShell::FullscreenShell(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_shell(nullptr)
|
||||
, m_capabilityArbitraryModes(false)
|
||||
, m_capabilityCursorPlane(false)
|
||||
{
|
||||
}
|
||||
|
||||
FullscreenShell::~FullscreenShell()
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
void FullscreenShell::release()
|
||||
{
|
||||
if (m_shell) {
|
||||
_wl_fullscreen_shell_release(m_shell);
|
||||
m_shell = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void FullscreenShell::destroy()
|
||||
{
|
||||
if (m_shell) {
|
||||
free(m_shell);
|
||||
m_shell = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
_wl_fullscreen_shell_listener FullscreenShell::s_fullscreenShellListener = {
|
||||
FullscreenShell::capabilitiesAnnounce
|
||||
};
|
||||
|
||||
void FullscreenShell::setup(_wl_fullscreen_shell *shell)
|
||||
{
|
||||
Q_ASSERT(!m_shell);
|
||||
Q_ASSERT(shell);
|
||||
m_shell = shell;
|
||||
_wl_fullscreen_shell_add_listener(m_shell, &s_fullscreenShellListener, this);
|
||||
}
|
||||
|
||||
void FullscreenShell::capabilitiesAnnounce(void *data, _wl_fullscreen_shell *shell, uint32_t capability)
|
||||
{
|
||||
FullscreenShell *s = reinterpret_cast<FullscreenShell*>(data);
|
||||
Q_ASSERT(shell == s->m_shell);
|
||||
s->handleCapabilities(capability);
|
||||
}
|
||||
|
||||
void FullscreenShell::handleCapabilities(uint32_t capability)
|
||||
{
|
||||
if (capability & _WL_FULLSCREEN_SHELL_CAPABILITY_ARBITRARY_MODES) {
|
||||
m_capabilityArbitraryModes = true;
|
||||
emit capabilityArbitraryModesChanged(m_capabilityArbitraryModes);
|
||||
}
|
||||
if (capability & _WL_FULLSCREEN_SHELL_CAPABILITY_CURSOR_PLANE) {
|
||||
m_capabilityCursorPlane = true;
|
||||
emit capabilityCursorPlaneChanged(m_capabilityCursorPlane);
|
||||
}
|
||||
}
|
||||
|
||||
void FullscreenShell::present(wl_surface *surface, wl_output *output)
|
||||
{
|
||||
Q_ASSERT(m_shell);
|
||||
_wl_fullscreen_shell_present_surface(m_shell, surface, _WL_FULLSCREEN_SHELL_PRESENT_METHOD_DEFAULT, output);
|
||||
}
|
||||
|
||||
void FullscreenShell::present(Surface *surface, Output *output)
|
||||
{
|
||||
Q_ASSERT(surface);
|
||||
Q_ASSERT(output);
|
||||
present(*surface, *output);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2014 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_FULLSCREEN_SHELL_H
|
||||
#define KWIN_WAYLAND_FULLSCREEN_SHELL_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <wayland-client-fullscreen-shell.h>
|
||||
#include <wayland-client-protocol.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
namespace Wayland
|
||||
{
|
||||
|
||||
class Surface;
|
||||
class Output;
|
||||
|
||||
class FullscreenShell : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool capabilityArbitraryModes READ hasCapabilityArbitraryModes NOTIFY capabilityArbitraryModesChanged)
|
||||
Q_PROPERTY(bool capabilityCursorPlane READ hasCapabilityCursorPlane NOTIFY capabilityCursorPlaneChanged)
|
||||
public:
|
||||
explicit FullscreenShell(QObject *parent = nullptr);
|
||||
virtual ~FullscreenShell();
|
||||
|
||||
bool isValid() const {
|
||||
return m_shell != nullptr;
|
||||
}
|
||||
void release();
|
||||
void destroy();
|
||||
bool hasCapabilityArbitraryModes() const {
|
||||
return m_capabilityArbitraryModes;
|
||||
}
|
||||
bool hasCapabilityCursorPlane() const {
|
||||
return m_capabilityCursorPlane;
|
||||
}
|
||||
void setup(_wl_fullscreen_shell *shell);
|
||||
void present(wl_surface *surface, wl_output *output);
|
||||
void present(Surface *surface, Output *output);
|
||||
|
||||
static void capabilitiesAnnounce(void *data, struct _wl_fullscreen_shell *shell, uint32_t capability);
|
||||
|
||||
Q_SIGNALS:
|
||||
void capabilityArbitraryModesChanged(bool);
|
||||
void capabilityCursorPlaneChanged(bool);
|
||||
|
||||
private:
|
||||
void handleCapabilities(uint32_t capability);
|
||||
_wl_fullscreen_shell *m_shell;
|
||||
bool m_capabilityArbitraryModes;
|
||||
bool m_capabilityCursorPlane;
|
||||
static _wl_fullscreen_shell_listener s_fullscreenShellListener;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,117 +0,0 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2014 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/>.
|
||||
*********************************************************************/
|
||||
#include "keyboard.h"
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
namespace Wayland
|
||||
{
|
||||
|
||||
const wl_keyboard_listener Keyboard::s_listener = {
|
||||
keymapCallback,
|
||||
enterCallback,
|
||||
leaveCallback,
|
||||
keyCallback,
|
||||
modifiersCallback
|
||||
};
|
||||
|
||||
Keyboard::Keyboard(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_keyboard(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
Keyboard::~Keyboard()
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
void Keyboard::release()
|
||||
{
|
||||
if (!m_keyboard) {
|
||||
return;
|
||||
}
|
||||
wl_keyboard_destroy(m_keyboard);
|
||||
m_keyboard = nullptr;
|
||||
}
|
||||
|
||||
void Keyboard::setup(wl_keyboard *keyboard)
|
||||
{
|
||||
Q_ASSERT(keyboard);
|
||||
Q_ASSERT(!m_keyboard);
|
||||
m_keyboard = keyboard;
|
||||
wl_keyboard_add_listener(m_keyboard, &Keyboard::s_listener, this);
|
||||
}
|
||||
|
||||
void Keyboard::enterCallback(void *data, wl_keyboard *keyboard, uint32_t serial, wl_surface *surface, wl_array *keys)
|
||||
{
|
||||
// ignore
|
||||
Q_UNUSED(data)
|
||||
Q_UNUSED(keyboard)
|
||||
Q_UNUSED(serial)
|
||||
Q_UNUSED(surface)
|
||||
Q_UNUSED(keys)
|
||||
}
|
||||
|
||||
void Keyboard::leaveCallback(void *data, wl_keyboard *keyboard, uint32_t serial, wl_surface *surface)
|
||||
{
|
||||
// ignore
|
||||
Q_UNUSED(data)
|
||||
Q_UNUSED(keyboard)
|
||||
Q_UNUSED(serial)
|
||||
Q_UNUSED(surface)
|
||||
}
|
||||
|
||||
void Keyboard::keyCallback(void *data, wl_keyboard *keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
|
||||
{
|
||||
Q_UNUSED(serial)
|
||||
Keyboard *k = reinterpret_cast<Keyboard*>(data);
|
||||
Q_ASSERT(k->m_keyboard == keyboard);
|
||||
auto toState = [state] {
|
||||
if (state == WL_KEYBOARD_KEY_STATE_RELEASED) {
|
||||
return KeyState::Released;
|
||||
} else {
|
||||
return KeyState::Pressed;
|
||||
}
|
||||
};
|
||||
emit k->keyChanged(key, toState(), time);
|
||||
}
|
||||
|
||||
void Keyboard::keymapCallback(void *data, wl_keyboard *keyboard, uint32_t format, int fd, uint32_t size)
|
||||
{
|
||||
Keyboard *k = reinterpret_cast<Keyboard*>(data);
|
||||
Q_ASSERT(k->m_keyboard == keyboard);
|
||||
if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) {
|
||||
return;
|
||||
}
|
||||
emit k->keymapChanged(fd, size);
|
||||
}
|
||||
|
||||
void Keyboard::modifiersCallback(void *data, wl_keyboard *keyboard, uint32_t serial, uint32_t modsDepressed,
|
||||
uint32_t modsLatched, uint32_t modsLocked, uint32_t group)
|
||||
{
|
||||
Q_UNUSED(serial)
|
||||
Keyboard *k = reinterpret_cast<Keyboard*>(data);
|
||||
Q_ASSERT(k->m_keyboard == keyboard);
|
||||
emit k->modifiersChanged(modsDepressed, modsLatched, modsLocked, group);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2014 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_KEYBOARD_H
|
||||
#define KWIN_WAYLAND_KEYBOARD_H
|
||||
|
||||
#include <QObject>
|
||||
#include <wayland-client-protocol.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
namespace Wayland
|
||||
{
|
||||
|
||||
class Keyboard : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum class KeyState {
|
||||
Released,
|
||||
Pressed
|
||||
};
|
||||
explicit Keyboard(QObject *parent = nullptr);
|
||||
virtual ~Keyboard();
|
||||
|
||||
bool isValid() const {
|
||||
return m_keyboard != nullptr;
|
||||
}
|
||||
void setup(wl_keyboard *keyboard);
|
||||
void release();
|
||||
|
||||
operator wl_keyboard*() {
|
||||
return m_keyboard;
|
||||
}
|
||||
operator wl_keyboard*() const {
|
||||
return m_keyboard;
|
||||
}
|
||||
|
||||
static void keymapCallback(void *data, wl_keyboard *keyboard, uint32_t format, int fd, uint32_t size);
|
||||
static void enterCallback(void *data, wl_keyboard *keyboard, uint32_t serial, wl_surface *surface, wl_array *keys);
|
||||
static void leaveCallback(void *data, wl_keyboard *keyboard, uint32_t serial, wl_surface *surface);
|
||||
static void keyCallback(void *data, wl_keyboard *keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state);
|
||||
static void modifiersCallback(void *data, wl_keyboard *keyboard, uint32_t serial, uint32_t modsDepressed,
|
||||
uint32_t modsLatched, uint32_t modsLocked, uint32_t group);
|
||||
|
||||
Q_SIGNALS:
|
||||
void keymapChanged(int fd, quint32 size);
|
||||
void keyChanged(quint32 key, KWin::Wayland::Keyboard::KeyState state, quint32 time);
|
||||
void modifiersChanged(quint32 depressed, quint32 latched, quint32 locked, quint32 group);
|
||||
|
||||
private:
|
||||
wl_keyboard *m_keyboard;
|
||||
static const wl_keyboard_listener s_listener;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(KWin::Wayland::Keyboard::KeyState)
|
||||
|
||||
#endif
|
|
@ -1,201 +0,0 @@
|
|||
/********************************************************************
|
||||
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/>.
|
||||
*********************************************************************/
|
||||
#include "output.h"
|
||||
|
||||
#include <QRect>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
namespace Wayland
|
||||
{
|
||||
|
||||
Output::Output(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_output(nullptr)
|
||||
, m_physicalSize()
|
||||
, m_globalPosition()
|
||||
, m_manufacturer()
|
||||
, m_model()
|
||||
, m_pixelSize()
|
||||
, m_refreshRate(0)
|
||||
, m_scale(1)
|
||||
, m_subPixel(SubPixel::Unknown)
|
||||
, m_transform(Transform::Normal)
|
||||
{
|
||||
}
|
||||
|
||||
Output::~Output()
|
||||
{
|
||||
if (m_output) {
|
||||
wl_output_destroy(m_output);
|
||||
}
|
||||
}
|
||||
|
||||
wl_output_listener Output::s_outputListener = {
|
||||
Output::geometryCallback,
|
||||
Output::modeCallback,
|
||||
Output::doneCallback,
|
||||
Output::scaleCallback
|
||||
};
|
||||
|
||||
void Output::geometryCallback(void *data, wl_output *output,
|
||||
int32_t x, int32_t y,
|
||||
int32_t physicalWidth, int32_t physicalHeight,
|
||||
int32_t subPixel, const char *make, const char *model, int32_t transform)
|
||||
{
|
||||
Q_UNUSED(transform)
|
||||
Output *o = reinterpret_cast<Output*>(data);
|
||||
Q_ASSERT(o->output() == output);
|
||||
o->setGlobalPosition(QPoint(x, y));
|
||||
o->setManufacturer(make);
|
||||
o->setModel(model);
|
||||
o->setPhysicalSize(QSize(physicalWidth, physicalHeight));
|
||||
auto toSubPixel = [subPixel]() {
|
||||
switch (subPixel) {
|
||||
case WL_OUTPUT_SUBPIXEL_NONE:
|
||||
return SubPixel::None;
|
||||
case WL_OUTPUT_SUBPIXEL_HORIZONTAL_RGB:
|
||||
return SubPixel::HorizontalRGB;
|
||||
case WL_OUTPUT_SUBPIXEL_HORIZONTAL_BGR:
|
||||
return SubPixel::HorizontalBGR;
|
||||
case WL_OUTPUT_SUBPIXEL_VERTICAL_RGB:
|
||||
return SubPixel::VerticalRGB;
|
||||
case WL_OUTPUT_SUBPIXEL_VERTICAL_BGR:
|
||||
return SubPixel::VerticalBGR;
|
||||
case WL_OUTPUT_SUBPIXEL_UNKNOWN:
|
||||
default:
|
||||
return SubPixel::Unknown;
|
||||
}
|
||||
};
|
||||
o->setSubPixel(toSubPixel());
|
||||
auto toTransform = [transform]() {
|
||||
switch (transform) {
|
||||
case WL_OUTPUT_TRANSFORM_90:
|
||||
return Transform::Rotated90;
|
||||
case WL_OUTPUT_TRANSFORM_180:
|
||||
return Transform::Rotated180;
|
||||
case WL_OUTPUT_TRANSFORM_270:
|
||||
return Transform::Rotated270;
|
||||
case WL_OUTPUT_TRANSFORM_FLIPPED:
|
||||
return Transform::Flipped;
|
||||
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
|
||||
return Transform::Flipped90;
|
||||
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
|
||||
return Transform::Flipped180;
|
||||
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
|
||||
return Transform::Flipped270;
|
||||
case WL_OUTPUT_TRANSFORM_NORMAL:
|
||||
default:
|
||||
return Transform::Normal;
|
||||
}
|
||||
};
|
||||
o->setTransform(toTransform());
|
||||
}
|
||||
|
||||
void Output::modeCallback(void *data, wl_output *output, uint32_t flags, int32_t width, int32_t height, int32_t refresh)
|
||||
{
|
||||
if (!(flags & WL_OUTPUT_MODE_CURRENT)) {
|
||||
// ignore all non-current modes;
|
||||
return;
|
||||
}
|
||||
Output *o = reinterpret_cast<Output*>(data);
|
||||
Q_ASSERT(o->output() == output);
|
||||
o->setPixelSize(QSize(width, height));
|
||||
o->setRefreshRate(refresh);
|
||||
}
|
||||
|
||||
void Output::scaleCallback(void *data, wl_output *output, int32_t scale)
|
||||
{
|
||||
Output *o = reinterpret_cast<Output*>(data);
|
||||
Q_ASSERT(o->output() == output);
|
||||
o->setScale(scale);
|
||||
}
|
||||
|
||||
void Output::doneCallback(void *data, wl_output *output)
|
||||
{
|
||||
Output *o = reinterpret_cast<Output*>(data);
|
||||
Q_ASSERT(o->output() == output);
|
||||
o->changed();
|
||||
}
|
||||
|
||||
void Output::setup(wl_output *output)
|
||||
{
|
||||
Q_ASSERT(output);
|
||||
Q_ASSERT(!m_output);
|
||||
m_output = output;
|
||||
wl_output_add_listener(m_output, &s_outputListener, this);
|
||||
}
|
||||
|
||||
void Output::setGlobalPosition(const QPoint &pos)
|
||||
{
|
||||
m_globalPosition = pos;
|
||||
}
|
||||
|
||||
void Output::setManufacturer(const QString &manufacturer)
|
||||
{
|
||||
m_manufacturer = manufacturer;
|
||||
}
|
||||
|
||||
void Output::setModel(const QString &model)
|
||||
{
|
||||
m_model = model;
|
||||
}
|
||||
|
||||
void Output::setPhysicalSize(const QSize &size)
|
||||
{
|
||||
m_physicalSize = size;
|
||||
}
|
||||
|
||||
void Output::setPixelSize(const QSize& size)
|
||||
{
|
||||
m_pixelSize = size;
|
||||
}
|
||||
|
||||
void Output::setRefreshRate(int refreshRate)
|
||||
{
|
||||
m_refreshRate = refreshRate;
|
||||
}
|
||||
|
||||
void Output::setScale(int scale)
|
||||
{
|
||||
m_scale = scale;
|
||||
}
|
||||
|
||||
QRect Output::geometry() const
|
||||
{
|
||||
if (!m_pixelSize.isValid()) {
|
||||
return QRect();
|
||||
}
|
||||
return QRect(m_globalPosition, m_pixelSize);
|
||||
}
|
||||
|
||||
void Output::setSubPixel(Output::SubPixel subPixel)
|
||||
{
|
||||
m_subPixel = subPixel;
|
||||
}
|
||||
|
||||
void Output::setTransform(Output::Transform transform)
|
||||
{
|
||||
m_transform = transform;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,185 +0,0 @@
|
|||
/********************************************************************
|
||||
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_OUTPUT_H
|
||||
#define KWIN_WAYLAND_OUTPUT_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QPoint>
|
||||
#include <QSize>
|
||||
|
||||
#include <wayland-client-protocol.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
namespace Wayland
|
||||
{
|
||||
|
||||
class Output : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum class SubPixel {
|
||||
Unknown,
|
||||
None,
|
||||
HorizontalRGB,
|
||||
HorizontalBGR,
|
||||
VerticalRGB,
|
||||
VerticalBGR
|
||||
};
|
||||
enum class Transform {
|
||||
Normal,
|
||||
Rotated90,
|
||||
Rotated180,
|
||||
Rotated270,
|
||||
Flipped,
|
||||
Flipped90,
|
||||
Flipped180,
|
||||
Flipped270
|
||||
};
|
||||
explicit Output(QObject *parent = nullptr);
|
||||
virtual ~Output();
|
||||
|
||||
void setup(wl_output *output);
|
||||
|
||||
bool isValid() const;
|
||||
operator wl_output*() {
|
||||
return m_output;
|
||||
}
|
||||
operator wl_output*() const {
|
||||
return m_output;
|
||||
}
|
||||
wl_output *output();
|
||||
const QSize &physicalSize() const;
|
||||
const QPoint &globalPosition() const;
|
||||
const QString &manufacturer() const;
|
||||
const QString &model() const;
|
||||
const QSize &pixelSize() const;
|
||||
QRect geometry() const;
|
||||
int refreshRate() const;
|
||||
int scale() const;
|
||||
SubPixel subPixel() const;
|
||||
Transform transform() const;
|
||||
|
||||
static void geometryCallback(void *data, wl_output *output, int32_t x, int32_t y,
|
||||
int32_t physicalWidth, int32_t physicalHeight, int32_t subPixel,
|
||||
const char *make, const char *model, int32_t transform);
|
||||
static void modeCallback(void *data, wl_output *output, uint32_t flags, int32_t width, int32_t height, int32_t refresh);
|
||||
static void doneCallback(void *data, wl_output *output);
|
||||
static void scaleCallback(void *data, wl_output *output, int32_t scale);
|
||||
|
||||
Q_SIGNALS:
|
||||
void changed();
|
||||
|
||||
private:
|
||||
void setPhysicalSize(const QSize &size);
|
||||
void setGlobalPosition(const QPoint &pos);
|
||||
void setManufacturer(const QString &manufacturer);
|
||||
void setModel(const QString &model);
|
||||
void setPixelSize(const QSize &size);
|
||||
void setRefreshRate(int refreshRate);
|
||||
void setScale(int scale);
|
||||
void setSubPixel(SubPixel subPixel);
|
||||
void setTransform(Transform transform);
|
||||
static struct wl_output_listener s_outputListener;
|
||||
wl_output *m_output;
|
||||
QSize m_physicalSize;
|
||||
QPoint m_globalPosition;
|
||||
QString m_manufacturer;
|
||||
QString m_model;
|
||||
QSize m_pixelSize;
|
||||
int m_refreshRate;
|
||||
int m_scale;
|
||||
SubPixel m_subPixel;
|
||||
Transform m_transform;
|
||||
};
|
||||
|
||||
inline
|
||||
const QPoint &Output::globalPosition() const
|
||||
{
|
||||
return m_globalPosition;
|
||||
}
|
||||
|
||||
inline
|
||||
const QString &Output::manufacturer() const
|
||||
{
|
||||
return m_manufacturer;
|
||||
}
|
||||
|
||||
inline
|
||||
const QString &Output::model() const
|
||||
{
|
||||
return m_model;
|
||||
}
|
||||
|
||||
inline
|
||||
wl_output *Output::output()
|
||||
{
|
||||
return m_output;
|
||||
}
|
||||
|
||||
inline
|
||||
const QSize &Output::physicalSize() const
|
||||
{
|
||||
return m_physicalSize;
|
||||
}
|
||||
|
||||
inline
|
||||
const QSize &Output::pixelSize() const
|
||||
{
|
||||
return m_pixelSize;
|
||||
}
|
||||
|
||||
inline
|
||||
int Output::refreshRate() const
|
||||
{
|
||||
return m_refreshRate;
|
||||
}
|
||||
|
||||
inline
|
||||
int Output::scale() const
|
||||
{
|
||||
return m_scale;
|
||||
}
|
||||
|
||||
inline
|
||||
bool Output::isValid() const
|
||||
{
|
||||
return m_output != nullptr;
|
||||
}
|
||||
|
||||
inline
|
||||
Output::SubPixel Output::subPixel() const
|
||||
{
|
||||
return m_subPixel;
|
||||
}
|
||||
|
||||
inline
|
||||
Output::Transform Output::transform() const
|
||||
{
|
||||
return m_transform;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(KWin::Wayland::Output::SubPixel)
|
||||
Q_DECLARE_METATYPE(KWin::Wayland::Output::Transform)
|
||||
|
||||
#endif
|
|
@ -1,131 +0,0 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2014 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/>.
|
||||
*********************************************************************/
|
||||
#include "pointer.h"
|
||||
#include "surface.h"
|
||||
|
||||
#include <QPointF>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
namespace Wayland
|
||||
{
|
||||
|
||||
const wl_pointer_listener Pointer::s_listener = {
|
||||
Pointer::enterCallback,
|
||||
Pointer::leaveCallback,
|
||||
Pointer::motionCallback,
|
||||
Pointer::buttonCallback,
|
||||
Pointer::axisCallback
|
||||
};
|
||||
|
||||
Pointer::Pointer(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_pointer(nullptr)
|
||||
, m_enteredSurface(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
Pointer::~Pointer()
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
void Pointer::release()
|
||||
{
|
||||
if (!m_pointer) {
|
||||
return;
|
||||
}
|
||||
wl_pointer_destroy(m_pointer);
|
||||
m_pointer = nullptr;
|
||||
}
|
||||
|
||||
void Pointer::setup(wl_pointer *pointer)
|
||||
{
|
||||
Q_ASSERT(pointer);
|
||||
Q_ASSERT(!m_pointer);
|
||||
m_pointer = pointer;
|
||||
wl_pointer_add_listener(m_pointer, &Pointer::s_listener, this);
|
||||
}
|
||||
|
||||
void Pointer::enterCallback(void *data, wl_pointer *pointer, uint32_t serial, wl_surface *surface,
|
||||
wl_fixed_t sx, wl_fixed_t sy)
|
||||
{
|
||||
Pointer *p = reinterpret_cast<Pointer*>(data);
|
||||
Q_ASSERT(p->m_pointer == pointer);
|
||||
p->enter(serial, surface, QPointF(wl_fixed_to_double(sx), wl_fixed_to_double(sy)));
|
||||
}
|
||||
|
||||
void Pointer::enter(uint32_t serial, wl_surface *surface, const QPointF &relativeToSurface)
|
||||
{
|
||||
m_enteredSurface = Surface::get(surface);
|
||||
emit entered(serial, relativeToSurface);
|
||||
}
|
||||
|
||||
void Pointer::leaveCallback(void *data, wl_pointer *pointer, uint32_t serial, wl_surface *surface)
|
||||
{
|
||||
Pointer *p = reinterpret_cast<Pointer*>(data);
|
||||
Q_ASSERT(p->m_pointer == pointer);
|
||||
Q_ASSERT(*(p->m_enteredSurface) == surface);
|
||||
p->leave(serial);
|
||||
}
|
||||
|
||||
void Pointer::leave(uint32_t serial)
|
||||
{
|
||||
m_enteredSurface = nullptr;
|
||||
emit left(serial);
|
||||
}
|
||||
|
||||
void Pointer::motionCallback(void *data, wl_pointer *pointer, uint32_t time, wl_fixed_t sx, wl_fixed_t sy)
|
||||
{
|
||||
Pointer *p = reinterpret_cast<Pointer*>(data);
|
||||
Q_ASSERT(p->m_pointer == pointer);
|
||||
emit p->motion(QPointF(wl_fixed_to_double(sx), wl_fixed_to_double(sy)), time);
|
||||
}
|
||||
|
||||
void Pointer::buttonCallback(void *data, wl_pointer *pointer, uint32_t serial, uint32_t time, uint32_t button, uint32_t state)
|
||||
{
|
||||
Pointer *p = reinterpret_cast<Pointer*>(data);
|
||||
Q_ASSERT(p->m_pointer == pointer);
|
||||
auto toState = [state] {
|
||||
if (state == WL_POINTER_BUTTON_STATE_RELEASED) {
|
||||
return ButtonState::Released;
|
||||
} else {
|
||||
return ButtonState::Pressed;
|
||||
}
|
||||
};
|
||||
emit p->buttonStateChanged(serial, time, button, toState());
|
||||
}
|
||||
|
||||
void Pointer::axisCallback(void *data, wl_pointer *pointer, uint32_t time, uint32_t axis, wl_fixed_t value)
|
||||
{
|
||||
Pointer *p = reinterpret_cast<Pointer*>(data);
|
||||
Q_ASSERT(p->m_pointer == pointer);
|
||||
auto toAxis = [axis] {
|
||||
if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) {
|
||||
return Axis::Horizontal;
|
||||
} else {
|
||||
return Axis::Vertical;
|
||||
}
|
||||
};
|
||||
emit p->axisChanged(time, toAxis(), wl_fixed_to_double(value));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2014 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_POINTER_H
|
||||
#define KWIN_WAYLAND_POINTER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <wayland-client-protocol.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
namespace Wayland
|
||||
{
|
||||
|
||||
class Surface;
|
||||
|
||||
class Pointer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum class ButtonState {
|
||||
Released,
|
||||
Pressed
|
||||
};
|
||||
enum class Axis {
|
||||
Vertical,
|
||||
Horizontal
|
||||
};
|
||||
explicit Pointer(QObject *parent = nullptr);
|
||||
virtual ~Pointer();
|
||||
|
||||
bool isValid() const {
|
||||
return m_pointer;
|
||||
}
|
||||
void setup(wl_pointer *pointer);
|
||||
void release();
|
||||
|
||||
Surface *enteredSurface() const {
|
||||
return m_enteredSurface;
|
||||
}
|
||||
Surface *enteredSurface(){
|
||||
return m_enteredSurface;
|
||||
}
|
||||
|
||||
operator wl_pointer*() {
|
||||
return m_pointer;
|
||||
}
|
||||
operator wl_pointer*() const {
|
||||
return m_pointer;
|
||||
}
|
||||
|
||||
static void enterCallback(void *data, wl_pointer *pointer, uint32_t serial, wl_surface *surface,
|
||||
wl_fixed_t sx, wl_fixed_t sy);
|
||||
static void leaveCallback(void *data, wl_pointer *pointer, uint32_t serial, wl_surface *surface);
|
||||
static void motionCallback(void *data, wl_pointer *pointer, uint32_t time, wl_fixed_t sx, wl_fixed_t sy);
|
||||
static void buttonCallback(void *data, wl_pointer *pointer, uint32_t serial, uint32_t time,
|
||||
uint32_t button, uint32_t state);
|
||||
static void axisCallback(void *data, wl_pointer *pointer, uint32_t time, uint32_t axis, wl_fixed_t value);
|
||||
|
||||
Q_SIGNALS:
|
||||
void entered(quint32 serial, const QPointF &relativeToSurface);
|
||||
void left(quint32 serial);
|
||||
void motion(const QPointF &relativeToSurface, quint32 time);
|
||||
void buttonStateChanged(quint32 serial, quint32 time, quint32 button, KWin::Wayland::Pointer::ButtonState state);
|
||||
void axisChanged(quint32 time, KWin::Wayland::Pointer::Axis axis, qreal delta);
|
||||
|
||||
private:
|
||||
void enter(uint32_t serial, wl_surface *surface, const QPointF &relativeToSurface);
|
||||
void leave(uint32_t serial);
|
||||
wl_pointer *m_pointer;
|
||||
Surface *m_enteredSurface;
|
||||
static const wl_pointer_listener s_listener;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(KWin::Wayland::Pointer::ButtonState)
|
||||
Q_DECLARE_METATYPE(KWin::Wayland::Pointer::Axis)
|
||||
|
||||
#endif
|
|
@ -1,206 +0,0 @@
|
|||
<protocol name="fullscreen_shell">
|
||||
<interface name="_wl_fullscreen_shell" version="1">
|
||||
<description summary="Displays a single surface per output">
|
||||
Displays a single surface per output.
|
||||
|
||||
This interface provides a mechanism for a single client to display
|
||||
simple full-screen surfaces. While there technically may be multiple
|
||||
clients bound to this interface, only one of those clients should be
|
||||
shown at a time.
|
||||
|
||||
To present a surface, the client uses either the present_surface or
|
||||
present_surface_for_mode requests. Presenting a surface takes effect
|
||||
on the next wl_surface.commit. See the individual requests for
|
||||
details about scaling and mode switches.
|
||||
|
||||
The client can have at most one surface per output at any time.
|
||||
Requesting a surface be presented on an output that already has a
|
||||
surface replaces the previously presented surface. Presenting a null
|
||||
surface removes its content and effectively disables the output.
|
||||
Exactly what happens when an output is "disabled" is
|
||||
compositor-specific. The same surface may be presented on multiple
|
||||
outputs simultaneously.
|
||||
|
||||
Once a surface is presented on an output, it stays on that output
|
||||
until either the client removes it or the compositor destroys the
|
||||
output. This way, the client can update the output's contents by
|
||||
simply attaching a new buffer.
|
||||
</description>
|
||||
|
||||
<request name="release" type="destructor">
|
||||
<description summary="release the wl_fullscreen_shell interface">
|
||||
Release the binding from the wl_fullscreen_shell interface
|
||||
|
||||
This destroys the server-side object and frees this binding. If
|
||||
the client binds to wl_fullscreen_shell multiple times, it may wish
|
||||
to free some of those bindings.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<enum name="capability">
|
||||
<description summary="capabilities advertised by the compositor">
|
||||
Various capabilities that can be advertised by the compositor. They
|
||||
are advertised one-at-a-time when the wl_fullscreen_shell interface is
|
||||
bound. See the wl_fullscreen_shell.capability event for more details.
|
||||
|
||||
ARBITRARY_MODE:
|
||||
This is a hint to the client that indicates that the compositor is
|
||||
capable of setting practially any mode on its outputs. If this
|
||||
capability is provided, wl_fullscreen_shell.present_surface_for_mode
|
||||
will almost never fail and clients should feel free to set whatever
|
||||
mode they like. If the compositor does not advertise this, it may
|
||||
still support some modes that are not advertised through wl_global.mode
|
||||
but it is less likely.
|
||||
|
||||
CURSOR_PLANE:
|
||||
This is a hint to the client that indicates that the compositor can
|
||||
handle a cursor surface from the client without actually compositing.
|
||||
This may be because of a hardware cursor plane or some other mechanism.
|
||||
If the compositor does not advertise this capability then setting
|
||||
wl_pointer.cursor may degrade performance or be ignored entirely. If
|
||||
CURSOR_PLANE is not advertised, it is recommended that the client draw
|
||||
its own cursor and set wl_pointer.cursor(NULL).
|
||||
</description>
|
||||
<entry name="arbitrary_modes" value="1" summary="compositor is capable of almost any output mode"/>
|
||||
<entry name="cursor_plane" value="2" summary="compositor has a seperate cursor plane"/>
|
||||
</enum>
|
||||
|
||||
<event name="capability">
|
||||
<description summary="advertises a capability of the compositor">
|
||||
Advertises a single capability of the compositor.
|
||||
|
||||
When the wl_fullscreen_shell interface is bound, this event is emitted
|
||||
once for each capability advertised. Valid capabilities are given by
|
||||
the wl_fullscreen_shell.capability enum. If clients want to take
|
||||
advantage of any of these capabilities, they sould use a
|
||||
wl_display.sync request immediatly after binding to ensure that they
|
||||
recieve all the capability events.
|
||||
</description>
|
||||
<arg name="capabilty" type="uint"/>
|
||||
</event>
|
||||
|
||||
<enum name="present_method">
|
||||
<description summary="different method to set the surface fullscreen">
|
||||
Hints to indicate to the compositor how to deal with a conflict
|
||||
between the dimensions of the surface and the dimensions of the
|
||||
output. The compositor is free to ignore this parameter.
|
||||
</description>
|
||||
<entry name="default" value="0" summary="no preference, apply default policy"/>
|
||||
<entry name="center" value="1" summary="center the surface on the output"/>
|
||||
<entry name="zoom" value="2" summary="scale the surface, preserving aspect ratio, to the largest size that will fit on the output" />
|
||||
<entry name="zoom_crop" value="3" summary="scale the surface, preserving aspect ratio, to fully fill the output cropping if needed" />
|
||||
<entry name="stretch" value="4" summary="scale the surface to the size of the output ignoring aspect ratio" />
|
||||
</enum>
|
||||
|
||||
<request name="present_surface">
|
||||
<description summary="present surface for display">
|
||||
Present a surface on the given output.
|
||||
|
||||
If the output is null, the compositor will present the surface on
|
||||
whatever display (or displays) it thinks best. In particular, this
|
||||
may replace any or all surfaces currently presented so it should
|
||||
not be used in combination with placing surfaces on specific
|
||||
outputs.
|
||||
|
||||
The method parameter is a hint to the compositor for how the surface
|
||||
is to be presented. In particular, it tells the compostior how to
|
||||
handle a size mismatch between the presented surface and the
|
||||
output. The compositor is free to ignore this parameter.
|
||||
|
||||
The "zoom", "zoom_crop", and "stretch" methods imply a scaling
|
||||
operation on the surface. This will override any kind of output
|
||||
scaling, so the buffer_scale property of the surface is effectively
|
||||
ignored.
|
||||
</description>
|
||||
<arg name="surface" type="object" interface="wl_surface" allow-null="true"/>
|
||||
<arg name="method" type="uint"/>
|
||||
<arg name="output" type="object" interface="wl_output" allow-null="true"/>
|
||||
</request>
|
||||
|
||||
<request name="present_surface_for_mode">
|
||||
<description summary="present surface for display at a particular mode">
|
||||
Presents a surface on the given output for a particular mode.
|
||||
|
||||
If the current size of the output differs from that of the surface,
|
||||
the compositor will attempt to change the size of the output to
|
||||
match the surface. The result of the mode-switch operation will be
|
||||
returned via the provided wl_fullscreen_shell_mode_feedback object.
|
||||
|
||||
If the current output mode matches the one requested or if the
|
||||
compositor successfully switches the mode to match the surface,
|
||||
then the mode_successful event will be sent and the output will
|
||||
contain the contents of the given surface. If the compositor
|
||||
cannot match the output size to the surface size, the mode_failed
|
||||
will be sent and the output will contain the contents of the
|
||||
previously presented surface (if any). If another surface is
|
||||
presented on the given output before either of these has a chance
|
||||
to happen, the present_cancelled event will be sent.
|
||||
|
||||
Due to race conditions and other issues unknown to the client, no
|
||||
mode-switch operation is guaranteed to succeed. However, if the
|
||||
mode is one advertised by wl_output.mode or if the compositor
|
||||
advertises the ARBITRARY_MODES capability, then the client should
|
||||
expect that the mode-switch operation will usually succeed.
|
||||
|
||||
If the size of the presented surface changes, the resulting output
|
||||
is undefined. The compositor may attempt to change the output mode
|
||||
to compensate. However, there is no guarantee that a suitable mode
|
||||
will be found and the client has no way to be notified of success
|
||||
or failure.
|
||||
|
||||
The framerate parameter specifies the desired framerate for the
|
||||
output in mHz. The compositor is free to ignore this parameter. A
|
||||
value of 0 indicates that the client has no preference.
|
||||
|
||||
If the value of wl_output.scale differs from wl_surface.buffer_scale,
|
||||
then the compositor may choose a mode that matches either the buffer
|
||||
size or the surface size. In either case, the surface will fill the
|
||||
output.
|
||||
</description>
|
||||
<arg name="surface" type="object" interface="wl_surface"/>
|
||||
<arg name="output" type="object" interface="wl_output"/>
|
||||
<arg name="framerate" type="int"/>
|
||||
<arg name="feedback" type="new_id" interface="_wl_fullscreen_shell_mode_feedback"/>
|
||||
</request>
|
||||
|
||||
<enum name="error">
|
||||
<description summary="wl_fullscreen_shell error values">
|
||||
These errors can be emitted in response to wl_fullscreen_shell requests
|
||||
</description>
|
||||
<entry name="invalid_method" value="0" summary="present_method is not known"/>
|
||||
</enum>
|
||||
</interface>
|
||||
|
||||
<interface name="_wl_fullscreen_shell_mode_feedback" version="1">
|
||||
<event name="mode_successful">
|
||||
<description summary="mode switch succeeded">
|
||||
This event indicates that the attempted mode switch operation was
|
||||
successful. A surface of the size requested in the mode switch
|
||||
will fill the output without scaling.
|
||||
|
||||
Upon receiving this event, the client should destroy the
|
||||
wl_fullscreen_shell_mode_feedback object.
|
||||
</description>
|
||||
</event>
|
||||
<event name="mode_failed">
|
||||
<description summary="mode switch failed">
|
||||
This event indicates that the attempted mode switch operation
|
||||
failed. This may be because the requested output mode is not
|
||||
possible or it may mean that the compositor does not want to allow it.
|
||||
|
||||
Upon receiving this event, the client should destroy the
|
||||
wl_fullscreen_shell_mode_feedback object.
|
||||
</description>
|
||||
</event>
|
||||
<event name="present_cancelled">
|
||||
<description summary="mode switch cancelled">
|
||||
This event indicates that the attempted mode switch operation was
|
||||
cancelled. Most likely this is because the client requested a
|
||||
second mode switch before the first one completed.
|
||||
|
||||
Upon receiving this event, the client should destroy the
|
||||
wl_fullscreen_shell_mode_feedback object.
|
||||
</description>
|
||||
</event>
|
||||
</interface>
|
||||
</protocol>
|
|
@ -1,253 +0,0 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2014 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/>.
|
||||
*********************************************************************/
|
||||
#include "registry.h"
|
||||
#include <wayland-client-fullscreen-shell.h>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
namespace Wayland
|
||||
{
|
||||
|
||||
Registry::Registry(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_registry(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
Registry::~Registry()
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
void Registry::release()
|
||||
{
|
||||
if (m_registry) {
|
||||
wl_registry_destroy(m_registry);
|
||||
m_registry = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void Registry::destroy()
|
||||
{
|
||||
if (m_registry) {
|
||||
free(m_registry);
|
||||
m_registry = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void Registry::create(wl_display *display)
|
||||
{
|
||||
Q_ASSERT(display);
|
||||
Q_ASSERT(!isValid());
|
||||
m_registry = wl_display_get_registry(display);
|
||||
}
|
||||
|
||||
void Registry::setup()
|
||||
{
|
||||
Q_ASSERT(isValid());
|
||||
wl_registry_add_listener(m_registry, &s_registryListener, this);
|
||||
}
|
||||
|
||||
const struct wl_registry_listener Registry::s_registryListener = {
|
||||
Registry::globalAnnounce,
|
||||
Registry::globalRemove
|
||||
};
|
||||
|
||||
void Registry::globalAnnounce(void *data, wl_registry *registry, uint32_t name, const char *interface, uint32_t version)
|
||||
{
|
||||
Registry *r = reinterpret_cast<Registry*>(data);
|
||||
Q_ASSERT(registry == r->m_registry);
|
||||
r->handleAnnounce(name, interface, version);
|
||||
}
|
||||
|
||||
void Registry::globalRemove(void *data, wl_registry *registry, uint32_t name)
|
||||
{
|
||||
Registry *r = reinterpret_cast<Registry*>(data);
|
||||
Q_ASSERT(registry == r->m_registry);
|
||||
r->handleRemove(name);
|
||||
}
|
||||
|
||||
static Registry::Interface nameToInterface(const char *interface)
|
||||
{
|
||||
if (strcmp(interface, "wl_compositor") == 0) {
|
||||
return Registry::Interface::Compositor;
|
||||
} else if (strcmp(interface, "wl_shell") == 0) {
|
||||
return Registry::Interface::Shell;
|
||||
} else if (strcmp(interface, "wl_seat") == 0) {
|
||||
return Registry::Interface::Seat;
|
||||
} else if (strcmp(interface, "wl_shm") == 0) {
|
||||
return Registry::Interface::Shm;
|
||||
} else if (strcmp(interface, "wl_output") == 0) {
|
||||
return Registry::Interface::Output;
|
||||
} else if (strcmp(interface, "_wl_fullscreen_shell") == 0) {
|
||||
return Registry::Interface::FullscreenShell;
|
||||
}
|
||||
return Registry::Interface::Unknown;
|
||||
}
|
||||
|
||||
void Registry::handleAnnounce(uint32_t name, const char *interface, uint32_t version)
|
||||
{
|
||||
Interface i = nameToInterface(interface);
|
||||
if (i == Interface::Unknown) {
|
||||
qDebug() << "Unknown interface announced: " << interface << "/" << name << "/" << version;
|
||||
return;
|
||||
}
|
||||
qDebug() << "Wayland Interface: " << interface << "/" << name << "/" << version;
|
||||
m_interfaces.append({i, name, version});
|
||||
switch (i) {
|
||||
case Interface::Compositor:
|
||||
emit compositorAnnounced(name, version);
|
||||
break;
|
||||
case Interface::Shell:
|
||||
emit shellAnnounced(name, version);
|
||||
break;
|
||||
case Interface::Output:
|
||||
emit outputAnnounced(name, version);
|
||||
break;
|
||||
case Interface::Seat:
|
||||
emit seatAnnounced(name, version);
|
||||
break;
|
||||
case Interface::Shm:
|
||||
emit shmAnnounced(name, version);
|
||||
break;
|
||||
case Interface::FullscreenShell:
|
||||
emit fullscreenShellAnnounced(name, version);
|
||||
break;
|
||||
case Interface::Unknown:
|
||||
default:
|
||||
// nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Registry::handleRemove(uint32_t name)
|
||||
{
|
||||
auto it = std::find_if(m_interfaces.begin(), m_interfaces.end(),
|
||||
[name](const InterfaceData &data) {
|
||||
return data.name == name;
|
||||
}
|
||||
);
|
||||
if (it != m_interfaces.end()) {
|
||||
InterfaceData data = *(it);
|
||||
m_interfaces.erase(it);
|
||||
switch (data.interface) {
|
||||
case Interface::Compositor:
|
||||
emit compositorRemoved(data.name);
|
||||
break;
|
||||
case Interface::Output:
|
||||
emit outputRemoved(data.name);
|
||||
break;
|
||||
case Interface::Seat:
|
||||
emit seatRemoved(data.name);
|
||||
break;
|
||||
case Interface::Shell:
|
||||
emit shellRemoved(data.name);
|
||||
break;
|
||||
case Interface::Shm:
|
||||
emit shmRemoved(data.name);
|
||||
break;
|
||||
case Interface::FullscreenShell:
|
||||
emit fullscreenShellRemoved(data.name);
|
||||
break;
|
||||
case Interface::Unknown:
|
||||
default:
|
||||
// nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Registry::hasInterface(Registry::Interface interface) const
|
||||
{
|
||||
auto it = std::find_if(m_interfaces.begin(), m_interfaces.end(),
|
||||
[interface](const InterfaceData &data) {
|
||||
return data.interface == interface;
|
||||
}
|
||||
);
|
||||
return it != m_interfaces.end();
|
||||
}
|
||||
|
||||
wl_compositor *Registry::bindCompositor(uint32_t name, uint32_t version) const
|
||||
{
|
||||
return reinterpret_cast<wl_compositor*>(bind(Interface::Compositor, name, version));
|
||||
}
|
||||
|
||||
wl_output *Registry::bindOutput(uint32_t name, uint32_t version) const
|
||||
{
|
||||
return reinterpret_cast<wl_output*>(bind(Interface::Output, name, version));
|
||||
}
|
||||
|
||||
wl_seat *Registry::bindSeat(uint32_t name, uint32_t version) const
|
||||
{
|
||||
return reinterpret_cast<wl_seat*>(bind(Interface::Seat, name, version));
|
||||
}
|
||||
|
||||
wl_shell *Registry::bindShell(uint32_t name, uint32_t version) const
|
||||
{
|
||||
return reinterpret_cast<wl_shell*>(bind(Interface::Shell, name, version));
|
||||
}
|
||||
|
||||
wl_shm *Registry::bindShm(uint32_t name, uint32_t version) const
|
||||
{
|
||||
return reinterpret_cast<wl_shm*>(bind(Interface::Shm, name, version));
|
||||
}
|
||||
|
||||
_wl_fullscreen_shell *Registry::bindFullscreenShell(uint32_t name, uint32_t version) const
|
||||
{
|
||||
return reinterpret_cast<_wl_fullscreen_shell*>(bind(Interface::FullscreenShell, name, version));
|
||||
}
|
||||
|
||||
static const wl_interface *wlInterface(Registry::Interface interface)
|
||||
{
|
||||
switch (interface) {
|
||||
case Registry::Interface::Compositor:
|
||||
return &wl_compositor_interface;
|
||||
case Registry::Interface::Output:
|
||||
return &wl_output_interface;
|
||||
case Registry::Interface::Seat:
|
||||
return &wl_seat_interface;
|
||||
case Registry::Interface::Shell:
|
||||
return &wl_shell_interface;
|
||||
case Registry::Interface::Shm:
|
||||
return &wl_shm_interface;
|
||||
case Registry::Interface::FullscreenShell:
|
||||
return &_wl_fullscreen_shell_interface;
|
||||
case Registry::Interface::Unknown:
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void *Registry::bind(Registry::Interface interface, uint32_t name, uint32_t version) const
|
||||
{
|
||||
auto it = std::find_if(m_interfaces.begin(), m_interfaces.end(), [=](const InterfaceData &data) {
|
||||
return data.interface == interface && data.name == name && data.version >= version;
|
||||
});
|
||||
if (it == m_interfaces.end()) {
|
||||
qDebug() << "Don't have interface " << int(interface) << "with name " << name << "and minimum version" << version;
|
||||
return nullptr;
|
||||
}
|
||||
return wl_registry_bind(m_registry, name, wlInterface(interface), version);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,113 +0,0 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2014 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_REGISTRY_H
|
||||
#define KWIN_WAYLAND_REGISTRY_H
|
||||
|
||||
#include <QHash>
|
||||
#include <QObject>
|
||||
|
||||
#include <wayland-client-protocol.h>
|
||||
|
||||
struct _wl_fullscreen_shell;
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
namespace Wayland
|
||||
{
|
||||
|
||||
class Registry : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum class Interface {
|
||||
Compositor, // wl_compositor
|
||||
Shell, // wl_shell
|
||||
Seat, // wl_seat
|
||||
Shm, // wl_shm
|
||||
Output, // wl_output
|
||||
FullscreenShell, // _wl_fullscreen_shell
|
||||
Unknown
|
||||
};
|
||||
explicit Registry(QObject *parent = nullptr);
|
||||
virtual ~Registry();
|
||||
|
||||
void release();
|
||||
void destroy();
|
||||
void create(wl_display *display);
|
||||
void setup();
|
||||
|
||||
bool isValid() const {
|
||||
return m_registry != nullptr;
|
||||
}
|
||||
bool hasInterface(Interface interface) const;
|
||||
|
||||
wl_compositor *bindCompositor(uint32_t name, uint32_t version) const;
|
||||
wl_shell *bindShell(uint32_t name, uint32_t version) const;
|
||||
wl_seat *bindSeat(uint32_t name, uint32_t version) const;
|
||||
wl_shm *bindShm(uint32_t name, uint32_t version) const;
|
||||
wl_output *bindOutput(uint32_t name, uint32_t version) const;
|
||||
_wl_fullscreen_shell *bindFullscreenShell(uint32_t name, uint32_t version) const;
|
||||
|
||||
operator wl_registry*() {
|
||||
return m_registry;
|
||||
}
|
||||
operator wl_registry*() const {
|
||||
return m_registry;
|
||||
}
|
||||
wl_registry *registry() {
|
||||
return m_registry;
|
||||
}
|
||||
|
||||
static void globalAnnounce(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version);
|
||||
static void globalRemove(void *data, struct wl_registry *registry, uint32_t name);
|
||||
|
||||
Q_SIGNALS:
|
||||
void compositorAnnounced(quint32 name, quint32 version);
|
||||
void shellAnnounced(quint32 name, quint32 version);
|
||||
void seatAnnounced(quint32 name, quint32 version);
|
||||
void shmAnnounced(quint32 name, quint32 version);
|
||||
void outputAnnounced(quint32 name, quint32 version);
|
||||
void fullscreenShellAnnounced(quint32 name, quint32 version);
|
||||
void compositorRemoved(quint32 name);
|
||||
void shellRemoved(quint32 name);
|
||||
void seatRemoved(quint32 name);
|
||||
void shmRemoved(quint32 name);
|
||||
void outputRemoved(quint32 name);
|
||||
void fullscreenShellRemoved(quint32 name);
|
||||
|
||||
private:
|
||||
static const struct wl_registry_listener s_registryListener;
|
||||
void handleAnnounce(uint32_t name, const char *interface, uint32_t version);
|
||||
void handleRemove(uint32_t name);
|
||||
void *bind(Interface interface, uint32_t name, uint32_t version) const;
|
||||
|
||||
wl_registry *m_registry;
|
||||
struct InterfaceData {
|
||||
Interface interface;
|
||||
uint32_t name;
|
||||
uint32_t version;
|
||||
};
|
||||
QList<InterfaceData> m_interfaces;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,167 +0,0 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2014 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/>.
|
||||
*********************************************************************/
|
||||
#include "seat.h"
|
||||
#include "keyboard.h"
|
||||
#include "pointer.h"
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
namespace Wayland
|
||||
{
|
||||
|
||||
const wl_seat_listener Seat::s_listener = {
|
||||
Seat::capabilitiesCallback,
|
||||
Seat::nameCallback
|
||||
};
|
||||
|
||||
Seat::Seat(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_seat(nullptr)
|
||||
, m_capabilityKeyboard(false)
|
||||
, m_capabilityPointer(false)
|
||||
, m_capabilityTouch(false)
|
||||
{
|
||||
}
|
||||
|
||||
Seat::~Seat()
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
void Seat::release()
|
||||
{
|
||||
if (!m_seat) {
|
||||
return;
|
||||
}
|
||||
wl_seat_destroy(m_seat);
|
||||
m_seat = nullptr;
|
||||
resetSeat();
|
||||
}
|
||||
|
||||
void Seat::destroy()
|
||||
{
|
||||
if (!m_seat) {
|
||||
return;
|
||||
}
|
||||
free(m_seat);
|
||||
m_seat = nullptr;
|
||||
resetSeat();
|
||||
}
|
||||
|
||||
void Seat::resetSeat()
|
||||
{
|
||||
setHasKeyboard(false);
|
||||
setHasPointer(false);
|
||||
setHasTouch(false);
|
||||
setName(QString());
|
||||
}
|
||||
|
||||
void Seat::setHasKeyboard(bool has)
|
||||
{
|
||||
if (m_capabilityKeyboard == has) {
|
||||
return;
|
||||
}
|
||||
m_capabilityKeyboard = has;
|
||||
emit hasKeyboardChanged(m_capabilityKeyboard);
|
||||
}
|
||||
|
||||
void Seat::setHasPointer(bool has)
|
||||
{
|
||||
if (m_capabilityPointer == has) {
|
||||
return;
|
||||
}
|
||||
m_capabilityPointer = has;
|
||||
emit hasPointerChanged(m_capabilityPointer);
|
||||
}
|
||||
|
||||
void Seat::setHasTouch(bool has)
|
||||
{
|
||||
if (m_capabilityTouch == has) {
|
||||
return;
|
||||
}
|
||||
m_capabilityTouch = has;
|
||||
emit hasTouchChanged(m_capabilityTouch);
|
||||
}
|
||||
|
||||
void Seat::setup(wl_seat *seat)
|
||||
{
|
||||
Q_ASSERT(seat);
|
||||
Q_ASSERT(!m_seat);
|
||||
m_seat = seat;
|
||||
wl_seat_add_listener(m_seat, &Seat::s_listener, this);
|
||||
}
|
||||
|
||||
void Seat::capabilitiesCallback(void *data, wl_seat *seat, uint32_t capabilities)
|
||||
{
|
||||
Seat *s = reinterpret_cast<Seat*>(data);
|
||||
Q_ASSERT(s->m_seat == seat);
|
||||
s->capabilitiesChanged(capabilities);
|
||||
}
|
||||
|
||||
void Seat::nameCallback(void *data, wl_seat *seat, const char *name)
|
||||
{
|
||||
Seat *s = reinterpret_cast<Seat*>(data);
|
||||
Q_ASSERT(s->m_seat == seat);
|
||||
s->setName(QString::fromUtf8(name));
|
||||
}
|
||||
|
||||
void Seat::capabilitiesChanged(uint32_t capabilities)
|
||||
{
|
||||
setHasKeyboard(capabilities & WL_SEAT_CAPABILITY_KEYBOARD);
|
||||
setHasPointer(capabilities & WL_SEAT_CAPABILITY_POINTER);
|
||||
setHasTouch(capabilities & WL_SEAT_CAPABILITY_TOUCH);
|
||||
}
|
||||
|
||||
Keyboard *Seat::createKeyboard(QObject *parent)
|
||||
{
|
||||
Q_ASSERT(isValid());
|
||||
Q_ASSERT(m_capabilityKeyboard);
|
||||
Keyboard *k = new Keyboard(parent);
|
||||
k->setup(wl_seat_get_keyboard(m_seat));
|
||||
return k;
|
||||
}
|
||||
|
||||
Pointer *Seat::createPointer(QObject *parent)
|
||||
{
|
||||
Q_ASSERT(isValid());
|
||||
Q_ASSERT(m_capabilityPointer);
|
||||
Pointer *p = new Pointer(parent);
|
||||
p->setup(wl_seat_get_pointer(m_seat));
|
||||
return p;
|
||||
}
|
||||
|
||||
wl_touch *Seat::createTouch()
|
||||
{
|
||||
Q_ASSERT(isValid());
|
||||
Q_ASSERT(m_capabilityTouch);
|
||||
return wl_seat_get_touch(m_seat);
|
||||
}
|
||||
|
||||
void Seat::setName(const QString &name)
|
||||
{
|
||||
if (m_name == name) {
|
||||
return;
|
||||
}
|
||||
m_name = name;
|
||||
emit nameChanged(m_name);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,103 +0,0 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2014 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_SEAT_H
|
||||
#define KWIN_WAYLAND_SEAT_H
|
||||
|
||||
#include <QObject>
|
||||
#include <wayland-client-protocol.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
namespace Wayland
|
||||
{
|
||||
|
||||
class Keyboard;
|
||||
class Pointer;
|
||||
|
||||
class Seat : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool keyboard READ hasKeyboard NOTIFY hasKeyboardChanged)
|
||||
Q_PROPERTY(bool pointer READ hasPointer NOTIFY hasPointerChanged)
|
||||
Q_PROPERTY(bool touch READ hasTouch NOTIFY hasTouchChanged)
|
||||
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
|
||||
public:
|
||||
explicit Seat(QObject *parent = nullptr);
|
||||
virtual ~Seat();
|
||||
|
||||
bool isValid() const {
|
||||
return m_seat != nullptr;
|
||||
}
|
||||
void setup(wl_seat *seat);
|
||||
void release();
|
||||
void destroy();
|
||||
|
||||
bool hasKeyboard() const {
|
||||
return m_capabilityKeyboard;
|
||||
}
|
||||
bool hasPointer() const {
|
||||
return m_capabilityPointer;
|
||||
}
|
||||
bool hasTouch() const {
|
||||
return m_capabilityTouch;
|
||||
}
|
||||
const QString &name() const {
|
||||
return m_name;
|
||||
}
|
||||
operator wl_seat*() {
|
||||
return m_seat;
|
||||
}
|
||||
operator wl_seat*() const {
|
||||
return m_seat;
|
||||
}
|
||||
|
||||
Keyboard *createKeyboard(QObject *parent = nullptr);
|
||||
Pointer *createPointer(QObject *parent = nullptr);
|
||||
wl_touch *createTouch();
|
||||
|
||||
static void capabilitiesCallback(void *data, wl_seat *seat, uint32_t capabilities);
|
||||
static void nameCallback(void *data, wl_seat *wl_seat, const char *name);
|
||||
|
||||
Q_SIGNALS:
|
||||
void hasKeyboardChanged(bool);
|
||||
void hasPointerChanged(bool);
|
||||
void hasTouchChanged(bool);
|
||||
void nameChanged(const QString &name);
|
||||
|
||||
private:
|
||||
void resetSeat();
|
||||
void setHasKeyboard(bool has);
|
||||
void setHasPointer(bool has);
|
||||
void setHasTouch(bool has);
|
||||
void capabilitiesChanged(uint32_t capabilities);
|
||||
void setName(const QString &name);
|
||||
|
||||
wl_seat *m_seat;
|
||||
bool m_capabilityKeyboard;
|
||||
bool m_capabilityPointer;
|
||||
bool m_capabilityTouch;
|
||||
QString m_name;
|
||||
static const wl_seat_listener s_listener;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,171 +0,0 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2014 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/>.
|
||||
*********************************************************************/
|
||||
#include "shell.h"
|
||||
#include "output.h"
|
||||
#include "surface.h"
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
namespace Wayland
|
||||
{
|
||||
|
||||
Shell::Shell(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_shell(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
Shell::~Shell()
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
void Shell::destroy()
|
||||
{
|
||||
if (!m_shell) {
|
||||
return;
|
||||
}
|
||||
emit interfaceAboutToBeDestroyed();
|
||||
free(m_shell);
|
||||
m_shell = nullptr;
|
||||
}
|
||||
|
||||
void Shell::release()
|
||||
{
|
||||
if (!m_shell) {
|
||||
return;
|
||||
}
|
||||
emit interfaceAboutToBeReleased();
|
||||
wl_shell_destroy(m_shell);
|
||||
m_shell = nullptr;
|
||||
}
|
||||
|
||||
void Shell::setup(wl_shell *shell)
|
||||
{
|
||||
Q_ASSERT(!m_shell);
|
||||
Q_ASSERT(shell);
|
||||
m_shell = shell;
|
||||
}
|
||||
|
||||
ShellSurface *Shell::createSurface(wl_surface *surface, QObject *parent)
|
||||
{
|
||||
Q_ASSERT(isValid());
|
||||
ShellSurface *s = new ShellSurface(parent);
|
||||
connect(this, &Shell::interfaceAboutToBeReleased, s, &ShellSurface::release);
|
||||
connect(this, &Shell::interfaceAboutToBeDestroyed, s, &ShellSurface::destroy);
|
||||
s->setup(wl_shell_get_shell_surface(m_shell, surface));
|
||||
return s;
|
||||
}
|
||||
|
||||
ShellSurface *Shell::createSurface(Surface *surface, QObject *parent)
|
||||
{
|
||||
Q_ASSERT(surface);
|
||||
return createSurface(*surface, parent);
|
||||
}
|
||||
|
||||
ShellSurface::ShellSurface(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_surface(nullptr)
|
||||
, m_size()
|
||||
{
|
||||
}
|
||||
|
||||
ShellSurface::~ShellSurface()
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
void ShellSurface::release()
|
||||
{
|
||||
if (!isValid()) {
|
||||
return;
|
||||
}
|
||||
wl_shell_surface_destroy(m_surface);
|
||||
m_surface = nullptr;
|
||||
}
|
||||
|
||||
void ShellSurface::destroy()
|
||||
{
|
||||
if (!isValid()) {
|
||||
return;
|
||||
}
|
||||
free(m_surface);
|
||||
m_surface = nullptr;
|
||||
}
|
||||
|
||||
const struct wl_shell_surface_listener ShellSurface::s_listener = {
|
||||
ShellSurface::pingCallback,
|
||||
ShellSurface::configureCallback,
|
||||
ShellSurface::popupDoneCallback
|
||||
};
|
||||
|
||||
void ShellSurface::configureCallback(void *data, wl_shell_surface *shellSurface, uint32_t edges, int32_t width, int32_t height)
|
||||
{
|
||||
Q_UNUSED(edges)
|
||||
ShellSurface *s = reinterpret_cast<ShellSurface*>(data);
|
||||
Q_ASSERT(s->m_surface == shellSurface);
|
||||
s->setSize(QSize(width, height));
|
||||
}
|
||||
|
||||
void ShellSurface::pingCallback(void *data, wl_shell_surface *shellSurface, uint32_t serial)
|
||||
{
|
||||
ShellSurface *s = reinterpret_cast<ShellSurface*>(data);
|
||||
Q_ASSERT(s->m_surface == shellSurface);
|
||||
s->ping(serial);
|
||||
}
|
||||
|
||||
void ShellSurface::popupDoneCallback(void *data, wl_shell_surface *shellSurface)
|
||||
{
|
||||
// not needed, we don't have popups
|
||||
Q_UNUSED(data)
|
||||
Q_UNUSED(shellSurface)
|
||||
}
|
||||
|
||||
void ShellSurface::setup(wl_shell_surface *surface)
|
||||
{
|
||||
Q_ASSERT(surface);
|
||||
Q_ASSERT(!m_surface);
|
||||
m_surface = surface;
|
||||
wl_shell_surface_add_listener(m_surface, &s_listener, this);
|
||||
}
|
||||
|
||||
void ShellSurface::ping(uint32_t serial)
|
||||
{
|
||||
wl_shell_surface_pong(m_surface, serial);
|
||||
emit pinged();
|
||||
}
|
||||
|
||||
void ShellSurface::setSize(const QSize &size)
|
||||
{
|
||||
if (m_size == size) {
|
||||
return;
|
||||
}
|
||||
m_size = size;
|
||||
emit sizeChanged(size);
|
||||
}
|
||||
|
||||
void ShellSurface::setFullscreen(Output *output)
|
||||
{
|
||||
Q_ASSERT(isValid());
|
||||
wl_shell_surface_set_fullscreen(m_surface, WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, output ? output->output() : nullptr);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,114 +0,0 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2014 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_SHELL_H
|
||||
#define KWIN_WAYLAND_SHELL_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QSize>
|
||||
|
||||
#include <wayland-client-protocol.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
namespace Wayland
|
||||
{
|
||||
class ShellSurface;
|
||||
class Output;
|
||||
class Surface;
|
||||
|
||||
class Shell : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Shell(QObject *parent = nullptr);
|
||||
virtual ~Shell();
|
||||
|
||||
bool isValid() const {
|
||||
return m_shell != nullptr;
|
||||
}
|
||||
void release();
|
||||
void destroy();
|
||||
void setup(wl_shell *shell);
|
||||
|
||||
ShellSurface *createSurface(wl_surface *surface, QObject *parent = nullptr);
|
||||
ShellSurface *createSurface(Surface *surface, QObject *parent = nullptr);
|
||||
|
||||
operator wl_shell*() {
|
||||
return m_shell;
|
||||
}
|
||||
operator wl_shell*() const {
|
||||
return m_shell;
|
||||
}
|
||||
|
||||
Q_SIGNALS:
|
||||
void interfaceAboutToBeReleased();
|
||||
void interfaceAboutToBeDestroyed();
|
||||
|
||||
private:
|
||||
wl_shell *m_shell;
|
||||
};
|
||||
|
||||
class ShellSurface : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY sizeChanged)
|
||||
public:
|
||||
explicit ShellSurface(QObject *parent);
|
||||
virtual ~ShellSurface();
|
||||
|
||||
void release();
|
||||
void destroy();
|
||||
void setup(wl_shell_surface *surface);
|
||||
QSize size() const {
|
||||
return m_size;
|
||||
}
|
||||
void setSize(const QSize &size);
|
||||
|
||||
void setFullscreen(Output *output = nullptr);
|
||||
|
||||
bool isValid() const {
|
||||
return m_surface != nullptr;
|
||||
}
|
||||
operator wl_shell_surface*() {
|
||||
return m_surface;
|
||||
}
|
||||
operator wl_shell_surface*() const {
|
||||
return m_surface;
|
||||
}
|
||||
|
||||
static void pingCallback(void *data, struct wl_shell_surface *shellSurface, uint32_t serial);
|
||||
static void configureCallback(void *data, struct wl_shell_surface *shellSurface, uint32_t edges, int32_t width, int32_t height);
|
||||
static void popupDoneCallback(void *data, struct wl_shell_surface *shellSurface);
|
||||
|
||||
Q_SIGNALS:
|
||||
void pinged();
|
||||
void sizeChanged(const QSize &);
|
||||
|
||||
private:
|
||||
void ping(uint32_t serial);
|
||||
wl_shell_surface *m_surface;
|
||||
QSize m_size;
|
||||
static const struct wl_shell_surface_listener s_listener;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,197 +0,0 @@
|
|||
/********************************************************************
|
||||
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/>.
|
||||
*********************************************************************/
|
||||
#include "shm_pool.h"
|
||||
#include "buffer.h"
|
||||
// Qt
|
||||
#include <QDebug>
|
||||
#include <QImage>
|
||||
#include <QTemporaryFile>
|
||||
// system
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
namespace Wayland
|
||||
{
|
||||
|
||||
ShmPool::ShmPool(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_shm(nullptr)
|
||||
, m_pool(nullptr)
|
||||
, m_poolData(nullptr)
|
||||
, m_size(1024)
|
||||
, m_tmpFile(new QTemporaryFile())
|
||||
, m_valid(false)
|
||||
, m_offset(0)
|
||||
{
|
||||
}
|
||||
|
||||
ShmPool::~ShmPool()
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
void ShmPool::release()
|
||||
{
|
||||
qDeleteAll(m_buffers);
|
||||
m_buffers.clear();
|
||||
if (m_poolData) {
|
||||
munmap(m_poolData, m_size);
|
||||
m_poolData = nullptr;
|
||||
}
|
||||
if (m_pool) {
|
||||
wl_shm_pool_destroy(m_pool);
|
||||
m_pool = nullptr;
|
||||
}
|
||||
if (m_shm) {
|
||||
wl_shm_destroy(m_shm);
|
||||
m_shm = nullptr;
|
||||
}
|
||||
m_tmpFile->close();
|
||||
m_valid = false;
|
||||
m_offset = 0;
|
||||
}
|
||||
|
||||
void ShmPool::destroy()
|
||||
{
|
||||
qDeleteAll(m_buffers);
|
||||
m_buffers.clear();
|
||||
if (m_poolData) {
|
||||
munmap(m_poolData, m_size);
|
||||
m_poolData = nullptr;
|
||||
}
|
||||
if (m_pool) {
|
||||
free(m_pool);
|
||||
m_pool = nullptr;
|
||||
}
|
||||
if (m_shm) {
|
||||
free(m_shm);
|
||||
m_shm = nullptr;
|
||||
}
|
||||
m_tmpFile->close();
|
||||
m_valid = false;
|
||||
m_offset = 0;
|
||||
}
|
||||
|
||||
void ShmPool::setup(wl_shm *shm)
|
||||
{
|
||||
Q_ASSERT(shm);
|
||||
Q_ASSERT(!m_shm);
|
||||
m_shm = shm;
|
||||
m_valid = createPool();
|
||||
}
|
||||
|
||||
bool ShmPool::createPool()
|
||||
{
|
||||
if (!m_tmpFile->open()) {
|
||||
qDebug() << "Could not open temporary file for Shm pool";
|
||||
return false;
|
||||
}
|
||||
if (ftruncate(m_tmpFile->handle(), m_size) < 0) {
|
||||
qDebug() << "Could not set size for Shm pool file";
|
||||
return false;
|
||||
}
|
||||
m_poolData = mmap(NULL, m_size, PROT_READ | PROT_WRITE, MAP_SHARED, m_tmpFile->handle(), 0);
|
||||
m_pool = wl_shm_create_pool(m_shm, m_tmpFile->handle(), m_size);
|
||||
|
||||
if (!m_poolData || !m_pool) {
|
||||
qDebug() << "Creating Shm pool failed";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ShmPool::resizePool(int32_t newSize)
|
||||
{
|
||||
if (ftruncate(m_tmpFile->handle(), newSize) < 0) {
|
||||
qDebug() << "Could not set new size for Shm pool file";
|
||||
return false;
|
||||
}
|
||||
wl_shm_pool_resize(m_pool, newSize);
|
||||
munmap(m_poolData, m_size);
|
||||
m_poolData = mmap(NULL, newSize, PROT_READ | PROT_WRITE, MAP_SHARED, m_tmpFile->handle(), 0);
|
||||
m_size = newSize;
|
||||
if (!m_poolData) {
|
||||
qDebug() << "Resizing Shm pool failed";
|
||||
return false;
|
||||
}
|
||||
emit poolResized();
|
||||
return true;
|
||||
}
|
||||
|
||||
wl_buffer *ShmPool::createBuffer(const QImage& image)
|
||||
{
|
||||
if (image.isNull() || !m_valid) {
|
||||
return NULL;
|
||||
}
|
||||
Buffer *buffer = getBuffer(image.size(), image.bytesPerLine());
|
||||
if (!buffer) {
|
||||
return NULL;
|
||||
}
|
||||
buffer->copy(image.bits());
|
||||
return buffer->buffer();
|
||||
}
|
||||
|
||||
wl_buffer *ShmPool::createBuffer(const QSize &size, int32_t stride, const void *src)
|
||||
{
|
||||
if (size.isNull() || !m_valid) {
|
||||
return NULL;
|
||||
}
|
||||
Buffer *buffer = getBuffer(size, stride);
|
||||
if (!buffer) {
|
||||
return NULL;
|
||||
}
|
||||
buffer->copy(src);
|
||||
return buffer->buffer();
|
||||
}
|
||||
|
||||
Buffer *ShmPool::getBuffer(const QSize &size, int32_t stride)
|
||||
{
|
||||
Q_FOREACH (Buffer *buffer, m_buffers) {
|
||||
if (!buffer->isReleased() || buffer->isUsed()) {
|
||||
continue;
|
||||
}
|
||||
if (buffer->size() != size || buffer->stride() != stride) {
|
||||
continue;
|
||||
}
|
||||
buffer->setReleased(false);
|
||||
return buffer;
|
||||
}
|
||||
const int32_t byteCount = size.height() * stride;
|
||||
if (m_offset + byteCount > m_size) {
|
||||
if (!resizePool(m_size + byteCount)) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
// we don't have a buffer which we could reuse - need to create a new one
|
||||
wl_buffer *native = wl_shm_pool_create_buffer(m_pool, m_offset, size.width(), size.height(),
|
||||
stride, WL_SHM_FORMAT_ARGB8888);
|
||||
if (!native) {
|
||||
return NULL;
|
||||
}
|
||||
Buffer *buffer = new Buffer(this, native, size, stride, m_offset);
|
||||
m_offset += byteCount;
|
||||
m_buffers.append(buffer);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,91 +0,0 @@
|
|||
/********************************************************************
|
||||
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_SHM_POOL_H
|
||||
#define KWIN_WAYLAND_SHM_POOL_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class QImage;
|
||||
class QSize;
|
||||
class QTemporaryFile;
|
||||
|
||||
struct wl_shm;
|
||||
struct wl_buffer;
|
||||
struct wl_shm_pool;
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
namespace Wayland
|
||||
{
|
||||
class Buffer;
|
||||
|
||||
class ShmPool : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ShmPool(QObject *parent = nullptr);
|
||||
virtual ~ShmPool();
|
||||
bool isValid() const;
|
||||
void setup(wl_shm *shm);
|
||||
void release();
|
||||
void destroy();
|
||||
|
||||
wl_buffer *createBuffer(const QImage &image);
|
||||
wl_buffer *createBuffer(const QSize &size, int32_t stride, const void *src);
|
||||
void *poolAddress() const;
|
||||
Buffer *getBuffer(const QSize &size, int32_t stride);
|
||||
wl_shm *shm();
|
||||
Q_SIGNALS:
|
||||
void poolResized();
|
||||
private:
|
||||
bool createPool();
|
||||
bool resizePool(int32_t newSize);
|
||||
wl_shm *m_shm;
|
||||
wl_shm_pool *m_pool;
|
||||
void *m_poolData;
|
||||
int32_t m_size;
|
||||
QScopedPointer<QTemporaryFile> m_tmpFile;
|
||||
bool m_valid;
|
||||
int m_offset;
|
||||
QList<Buffer*> m_buffers;
|
||||
};
|
||||
|
||||
inline
|
||||
bool ShmPool::isValid() const
|
||||
{
|
||||
return m_valid;
|
||||
}
|
||||
|
||||
inline
|
||||
void* ShmPool::poolAddress() const
|
||||
{
|
||||
return m_poolData;
|
||||
}
|
||||
|
||||
inline
|
||||
wl_shm *ShmPool::shm()
|
||||
{
|
||||
return m_shm;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,156 +0,0 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2014 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/>.
|
||||
*********************************************************************/
|
||||
#include "surface.h"
|
||||
|
||||
#include <QRegion>
|
||||
#include <QVector>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
namespace Wayland
|
||||
{
|
||||
|
||||
QList<Surface*> Surface::s_surfaces = QList<Surface*>();
|
||||
|
||||
Surface::Surface(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_surface(nullptr)
|
||||
, m_frameCallbackInstalled(false)
|
||||
{
|
||||
s_surfaces << this;
|
||||
}
|
||||
|
||||
Surface::~Surface()
|
||||
{
|
||||
s_surfaces.removeAll(this);
|
||||
release();
|
||||
}
|
||||
|
||||
void Surface::release()
|
||||
{
|
||||
if (!m_surface) {
|
||||
return;
|
||||
}
|
||||
wl_surface_destroy(m_surface);
|
||||
m_surface = nullptr;
|
||||
}
|
||||
|
||||
void Surface::destroy()
|
||||
{
|
||||
if (!m_surface) {
|
||||
return;
|
||||
}
|
||||
free(m_surface);
|
||||
m_surface = nullptr;
|
||||
}
|
||||
|
||||
void Surface::setup(wl_surface *surface)
|
||||
{
|
||||
Q_ASSERT(surface);
|
||||
Q_ASSERT(!m_surface);
|
||||
m_surface = surface;
|
||||
}
|
||||
|
||||
void Surface::frameCallback(void *data, wl_callback *callback, uint32_t time)
|
||||
{
|
||||
Q_UNUSED(time)
|
||||
Surface *s = reinterpret_cast<Surface*>(data);
|
||||
if (callback) {
|
||||
wl_callback_destroy(callback);
|
||||
}
|
||||
s->handleFrameCallback();
|
||||
}
|
||||
|
||||
void Surface::handleFrameCallback()
|
||||
{
|
||||
m_frameCallbackInstalled = false;
|
||||
frameRendered();
|
||||
}
|
||||
|
||||
const struct wl_callback_listener Surface::s_listener = {
|
||||
Surface::frameCallback
|
||||
};
|
||||
|
||||
void Surface::setupFrameCallback()
|
||||
{
|
||||
Q_ASSERT(isValid());
|
||||
Q_ASSERT(!m_frameCallbackInstalled);
|
||||
wl_callback *callback = wl_surface_frame(m_surface);
|
||||
wl_callback_add_listener(callback, &s_listener, this);
|
||||
m_frameCallbackInstalled = true;
|
||||
}
|
||||
|
||||
void Surface::commit(Surface::CommitFlag flag)
|
||||
{
|
||||
Q_ASSERT(isValid());
|
||||
if (flag == CommitFlag::FrameCallback) {
|
||||
setupFrameCallback();
|
||||
}
|
||||
wl_surface_commit(m_surface);
|
||||
}
|
||||
|
||||
void Surface::damage(const QRegion ®ion)
|
||||
{
|
||||
for (const QRect &r : region.rects()) {
|
||||
damage(r);
|
||||
}
|
||||
}
|
||||
|
||||
void Surface::damage(const QRect &rect)
|
||||
{
|
||||
Q_ASSERT(isValid());
|
||||
wl_surface_damage(m_surface, rect.x(), rect.y(), rect.width(), rect.height());
|
||||
}
|
||||
|
||||
void Surface::attachBuffer(wl_buffer *buffer, const QPoint &offset)
|
||||
{
|
||||
Q_ASSERT(isValid());
|
||||
wl_surface_attach(m_surface, buffer, offset.x(), offset.y());
|
||||
}
|
||||
|
||||
void Surface::setSize(const QSize &size)
|
||||
{
|
||||
if (m_size == size) {
|
||||
return;
|
||||
}
|
||||
m_size = size;
|
||||
emit sizeChanged(m_size);
|
||||
}
|
||||
|
||||
Surface *Surface::get(wl_surface *native)
|
||||
{
|
||||
auto it = std::find_if(s_surfaces.constBegin(), s_surfaces.constEnd(),
|
||||
[native](Surface *s) {
|
||||
return s->m_surface == native;
|
||||
}
|
||||
);
|
||||
if (it != s_surfaces.constEnd()) {
|
||||
return *(it);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const QList< Surface* > &Surface::all()
|
||||
{
|
||||
return s_surfaces;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,89 +0,0 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2014 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_SURFACE_H
|
||||
#define KWIN_WAYLAND_SURFACE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QPoint>
|
||||
#include <QSize>
|
||||
|
||||
#include <wayland-client-protocol.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
namespace Wayland
|
||||
{
|
||||
|
||||
class Surface : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Surface(QObject *parent = nullptr);
|
||||
virtual ~Surface();
|
||||
|
||||
void setup(wl_surface *surface);
|
||||
void release();
|
||||
void destroy();
|
||||
bool isValid() const {
|
||||
return m_surface != nullptr;
|
||||
}
|
||||
void setupFrameCallback();
|
||||
enum class CommitFlag {
|
||||
None,
|
||||
FrameCallback
|
||||
};
|
||||
void commit(CommitFlag flag = CommitFlag::FrameCallback);
|
||||
void damage(const QRect &rect);
|
||||
void damage(const QRegion ®ion);
|
||||
void attachBuffer(wl_buffer *buffer, const QPoint &offset = QPoint());
|
||||
void setSize(const QSize &size);
|
||||
const QSize &size() const {
|
||||
return m_size;
|
||||
}
|
||||
|
||||
operator wl_surface*() {
|
||||
return m_surface;
|
||||
}
|
||||
operator wl_surface*() const {
|
||||
return m_surface;
|
||||
}
|
||||
|
||||
static void frameCallback(void *data, wl_callback *callback, uint32_t time);
|
||||
|
||||
static const QList<Surface*> &all();
|
||||
static Surface *get(wl_surface *native);
|
||||
|
||||
Q_SIGNALS:
|
||||
void frameRendered();
|
||||
void sizeChanged(const QSize&);
|
||||
|
||||
private:
|
||||
void handleFrameCallback();
|
||||
static const wl_callback_listener s_listener;
|
||||
static QList<Surface*> s_surfaces;
|
||||
wl_surface *m_surface;
|
||||
bool m_frameCallbackInstalled;
|
||||
QSize m_size;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue