KWin
|
Replacement for QCursor. More...
#include <cursor.h>
Signals | |
void | posChanged (const QPointF &pos) |
void | mouseChanged (const QPointF &pos, const QPointF &oldpos, Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers) |
void | cursorChanged () |
Signal emitted when the cursor image changes. | |
void | themeChanged () |
void | rendered (std::chrono::milliseconds timestamp) |
Public Member Functions | |
Cursor () | |
~Cursor () override | |
void | startMousePolling () |
void | stopMousePolling () |
void | startCursorTracking () |
Enables tracking changes of cursor images. | |
void | stopCursorTracking () |
Disables tracking changes of cursor images. | |
const QString & | themeName () const |
The name of the currently used Cursor theme. | |
int | themeSize () const |
The size of the currently used Cursor theme. | |
QPointF | pos () |
void | setPos (const QPointF &pos) |
xcb_cursor_t | x11Cursor (CursorShape shape) |
xcb_cursor_t | x11Cursor (const QByteArray &name) |
QPointF | hotspot () const |
QRectF | geometry () const |
QRectF | rect () const |
CursorSource * | source () const |
void | setSource (CursorSource *source) |
bool | isOnOutput (Output *output) const |
void | markAsRendered (std::chrono::milliseconds timestamp) |
Static Public Member Functions | |
static QString | defaultThemeName () |
static int | defaultThemeSize () |
Protected Member Functions | |
virtual void | doSetPos () |
virtual void | doGetPos () |
virtual void | doStartMousePolling () |
virtual void | doStopMousePolling () |
virtual void | doStartCursorTracking () |
virtual void | doStopCursorTracking () |
bool | isCursorTracking () const |
const QPointF & | currentPos () const |
void | updatePos (const QPointF &pos) |
Replacement for QCursor.
This class provides a similar API to QCursor and should be preferred inside KWin. It allows to get the position and warp the mouse cursor with static methods just like QCursor. It also provides the possibility to get an X11 cursor for a Qt::CursorShape - a functionality lost in Qt 5's QCursor implementation.
In addition the class provides a mouse polling facility as required by e.g. Effects and ScreenEdges and emits signals when the mouse position changes. In opposite to QCursor this class is a QObject and cannot be constructed. Instead it provides a singleton getter, though the most important methods are wrapped in a static method, just like QCursor.
The actual implementation is split into two parts: a system independent interface and a windowing system specific subclass. So far only an X11 backend is implemented which uses query pointer to fetch the position and warp pointer to set the position. It uses a timer based mouse polling and can provide X11 cursors through the XCursor library.
KWin::Cursor::Cursor | ( | ) |
Definition at line 112 of file cursor.cpp.
|
override |
Definition at line 129 of file cursor.cpp.
|
inlineprotected |
|
signal |
Signal emitted when the cursor image changes.
To enable these signals use startCursorTracking.
|
static |
Returns the default Xcursor theme name.
Definition at line 333 of file cursor.cpp.
|
static |
Returns the default Xcursor theme size.
Definition at line 338 of file cursor.cpp.
|
protectedvirtual |
Called from pos() to allow syncing the internal position with the underlying system's cursor position.
Reimplemented in KWin::X11Cursor.
Definition at line 270 of file cursor.cpp.
|
protectedvirtual |
Performs the actual warping of the cursor.
Reimplemented in KWin::X11Cursor, and KWin::InputRedirectionCursor.
Definition at line 265 of file cursor.cpp.
|
protectedvirtual |
Called from startCursorTracking when cursor image tracking gets activated. Inheriting class needs to overwrite to enable platform specific code for the tracking.
Reimplemented in KWin::X11Cursor.
Definition at line 325 of file cursor.cpp.
|
protectedvirtual |
Called from startMousePolling when the mouse polling gets activated. Base implementation does nothing, inheriting classes can overwrite to e.g. start a timer.
Reimplemented in KWin::X11Cursor.
Definition at line 300 of file cursor.cpp.
|
protectedvirtual |
Called from stopCursorTracking when cursor image tracking gets deactivated. Inheriting class needs to overwrite to disable platform specific code for the tracking.
Reimplemented in KWin::X11Cursor.
Definition at line 329 of file cursor.cpp.
|
protectedvirtual |
Called from stopMousePolling when the mouse polling gets deactivated. Base implementation does nothing, inheriting classes can overwrite to e.g. stop a timer.
Reimplemented in KWin::X11Cursor.
Definition at line 304 of file cursor.cpp.
QRectF KWin::Cursor::geometry | ( | ) | const |
Definition at line 190 of file cursor.cpp.
QPointF KWin::Cursor::hotspot | ( | ) | const |
Definition at line 182 of file cursor.cpp.
|
inlineprotected |
bool KWin::Cursor::isOnOutput | ( | Output * | output | ) | const |
Returns true
if the cursor is visible on the given output; otherwise returns false
.
Definition at line 174 of file cursor.cpp.
void KWin::Cursor::markAsRendered | ( | std::chrono::milliseconds | timestamp | ) |
Definition at line 220 of file cursor.cpp.
|
signal |
QPointF KWin::Cursor::pos | ( | ) |
Returns the current cursor position. This method does an update of the mouse position if needed. It's save to call it multiple times.
Implementing subclasses should prefer to use currentPos which is not performing a check for update.
Definition at line 204 of file cursor.cpp.
|
signal |
QRectF KWin::Cursor::rect | ( | ) | const |
Definition at line 195 of file cursor.cpp.
|
signal |
void KWin::Cursor::setPos | ( | const QPointF & | pos | ) |
Warps the mouse cursor to new pos
.
Definition at line 210 of file cursor.cpp.
void KWin::Cursor::setSource | ( | CursorSource * | source | ) |
Definition at line 703 of file cursor.cpp.
CursorSource * KWin::Cursor::source | ( | ) | const |
Definition at line 698 of file cursor.cpp.
void KWin::Cursor::startCursorTracking | ( | ) |
Enables tracking changes of cursor images.
After enabling cursor change tracking the signal cursorChanged will be emitted whenever a change to the cursor image is recognized.
Use stopCursorTracking to no longer emit this signal. Note: the signal will be emitted until each call of this method has been matched with a call to stopCursorTracking.
This tracking is not about pointer position tracking.
Definition at line 308 of file cursor.cpp.
void KWin::Cursor::startMousePolling | ( | ) |
Definition at line 283 of file cursor.cpp.
void KWin::Cursor::stopCursorTracking | ( | ) |
Disables tracking changes of cursor images.
Only call after using startCursorTracking.
Definition at line 316 of file cursor.cpp.
void KWin::Cursor::stopMousePolling | ( | ) |
Definition at line 291 of file cursor.cpp.
|
signal |
|
inline |
|
inline |
|
protected |
Updates the internal position to pos
without warping the pointer as setPos does.
Definition at line 274 of file cursor.cpp.
xcb_cursor_t KWin::Cursor::x11Cursor | ( | const QByteArray & | name | ) |
Notice: if available always use the CursorShape variant to avoid cache duplicates for ambiguous cursor names in the non existing cursor name specification
Definition at line 230 of file cursor.cpp.
xcb_cursor_t KWin::Cursor::x11Cursor | ( | CursorShape | shape | ) |
Definition at line 225 of file cursor.cpp.