|
1 /* vim: se cin sw=2 ts=2 et : */ |
|
2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
|
3 * |
|
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/. */ |
|
7 |
|
8 #ifndef __mozilla_widget_TaskbarPreview_h__ |
|
9 #define __mozilla_widget_TaskbarPreview_h__ |
|
10 |
|
11 #include <windows.h> |
|
12 #include <shobjidl.h> |
|
13 #undef LogSeverity // SetupAPI.h #defines this as DWORD |
|
14 |
|
15 #include <nsITaskbarPreview.h> |
|
16 #include <nsAutoPtr.h> |
|
17 #include <nsString.h> |
|
18 #include <nsWeakPtr.h> |
|
19 #include <nsIDocShell.h> |
|
20 #include "WindowHook.h" |
|
21 |
|
22 namespace mozilla { |
|
23 namespace widget { |
|
24 |
|
25 class TaskbarPreview : public nsITaskbarPreview |
|
26 { |
|
27 public: |
|
28 TaskbarPreview(ITaskbarList4 *aTaskbar, nsITaskbarPreviewController *aController, HWND aHWND, nsIDocShell *aShell); |
|
29 virtual ~TaskbarPreview(); |
|
30 |
|
31 NS_DECL_NSITASKBARPREVIEW |
|
32 |
|
33 protected: |
|
34 // Called to update ITaskbarList4 dependent properties |
|
35 virtual nsresult UpdateTaskbarProperties(); |
|
36 |
|
37 // Invoked when the preview is made visible |
|
38 virtual nsresult Enable(); |
|
39 // Invoked when the preview is made invisible |
|
40 virtual nsresult Disable(); |
|
41 |
|
42 // Detaches this preview from the nsWindow instance it's tied to |
|
43 virtual void DetachFromNSWindow(); |
|
44 |
|
45 // Determines if the window is available and a destroy has not yet started |
|
46 bool IsWindowAvailable() const; |
|
47 |
|
48 // Marks this preview as being active |
|
49 virtual nsresult ShowActive(bool active) = 0; |
|
50 // Gets a reference to the window used to handle the preview messages |
|
51 virtual HWND& PreviewWindow() = 0; |
|
52 |
|
53 // Window procedure for the PreviewWindow (hooked for window previews) |
|
54 virtual LRESULT WndProc(UINT nMsg, WPARAM wParam, LPARAM lParam); |
|
55 |
|
56 // Returns whether or not the taskbar icon has been created for mWnd The |
|
57 // ITaskbarList4 API requires that we wait until the icon has been created |
|
58 // before we can call its methods. |
|
59 bool CanMakeTaskbarCalls(); |
|
60 |
|
61 // Gets the WindowHook for the nsWindow |
|
62 WindowHook &GetWindowHook(); |
|
63 |
|
64 // Enables/disables custom drawing for the given window |
|
65 static void EnableCustomDrawing(HWND aHWND, bool aEnable); |
|
66 |
|
67 // MSCOM Taskbar interface |
|
68 nsRefPtr<ITaskbarList4> mTaskbar; |
|
69 // Controller for this preview |
|
70 nsCOMPtr<nsITaskbarPreviewController> mController; |
|
71 // The HWND to the nsWindow that this object previews |
|
72 HWND mWnd; |
|
73 // Whether or not this preview is visible |
|
74 bool mVisible; |
|
75 |
|
76 private: |
|
77 // Called when the tooltip should be updated |
|
78 nsresult UpdateTooltip(); |
|
79 |
|
80 // Requests the controller to draw into a canvas of the given width and |
|
81 // height. The resulting bitmap is sent to the DWM to display. |
|
82 void DrawBitmap(uint32_t width, uint32_t height, bool isPreview); |
|
83 |
|
84 // WindowHook procedure for hooking mWnd |
|
85 static bool MainWindowHook(void *aContext, |
|
86 HWND hWnd, UINT nMsg, |
|
87 WPARAM wParam, LPARAM lParam, |
|
88 LRESULT *aResult); |
|
89 |
|
90 // Docshell corresponding to the <window> the nsWindow contains |
|
91 nsWeakPtr mDocShell; |
|
92 nsString mTooltip; |
|
93 |
|
94 // The preview currently marked as active in the taskbar. nullptr if no |
|
95 // preview is active (some other window is). |
|
96 static TaskbarPreview *sActivePreview; |
|
97 }; |
|
98 |
|
99 } // namespace widget |
|
100 } // namespace mozilla |
|
101 |
|
102 #endif /* __mozilla_widget_TaskbarPreview_h__ */ |
|
103 |