зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1496834 - Set focus on Firefox since focus is moved to another process. r=aklotz
When clicking native toast on Windows 10, focus moves to another process, So we have to set focus on Firefox process. Differential Revision: https://phabricator.services.mozilla.com/D47398 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
ae7651951f
Коммит
3c68f51a44
|
@ -13,8 +13,12 @@
|
|||
#include "nsIStringBundle.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIUUIDGenerator.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIWindowMediator.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsProxyRelease.h"
|
||||
#include "WidgetUtils.h"
|
||||
#include "WinTaskbar.h"
|
||||
#include "WinUtils.h"
|
||||
|
||||
|
@ -432,6 +436,23 @@ ToastNotificationHandler::OnActivate(IToastNotification* notification,
|
|||
} else if (argString.EqualsLiteral("snooze")) {
|
||||
mAlertListener->Observe(nullptr, "alertdisablecallback", mCookie.get());
|
||||
} else if (mClickable) {
|
||||
// When clicking toast, focus moves to another process, but we want to set
|
||||
// focus on Firefox process.
|
||||
nsCOMPtr<nsIWindowMediator> winMediator(
|
||||
do_GetService(NS_WINDOWMEDIATOR_CONTRACTID));
|
||||
if (winMediator) {
|
||||
nsCOMPtr<mozIDOMWindowProxy> navWin;
|
||||
winMediator->GetMostRecentWindow(u"navigator:browser",
|
||||
getter_AddRefs(navWin));
|
||||
if (navWin) {
|
||||
nsCOMPtr<nsIWidget> widget =
|
||||
WidgetUtils::DOMWindowToWidget(nsPIDOMWindowOuter::From(navWin));
|
||||
if (widget) {
|
||||
SetForegroundWindow(
|
||||
static_cast<HWND>(widget->GetNativeData(NS_NATIVE_WINDOW)));
|
||||
}
|
||||
}
|
||||
}
|
||||
mAlertListener->Observe(nullptr, "alertclickcallback", mCookie.get());
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче