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/. */
10 * nsWindow - Native window management and event handling.
13 #include "nsAutoPtr.h"
14 #include "nsBaseWidget.h"
15 #include "nsWindowBase.h"
17 #include "nsIdleService.h"
18 #include "nsToolkit.h"
22 #include "gfxWindowsSurface.h"
23 #include "nsWindowDbg.h"
26 #include "mozilla/TimeStamp.h"
28 #ifdef CAIRO_HAS_D2D_SURFACE
29 #include "gfxD2DSurface.h"
32 #include "nsWinGesture.h"
34 #include "WindowHook.h"
35 #include "TaskbarWindowPreview.h"
39 #include "mozilla/a11y/Accessible.h"
42 #include "nsUXThemeData.h"
44 #include "nsIDOMMouseEvent.h"
46 #include "nsIIdleServiceInternal.h"
49 * Forward class definitions
52 class nsNativeDragTarget
;
53 class nsIRollupListener
;
60 class ModifierKeyState
;
62 } // namespacw mozilla;
65 * Native WIN32 window wrapper.
68 class nsWindow
: public nsWindowBase
70 typedef mozilla::TimeStamp TimeStamp
;
71 typedef mozilla::TimeDuration TimeDuration
;
72 typedef mozilla::widget::WindowHook WindowHook
;
73 typedef mozilla::widget::TaskbarWindowPreview TaskbarWindowPreview
;
74 typedef mozilla::widget::NativeKey NativeKey
;
79 NS_DECL_ISUPPORTS_INHERITED
81 friend class nsWindowGfx
;
84 virtual void InitEvent(nsGUIEvent
& aEvent
, nsIntPoint
* aPoint
= nullptr) MOZ_OVERRIDE
;
85 virtual bool DispatchWindowEvent(nsGUIEvent
* aEvent
) MOZ_OVERRIDE
;
87 // nsIWidget interface
88 NS_IMETHOD
Create(nsIWidget
*aParent
,
89 nsNativeWidget aNativeParent
,
90 const nsIntRect
&aRect
,
91 nsDeviceContext
*aContext
,
92 nsWidgetInitData
*aInitData
= nullptr);
94 NS_IMETHOD
SetParent(nsIWidget
*aNewParent
);
95 virtual nsIWidget
* GetParent(void);
96 virtual float GetDPI();
97 virtual double GetDefaultScaleInternal();
98 NS_IMETHOD
Show(bool bState
);
99 virtual bool IsVisible() const;
100 NS_IMETHOD
ConstrainPosition(bool aAllowSlop
, int32_t *aX
, int32_t *aY
);
101 virtual void SetSizeConstraints(const SizeConstraints
& aConstraints
);
102 NS_IMETHOD
Move(double aX
, double aY
);
103 NS_IMETHOD
Resize(double aWidth
, double aHeight
, bool aRepaint
);
104 NS_IMETHOD
Resize(double aX
, double aY
, double aWidth
, double aHeight
, bool aRepaint
);
105 NS_IMETHOD
BeginResizeDrag(nsGUIEvent
* aEvent
, int32_t aHorizontal
, int32_t aVertical
);
106 NS_IMETHOD
PlaceBehind(nsTopLevelWidgetZPlacement aPlacement
, nsIWidget
*aWidget
, bool aActivate
);
107 NS_IMETHOD
SetSizeMode(int32_t aMode
);
108 NS_IMETHOD
Enable(bool aState
);
109 virtual bool IsEnabled() const;
110 NS_IMETHOD
SetFocus(bool aRaise
);
111 NS_IMETHOD
GetBounds(nsIntRect
&aRect
);
112 NS_IMETHOD
GetScreenBounds(nsIntRect
&aRect
);
113 NS_IMETHOD
GetClientBounds(nsIntRect
&aRect
);
114 virtual nsIntPoint
GetClientOffset();
115 NS_IMETHOD
SetBackgroundColor(const nscolor
&aColor
);
116 NS_IMETHOD
SetCursor(imgIContainer
* aCursor
,
117 uint32_t aHotspotX
, uint32_t aHotspotY
);
118 NS_IMETHOD
SetCursor(nsCursor aCursor
);
119 virtual nsresult
ConfigureChildren(const nsTArray
<Configuration
>& aConfigurations
);
120 NS_IMETHOD
MakeFullScreen(bool aFullScreen
);
121 NS_IMETHOD
HideWindowChrome(bool aShouldHide
);
122 NS_IMETHOD
Invalidate(bool aEraseBackground
= false,
123 bool aUpdateNCArea
= false,
124 bool aIncludeChildren
= false);
125 NS_IMETHOD
Invalidate(const nsIntRect
& aRect
);
126 virtual void* GetNativeData(uint32_t aDataType
);
127 virtual void FreeNativeData(void * data
, uint32_t aDataType
);
128 NS_IMETHOD
SetTitle(const nsAString
& aTitle
);
129 NS_IMETHOD
SetIcon(const nsAString
& aIconSpec
);
130 virtual nsIntPoint
WidgetToScreenOffset();
131 virtual nsIntSize
ClientToWindowSize(const nsIntSize
& aClientSize
);
132 NS_IMETHOD
DispatchEvent(nsGUIEvent
* event
, nsEventStatus
& aStatus
);
133 NS_IMETHOD
EnableDragDrop(bool aEnable
);
134 NS_IMETHOD
CaptureMouse(bool aCapture
);
135 NS_IMETHOD
CaptureRollupEvents(nsIRollupListener
* aListener
,
137 NS_IMETHOD
GetAttention(int32_t aCycleCount
);
138 virtual bool HasPendingInputEvent();
139 virtual LayerManager
* GetLayerManager(PLayerTransactionChild
* aShadowManager
= nullptr,
140 LayersBackend aBackendHint
= mozilla::layers::LAYERS_NONE
,
141 LayerManagerPersistence aPersistence
= LAYER_MANAGER_CURRENT
,
142 bool* aAllowRetaining
= nullptr);
143 gfxASurface
*GetThebesSurface();
144 NS_IMETHOD
OnDefaultButtonLoaded(const nsIntRect
&aButtonRect
);
145 NS_IMETHOD
OverrideSystemMouseScrollSpeed(double aOriginalDeltaX
,
146 double aOriginalDeltaY
,
147 double& aOverriddenDeltaX
,
148 double& aOverriddenDeltaY
);
150 virtual nsresult
SynthesizeNativeKeyEvent(int32_t aNativeKeyboardLayout
,
151 int32_t aNativeKeyCode
,
152 uint32_t aModifierFlags
,
153 const nsAString
& aCharacters
,
154 const nsAString
& aUnmodifiedCharacters
);
155 virtual nsresult
SynthesizeNativeMouseEvent(nsIntPoint aPoint
,
156 uint32_t aNativeMessage
,
157 uint32_t aModifierFlags
);
159 virtual nsresult
SynthesizeNativeMouseMove(nsIntPoint aPoint
)
160 { return SynthesizeNativeMouseEvent(aPoint
, MOUSEEVENTF_MOVE
, 0); }
162 virtual nsresult
SynthesizeNativeMouseScrollEvent(nsIntPoint aPoint
,
163 uint32_t aNativeMessage
,
167 uint32_t aModifierFlags
,
168 uint32_t aAdditionalFlags
);
169 NS_IMETHOD
NotifyIME(NotificationToIME aNotification
) MOZ_OVERRIDE
;
170 NS_IMETHOD_(void) SetInputContext(const InputContext
& aContext
,
171 const InputContextAction
& aAction
);
172 NS_IMETHOD_(InputContext
) GetInputContext();
173 NS_IMETHOD
GetToggledKeyState(uint32_t aKeyCode
, bool* aLEDState
);
174 NS_IMETHOD
RegisterTouchWindow();
175 NS_IMETHOD
UnregisterTouchWindow();
177 virtual void SetTransparencyMode(nsTransparencyMode aMode
);
178 virtual nsTransparencyMode
GetTransparencyMode();
179 virtual void UpdateOpaqueRegion(const nsIntRegion
& aOpaqueRegion
);
181 NS_IMETHOD
NotifyIMEOfTextChange(uint32_t aStart
,
183 uint32_t aNewEnd
) MOZ_OVERRIDE
;
184 virtual nsIMEUpdatePreference
GetIMEUpdatePreference();
185 NS_IMETHOD
GetNonClientMargins(nsIntMargin
&margins
);
186 NS_IMETHOD
SetNonClientMargins(nsIntMargin
&margins
);
187 void SetDrawsInTitlebar(bool aState
);
192 virtual bool DispatchMouseEvent(uint32_t aEventType
, WPARAM wParam
,
194 bool aIsContextMenuKey
= false,
195 int16_t aButton
= nsMouseEvent::eLeftButton
,
196 uint16_t aInputSource
= nsIDOMMouseEvent::MOZ_SOURCE_MOUSE
);
197 virtual bool DispatchWindowEvent(nsGUIEvent
*event
, nsEventStatus
&aStatus
);
198 void InitKeyEvent(nsKeyEvent
& aKeyEvent
,
199 const NativeKey
& aNativeKey
,
200 const mozilla::widget::ModifierKeyState
&aModKeyState
);
201 virtual bool DispatchKeyEvent(nsKeyEvent
& aKeyEvent
,
202 const MSG
*aMsgSentToPlugin
);
203 void DispatchPendingEvents();
204 bool DispatchPluginEvent(UINT aMessage
,
207 bool aDispatchPendingEvents
);
209 void SuppressBlurEvents(bool aSuppress
); // Called from nsFilePicker
210 bool BlurEventsSuppressed();
212 mozilla::a11y::Accessible
* GetRootAccessible();
213 #endif // ACCESSIBILITY
218 nsWindow
* GetTopLevelWindow(bool aStopOnDialogOrPopup
);
219 WNDPROC
GetPrevWindowProc() { return mPrevWndProc
; }
220 WindowHook
& GetWindowHook() { return mWindowHook
; }
221 nsWindow
* GetParentWindow(bool aIncludeOwner
);
222 // Get an array of all nsWindow*s on the main thread.
223 typedef void (WindowEnumCallback
)(nsWindow
*);
224 static void EnumAllWindows(WindowEnumCallback aCallback
);
229 virtual bool AutoErase(HDC dc
);
230 nsIntPoint
* GetLastPoint() { return &mLastPoint
; }
231 // needed in nsIMM32Handler.cpp
232 bool PluginHasFocus()
234 return (mInputContext
.mIMEState
.mEnabled
== IMEState::PLUGIN
);
236 bool IsTopLevelWidget() { return mIsTopWidgetWindow
; }
238 * Start allowing Direct3D9 to be used by widgets when GetLayerManager is
241 * @param aReinitialize Call GetLayerManager on widgets to ensure D3D9 is
242 * initialized, this is usually called when this function
243 * is triggered by timeout and not user/web interaction.
245 static void StartAllowingD3D9(bool aReinitialize
);
248 * AssociateDefaultIMC() associates or disassociates the default IMC for
251 * @param aAssociate TRUE, associates the default IMC with the window.
252 * Otherwise, disassociates the default IMC from the
254 * @return TRUE if this method associated the default IMC with
255 * disassociated window or disassociated the default IMC
256 * from associated window.
257 * Otherwise, i.e., if this method did nothing actually,
260 bool AssociateDefaultIMC(bool aAssociate
);
262 bool HasTaskbarIconBeenCreated() { return mHasTaskbarIconBeenCreated
; }
263 // Called when either the nsWindow or an nsITaskbarTabPreview receives the noticiation that this window
264 // has its icon placed on the taskbar.
265 void SetHasTaskbarIconBeenCreated(bool created
= true) { mHasTaskbarIconBeenCreated
= created
; }
267 // Getter/setter for the nsITaskbarWindowPreview for this nsWindow
268 already_AddRefed
<nsITaskbarWindowPreview
> GetTaskbarPreview() {
269 nsCOMPtr
<nsITaskbarWindowPreview
> preview(do_QueryReferent(mTaskbarPreview
));
270 return preview
.forget();
272 void SetTaskbarPreview(nsITaskbarWindowPreview
*preview
) { mTaskbarPreview
= do_GetWeakReference(preview
); }
274 NS_IMETHOD
ReparentNativeWidget(nsIWidget
* aNewParent
);
276 // Open file picker tracking
280 bool const DestroyCalled() { return mDestroyCalled
; }
282 static void SetupKeyModifiersSequence(nsTArray
<KeyPair
>* aArray
, uint32_t aModifiers
);
284 virtual mozilla::layers::LayersBackend
GetPreferredCompositorBackend() { return mozilla::layers::LAYERS_D3D11
; }
288 // A magic number to identify the FAKETRACKPOINTSCROLLABLE window created
289 // when the trackpoint hack is enabled.
290 enum { eFakeTrackPointScrollableID
= 0x46545053 };
295 static LRESULT CALLBACK
WindowProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
);
296 static LRESULT CALLBACK
WindowProcInternal(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
);
298 static BOOL CALLBACK
BroadcastMsgToChildren(HWND aWnd
, LPARAM aMsg
);
299 static BOOL CALLBACK
BroadcastMsg(HWND aTopWindow
, LPARAM aMsg
);
300 static BOOL CALLBACK
DispatchStarvedPaints(HWND aTopWindow
, LPARAM aMsg
);
301 static BOOL CALLBACK
RegisterTouchForDescendants(HWND aTopWindow
, LPARAM aMsg
);
302 static BOOL CALLBACK
UnregisterTouchForDescendants(HWND aTopWindow
, LPARAM aMsg
);
303 static LRESULT CALLBACK
MozSpecialMsgFilter(int code
, WPARAM wParam
, LPARAM lParam
);
304 static LRESULT CALLBACK
MozSpecialWndProc(int code
, WPARAM wParam
, LPARAM lParam
);
305 static LRESULT CALLBACK
MozSpecialMouseProc(int code
, WPARAM wParam
, LPARAM lParam
);
306 static VOID CALLBACK
HookTimerForPopups( HWND hwnd
, UINT uMsg
, UINT idEvent
, DWORD dwTime
);
307 static BOOL CALLBACK
ClearResourcesCallback(HWND aChild
, LPARAM aParam
);
308 static BOOL CALLBACK
EnumAllChildWindProc(HWND aWnd
, LPARAM aParam
);
309 static BOOL CALLBACK
EnumAllThreadWindowProc(HWND aWnd
, LPARAM aParam
);
310 static void AllowD3D9Callback(nsWindow
*aWindow
);
311 static void AllowD3D9WithReinitializeCallback(nsWindow
*aWindow
);
316 LPARAM
lParamToScreen(LPARAM lParam
);
317 LPARAM
lParamToClient(LPARAM lParam
);
318 virtual void SubclassWindow(BOOL bState
);
320 bool UpdateNonClientMargins(int32_t aSizeMode
= -1, bool aReflowWindow
= true);
321 void UpdateGetWindowInfoCaptionStatus(bool aActiveCaption
);
323 void InvalidateNonClientRegion();
324 HRGN
ExcludeNonClientFromPaintRegion(HRGN aRegion
);
325 static void GetMainWindowClass(nsAString
& aClass
);
326 bool HasGlass() const {
327 return mTransparencyMode
== eTransparencyGlass
||
328 mTransparencyMode
== eTransparencyBorderlessGlass
;
332 * Event processing helpers
334 bool DispatchPluginEvent(const MSG
&aMsg
);
335 void DispatchFocusToTopLevelWindow(bool aIsActivate
);
336 bool DispatchStandardEvent(uint32_t aMsg
);
337 bool DispatchCommandEvent(uint32_t aEventCommand
);
338 void RelayMouseEvent(UINT aMsg
, WPARAM wParam
, LPARAM lParam
);
339 static void RemoveNextCharMessage(HWND aWnd
);
340 void RemoveMessageAndDispatchPluginEvent(UINT aFirstMsg
,
342 nsFakeCharMessage
* aFakeCharMessage
= nullptr);
343 virtual bool ProcessMessage(UINT msg
, WPARAM
&wParam
,
344 LPARAM
&lParam
, LRESULT
*aRetValue
);
345 bool ProcessMessageForPlugin(const MSG
&aMsg
,
346 LRESULT
*aRetValue
, bool &aCallDefWndProc
);
347 LRESULT
ProcessCharMessage(const MSG
&aMsg
,
348 bool *aEventDispatched
);
349 LRESULT
ProcessKeyUpMessage(const MSG
&aMsg
,
350 bool *aEventDispatched
);
351 LRESULT
ProcessKeyDownMessage(const MSG
&aMsg
,
352 bool *aEventDispatched
);
353 static bool EventIsInsideWindow(UINT Msg
, nsWindow
* aWindow
);
354 // Convert nsEventStatus value to a windows boolean
355 static bool ConvertStatus(nsEventStatus aStatus
);
356 static void PostSleepWakeNotification(const bool aIsSleepMode
);
357 int32_t ClientMarginHitTestPoint(int32_t mx
, int32_t my
);
358 static bool IsRedirectedKeyDownMessage(const MSG
&aMsg
);
359 static void ForgetRedirectedKeyDownMessage()
361 sRedirectedKeyDown
.message
= WM_NULL
;
367 virtual void OnDestroy();
368 virtual bool OnMove(int32_t aX
, int32_t aY
);
369 virtual bool OnResize(nsIntRect
&aWindowRect
);
371 * @param aVirtualKeyCode If caller knows which key exactly caused the
372 * aMsg, set the virtual key code.
374 * @param aScanCode If aVirutalKeyCode isn't 0, set the scan code.
376 LRESULT
OnChar(const MSG
&aMsg
,
377 const NativeKey
& aNativeKey
,
378 const mozilla::widget::ModifierKeyState
&aModKeyState
,
379 bool *aEventDispatched
,
380 const mozilla::widget::EventFlags
* aExtraFlags
= nullptr);
381 LRESULT
OnKeyDown(const MSG
&aMsg
,
382 const mozilla::widget::ModifierKeyState
&aModKeyState
,
383 bool *aEventDispatched
,
384 nsFakeCharMessage
* aFakeCharMessage
);
385 LRESULT
OnKeyUp(const MSG
&aMsg
,
386 const mozilla::widget::ModifierKeyState
&aModKeyState
,
387 bool *aEventDispatched
);
388 bool OnGesture(WPARAM wParam
, LPARAM lParam
);
389 bool OnTouch(WPARAM wParam
, LPARAM lParam
);
390 bool OnHotKey(WPARAM wParam
, LPARAM lParam
);
391 BOOL
OnInputLangChange(HKL aHKL
);
392 bool OnPaint(HDC aDC
, uint32_t aNestingLevel
);
393 void OnWindowPosChanged(WINDOWPOS
*wp
, bool& aResult
);
394 void OnWindowPosChanging(LPWINDOWPOS
& info
);
395 void OnSysColorChanged();
398 * Function that registers when the user has been active (used for detecting
399 * when the user is idle).
403 int32_t GetHeight(int32_t aProposedHeight
);
404 void GetWindowClass(nsString
& aWindowClass
);
405 void GetWindowPopupClass(nsString
& aWindowClass
);
406 virtual DWORD
WindowStyle();
407 DWORD
WindowExStyle();
409 void RegisterWindowClass(const nsString
& aClassName
,
414 * XP and Vista theming support for windows with rounded edges
416 void ClearThemeRegion();
417 void SetThemeRegion();
422 static void ScheduleHookTimer(HWND aWnd
, UINT aMsgId
);
423 static void RegisterSpecialDropdownHooks();
424 static void UnregisterSpecialDropdownHooks();
425 static bool DealWithPopups(HWND inWnd
, UINT inMsg
, WPARAM inWParam
, LPARAM inLParam
, LRESULT
* outResult
);
428 * Window transparency helpers
432 void SetWindowTranslucencyInner(nsTransparencyMode aMode
);
433 nsTransparencyMode
GetWindowTranslucencyInner() const { return mTransparencyMode
; }
434 void ResizeTranslucentWindow(int32_t aNewWidth
, int32_t aNewHeight
, bool force
= false);
435 nsresult
UpdateTranslucentWindow();
436 void ClearTranslucentWindow();
437 void SetupTranslucentWindowMemoryBitmap(nsTransparencyMode aMode
);
442 static bool IsAsyncResponseEvent(UINT aMsg
, LRESULT
& aResult
);
443 void IPCWindowProcHandler(UINT
& msg
, WPARAM
& wParam
, LPARAM
& lParam
);
449 static bool IsTopLevelMouseExit(HWND aWnd
);
450 nsresult
SetWindowClipRegion(const nsTArray
<nsIntRect
>& aRects
,
451 bool aIntersectWithExisting
);
452 nsIntRegion
GetRegionToPaint(bool aForceFullRepaint
,
453 PAINTSTRUCT ps
, HDC aDC
);
454 static void ActivateOtherWindowHelper(HWND aWnd
);
455 void ClearCachedResources();
456 nsIWidgetListener
* GetPaintListener();
459 nsCOMPtr
<nsIWidget
> mParent
;
461 nsIntPoint mLastPoint
;
463 WNDPROC mPrevWndProc
;
465 bool mIsTopWidgetWindow
;
471 bool mDisplayPanFeedback
;
474 bool mFullscreenMode
;
477 uint32_t mBlurSuppressLevel
;
479 DWORD_PTR mOldExStyle
;
480 InputContext mInputContext
;
481 nsNativeDragTarget
* mNativeDragTarget
;
482 HKL mLastKeyboardLayout
;
483 nsSizeMode mOldSizeMode
;
484 nsSizeMode mLastSizeMode
;
485 WindowHook mWindowHook
;
486 DWORD mAssumeWheelIsZoomUntil
;
487 uint32_t mPickerDisplayCount
;
490 static bool sDropShadowEnabled
;
491 static uint32_t sInstanceCount
;
492 static TriStateBool sCanQuit
;
493 static nsWindow
* sCurrentWindow
;
494 static BOOL sIsOleInitialized
;
495 static HCURSOR sHCursor
;
496 static imgIContainer
* sCursorImgContainer
;
497 static bool sSwitchKeyboardLayout
;
498 static bool sJustGotDeactivate
;
499 static bool sJustGotActivate
;
500 static bool sIsInMouseCapture
;
501 static int sTrimOnMinimize
;
502 static const char* sDefaultMainWindowClass
;
503 static bool sAllowD3D9
;
505 // Always use the helper method to read this property. See bug 603793.
506 static TriStateBool sHasBogusPopupsDropShadowOnMultiMonitor
;
507 static bool HasBogusPopupsDropShadowOnMultiMonitor();
509 static uint32_t sOOPPPluginFocusEvent
;
511 // Non-client margin settings
512 // Pre-calculated outward offset applied to default frames
513 nsIntMargin mNonClientOffset
;
514 // Margins set by the owner
515 nsIntMargin mNonClientMargins
;
517 // Indicates custom frames are enabled
518 bool mCustomNonClient
;
519 // Cached copy of L&F's resize border
520 int32_t mHorResizeMargin
;
521 int32_t mVertResizeMargin
;
522 // Height of the caption plus border
523 int32_t mCaptionHeight
;
525 nsCOMPtr
<nsIIdleServiceInternal
> mIdleService
;
527 // Hook Data Memebers for Dropdowns. sProcessHook Tells the
528 // hook methods whether they should be processing the hook
530 static HHOOK sMsgFilterHook
;
531 static HHOOK sCallProcHook
;
532 static HHOOK sCallMouseHook
;
533 static bool sProcessHook
;
534 static UINT sRollupMsgId
;
535 static HWND sRollupMsgWnd
;
536 static UINT sHookTimerId
;
538 // Mouse Clicks - static variable definitions for figuring
540 static POINT sLastMousePoint
;
541 static POINT sLastMouseMovePoint
;
542 static LONG sLastMouseDownTime
;
543 static LONG sLastClickCount
;
544 static BYTE sLastMouseButton
;
547 HDC mPaintDC
; // only set during painting
549 #ifdef CAIRO_HAS_D2D_SURFACE
550 nsRefPtr
<gfxD2DSurface
> mD2DWindowSurface
; // Surface for this window.
555 // Use layered windows to support full 256 level alpha translucency
556 nsRefPtr
<gfxASurface
> mTransparentSurface
;
558 nsTransparencyMode mTransparencyMode
;
559 nsIntRegion mPossiblyTransparentRegion
;
560 MARGINS mGlassMargins
;
563 // Win7 Gesture processing and management
564 nsWinGesture mGesture
;
566 // Weak ref to the nsITaskbarWindowPreview associated with this window
567 nsWeakPtr mTaskbarPreview
;
568 // True if the taskbar (possibly through the tab preview) tells us that the
569 // icon has been created on the taskbar.
570 bool mHasTaskbarIconBeenCreated
;
572 // The point in time at which the last paint completed. We use this to avoid
573 // painting too rapidly in response to frequent input events.
574 TimeStamp mLastPaintEndTime
;
576 // sRedirectedKeyDown is WM_KEYDOWN message or WM_SYSKEYDOWN message which
577 // was reirected to SendInput() API by OnKeyDown().
578 static MSG sRedirectedKeyDown
;
580 static bool sNeedsToInitMouseWheelSettings
;
581 static void InitMouseWheelScrollData();
583 // If a window receives WM_KEYDOWN message or WM_SYSKEYDOWM message which is
584 // redirected message, OnKeyDowm() prevents to dispatch NS_KEY_DOWN event
585 // because it has been dispatched before the message was redirected.
586 // However, in some cases, ProcessKeyDownMessage() doesn't call OnKeyDown().
587 // Then, ProcessKeyDownMessage() needs to forget the redirected message and
588 // remove WM_CHAR message or WM_SYSCHAR message for the redirected keydown
589 // message. AutoForgetRedirectedKeyDownMessage struct is a helper struct
590 // for doing that. This must be created in stack.
591 struct AutoForgetRedirectedKeyDownMessage
593 AutoForgetRedirectedKeyDownMessage(nsWindow
* aWindow
, const MSG
&aMsg
) :
594 mCancel(!nsWindow::IsRedirectedKeyDownMessage(aMsg
)),
595 mWindow(aWindow
), mMsg(aMsg
)
599 ~AutoForgetRedirectedKeyDownMessage()
604 // Prevent unnecessary keypress event
605 if (!mWindow
->mOnDestroyCalled
) {
606 nsWindow::RemoveNextCharMessage(mWindow
->mWnd
);
608 // Foreget the redirected message
609 nsWindow::ForgetRedirectedKeyDownMessage();
613 nsRefPtr
<nsWindow
> mWindow
;
619 * A child window is a window with different style.
621 class ChildWindow
: public nsWindow
{
627 virtual DWORD
WindowStyle();