widget/windows/nsToolkit.h

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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

mercurial