on xenial help sign in
better focus condensing
commitcf4f2ea5968626ded3ff84c3c054b3a808fffa59 authorNick Dedekind <nick.dedekind@canonical.com> dateWed 15 Mar 2017, 09:32 (10 years ago) parentbcbc40d
2 files changed+12−18
plugins/WindowManager/TopLevelWindowModel.cpp+11−16 plugins/WindowManager/TopLevelWindowModel.h+1−2
plugins/WindowManager/TopLevelWindowModel.cpp+11−16
@@ -254,14 +254,14 @@ void TopLevelWindowModel::connectWindow(Window *window)
254254
255255 connect(window, &Window::focusedChanged, this, [this, window](bool focused) {
256256 if (window->surface()) {
257− // Condense changes to the focused window
258− // eg: Do focusedWindow=A to focusedWindow=B instead of
259− // focusedWindow=A to focusedWindow=null to focusedWindow=B
260257 if (focused) {
261− m_focusedWindowChanged = true;
262− m_newlyFocusedWindow = window;
258+ setFocusedWindow(window);
259+ m_focusedWindowCleared = false;
263260 } else if (m_focusedWindow == window) {
264− m_focusedWindowChanged = true;
261+ // Condense changes to the focused window
262+ // eg: Do focusedWindow=A to focusedWindow=B instead of
263+ // focusedWindow=A to focusedWindow=null to focusedWindow=B
264+ m_focusedWindowCleared = true;
265265 } else {
266266 // don't clear the focused window if you were not there in the first place
267267 // happens when a filled window gets replaced with an empty one (no surface) as the focused window.
@@ -500,10 +500,7 @@ void TopLevelWindowModel::removeAt(int index)
500500 disconnect(window, 0, this, 0);
501501 if (m_focusedWindow == window) {
502502 setFocusedWindow(nullptr);
503− }
504− if (m_newlyFocusedWindow == window) {
505− m_focusedWindowChanged = false;
506− m_newlyFocusedWindow = nullptr;
503+ m_focusedWindowCleared = false;
507504 }
508505 delete window;
509506
@@ -772,12 +769,11 @@ void TopLevelWindowModel::onModificationsStarted()
772769
773770void TopLevelWindowModel::onModificationsEnded()
774771{
775− if (m_focusedWindowChanged) {
776− setFocusedWindow(m_newlyFocusedWindow);
772+ if (m_focusedWindowCleared) {
773+ setFocusedWindow(nullptr);
777774 }
778775 // reset
779− m_focusedWindowChanged = false;
780− m_newlyFocusedWindow = nullptr;
776+ m_focusedWindowCleared = false;
781777}
782778
783779void TopLevelWindowModel::activateTopMostWindowWithoutId(int forbiddenId)
@@ -840,6 +836,5 @@ void TopLevelWindowModel::clear()
840836 }
841837 m_allSurfaces.clear();
842838 setFocusedWindow(nullptr);
843− m_focusedWindowChanged = false;
844− m_newlyFocusedWindow = nullptr;
839+ m_focusedWindowCleared = false;
845840}
plugins/WindowManager/TopLevelWindowModel.h+1−2
@@ -279,8 +279,7 @@ private:
279279 ModelState m_modelState{IdleState};
280280
281281 // Valid between modificationsStarted and modificationsEnded
282− bool m_focusedWindowChanged{false};
283− Window *m_newlyFocusedWindow{nullptr};
282+ bool m_focusedWindowCleared{false};
284283};
285284
286285#endif // TOPLEVELWINDOWMODEL_H