2009-10-06 06:26:54 +04:00
|
|
|
/* vim: se cin sw=2 ts=2 et : */
|
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2012-05-21 15:12:37 +04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-10-06 06:26:54 +04:00
|
|
|
|
|
|
|
#ifndef __mozilla_widget_TaskbarPreview_h__
|
|
|
|
#define __mozilla_widget_TaskbarPreview_h__
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include <shobjidl.h>
|
2013-12-16 04:00:54 +04:00
|
|
|
#undef LogSeverity // SetupAPI.h #defines this as DWORD
|
2009-10-06 06:26:54 +04:00
|
|
|
|
2016-04-19 23:51:25 +03:00
|
|
|
#include "mozilla/RefPtr.h"
|
2009-10-06 06:26:54 +04:00
|
|
|
#include <nsITaskbarPreview.h>
|
2016-01-12 20:08:34 +03:00
|
|
|
#include <nsITaskbarPreviewController.h>
|
2009-10-06 06:26:54 +04:00
|
|
|
#include <nsString.h>
|
2018-10-31 23:39:03 +03:00
|
|
|
#include <nsIWeakReferenceUtils.h>
|
2009-10-06 06:26:54 +04:00
|
|
|
#include <nsIDocShell.h>
|
|
|
|
#include "WindowHook.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace widget {
|
|
|
|
|
2016-01-12 20:08:34 +03:00
|
|
|
class TaskbarPreviewCallback;
|
|
|
|
|
2009-10-06 06:26:54 +04:00
|
|
|
class TaskbarPreview : public nsITaskbarPreview {
|
|
|
|
public:
|
|
|
|
TaskbarPreview(ITaskbarList4* aTaskbar,
|
|
|
|
nsITaskbarPreviewController* aController, HWND aHWND,
|
|
|
|
nsIDocShell* aShell);
|
2020-09-29 00:22:11 +03:00
|
|
|
virtual nsresult Init();
|
2009-10-06 06:26:54 +04:00
|
|
|
|
2016-01-12 20:08:34 +03:00
|
|
|
friend class TaskbarPreviewCallback;
|
|
|
|
|
2009-10-06 06:26:54 +04:00
|
|
|
NS_DECL_NSITASKBARPREVIEW
|
|
|
|
|
|
|
|
protected:
|
2014-07-15 22:57:14 +04:00
|
|
|
virtual ~TaskbarPreview();
|
|
|
|
|
2009-10-06 06:26:54 +04:00
|
|
|
// Called to update ITaskbarList4 dependent properties
|
|
|
|
virtual nsresult UpdateTaskbarProperties();
|
|
|
|
|
|
|
|
// Invoked when the preview is made visible
|
|
|
|
virtual nsresult Enable();
|
|
|
|
// Invoked when the preview is made invisible
|
|
|
|
virtual nsresult Disable();
|
|
|
|
|
|
|
|
// Detaches this preview from the nsWindow instance it's tied to
|
2010-04-21 23:09:59 +04:00
|
|
|
virtual void DetachFromNSWindow();
|
2009-10-06 06:26:54 +04:00
|
|
|
|
2011-09-28 18:02:36 +04:00
|
|
|
// Determines if the window is available and a destroy has not yet started
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsWindowAvailable() const;
|
2011-09-28 18:02:36 +04:00
|
|
|
|
2009-10-06 06:26:54 +04:00
|
|
|
// Marks this preview as being active
|
2011-09-29 10:19:26 +04:00
|
|
|
virtual nsresult ShowActive(bool active) = 0;
|
2009-10-06 06:26:54 +04:00
|
|
|
// Gets a reference to the window used to handle the preview messages
|
|
|
|
virtual HWND& PreviewWindow() = 0;
|
|
|
|
|
|
|
|
// Window procedure for the PreviewWindow (hooked for window previews)
|
|
|
|
virtual LRESULT WndProc(UINT nMsg, WPARAM wParam, LPARAM lParam);
|
|
|
|
|
|
|
|
// Returns whether or not the taskbar icon has been created for mWnd The
|
|
|
|
// ITaskbarList4 API requires that we wait until the icon has been created
|
|
|
|
// before we can call its methods.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool CanMakeTaskbarCalls();
|
2009-10-06 06:26:54 +04:00
|
|
|
|
|
|
|
// Gets the WindowHook for the nsWindow
|
2020-09-29 00:22:11 +03:00
|
|
|
WindowHook* GetWindowHook();
|
2009-10-06 06:26:54 +04:00
|
|
|
|
|
|
|
// Enables/disables custom drawing for the given window
|
2011-09-29 10:19:26 +04:00
|
|
|
static void EnableCustomDrawing(HWND aHWND, bool aEnable);
|
2009-10-06 06:26:54 +04:00
|
|
|
|
|
|
|
// MSCOM Taskbar interface
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ITaskbarList4> mTaskbar;
|
2009-10-06 06:26:54 +04:00
|
|
|
// Controller for this preview
|
|
|
|
nsCOMPtr<nsITaskbarPreviewController> mController;
|
|
|
|
// The HWND to the nsWindow that this object previews
|
|
|
|
HWND mWnd;
|
|
|
|
// Whether or not this preview is visible
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mVisible;
|
2009-10-06 06:26:54 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Called when the tooltip should be updated
|
|
|
|
nsresult UpdateTooltip();
|
|
|
|
|
|
|
|
// Requests the controller to draw into a canvas of the given width and
|
|
|
|
// height. The resulting bitmap is sent to the DWM to display.
|
2012-08-22 19:56:38 +04:00
|
|
|
void DrawBitmap(uint32_t width, uint32_t height, bool isPreview);
|
2009-10-06 06:26:54 +04:00
|
|
|
|
|
|
|
// WindowHook procedure for hooking mWnd
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool MainWindowHook(void* aContext, HWND hWnd, UINT nMsg,
|
2009-10-06 06:26:54 +04:00
|
|
|
WPARAM wParam, LPARAM lParam, LRESULT* aResult);
|
|
|
|
|
|
|
|
// Docshell corresponding to the <window> the nsWindow contains
|
|
|
|
nsWeakPtr mDocShell;
|
|
|
|
nsString mTooltip;
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
// The preview currently marked as active in the taskbar. nullptr if no
|
2009-10-06 06:26:54 +04:00
|
|
|
// preview is active (some other window is).
|
|
|
|
static TaskbarPreview* sActivePreview;
|
|
|
|
};
|
|
|
|
|
2016-01-12 20:08:34 +03:00
|
|
|
/*
|
|
|
|
* Callback object TaskbarPreview hands to preview controllers when we
|
|
|
|
* request async thumbnail or live preview images. Controllers invoke
|
|
|
|
* this interface once they have aquired the requested image.
|
|
|
|
*/
|
|
|
|
class TaskbarPreviewCallback : public nsITaskbarPreviewCallback {
|
|
|
|
public:
|
|
|
|
TaskbarPreviewCallback() : mIsThumbnail(true) {}
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSITASKBARPREVIEWCALLBACK
|
|
|
|
|
|
|
|
void SetPreview(TaskbarPreview* aPreview) { mPreview = aPreview; }
|
|
|
|
|
|
|
|
void SetIsPreview() { mIsThumbnail = false; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~TaskbarPreviewCallback() {}
|
|
|
|
|
|
|
|
private:
|
|
|
|
RefPtr<TaskbarPreview> mPreview;
|
|
|
|
bool mIsThumbnail;
|
|
|
|
};
|
|
|
|
|
2009-10-06 06:26:54 +04:00
|
|
|
} // namespace widget
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif /* __mozilla_widget_TaskbarPreview_h__ */
|