widget/windows/nsToolkit.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef nsToolkit_h__
     7 #define nsToolkit_h__
     9 #include "nsdefs.h"
    11 #include "nsITimer.h"
    12 #include "nsCOMPtr.h"
    13 #include <windows.h>
    15 // Avoid including windowsx.h to prevent macro pollution
    16 #ifndef GET_X_LPARAM
    17 #define GET_X_LPARAM(pt) (short(LOWORD(pt)))
    18 #endif
    19 #ifndef GET_Y_LPARAM
    20 #define GET_Y_LPARAM(pt) (short(HIWORD(pt)))
    21 #endif
    23 /**
    24  * Makes sure exit/enter mouse messages are always dispatched.
    25  * In the case where the mouse has exited the outer most window the
    26  * only way to tell if it has exited is to set a timer and look at the
    27  * mouse pointer to see if it is within the outer most window.
    28  */ 
    30 class MouseTrailer 
    31 {
    32 public:
    33     HWND                  GetMouseTrailerWindow() { return mMouseTrailerWindow; }
    34     HWND                  GetCaptureWindow() { return mCaptureWindow; }
    36     void                  SetMouseTrailerWindow(HWND aWnd);
    37     void                  SetCaptureWindow(HWND aWnd);
    38     void                  Disable() { mEnabled = false; DestroyTimer(); }
    39     void                  Enable() { mEnabled = true; CreateTimer(); }
    40     void                  DestroyTimer();
    42                           MouseTrailer();
    43                           ~MouseTrailer();
    44 private:
    46     nsresult              CreateTimer();
    48     static void           TimerProc(nsITimer* aTimer, void* aClosure);
    50     // Information for mouse enter/exit events
    51     HWND                  mMouseTrailerWindow;
    52     HWND                  mCaptureWindow;
    53     bool                  mIsInCaptureMode;
    54     bool                  mEnabled;
    55     nsCOMPtr<nsITimer>    mTimer;
    56 };
    58 /**
    59  * Wrapper around the thread running the message pump.
    60  * The toolkit abstraction is necessary because the message pump must
    61  * execute within the same thread that created the widget under Win32.
    62  */ 
    64 class nsToolkit
    65 {
    66 public:
    67     nsToolkit();
    69 private:
    70     ~nsToolkit();
    72 public:
    73     static nsToolkit* GetToolkit();
    75     static HINSTANCE mDllInstance;
    76     static MouseTrailer *gMouseTrailer;
    78     static void Startup(HMODULE hModule);
    79     static void Shutdown();
    80     static void StartAllowingD3D9();
    82 protected:
    83     static nsToolkit* gToolkit;
    85     nsCOMPtr<nsITimer> mD3D9Timer;
    86     MouseTrailer mMouseTrailer;
    87 };
    89 #endif  // TOOLKIT_H

mercurial