on 12e32a5 help sign in
unity8/plugins/WindowManager/TopLevelWindowModel.cpp
779 lines 25 kB history raw
1/*
2 * Copyright (C) 2016-2017 Canonical, Ltd.
3 * Copyright 2019 UBports Foundation
4 *
5 * This program is free software: you can redistribute it and/or modify it under
6 * the terms of the GNU Lesser General Public License version 3, as published by
7 * the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
11 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
18#include "TopLevelWindowModel.h"
20// unity-api
21#include <unity/shell/application/ApplicationInfoInterface.h>
22#include <unity/shell/application/ApplicationManagerInterface.h>
23#include <unity/shell/application/MirSurfaceInterface.h>
24#include <unity/shell/application/MirSurfaceListInterface.h>
25#include <unity/shell/application/SurfaceManagerInterface.h>
27// Qt
28#include <QGuiApplication>
29#include <QDebug>
31// local
32#include "Window.h"
34Q_LOGGING_CATEGORY(TOPLEVELWINDOWMODEL, "toplevelwindowmodel", QtInfoMsg)
36#define DEBUG_MSG qCDebug(TOPLEVELWINDOWMODEL).nospace().noquote() << __func__
37#define INFO_MSG qCInfo(TOPLEVELWINDOWMODEL).nospace().noquote() << __func__
39namespace unityapi = unity::shell::application;
41TopLevelWindowModel::TopLevelWindowModel()
42 : m_nullWindow(createNullWindow()),
43 m_surfaceManagerBusy(false)
45 connect(m_nullWindow, &Window::focusedChanged, this, [this] {
46 Q_EMIT rootFocusChanged();
47 });
50void TopLevelWindowModel::setApplicationManager(unityapi::ApplicationManagerInterface* value)
52 if (m_applicationManager == value) {
53 return;
54 }
56 DEBUG_MSG << "(" << value << ")";
58 Q_ASSERT(m_modelState == IdleState);
59 m_modelState = ResettingState;
61 beginResetModel();
63 if (m_applicationManager) {
64 m_windowModel.clear();
65 disconnect(m_applicationManager, 0, this, 0);
66 }
68 m_applicationManager = value;
70 if (m_applicationManager) {
71 connect(m_applicationManager, &QAbstractItemModel::rowsInserted,
72 this, [this](const QModelIndex &/*parent*/, int first, int last) {
73 for (int i = first; i <= last; ++i) {
74 auto application = m_applicationManager->get(i);
75 addApplication(application);
76 }
77 });
79 connect(m_applicationManager, &QAbstractItemModel::rowsAboutToBeRemoved,
80 this, [this](const QModelIndex &/*parent*/, int first, int last) {
81 for (int i = first; i <= last; ++i) {
82 auto application = m_applicationManager->get(i);
83 removeApplication(application);
84 }
85 });
87 for (int i = 0; i < m_applicationManager->rowCount(); ++i) {
88 auto application = m_applicationManager->get(i);
89 addApplication(application);
90 }
91 }
93 endResetModel();
94 m_modelState = IdleState;
97void TopLevelWindowModel::setSurfaceManager(unityapi::SurfaceManagerInterface *surfaceManager)
99 if (surfaceManager == m_surfaceManager) {
100 return;
101 }
103 DEBUG_MSG << "(" << surfaceManager << ")";
105 if (m_surfaceManager) {
106 disconnect(m_surfaceManager, 0, this, 0);
107 }
109 m_surfaceManager = surfaceManager;
111 if (m_surfaceManager) {
112 connect(m_surfaceManager, &unityapi::SurfaceManagerInterface::surfaceCreated, this, &TopLevelWindowModel::onSurfaceCreated);
113 connect(m_surfaceManager, &unityapi::SurfaceManagerInterface::surfacesRaised, this, &TopLevelWindowModel::onSurfacesRaised);
114 connect(m_surfaceManager, &unityapi::SurfaceManagerInterface::modificationsStarted, this, &TopLevelWindowModel::onModificationsStarted);
115 connect(m_surfaceManager, &unityapi::SurfaceManagerInterface::modificationsEnded, this, &TopLevelWindowModel::onModificationsEnded);
116 }
118 Q_EMIT surfaceManagerChanged(m_surfaceManager);
121void TopLevelWindowModel::addApplication(unityapi::ApplicationInfoInterface *application)
123 DEBUG_MSG << "(" << application->appId() << ")";
125 if (application->state() != unityapi::ApplicationInfoInterface::Stopped && application->surfaceList()->count() == 0) {
126 prependPlaceholder(application);
127 }
130void TopLevelWindowModel::removeApplication(unityapi::ApplicationInfoInterface *application)
132 DEBUG_MSG << "(" << application->appId() << ")";
134 Q_ASSERT(m_modelState == IdleState);
136 int i = 0;
137 while (i < m_windowModel.count()) {
138 if (m_windowModel.at(i).application == application) {
139 deleteAt(i);
140 } else {
141 ++i;
142 }
143 }
146void TopLevelWindowModel::prependPlaceholder(unityapi::ApplicationInfoInterface *application)
148 INFO_MSG << "(" << application->appId() << ")";
150 prependSurfaceHelper(nullptr, application);
153void TopLevelWindowModel::prependSurface(unityapi::MirSurfaceInterface *surface, unityapi::ApplicationInfoInterface *application)
155 Q_ASSERT(surface != nullptr);
157 connectSurface(surface);
159 bool filledPlaceholder = false;
160 for (int i = 0; i < m_windowModel.count() && !filledPlaceholder; ++i) {
161 ModelEntry &entry = m_windowModel[i];
162 if (entry.application == application && entry.window->surface() == nullptr) {
163 entry.window->setSurface(surface);
164 INFO_MSG << " appId=" << application->appId() << " surface=" << surface
165 << ", filling out placeholder. after: " << toString();
166 filledPlaceholder = true;
167 }
168 }
170 if (!filledPlaceholder) {
171 INFO_MSG << " appId=" << application->appId() << " surface=" << surface << ", adding new row";
172 prependSurfaceHelper(surface, application);
173 }
176void TopLevelWindowModel::prependSurfaceHelper(unityapi::MirSurfaceInterface *surface, unityapi::ApplicationInfoInterface *application)
179 Window *window = createWindow(surface);
181 connect(window, &Window::stateChanged, this, [=](Mir::State newState) {
182 if (newState == Mir::HiddenState) {
183 // Comply, removing it from our model. Just as if it didn't exist anymore.
184 removeAt(indexForId(window->id()));
185 } else {
186 if (indexForId(window->id()) == -1) {
187 // was probably hidden before. put it back on the list
188 auto *application = m_applicationManager->findApplicationWithSurface(window->surface());
189 Q_ASSERT(application);
190 prependWindow(window, application);
191 }
192 }
193 });
195 prependWindow(window, application);
197 if (!surface) {
198 activateEmptyWindow(window);
199 }
201 INFO_MSG << " after " << toString();
204void TopLevelWindowModel::prependWindow(Window *window, unityapi::ApplicationInfoInterface *application)
206 if (m_modelState == IdleState) {
207 m_modelState = InsertingState;
208 beginInsertRows(QModelIndex(), 0 /*first*/, 0 /*last*/);
209 } else {
210 Q_ASSERT(m_modelState == ResettingState);
211 // No point in signaling anything if we're resetting the whole model
212 }
214 m_windowModel.prepend(ModelEntry(window, application));
216 if (m_modelState == InsertingState) {
217 endInsertRows();
218 Q_EMIT countChanged();
219 Q_EMIT listChanged();
220 m_modelState = IdleState;
221 }
224void TopLevelWindowModel::connectWindow(Window *window)
226 connect(window, &Window::focusRequested, this, [this, window]() {
227 if (!window->surface()) {
228 activateEmptyWindow(window);
229 }
230 });
232 connect(window, &Window::focusedChanged, this, [this, window](bool focused) {
233 if (window->surface()) {
234 // Condense changes to the focused window
235 // eg: Do focusedWindow=A to focusedWindow=B instead of
236 // focusedWindow=A to focusedWindow=null to focusedWindow=B
237 if (focused) {
238 Q_ASSERT(m_newlyFocusedWindow == nullptr);
239 m_focusedWindowChanged = true;
240 m_newlyFocusedWindow = window;
241 } else if (m_focusedWindow == window) {
242 m_focusedWindowChanged = true;
243 } else {
244 // don't clear the focused window if you were not there in the first place
245 // happens when a filled window gets replaced with an empty one (no surface) as the focused window.
246 }
247 }
248 });
250 connect(window, &Window::closeRequested, this, [this, window]() {
251 if (!window->surface()) {
252 // do things ourselves as miral doesn't know about this window
253 int id = window->id();
254 int index = indexForId(id);
255 bool focusOther = false;
256 Q_ASSERT(index >= 0);
257 if (window->focused()) {
258 focusOther = true;
259 }
260 m_windowModel[index].application->close();
261 if (focusOther) {
262 activateTopMostWindowWithoutId(id);
263 }
264 }
265 });
267 connect(window, &Window::emptyWindowActivated, this, [this, window]() {
268 activateEmptyWindow(window);
269 });
271 connect(window, &Window::liveChanged, this, [this, window](bool isAlive) {
272 if (!isAlive && window->state() == Mir::HiddenState) {
273 // Hidden windows are not in the model. So just delete it right away.
274 delete window;
275 }
276 });
279void TopLevelWindowModel::activateEmptyWindow(Window *window)
281 Q_ASSERT(!window->surface());
282 DEBUG_MSG << "(" << window << ")";
284 // miral doesn't know about empty windows (ie, windows that are not backed up by MirSurfaces)
285 // So we have to activate them ourselves (instead of asking SurfaceManager to do it for us).
287 window->setFocused(true);
288 raiseId(window->id());
289 Window *previousWindow = m_focusedWindow;
290 setFocusedWindow(window);
291 if (previousWindow && previousWindow->surface() && previousWindow->surface()->focused()) {
292 m_surfaceManager->activate(nullptr);
293 }
296void TopLevelWindowModel::connectSurface(unityapi::MirSurfaceInterface *surface)
298 connect(surface, &unityapi::MirSurfaceInterface::liveChanged, this, [this, surface](bool live){
299 if (!live) {
300 onSurfaceDied(surface);
301 }
302 });
303 connect(surface, &QObject::destroyed, this, [this, surface](){ this->onSurfaceDestroyed(surface); });
306void TopLevelWindowModel::onSurfaceDied(unityapi::MirSurfaceInterface *surface)
308 if (surface->type() == Mir::InputMethodType) {
309 removeInputMethodWindow();
310 return;
311 }
313 int i = indexOf(surface);
314 if (i == -1) {
315 return;
316 }
318 auto application = m_windowModel[i].application;
320 // can't be starting if it already has a surface
321 Q_ASSERT(application->state() != unityapi::ApplicationInfoInterface::Starting);
323 if (application->state() == unityapi::ApplicationInfoInterface::Running) {
324 m_windowModel[i].removeOnceSurfaceDestroyed = true;
325 } else {
326 // assume it got killed by the out-of-memory daemon.
327 //
328 // So leave entry in the model and only remove its surface, so shell can display a screenshot
329 // in its place.
330 m_windowModel[i].removeOnceSurfaceDestroyed = false;
331 }
334void TopLevelWindowModel::onSurfaceDestroyed(unityapi::MirSurfaceInterface *surface)
336 int i = indexOf(surface);
337 if (i == -1) {
338 return;
339 }
341 if (m_windowModel[i].removeOnceSurfaceDestroyed) {
342 deleteAt(i);
343 } else {
344 auto window = m_windowModel[i].window;
345 window->setSurface(nullptr);
346 window->setFocused(false);
347 INFO_MSG << " Removed surface from entry. After: " << toString();
348 }
351Window *TopLevelWindowModel::createWindow(unityapi::MirSurfaceInterface *surface)
353 int id = m_nextId.fetchAndAddAcquire(1);
354 return createWindowWithId(surface, id);
357Window *TopLevelWindowModel::createNullWindow()
359 return createWindowWithId(nullptr, 0);
362Window *TopLevelWindowModel::createWindowWithId(unityapi::MirSurfaceInterface *surface, int id)
364 Window *qmlWindow = new Window(id, this);
365 connectWindow(qmlWindow);
366 if (surface) {
367 qmlWindow->setSurface(surface);
368 }
369 return qmlWindow;
372void TopLevelWindowModel::onSurfaceCreated(unityapi::MirSurfaceInterface *surface)
374 DEBUG_MSG << "(" << surface << ")";
376 if (surface->parentSurface()) {
377 // Wrap it in a Window so that we keep focusedWindow() up to date.
378 Window *window = createWindow(surface);
379 connect(surface, &QObject::destroyed, window, [=](){
380 window->setSurface(nullptr);
381 window->deleteLater();
382 });
383 } else {
384 if (surface->type() == Mir::InputMethodType) {
385 connectSurface(surface);
386 setInputMethodWindow(createWindow(surface));
387 } else {
388 auto *application = m_applicationManager->findApplicationWithSurface(surface);
389 if (application) {
390 if (surface->state() == Mir::HiddenState) {
391 // Ignore it until it's finally shown
392 connect(surface, &unityapi::MirSurfaceInterface::stateChanged, this, [=](Mir::State newState) {
393 Q_ASSERT(newState != Mir::HiddenState);
394 disconnect(surface, &unityapi::MirSurfaceInterface::stateChanged, this, 0);
395 prependSurface(surface, application);
396 });
397 } else {
398 prependSurface(surface, application);
399 }
400 } else {
401 // Must be a prompt session. No need to do add it as a prompt surface is not top-level.
402 // It will show up in the ApplicationInfoInterface::promptSurfaceList of some application.
403 // Still wrap it in a Window though, so that we keep focusedWindow() up to date.
404 Window *promptWindow = createWindow(surface);
405 connect(surface, &QObject::destroyed, promptWindow, [=](){
406 promptWindow->setSurface(nullptr);
407 promptWindow->deleteLater();
408 });
409 }
410 }
411 }
414void TopLevelWindowModel::deleteAt(int index)
416 auto window = m_windowModel[index].window;
418 removeAt(index);
420 window->setSurface(nullptr);
422 delete window;
425void TopLevelWindowModel::removeAt(int index)
427 if (m_modelState == IdleState) {
428 beginRemoveRows(QModelIndex(), index, index);
429 m_modelState = RemovingState;
430 } else {
431 Q_ASSERT(m_modelState == ResettingState);
432 // No point in signaling anything if we're resetting the whole model
433 }
435 auto window = m_windowModel[index].window;
437 if (!window->surface()) {
438 window->setFocused(false);
439 }
441 m_windowModel.removeAt(index);
443 if (m_modelState == RemovingState) {
444 endRemoveRows();
445 Q_EMIT countChanged();
446 Q_EMIT listChanged();
447 m_modelState = IdleState;
448 }
450 if (m_focusedWindow == window) {
451 setFocusedWindow(nullptr);
452 }
454 if (m_previousWindow == window) {
455 m_previousWindow = nullptr;
456 }
458 if (m_closingAllApps) {
459 if (m_windowModel.isEmpty()) {
460 Q_EMIT closedAllWindows();
461 }
462 }
464 INFO_MSG << " after " << toString() << " apps left " << m_windowModel.count();
467void TopLevelWindowModel::setInputMethodWindow(Window *window)
469 if (m_inputMethodWindow) {
470 qWarning("Multiple Input Method Surfaces created, removing the old one!");
471 delete m_inputMethodWindow;
472 }
473 m_inputMethodWindow = window;
474 Q_EMIT inputMethodSurfaceChanged(m_inputMethodWindow->surface());
477void TopLevelWindowModel::removeInputMethodWindow()
479 if (m_inputMethodWindow) {
480 delete m_inputMethodWindow;
481 m_inputMethodWindow = nullptr;
482 Q_EMIT inputMethodSurfaceChanged(nullptr);
483 }
486void TopLevelWindowModel::onSurfacesRaised(const QVector<unityapi::MirSurfaceInterface*> &surfaces)
488 DEBUG_MSG << "(" << surfaces << ")";
489 const int raiseCount = surfaces.size();
490 for (int i = 0; i < raiseCount; i++) {
491 int fromIndex = findIndexOf(surfaces[i]);
492 if (fromIndex != -1) {
493 move(fromIndex, 0);
494 }
495 }
498int TopLevelWindowModel::rowCount(const QModelIndex &/*parent*/) const
500 return m_windowModel.count();
503QVariant TopLevelWindowModel::data(const QModelIndex& index, int role) const
505 if (index.row() < 0 || index.row() >= m_windowModel.size())
506 return QVariant();
508 if (role == WindowRole) {
509 Window *window = m_windowModel.at(index.row()).window;
510 return QVariant::fromValue(window);
511 } else if (role == ApplicationRole) {
512 return QVariant::fromValue(m_windowModel.at(index.row()).application);
513 } else {
514 return QVariant();
515 }
518int TopLevelWindowModel::findIndexOf(const unityapi::MirSurfaceInterface *surface) const
520 for (int i=0; i<m_windowModel.count(); i++) {
521 if (m_windowModel[i].window->surface() == surface) {
522 return i;
523 }
524 }
525 return -1;
528QString TopLevelWindowModel::toString()
530 QString str;
531 for (int i = 0; i < m_windowModel.count(); ++i) {
532 auto item = m_windowModel.at(i);
534 QString itemStr = QString("(index=%1,appId=%2,surface=0x%3,id=%4)")
535 .arg(QString::number(i),
536 item.application->appId(),
537 QString::number((qintptr)item.window->surface(), 16),
538 QString::number(item.window->id()));
540 if (i > 0) {
541 str.append(",");
542 }
543 str.append(itemStr);
544 }
545 return str;
548int TopLevelWindowModel::indexOf(unityapi::MirSurfaceInterface *surface)
550 for (int i = 0; i < m_windowModel.count(); ++i) {
551 if (m_windowModel.at(i).window->surface() == surface) {
552 return i;
553 }
554 }
555 return -1;
558int TopLevelWindowModel::indexForId(int id) const
560 for (int i = 0; i < m_windowModel.count(); ++i) {
561 if (m_windowModel[i].window->id() == id) {
562 return i;
563 }
564 }
565 return -1;
568Window *TopLevelWindowModel::windowAt(int index) const
570 if (index >=0 && index < m_windowModel.count()) {
571 return m_windowModel[index].window;
572 } else {
573 return nullptr;
574 }
577unityapi::MirSurfaceInterface *TopLevelWindowModel::surfaceAt(int index) const
579 if (index >=0 && index < m_windowModel.count()) {
580 return m_windowModel[index].window->surface();
581 } else {
582 return nullptr;
583 }
586unityapi::ApplicationInfoInterface *TopLevelWindowModel::applicationAt(int index) const
588 if (index >=0 && index < m_windowModel.count()) {
589 return m_windowModel[index].application;
590 } else {
591 return nullptr;
592 }
595int TopLevelWindowModel::idAt(int index) const
597 if (index >=0 && index < m_windowModel.count()) {
598 return m_windowModel[index].window->id();
599 } else {
600 return 0;
601 }
604void TopLevelWindowModel::raiseId(int id)
606 if (m_modelState == IdleState) {
607 DEBUG_MSG << "(id=" << id << ") - do it now.";
608 doRaiseId(id);
609 } else {
610 DEBUG_MSG << "(id=" << id << ") - Model busy (modelState=" << m_modelState << "). Try again in the next event loop.";
611 // The model has just signalled some change. If we have a Repeater responding to this update, it will get nuts
612 // if we perform yet another model change straight away.
613 //
614 // A bad sympton of this problem is a Repeater.itemAt(index) call returning null event though Repeater.count says
615 // the index is definitely within bounds.
616 QMetaObject::invokeMethod(this, "raiseId", Qt::QueuedConnection, Q_ARG(int, id));
617 }
620void TopLevelWindowModel::doRaiseId(int id)
622 int fromIndex = indexForId(id);
623 // can't raise something that doesn't exist or that it's already on top
624 if (fromIndex != -1 && fromIndex != 0) {
625 auto surface = m_windowModel[fromIndex].window->surface();
626 if (surface) {
627 m_surfaceManager->raise(surface);
628 } else {
629 // move it ourselves. Since there's no mir::scene::Surface/miral::Window, there's nothing
630 // miral can do about it.
631 move(fromIndex, 0);
632 }
633 }
636void TopLevelWindowModel::setFocusedWindow(Window *window)
638 if (window != m_focusedWindow) {
639 INFO_MSG << "(" << window << ")";
641 m_previousWindow = m_focusedWindow;
643 m_focusedWindow = window;
644 Q_EMIT focusedWindowChanged(m_focusedWindow);
646 if (m_previousWindow && m_previousWindow->focused() && !m_previousWindow->surface()) {
647 // do it ourselves. miral doesn't know about this window
648 m_previousWindow->setFocused(false);
649 }
650 }
652 // Reset
653 m_pendingActivation = false;
656unityapi::MirSurfaceInterface* TopLevelWindowModel::inputMethodSurface() const
658 return m_inputMethodWindow ? m_inputMethodWindow->surface() : nullptr;
661Window* TopLevelWindowModel::focusedWindow() const
663 return m_focusedWindow;
666void TopLevelWindowModel::move(int from, int to)
668 if (from == to) return;
669 DEBUG_MSG << " from=" << from << " to=" << to;
671 if (from >= 0 && from < m_windowModel.size() && to >= 0 && to < m_windowModel.size()) {
672 QModelIndex parent;
673 /* When moving an item down, the destination index needs to be incremented
674 by one, as explained in the documentation:
675 http://qt-project.org/doc/qt-5.0/qtcore/qabstractitemmodel.html#beginMoveRows */
677 Q_ASSERT(m_modelState == IdleState);
678 m_modelState = MovingState;
680 beginMoveRows(parent, from, from, parent, to + (to > from ? 1 : 0));
681#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0)
682 const auto &window = m_windowModel.takeAt(from);
683 m_windowModel.insert(to, window);
684#else
685 m_windowModel.move(from, to);
686#endif
687 endMoveRows();
689 Q_EMIT listChanged();
690 m_modelState = IdleState;
692 INFO_MSG << " after " << toString();
693 }
695void TopLevelWindowModel::onModificationsStarted()
697 m_surfaceManagerBusy = true;
700void TopLevelWindowModel::onModificationsEnded()
702 if (m_focusedWindowChanged) {
703 setFocusedWindow(m_newlyFocusedWindow);
704 }
705 // reset
706 m_focusedWindowChanged = false;
707 m_newlyFocusedWindow = nullptr;
708 m_surfaceManagerBusy = false;
711void TopLevelWindowModel::activateTopMostWindowWithoutId(int forbiddenId)
713 DEBUG_MSG << "(" << forbiddenId << ")";
715 for (int i = 0; i < m_windowModel.count(); ++i) {
716 Window *window = m_windowModel[i].window;
717 if (window->id() != forbiddenId) {
718 window->activate();
719 break;
720 }
721 }
724void TopLevelWindowModel::closeAllWindows()
726 m_closingAllApps = true;
727 for (auto win : m_windowModel) {
728 win.window->close();
729 }
731 // This is done after the for loop in the unlikely event that
732 // an app starts in between this
733 if (m_windowModel.isEmpty()) {
734 Q_EMIT closedAllWindows();
735 }
738bool TopLevelWindowModel::rootFocus()
740 return !m_nullWindow->focused();
743void TopLevelWindowModel::setRootFocus(bool focus)
745 INFO_MSG << "(" << focus << "), surfaceManagerBusy is " << m_surfaceManagerBusy;
747 if (m_surfaceManagerBusy) {
748 // Something else is probably being focused already, let's not add to
749 // the noise.
750 return;
751 }
753 if (focus) {
754 // Give focus back to previous focused window, only if null window is focused.
755 // If null window is not focused, a different app had taken the focus and we
756 // should repect that, or if a pendingActivation is going on.
757 if (m_previousWindow && !m_previousWindow->focused() && !m_pendingActivation &&
758 m_nullWindow == m_focusedWindow && m_previousWindow != m_nullWindow) {
759 m_previousWindow->activate();
760 } else if (!m_pendingActivation) {
761 // The previous window does not exist any more, focus top window.
762 activateTopMostWindowWithoutId(-1);
763 }
764 } else {
765 if (!m_nullWindow->focused()) {
766 m_nullWindow->activate();
767 }
768 }
771// Pending Activation will block refocus of previous focused window
772// this is needed since surface activation with miral is async,
773// and activation of placeholder is sync. This causes a race condition
774// between placeholder and prev window. This results in prev window
775// gets focused, as it will always be later than the placeholder.
776void TopLevelWindowModel::pendingActivation()
778 m_pendingActivation = true;