File indexing completed on 2024-12-01 13:37:27

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2018 Martin Flöser <mgraesslin@kde.org>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 #include "hide_cursor_spy.h"
0010 #include "cursor.h"
0011 #include "input_event.h"
0012 #include "main.h"
0013 
0014 namespace KWin
0015 {
0016 
0017 void HideCursorSpy::pointerEvent(MouseEvent *event)
0018 {
0019     showCursor();
0020 }
0021 
0022 void HideCursorSpy::wheelEvent(KWin::WheelEvent *event)
0023 {
0024     showCursor();
0025 }
0026 
0027 void HideCursorSpy::touchDown(qint32 id, const QPointF &pos, std::chrono::microseconds time)
0028 {
0029     hideCursor();
0030 }
0031 
0032 void HideCursorSpy::tabletToolEvent(TabletEvent *event)
0033 {
0034     if (event->type() == QEvent::Type::TabletLeaveProximity) {
0035         hideCursor();
0036     } else {
0037         showCursor();
0038     }
0039 }
0040 
0041 void HideCursorSpy::showCursor()
0042 {
0043     if (!m_cursorHidden) {
0044         return;
0045     }
0046     m_cursorHidden = false;
0047     Cursors::self()->showCursor();
0048 }
0049 
0050 void HideCursorSpy::hideCursor()
0051 {
0052     if (m_cursorHidden) {
0053         return;
0054     }
0055     m_cursorHidden = true;
0056     Cursors::self()->hideCursor();
0057 }
0058 
0059 }