Changeset View
Changeset View
Standalone View
Standalone View
applets/pager/plugin/pagermodel.cpp
Show All 26 Lines | |||||
27 | #include <windowtasksmodel.h> | 27 | #include <windowtasksmodel.h> | ||
28 | #include <xwindowtasksmodel.h> | 28 | #include <xwindowtasksmodel.h> | ||
29 | #include <waylandtasksmodel.h> | 29 | #include <waylandtasksmodel.h> | ||
30 | 30 | | |||
31 | #include <QApplication> | 31 | #include <QApplication> | ||
32 | #include <QDBusConnection> | 32 | #include <QDBusConnection> | ||
33 | #include <QDBusMessage> | 33 | #include <QDBusMessage> | ||
34 | #include <QDBusPendingCall> | 34 | #include <QDBusPendingCall> | ||
35 | #include <QDesktopWidget> | | |||
36 | #include <QMetaEnum> | 35 | #include <QMetaEnum> | ||
36 | #include <QScreen> | ||||
37 | 37 | | |||
38 | #include <KWindowSystem> | 38 | #include <KWindowSystem> | ||
39 | 39 | | |||
40 | #include <KActivities/Controller> | 40 | #include <KActivities/Controller> | ||
41 | 41 | | |||
42 | using namespace TaskManager; | 42 | using namespace TaskManager; | ||
43 | 43 | | |||
44 | class PagerModel::Private | 44 | class PagerModel::Private | ||
Show All 18 Lines | 46 | public: | |||
63 | static ActivityInfo *activityInfo; | 63 | static ActivityInfo *activityInfo; | ||
64 | QMetaObject::Connection activityNumberConn; | 64 | QMetaObject::Connection activityNumberConn; | ||
65 | QMetaObject::Connection activityNamesConn; | 65 | QMetaObject::Connection activityNamesConn; | ||
66 | 66 | | |||
67 | static VirtualDesktopInfo *virtualDesktopInfo; | 67 | static VirtualDesktopInfo *virtualDesktopInfo; | ||
68 | QMetaObject::Connection virtualDesktopNumberConn; | 68 | QMetaObject::Connection virtualDesktopNumberConn; | ||
69 | QMetaObject::Connection virtualDesktopNamesConn; | 69 | QMetaObject::Connection virtualDesktopNamesConn; | ||
70 | 70 | | |||
71 | QDesktopWidget *desktopWidget = QApplication::desktop(); | | |||
72 | | ||||
73 | QList<WindowModel *> windowModels; | 71 | QList<WindowModel *> windowModels; | ||
74 | 72 | | |||
75 | #if HAVE_X11 | 73 | #if HAVE_X11 | ||
76 | QList<WId> cachedStackingOrder = KWindowSystem::stackingOrder(); | 74 | QList<WId> cachedStackingOrder = KWindowSystem::stackingOrder(); | ||
77 | #endif | 75 | #endif | ||
78 | 76 | | |||
79 | void refreshDataSource(); | 77 | void refreshDataSource(); | ||
80 | 78 | | |||
Show All 32 Lines | 108 | if (pagerType == VirtualDesktops && windowModels.count()) { | |||
113 | } | 111 | } | ||
114 | } | 112 | } | ||
115 | } | 113 | } | ||
116 | ); | 114 | ); | ||
117 | 115 | | |||
118 | QObject::connect(virtualDesktopInfo, &VirtualDesktopInfo::desktopLayoutRowsChanged, | 116 | QObject::connect(virtualDesktopInfo, &VirtualDesktopInfo::desktopLayoutRowsChanged, | ||
119 | q, &PagerModel::layoutRowsChanged); | 117 | q, &PagerModel::layoutRowsChanged); | ||
120 | 118 | | |||
121 | QObject::connect(desktopWidget, &QDesktopWidget::screenCountChanged, | 119 | auto configureScreen = [q](QScreen* screen) { | ||
122 | q, &PagerModel::pagerItemSizeChanged); | 120 | QObject::connect(screen, &QScreen::geometryChanged, q, &PagerModel::pagerItemSizeChanged); | ||
davidedmundson: we need this connection for screens that already exist when this code runs | |||||
123 | QObject::connect(desktopWidget, &QDesktopWidget::resized, | 121 | q->pagerItemSizeChanged(); | ||
124 | q, &PagerModel::pagerItemSizeChanged); | 122 | }; | ||
123 | for (QScreen* screen : qGuiApp->screens()) { | ||||
hein: Missing braces around single-line block and no const | |||||
124 | configureScreen(screen); | ||||
125 | } | ||||
126 | QObject::connect(qGuiApp, &QGuiApplication::screenAdded, q, configureScreen); | ||||
127 | QObject::connect(qGuiApp, &QGuiApplication::screenRemoved, q, &PagerModel::pagerItemSizeChanged); | ||||
125 | 128 | | |||
126 | #if HAVE_X11 | 129 | #if HAVE_X11 | ||
127 | QObject::connect(KWindowSystem::self(), &KWindowSystem::stackingOrderChanged, q, | 130 | QObject::connect(KWindowSystem::self(), &KWindowSystem::stackingOrderChanged, q, | ||
128 | [this]() { | 131 | [this]() { | ||
129 | cachedStackingOrder = KWindowSystem::stackingOrder(); | 132 | cachedStackingOrder = KWindowSystem::stackingOrder(); | ||
130 | 133 | | |||
131 | for (auto windowModel : windowModels) { | 134 | for (auto windowModel : windowModels) { | ||
132 | windowModel->refreshStackingOrder(); | 135 | windowModel->refreshStackingOrder(); | ||
▲ Show 20 Lines • Show All 242 Lines • ▼ Show 20 Line(s) | |||||
375 | QSize PagerModel::pagerItemSize() const | 378 | QSize PagerModel::pagerItemSize() const | ||
376 | { | 379 | { | ||
377 | if (d->showOnlyCurrentScreen && d->screenGeometry.isValid()) { | 380 | if (d->showOnlyCurrentScreen && d->screenGeometry.isValid()) { | ||
378 | return d->screenGeometry.size(); | 381 | return d->screenGeometry.size(); | ||
379 | } | 382 | } | ||
380 | 383 | | |||
381 | QRect totalRect; | 384 | QRect totalRect; | ||
382 | 385 | | |||
383 | for (int i = 0; i < d->desktopWidget->screenCount(); ++i) { | 386 | const auto screens = QGuiApplication::screens(); | ||
384 | totalRect |= d->desktopWidget->screenGeometry(i); | 387 | for (auto screen : screens) { | ||
388 | totalRect |= screen->geometry(); | ||||
385 | } | 389 | } | ||
386 | 390 | | |||
387 | return totalRect.size(); | 391 | return totalRect.size(); | ||
388 | } | 392 | } | ||
389 | 393 | | |||
390 | #if HAVE_X11 | 394 | #if HAVE_X11 | ||
391 | QList<WId> PagerModel::stackingOrder() const | 395 | QList<WId> PagerModel::stackingOrder() const | ||
392 | { | 396 | { | ||
▲ Show 20 Lines • Show All 286 Lines • Show Last 20 Lines |
we need this connection for screens that already exist when this code runs