Commit 6f99b577 authored by Martin Flöser's avatar Martin Flöser

Move XFixes cursor change tracking into the x11 standalone platform

Summary:
A dedicated X11EventFilter is added and created from the X11Cursor in
case we have XFixes. This means some more X11 specific code is now only
on X11.

Test Plan: Only compile tested.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7843
parent cea7a189
......@@ -227,16 +227,6 @@ void Cursor::doStopCursorTracking()
{
}
void Cursor::notifyCursorChanged(uint32_t serial)
{
Q_UNUSED(serial)
if (m_cursorTrackingCounter <= 0) {
// cursor change tracking is currently disabled, so don't emit signal
return;
}
emit cursorChanged();
}
QVector<QByteArray> Cursor::cursorAlternativeNames(const QByteArray &name) const
{
static const QHash<QByteArray, QVector<QByteArray>> alternatives = {
......
......@@ -80,12 +80,6 @@ public:
* @see startCursorTracking
*/
void stopCursorTracking();
/**
* @internal
*
* Called from X11 event handler.
*/
void notifyCursorChanged(uint32_t serial);
/**
* @brief The name of the currently used Cursor theme.
......
......@@ -391,8 +391,6 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e)
c->syncEvent(reinterpret_cast< xcb_sync_alarm_notify_event_t* >(e));
for (Client *c : desktops)
c->syncEvent(reinterpret_cast< xcb_sync_alarm_notify_event_t* >(e));
} else if (eventType == Xcb::Extensions::self()->fixesCursorNotifyEvent() && Xcb::Extensions::self()->isFixesAvailable()) {
Cursor::self()->notifyCursorChanged(reinterpret_cast<xcb_xfixes_cursor_notify_event_t*>(e)->cursor_serial);
}
break;
}
......
......@@ -9,6 +9,7 @@ set(X11PLATFORM_SOURCES
screenedges_filter.cpp
non_composited_outline.cpp
x11_decoration_renderer.cpp
xfixes_cursor_event_filter.cpp
)
if(X11_Xinput_FOUND)
......
......@@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "keyboard_input.h"
#include "utils.h"
#include "xcbutils.h"
#include "xfixes_cursor_event_filter.h"
#include <QAbstractEventDispatcher>
#include <QTimer>
......@@ -51,6 +52,16 @@ X11Cursor::X11Cursor(QObject *parent, bool xInputSupport)
if (m_hasXInput) {
connect(qApp->eventDispatcher(), &QAbstractEventDispatcher::aboutToBlock, this, &X11Cursor::aboutToBlock);
}
#ifndef KCMRULES
connect(kwinApp(), &Application::workspaceCreated, this,
[this] {
if (Xcb::Extensions::self()->isFixesAvailable()) {
m_xfixesFilter = std::make_unique<XFixesCursorEventFilter>(this);
}
}
);
#endif
}
X11Cursor::~X11Cursor()
......@@ -173,4 +184,13 @@ xcb_cursor_t X11Cursor::createCursor(const QByteArray &name)
return cursor;
}
void X11Cursor::notifyCursorChanged()
{
if (!isCursorTracking()) {
// cursor change tracking is currently disabled, so don't emit signal
return;
}
emit cursorChanged();
}
}
......@@ -21,8 +21,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define KWIN_X11CURSOR_H
#include "cursor.h"
#include <memory>
namespace KWin
{
class XFixesCursorEventFilter;
class KWIN_EXPORT X11Cursor : public Cursor
{
......@@ -35,6 +38,13 @@ public:
m_needsPoll = true;
}
/**
* @internal
*
* Called from X11 event handler.
*/
void notifyCursorChanged();
protected:
virtual xcb_cursor_t getX11Cursor(Qt::CursorShape shape);
xcb_cursor_t getX11Cursor(const QByteArray &name) override;
......@@ -63,6 +73,9 @@ private:
QTimer *m_mousePollingTimer;
bool m_hasXInput;
bool m_needsPoll;
std::unique_ptr<XFixesCursorEventFilter> m_xfixesFilter;
friend class Cursor;
};
......
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2017 Martin Flöser <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 "xfixes_cursor_event_filter.h"
#include "x11cursor.h"
#include "xcbutils.h"
namespace KWin
{
XFixesCursorEventFilter::XFixesCursorEventFilter(X11Cursor *cursor)
: X11EventFilter(QVector<int>{Xcb::Extensions::self()->fixesCursorNotifyEvent()})
, m_cursor(cursor)
{
}
bool XFixesCursorEventFilter::event(xcb_generic_event_t *event)
{
Q_UNUSED(event);
m_cursor->notifyCursorChanged();
return false;
}
}
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2017 Martin Flöser <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_XFIXES_CURSOR_EVENT_FILTER_H
#define KWIN_XFIXES_CURSOR_EVENT_FILTER_H
#include "x11eventfilter.h"
namespace KWin
{
class X11Cursor;
class XFixesCursorEventFilter : public X11EventFilter
{
public:
explicit XFixesCursorEventFilter(X11Cursor *cursor);
bool event(xcb_generic_event_t *event) override;
private:
X11Cursor *m_cursor;
};
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment