Changeset View
Changeset View
Standalone View
Standalone View
applets/pager/plugin/windowmodel.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 "windowmodel.h" | 20 | #include "windowmodel.h" | ||
21 | #include "pagermodel.h" | 21 | #include "pagermodel.h" | ||
22 | 22 | | |||
23 | #include <abstracttasksmodel.h> | 23 | #include <abstracttasksmodel.h> | ||
24 | 24 | | |||
25 | #include <QApplication> | 25 | #include <QGuiApplication> | ||
26 | #include <QDesktopWidget> | | |||
27 | #include <QMetaEnum> | 26 | #include <QMetaEnum> | ||
27 | #include <QScreen> | ||||
28 | 28 | | |||
29 | #include <KWindowSystem> | 29 | #include <KWindowSystem> | ||
30 | 30 | | |||
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 | 39 | | |||
40 | PagerModel *pagerModel = nullptr; | 40 | PagerModel *pagerModel = nullptr; | ||
41 | 41 | | |||
42 | QDesktopWidget *desktopWidget = QApplication::desktop(); | | |||
43 | | ||||
44 | private: | 42 | private: | ||
45 | WindowModel *q; | 43 | WindowModel *q; | ||
46 | }; | 44 | }; | ||
47 | 45 | | |||
48 | WindowModel::Private::Private(WindowModel *q) | 46 | WindowModel::Private::Private(WindowModel *q) | ||
49 | : q(q) | 47 | : q(q) | ||
50 | { | 48 | { | ||
51 | } | 49 | } | ||
Show All 21 Lines | 63 | { | |||
73 | 71 | | |||
74 | return roles; | 72 | return roles; | ||
75 | } | 73 | } | ||
76 | 74 | | |||
77 | QVariant WindowModel::data(const QModelIndex &index, int role) const | 75 | QVariant WindowModel::data(const QModelIndex &index, int role) const | ||
78 | { | 76 | { | ||
79 | if (role == AbstractTasksModel::Geometry) { | 77 | if (role == AbstractTasksModel::Geometry) { | ||
80 | QRect windowGeo = TaskFilterProxyModel::data(index, role).toRect(); | 78 | QRect windowGeo = TaskFilterProxyModel::data(index, role).toRect(); | ||
81 | const QRect &desktopGeo = d->desktopWidget->geometry(); | 79 | QList<QScreen *> screens = QGuiApplication::screens(); | ||
broulik: Isn't that the combined geometry of all screens, not just a single screen? | |||||
Oh indeed. But then this was the wrong thing to use anyway. You don't want to center the window in relation to the combined geometry, as the documentation of QDesktopWidget rightfully says. Not that I really understand this code, I admit. dfaure: Oh indeed. But then this was the wrong thing to use anyway. You don't want to center the window… | |||||
80 | const QRect desktopGeo = screens.at(0)->geometry(); | ||||
82 | 81 | | |||
83 | if (KWindowSystem::mapViewport()) { | 82 | if (KWindowSystem::mapViewport()) { | ||
84 | int x = windowGeo.center().x() % desktopGeo.width(); | 83 | int x = windowGeo.center().x() % desktopGeo.width(); | ||
85 | int y = windowGeo.center().y() % desktopGeo.height(); | 84 | int y = windowGeo.center().y() % desktopGeo.height(); | ||
86 | 85 | | |||
87 | if (x < 0) { | 86 | if (x < 0) { | ||
88 | x = x + desktopGeo.width(); | 87 | x = x + desktopGeo.width(); | ||
89 | } | 88 | } | ||
▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines |
Isn't that the combined geometry of all screens, not just a single screen?