widget/windows/TaskbarPreview.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/widget/windows/TaskbarPreview.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,103 @@
     1.4 +/* vim: se cin sw=2 ts=2 et : */
     1.5 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     1.6 + *
     1.7 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
    1.10 +
    1.11 +#ifndef __mozilla_widget_TaskbarPreview_h__
    1.12 +#define __mozilla_widget_TaskbarPreview_h__
    1.13 +
    1.14 +#include <windows.h>
    1.15 +#include <shobjidl.h>
    1.16 +#undef LogSeverity // SetupAPI.h #defines this as DWORD
    1.17 +
    1.18 +#include <nsITaskbarPreview.h>
    1.19 +#include <nsAutoPtr.h>
    1.20 +#include <nsString.h>
    1.21 +#include <nsWeakPtr.h>
    1.22 +#include <nsIDocShell.h>
    1.23 +#include "WindowHook.h"
    1.24 +
    1.25 +namespace mozilla {
    1.26 +namespace widget {
    1.27 +
    1.28 +class TaskbarPreview : public nsITaskbarPreview
    1.29 +{
    1.30 +public:
    1.31 +  TaskbarPreview(ITaskbarList4 *aTaskbar, nsITaskbarPreviewController *aController, HWND aHWND, nsIDocShell *aShell);
    1.32 +  virtual ~TaskbarPreview();
    1.33 +
    1.34 +  NS_DECL_NSITASKBARPREVIEW
    1.35 +
    1.36 +protected:
    1.37 +  // Called to update ITaskbarList4 dependent properties
    1.38 +  virtual nsresult UpdateTaskbarProperties();
    1.39 +
    1.40 +  // Invoked when the preview is made visible
    1.41 +  virtual nsresult Enable();
    1.42 +  // Invoked when the preview is made invisible
    1.43 +  virtual nsresult Disable();
    1.44 +
    1.45 +  // Detaches this preview from the nsWindow instance it's tied to
    1.46 +  virtual void DetachFromNSWindow();
    1.47 +
    1.48 +  // Determines if the window is available and a destroy has not yet started
    1.49 +  bool IsWindowAvailable() const;
    1.50 +
    1.51 +  // Marks this preview as being active
    1.52 +  virtual nsresult ShowActive(bool active) = 0;
    1.53 +  // Gets a reference to the window used to handle the preview messages
    1.54 +  virtual HWND& PreviewWindow() = 0;
    1.55 +
    1.56 +  // Window procedure for the PreviewWindow (hooked for window previews)
    1.57 +  virtual LRESULT WndProc(UINT nMsg, WPARAM wParam, LPARAM lParam);
    1.58 +
    1.59 +  // Returns whether or not the taskbar icon has been created for mWnd The
    1.60 +  // ITaskbarList4 API requires that we wait until the icon has been created
    1.61 +  // before we can call its methods.
    1.62 +  bool CanMakeTaskbarCalls();
    1.63 +
    1.64 +  // Gets the WindowHook for the nsWindow
    1.65 +  WindowHook &GetWindowHook();
    1.66 +
    1.67 +  // Enables/disables custom drawing for the given window
    1.68 +  static void EnableCustomDrawing(HWND aHWND, bool aEnable);
    1.69 +
    1.70 +  // MSCOM Taskbar interface
    1.71 +  nsRefPtr<ITaskbarList4> mTaskbar;
    1.72 +  // Controller for this preview
    1.73 +  nsCOMPtr<nsITaskbarPreviewController> mController;
    1.74 +  // The HWND to the nsWindow that this object previews
    1.75 +  HWND                    mWnd;
    1.76 +  // Whether or not this preview is visible
    1.77 +  bool                    mVisible;
    1.78 +
    1.79 +private:
    1.80 +  // Called when the tooltip should be updated
    1.81 +  nsresult UpdateTooltip();
    1.82 +
    1.83 +  // Requests the controller to draw into a canvas of the given width and
    1.84 +  // height. The resulting bitmap is sent to the DWM to display.
    1.85 +  void DrawBitmap(uint32_t width, uint32_t height, bool isPreview);
    1.86 +
    1.87 +  // WindowHook procedure for hooking mWnd
    1.88 +  static bool MainWindowHook(void *aContext,
    1.89 +                               HWND hWnd, UINT nMsg,
    1.90 +                               WPARAM wParam, LPARAM lParam,
    1.91 +                               LRESULT *aResult);
    1.92 +
    1.93 +  // Docshell corresponding to the <window> the nsWindow contains
    1.94 +  nsWeakPtr               mDocShell;
    1.95 +  nsString                mTooltip;
    1.96 +
    1.97 +  // The preview currently marked as active in the taskbar. nullptr if no
    1.98 +  // preview is active (some other window is).
    1.99 +  static TaskbarPreview  *sActivePreview;
   1.100 +};
   1.101 +
   1.102 +} // namespace widget
   1.103 +} // namespace mozilla
   1.104 +
   1.105 +#endif /* __mozilla_widget_TaskbarPreview_h__ */
   1.106 +

mercurial