Changeset View
Changeset View
Standalone View
Standalone View
wayland_cursor_theme.cpp
Show All 14 Lines | |||||
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. | ||
16 | 16 | | |||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #include "wayland_cursor_theme.h" | 20 | #include "wayland_cursor_theme.h" | ||
21 | #include "cursor.h" | 21 | #include "cursor.h" | ||
22 | #include "wayland_server.h" | 22 | #include "wayland_server.h" | ||
23 | #include "screens.h" | ||||
23 | // Qt | 24 | // Qt | ||
24 | #include <QVector> | 25 | #include <QVector> | ||
25 | // KWayland | 26 | // KWayland | ||
26 | #include <KWayland/Client/shm_pool.h> | 27 | #include <KWayland/Client/shm_pool.h> | ||
27 | #include <KWayland/Server/display.h> | 28 | #include <KWayland/Server/display.h> | ||
28 | #include <KWayland/Server/output_interface.h> | 29 | #include <KWayland/Server/output_interface.h> | ||
29 | // Wayland | 30 | // Wayland | ||
30 | #include <wayland-cursor.h> | 31 | #include <wayland-cursor.h> | ||
31 | 32 | | |||
32 | namespace KWin | 33 | namespace KWin | ||
33 | { | 34 | { | ||
34 | 35 | | |||
35 | WaylandCursorTheme::WaylandCursorTheme(KWayland::Client::ShmPool *shm, QObject *parent) | 36 | WaylandCursorTheme::WaylandCursorTheme(KWayland::Client::ShmPool *shm, QObject *parent) | ||
36 | : QObject(parent) | 37 | : QObject(parent) | ||
37 | , m_theme(nullptr) | 38 | , m_theme(nullptr) | ||
38 | , m_shm(shm) | 39 | , m_shm(shm) | ||
39 | { | 40 | { | ||
41 | connect(screens(), &Screens::maxScaleChanged, this, &WaylandCursorTheme::loadTheme); | ||||
40 | } | 42 | } | ||
41 | 43 | | |||
42 | WaylandCursorTheme::~WaylandCursorTheme() | 44 | WaylandCursorTheme::~WaylandCursorTheme() | ||
43 | { | 45 | { | ||
44 | destroyTheme(); | 46 | destroyTheme(); | ||
45 | } | 47 | } | ||
46 | 48 | | |||
47 | void WaylandCursorTheme::loadTheme() | 49 | void WaylandCursorTheme::loadTheme() | ||
48 | { | 50 | { | ||
49 | if (!m_shm->isValid()) { | 51 | if (!m_shm->isValid()) { | ||
50 | return; | 52 | return; | ||
51 | } | 53 | } | ||
52 | Cursor *c = Cursor::self(); | 54 | Cursor *c = Cursor::self(); | ||
53 | int size = c->themeSize(); | 55 | int size = c->themeSize(); | ||
54 | if (size == 0) { | 56 | if (size == 0) { | ||
55 | //set a default size | 57 | //set a default size | ||
56 | size = 24; | 58 | size = 24; | ||
57 | } | 59 | } | ||
58 | 60 | | |||
61 | size *= screens()->maxScale(); | ||||
62 | | ||||
59 | auto theme = wl_cursor_theme_load(c->themeName().toUtf8().constData(), | 63 | auto theme = wl_cursor_theme_load(c->themeName().toUtf8().constData(), | ||
60 | size, m_shm->shm()); | 64 | size, m_shm->shm()); | ||
61 | if (theme) { | 65 | if (theme) { | ||
62 | if (!m_theme) { | 66 | if (!m_theme) { | ||
63 | // so far the theme had not been created, this means we need to start tracking theme changes | 67 | // so far the theme had not been created, this means we need to start tracking theme changes | ||
64 | connect(c, &Cursor::themeChanged, this, &WaylandCursorTheme::loadTheme); | 68 | connect(c, &Cursor::themeChanged, this, &WaylandCursorTheme::loadTheme); | ||
65 | } else { | 69 | } else { | ||
66 | destroyTheme(); | 70 | destroyTheme(); | ||
▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines |