Changeset View
Changeset View
Standalone View
Standalone View
shell/screenpool.cpp
Show All 16 Lines | |||||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include "screenpool.h" | 20 | #include "screenpool.h" | ||
21 | #include <config-plasma.h> | 21 | #include <config-plasma.h> | ||
22 | 22 | | |||
23 | #include <QGuiApplication> | 23 | #include <QGuiApplication> | ||
24 | #include <QScreen> | 24 | #include <QScreen> | ||
25 | #include <KWindowSystem> | ||||
25 | 26 | | |||
26 | #if HAVE_X11 | 27 | #if HAVE_X11 | ||
27 | #include <QtX11Extras/QX11Info> | 28 | #include <QtX11Extras/QX11Info> | ||
28 | #include <xcb/xcb.h> | 29 | #include <xcb/xcb.h> | ||
29 | #include <xcb/randr.h> | 30 | #include <xcb/randr.h> | ||
30 | #include <xcb/xcb_event.h> | 31 | #include <xcb/xcb_event.h> | ||
31 | #endif | 32 | #endif | ||
32 | 33 | | |||
33 | ScreenPool::ScreenPool(KSharedConfig::Ptr config, QObject *parent) | 34 | ScreenPool::ScreenPool(KSharedConfig::Ptr config, QObject *parent) | ||
34 | : QObject(parent), | 35 | : QObject(parent), | ||
35 | m_configGroup(KConfigGroup(config, QStringLiteral("ScreenConnectors"))) | 36 | m_configGroup(KConfigGroup(config, QStringLiteral("ScreenConnectors"))) | ||
36 | { | 37 | { | ||
37 | qApp->installNativeEventFilter(this); | | |||
38 | 38 | | |||
39 | m_configSaveTimer.setSingleShot(true); | 39 | m_configSaveTimer.setSingleShot(true); | ||
40 | connect(&m_configSaveTimer, &QTimer::timeout, this, [this](){ | 40 | connect(&m_configSaveTimer, &QTimer::timeout, this, [this](){ | ||
41 | m_configGroup.sync(); | 41 | m_configGroup.sync(); | ||
42 | }); | 42 | }); | ||
43 | | ||||
44 | #ifdef HAVE_X11 | ||||
broulik: Needs x11 guard | |||||
jtamate: Shouldn't it be a #if HAVE_X11? | |||||
45 | if (KWindowSystem::isPlatformX11()) { | ||||
46 | qApp->installNativeEventFilter(this); | ||||
47 | const xcb_query_extension_reply_t* reply = xcb_get_extension_data(QX11Info::connection(), &xcb_randr_id); | ||||
48 | m_xrandrExtensionOffset = reply->first_event; | ||||
49 | } | ||||
50 | #endif | ||||
43 | } | 51 | } | ||
44 | 52 | | |||
45 | void ScreenPool::load() | 53 | void ScreenPool::load() | ||
46 | { | 54 | { | ||
47 | m_primaryConnector = QString(); | 55 | m_primaryConnector = QString(); | ||
48 | m_connectorForId.clear(); | 56 | m_connectorForId.clear(); | ||
49 | m_idForConnector.clear(); | 57 | m_idForConnector.clear(); | ||
50 | 58 | | |||
▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Line(s) | 183 | #if HAVE_X11 | |||
180 | if (eventType != "xcb_generic_event_t") { | 188 | if (eventType != "xcb_generic_event_t") { | ||
181 | return false; | 189 | return false; | ||
182 | } | 190 | } | ||
183 | 191 | | |||
184 | xcb_generic_event_t *ev = static_cast<xcb_generic_event_t *>(message); | 192 | xcb_generic_event_t *ev = static_cast<xcb_generic_event_t *>(message); | ||
185 | 193 | | |||
186 | const auto responseType = XCB_EVENT_RESPONSE_TYPE(ev); | 194 | const auto responseType = XCB_EVENT_RESPONSE_TYPE(ev); | ||
187 | 195 | | |||
188 | const xcb_query_extension_reply_t* reply = xcb_get_extension_data(QX11Info::connection(), &xcb_randr_id); | | |||
189 | 196 | | |||
190 | if (responseType == reply->first_event + XCB_RANDR_SCREEN_CHANGE_NOTIFY) { | 197 | if (responseType == m_xrandrExtensionOffset + XCB_RANDR_SCREEN_CHANGE_NOTIFY) { | ||
191 | if (qGuiApp->primaryScreen()->name() != primaryConnector()) { | 198 | if (qGuiApp->primaryScreen()->name() != primaryConnector()) { | ||
192 | //new screen? | 199 | //new screen? | ||
193 | if (id(qGuiApp->primaryScreen()->name()) < 0) { | 200 | if (id(qGuiApp->primaryScreen()->name()) < 0) { | ||
194 | insertScreenMapping(firstAvailableId(), qGuiApp->primaryScreen()->name()); | 201 | insertScreenMapping(firstAvailableId(), qGuiApp->primaryScreen()->name()); | ||
195 | } | 202 | } | ||
196 | //switch the primary screen in the pool | 203 | //switch the primary screen in the pool | ||
197 | setPrimaryConnector(qGuiApp->primaryScreen()->name()); | 204 | setPrimaryConnector(qGuiApp->primaryScreen()->name()); | ||
198 | } | 205 | } | ||
199 | } | 206 | } | ||
200 | #endif | 207 | #endif | ||
201 | return false; | 208 | return false; | ||
202 | } | 209 | } | ||
203 | 210 | | |||
204 | 211 | | |||
205 | #include "moc_screenpool.cpp" | 212 | #include "moc_screenpool.cpp" | ||
206 | 213 | |
Needs x11 guard