on xenial help sign in
better focus condensing
cf4f2eaNick Dedekind
plugins/WindowManager/TopLevelWindowModel.cpp+11−16
@@ -254,14 +254,14 @@ void TopLevelWindowModel::connectWindow(Window *window)
254
254
255 connect(window, &Window::focusedChanged, this, [this, window](bool focused) {
255 connect(window, &Window::focusedChanged, this, [this, window](bool focused) {
256 if (window->surface()) {
256 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
260 if (focused) {
257 if (focused) {
261− m_focusedWindowChanged = true;
258+ setFocusedWindow(window);
262− m_newlyFocusedWindow = window;
259+ m_focusedWindowCleared = false;
263 } else if (m_focusedWindow == window) {
260 } 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;
265 } else {
265 } else {
266 // don't clear the focused window if you were not there in the first place
266 // don't clear the focused window if you were not there in the first place
267 // happens when a filled window gets replaced with an empty one (no surface) as the focused window.
267 // 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)
500 disconnect(window, 0, this, 0);
500 disconnect(window, 0, this, 0);
501 if (m_focusedWindow == window) {
501 if (m_focusedWindow == window) {
502 setFocusedWindow(nullptr);
502 setFocusedWindow(nullptr);
503− }
503+ m_focusedWindowCleared = false;
504− if (m_newlyFocusedWindow == window) {
505− m_focusedWindowChanged = false;
506− m_newlyFocusedWindow = nullptr;
507 }
504 }
508 delete window;
505 delete window;
509
506
@@ -772,12 +769,11 @@ void TopLevelWindowModel::onModificationsStarted()
772
769
773void TopLevelWindowModel::onModificationsEnded()
770void TopLevelWindowModel::onModificationsEnded()
774{
771{
775− if (m_focusedWindowChanged) {
772+ if (m_focusedWindowCleared) {
776− setFocusedWindow(m_newlyFocusedWindow);
773+ setFocusedWindow(nullptr);
777 }
774 }
778 // reset
775 // reset
779− m_focusedWindowChanged = false;
776+ m_focusedWindowCleared = false;
780− m_newlyFocusedWindow = nullptr;
781}
777}
782
778
783void TopLevelWindowModel::activateTopMostWindowWithoutId(int forbiddenId)
779void TopLevelWindowModel::activateTopMostWindowWithoutId(int forbiddenId)
@@ -840,6 +836,5 @@ void TopLevelWindowModel::clear()
840 }
836 }
841 m_allSurfaces.clear();
837 m_allSurfaces.clear();
842 setFocusedWindow(nullptr);
838 setFocusedWindow(nullptr);
843− m_focusedWindowChanged = false;
839+ m_focusedWindowCleared = false;
844− m_newlyFocusedWindow = nullptr;
845}
840}
plugins/WindowManager/TopLevelWindowModel.h+1−2
@@ -279,8 +279,7 @@ private:
279 ModelState m_modelState{IdleState};
279 ModelState m_modelState{IdleState};
280
280
281 // Valid between modificationsStarted and modificationsEnded
281 // Valid between modificationsStarted and modificationsEnded
282− bool m_focusedWindowChanged{false};
282+ bool m_focusedWindowCleared{false};
283− Window *m_newlyFocusedWindow{nullptr};
284};
283};
285
284
286#endif // TOPLEVELWINDOWMODEL_H
285#endif // TOPLEVELWINDOWMODEL_H