Changeset View
Changeset View
Standalone View
Standalone View
wayland_cursor_theme.cpp
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | |||||
47 | void WaylandCursorTheme::loadTheme() | 47 | void WaylandCursorTheme::loadTheme() | ||
48 | { | 48 | { | ||
49 | if (!m_shm->isValid()) { | 49 | if (!m_shm->isValid()) { | ||
50 | return; | 50 | return; | ||
51 | } | 51 | } | ||
52 | Cursor *c = Cursor::self(); | 52 | Cursor *c = Cursor::self(); | ||
53 | int size = c->themeSize(); | 53 | int size = c->themeSize(); | ||
54 | if (size == 0) { | 54 | if (size == 0) { | ||
55 | // resolution depended | 55 | //set a default size | ||
56 | // as we don't support per screen cursor sizes yet, we use the first screen | | |||
57 | KWayland::Server::Display *display = waylandServer()->display(); | | |||
58 | auto output = display->outputs().first(); | | |||
59 | // calculate dots per inch, multiplied with magic constants | | |||
60 | if (output->physicalSize().height()) { | | |||
61 | size = qreal(output->pixelSize().height()) / (qreal(output->physicalSize().height()) * 0.0393701) * 16.0 / 72.0; | | |||
62 | } else { | | |||
63 | // use sensible default | | |||
64 | size = 24; | 56 | size = 24; | ||
65 | } | 57 | } | ||
66 | connect(output, &KWayland::Server::OutputInterface::pixelSizeChanged, this, &WaylandCursorTheme::loadTheme, Qt::UniqueConnection); | | |||
67 | connect(output, &KWayland::Server::OutputInterface::physicalSizeChanged, this, &WaylandCursorTheme::loadTheme, Qt::UniqueConnection); | | |||
68 | } | | |||
69 | 58 | | |||
70 | auto theme = wl_cursor_theme_load(c->themeName().toUtf8().constData(), | 59 | auto theme = wl_cursor_theme_load(c->themeName().toUtf8().constData(), | ||
71 | size, m_shm->shm()); | 60 | size, m_shm->shm()); | ||
72 | if (theme) { | 61 | if (theme) { | ||
73 | if (!m_theme) { | 62 | if (!m_theme) { | ||
74 | // so far the theme had not been created, this means we need to start tracking theme changes | 63 | // so far the theme had not been created, this means we need to start tracking theme changes | ||
75 | connect(c, &Cursor::themeChanged, this, &WaylandCursorTheme::loadTheme); | 64 | connect(c, &Cursor::themeChanged, this, &WaylandCursorTheme::loadTheme); | ||
76 | } else { | 65 | } else { | ||
▲ Show 20 Lines • Show All 48 Lines • Show Last 20 Lines |