2016-02-12 12:30:00 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2013, 2016 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_input.h"
|
2016-04-07 07:24:17 +00:00
|
|
|
#include "platform.h"
|
2016-02-23 11:29:05 +00:00
|
|
|
#include "effects.h"
|
2016-05-24 08:57:57 +00:00
|
|
|
#include "input_event.h"
|
2016-02-12 12:30:00 +00:00
|
|
|
#include "screens.h"
|
|
|
|
#include "shell_client.h"
|
2016-02-23 11:29:05 +00:00
|
|
|
#include "wayland_cursor_theme.h"
|
2016-02-12 12:30:00 +00:00
|
|
|
#include "wayland_server.h"
|
|
|
|
#include "workspace.h"
|
|
|
|
#include "decorations/decoratedclient.h"
|
|
|
|
// KDecoration
|
|
|
|
#include <KDecoration2/Decoration>
|
|
|
|
// KWayland
|
2016-02-23 11:29:05 +00:00
|
|
|
#include <KWayland/Client/connection_thread.h>
|
|
|
|
#include <KWayland/Client/buffer.h>
|
|
|
|
#include <KWayland/Server/buffer_interface.h>
|
2016-03-01 07:42:07 +00:00
|
|
|
#include <KWayland/Server/datadevice_interface.h>
|
2016-02-23 11:29:05 +00:00
|
|
|
#include <KWayland/Server/display.h>
|
2016-02-12 12:30:00 +00:00
|
|
|
#include <KWayland/Server/seat_interface.h>
|
2016-02-23 11:29:05 +00:00
|
|
|
#include <KWayland/Server/surface_interface.h>
|
2016-02-12 12:30:00 +00:00
|
|
|
// screenlocker
|
|
|
|
#include <KScreenLocker/KsldApp>
|
|
|
|
|
|
|
|
#include <QHoverEvent>
|
|
|
|
#include <QWindow>
|
2016-02-23 11:29:05 +00:00
|
|
|
// Wayland
|
|
|
|
#include <wayland-cursor.h>
|
2016-02-12 12:30:00 +00:00
|
|
|
|
|
|
|
#include <linux/input.h>
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
static Qt::MouseButton buttonToQtMouseButton(uint32_t button)
|
|
|
|
{
|
|
|
|
switch (button) {
|
|
|
|
case BTN_LEFT:
|
|
|
|
return Qt::LeftButton;
|
|
|
|
case BTN_MIDDLE:
|
|
|
|
return Qt::MiddleButton;
|
|
|
|
case BTN_RIGHT:
|
|
|
|
return Qt::RightButton;
|
2016-02-17 10:16:57 +00:00
|
|
|
case BTN_SIDE:
|
|
|
|
// in QtWayland mapped like that
|
|
|
|
return Qt::ExtraButton1;
|
|
|
|
case BTN_EXTRA:
|
|
|
|
// in QtWayland mapped like that
|
|
|
|
return Qt::ExtraButton2;
|
2016-02-12 12:30:00 +00:00
|
|
|
case BTN_BACK:
|
2016-02-17 10:16:57 +00:00
|
|
|
return Qt::BackButton;
|
2016-02-12 12:30:00 +00:00
|
|
|
case BTN_FORWARD:
|
2016-02-17 10:16:57 +00:00
|
|
|
return Qt::ForwardButton;
|
|
|
|
case BTN_TASK:
|
|
|
|
return Qt::TaskButton;
|
|
|
|
// mapped like that in QtWayland
|
|
|
|
case 0x118:
|
|
|
|
return Qt::ExtraButton6;
|
|
|
|
case 0x119:
|
|
|
|
return Qt::ExtraButton7;
|
|
|
|
case 0x11a:
|
|
|
|
return Qt::ExtraButton8;
|
|
|
|
case 0x11b:
|
|
|
|
return Qt::ExtraButton9;
|
|
|
|
case 0x11c:
|
|
|
|
return Qt::ExtraButton10;
|
|
|
|
case 0x11d:
|
|
|
|
return Qt::ExtraButton11;
|
|
|
|
case 0x11e:
|
|
|
|
return Qt::ExtraButton12;
|
|
|
|
case 0x11f:
|
|
|
|
return Qt::ExtraButton13;
|
2016-02-12 12:30:00 +00:00
|
|
|
}
|
2016-02-17 10:16:57 +00:00
|
|
|
// all other values get mapped to ExtraButton24
|
|
|
|
// this is actually incorrect but doesn't matter in our usage
|
|
|
|
// KWin internally doesn't use these high extra buttons anyway
|
|
|
|
// it's only needed for recognizing whether buttons are pressed
|
|
|
|
// if multiple buttons are mapped to the value the evaluation whether
|
|
|
|
// buttons are pressed is correct and that's all we care about.
|
|
|
|
return Qt::ExtraButton24;
|
2016-02-12 12:30:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool screenContainsPos(const QPointF &pos)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < screens()->count(); ++i) {
|
|
|
|
if (screens()->geometry(i).contains(pos.toPoint())) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
PointerInputRedirection::PointerInputRedirection(InputRedirection* parent)
|
2016-05-12 14:33:03 +00:00
|
|
|
: InputDeviceHandler(parent)
|
2016-02-23 11:29:05 +00:00
|
|
|
, m_cursor(nullptr)
|
2016-02-12 12:30:00 +00:00
|
|
|
, m_supportsWarping(Application::usesLibinput())
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
PointerInputRedirection::~PointerInputRedirection() = default;
|
|
|
|
|
|
|
|
void PointerInputRedirection::init()
|
|
|
|
{
|
|
|
|
Q_ASSERT(!m_inited);
|
2016-02-23 11:29:05 +00:00
|
|
|
m_cursor = new CursorImage(this);
|
2016-02-12 12:30:00 +00:00
|
|
|
m_inited = true;
|
2016-04-07 07:18:10 +00:00
|
|
|
connect(m_cursor, &CursorImage::changed, kwinApp()->platform(), &Platform::cursorChanged);
|
2016-02-23 11:29:05 +00:00
|
|
|
emit m_cursor->changed();
|
2016-02-12 12:30:00 +00:00
|
|
|
connect(workspace(), &Workspace::stackingOrderChanged, this, &PointerInputRedirection::update);
|
|
|
|
connect(screens(), &Screens::changed, this, &PointerInputRedirection::updateAfterScreenChange);
|
2016-04-25 06:51:33 +00:00
|
|
|
if (waylandServer()->hasScreenLockerIntegration()) {
|
|
|
|
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this, &PointerInputRedirection::update);
|
|
|
|
}
|
2016-02-12 12:30:00 +00:00
|
|
|
connect(workspace(), &QObject::destroyed, this, [this] { m_inited = false; });
|
|
|
|
connect(waylandServer(), &QObject::destroyed, this, [this] { m_inited = false; });
|
2016-03-01 07:42:07 +00:00
|
|
|
connect(waylandServer()->seat(), &KWayland::Server::SeatInterface::dragEnded, this,
|
|
|
|
[this] {
|
|
|
|
// need to force a focused pointer change
|
|
|
|
waylandServer()->seat()->setFocusedPointerSurface(nullptr);
|
|
|
|
m_window.clear();
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
);
|
2016-05-23 15:07:08 +00:00
|
|
|
connect(this, &PointerInputRedirection::internalWindowChanged, this,
|
|
|
|
[this] {
|
|
|
|
disconnect(m_internalWindowConnection);
|
|
|
|
m_internalWindowConnection = QMetaObject::Connection();
|
|
|
|
if (m_internalWindow) {
|
|
|
|
m_internalWindowConnection = connect(m_internalWindow.data(), &QWindow::visibleChanged, this,
|
|
|
|
[this] (bool visible) {
|
|
|
|
if (!visible) {
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2016-02-12 12:30:00 +00:00
|
|
|
|
|
|
|
// warp the cursor to center of screen
|
|
|
|
warp(screens()->geometry().center());
|
|
|
|
updateAfterScreenChange();
|
|
|
|
}
|
|
|
|
|
2016-05-24 08:57:57 +00:00
|
|
|
void PointerInputRedirection::processMotion(const QPointF &pos, uint32_t time, LibInput::Device *device)
|
2016-02-12 12:30:00 +00:00
|
|
|
{
|
|
|
|
if (!m_inited) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
updatePosition(pos);
|
2016-05-24 08:57:57 +00:00
|
|
|
MouseEvent event(QEvent::MouseMove, m_pos, Qt::NoButton, m_qtButtons,
|
|
|
|
m_input->keyboardModifiers(), time, device);
|
2016-02-12 12:30:00 +00:00
|
|
|
|
|
|
|
const auto &filters = m_input->filters();
|
|
|
|
for (auto it = filters.begin(), end = filters.end(); it != end; it++) {
|
|
|
|
if ((*it)->pointerEvent(&event, 0)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-24 08:57:57 +00:00
|
|
|
void PointerInputRedirection::processButton(uint32_t button, InputRedirection::PointerButtonState state, uint32_t time, LibInput::Device *device)
|
2016-02-12 12:30:00 +00:00
|
|
|
{
|
2016-08-19 14:56:21 +00:00
|
|
|
updateButton(button, state);
|
|
|
|
|
2016-02-12 12:30:00 +00:00
|
|
|
if (!m_inited) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QEvent::Type type;
|
|
|
|
switch (state) {
|
|
|
|
case InputRedirection::PointerButtonReleased:
|
|
|
|
type = QEvent::MouseButtonRelease;
|
|
|
|
break;
|
|
|
|
case InputRedirection::PointerButtonPressed:
|
|
|
|
type = QEvent::MouseButtonPress;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Q_UNREACHABLE();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-05-24 08:57:57 +00:00
|
|
|
MouseEvent event(type, m_pos, buttonToQtMouseButton(button), m_qtButtons,
|
|
|
|
m_input->keyboardModifiers(), time, device);
|
2016-02-12 12:30:00 +00:00
|
|
|
|
|
|
|
const auto &filters = m_input->filters();
|
|
|
|
for (auto it = filters.begin(), end = filters.end(); it != end; it++) {
|
|
|
|
if ((*it)->pointerEvent(&event, button)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-24 08:57:57 +00:00
|
|
|
void PointerInputRedirection::processAxis(InputRedirection::PointerAxis axis, qreal delta, uint32_t time, LibInput::Device *device)
|
2016-02-12 12:30:00 +00:00
|
|
|
{
|
|
|
|
if (delta == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
emit m_input->pointerAxisChanged(axis, delta);
|
|
|
|
|
2016-08-19 14:56:21 +00:00
|
|
|
if (!m_inited) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-05-24 08:57:57 +00:00
|
|
|
WheelEvent wheelEvent(m_pos, delta,
|
2016-02-12 12:30:00 +00:00
|
|
|
(axis == InputRedirection::PointerAxisHorizontal) ? Qt::Horizontal : Qt::Vertical,
|
2016-05-24 08:57:57 +00:00
|
|
|
m_qtButtons, m_input->keyboardModifiers(), time, device);
|
2016-02-12 12:30:00 +00:00
|
|
|
|
|
|
|
const auto &filters = m_input->filters();
|
|
|
|
for (auto it = filters.begin(), end = filters.end(); it != end; it++) {
|
|
|
|
if ((*it)->wheelEvent(&wheelEvent)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-05 12:35:33 +00:00
|
|
|
void PointerInputRedirection::processSwipeGestureBegin(int fingerCount, quint32 time, KWin::LibInput::Device *device)
|
|
|
|
{
|
|
|
|
Q_UNUSED(device)
|
|
|
|
if (!m_inited) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto &filters = m_input->filters();
|
|
|
|
for (auto it = filters.begin(), end = filters.end(); it != end; it++) {
|
|
|
|
if ((*it)->swipeGestureBegin(fingerCount, time)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PointerInputRedirection::processSwipeGestureUpdate(const QSizeF &delta, quint32 time, KWin::LibInput::Device *device)
|
|
|
|
{
|
|
|
|
Q_UNUSED(device)
|
|
|
|
if (!m_inited) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto &filters = m_input->filters();
|
|
|
|
for (auto it = filters.begin(), end = filters.end(); it != end; it++) {
|
|
|
|
if ((*it)->swipeGestureUpdate(delta, time)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PointerInputRedirection::processSwipeGestureEnd(quint32 time, KWin::LibInput::Device *device)
|
|
|
|
{
|
|
|
|
Q_UNUSED(device)
|
|
|
|
if (!m_inited) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto &filters = m_input->filters();
|
|
|
|
for (auto it = filters.begin(), end = filters.end(); it != end; it++) {
|
|
|
|
if ((*it)->swipeGestureEnd(time)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PointerInputRedirection::processSwipeGestureCancelled(quint32 time, KWin::LibInput::Device *device)
|
|
|
|
{
|
|
|
|
Q_UNUSED(device)
|
|
|
|
if (!m_inited) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto &filters = m_input->filters();
|
|
|
|
for (auto it = filters.begin(), end = filters.end(); it != end; it++) {
|
|
|
|
if ((*it)->swipeGestureCancelled(time)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PointerInputRedirection::processPinchGestureBegin(int fingerCount, quint32 time, KWin::LibInput::Device *device)
|
|
|
|
{
|
|
|
|
Q_UNUSED(device)
|
|
|
|
if (!m_inited) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto &filters = m_input->filters();
|
|
|
|
for (auto it = filters.begin(), end = filters.end(); it != end; it++) {
|
|
|
|
if ((*it)->pinchGestureBegin(fingerCount, time)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PointerInputRedirection::processPinchGestureUpdate(qreal scale, qreal angleDelta, const QSizeF &delta, quint32 time, KWin::LibInput::Device *device)
|
|
|
|
{
|
|
|
|
Q_UNUSED(device)
|
|
|
|
if (!m_inited) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto &filters = m_input->filters();
|
|
|
|
for (auto it = filters.begin(), end = filters.end(); it != end; it++) {
|
|
|
|
if ((*it)->pinchGestureUpdate(scale, angleDelta, delta, time)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PointerInputRedirection::processPinchGestureEnd(quint32 time, KWin::LibInput::Device *device)
|
|
|
|
{
|
|
|
|
Q_UNUSED(device)
|
|
|
|
if (!m_inited) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto &filters = m_input->filters();
|
|
|
|
for (auto it = filters.begin(), end = filters.end(); it != end; it++) {
|
|
|
|
if ((*it)->pinchGestureEnd(time)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PointerInputRedirection::processPinchGestureCancelled(quint32 time, KWin::LibInput::Device *device)
|
|
|
|
{
|
|
|
|
Q_UNUSED(device)
|
|
|
|
if (!m_inited) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto &filters = m_input->filters();
|
|
|
|
for (auto it = filters.begin(), end = filters.end(); it != end; it++) {
|
|
|
|
if ((*it)->pinchGestureCancelled(time)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-12 12:30:00 +00:00
|
|
|
void PointerInputRedirection::update()
|
|
|
|
{
|
|
|
|
if (!m_inited) {
|
|
|
|
return;
|
|
|
|
}
|
2016-03-01 07:42:07 +00:00
|
|
|
if (waylandServer()->seat()->isDragPointer()) {
|
|
|
|
// ignore during drag and drop
|
|
|
|
return;
|
|
|
|
}
|
2016-02-12 12:30:00 +00:00
|
|
|
// TODO: handle pointer grab aka popups
|
|
|
|
Toplevel *t = m_input->findToplevel(m_pos.toPoint());
|
2016-02-18 12:02:07 +00:00
|
|
|
const auto oldDeco = m_decoration;
|
2016-05-23 15:07:08 +00:00
|
|
|
updateInternalWindow(m_pos);
|
2016-02-12 12:30:00 +00:00
|
|
|
if (!m_internalWindow) {
|
2016-05-12 14:33:03 +00:00
|
|
|
updateDecoration(t, m_pos);
|
2016-02-12 12:30:00 +00:00
|
|
|
} else {
|
2016-05-09 12:48:10 +00:00
|
|
|
updateDecoration(waylandServer()->findClient(m_internalWindow), m_pos);
|
2016-02-18 12:02:07 +00:00
|
|
|
if (m_decoration) {
|
2016-05-09 12:48:10 +00:00
|
|
|
disconnect(m_internalWindowConnection);
|
|
|
|
m_internalWindowConnection = QMetaObject::Connection();
|
|
|
|
QEvent event(QEvent::Leave);
|
|
|
|
QCoreApplication::sendEvent(m_internalWindow.data(), &event);
|
|
|
|
m_internalWindow.clear();
|
2016-02-18 12:02:07 +00:00
|
|
|
}
|
2016-02-12 12:30:00 +00:00
|
|
|
}
|
|
|
|
if (m_decoration || m_internalWindow) {
|
|
|
|
t = nullptr;
|
|
|
|
}
|
2016-02-23 11:29:05 +00:00
|
|
|
if (m_decoration != oldDeco) {
|
|
|
|
emit decorationChanged();
|
|
|
|
}
|
2016-02-12 12:30:00 +00:00
|
|
|
auto oldWindow = m_window;
|
|
|
|
if (!oldWindow.isNull() && t == m_window.data()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto seat = waylandServer()->seat();
|
|
|
|
// disconnect old surface
|
|
|
|
if (oldWindow) {
|
2016-02-18 12:02:07 +00:00
|
|
|
if (AbstractClient *c = qobject_cast<AbstractClient*>(oldWindow.data())) {
|
|
|
|
c->leaveEvent();
|
|
|
|
}
|
2016-02-12 12:30:00 +00:00
|
|
|
disconnect(m_windowGeometryConnection);
|
|
|
|
m_windowGeometryConnection = QMetaObject::Connection();
|
|
|
|
}
|
2016-02-18 12:02:07 +00:00
|
|
|
if (AbstractClient *c = qobject_cast<AbstractClient*>(t)) {
|
|
|
|
// only send enter if it wasn't on deco for the same client before
|
|
|
|
if (m_decoration.isNull() || m_decoration->client() != c) {
|
|
|
|
c->enterEvent(m_pos.toPoint());
|
|
|
|
workspace()->updateFocusMousePosition(m_pos.toPoint());
|
|
|
|
}
|
|
|
|
}
|
2016-02-12 12:30:00 +00:00
|
|
|
if (t && t->surface()) {
|
2016-02-24 16:28:27 +00:00
|
|
|
m_window = QPointer<Toplevel>(t);
|
2016-08-04 08:39:23 +00:00
|
|
|
// TODO: add convenient API to update global pos together with updating focused surface
|
2016-08-22 17:20:57 +00:00
|
|
|
warpXcbOnSurfaceLeft(t->surface());
|
2016-08-04 08:39:23 +00:00
|
|
|
seat->setFocusedPointerSurface(nullptr);
|
|
|
|
seat->setPointerPos(m_pos.toPoint());
|
2016-02-12 12:30:00 +00:00
|
|
|
seat->setFocusedPointerSurface(t->surface(), t->inputTransformation());
|
|
|
|
m_windowGeometryConnection = connect(t, &Toplevel::geometryChanged, this,
|
|
|
|
[this] {
|
|
|
|
if (m_window.isNull()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// TODO: can we check on the client instead?
|
|
|
|
if (workspace()->getMovingClient()) {
|
|
|
|
// don't update while moving
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto seat = waylandServer()->seat();
|
|
|
|
if (m_window.data()->surface() != seat->focusedPointerSurface()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
seat->setFocusedPointerSurfaceTransformation(m_window.data()->inputTransformation());
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} else {
|
2016-02-24 16:28:27 +00:00
|
|
|
m_window.clear();
|
2016-08-22 17:20:57 +00:00
|
|
|
warpXcbOnSurfaceLeft(nullptr);
|
2016-02-12 12:30:00 +00:00
|
|
|
seat->setFocusedPointerSurface(nullptr);
|
|
|
|
t = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-22 17:20:57 +00:00
|
|
|
void PointerInputRedirection::warpXcbOnSurfaceLeft(KWayland::Server::SurfaceInterface *newSurface)
|
|
|
|
{
|
|
|
|
auto xc = waylandServer()->xWaylandConnection();
|
|
|
|
if (!xc) {
|
|
|
|
// No XWayland, no point in warping the x cursor
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!kwinApp()->x11Connection()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
static bool s_hasXWayland119 = xcb_get_setup(kwinApp()->x11Connection())->release_number >= 11900000;
|
|
|
|
if (s_hasXWayland119) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (newSurface && newSurface->client() == xc) {
|
|
|
|
// new window is an X window
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto s = waylandServer()->seat()->focusedPointerSurface();
|
|
|
|
if (!s || s->client() != xc) {
|
|
|
|
// pointer was not on an X window
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// warp pointer to 0/0 to trigger leave events on previously focused X window
|
|
|
|
xcb_warp_pointer(connection(), XCB_WINDOW_NONE, rootWindow(), 0, 0, 0, 0, 0, 0),
|
|
|
|
xcb_flush(connection());
|
|
|
|
}
|
|
|
|
|
2016-02-12 12:30:00 +00:00
|
|
|
void PointerInputRedirection::updatePosition(const QPointF &pos)
|
|
|
|
{
|
|
|
|
// verify that at least one screen contains the pointer position
|
|
|
|
QPointF p = pos;
|
|
|
|
if (!screenContainsPos(p)) {
|
|
|
|
// allow either x or y to pass
|
|
|
|
p = QPointF(m_pos.x(), pos.y());
|
|
|
|
if (!screenContainsPos(p)) {
|
|
|
|
p = QPointF(pos.x(), m_pos.y());
|
|
|
|
if (!screenContainsPos(p)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_pos = p;
|
|
|
|
emit m_input->globalPointerChanged(m_pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PointerInputRedirection::updateButton(uint32_t button, InputRedirection::PointerButtonState state)
|
|
|
|
{
|
|
|
|
m_buttons[button] = state;
|
|
|
|
|
|
|
|
// update Qt buttons
|
|
|
|
m_qtButtons = Qt::NoButton;
|
|
|
|
for (auto it = m_buttons.constBegin(); it != m_buttons.constEnd(); ++it) {
|
|
|
|
if (it.value() == InputRedirection::PointerButtonReleased) {
|
|
|
|
continue;
|
|
|
|
}
|
2016-02-17 10:16:57 +00:00
|
|
|
m_qtButtons |= buttonToQtMouseButton(it.key());
|
2016-02-12 12:30:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
emit m_input->pointerButtonStateChanged(button, state);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PointerInputRedirection::warp(const QPointF &pos)
|
|
|
|
{
|
|
|
|
if (supportsWarping()) {
|
2016-04-07 06:28:35 +00:00
|
|
|
kwinApp()->platform()->warpPointer(pos);
|
2016-02-12 12:30:00 +00:00
|
|
|
processMotion(pos, waylandServer()->seat()->timestamp());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PointerInputRedirection::supportsWarping() const
|
|
|
|
{
|
|
|
|
if (!m_inited) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (m_supportsWarping) {
|
|
|
|
return true;
|
|
|
|
}
|
2016-04-07 06:28:35 +00:00
|
|
|
if (kwinApp()->platform()->supportsPointerWarping()) {
|
2016-02-12 12:30:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PointerInputRedirection::updateAfterScreenChange()
|
|
|
|
{
|
|
|
|
if (!m_inited) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (screenContainsPos(m_pos)) {
|
|
|
|
// pointer still on a screen
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// pointer no longer on a screen, reposition to closes screen
|
|
|
|
const QPointF pos = screens()->geometry(screens()->number(m_pos.toPoint())).center();
|
|
|
|
// TODO: better way to get timestamps
|
|
|
|
processMotion(pos, waylandServer()->seat()->timestamp());
|
|
|
|
}
|
|
|
|
|
2016-02-23 11:29:05 +00:00
|
|
|
QImage PointerInputRedirection::cursorImage() const
|
|
|
|
{
|
|
|
|
if (!m_inited) {
|
|
|
|
return QImage();
|
|
|
|
}
|
|
|
|
return m_cursor->image();
|
|
|
|
}
|
|
|
|
|
|
|
|
QPoint PointerInputRedirection::cursorHotSpot() const
|
|
|
|
{
|
|
|
|
if (!m_inited) {
|
|
|
|
return QPoint();
|
|
|
|
}
|
|
|
|
return m_cursor->hotSpot();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PointerInputRedirection::markCursorAsRendered()
|
|
|
|
{
|
|
|
|
if (!m_inited) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_cursor->markAsRendered();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PointerInputRedirection::setEffectsOverrideCursor(Qt::CursorShape shape)
|
|
|
|
{
|
|
|
|
if (!m_inited) {
|
|
|
|
return;
|
|
|
|
}
|
2016-02-25 08:15:41 +00:00
|
|
|
// current pointer focus window should get a leave event
|
|
|
|
update();
|
2016-02-23 11:29:05 +00:00
|
|
|
m_cursor->setEffectsOverrideCursor(shape);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PointerInputRedirection::removeEffectsOverrideCursor()
|
|
|
|
{
|
|
|
|
if (!m_inited) {
|
|
|
|
return;
|
|
|
|
}
|
2016-02-25 08:15:41 +00:00
|
|
|
// cursor position might have changed while there was an effect in place
|
|
|
|
update();
|
2016-02-23 11:29:05 +00:00
|
|
|
m_cursor->removeEffectsOverrideCursor();
|
|
|
|
}
|
|
|
|
|
|
|
|
CursorImage::CursorImage(PointerInputRedirection *parent)
|
|
|
|
: QObject(parent)
|
|
|
|
, m_pointer(parent)
|
|
|
|
{
|
|
|
|
connect(waylandServer()->seat(), &KWayland::Server::SeatInterface::focusedPointerChanged, this, &CursorImage::update);
|
2016-03-01 07:42:07 +00:00
|
|
|
connect(waylandServer()->seat(), &KWayland::Server::SeatInterface::dragStarted, this, &CursorImage::updateDrag);
|
|
|
|
connect(waylandServer()->seat(), &KWayland::Server::SeatInterface::dragEnded, this,
|
|
|
|
[this] {
|
|
|
|
disconnect(m_drag.connection);
|
|
|
|
reevaluteSource();
|
|
|
|
}
|
|
|
|
);
|
2016-04-25 06:51:33 +00:00
|
|
|
if (waylandServer()->hasScreenLockerIntegration()) {
|
|
|
|
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this, &CursorImage::reevaluteSource);
|
|
|
|
}
|
2016-02-23 11:29:05 +00:00
|
|
|
connect(m_pointer, &PointerInputRedirection::decorationChanged, this, &CursorImage::updateDecoration);
|
2016-02-23 13:08:28 +00:00
|
|
|
// connect the move resize of all window
|
|
|
|
auto setupMoveResizeConnection = [this] (AbstractClient *c) {
|
|
|
|
connect(c, &AbstractClient::moveResizedChanged, this, &CursorImage::updateMoveResize);
|
|
|
|
};
|
|
|
|
const auto clients = workspace()->allClientList();
|
|
|
|
std::for_each(clients.begin(), clients.end(), setupMoveResizeConnection);
|
|
|
|
connect(workspace(), &Workspace::clientAdded, this, setupMoveResizeConnection);
|
|
|
|
connect(waylandServer(), &WaylandServer::shellClientAdded, this, setupMoveResizeConnection);
|
2016-02-23 11:29:05 +00:00
|
|
|
loadThemeCursor(Qt::ArrowCursor, &m_fallbackCursor);
|
2016-02-23 12:12:29 +00:00
|
|
|
if (m_cursorTheme) {
|
|
|
|
connect(m_cursorTheme, &WaylandCursorTheme::themeChanged, this,
|
|
|
|
[this] {
|
|
|
|
m_cursors.clear();
|
|
|
|
loadThemeCursor(Qt::ArrowCursor, &m_fallbackCursor);
|
|
|
|
updateDecorationCursor();
|
2016-02-23 13:08:28 +00:00
|
|
|
updateMoveResize();
|
2016-02-23 12:12:29 +00:00
|
|
|
// TODO: update effects
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2016-02-23 11:29:05 +00:00
|
|
|
m_surfaceRenderedTimer.start();
|
|
|
|
}
|
|
|
|
|
|
|
|
CursorImage::~CursorImage() = default;
|
|
|
|
|
|
|
|
void CursorImage::markAsRendered()
|
|
|
|
{
|
2016-03-01 07:42:07 +00:00
|
|
|
if (m_currentSource == CursorSource::DragAndDrop) {
|
|
|
|
// always sending a frame rendered to the drag icon surface to not freeze QtWayland (see https://bugreports.qt.io/browse/QTBUG-51599 )
|
|
|
|
if (auto ddi = waylandServer()->seat()->dragSource()) {
|
|
|
|
if (auto s = ddi->icon()) {
|
|
|
|
s->frameRendered(m_surfaceRenderedTimer.elapsed());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
auto p = waylandServer()->seat()->dragPointer();
|
|
|
|
if (!p) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto c = p->cursor();
|
|
|
|
if (!c) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto cursorSurface = c->surface();
|
|
|
|
if (cursorSurface.isNull()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
cursorSurface->frameRendered(m_surfaceRenderedTimer.elapsed());
|
|
|
|
return;
|
|
|
|
}
|
2016-02-23 11:29:05 +00:00
|
|
|
if (m_currentSource != CursorSource::LockScreen && m_currentSource != CursorSource::PointerSurface) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto p = waylandServer()->seat()->focusedPointer();
|
|
|
|
if (!p) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto c = p->cursor();
|
|
|
|
if (!c) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto cursorSurface = c->surface();
|
|
|
|
if (cursorSurface.isNull()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
cursorSurface->frameRendered(m_surfaceRenderedTimer.elapsed());
|
|
|
|
}
|
|
|
|
|
|
|
|
void CursorImage::update()
|
|
|
|
{
|
|
|
|
using namespace KWayland::Server;
|
|
|
|
disconnect(m_serverCursor.connection);
|
|
|
|
auto p = waylandServer()->seat()->focusedPointer();
|
|
|
|
if (p) {
|
|
|
|
m_serverCursor.connection = connect(p, &PointerInterface::cursorChanged, this, &CursorImage::updateServerCursor);
|
|
|
|
} else {
|
|
|
|
m_serverCursor.connection = QMetaObject::Connection();
|
|
|
|
}
|
|
|
|
updateServerCursor();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CursorImage::updateDecoration()
|
|
|
|
{
|
|
|
|
disconnect(m_decorationConnection);
|
|
|
|
auto deco = m_pointer->decoration();
|
|
|
|
AbstractClient *c = deco.isNull() ? nullptr : deco->client();
|
|
|
|
if (c) {
|
|
|
|
m_decorationConnection = connect(c, &AbstractClient::moveResizeCursorChanged, this, &CursorImage::updateDecorationCursor);
|
|
|
|
} else {
|
|
|
|
m_decorationConnection = QMetaObject::Connection();
|
|
|
|
}
|
|
|
|
updateDecorationCursor();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CursorImage::updateDecorationCursor()
|
|
|
|
{
|
|
|
|
m_decorationCursor.image = QImage();
|
|
|
|
m_decorationCursor.hotSpot = QPoint();
|
|
|
|
|
|
|
|
auto deco = m_pointer->decoration();
|
|
|
|
if (AbstractClient *c = deco.isNull() ? nullptr : deco->client()) {
|
|
|
|
loadThemeCursor(c->cursor(), &m_decorationCursor);
|
|
|
|
if (m_currentSource == CursorSource::Decoration) {
|
|
|
|
emit changed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
reevaluteSource();
|
|
|
|
}
|
|
|
|
|
2016-02-23 13:08:28 +00:00
|
|
|
void CursorImage::updateMoveResize()
|
|
|
|
{
|
|
|
|
m_moveResizeCursor.image = QImage();
|
|
|
|
m_moveResizeCursor.hotSpot = QPoint();
|
|
|
|
if (AbstractClient *c = workspace()->getMovingClient()) {
|
|
|
|
loadThemeCursor(c->isMove() ? Qt::SizeAllCursor : Qt::SizeBDiagCursor, &m_moveResizeCursor);
|
|
|
|
if (m_currentSource == CursorSource::MoveResize) {
|
|
|
|
emit changed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
reevaluteSource();
|
|
|
|
}
|
|
|
|
|
2016-02-23 11:29:05 +00:00
|
|
|
void CursorImage::updateServerCursor()
|
|
|
|
{
|
|
|
|
m_serverCursor.image = QImage();
|
|
|
|
m_serverCursor.hotSpot = QPoint();
|
|
|
|
reevaluteSource();
|
|
|
|
const bool needsEmit = m_currentSource == CursorSource::LockScreen || m_currentSource == CursorSource::PointerSurface;
|
|
|
|
auto p = waylandServer()->seat()->focusedPointer();
|
|
|
|
if (!p) {
|
|
|
|
if (needsEmit) {
|
|
|
|
emit changed();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto c = p->cursor();
|
|
|
|
if (!c) {
|
|
|
|
if (needsEmit) {
|
|
|
|
emit changed();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto cursorSurface = c->surface();
|
|
|
|
if (cursorSurface.isNull()) {
|
|
|
|
if (needsEmit) {
|
|
|
|
emit changed();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto buffer = cursorSurface.data()->buffer();
|
|
|
|
if (!buffer) {
|
|
|
|
if (needsEmit) {
|
|
|
|
emit changed();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_serverCursor.hotSpot = c->hotspot();
|
|
|
|
m_serverCursor.image = buffer->data().copy();
|
|
|
|
if (needsEmit) {
|
|
|
|
emit changed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CursorImage::loadTheme()
|
|
|
|
{
|
|
|
|
if (m_cursorTheme) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// check whether we can create it
|
|
|
|
if (waylandServer()->internalShmPool()) {
|
|
|
|
m_cursorTheme = new WaylandCursorTheme(waylandServer()->internalShmPool(), this);
|
|
|
|
connect(waylandServer(), &WaylandServer::terminatingInternalClientConnection, this,
|
|
|
|
[this] {
|
|
|
|
delete m_cursorTheme;
|
|
|
|
m_cursorTheme = nullptr;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CursorImage::setEffectsOverrideCursor(Qt::CursorShape shape)
|
|
|
|
{
|
|
|
|
loadThemeCursor(shape, &m_effectsCursor);
|
|
|
|
if (m_currentSource == CursorSource::EffectsOverride) {
|
|
|
|
emit changed();
|
|
|
|
}
|
|
|
|
reevaluteSource();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CursorImage::removeEffectsOverrideCursor()
|
|
|
|
{
|
|
|
|
reevaluteSource();
|
|
|
|
}
|
|
|
|
|
2016-03-01 07:42:07 +00:00
|
|
|
void CursorImage::updateDrag()
|
|
|
|
{
|
|
|
|
using namespace KWayland::Server;
|
|
|
|
disconnect(m_drag.connection);
|
|
|
|
m_drag.cursor.image = QImage();
|
|
|
|
m_drag.cursor.hotSpot = QPoint();
|
|
|
|
reevaluteSource();
|
|
|
|
if (auto p = waylandServer()->seat()->dragPointer()) {
|
|
|
|
m_drag.connection = connect(p, &PointerInterface::cursorChanged, this, &CursorImage::updateDragCursor);
|
|
|
|
} else {
|
|
|
|
m_drag.connection = QMetaObject::Connection();
|
|
|
|
}
|
|
|
|
updateDragCursor();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CursorImage::updateDragCursor()
|
|
|
|
{
|
|
|
|
m_drag.cursor.image = QImage();
|
|
|
|
m_drag.cursor.hotSpot = QPoint();
|
|
|
|
const bool needsEmit = m_currentSource == CursorSource::DragAndDrop;
|
|
|
|
QImage additionalIcon;
|
|
|
|
if (auto ddi = waylandServer()->seat()->dragSource()) {
|
|
|
|
if (auto dragIcon = ddi->icon()) {
|
|
|
|
if (auto buffer = dragIcon->buffer()) {
|
|
|
|
additionalIcon = buffer->data().copy();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
auto p = waylandServer()->seat()->dragPointer();
|
|
|
|
if (!p) {
|
|
|
|
if (needsEmit) {
|
|
|
|
emit changed();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto c = p->cursor();
|
|
|
|
if (!c) {
|
|
|
|
if (needsEmit) {
|
|
|
|
emit changed();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto cursorSurface = c->surface();
|
|
|
|
if (cursorSurface.isNull()) {
|
|
|
|
if (needsEmit) {
|
|
|
|
emit changed();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto buffer = cursorSurface.data()->buffer();
|
|
|
|
if (!buffer) {
|
|
|
|
if (needsEmit) {
|
|
|
|
emit changed();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_drag.cursor.hotSpot = c->hotspot();
|
|
|
|
m_drag.cursor.image = buffer->data().copy();
|
|
|
|
if (needsEmit) {
|
|
|
|
emit changed();
|
|
|
|
}
|
|
|
|
// TODO: add the cursor image
|
|
|
|
}
|
|
|
|
|
2016-02-23 11:29:05 +00:00
|
|
|
void CursorImage::loadThemeCursor(Qt::CursorShape shape, Image *image)
|
|
|
|
{
|
|
|
|
loadTheme();
|
|
|
|
if (!m_cursorTheme) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto it = m_cursors.constFind(shape);
|
|
|
|
if (it == m_cursors.constEnd()) {
|
|
|
|
image->image = QImage();
|
|
|
|
image->hotSpot = QPoint();
|
|
|
|
wl_cursor_image *cursor = m_cursorTheme->get(shape);
|
|
|
|
if (!cursor) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
wl_buffer *b = wl_cursor_image_get_buffer(cursor);
|
|
|
|
if (!b) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
waylandServer()->internalClientConection()->flush();
|
|
|
|
waylandServer()->dispatch();
|
|
|
|
auto buffer = KWayland::Server::BufferInterface::get(waylandServer()->internalConnection()->getResource(KWayland::Client::Buffer::getId(b)));
|
|
|
|
if (!buffer) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
it = decltype(it)(m_cursors.insert(shape, {buffer->data().copy(), QPoint(cursor->hotspot_x, cursor->hotspot_y)}));
|
|
|
|
}
|
|
|
|
image->hotSpot = it.value().hotSpot;
|
|
|
|
image->image = it.value().image;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CursorImage::reevaluteSource()
|
|
|
|
{
|
2016-03-01 07:42:07 +00:00
|
|
|
if (waylandServer()->seat()->isDragPointer()) {
|
|
|
|
// TODO: touch drag?
|
|
|
|
setSource(CursorSource::DragAndDrop);
|
|
|
|
return;
|
|
|
|
}
|
2016-02-23 11:29:05 +00:00
|
|
|
if (waylandServer()->isScreenLocked()) {
|
|
|
|
setSource(CursorSource::LockScreen);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (effects && static_cast<EffectsHandlerImpl*>(effects)->isMouseInterception()) {
|
|
|
|
setSource(CursorSource::EffectsOverride);
|
|
|
|
return;
|
|
|
|
}
|
2016-02-23 13:08:28 +00:00
|
|
|
if (workspace() && workspace()->getMovingClient()) {
|
|
|
|
setSource(CursorSource::MoveResize);
|
|
|
|
return;
|
|
|
|
}
|
2016-02-23 11:29:05 +00:00
|
|
|
if (!m_pointer->decoration().isNull()) {
|
|
|
|
setSource(CursorSource::Decoration);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!m_pointer->window().isNull()) {
|
|
|
|
setSource(CursorSource::PointerSurface);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
setSource(CursorSource::Fallback);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CursorImage::setSource(CursorSource source)
|
|
|
|
{
|
|
|
|
if (m_currentSource == source) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_currentSource = source;
|
|
|
|
emit changed();
|
|
|
|
}
|
|
|
|
|
|
|
|
QImage CursorImage::image() const
|
|
|
|
{
|
|
|
|
switch (m_currentSource) {
|
|
|
|
case CursorSource::EffectsOverride:
|
|
|
|
return m_effectsCursor.image;
|
2016-02-23 13:08:28 +00:00
|
|
|
case CursorSource::MoveResize:
|
|
|
|
return m_moveResizeCursor.image;
|
2016-02-23 11:29:05 +00:00
|
|
|
case CursorSource::LockScreen:
|
|
|
|
case CursorSource::PointerSurface:
|
|
|
|
// lockscreen also uses server cursor image
|
|
|
|
return m_serverCursor.image;
|
|
|
|
case CursorSource::Decoration:
|
|
|
|
return m_decorationCursor.image;
|
2016-03-01 07:42:07 +00:00
|
|
|
case CursorSource::DragAndDrop:
|
|
|
|
return m_drag.cursor.image;
|
2016-02-23 11:29:05 +00:00
|
|
|
case CursorSource::Fallback:
|
|
|
|
return m_fallbackCursor.image;
|
|
|
|
default:
|
|
|
|
Q_UNREACHABLE();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QPoint CursorImage::hotSpot() const
|
|
|
|
{
|
|
|
|
switch (m_currentSource) {
|
|
|
|
case CursorSource::EffectsOverride:
|
|
|
|
return m_effectsCursor.hotSpot;
|
2016-02-23 13:08:28 +00:00
|
|
|
case CursorSource::MoveResize:
|
|
|
|
return m_moveResizeCursor.hotSpot;
|
2016-02-23 11:29:05 +00:00
|
|
|
case CursorSource::LockScreen:
|
|
|
|
case CursorSource::PointerSurface:
|
|
|
|
// lockscreen also uses server cursor image
|
|
|
|
return m_serverCursor.hotSpot;
|
|
|
|
case CursorSource::Decoration:
|
|
|
|
return m_decorationCursor.hotSpot;
|
2016-03-01 07:42:07 +00:00
|
|
|
case CursorSource::DragAndDrop:
|
|
|
|
return m_drag.cursor.hotSpot;
|
2016-02-23 11:29:05 +00:00
|
|
|
case CursorSource::Fallback:
|
|
|
|
return m_fallbackCursor.hotSpot;
|
|
|
|
default:
|
|
|
|
Q_UNREACHABLE();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-12 12:30:00 +00:00
|
|
|
}
|