Bug 1592234 - Add window icon to PiP window r=kpatenio,mhowell

Differential Revision: https://phabricator.services.mozilla.com/D134429
This commit is contained in:
Rashelle Hopkins 2022-01-11 16:21:09 +00:00
parent 83e6733608
commit f9defb0250
5 changed files with 41 additions and 0 deletions

View File

@ -16,6 +16,13 @@ const { AppConstants } = ChromeUtils.import(
"resource://gre/modules/AppConstants.jsm"
);
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyServiceGetters(this, {
WindowsUIUtils: ["@mozilla.org/windows-ui-utils;1", "nsIWindowsUIUtils"],
});
const PLAYER_URI = "chrome://global/content/pictureinpicture/player.xhtml";
var PLAYER_FEATURES =
"chrome,titlebar=yes,alwaysontop,lockaspectratio,resizable";
@ -410,6 +417,10 @@ var PictureInPicture = {
null
);
if (Services.appinfo.OS == "WINNT") {
WindowsUIUtils.setWindowIconNoData(pipWindow);
}
return new Promise(resolve => {
pipWindow.addEventListener(
"load",

View File

@ -17,6 +17,8 @@ interface nsIWindowsUIUtils : nsISupports
void setWindowIcon(in mozIDOMWindowProxy aWindow, in imgIContainer aSmallIcon, in imgIContainer aLargeIcon);
void setWindowIconNoData(in mozIDOMWindowProxy aWindow);
/**
* Whether the OS is currently in tablet mode. Always false on
* non-Windows and on versions of Windows before win10

View File

@ -198,6 +198,20 @@ WindowsUIUtils::SetWindowIcon(mozIDOMWindowProxy* aWindow,
return NS_OK;
}
NS_IMETHODIMP
WindowsUIUtils::SetWindowIconNoData(mozIDOMWindowProxy* aWindow) {
NS_ENSURE_ARG(aWindow);
nsCOMPtr<nsIWidget> widget =
nsGlobalWindowOuter::Cast(aWindow)->GetMainWidget();
nsWindow* window = static_cast<nsWindow*>(widget.get());
window->SetSmallIconNoData();
window->SetBigIconNoData();
return NS_OK;
}
NS_IMETHODIMP
WindowsUIUtils::GetInTabletMode(bool* aResult) {
if (mInTabletMode == eTabletModeUnknown) {

View File

@ -3869,6 +3869,18 @@ void nsWindow::SetIcon(const nsAString& aIconSpec) {
#endif
}
void nsWindow::SetBigIconNoData() {
HICON bigIcon =
::LoadIconW(::GetModuleHandleW(nullptr), gStockApplicationIcon);
SetBigIcon(bigIcon);
}
void nsWindow::SetSmallIconNoData() {
HICON smallIcon =
::LoadIconW(::GetModuleHandleW(nullptr), gStockApplicationIcon);
SetSmallIcon(smallIcon);
}
/**************************************************************
*
* SECTION: nsIWidget::WidgetToScreenOffset

View File

@ -301,6 +301,8 @@ class nsWindow final : public nsWindowBase {
void SetSmallIcon(HICON aIcon);
void SetBigIcon(HICON aIcon);
void SetSmallIconNoData();
void SetBigIconNoData();
static void SetIsRestoringSession(const bool aIsRestoringSession) {
sIsRestoringSession = aIsRestoringSession;