Bug 1861709 replace AudioCallbackDriver::ThreadRunning() assertions that mean to...
[gecko.git] / widget / windows / TaskbarPreview.h
blobca21e3eeb8e10e03182f62554323f30eb3aeac93
1 /* vim: se cin sw=2 ts=2 et : */
2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #ifndef __mozilla_widget_TaskbarPreview_h__
9 #define __mozilla_widget_TaskbarPreview_h__
11 #include <windows.h>
12 #include <shobjidl.h>
13 #undef LogSeverity // SetupAPI.h #defines this as DWORD
15 #include "mozilla/RefPtr.h"
16 #include <nsITaskbarPreview.h>
17 #include <nsITaskbarPreviewController.h>
18 #include <nsString.h>
19 #include <nsIWeakReferenceUtils.h>
20 #include <nsIDocShell.h>
21 #include "WindowHook.h"
23 namespace mozilla {
24 namespace widget {
26 class TaskbarPreviewCallback;
28 class TaskbarPreview : public nsITaskbarPreview {
29 public:
30 TaskbarPreview(ITaskbarList4* aTaskbar,
31 nsITaskbarPreviewController* aController, HWND aHWND,
32 nsIDocShell* aShell);
33 virtual nsresult Init();
35 friend class TaskbarPreviewCallback;
37 NS_DECL_NSITASKBARPREVIEW
39 protected:
40 virtual ~TaskbarPreview();
42 // Called to update ITaskbarList4 dependent properties
43 virtual nsresult UpdateTaskbarProperties();
45 // Invoked when the preview is made visible
46 virtual nsresult Enable();
47 // Invoked when the preview is made invisible
48 virtual nsresult Disable();
50 // Detaches this preview from the nsWindow instance it's tied to
51 virtual void DetachFromNSWindow();
53 // Determines if the window is available and a destroy has not yet started
54 bool IsWindowAvailable() const;
56 // Marks this preview as being active
57 virtual nsresult ShowActive(bool active) = 0;
58 // Gets a reference to the window used to handle the preview messages
59 virtual HWND& PreviewWindow() = 0;
61 // Window procedure for the PreviewWindow (hooked for window previews)
62 virtual LRESULT WndProc(UINT nMsg, WPARAM wParam, LPARAM lParam);
64 // Returns whether or not the taskbar icon has been created for mWnd The
65 // ITaskbarList4 API requires that we wait until the icon has been created
66 // before we can call its methods.
67 bool CanMakeTaskbarCalls();
69 // Gets the WindowHook for the nsWindow
70 WindowHook* GetWindowHook();
72 // Enables/disables custom drawing for the given window
73 static void EnableCustomDrawing(HWND aHWND, bool aEnable);
75 // MSCOM Taskbar interface
76 RefPtr<ITaskbarList4> mTaskbar;
77 // Controller for this preview
78 nsCOMPtr<nsITaskbarPreviewController> mController;
79 // The HWND to the nsWindow that this object previews
80 HWND mWnd;
81 // Whether or not this preview is visible
82 bool mVisible;
84 private:
85 // Called when the tooltip should be updated
86 nsresult UpdateTooltip();
88 // Requests the controller to draw into a canvas of the given width and
89 // height. The resulting bitmap is sent to the DWM to display.
90 void DrawBitmap(uint32_t width, uint32_t height, bool isPreview);
92 // WindowHook procedure for hooking mWnd
93 static bool MainWindowHook(void* aContext, HWND hWnd, UINT nMsg,
94 WPARAM wParam, LPARAM lParam, LRESULT* aResult);
96 // Docshell corresponding to the <window> the nsWindow contains
97 nsWeakPtr mDocShell;
98 nsString mTooltip;
100 // The preview currently marked as active in the taskbar. nullptr if no
101 // preview is active (some other window is).
102 static TaskbarPreview* sActivePreview;
106 * Callback object TaskbarPreview hands to preview controllers when we
107 * request async thumbnail or live preview images. Controllers invoke
108 * this interface once they have aquired the requested image.
110 class TaskbarPreviewCallback : public nsITaskbarPreviewCallback {
111 public:
112 TaskbarPreviewCallback() : mIsThumbnail(true) {}
114 NS_DECL_ISUPPORTS
115 NS_DECL_NSITASKBARPREVIEWCALLBACK
117 void SetPreview(TaskbarPreview* aPreview) { mPreview = aPreview; }
119 void SetIsPreview() { mIsThumbnail = false; }
121 protected:
122 virtual ~TaskbarPreviewCallback() {}
124 private:
125 RefPtr<TaskbarPreview> mPreview;
126 bool mIsThumbnail;
129 } // namespace widget
130 } // namespace mozilla
132 #endif /* __mozilla_widget_TaskbarPreview_h__ */