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 screens being added, removed or reordered | ||
185 | connect( &X11EventNotifier::instance(), SIGNAL(tabletAdded(int)), &TabletFinder::instance(), SLOT(onX11TabletAdded(int))); | 182 | connect(qApp, &QGuiApplication::primaryScreenChanged, &(d->tabletHandler), &TabletHandler::onScreenAddedRemoved); | ||
186 | connect( &X11EventNotifier::instance(), SIGNAL(tabletRemoved(int)), &TabletFinder::instance(), SLOT(onX11TabletRemoved(int))); | 183 | connect(qApp, &QGuiApplication::screenAdded, &(d->tabletHandler), &TabletHandler::onScreenAddedRemoved); | ||
184 | connect(qApp, &QGuiApplication::screenRemoved, &(d->tabletHandler), &TabletHandler::onScreenAddedRemoved); | ||||
185 | | ||||
186 | // Set up tablet connected/disconnected signals | ||||
187 | connect( &X11EventNotifier::instance(), &X11EventNotifier::tabletAdded, &TabletFinder::instance(), &TabletFinder::onX11TabletAdded); | ||||
188 | connect( &X11EventNotifier::instance(), &X11EventNotifier::tabletRemoved, &TabletFinder::instance(), &TabletFinder::onX11TabletRemoved); | ||||
187 | 189 | | |||
188 | connect( &TabletFinder::instance(), SIGNAL(tabletAdded(TabletInformation)), &(d->tabletHandler), SLOT(onTabletAdded(TabletInformation))); | 190 | connect( &TabletFinder::instance(), &TabletFinder::tabletAdded, &(d->tabletHandler), &TabletHandler::onTabletAdded); | ||
189 | connect( &TabletFinder::instance(), SIGNAL(tabletRemoved(TabletInformation)), &(d->tabletHandler), SLOT(onTabletRemoved(TabletInformation))); | 191 | connect( &TabletFinder::instance(), &TabletFinder::tabletRemoved, &(d->tabletHandler), &TabletHandler::onTabletRemoved); | ||
190 | 192 | | |||
191 | X11EventNotifier::instance().start(); | 193 | X11EventNotifier::instance().start(); | ||
192 | } | 194 | } | ||
193 | 195 | | |||
196 | void TabletDaemon::monitorAllScreensGeometry() | ||||
197 | { | ||||
198 | // FIXME: Should be duplicating old, buggy behaviour: | ||||
199 | // rotation changes monitored for all screens, which causes | ||||
200 | // unwanted rotation in a multi-screen setup | ||||
201 | | ||||
202 | // Add existing screens | ||||
203 | for (const auto &screen : QGuiApplication::screens()) | ||||
204 | { | ||||
205 | monitorScreenGeometry(screen); | ||||
206 | } | ||||
207 | | ||||
208 | // Monitor future screens | ||||
209 | connect(qApp, &QGuiApplication::screenAdded, this, &TabletDaemon::monitorScreenGeometry); | ||||
210 | } | ||||
211 | | ||||
212 | void TabletDaemon::monitorScreenGeometry(QScreen *screen) | ||||
213 | { | ||||
214 | Q_D( TabletDaemon ); | ||||
215 | | ||||
216 | auto tabletHandler = &(d->tabletHandler); | ||||
217 | | ||||
218 | connect(screen, &QScreen::orientationChanged, tabletHandler, &TabletHandler::onScreenRotated); | ||||
219 | screen->setOrientationUpdateMask(Qt::LandscapeOrientation | | ||||
220 | Qt::PortraitOrientation | | ||||
221 | Qt::InvertedLandscapeOrientation | | ||||
222 | Qt::InvertedPortraitOrientation); | ||||
223 | | ||||
224 | connect(screen, &QScreen::geometryChanged, &(d->tabletHandler), &TabletHandler::onScreenGeometryChanged); | ||||
225 | } | ||||
226 | | ||||
194 | #include "tabletdaemon.moc" | 227 | #include "tabletdaemon.moc" |