on xenial help sign in
mock screen active
2adba16Nick Dedekind
tests/mocks/WindowManager/MockScreens.cpp+21−2
@@ -57,18 +57,29 @@ public:
57 m_connectedWindow = w;
57 m_connectedWindow = w;
58
58
59 if (w) {
59 if (w) {
60− connect(w, &ScreenWindow::heightChanged, this, [this](int height) {
60+ connect(w, &QWindow::heightChanged, this, [this](int height) {
61+ if (height == 0 || height == m_sizes.first()->size.rheight()) {
62+ return;
63+ }
61 m_sizes.first()->size.rheight() = height;
64 m_sizes.first()->size.rheight() = height;
62 Q_EMIT availableModesChanged();
65 Q_EMIT availableModesChanged();
63
66
64 });
67 });
65− connect(w, &ScreenWindow::widthChanged, this, [this](int width) {
68+ connect(w, &QWindow::widthChanged, this, [this](int width) {
69+ if (width == 0 || width == m_sizes.first()->size.rwidth()) {
70+ return;
71+ }
66 m_sizes.first()->size.rwidth() = width;
72 m_sizes.first()->size.rwidth() = width;
67 Q_EMIT availableModesChanged();
73 Q_EMIT availableModesChanged();
68 });
74 });
75+ connect(w, &QWindow::activeChanged, this, [w, this]() {
76+ if (w->isActive()) setActive(true);
77+ });
78+ if (w->isActive()) setActive(true);
69
79
70 m_sizes.push_front(new qtmir::ScreenMode(50, w->size()));
80 m_sizes.push_front(new qtmir::ScreenMode(50, w->size()));
71 Q_EMIT availableModesChanged();
81 Q_EMIT availableModesChanged();
82+
72 }
83 }
73 }
84 }
74
85
@@ -161,6 +172,14 @@ MockScreens::MockScreens()
161 m_mocks.append(screen);
172 m_mocks.append(screen);
162
173
163 lastPoint.rx() += screen->m_sizes[screen->m_currentModeIndex]->size.width();
174 lastPoint.rx() += screen->m_sizes[screen->m_currentModeIndex]->size.width();
175+
176+ connect(screen, &qtmir::Screen::activeChanged, this, [=](bool active) {
177+ Q_FOREACH(auto otherScreen, m_mocks) {
178+ if (active && otherScreen != screen) {
179+ otherScreen->setActive(false);
180+ }
181+ }
182+ });
164 }
183 }
165}
184}
166
185