Changeset View
Changeset View
Standalone View
Standalone View
applets/pager/plugin/windowmodel.cpp
Show All 30 Lines | |||||
31 | #include <algorithm> | 31 | #include <algorithm> | ||
32 | 32 | | |||
33 | using namespace TaskManager; | 33 | using namespace TaskManager; | ||
34 | 34 | | |||
35 | class WindowModel::Private | 35 | class WindowModel::Private | ||
36 | { | 36 | { | ||
37 | public: | 37 | public: | ||
38 | Private(WindowModel *q); | 38 | Private(WindowModel *q); | ||
39 | QRect screenGeometry() const; | ||||
39 | 40 | | |||
40 | PagerModel *pagerModel = nullptr; | 41 | PagerModel *pagerModel = nullptr; | ||
41 | 42 | | |||
42 | private: | 43 | private: | ||
43 | WindowModel *q; | 44 | WindowModel *q; | ||
44 | }; | 45 | }; | ||
45 | 46 | | |||
46 | WindowModel::Private::Private(WindowModel *q) | 47 | WindowModel::Private::Private(WindowModel *q) | ||
Show All 24 Lines | 64 | { | |||
71 | 72 | | |||
72 | return roles; | 73 | return roles; | ||
73 | } | 74 | } | ||
74 | 75 | | |||
75 | QVariant WindowModel::data(const QModelIndex &index, int role) const | 76 | QVariant WindowModel::data(const QModelIndex &index, int role) const | ||
76 | { | 77 | { | ||
77 | if (role == AbstractTasksModel::Geometry) { | 78 | if (role == AbstractTasksModel::Geometry) { | ||
78 | QRect windowGeo = TaskFilterProxyModel::data(index, role).toRect(); | 79 | QRect windowGeo = TaskFilterProxyModel::data(index, role).toRect(); | ||
79 | QList<QScreen *> screens = QGuiApplication::screens(); | 80 | const QRect desktopGeo = d->screenGeometry(); | ||
80 | const QRect desktopGeo = screens.at(0)->geometry(); | | |||
81 | 81 | | |||
82 | if (KWindowSystem::mapViewport()) { | 82 | if (KWindowSystem::mapViewport()) { | ||
83 | int x = windowGeo.center().x() % desktopGeo.width(); | 83 | int x = windowGeo.center().x() % desktopGeo.width(); | ||
84 | int y = windowGeo.center().y() % desktopGeo.height(); | 84 | int y = windowGeo.center().y() % desktopGeo.height(); | ||
85 | 85 | | |||
86 | if (x < 0) { | 86 | if (x < 0) { | ||
87 | x = x + desktopGeo.width(); | 87 | x = x + desktopGeo.width(); | ||
88 | } | 88 | } | ||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | |||||
140 | } | 140 | } | ||
141 | 141 | | |||
142 | void WindowModel::refreshStackingOrder() | 142 | void WindowModel::refreshStackingOrder() | ||
143 | { | 143 | { | ||
144 | if (rowCount()) { | 144 | if (rowCount()) { | ||
145 | emit dataChanged(index(0, 0), index(rowCount() - 1, 0), QVector<int>{StackingOrder}); | 145 | emit dataChanged(index(0, 0), index(rowCount() - 1, 0), QVector<int>{StackingOrder}); | ||
146 | } | 146 | } | ||
147 | } | 147 | } | ||
148 | | ||||
149 | QRect WindowModel::Private::screenGeometry() const | ||||
150 | { | ||||
151 | QRegion geometry; | ||||
152 | for (auto screen: qApp->screens()) { | ||||
153 | geometry += screen->geometry(); | ||||
154 | } | ||||
155 | return geometry.boundingRect(); | ||||
156 | } |