widget/windows/nsWindow.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

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 Window_h__
michael@0 7 #define Window_h__
michael@0 8
michael@0 9 /*
michael@0 10 * nsWindow - Native window management and event handling.
michael@0 11 */
michael@0 12
michael@0 13 #include "nsAutoPtr.h"
michael@0 14 #include "nsBaseWidget.h"
michael@0 15 #include "nsWindowBase.h"
michael@0 16 #include "nsdefs.h"
michael@0 17 #include "nsIdleService.h"
michael@0 18 #include "nsToolkit.h"
michael@0 19 #include "nsString.h"
michael@0 20 #include "nsTArray.h"
michael@0 21 #include "gfxWindowsPlatform.h"
michael@0 22 #include "gfxWindowsSurface.h"
michael@0 23 #include "nsWindowDbg.h"
michael@0 24 #include "cairo.h"
michael@0 25 #include "nsITimer.h"
michael@0 26 #include "nsRegion.h"
michael@0 27 #include "mozilla/EventForwards.h"
michael@0 28 #include "mozilla/MouseEvents.h"
michael@0 29 #include "mozilla/TimeStamp.h"
michael@0 30 #include "nsMargin.h"
michael@0 31
michael@0 32 #include "nsWinGesture.h"
michael@0 33
michael@0 34 #include "WindowHook.h"
michael@0 35 #include "TaskbarWindowPreview.h"
michael@0 36
michael@0 37 #ifdef ACCESSIBILITY
michael@0 38 #include "oleacc.h"
michael@0 39 #include "mozilla/a11y/Accessible.h"
michael@0 40 #endif
michael@0 41
michael@0 42 #include "nsUXThemeData.h"
michael@0 43
michael@0 44 #include "nsIDOMMouseEvent.h"
michael@0 45
michael@0 46 #include "nsIIdleServiceInternal.h"
michael@0 47
michael@0 48 /**
michael@0 49 * Forward class definitions
michael@0 50 */
michael@0 51
michael@0 52 class nsNativeDragTarget;
michael@0 53 class nsIRollupListener;
michael@0 54 class nsIFile;
michael@0 55 class nsIntRegion;
michael@0 56 class imgIContainer;
michael@0 57
michael@0 58 namespace mozilla {
michael@0 59 namespace widget {
michael@0 60 class NativeKey;
michael@0 61 class ModifierKeyState;
michael@0 62 struct MSGResult;
michael@0 63 } // namespace widget
michael@0 64 } // namespacw mozilla;
michael@0 65
michael@0 66 /**
michael@0 67 * Native WIN32 window wrapper.
michael@0 68 */
michael@0 69
michael@0 70 class nsWindow : public nsWindowBase
michael@0 71 {
michael@0 72 typedef mozilla::TimeStamp TimeStamp;
michael@0 73 typedef mozilla::TimeDuration TimeDuration;
michael@0 74 typedef mozilla::widget::WindowHook WindowHook;
michael@0 75 typedef mozilla::widget::TaskbarWindowPreview TaskbarWindowPreview;
michael@0 76 typedef mozilla::widget::NativeKey NativeKey;
michael@0 77 typedef mozilla::widget::MSGResult MSGResult;
michael@0 78 public:
michael@0 79 nsWindow();
michael@0 80 virtual ~nsWindow();
michael@0 81
michael@0 82 NS_DECL_ISUPPORTS_INHERITED
michael@0 83
michael@0 84 friend class nsWindowGfx;
michael@0 85
michael@0 86 // nsWindowBase
michael@0 87 virtual void InitEvent(mozilla::WidgetGUIEvent& aEvent,
michael@0 88 nsIntPoint* aPoint = nullptr) MOZ_OVERRIDE;
michael@0 89 virtual bool DispatchWindowEvent(mozilla::WidgetGUIEvent* aEvent) MOZ_OVERRIDE;
michael@0 90 virtual bool DispatchKeyboardEvent(mozilla::WidgetGUIEvent* aEvent) MOZ_OVERRIDE;
michael@0 91 virtual bool DispatchScrollEvent(mozilla::WidgetGUIEvent* aEvent) MOZ_OVERRIDE;
michael@0 92 virtual nsWindowBase* GetParentWindowBase(bool aIncludeOwner) MOZ_OVERRIDE;
michael@0 93 virtual bool IsTopLevelWidget() MOZ_OVERRIDE { return mIsTopWidgetWindow; }
michael@0 94
michael@0 95 // nsIWidget interface
michael@0 96 NS_IMETHOD Create(nsIWidget *aParent,
michael@0 97 nsNativeWidget aNativeParent,
michael@0 98 const nsIntRect &aRect,
michael@0 99 nsDeviceContext *aContext,
michael@0 100 nsWidgetInitData *aInitData = nullptr);
michael@0 101 NS_IMETHOD Destroy();
michael@0 102 NS_IMETHOD SetParent(nsIWidget *aNewParent);
michael@0 103 virtual nsIWidget* GetParent(void);
michael@0 104 virtual float GetDPI();
michael@0 105 virtual double GetDefaultScaleInternal();
michael@0 106 NS_IMETHOD Show(bool bState);
michael@0 107 virtual bool IsVisible() const;
michael@0 108 NS_IMETHOD ConstrainPosition(bool aAllowSlop, int32_t *aX, int32_t *aY);
michael@0 109 virtual void SetSizeConstraints(const SizeConstraints& aConstraints);
michael@0 110 NS_IMETHOD Move(double aX, double aY);
michael@0 111 NS_IMETHOD Resize(double aWidth, double aHeight, bool aRepaint);
michael@0 112 NS_IMETHOD Resize(double aX, double aY, double aWidth, double aHeight, bool aRepaint);
michael@0 113 NS_IMETHOD BeginResizeDrag(mozilla::WidgetGUIEvent* aEvent,
michael@0 114 int32_t aHorizontal,
michael@0 115 int32_t aVertical);
michael@0 116 NS_IMETHOD PlaceBehind(nsTopLevelWidgetZPlacement aPlacement, nsIWidget *aWidget, bool aActivate);
michael@0 117 NS_IMETHOD SetSizeMode(int32_t aMode);
michael@0 118 NS_IMETHOD Enable(bool aState);
michael@0 119 virtual bool IsEnabled() const;
michael@0 120 NS_IMETHOD SetFocus(bool aRaise);
michael@0 121 NS_IMETHOD GetBounds(nsIntRect &aRect);
michael@0 122 NS_IMETHOD GetScreenBounds(nsIntRect &aRect);
michael@0 123 NS_IMETHOD GetClientBounds(nsIntRect &aRect);
michael@0 124 virtual nsIntPoint GetClientOffset();
michael@0 125 void SetBackgroundColor(const nscolor &aColor);
michael@0 126 NS_IMETHOD SetCursor(imgIContainer* aCursor,
michael@0 127 uint32_t aHotspotX, uint32_t aHotspotY);
michael@0 128 NS_IMETHOD SetCursor(nsCursor aCursor);
michael@0 129 virtual nsresult ConfigureChildren(const nsTArray<Configuration>& aConfigurations);
michael@0 130 NS_IMETHOD MakeFullScreen(bool aFullScreen);
michael@0 131 NS_IMETHOD HideWindowChrome(bool aShouldHide);
michael@0 132 NS_IMETHOD Invalidate(bool aEraseBackground = false,
michael@0 133 bool aUpdateNCArea = false,
michael@0 134 bool aIncludeChildren = false);
michael@0 135 NS_IMETHOD Invalidate(const nsIntRect & aRect);
michael@0 136 virtual void* GetNativeData(uint32_t aDataType);
michael@0 137 virtual void FreeNativeData(void * data, uint32_t aDataType);
michael@0 138 NS_IMETHOD SetTitle(const nsAString& aTitle);
michael@0 139 NS_IMETHOD SetIcon(const nsAString& aIconSpec);
michael@0 140 virtual nsIntPoint WidgetToScreenOffset();
michael@0 141 virtual nsIntSize ClientToWindowSize(const nsIntSize& aClientSize);
michael@0 142 NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
michael@0 143 nsEventStatus& aStatus);
michael@0 144 NS_IMETHOD EnableDragDrop(bool aEnable);
michael@0 145 NS_IMETHOD CaptureMouse(bool aCapture);
michael@0 146 NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener,
michael@0 147 bool aDoCapture);
michael@0 148 NS_IMETHOD GetAttention(int32_t aCycleCount);
michael@0 149 virtual bool HasPendingInputEvent();
michael@0 150 virtual LayerManager* GetLayerManager(PLayerTransactionChild* aShadowManager = nullptr,
michael@0 151 LayersBackend aBackendHint = mozilla::layers::LayersBackend::LAYERS_NONE,
michael@0 152 LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
michael@0 153 bool* aAllowRetaining = nullptr);
michael@0 154 gfxASurface *GetThebesSurface();
michael@0 155 NS_IMETHOD OnDefaultButtonLoaded(const nsIntRect &aButtonRect);
michael@0 156 NS_IMETHOD OverrideSystemMouseScrollSpeed(double aOriginalDeltaX,
michael@0 157 double aOriginalDeltaY,
michael@0 158 double& aOverriddenDeltaX,
michael@0 159 double& aOverriddenDeltaY);
michael@0 160
michael@0 161 virtual nsresult SynthesizeNativeKeyEvent(int32_t aNativeKeyboardLayout,
michael@0 162 int32_t aNativeKeyCode,
michael@0 163 uint32_t aModifierFlags,
michael@0 164 const nsAString& aCharacters,
michael@0 165 const nsAString& aUnmodifiedCharacters);
michael@0 166 virtual nsresult SynthesizeNativeMouseEvent(nsIntPoint aPoint,
michael@0 167 uint32_t aNativeMessage,
michael@0 168 uint32_t aModifierFlags);
michael@0 169
michael@0 170 virtual nsresult SynthesizeNativeMouseMove(nsIntPoint aPoint)
michael@0 171 { return SynthesizeNativeMouseEvent(aPoint, MOUSEEVENTF_MOVE, 0); }
michael@0 172
michael@0 173 virtual nsresult SynthesizeNativeMouseScrollEvent(nsIntPoint aPoint,
michael@0 174 uint32_t aNativeMessage,
michael@0 175 double aDeltaX,
michael@0 176 double aDeltaY,
michael@0 177 double aDeltaZ,
michael@0 178 uint32_t aModifierFlags,
michael@0 179 uint32_t aAdditionalFlags);
michael@0 180 NS_IMETHOD NotifyIME(const IMENotification& aIMENotification) MOZ_OVERRIDE;
michael@0 181 NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
michael@0 182 const InputContextAction& aAction);
michael@0 183 NS_IMETHOD_(InputContext) GetInputContext();
michael@0 184 NS_IMETHOD GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState);
michael@0 185 NS_IMETHOD RegisterTouchWindow();
michael@0 186 NS_IMETHOD UnregisterTouchWindow();
michael@0 187 #ifdef MOZ_XUL
michael@0 188 virtual void SetTransparencyMode(nsTransparencyMode aMode);
michael@0 189 virtual nsTransparencyMode GetTransparencyMode();
michael@0 190 virtual void UpdateOpaqueRegion(const nsIntRegion& aOpaqueRegion);
michael@0 191 #endif // MOZ_XUL
michael@0 192 virtual nsIMEUpdatePreference GetIMEUpdatePreference();
michael@0 193 NS_IMETHOD GetNonClientMargins(nsIntMargin &margins);
michael@0 194 NS_IMETHOD SetNonClientMargins(nsIntMargin &margins);
michael@0 195 void SetDrawsInTitlebar(bool aState);
michael@0 196 mozilla::TemporaryRef<mozilla::gfx::DrawTarget> StartRemoteDrawing() MOZ_OVERRIDE;
michael@0 197 virtual void EndRemoteDrawing() MOZ_OVERRIDE;
michael@0 198
michael@0 199 virtual void UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries) MOZ_OVERRIDE;
michael@0 200
michael@0 201 /**
michael@0 202 * Event helpers
michael@0 203 */
michael@0 204 virtual bool DispatchMouseEvent(uint32_t aEventType, WPARAM wParam,
michael@0 205 LPARAM lParam,
michael@0 206 bool aIsContextMenuKey = false,
michael@0 207 int16_t aButton = mozilla::WidgetMouseEvent::eLeftButton,
michael@0 208 uint16_t aInputSource = nsIDOMMouseEvent::MOZ_SOURCE_MOUSE);
michael@0 209 virtual bool DispatchWindowEvent(mozilla::WidgetGUIEvent* aEvent,
michael@0 210 nsEventStatus& aStatus);
michael@0 211 void DispatchPendingEvents();
michael@0 212 bool DispatchPluginEvent(UINT aMessage,
michael@0 213 WPARAM aWParam,
michael@0 214 LPARAM aLParam,
michael@0 215 bool aDispatchPendingEvents);
michael@0 216
michael@0 217 void SuppressBlurEvents(bool aSuppress); // Called from nsFilePicker
michael@0 218 bool BlurEventsSuppressed();
michael@0 219 #ifdef ACCESSIBILITY
michael@0 220 /**
michael@0 221 * Return an accessible associated with the window.
michael@0 222 */
michael@0 223 mozilla::a11y::Accessible* GetAccessible();
michael@0 224 #endif // ACCESSIBILITY
michael@0 225
michael@0 226 /**
michael@0 227 * Window utilities
michael@0 228 */
michael@0 229 nsWindow* GetTopLevelWindow(bool aStopOnDialogOrPopup);
michael@0 230 WNDPROC GetPrevWindowProc() { return mPrevWndProc; }
michael@0 231 WindowHook& GetWindowHook() { return mWindowHook; }
michael@0 232 nsWindow* GetParentWindow(bool aIncludeOwner);
michael@0 233 // Get an array of all nsWindow*s on the main thread.
michael@0 234 typedef void (WindowEnumCallback)(nsWindow*);
michael@0 235 static void EnumAllWindows(WindowEnumCallback aCallback);
michael@0 236
michael@0 237 /**
michael@0 238 * Misc.
michael@0 239 */
michael@0 240 virtual bool AutoErase(HDC dc);
michael@0 241
michael@0 242 /**
michael@0 243 * Start allowing Direct3D9 to be used by widgets when GetLayerManager is
michael@0 244 * called.
michael@0 245 *
michael@0 246 * @param aReinitialize Call GetLayerManager on widgets to ensure D3D9 is
michael@0 247 * initialized, this is usually called when this function
michael@0 248 * is triggered by timeout and not user/web interaction.
michael@0 249 */
michael@0 250 static void StartAllowingD3D9(bool aReinitialize);
michael@0 251
michael@0 252 /**
michael@0 253 * AssociateDefaultIMC() associates or disassociates the default IMC for
michael@0 254 * the window.
michael@0 255 *
michael@0 256 * @param aAssociate TRUE, associates the default IMC with the window.
michael@0 257 * Otherwise, disassociates the default IMC from the
michael@0 258 * window.
michael@0 259 * @return TRUE if this method associated the default IMC with
michael@0 260 * disassociated window or disassociated the default IMC
michael@0 261 * from associated window.
michael@0 262 * Otherwise, i.e., if this method did nothing actually,
michael@0 263 * FALSE.
michael@0 264 */
michael@0 265 bool AssociateDefaultIMC(bool aAssociate);
michael@0 266
michael@0 267 bool HasTaskbarIconBeenCreated() { return mHasTaskbarIconBeenCreated; }
michael@0 268 // Called when either the nsWindow or an nsITaskbarTabPreview receives the noticiation that this window
michael@0 269 // has its icon placed on the taskbar.
michael@0 270 void SetHasTaskbarIconBeenCreated(bool created = true) { mHasTaskbarIconBeenCreated = created; }
michael@0 271
michael@0 272 // Getter/setter for the nsITaskbarWindowPreview for this nsWindow
michael@0 273 already_AddRefed<nsITaskbarWindowPreview> GetTaskbarPreview() {
michael@0 274 nsCOMPtr<nsITaskbarWindowPreview> preview(do_QueryReferent(mTaskbarPreview));
michael@0 275 return preview.forget();
michael@0 276 }
michael@0 277 void SetTaskbarPreview(nsITaskbarWindowPreview *preview) { mTaskbarPreview = do_GetWeakReference(preview); }
michael@0 278
michael@0 279 NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent);
michael@0 280
michael@0 281 // Open file picker tracking
michael@0 282 void PickerOpen();
michael@0 283 void PickerClosed();
michael@0 284
michael@0 285 bool const DestroyCalled() { return mDestroyCalled; }
michael@0 286
michael@0 287 virtual void GetPreferredCompositorBackends(nsTArray<mozilla::layers::LayersBackend>& aHints);
michael@0 288
michael@0 289 virtual bool ShouldUseOffMainThreadCompositing();
michael@0 290
michael@0 291 protected:
michael@0 292
michael@0 293 virtual void WindowUsesOMTC() MOZ_OVERRIDE;
michael@0 294
michael@0 295 // A magic number to identify the FAKETRACKPOINTSCROLLABLE window created
michael@0 296 // when the trackpoint hack is enabled.
michael@0 297 enum { eFakeTrackPointScrollableID = 0x46545053 };
michael@0 298
michael@0 299 /**
michael@0 300 * Callbacks
michael@0 301 */
michael@0 302 static LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
michael@0 303 static LRESULT CALLBACK WindowProcInternal(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
michael@0 304
michael@0 305 static BOOL CALLBACK BroadcastMsgToChildren(HWND aWnd, LPARAM aMsg);
michael@0 306 static BOOL CALLBACK BroadcastMsg(HWND aTopWindow, LPARAM aMsg);
michael@0 307 static BOOL CALLBACK DispatchStarvedPaints(HWND aTopWindow, LPARAM aMsg);
michael@0 308 static BOOL CALLBACK RegisterTouchForDescendants(HWND aTopWindow, LPARAM aMsg);
michael@0 309 static BOOL CALLBACK UnregisterTouchForDescendants(HWND aTopWindow, LPARAM aMsg);
michael@0 310 static LRESULT CALLBACK MozSpecialMsgFilter(int code, WPARAM wParam, LPARAM lParam);
michael@0 311 static LRESULT CALLBACK MozSpecialWndProc(int code, WPARAM wParam, LPARAM lParam);
michael@0 312 static LRESULT CALLBACK MozSpecialMouseProc(int code, WPARAM wParam, LPARAM lParam);
michael@0 313 static VOID CALLBACK HookTimerForPopups( HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime );
michael@0 314 static BOOL CALLBACK ClearResourcesCallback(HWND aChild, LPARAM aParam);
michael@0 315 static BOOL CALLBACK EnumAllChildWindProc(HWND aWnd, LPARAM aParam);
michael@0 316 static BOOL CALLBACK EnumAllThreadWindowProc(HWND aWnd, LPARAM aParam);
michael@0 317 static void AllowD3D9Callback(nsWindow *aWindow);
michael@0 318 static void AllowD3D9WithReinitializeCallback(nsWindow *aWindow);
michael@0 319
michael@0 320 /**
michael@0 321 * Window utilities
michael@0 322 */
michael@0 323 LPARAM lParamToScreen(LPARAM lParam);
michael@0 324 LPARAM lParamToClient(LPARAM lParam);
michael@0 325 virtual void SubclassWindow(BOOL bState);
michael@0 326 bool CanTakeFocus();
michael@0 327 bool UpdateNonClientMargins(int32_t aSizeMode = -1, bool aReflowWindow = true);
michael@0 328 void UpdateGetWindowInfoCaptionStatus(bool aActiveCaption);
michael@0 329 void ResetLayout();
michael@0 330 void InvalidateNonClientRegion();
michael@0 331 HRGN ExcludeNonClientFromPaintRegion(HRGN aRegion);
michael@0 332 static void GetMainWindowClass(nsAString& aClass);
michael@0 333 bool HasGlass() const {
michael@0 334 return mTransparencyMode == eTransparencyGlass ||
michael@0 335 mTransparencyMode == eTransparencyBorderlessGlass;
michael@0 336 }
michael@0 337 HWND GetOwnerWnd() const
michael@0 338 {
michael@0 339 return ::GetWindow(mWnd, GW_OWNER);
michael@0 340 }
michael@0 341 bool IsOwnerForegroundWindow() const
michael@0 342 {
michael@0 343 HWND owner = GetOwnerWnd();
michael@0 344 return owner && owner == ::GetForegroundWindow();
michael@0 345 }
michael@0 346 bool IsPopup() const
michael@0 347 {
michael@0 348 return mWindowType == eWindowType_popup;
michael@0 349 }
michael@0 350
michael@0 351
michael@0 352 /**
michael@0 353 * Event processing helpers
michael@0 354 */
michael@0 355 void DispatchFocusToTopLevelWindow(bool aIsActivate);
michael@0 356 bool DispatchStandardEvent(uint32_t aMsg);
michael@0 357 void RelayMouseEvent(UINT aMsg, WPARAM wParam, LPARAM lParam);
michael@0 358 virtual bool ProcessMessage(UINT msg, WPARAM &wParam,
michael@0 359 LPARAM &lParam, LRESULT *aRetValue);
michael@0 360 bool ExternalHandlerProcessMessage(
michael@0 361 UINT aMessage, WPARAM& aWParam,
michael@0 362 LPARAM& aLParam, MSGResult& aResult);
michael@0 363 bool ProcessMessageForPlugin(const MSG &aMsg,
michael@0 364 MSGResult& aResult);
michael@0 365 LRESULT ProcessCharMessage(const MSG &aMsg,
michael@0 366 bool *aEventDispatched);
michael@0 367 LRESULT ProcessKeyUpMessage(const MSG &aMsg,
michael@0 368 bool *aEventDispatched);
michael@0 369 LRESULT ProcessKeyDownMessage(const MSG &aMsg,
michael@0 370 bool *aEventDispatched);
michael@0 371 static bool EventIsInsideWindow(nsWindow* aWindow);
michael@0 372 // Convert nsEventStatus value to a windows boolean
michael@0 373 static bool ConvertStatus(nsEventStatus aStatus);
michael@0 374 static void PostSleepWakeNotification(const bool aIsSleepMode);
michael@0 375 int32_t ClientMarginHitTestPoint(int32_t mx, int32_t my);
michael@0 376
michael@0 377 /**
michael@0 378 * Event handlers
michael@0 379 */
michael@0 380 virtual void OnDestroy();
michael@0 381 virtual bool OnResize(nsIntRect &aWindowRect);
michael@0 382 bool OnGesture(WPARAM wParam, LPARAM lParam);
michael@0 383 bool OnTouch(WPARAM wParam, LPARAM lParam);
michael@0 384 bool OnHotKey(WPARAM wParam, LPARAM lParam);
michael@0 385 bool OnPaint(HDC aDC, uint32_t aNestingLevel);
michael@0 386 void OnWindowPosChanged(WINDOWPOS* wp);
michael@0 387 void OnWindowPosChanging(LPWINDOWPOS& info);
michael@0 388 void OnSysColorChanged();
michael@0 389
michael@0 390 /**
michael@0 391 * Function that registers when the user has been active (used for detecting
michael@0 392 * when the user is idle).
michael@0 393 */
michael@0 394 void UserActivity();
michael@0 395
michael@0 396 int32_t GetHeight(int32_t aProposedHeight);
michael@0 397 void GetWindowClass(nsString& aWindowClass);
michael@0 398 void GetWindowPopupClass(nsString& aWindowClass);
michael@0 399 virtual DWORD WindowStyle();
michael@0 400 DWORD WindowExStyle();
michael@0 401
michael@0 402 void RegisterWindowClass(const nsString& aClassName,
michael@0 403 UINT aExtraStyle,
michael@0 404 LPWSTR aIconID);
michael@0 405
michael@0 406 /**
michael@0 407 * XP and Vista theming support for windows with rounded edges
michael@0 408 */
michael@0 409 void ClearThemeRegion();
michael@0 410 void SetThemeRegion();
michael@0 411
michael@0 412 /**
michael@0 413 * Popup hooks
michael@0 414 */
michael@0 415 static void ScheduleHookTimer(HWND aWnd, UINT aMsgId);
michael@0 416 static void RegisterSpecialDropdownHooks();
michael@0 417 static void UnregisterSpecialDropdownHooks();
michael@0 418 static bool GetPopupsToRollup(nsIRollupListener* aRollupListener,
michael@0 419 uint32_t* aPopupsToRollup);
michael@0 420 static bool NeedsToHandleNCActivateDelayed(HWND aWnd);
michael@0 421 static bool DealWithPopups(HWND inWnd, UINT inMsg, WPARAM inWParam, LPARAM inLParam, LRESULT* outResult);
michael@0 422
michael@0 423 /**
michael@0 424 * Window transparency helpers
michael@0 425 */
michael@0 426 #ifdef MOZ_XUL
michael@0 427 private:
michael@0 428 void SetWindowTranslucencyInner(nsTransparencyMode aMode);
michael@0 429 nsTransparencyMode GetWindowTranslucencyInner() const { return mTransparencyMode; }
michael@0 430 void ResizeTranslucentWindow(int32_t aNewWidth, int32_t aNewHeight, bool force = false);
michael@0 431 nsresult UpdateTranslucentWindow();
michael@0 432 void ClearTranslucentWindow();
michael@0 433 void SetupTranslucentWindowMemoryBitmap(nsTransparencyMode aMode);
michael@0 434 void UpdateGlass();
michael@0 435 protected:
michael@0 436 #endif // MOZ_XUL
michael@0 437
michael@0 438 static bool IsAsyncResponseEvent(UINT aMsg, LRESULT& aResult);
michael@0 439 void IPCWindowProcHandler(UINT& msg, WPARAM& wParam, LPARAM& lParam);
michael@0 440
michael@0 441 /**
michael@0 442 * Misc.
michael@0 443 */
michael@0 444 void StopFlashing();
michael@0 445 static bool IsTopLevelMouseExit(HWND aWnd);
michael@0 446 nsresult SetWindowClipRegion(const nsTArray<nsIntRect>& aRects,
michael@0 447 bool aIntersectWithExisting);
michael@0 448 nsIntRegion GetRegionToPaint(bool aForceFullRepaint,
michael@0 449 PAINTSTRUCT ps, HDC aDC);
michael@0 450 static void ActivateOtherWindowHelper(HWND aWnd);
michael@0 451 void ClearCachedResources();
michael@0 452 nsIWidgetListener* GetPaintListener();
michael@0 453 static bool IsRenderMode(gfxWindowsPlatform::RenderMode aMode);
michael@0 454
michael@0 455 protected:
michael@0 456 nsCOMPtr<nsIWidget> mParent;
michael@0 457 nsIntSize mLastSize;
michael@0 458 nsIntPoint mLastPoint;
michael@0 459 HWND mWnd;
michael@0 460 WNDPROC mPrevWndProc;
michael@0 461 HBRUSH mBrush;
michael@0 462 bool mIsTopWidgetWindow;
michael@0 463 bool mInDtor;
michael@0 464 bool mIsVisible;
michael@0 465 bool mUnicodeWidget;
michael@0 466 bool mPainting;
michael@0 467 bool mTouchWindow;
michael@0 468 bool mDisplayPanFeedback;
michael@0 469 bool mHideChrome;
michael@0 470 bool mIsRTL;
michael@0 471 bool mFullscreenMode;
michael@0 472 bool mMousePresent;
michael@0 473 bool mDestroyCalled;
michael@0 474 uint32_t mBlurSuppressLevel;
michael@0 475 DWORD_PTR mOldStyle;
michael@0 476 DWORD_PTR mOldExStyle;
michael@0 477 nsNativeDragTarget* mNativeDragTarget;
michael@0 478 HKL mLastKeyboardLayout;
michael@0 479 nsSizeMode mOldSizeMode;
michael@0 480 nsSizeMode mLastSizeMode;
michael@0 481 WindowHook mWindowHook;
michael@0 482 DWORD mAssumeWheelIsZoomUntil;
michael@0 483 uint32_t mPickerDisplayCount;
michael@0 484 HICON mIconSmall;
michael@0 485 HICON mIconBig;
michael@0 486 static bool sDropShadowEnabled;
michael@0 487 static uint32_t sInstanceCount;
michael@0 488 static TriStateBool sCanQuit;
michael@0 489 static nsWindow* sCurrentWindow;
michael@0 490 static BOOL sIsOleInitialized;
michael@0 491 static HCURSOR sHCursor;
michael@0 492 static imgIContainer* sCursorImgContainer;
michael@0 493 static bool sSwitchKeyboardLayout;
michael@0 494 static bool sJustGotDeactivate;
michael@0 495 static bool sJustGotActivate;
michael@0 496 static bool sIsInMouseCapture;
michael@0 497 static int sTrimOnMinimize;
michael@0 498 static const char* sDefaultMainWindowClass;
michael@0 499 static bool sAllowD3D9;
michael@0 500
michael@0 501 // Always use the helper method to read this property. See bug 603793.
michael@0 502 static TriStateBool sHasBogusPopupsDropShadowOnMultiMonitor;
michael@0 503 static bool HasBogusPopupsDropShadowOnMultiMonitor();
michael@0 504
michael@0 505 static uint32_t sOOPPPluginFocusEvent;
michael@0 506
michael@0 507 // Non-client margin settings
michael@0 508 // Pre-calculated outward offset applied to default frames
michael@0 509 nsIntMargin mNonClientOffset;
michael@0 510 // Margins set by the owner
michael@0 511 nsIntMargin mNonClientMargins;
michael@0 512
michael@0 513 // Indicates custom frames are enabled
michael@0 514 bool mCustomNonClient;
michael@0 515 // Cached copy of L&F's resize border
michael@0 516 int32_t mHorResizeMargin;
michael@0 517 int32_t mVertResizeMargin;
michael@0 518 // Height of the caption plus border
michael@0 519 int32_t mCaptionHeight;
michael@0 520
michael@0 521 nsCOMPtr<nsIIdleServiceInternal> mIdleService;
michael@0 522
michael@0 523 // Hook Data Memebers for Dropdowns. sProcessHook Tells the
michael@0 524 // hook methods whether they should be processing the hook
michael@0 525 // messages.
michael@0 526 static HHOOK sMsgFilterHook;
michael@0 527 static HHOOK sCallProcHook;
michael@0 528 static HHOOK sCallMouseHook;
michael@0 529 static bool sProcessHook;
michael@0 530 static UINT sRollupMsgId;
michael@0 531 static HWND sRollupMsgWnd;
michael@0 532 static UINT sHookTimerId;
michael@0 533
michael@0 534 // Mouse Clicks - static variable definitions for figuring
michael@0 535 // out 1 - 3 Clicks.
michael@0 536 static POINT sLastMousePoint;
michael@0 537 static POINT sLastMouseMovePoint;
michael@0 538 static LONG sLastMouseDownTime;
michael@0 539 static LONG sLastClickCount;
michael@0 540 static BYTE sLastMouseButton;
michael@0 541
michael@0 542 // Graphics
michael@0 543 HDC mPaintDC; // only set during painting
michael@0 544 HDC mCompositeDC; // only set during StartRemoteDrawing
michael@0 545
michael@0 546 nsIntRect mLastPaintBounds;
michael@0 547
michael@0 548 // Transparency
michael@0 549 #ifdef MOZ_XUL
michael@0 550 // Use layered windows to support full 256 level alpha translucency
michael@0 551 nsRefPtr<gfxASurface> mTransparentSurface;
michael@0 552 HDC mMemoryDC;
michael@0 553 nsTransparencyMode mTransparencyMode;
michael@0 554 nsIntRegion mPossiblyTransparentRegion;
michael@0 555 MARGINS mGlassMargins;
michael@0 556 #endif // MOZ_XUL
michael@0 557
michael@0 558 // Win7 Gesture processing and management
michael@0 559 nsWinGesture mGesture;
michael@0 560
michael@0 561 // Weak ref to the nsITaskbarWindowPreview associated with this window
michael@0 562 nsWeakPtr mTaskbarPreview;
michael@0 563 // True if the taskbar (possibly through the tab preview) tells us that the
michael@0 564 // icon has been created on the taskbar.
michael@0 565 bool mHasTaskbarIconBeenCreated;
michael@0 566
michael@0 567 // Indicates that mouse events should be ignored and pass through to the
michael@0 568 // window below. This is currently only used for popups.
michael@0 569 bool mMouseTransparent;
michael@0 570
michael@0 571 // The point in time at which the last paint completed. We use this to avoid
michael@0 572 // painting too rapidly in response to frequent input events.
michael@0 573 TimeStamp mLastPaintEndTime;
michael@0 574
michael@0 575 // Caching for hit test results
michael@0 576 POINT mCachedHitTestPoint;
michael@0 577 TimeStamp mCachedHitTestTime;
michael@0 578 int32_t mCachedHitTestResult;
michael@0 579
michael@0 580 static bool sNeedsToInitMouseWheelSettings;
michael@0 581 static void InitMouseWheelScrollData();
michael@0 582 };
michael@0 583
michael@0 584 /**
michael@0 585 * A child window is a window with different style.
michael@0 586 */
michael@0 587 class ChildWindow : public nsWindow {
michael@0 588
michael@0 589 public:
michael@0 590 ChildWindow() {}
michael@0 591
michael@0 592 protected:
michael@0 593 virtual DWORD WindowStyle();
michael@0 594 };
michael@0 595
michael@0 596 #endif // Window_h__

mercurial