Changeset View
Changeset View
Standalone View
Standalone View
src/kded/tabletdaemon.cpp
Show All 32 Lines | |||||
33 | 33 | | |||
34 | // stdlib includes | 34 | // stdlib includes | ||
35 | #include <memory> | 35 | #include <memory> | ||
36 | 36 | | |||
37 | // KDE includes | 37 | // KDE includes | ||
38 | #include <KPluginFactory> | 38 | #include <KPluginFactory> | ||
39 | #include <KNotification> | 39 | #include <KNotification> | ||
40 | #include <KLocalizedString> | 40 | #include <KLocalizedString> | ||
41 | #include <KActionCollection> | 41 | #include <QGuiApplication> | ||
42 | #include <KGlobalAccel> | 42 | #include <QScreen> | ||
43 | #include <QAction> | | |||
44 | 43 | | |||
45 | using namespace Wacom; | 44 | using namespace Wacom; | ||
46 | 45 | | |||
47 | K_PLUGIN_FACTORY( WacomTabletFactory, registerPlugin<TabletDaemon>(); ) | 46 | K_PLUGIN_FACTORY( WacomTabletFactory, registerPlugin<TabletDaemon>(); ) | ||
48 | K_EXPORT_PLUGIN( WacomTabletFactory( "wacomtabletdaemon" ) ) | 47 | K_EXPORT_PLUGIN( WacomTabletFactory( "wacomtabletdaemon" ) ) | ||
49 | 48 | | |||
50 | namespace Wacom { | 49 | namespace Wacom { | ||
51 | /** | 50 | /** | ||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Line(s) | 127 | { | |||
145 | connect( d->actionCollection.get(), SIGNAL(nextProfileTriggered()), &(d->tabletHandler), SLOT(onNextProfile()) ); | 144 | connect( d->actionCollection.get(), SIGNAL(nextProfileTriggered()), &(d->tabletHandler), SLOT(onNextProfile()) ); | ||
146 | connect( d->actionCollection.get(), SIGNAL(previousProfileTriggered()), &(d->tabletHandler), SLOT(onPreviousProfile()) ); | 145 | connect( d->actionCollection.get(), SIGNAL(previousProfileTriggered()), &(d->tabletHandler), SLOT(onPreviousProfile()) ); | ||
147 | } | 146 | } | ||
148 | 147 | | |||
149 | 148 | | |||
150 | 149 | | |||
151 | void TabletDaemon::setupApplication() | 150 | void TabletDaemon::setupApplication() | ||
152 | { | 151 | { | ||
153 | Q_D( TabletDaemon ); | | |||
154 | | ||||
155 | static AboutData about( QLatin1Literal("wacomtablet"), | 152 | static AboutData about( QLatin1Literal("wacomtablet"), | ||
156 | i18n( "Graphic Tablet Configuration daemon" ), | 153 | i18n( "Graphic Tablet Configuration daemon" ), | ||
157 | QLatin1String(kded_version), i18n( "A Wacom tablet control daemon" ) ); | 154 | QLatin1String(kded_version), i18n( "A Wacom tablet control daemon" ) ); | ||
158 | } | 155 | } | ||
159 | 156 | | |||
160 | 157 | | |||
161 | 158 | | |||
162 | void TabletDaemon::setupDBus() | 159 | void TabletDaemon::setupDBus() | ||
Show All 13 Lines | |||||
176 | } | 173 | } | ||
177 | 174 | | |||
178 | 175 | | |||
179 | 176 | | |||
180 | void TabletDaemon::setupEventNotifier() | 177 | void TabletDaemon::setupEventNotifier() | ||
181 | { | 178 | { | ||
182 | Q_D( TabletDaemon ); | 179 | Q_D( TabletDaemon ); | ||
183 | 180 | | |||
184 | connect( &X11EventNotifier::instance(), SIGNAL(screenRotated(ScreenRotation)), &(d->tabletHandler), SLOT(onScreenRotated(ScreenRotation))); | 181 | // Set up monitoring for individual screen geometry changes | ||
185 | connect( &X11EventNotifier::instance(), SIGNAL(tabletAdded(int)), &TabletFinder::instance(), SLOT(onX11TabletAdded(int))); | 182 | monitorAllScreensGeometry(); | ||
186 | connect( &X11EventNotifier::instance(), SIGNAL(tabletRemoved(int)), &TabletFinder::instance(), SLOT(onX11TabletRemoved(int))); | 183 | | ||
184 | // Set up monitoring for screens being added, removed or reordered | ||||
185 | connect(qApp, &QGuiApplication::primaryScreenChanged, &(d->tabletHandler), &TabletHandler::onScreenAddedRemoved); | ||||
186 | connect(qApp, &QGuiApplication::screenAdded, &(d->tabletHandler), &TabletHandler::onScreenAddedRemoved); | ||||
187 | connect(qApp, &QGuiApplication::screenRemoved, &(d->tabletHandler), &TabletHandler::onScreenAddedRemoved); | ||||
188 | | ||||
189 | // Set up tablet connected/disconnected signals | ||||
190 | connect( &X11EventNotifier::instance(), &X11EventNotifier::tabletAdded, &TabletFinder::instance(), &TabletFinder::onX11TabletAdded); | ||||
191 | connect( &X11EventNotifier::instance(), &X11EventNotifier::tabletRemoved, &TabletFinder::instance(), &TabletFinder::onX11TabletRemoved); | ||||
187 | 192 | | |||
188 | connect( &TabletFinder::instance(), SIGNAL(tabletAdded(TabletInformation)), &(d->tabletHandler), SLOT(onTabletAdded(TabletInformation))); | 193 | connect( &TabletFinder::instance(), &TabletFinder::tabletAdded, &(d->tabletHandler), &TabletHandler::onTabletAdded); | ||
189 | connect( &TabletFinder::instance(), SIGNAL(tabletRemoved(TabletInformation)), &(d->tabletHandler), SLOT(onTabletRemoved(TabletInformation))); | 194 | connect( &TabletFinder::instance(), &TabletFinder::tabletRemoved, &(d->tabletHandler), &TabletHandler::onTabletRemoved); | ||
190 | 195 | | |||
191 | X11EventNotifier::instance().start(); | 196 | X11EventNotifier::instance().start(); | ||
192 | } | 197 | } | ||
193 | 198 | | |||
199 | void TabletDaemon::monitorAllScreensGeometry() | ||||
200 | { | ||||
201 | // FIXME: Should be duplicating old, buggy behaviour: | ||||
202 | // rotation changes monitored for all screens, which causes | ||||
203 | // unwanted rotation in a multi-screen setup | ||||
204 | | ||||
205 | // Add existing screens | ||||
206 | for (const auto &screen : QGuiApplication::screens()) | ||||
207 | { | ||||
208 | monitorScreenGeometry(screen); | ||||
209 | } | ||||
210 | | ||||
211 | // Monitor future screens | ||||
212 | connect(qApp, &QGuiApplication::screenAdded, this, &TabletDaemon::monitorScreenGeometry); | ||||
213 | } | ||||
214 | | ||||
215 | void TabletDaemon::monitorScreenGeometry(QScreen *screen) | ||||
216 | { | ||||
217 | Q_D( TabletDaemon ); | ||||
218 | | ||||
219 | auto tabletHandler = &(d->tabletHandler); | ||||
220 | | ||||
221 | connect(screen, &QScreen::orientationChanged, tabletHandler, &TabletHandler::onScreenRotated); | ||||
222 | screen->setOrientationUpdateMask(Qt::LandscapeOrientation | | ||||
223 | Qt::PortraitOrientation | | ||||
224 | Qt::InvertedLandscapeOrientation | | ||||
225 | Qt::InvertedPortraitOrientation); | ||||
226 | | ||||
227 | connect(screen, &QScreen::geometryChanged, &(d->tabletHandler), &TabletHandler::onScreenGeometryChanged); | ||||
228 | } | ||||
229 | | ||||
194 | #include "tabletdaemon.moc" | 230 | #include "tabletdaemon.moc" |