2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2011-11-03 20:39:07 +00:00
|
|
|
#ifndef nsToolkit_h__
|
|
|
|
#define nsToolkit_h__
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
#include "nsdefs.h"
|
|
|
|
|
2005-02-27 17:52:44 +00:00
|
|
|
#include "nsITimer.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2011-12-14 21:22:46 +00:00
|
|
|
#include <windows.h>
|
2006-04-05 23:21:57 +00:00
|
|
|
|
2008-12-30 05:39:24 +00:00
|
|
|
// Avoid including windowsx.h to prevent macro pollution
|
|
|
|
#ifndef GET_X_LPARAM
|
|
|
|
#define GET_X_LPARAM(pt) (short(LOWORD(pt)))
|
|
|
|
#endif
|
|
|
|
#ifndef GET_Y_LPARAM
|
|
|
|
#define GET_Y_LPARAM(pt) (short(HIWORD(pt)))
|
|
|
|
#endif
|
|
|
|
|
1998-04-14 23:20:49 +00:00
|
|
|
/**
|
|
|
|
* Makes sure exit/enter mouse messages are always dispatched.
|
|
|
|
* In the case where the mouse has exited the outer most window the
|
|
|
|
* only way to tell if it has exited is to set a timer and look at the
|
|
|
|
* mouse pointer to see if it is within the outer most window.
|
|
|
|
*/
|
|
|
|
|
2005-03-11 18:46:56 +00:00
|
|
|
class MouseTrailer
|
|
|
|
{
|
1998-04-13 20:24:54 +00:00
|
|
|
public:
|
2005-12-02 12:08:32 +00:00
|
|
|
HWND GetMouseTrailerWindow() { return mMouseTrailerWindow; }
|
|
|
|
HWND GetCaptureWindow() { return mCaptureWindow; }
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2005-12-02 12:08:32 +00:00
|
|
|
void SetMouseTrailerWindow(HWND aWnd);
|
|
|
|
void SetCaptureWindow(HWND aWnd);
|
2011-10-02 02:16:19 +00:00
|
|
|
void Disable() { mEnabled = false; DestroyTimer(); }
|
|
|
|
void Enable() { mEnabled = true; CreateTimer(); }
|
2005-03-11 18:46:56 +00:00
|
|
|
void DestroyTimer();
|
1999-09-09 13:38:30 +00:00
|
|
|
|
2005-03-11 18:46:56 +00:00
|
|
|
MouseTrailer();
|
2006-02-22 21:08:40 +00:00
|
|
|
~MouseTrailer();
|
|
|
|
private:
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2005-03-11 18:46:56 +00:00
|
|
|
nsresult CreateTimer();
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2005-03-11 18:46:56 +00:00
|
|
|
static void TimerProc(nsITimer* aTimer, void* aClosure);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2005-12-02 12:08:32 +00:00
|
|
|
// Information for mouse enter/exit events
|
|
|
|
HWND mMouseTrailerWindow;
|
|
|
|
HWND mCaptureWindow;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mIsInCaptureMode;
|
|
|
|
bool mEnabled;
|
2005-03-11 18:46:56 +00:00
|
|
|
nsCOMPtr<nsITimer> mTimer;
|
1998-04-13 20:24:54 +00:00
|
|
|
};
|
|
|
|
|
2011-11-03 20:39:07 +00:00
|
|
|
/**
|
|
|
|
* Wrapper around the thread running the message pump.
|
|
|
|
* The toolkit abstraction is necessary because the message pump must
|
|
|
|
* execute within the same thread that created the widget under Win32.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class nsToolkit
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsToolkit();
|
|
|
|
|
|
|
|
private:
|
|
|
|
~nsToolkit();
|
|
|
|
|
|
|
|
public:
|
|
|
|
static nsToolkit* GetToolkit();
|
|
|
|
|
|
|
|
static HINSTANCE mDllInstance;
|
|
|
|
static MouseTrailer *gMouseTrailer;
|
|
|
|
|
|
|
|
static void Startup(HMODULE hModule);
|
|
|
|
static void Shutdown();
|
|
|
|
static void StartAllowingD3D9();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static nsToolkit* gToolkit;
|
|
|
|
|
|
|
|
nsCOMPtr<nsITimer> mD3D9Timer;
|
|
|
|
MouseTrailer mMouseTrailer;
|
|
|
|
};
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
#endif // TOOLKIT_H
|