Changeset View
Changeset View
Standalone View
Standalone View
cursor.h
Show All 27 Lines | |||||
28 | // xcb | 28 | // xcb | ||
29 | #include <xcb/xcb.h> | 29 | #include <xcb/xcb.h> | ||
30 | 30 | | |||
31 | class QTimer; | 31 | class QTimer; | ||
32 | 32 | | |||
33 | namespace KWin | 33 | namespace KWin | ||
34 | { | 34 | { | ||
35 | 35 | | |||
36 | namespace ExtendedCursor { | ||||
37 | enum Shape { | ||||
38 | SizeNorthWest = 0x100 + 0, | ||||
39 | SizeNorth = 0x100 + 1, | ||||
40 | SizeNorthEast = 0x100 + 2, | ||||
41 | SizeEast = 0x100 + 3, | ||||
42 | SizeWest = 0x100 + 4, | ||||
43 | SizeSouthEast = 0x100 + 5, | ||||
44 | SizeSouth = 0x100 + 6, | ||||
45 | SizeSouthWest = 0x100 + 7 | ||||
46 | }; | ||||
47 | } | ||||
48 | /** | ||||
49 | * Extension of Qt::CursorShape with values not currently present there | ||||
50 | */ | ||||
51 | | ||||
52 | | ||||
53 | /** | ||||
54 | * @brief Wrapper round Qt::CursorShape with extensions enums into a single entity | ||||
55 | */ | ||||
56 | class KWIN_EXPORT CursorShape { | ||||
57 | public: | ||||
58 | CursorShape(Qt::CursorShape qtShape) { | ||||
59 | m_shape = qtShape; | ||||
60 | } | ||||
61 | CursorShape(KWin::ExtendedCursor::Shape kwinShape) { | ||||
62 | m_shape = kwinShape; | ||||
63 | } | ||||
64 | bool operator==(const CursorShape &o) const { | ||||
65 | return m_shape == o.m_shape; | ||||
66 | } | ||||
67 | operator int() const { | ||||
68 | return m_shape; | ||||
69 | } | ||||
70 | /** | ||||
71 | * @brief The name of a cursor shape in the theme. | ||||
72 | */ | ||||
73 | QByteArray name() const; | ||||
74 | private: | ||||
75 | int m_shape = Qt::ArrowCursor; | ||||
76 | }; | ||||
77 | | ||||
36 | /** | 78 | /** | ||
37 | * @short Replacement for QCursor. | 79 | * @short Replacement for QCursor. | ||
38 | * | 80 | * | ||
39 | * This class provides a similar API to QCursor and should be preferred inside KWin. It allows to | 81 | * This class provides a similar API to QCursor and should be preferred inside KWin. It allows to | ||
40 | * get the position and warp the mouse cursor with static methods just like QCursor. It also provides | 82 | * get the position and warp the mouse cursor with static methods just like QCursor. It also provides | ||
41 | * the possibility to get an X11 cursor for a Qt::CursorShape - a functionality lost in Qt 5's QCursor | 83 | * the possibility to get an X11 cursor for a Qt::CursorShape - a functionality lost in Qt 5's QCursor | ||
42 | * implementation. | 84 | * implementation. | ||
43 | * | 85 | * | ||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | 99 | public: | |||
89 | const QString &themeName() const; | 131 | const QString &themeName() const; | ||
90 | /** | 132 | /** | ||
91 | * @brief The size of the currently used Cursor theme. | 133 | * @brief The size of the currently used Cursor theme. | ||
92 | * | 134 | * | ||
93 | * @return int | 135 | * @return int | ||
94 | */ | 136 | */ | ||
95 | int themeSize() const; | 137 | int themeSize() const; | ||
96 | /** | 138 | /** | ||
97 | * @brief The name of a cursor shape in the theme. | | |||
98 | * | | |||
99 | * @param shape The cursor for which the name needs to be known. | | |||
100 | * @return QByteArray | | |||
101 | */ | | |||
102 | QByteArray cursorName(Qt::CursorShape shape) const; | | |||
103 | /** | | |||
104 | * @return list of alternative names for the cursor with @p name | 139 | * @return list of alternative names for the cursor with @p name | ||
105 | **/ | 140 | **/ | ||
106 | QVector<QByteArray> cursorAlternativeNames(const QByteArray &name) const; | 141 | QVector<QByteArray> cursorAlternativeNames(const QByteArray &name) const; | ||
107 | 142 | | |||
108 | /** | 143 | /** | ||
109 | * Returns the current cursor position. This method does an update of the mouse position if | 144 | * Returns the current cursor position. This method does an update of the mouse position if | ||
110 | * needed. It's save to call it multiple times. | 145 | * needed. It's save to call it multiple times. | ||
111 | * | 146 | * | ||
112 | * Implementing subclasses should prefer to use @link currentPos which is not performing a check | 147 | * Implementing subclasses should prefer to use @link currentPos which is not performing a check | ||
113 | * for update. | 148 | * for update. | ||
114 | **/ | 149 | **/ | ||
115 | static QPoint pos(); | 150 | static QPoint pos(); | ||
116 | /** | 151 | /** | ||
117 | * Warps the mouse cursor to new @p pos. | 152 | * Warps the mouse cursor to new @p pos. | ||
118 | **/ | 153 | **/ | ||
119 | static void setPos(const QPoint &pos); | 154 | static void setPos(const QPoint &pos); | ||
120 | static void setPos(int x, int y); | 155 | static void setPos(int x, int y); | ||
121 | static xcb_cursor_t x11Cursor(Qt::CursorShape shape); | 156 | static xcb_cursor_t x11Cursor(CursorShape shape); | ||
122 | /** | 157 | /** | ||
123 | * Notice: if available always use the Qt::CursorShape variant to avoid cache duplicates for | 158 | * Notice: if available always use the CursorShape variant to avoid cache duplicates for | ||
124 | * ambiguous cursor names in the non existing cursor name spcification | 159 | * ambiguous cursor names in the non existing cursor name spcification | ||
125 | **/ | 160 | **/ | ||
126 | static xcb_cursor_t x11Cursor(const QByteArray &name); | 161 | static xcb_cursor_t x11Cursor(const QByteArray &name); | ||
127 | 162 | | |||
128 | Q_SIGNALS: | 163 | Q_SIGNALS: | ||
129 | void posChanged(QPoint pos); | 164 | void posChanged(QPoint pos); | ||
130 | void mouseChanged(const QPoint& pos, const QPoint& oldpos, | 165 | void mouseChanged(const QPoint& pos, const QPoint& oldpos, | ||
131 | Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, | 166 | Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, | ||
Show All 10 Lines | |||||
142 | void themeChanged(); | 177 | void themeChanged(); | ||
143 | 178 | | |||
144 | protected: | 179 | protected: | ||
145 | /** | 180 | /** | ||
146 | * Called from @link x11Cursor to actually retrieve the X11 cursor. Base implementation returns | 181 | * Called from @link x11Cursor to actually retrieve the X11 cursor. Base implementation returns | ||
147 | * a null cursor, an implementing subclass should implement this method if it can provide X11 | 182 | * a null cursor, an implementing subclass should implement this method if it can provide X11 | ||
148 | * mouse cursors. | 183 | * mouse cursors. | ||
149 | **/ | 184 | **/ | ||
150 | virtual xcb_cursor_t getX11Cursor(Qt::CursorShape shape); | 185 | virtual xcb_cursor_t getX11Cursor(CursorShape shape); | ||
151 | /** | 186 | /** | ||
152 | * Called from @link x11Cursor to actually retrieve the X11 cursor. Base implementation returns | 187 | * Called from @link x11Cursor to actually retrieve the X11 cursor. Base implementation returns | ||
153 | * a null cursor, an implementing subclass should implement this method if it can provide X11 | 188 | * a null cursor, an implementing subclass should implement this method if it can provide X11 | ||
154 | * mouse cursors. | 189 | * mouse cursors. | ||
155 | **/ | 190 | **/ | ||
156 | virtual xcb_cursor_t getX11Cursor(const QByteArray &name); | 191 | virtual xcb_cursor_t getX11Cursor(const QByteArray &name); | ||
157 | /** | 192 | /** | ||
158 | * Performs the actual warping of the cursor. | 193 | * Performs the actual warping of the cursor. | ||
▲ Show 20 Lines • Show All 110 Lines • Show Last 20 Lines |