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