backends/x11: port away from most remaining manual memory management
This commit is contained in:
parent
5412ccb71c
commit
297971006b
12 changed files with 74 additions and 82 deletions
|
@ -23,17 +23,15 @@ X11Cursor::X11Cursor(QObject *parent, bool xInputSupport)
|
||||||
: Cursor(parent)
|
: Cursor(parent)
|
||||||
, m_timeStamp(XCB_TIME_CURRENT_TIME)
|
, m_timeStamp(XCB_TIME_CURRENT_TIME)
|
||||||
, m_buttonMask(0)
|
, m_buttonMask(0)
|
||||||
, m_resetTimeStampTimer(new QTimer(this))
|
|
||||||
, m_mousePollingTimer(new QTimer(this))
|
|
||||||
, m_hasXInput(xInputSupport)
|
, m_hasXInput(xInputSupport)
|
||||||
, m_needsPoll(false)
|
, m_needsPoll(false)
|
||||||
{
|
{
|
||||||
Cursors::self()->setMouse(this);
|
Cursors::self()->setMouse(this);
|
||||||
m_resetTimeStampTimer->setSingleShot(true);
|
m_resetTimeStampTimer.setSingleShot(true);
|
||||||
connect(m_resetTimeStampTimer, &QTimer::timeout, this, &X11Cursor::resetTimeStamp);
|
connect(&m_resetTimeStampTimer, &QTimer::timeout, this, &X11Cursor::resetTimeStamp);
|
||||||
// TODO: How often do we really need to poll?
|
// TODO: How often do we really need to poll?
|
||||||
m_mousePollingTimer->setInterval(50);
|
m_mousePollingTimer.setInterval(50);
|
||||||
connect(m_mousePollingTimer, &QTimer::timeout, this, &X11Cursor::mousePolled);
|
connect(&m_mousePollingTimer, &QTimer::timeout, this, &X11Cursor::mousePolled);
|
||||||
|
|
||||||
if (m_hasXInput) {
|
if (m_hasXInput) {
|
||||||
connect(qApp->eventDispatcher(), &QAbstractEventDispatcher::aboutToBlock, this, &X11Cursor::aboutToBlock);
|
connect(qApp->eventDispatcher(), &QAbstractEventDispatcher::aboutToBlock, this, &X11Cursor::aboutToBlock);
|
||||||
|
@ -73,7 +71,7 @@ void X11Cursor::doGetPos()
|
||||||
}
|
}
|
||||||
m_buttonMask = pointer->mask;
|
m_buttonMask = pointer->mask;
|
||||||
updatePos(pointer->root_x, pointer->root_y);
|
updatePos(pointer->root_x, pointer->root_y);
|
||||||
m_resetTimeStampTimer->start(0);
|
m_resetTimeStampTimer.start(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void X11Cursor::resetTimeStamp()
|
void X11Cursor::resetTimeStamp()
|
||||||
|
@ -92,14 +90,14 @@ void X11Cursor::aboutToBlock()
|
||||||
void X11Cursor::doStartMousePolling()
|
void X11Cursor::doStartMousePolling()
|
||||||
{
|
{
|
||||||
if (!m_hasXInput) {
|
if (!m_hasXInput) {
|
||||||
m_mousePollingTimer->start();
|
m_mousePollingTimer.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void X11Cursor::doStopMousePolling()
|
void X11Cursor::doStopMousePolling()
|
||||||
{
|
{
|
||||||
if (!m_hasXInput) {
|
if (!m_hasXInput) {
|
||||||
m_mousePollingTimer->stop();
|
m_mousePollingTimer.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#define KWIN_X11CURSOR_H
|
#define KWIN_X11CURSOR_H
|
||||||
#include "cursor.h"
|
#include "cursor.h"
|
||||||
|
|
||||||
|
#include <QTimer>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace KWin
|
namespace KWin
|
||||||
|
@ -56,8 +57,8 @@ private Q_SLOTS:
|
||||||
private:
|
private:
|
||||||
xcb_timestamp_t m_timeStamp;
|
xcb_timestamp_t m_timeStamp;
|
||||||
uint16_t m_buttonMask;
|
uint16_t m_buttonMask;
|
||||||
QTimer *m_resetTimeStampTimer;
|
QTimer m_resetTimeStampTimer;
|
||||||
QTimer *m_mousePollingTimer;
|
QTimer m_mousePollingTimer;
|
||||||
bool m_hasXInput;
|
bool m_hasXInput;
|
||||||
bool m_needsPoll;
|
bool m_needsPoll;
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ bool XrandrEventFilter::event(xcb_generic_event_t *event)
|
||||||
|
|
||||||
X11StandalonePlatform::X11StandalonePlatform(QObject *parent)
|
X11StandalonePlatform::X11StandalonePlatform(QObject *parent)
|
||||||
: Platform(parent)
|
: Platform(parent)
|
||||||
, m_updateOutputsTimer(new QTimer(this))
|
, m_updateOutputsTimer(std::make_unique<QTimer>())
|
||||||
, m_x11Display(QX11Info::display())
|
, m_x11Display(QX11Info::display())
|
||||||
, m_renderLoop(std::make_unique<RenderLoop>())
|
, m_renderLoop(std::make_unique<RenderLoop>())
|
||||||
{
|
{
|
||||||
|
@ -119,7 +119,7 @@ X11StandalonePlatform::X11StandalonePlatform(QObject *parent)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_updateOutputsTimer->setSingleShot(true);
|
m_updateOutputsTimer->setSingleShot(true);
|
||||||
connect(m_updateOutputsTimer, &QTimer::timeout, this, &X11StandalonePlatform::updateOutputs);
|
connect(m_updateOutputsTimer.get(), &QTimer::timeout, this, &X11StandalonePlatform::updateOutputs);
|
||||||
|
|
||||||
setSupportsGammaControl(true);
|
setSupportsGammaControl(true);
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,6 @@ X11StandalonePlatform::~X11StandalonePlatform()
|
||||||
if (m_openGLFreezeProtectionThread) {
|
if (m_openGLFreezeProtectionThread) {
|
||||||
m_openGLFreezeProtectionThread->quit();
|
m_openGLFreezeProtectionThread->quit();
|
||||||
m_openGLFreezeProtectionThread->wait();
|
m_openGLFreezeProtectionThread->wait();
|
||||||
delete m_openGLFreezeProtectionThread;
|
|
||||||
}
|
}
|
||||||
if (sceneEglDisplay() != EGL_NO_DISPLAY) {
|
if (sceneEglDisplay() != EGL_NO_DISPLAY) {
|
||||||
eglTerminate(sceneEglDisplay());
|
eglTerminate(sceneEglDisplay());
|
||||||
|
@ -149,7 +148,7 @@ bool X11StandalonePlatform::initialize()
|
||||||
initOutputs();
|
initOutputs();
|
||||||
|
|
||||||
if (Xcb::Extensions::self()->isRandrAvailable()) {
|
if (Xcb::Extensions::self()->isRandrAvailable()) {
|
||||||
m_randrEventFilter.reset(new XrandrEventFilter(this));
|
m_randrEventFilter = std::make_unique<XrandrEventFilter>(this);
|
||||||
}
|
}
|
||||||
connect(Cursors::self(), &Cursors::hiddenChanged, this, &X11StandalonePlatform::updateCursor);
|
connect(Cursors::self(), &Cursors::hiddenChanged, this, &X11StandalonePlatform::updateCursor);
|
||||||
return true;
|
return true;
|
||||||
|
@ -275,17 +274,17 @@ void X11StandalonePlatform::createOpenGLSafePoint(OpenGLSafePoint safePoint)
|
||||||
case OpenGLSafePoint::PreFrame:
|
case OpenGLSafePoint::PreFrame:
|
||||||
if (m_openGLFreezeProtectionThread == nullptr) {
|
if (m_openGLFreezeProtectionThread == nullptr) {
|
||||||
Q_ASSERT(m_openGLFreezeProtection == nullptr);
|
Q_ASSERT(m_openGLFreezeProtection == nullptr);
|
||||||
m_openGLFreezeProtectionThread = new QThread(this);
|
m_openGLFreezeProtectionThread = std::make_unique<QThread>();
|
||||||
m_openGLFreezeProtectionThread->setObjectName("FreezeDetector");
|
m_openGLFreezeProtectionThread->setObjectName("FreezeDetector");
|
||||||
m_openGLFreezeProtectionThread->start();
|
m_openGLFreezeProtectionThread->start();
|
||||||
m_openGLFreezeProtection = new QTimer;
|
m_openGLFreezeProtection = std::make_unique<QTimer>();
|
||||||
m_openGLFreezeProtection->setInterval(15000);
|
m_openGLFreezeProtection->setInterval(15000);
|
||||||
m_openGLFreezeProtection->setSingleShot(true);
|
m_openGLFreezeProtection->setSingleShot(true);
|
||||||
m_openGLFreezeProtection->start();
|
m_openGLFreezeProtection->start();
|
||||||
const QString configName = kwinApp()->config()->name();
|
const QString configName = kwinApp()->config()->name();
|
||||||
m_openGLFreezeProtection->moveToThread(m_openGLFreezeProtectionThread);
|
m_openGLFreezeProtection->moveToThread(m_openGLFreezeProtectionThread.get());
|
||||||
connect(
|
connect(
|
||||||
m_openGLFreezeProtection, &QTimer::timeout, m_openGLFreezeProtection,
|
m_openGLFreezeProtection.get(), &QTimer::timeout, m_openGLFreezeProtection.get(),
|
||||||
[configName] {
|
[configName] {
|
||||||
auto group = KConfigGroup(KSharedConfig::openConfig(configName), "Compositing");
|
auto group = KConfigGroup(KSharedConfig::openConfig(configName), "Compositing");
|
||||||
group.writeEntry(QLatin1String("OpenGLIsUnsafe"), true);
|
group.writeEntry(QLatin1String("OpenGLIsUnsafe"), true);
|
||||||
|
@ -296,7 +295,7 @@ void X11StandalonePlatform::createOpenGLSafePoint(OpenGLSafePoint safePoint)
|
||||||
Qt::DirectConnection);
|
Qt::DirectConnection);
|
||||||
} else {
|
} else {
|
||||||
Q_ASSERT(m_openGLFreezeProtection);
|
Q_ASSERT(m_openGLFreezeProtection);
|
||||||
QMetaObject::invokeMethod(m_openGLFreezeProtection, QOverload<>::of(&QTimer::start), Qt::QueuedConnection);
|
QMetaObject::invokeMethod(m_openGLFreezeProtection.get(), QOverload<>::of(&QTimer::start), Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OpenGLSafePoint::PostInit:
|
case OpenGLSafePoint::PostInit:
|
||||||
|
@ -305,15 +304,13 @@ void X11StandalonePlatform::createOpenGLSafePoint(OpenGLSafePoint safePoint)
|
||||||
// Deliberately continue with PostFrame
|
// Deliberately continue with PostFrame
|
||||||
Q_FALLTHROUGH();
|
Q_FALLTHROUGH();
|
||||||
case OpenGLSafePoint::PostFrame:
|
case OpenGLSafePoint::PostFrame:
|
||||||
QMetaObject::invokeMethod(m_openGLFreezeProtection, &QTimer::stop, Qt::QueuedConnection);
|
QMetaObject::invokeMethod(m_openGLFreezeProtection.get(), &QTimer::stop, Qt::QueuedConnection);
|
||||||
break;
|
break;
|
||||||
case OpenGLSafePoint::PostLastGuardedFrame:
|
case OpenGLSafePoint::PostLastGuardedFrame:
|
||||||
m_openGLFreezeProtection->deleteLater();
|
|
||||||
m_openGLFreezeProtection = nullptr;
|
|
||||||
m_openGLFreezeProtectionThread->quit();
|
m_openGLFreezeProtectionThread->quit();
|
||||||
m_openGLFreezeProtectionThread->wait();
|
m_openGLFreezeProtectionThread->wait();
|
||||||
delete m_openGLFreezeProtectionThread;
|
m_openGLFreezeProtectionThread.reset();
|
||||||
m_openGLFreezeProtectionThread = nullptr;
|
m_openGLFreezeProtection.reset();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -347,7 +344,7 @@ void X11StandalonePlatform::updateCursor()
|
||||||
void X11StandalonePlatform::startInteractiveWindowSelection(std::function<void(KWin::Window *)> callback, const QByteArray &cursorName)
|
void X11StandalonePlatform::startInteractiveWindowSelection(std::function<void(KWin::Window *)> callback, const QByteArray &cursorName)
|
||||||
{
|
{
|
||||||
if (!m_windowSelector) {
|
if (!m_windowSelector) {
|
||||||
m_windowSelector.reset(new WindowSelector);
|
m_windowSelector = std::make_unique<WindowSelector>();
|
||||||
}
|
}
|
||||||
m_windowSelector->start(callback, cursorName);
|
m_windowSelector->start(callback, cursorName);
|
||||||
}
|
}
|
||||||
|
@ -355,7 +352,7 @@ void X11StandalonePlatform::startInteractiveWindowSelection(std::function<void(K
|
||||||
void X11StandalonePlatform::startInteractivePositionSelection(std::function<void(const QPoint &)> callback)
|
void X11StandalonePlatform::startInteractivePositionSelection(std::function<void(const QPoint &)> callback)
|
||||||
{
|
{
|
||||||
if (!m_windowSelector) {
|
if (!m_windowSelector) {
|
||||||
m_windowSelector.reset(new WindowSelector);
|
m_windowSelector = std::make_unique<WindowSelector>();
|
||||||
}
|
}
|
||||||
m_windowSelector->start(callback);
|
m_windowSelector->start(callback);
|
||||||
}
|
}
|
||||||
|
@ -382,12 +379,12 @@ std::unique_ptr<OverlayWindow> X11StandalonePlatform::createOverlayWindow()
|
||||||
return std::make_unique<OverlayWindowX11>();
|
return std::make_unique<OverlayWindowX11>();
|
||||||
}
|
}
|
||||||
|
|
||||||
OutlineVisual *X11StandalonePlatform::createOutline(Outline *outline)
|
std::unique_ptr<OutlineVisual> X11StandalonePlatform::createOutline(Outline *outline)
|
||||||
{
|
{
|
||||||
// first try composited Outline
|
// first try composited Outline
|
||||||
auto ret = Platform::createOutline(outline);
|
auto ret = Platform::createOutline(outline);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
ret = new NonCompositedOutlineVisual(outline);
|
ret = std::make_unique<NonCompositedOutlineVisual>(outline);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ public:
|
||||||
void setupActionForGlobalAccel(QAction *action) override;
|
void setupActionForGlobalAccel(QAction *action) override;
|
||||||
|
|
||||||
std::unique_ptr<OverlayWindow> createOverlayWindow() override;
|
std::unique_ptr<OverlayWindow> createOverlayWindow() override;
|
||||||
OutlineVisual *createOutline(Outline *outline) override;
|
std::unique_ptr<OutlineVisual> createOutline(Outline *outline) override;
|
||||||
|
|
||||||
void invertScreen() override;
|
void invertScreen() override;
|
||||||
|
|
||||||
|
@ -85,9 +85,9 @@ private:
|
||||||
void updateCursor();
|
void updateCursor();
|
||||||
|
|
||||||
std::unique_ptr<XInputIntegration> m_xinputIntegration;
|
std::unique_ptr<XInputIntegration> m_xinputIntegration;
|
||||||
QThread *m_openGLFreezeProtectionThread = nullptr;
|
std::unique_ptr<QThread> m_openGLFreezeProtectionThread;
|
||||||
QTimer *m_openGLFreezeProtection = nullptr;
|
std::unique_ptr<QTimer> m_openGLFreezeProtection;
|
||||||
QTimer *m_updateOutputsTimer = nullptr;
|
std::unique_ptr<QTimer> m_updateOutputsTimer;
|
||||||
Display *m_x11Display;
|
Display *m_x11Display;
|
||||||
std::unique_ptr<WindowSelector> m_windowSelector;
|
std::unique_ptr<WindowSelector> m_windowSelector;
|
||||||
std::unique_ptr<X11EventFilter> m_screenEdgesFilter;
|
std::unique_ptr<X11EventFilter> m_screenEdgesFilter;
|
||||||
|
|
|
@ -274,11 +274,11 @@ void XInputIntegration::startListening()
|
||||||
evmasks[0].mask = mask1;
|
evmasks[0].mask = mask1;
|
||||||
XISelectEvents(display(), rootWindow(), evmasks, 1);
|
XISelectEvents(display(), rootWindow(), evmasks, 1);
|
||||||
|
|
||||||
m_xiEventFilter.reset(new XInputEventFilter(m_xiOpcode));
|
m_xiEventFilter = std::make_unique<XInputEventFilter>(m_xiOpcode);
|
||||||
m_xiEventFilter->setCursor(m_x11Cursor);
|
m_xiEventFilter->setCursor(m_x11Cursor);
|
||||||
m_xiEventFilter->setDisplay(display());
|
m_xiEventFilter->setDisplay(display());
|
||||||
m_keyPressFilter.reset(new XKeyPressReleaseEventFilter(XCB_KEY_PRESS));
|
m_keyPressFilter = std::make_unique<XKeyPressReleaseEventFilter>(XCB_KEY_PRESS);
|
||||||
m_keyReleaseFilter.reset(new XKeyPressReleaseEventFilter(XCB_KEY_RELEASE));
|
m_keyReleaseFilter = std::make_unique<XKeyPressReleaseEventFilter>(XCB_KEY_RELEASE);
|
||||||
|
|
||||||
// install the input event spies also relevant for X11 platform
|
// install the input event spies also relevant for X11 platform
|
||||||
input()->installInputEventSpy(new ModifierOnlyShortcuts);
|
input()->installInputEventSpy(new ModifierOnlyShortcuts);
|
||||||
|
|
|
@ -42,11 +42,6 @@
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
|
||||||
X11WindowedInputDevice::X11WindowedInputDevice(QObject *parent)
|
|
||||||
: InputDevice(parent)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void X11WindowedInputDevice::setPointer(bool set)
|
void X11WindowedInputDevice::setPointer(bool set)
|
||||||
{
|
{
|
||||||
m_pointer = set;
|
m_pointer = set;
|
||||||
|
@ -142,9 +137,8 @@ bool X11WindowedInputDevice::isLidSwitch() const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
X11WindowedInputBackend::X11WindowedInputBackend(X11WindowedBackend *backend, QObject *parent)
|
X11WindowedInputBackend::X11WindowedInputBackend(X11WindowedBackend *backend)
|
||||||
: InputBackend(parent)
|
: m_backend(backend)
|
||||||
, m_backend(backend)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,17 +155,16 @@ void X11WindowedInputBackend::initialize()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
X11WindowedBackend::X11WindowedBackend(QObject *parent)
|
X11WindowedBackend::X11WindowedBackend()
|
||||||
: Platform(parent)
|
|
||||||
{
|
{
|
||||||
setSupportsPointerWarping(true);
|
setSupportsPointerWarping(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
X11WindowedBackend::~X11WindowedBackend()
|
X11WindowedBackend::~X11WindowedBackend()
|
||||||
{
|
{
|
||||||
delete m_pointerDevice;
|
m_pointerDevice.reset();
|
||||||
delete m_keyboardDevice;
|
m_keyboardDevice.reset();
|
||||||
delete m_touchDevice;
|
m_touchDevice.reset();
|
||||||
|
|
||||||
if (sceneEglDisplay() != EGL_NO_DISPLAY) {
|
if (sceneEglDisplay() != EGL_NO_DISPLAY) {
|
||||||
eglTerminate(sceneEglDisplay());
|
eglTerminate(sceneEglDisplay());
|
||||||
|
@ -217,12 +210,12 @@ bool X11WindowedBackend::initialize()
|
||||||
createCursor(c->image(), c->hotspot());
|
createCursor(c->image(), c->hotspot());
|
||||||
});
|
});
|
||||||
setReady(true);
|
setReady(true);
|
||||||
m_pointerDevice = new X11WindowedInputDevice(this);
|
m_pointerDevice = std::make_unique<X11WindowedInputDevice>();
|
||||||
m_pointerDevice->setPointer(true);
|
m_pointerDevice->setPointer(true);
|
||||||
m_keyboardDevice = new X11WindowedInputDevice(this);
|
m_keyboardDevice = std::make_unique<X11WindowedInputDevice>();
|
||||||
m_keyboardDevice->setKeyboard(true);
|
m_keyboardDevice->setKeyboard(true);
|
||||||
if (m_hasXInput) {
|
if (m_hasXInput) {
|
||||||
m_touchDevice = new X11WindowedInputDevice(this);
|
m_touchDevice = std::make_unique<X11WindowedInputDevice>();
|
||||||
m_touchDevice->setTouch(true);
|
m_touchDevice->setTouch(true);
|
||||||
}
|
}
|
||||||
Q_EMIT outputsQueried();
|
Q_EMIT outputsQueried();
|
||||||
|
@ -309,7 +302,7 @@ void X11WindowedBackend::createOutputs()
|
||||||
|
|
||||||
void X11WindowedBackend::startEventReading()
|
void X11WindowedBackend::startEventReading()
|
||||||
{
|
{
|
||||||
QSocketNotifier *notifier = new QSocketNotifier(xcb_get_file_descriptor(m_connection), QSocketNotifier::Read, this);
|
m_eventNotifier = std::make_unique<QSocketNotifier>(xcb_get_file_descriptor(m_connection), QSocketNotifier::Read);
|
||||||
auto processXcbEvents = [this] {
|
auto processXcbEvents = [this] {
|
||||||
while (auto event = xcb_poll_for_event(m_connection)) {
|
while (auto event = xcb_poll_for_event(m_connection)) {
|
||||||
handleEvent(event);
|
handleEvent(event);
|
||||||
|
@ -317,7 +310,7 @@ void X11WindowedBackend::startEventReading()
|
||||||
}
|
}
|
||||||
xcb_flush(m_connection);
|
xcb_flush(m_connection);
|
||||||
};
|
};
|
||||||
connect(notifier, &QSocketNotifier::activated, this, processXcbEvents);
|
connect(m_eventNotifier.get(), &QSocketNotifier::activated, this, processXcbEvents);
|
||||||
connect(QCoreApplication::eventDispatcher(), &QAbstractEventDispatcher::aboutToBlock, this, processXcbEvents);
|
connect(QCoreApplication::eventDispatcher(), &QAbstractEventDispatcher::aboutToBlock, this, processXcbEvents);
|
||||||
connect(QCoreApplication::eventDispatcher(), &QAbstractEventDispatcher::awake, this, processXcbEvents);
|
connect(QCoreApplication::eventDispatcher(), &QAbstractEventDispatcher::awake, this, processXcbEvents);
|
||||||
}
|
}
|
||||||
|
@ -345,7 +338,7 @@ void X11WindowedBackend::handleEvent(xcb_generic_event_t *e)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const QPointF position = output->mapFromGlobal(QPointF(event->root_x, event->root_y));
|
const QPointF position = output->mapFromGlobal(QPointF(event->root_x, event->root_y));
|
||||||
Q_EMIT m_pointerDevice->pointerMotionAbsolute(position, event->time, m_pointerDevice);
|
Q_EMIT m_pointerDevice->pointerMotionAbsolute(position, event->time, m_pointerDevice.get());
|
||||||
} break;
|
} break;
|
||||||
case XCB_KEY_PRESS:
|
case XCB_KEY_PRESS:
|
||||||
case XCB_KEY_RELEASE: {
|
case XCB_KEY_RELEASE: {
|
||||||
|
@ -361,12 +354,12 @@ void X11WindowedBackend::handleEvent(xcb_generic_event_t *e)
|
||||||
Q_EMIT m_keyboardDevice->keyChanged(event->detail - 8,
|
Q_EMIT m_keyboardDevice->keyChanged(event->detail - 8,
|
||||||
InputRedirection::KeyboardKeyPressed,
|
InputRedirection::KeyboardKeyPressed,
|
||||||
event->time,
|
event->time,
|
||||||
m_keyboardDevice);
|
m_keyboardDevice.get());
|
||||||
} else {
|
} else {
|
||||||
Q_EMIT m_keyboardDevice->keyChanged(event->detail - 8,
|
Q_EMIT m_keyboardDevice->keyChanged(event->detail - 8,
|
||||||
InputRedirection::KeyboardKeyReleased,
|
InputRedirection::KeyboardKeyReleased,
|
||||||
event->time,
|
event->time,
|
||||||
m_keyboardDevice);
|
m_keyboardDevice.get());
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case XCB_CONFIGURE_NOTIFY:
|
case XCB_CONFIGURE_NOTIFY:
|
||||||
|
@ -379,7 +372,7 @@ void X11WindowedBackend::handleEvent(xcb_generic_event_t *e)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const QPointF position = output->mapFromGlobal(QPointF(event->root_x, event->root_y));
|
const QPointF position = output->mapFromGlobal(QPointF(event->root_x, event->root_y));
|
||||||
Q_EMIT m_pointerDevice->pointerMotionAbsolute(position, event->time, m_pointerDevice);
|
Q_EMIT m_pointerDevice->pointerMotionAbsolute(position, event->time, m_pointerDevice.get());
|
||||||
} break;
|
} break;
|
||||||
case XCB_CLIENT_MESSAGE:
|
case XCB_CLIENT_MESSAGE:
|
||||||
handleClientMessage(reinterpret_cast<xcb_client_message_event_t *>(e));
|
handleClientMessage(reinterpret_cast<xcb_client_message_event_t *>(e));
|
||||||
|
@ -406,18 +399,18 @@ void X11WindowedBackend::handleEvent(xcb_generic_event_t *e)
|
||||||
switch (ge->event_type) {
|
switch (ge->event_type) {
|
||||||
|
|
||||||
case XI_TouchBegin: {
|
case XI_TouchBegin: {
|
||||||
Q_EMIT m_touchDevice->touchDown(te->detail, position, te->time, m_touchDevice);
|
Q_EMIT m_touchDevice->touchDown(te->detail, position, te->time, m_touchDevice.get());
|
||||||
Q_EMIT m_touchDevice->touchFrame(m_touchDevice);
|
Q_EMIT m_touchDevice->touchFrame(m_touchDevice.get());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case XI_TouchUpdate: {
|
case XI_TouchUpdate: {
|
||||||
Q_EMIT m_touchDevice->touchMotion(te->detail, position, te->time, m_touchDevice);
|
Q_EMIT m_touchDevice->touchMotion(te->detail, position, te->time, m_touchDevice.get());
|
||||||
Q_EMIT m_touchDevice->touchFrame(m_touchDevice);
|
Q_EMIT m_touchDevice->touchFrame(m_touchDevice.get());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case XI_TouchEnd: {
|
case XI_TouchEnd: {
|
||||||
Q_EMIT m_touchDevice->touchUp(te->detail, te->time, m_touchDevice);
|
Q_EMIT m_touchDevice->touchUp(te->detail, te->time, m_touchDevice.get());
|
||||||
Q_EMIT m_touchDevice->touchFrame(m_touchDevice);
|
Q_EMIT m_touchDevice->touchFrame(m_touchDevice.get());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case XI_TouchOwnership: {
|
case XI_TouchOwnership: {
|
||||||
|
@ -531,7 +524,7 @@ void X11WindowedBackend::handleButtonPress(xcb_button_press_event_t *event)
|
||||||
delta,
|
delta,
|
||||||
InputRedirection::PointerAxisSourceUnknown,
|
InputRedirection::PointerAxisSourceUnknown,
|
||||||
event->time,
|
event->time,
|
||||||
m_pointerDevice);
|
m_pointerDevice.get());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint32_t button = 0;
|
uint32_t button = 0;
|
||||||
|
@ -551,12 +544,12 @@ void X11WindowedBackend::handleButtonPress(xcb_button_press_event_t *event)
|
||||||
}
|
}
|
||||||
|
|
||||||
const QPointF position = output->mapFromGlobal(QPointF(event->root_x, event->root_y));
|
const QPointF position = output->mapFromGlobal(QPointF(event->root_x, event->root_y));
|
||||||
Q_EMIT m_pointerDevice->pointerMotionAbsolute(position, event->time, m_pointerDevice);
|
Q_EMIT m_pointerDevice->pointerMotionAbsolute(position, event->time, m_pointerDevice.get());
|
||||||
|
|
||||||
if (pressed) {
|
if (pressed) {
|
||||||
Q_EMIT m_pointerDevice->pointerButtonChanged(button, InputRedirection::PointerButtonPressed, event->time, m_pointerDevice);
|
Q_EMIT m_pointerDevice->pointerButtonChanged(button, InputRedirection::PointerButtonPressed, event->time, m_pointerDevice.get());
|
||||||
} else {
|
} else {
|
||||||
Q_EMIT m_pointerDevice->pointerButtonChanged(button, InputRedirection::PointerButtonReleased, event->time, m_pointerDevice);
|
Q_EMIT m_pointerDevice->pointerButtonChanged(button, InputRedirection::PointerButtonReleased, event->time, m_pointerDevice.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -637,17 +630,17 @@ xcb_window_t X11WindowedBackend::rootWindow() const
|
||||||
|
|
||||||
X11WindowedInputDevice *X11WindowedBackend::pointerDevice() const
|
X11WindowedInputDevice *X11WindowedBackend::pointerDevice() const
|
||||||
{
|
{
|
||||||
return m_pointerDevice;
|
return m_pointerDevice.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
X11WindowedInputDevice *X11WindowedBackend::keyboardDevice() const
|
X11WindowedInputDevice *X11WindowedBackend::keyboardDevice() const
|
||||||
{
|
{
|
||||||
return m_keyboardDevice;
|
return m_keyboardDevice.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
X11WindowedInputDevice *X11WindowedBackend::touchDevice() const
|
X11WindowedInputDevice *X11WindowedBackend::touchDevice() const
|
||||||
{
|
{
|
||||||
return m_touchDevice;
|
return m_touchDevice.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<OpenGLBackend> X11WindowedBackend::createOpenGLBackend()
|
std::unique_ptr<OpenGLBackend> X11WindowedBackend::createOpenGLBackend()
|
||||||
|
|
|
@ -23,6 +23,7 @@ struct _XDisplay;
|
||||||
typedef struct _XDisplay Display;
|
typedef struct _XDisplay Display;
|
||||||
typedef struct _XCBKeySymbols xcb_key_symbols_t;
|
typedef struct _XCBKeySymbols xcb_key_symbols_t;
|
||||||
class NETWinInfo;
|
class NETWinInfo;
|
||||||
|
class QSocketNotifier;
|
||||||
|
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
@ -34,7 +35,7 @@ class X11WindowedInputDevice : public InputDevice
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit X11WindowedInputDevice(QObject *parent = nullptr);
|
explicit X11WindowedInputDevice() = default;
|
||||||
|
|
||||||
void setPointer(bool set);
|
void setPointer(bool set);
|
||||||
void setKeyboard(bool set);
|
void setKeyboard(bool set);
|
||||||
|
@ -72,7 +73,7 @@ class X11WindowedInputBackend : public InputBackend
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit X11WindowedInputBackend(X11WindowedBackend *backend, QObject *parent = nullptr);
|
explicit X11WindowedInputBackend(X11WindowedBackend *backend);
|
||||||
|
|
||||||
void initialize() override;
|
void initialize() override;
|
||||||
|
|
||||||
|
@ -85,7 +86,7 @@ class KWIN_EXPORT X11WindowedBackend : public Platform
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
X11WindowedBackend(QObject *parent = nullptr);
|
explicit X11WindowedBackend();
|
||||||
~X11WindowedBackend() override;
|
~X11WindowedBackend() override;
|
||||||
bool initialize() override;
|
bool initialize() override;
|
||||||
|
|
||||||
|
@ -154,15 +155,16 @@ private:
|
||||||
xcb_key_symbols_t *m_keySymbols = nullptr;
|
xcb_key_symbols_t *m_keySymbols = nullptr;
|
||||||
int m_screenNumber = 0;
|
int m_screenNumber = 0;
|
||||||
|
|
||||||
X11WindowedInputDevice *m_pointerDevice = nullptr;
|
std::unique_ptr<X11WindowedInputDevice> m_pointerDevice;
|
||||||
X11WindowedInputDevice *m_keyboardDevice = nullptr;
|
std::unique_ptr<X11WindowedInputDevice> m_keyboardDevice;
|
||||||
X11WindowedInputDevice *m_touchDevice = nullptr;
|
std::unique_ptr<X11WindowedInputDevice> m_touchDevice;
|
||||||
|
|
||||||
xcb_atom_t m_protocols = XCB_ATOM_NONE;
|
xcb_atom_t m_protocols = XCB_ATOM_NONE;
|
||||||
xcb_atom_t m_deleteWindowProtocol = XCB_ATOM_NONE;
|
xcb_atom_t m_deleteWindowProtocol = XCB_ATOM_NONE;
|
||||||
xcb_cursor_t m_cursor = XCB_CURSOR_NONE;
|
xcb_cursor_t m_cursor = XCB_CURSOR_NONE;
|
||||||
Display *m_display = nullptr;
|
Display *m_display = nullptr;
|
||||||
bool m_keyboardGrabbed = false;
|
bool m_keyboardGrabbed = false;
|
||||||
|
std::unique_ptr<QSocketNotifier> m_eventNotifier;
|
||||||
|
|
||||||
bool m_hasXInput = false;
|
bool m_hasXInput = false;
|
||||||
int m_xiOpcode = 0;
|
int m_xiOpcode = 0;
|
||||||
|
|
|
@ -34,7 +34,7 @@ X11WindowedEglOutput::~X11WindowedEglOutput()
|
||||||
void X11WindowedEglOutput::ensureFbo()
|
void X11WindowedEglOutput::ensureFbo()
|
||||||
{
|
{
|
||||||
if (!m_fbo || m_fbo->size() != m_output->pixelSize()) {
|
if (!m_fbo || m_fbo->size() != m_output->pixelSize()) {
|
||||||
m_fbo.reset(new GLFramebuffer(0, m_output->pixelSize()));
|
m_fbo = std::make_unique<GLFramebuffer>(0, m_output->pixelSize());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -260,10 +260,10 @@ void Platform::updateXTime()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OutlineVisual *Platform::createOutline(Outline *outline)
|
std::unique_ptr<OutlineVisual> Platform::createOutline(Outline *outline)
|
||||||
{
|
{
|
||||||
if (Compositor::compositing()) {
|
if (Compositor::compositing()) {
|
||||||
return new CompositedOutlineVisual(outline);
|
return std::make_unique<CompositedOutlineVisual>(outline);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,7 +257,7 @@ public:
|
||||||
* Creates the OutlineVisual for the given @p outline.
|
* Creates the OutlineVisual for the given @p outline.
|
||||||
* Default implementation creates an OutlineVisual suited for composited usage.
|
* Default implementation creates an OutlineVisual suited for composited usage.
|
||||||
*/
|
*/
|
||||||
virtual OutlineVisual *createOutline(Outline *outline);
|
virtual std::unique_ptr<OutlineVisual> createOutline(Outline *outline);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Platform specific way to invert the screen.
|
* Platform specific way to invert the screen.
|
||||||
|
|
|
@ -105,7 +105,7 @@ void Outline::createHelper()
|
||||||
if (m_visual) {
|
if (m_visual) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_visual.reset(kwinApp()->platform()->createOutline(this));
|
m_visual = kwinApp()->platform()->createOutline(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Outline::compositingChanged()
|
void Outline::compositingChanged()
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include <kwin_export.h>
|
#include <kwin_export.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class QQmlContext;
|
class QQmlContext;
|
||||||
class QQmlComponent;
|
class QQmlComponent;
|
||||||
|
|
Loading…
Reference in a new issue