Bug 617052 - Use ITaskbarList2::MarkFullscreenWindow for proper windows taskbar integration. r=jmathies

This commit is contained in:
Brian R. Bondy 2011-09-01 10:15:09 -04:00
parent 2aa4803a10
commit 7971ff4bfd
3 changed files with 76 additions and 7 deletions

View File

@ -83,7 +83,7 @@ interface nsIDOMWindow;
* See nsIJumpListBuilder for more information.
*/
[scriptable, uuid(a25ad3ed-1ded-4473-bb6e-bf8b89d88949)]
[scriptable, uuid(9fc572db-1089-4d43-9121-f4833d77a2df)]
interface nsIWinTaskbar : nsISupports
{
/**
@ -143,7 +143,7 @@ interface nsIWinTaskbar : nsISupports
* should make use of a single instance of nsIJumpListBuilder for building lists
* within an application.
*
* @thow NS_ERROR_ALREADY_INITIALIZED if an nsIJumpListBuilder instance is
* @throw NS_ERROR_ALREADY_INITIALIZED if an nsIJumpListBuilder instance is
* currently building a list.
*/
nsIJumpListBuilder createJumpListBuilder();
@ -167,10 +167,35 @@ interface nsIWinTaskbar : nsISupports
* Note, when a window changes taskbar window stacks, it is placed at the
* bottom of the new stack.
*
* @thow NS_ERROR_INVALID_ARG if the window is not a valid top level window
* @throw NS_ERROR_INVALID_ARG if the window is not a valid top level window
* associated with a widget.
* @thow NS_ERROR_FAILURE if the property on the window could not be set.
* @thow NS_ERROR_UNEXPECTED for general failures.
* @throw NS_ERROR_FAILURE if the property on the window could not be set.
* @throw NS_ERROR_UNEXPECTED for general failures.
*/
void setGroupIdForWindow(in nsIDOMWindow aParent, in AString aIdentifier);
/**
* Notify the taskbar that a window is about to enter full screen mode.
*
* A Windows autohide taskbar will not behave correctly in all cases if
* it is not notified when full screen operations start and end.
*
* @throw NS_ERROR_INVALID_ARG if the window is not a valid top level window
* @throw NS_ERROR_UNEXPECTED for general failures.
* @throw NS_ERROR_NOT_AVAILABLE if the taskbar cannot be obtained.
*/
void prepareFullScreen(in nsIDOMWindow aWindow, in boolean aFullScreen);
/**
* Notify the taskbar that a window identified by its HWND is about to enter
* full screen mode.
*
* A Windows autohide taskbar will not behave correctly in all cases if
* it is not notified when full screen operations start and end.
*
* @throw NS_ERROR_INVALID_ARG if the window is not a valid top level window
* @throw NS_ERROR_UNEXPECTED for general failures.
* @throw NS_ERROR_NOT_AVAILABLE if the taskbar cannot be obtained.
*/
[noscript] void prepareFullScreenHWND(in voidPtr aWindow, in boolean aFullScreen);
};

View File

@ -441,6 +441,37 @@ WinTaskbar::SetGroupIdForWindow(nsIDOMWindow *aParent,
return SetWindowAppUserModelProp(aParent, nsString(aIdentifier));
}
/* void prepareFullScreen(in nsIDOMWindow aWindow, in boolean aFullScreen); */
NS_IMETHODIMP
WinTaskbar::PrepareFullScreen(nsIDOMWindow *aWindow, PRBool aFullScreen) {
NS_ENSURE_ARG_POINTER(aWindow);
HWND toplevelHWND = ::GetAncestor(GetHWNDFromDOMWindow(aWindow), GA_ROOT);
if (!toplevelHWND)
return NS_ERROR_INVALID_ARG;
return PrepareFullScreenHWND(toplevelHWND, aFullScreen);
}
/* void prepareFullScreen(in voidPtr aWindow, in boolean aFullScreen); */
NS_IMETHODIMP
WinTaskbar::PrepareFullScreenHWND(void *aHWND, PRBool aFullScreen) {
if (!Initialize())
return NS_ERROR_NOT_AVAILABLE;
NS_ENSURE_ARG_POINTER(aHWND);
if (!::IsWindow((HWND)aHWND))
return NS_ERROR_INVALID_ARG;
HRESULT hr = mTaskbar->MarkFullscreenWindow((HWND)aHWND, aFullScreen);
if (FAILED(hr)) {
return NS_ERROR_UNEXPECTED;
}
return NS_OK;
}
} // namespace widget
} // namespace mozilla

View File

@ -187,9 +187,8 @@
#endif // !defined(WINABLEAPI)
#endif // defined(ACCESSIBILITY)
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_WIN7
#include "nsIWinTaskbar.h"
#endif
#define NS_TASKBAR_CONTRACTID "@mozilla.org/windows-taskbar;1"
#if defined(NS_ENABLE_TSF)
#include "nsTextStore.h"
@ -2703,12 +2702,21 @@ NS_METHOD nsWindow::Invalidate(const nsIntRect & aRect, PRBool aIsSynchronous)
NS_IMETHODIMP
nsWindow::MakeFullScreen(PRBool aFullScreen)
{
// taskbarInfo will be NULL pre Windows 7 until Bug 680227 is resolved.
nsCOMPtr<nsIWinTaskbar> taskbarInfo =
do_GetService(NS_TASKBAR_CONTRACTID);
mFullscreenMode = aFullScreen;
if (aFullScreen) {
if (mSizeMode == nsSizeMode_Fullscreen)
return NS_OK;
mOldSizeMode = mSizeMode;
SetSizeMode(nsSizeMode_Fullscreen);
// Notify the taskbar that we will be entering full screen mode.
if (taskbarInfo) {
taskbarInfo->PrepareFullScreenHWND(mWnd, TRUE);
}
} else {
SetSizeMode(mOldSizeMode);
}
@ -2729,6 +2737,11 @@ nsWindow::MakeFullScreen(PRBool aFullScreen)
Invalidate(PR_FALSE);
}
// Notify the taskbar that we have exited full screen mode.
if (!aFullScreen && taskbarInfo) {
taskbarInfo->PrepareFullScreenHWND(mWnd, FALSE);
}
// Let the dom know via web shell window
nsSizeModeEvent event(PR_TRUE, NS_SIZEMODE, this);
event.mSizeMode = mSizeMode;