Backed out changeset 8517afe50156 (bug 540456) for reftest failures.
[gecko.git] / widget / windows / nsToolkit.h
blob5a983bd5316e848a58746f40fedb22e652898dd8
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
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;
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
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;
89 #endif // TOOLKIT_H