Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/widget/gtk/nsWindow.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* vim:expandtab:shiftwidth=4:tabstop=4:
3
 */
4
/* This Source Code Form is subject to the terms of the Mozilla Public
5
 * License, v. 2.0. If a copy of the MPL was not distributed with this
6
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7
8
#ifndef __nsWindow_h__
9
#define __nsWindow_h__
10
11
#include "mozcontainer.h"
12
#include "mozilla/RefPtr.h"
13
#include "mozilla/UniquePtr.h"
14
#include "nsIDragService.h"
15
#include "nsITimer.h"
16
#include "nsGkAtoms.h"
17
#include "nsRefPtrHashtable.h"
18
#include "nsIFrame.h"
19
20
#include "nsBaseWidget.h"
21
#include "CompositorWidget.h"
22
#include <gdk/gdk.h>
23
#include <gtk/gtk.h>
24
25
#ifdef MOZ_X11
26
#include <gdk/gdkx.h>
27
#include "X11UndefineNone.h"
28
#endif /* MOZ_X11 */
29
#ifdef MOZ_WAYLAND
30
#include <gdk/gdkwayland.h>
31
#endif
32
33
#include "mozilla/widget/WindowSurface.h"
34
#include "mozilla/widget/WindowSurfaceProvider.h"
35
36
#ifdef ACCESSIBILITY
37
#include "mozilla/a11y/Accessible.h"
38
#endif
39
#include "mozilla/EventForwards.h"
40
#include "mozilla/TouchEvents.h"
41
42
#include "IMContextWrapper.h"
43
44
#undef LOG
45
#ifdef MOZ_LOGGING
46
47
#include "mozilla/Logging.h"
48
#include "nsTArray.h"
49
#include "Units.h"
50
51
extern mozilla::LazyLogModule gWidgetLog;
52
extern mozilla::LazyLogModule gWidgetFocusLog;
53
extern mozilla::LazyLogModule gWidgetDragLog;
54
extern mozilla::LazyLogModule gWidgetDrawLog;
55
56
0
#define LOG(args) MOZ_LOG(gWidgetLog, mozilla::LogLevel::Debug, args)
57
0
#define LOGFOCUS(args) MOZ_LOG(gWidgetFocusLog, mozilla::LogLevel::Debug, args)
58
0
#define LOGDRAG(args) MOZ_LOG(gWidgetDragLog, mozilla::LogLevel::Debug, args)
59
0
#define LOGDRAW(args) MOZ_LOG(gWidgetDrawLog, mozilla::LogLevel::Debug, args)
60
61
#else
62
63
#define LOG(args)
64
#define LOGFOCUS(args)
65
#define LOGDRAG(args)
66
#define LOGDRAW(args)
67
68
#endif /* MOZ_LOGGING */
69
70
#ifdef MOZ_WAYLAND
71
class nsWaylandDragContext;
72
73
gboolean
74
WindowDragMotionHandler(GtkWidget *aWidget, GdkDragContext *aDragContext,
75
                        nsWaylandDragContext *aWaylandDragContext,
76
                        gint aX, gint aY, guint aTime);
77
gboolean
78
WindowDragDropHandler(GtkWidget *aWidget, GdkDragContext *aDragContext,
79
                      nsWaylandDragContext *aWaylandDragContext, gint aX, gint aY,
80
                      guint aTime);
81
void
82
WindowDragLeaveHandler(GtkWidget *aWidget);
83
#endif
84
85
class gfxPattern;
86
87
namespace mozilla {
88
class TimeStamp;
89
class CurrentX11TimeGetter;
90
}
91
92
class nsWindow final : public nsBaseWidget
93
{
94
public:
95
    typedef mozilla::gfx::DrawTarget DrawTarget;
96
    typedef mozilla::WidgetEventTime WidgetEventTime;
97
    typedef mozilla::WidgetKeyboardEvent WidgetKeyboardEvent;
98
    typedef mozilla::widget::PlatformCompositorWidgetDelegate PlatformCompositorWidgetDelegate;
99
100
    nsWindow();
101
102
    static void ReleaseGlobals();
103
104
    NS_INLINE_DECL_REFCOUNTING_INHERITED(nsWindow, nsBaseWidget)
105
106
    void CommonCreate(nsIWidget *aParent, bool aListenForResizes);
107
108
    virtual nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
109
                                   nsEventStatus& aStatus) override;
110
111
    // called when we are destroyed
112
    virtual void OnDestroy(void) override;
113
114
    // called to check and see if a widget's dimensions are sane
115
    bool AreBoundsSane(void);
116
117
    // nsIWidget
118
    using nsBaseWidget::Create; // for Create signature not overridden here
119
    virtual MOZ_MUST_USE nsresult Create(nsIWidget* aParent,
120
                                         nsNativeWidget aNativeParent,
121
                                         const LayoutDeviceIntRect& aRect,
122
                                         nsWidgetInitData* aInitData) override;
123
    virtual void       Destroy() override;
124
    virtual nsIWidget *GetParent() override;
125
    virtual float      GetDPI() override;
126
    virtual double     GetDefaultScaleInternal() override;
127
    mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScale() override;
128
    virtual void       SetParent(nsIWidget* aNewParent) override;
129
    virtual void       SetModal(bool aModal) override;
130
    virtual bool       IsVisible() const override;
131
    virtual void       ConstrainPosition(bool aAllowSlop,
132
                                         int32_t *aX,
133
                                         int32_t *aY) override;
134
    virtual void       SetSizeConstraints(const SizeConstraints& aConstraints) override;
135
    virtual void       Move(double aX, double aY) override;
136
    virtual void       Show             (bool aState) override;
137
    virtual void       Resize           (double aWidth,
138
                                         double aHeight,
139
                                         bool   aRepaint) override;
140
    virtual void       Resize           (double aX,
141
                                         double aY,
142
                                         double aWidth,
143
                                         double aHeight,
144
                                         bool   aRepaint) override;
145
    virtual bool       IsEnabled() const override;
146
147
    void               SetZIndex(int32_t aZIndex) override;
148
    virtual void       SetSizeMode(nsSizeMode aMode) override;
149
    virtual void       Enable(bool aState) override;
150
    virtual nsresult   SetFocus(bool aRaise = false) override;
151
    virtual LayoutDeviceIntRect GetScreenBounds() override;
152
    virtual LayoutDeviceIntRect GetClientBounds() override;
153
    virtual LayoutDeviceIntSize GetClientSize() override;
154
    virtual LayoutDeviceIntPoint GetClientOffset() override;
155
    virtual void       SetCursor(nsCursor aCursor) override;
156
    virtual nsresult   SetCursor(imgIContainer* aCursor,
157
                                 uint32_t aHotspotX, uint32_t aHotspotY) override;
158
    virtual void       Invalidate(const LayoutDeviceIntRect& aRect) override;
159
    virtual void*      GetNativeData(uint32_t aDataType) override;
160
    virtual nsresult   SetTitle(const nsAString& aTitle) override;
161
    virtual void       SetIcon(const nsAString& aIconSpec) override;
162
    virtual void       SetWindowClass(const nsAString& xulWinType) override;
163
    virtual LayoutDeviceIntPoint WidgetToScreenOffset() override;
164
    virtual void       CaptureMouse(bool aCapture) override;
165
    virtual void       CaptureRollupEvents(nsIRollupListener *aListener,
166
                                           bool aDoCapture) override;
167
    virtual MOZ_MUST_USE nsresult GetAttention(int32_t aCycleCount) override;
168
    virtual nsresult   SetWindowClipRegion(const nsTArray<LayoutDeviceIntRect>& aRects,
169
                                           bool aIntersectWithExisting) override;
170
    virtual bool       HasPendingInputEvent() override;
171
172
    virtual bool PrepareForFullscreenTransition(nsISupports** aData) override;
173
    virtual void PerformFullscreenTransition(FullscreenTransitionStage aStage,
174
                                             uint16_t aDuration,
175
                                             nsISupports* aData,
176
                                             nsIRunnable* aCallback) override;
177
    virtual already_AddRefed<nsIScreen> GetWidgetScreen() override;
178
    virtual nsresult   MakeFullScreen(bool aFullScreen,
179
                                      nsIScreen* aTargetScreen = nullptr) override;
180
    virtual void       HideWindowChrome(bool aShouldHide) override;
181
182
    /**
183
     * GetLastUserInputTime returns a timestamp for the most recent user input
184
     * event.  This is intended for pointer grab requests (including drags).
185
     */
186
    static guint32     GetLastUserInputTime();
187
188
    // utility method, -1 if no change should be made, otherwise returns a
189
    // value that can be passed to gdk_window_set_decorations
190
    gint               ConvertBorderStyles(nsBorderStyle aStyle);
191
192
    GdkRectangle DevicePixelsToGdkRectRoundOut(LayoutDeviceIntRect aRect);
193
194
    // event callbacks
195
    gboolean           OnExposeEvent(cairo_t *cr);
196
    gboolean           OnConfigureEvent(GtkWidget *aWidget,
197
                                        GdkEventConfigure *aEvent);
198
    void               OnContainerUnrealize();
199
    void               OnSizeAllocate(GtkAllocation *aAllocation);
200
    void               OnDeleteEvent();
201
    void               OnEnterNotifyEvent(GdkEventCrossing *aEvent);
202
    void               OnLeaveNotifyEvent(GdkEventCrossing *aEvent);
203
    void               OnMotionNotifyEvent(GdkEventMotion *aEvent);
204
    void               OnButtonPressEvent(GdkEventButton *aEvent);
205
    void               OnButtonReleaseEvent(GdkEventButton *aEvent);
206
    void               OnContainerFocusInEvent(GdkEventFocus *aEvent);
207
    void               OnContainerFocusOutEvent(GdkEventFocus *aEvent);
208
    gboolean           OnKeyPressEvent(GdkEventKey *aEvent);
209
    gboolean           OnKeyReleaseEvent(GdkEventKey *aEvent);
210
211
    /**
212
     * MaybeDispatchContextMenuEvent() may dispatch eContextMenu event if
213
     * the given key combination should cause opening context menu.
214
     *
215
     * @param aEvent            The native key event.
216
     * @return                  true if this method dispatched eContextMenu
217
     *                          event.  Otherwise, false.
218
     *                          Be aware, when this returns true, the
219
     *                          widget may have been destroyed.
220
     */
221
    bool               MaybeDispatchContextMenuEvent(const GdkEventKey* aEvent);
222
223
    void               OnScrollEvent(GdkEventScroll *aEvent);
224
    void               OnVisibilityNotifyEvent(GdkEventVisibility *aEvent);
225
    void               OnWindowStateEvent(GtkWidget *aWidget,
226
                                          GdkEventWindowState *aEvent);
227
    void               OnDragDataReceivedEvent(GtkWidget       *aWidget,
228
                                               GdkDragContext  *aDragContext,
229
                                               gint             aX,
230
                                               gint             aY,
231
                                               GtkSelectionData*aSelectionData,
232
                                               guint            aInfo,
233
                                               guint            aTime,
234
                                               gpointer         aData);
235
    gboolean           OnPropertyNotifyEvent(GtkWidget *aWidget,
236
                                             GdkEventProperty *aEvent);
237
#if GTK_CHECK_VERSION(3,4,0)
238
    gboolean           OnTouchEvent(GdkEventTouch* aEvent);
239
#endif
240
241
    virtual already_AddRefed<mozilla::gfx::DrawTarget>
242
                       StartRemoteDrawingInRegion(LayoutDeviceIntRegion& aInvalidRegion,
243
                                                  mozilla::layers::BufferMode* aBufferMode) override;
244
    virtual void       EndRemoteDrawingInRegion(mozilla::gfx::DrawTarget* aDrawTarget,
245
                                                LayoutDeviceIntRegion& aInvalidRegion) override;
246
247
    void               SetProgress(unsigned long progressPercent);
248
249
private:
250
    void               UpdateAlpha(mozilla::gfx::SourceSurface* aSourceSurface, nsIntRect aBoundsRect);
251
252
    void               NativeMove();
253
    void               NativeResize();
254
    void               NativeMoveResize();
255
256
    void               NativeShow  (bool    aAction);
257
    void               SetHasMappedToplevel(bool aState);
258
    LayoutDeviceIntSize GetSafeWindowSize(LayoutDeviceIntSize aSize);
259
260
    void               EnsureGrabs  (void);
261
    void               GrabPointer  (guint32 aTime);
262
    void               ReleaseGrabs (void);
263
264
    void               UpdateClientOffset();
265
266
    void               DispatchContextMenuEventFromMouseEvent(uint16_t domButton,
267
                                                              GdkEventButton *aEvent);
268
public:
269
    void               ThemeChanged(void);
270
    void               OnDPIChanged(void);
271
    void               OnCheckResize(void);
272
    void               OnCompositedChanged(void);
273
274
#ifdef MOZ_X11
275
    Window             mOldFocusWindow;
276
#endif /* MOZ_X11 */
277
278
    static guint32     sLastButtonPressTime;
279
280
    virtual MOZ_MUST_USE nsresult
281
                       BeginResizeDrag(mozilla::WidgetGUIEvent* aEvent,
282
                                       int32_t aHorizontal,
283
                                       int32_t aVertical) override;
284
    virtual MOZ_MUST_USE nsresult
285
                       BeginMoveDrag(mozilla::WidgetMouseEvent* aEvent) override;
286
287
0
    MozContainer*      GetMozContainer() { return mContainer; }
288
    // GetMozContainerWidget returns the MozContainer even for undestroyed
289
    // descendant windows
290
    GtkWidget*         GetMozContainerWidget();
291
0
    GdkWindow*         GetGdkWindow() { return mGdkWindow; }
292
0
    bool               IsDestroyed() { return mIsDestroyed; }
293
294
    void               DispatchDragEvent(mozilla::EventMessage aMsg,
295
                                         const LayoutDeviceIntPoint& aRefPoint,
296
                                         guint aTime);
297
    static void        UpdateDragStatus (GdkDragContext *aDragContext,
298
                                         nsIDragService *aDragService);
299
    /**
300
     * DispatchKeyDownOrKeyUpEvent() dispatches eKeyDown or eKeyUp event.
301
     *
302
     * @param aEvent            A native GDK_KEY_PRESS or GDK_KEY_RELEASE
303
     *                          event.
304
     * @param aProcessedByIME   true if the event is handled by IME.
305
     * @param aIsCancelled      [Out] true if the default is prevented.
306
     * @return                  true if eKeyDown event is actually dispatched.
307
     *                          Otherwise, false.
308
     */
309
    bool DispatchKeyDownOrKeyUpEvent(GdkEventKey* aEvent,
310
                                     bool aProcessedByIME,
311
                                     bool* aIsCancelled);
312
313
    /**
314
     * DispatchKeyDownOrKeyUpEvent() dispatches eKeyDown or eKeyUp event.
315
     *
316
     * @param aEvent            An eKeyDown or eKeyUp event.  This will be
317
     *                          dispatched as is.
318
     * @param aIsCancelled      [Out] true if the default is prevented.
319
     * @return                  true if eKeyDown event is actually dispatched.
320
     *                          Otherwise, false.
321
     */
322
    bool DispatchKeyDownOrKeyUpEvent(WidgetKeyboardEvent& aEvent,
323
                                     bool* aIsCancelled);
324
325
    WidgetEventTime    GetWidgetEventTime(guint32 aEventTime);
326
    mozilla::TimeStamp GetEventTimeStamp(guint32 aEventTime);
327
    mozilla::CurrentX11TimeGetter* GetCurrentTimeGetter();
328
329
    virtual void SetInputContext(const InputContext& aContext,
330
                                 const InputContextAction& aAction) override;
331
    virtual InputContext GetInputContext() override;
332
    virtual TextEventDispatcherListener*
333
        GetNativeTextEventDispatcherListener() override;
334
    void GetEditCommandsRemapped(NativeKeyBindingsType aType,
335
                                 const mozilla::WidgetKeyboardEvent& aEvent,
336
                                 nsTArray<mozilla::CommandInt>& aCommands,
337
                                 uint32_t aGeckoKeyCode,
338
                                 uint32_t aNativeKeyCode);
339
    virtual void GetEditCommands(
340
                     NativeKeyBindingsType aType,
341
                     const mozilla::WidgetKeyboardEvent& aEvent,
342
                     nsTArray<mozilla::CommandInt>& aCommands) override;
343
344
    // These methods are for toplevel windows only.
345
    void               ResizeTransparencyBitmap();
346
    void               ApplyTransparencyBitmap();
347
    void               ClearTransparencyBitmap();
348
349
   virtual void        SetTransparencyMode(nsTransparencyMode aMode) override;
350
   virtual nsTransparencyMode GetTransparencyMode() override;
351
#if (MOZ_WIDGET_GTK >= 3)
352
   virtual void        UpdateOpaqueRegion(const LayoutDeviceIntRegion& aOpaqueRegion) override;
353
#endif
354
   virtual nsresult    ConfigureChildren(const nsTArray<Configuration>& aConfigurations) override;
355
   nsresult            UpdateTranslucentWindowAlphaInternal(const nsIntRect& aRect,
356
                                                            uint8_t* aAlphas, int32_t aStride);
357
358
    virtual void       ReparentNativeWidget(nsIWidget* aNewParent) override;
359
360
    virtual nsresult SynthesizeNativeMouseEvent(LayoutDeviceIntPoint aPoint,
361
                                                uint32_t aNativeMessage,
362
                                                uint32_t aModifierFlags,
363
                                                nsIObserver* aObserver) override;
364
365
    virtual nsresult SynthesizeNativeMouseMove(LayoutDeviceIntPoint aPoint,
366
                                               nsIObserver* aObserver) override
367
0
    { return SynthesizeNativeMouseEvent(aPoint, GDK_MOTION_NOTIFY, 0, aObserver); }
368
369
    virtual nsresult SynthesizeNativeMouseScrollEvent(LayoutDeviceIntPoint aPoint,
370
                                                      uint32_t aNativeMessage,
371
                                                      double aDeltaX,
372
                                                      double aDeltaY,
373
                                                      double aDeltaZ,
374
                                                      uint32_t aModifierFlags,
375
                                                      uint32_t aAdditionalFlags,
376
                                                      nsIObserver* aObserver) override;
377
378
#if GTK_CHECK_VERSION(3,4,0)
379
    virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
380
                                                TouchPointerState aPointerState,
381
                                                LayoutDeviceIntPoint aPoint,
382
                                                double aPointerPressure,
383
                                                uint32_t aPointerOrientation,
384
                                                nsIObserver* aObserver) override;
385
#endif
386
387
388
#ifdef MOZ_X11
389
0
    Display* XDisplay() { return mXDisplay; }
390
#endif
391
#ifdef MOZ_WAYLAND
392
    wl_display* GetWaylandDisplay();
393
    wl_surface* GetWaylandSurface();
394
#endif
395
    virtual void GetCompositorWidgetInitData(mozilla::widget::CompositorWidgetInitData* aInitData) override;
396
397
    virtual nsresult SetNonClientMargins(LayoutDeviceIntMargin& aMargins) override;
398
    void SetDrawsInTitlebar(bool aState) override;
399
    virtual void UpdateWindowDraggingRegion(const LayoutDeviceIntRegion& aRegion) override;
400
401
    // HiDPI scale conversion
402
    gint GdkScaleFactor();
403
404
    // To GDK
405
    gint DevicePixelsToGdkCoordRoundUp(int pixels);
406
    gint DevicePixelsToGdkCoordRoundDown(int pixels);
407
    GdkPoint DevicePixelsToGdkPointRoundDown(LayoutDeviceIntPoint point);
408
    GdkRectangle DevicePixelsToGdkSizeRoundUp(LayoutDeviceIntSize pixelSize);
409
410
    // From GDK
411
    int GdkCoordToDevicePixels(gint coord);
412
    LayoutDeviceIntPoint GdkPointToDevicePixels(GdkPoint point);
413
    LayoutDeviceIntPoint GdkEventCoordsToDevicePixels(gdouble x, gdouble y);
414
    LayoutDeviceIntRect GdkRectToDevicePixels(GdkRectangle rect);
415
416
    virtual bool WidgetTypeSupportsAcceleration() override;
417
418
    nsresult SetSystemFont(const nsCString& aFontName) override;
419
    nsresult GetSystemFont(nsCString& aFontName) override;
420
421
    typedef enum { CSD_SUPPORT_SYSTEM,    // CSD including shadows
422
                   CSD_SUPPORT_CLIENT,    // CSD without shadows
423
                   CSD_SUPPORT_NONE,      // WM does not support CSD at all
424
                   CSD_SUPPORT_UNKNOWN
425
    } CSDSupportLevel;
426
    /**
427
     * Get the support of Client Side Decoration by checking
428
     * the XDG_CURRENT_DESKTOP environment variable.
429
     */
430
    static CSDSupportLevel GetSystemCSDSupportLevel();
431
432
    static bool TopLevelWindowUseARGBVisual();
433
    static bool GetTopLevelWindowActiveState(nsIFrame *aFrame);
434
435
protected:
436
    virtual ~nsWindow();
437
438
    // event handling code
439
    void DispatchActivateEvent(void);
440
    void DispatchDeactivateEvent(void);
441
    void DispatchResized();
442
    void MaybeDispatchResized();
443
444
    // Helper for SetParent and ReparentNativeWidget.
445
    void ReparentNativeWidgetInternal(nsIWidget* aNewParent,
446
                                      GtkWidget* aNewContainer,
447
                                      GdkWindow* aNewParentWindow,
448
                                      GtkWidget* aOldContainer);
449
450
    virtual void RegisterTouchWindow() override;
451
452
    nsCOMPtr<nsIWidget> mParent;
453
    // Is this a toplevel window?
454
    bool                mIsTopLevel;
455
    // Has this widget been destroyed yet?
456
    bool                mIsDestroyed;
457
458
    // Should we send resize events on all resizes?
459
    bool                mListenForResizes;
460
    // Does WindowResized need to be called on listeners?
461
    bool                mNeedsDispatchResized;
462
    // This flag tracks if we're hidden or shown.
463
    bool                mIsShown;
464
    bool                mNeedsShow;
465
    // is this widget enabled?
466
    bool                mEnabled;
467
    // has the native window for this been created yet?
468
    bool                mCreated;
469
#if GTK_CHECK_VERSION(3,4,0)
470
    // whether we handle touch event
471
    bool                mHandleTouchEvent;
472
#endif
473
    // true if this is a drag and drop feedback popup
474
    bool               mIsDragPopup;
475
    // Can we access X?
476
    bool               mIsX11Display;
477
478
private:
479
    void               DestroyChildWindows();
480
    GtkWidget         *GetToplevelWidget();
481
    nsWindow          *GetContainerWindow();
482
    void               SetUrgencyHint(GtkWidget *top_window, bool state);
483
    void               SetDefaultIcon(void);
484
    void               SetWindowDecoration(nsBorderStyle aStyle);
485
    void               InitButtonEvent(mozilla::WidgetMouseEvent& aEvent,
486
                                       GdkEventButton* aGdkEvent);
487
    bool               DispatchCommandEvent(nsAtom* aCommand);
488
    bool               DispatchContentCommandEvent(mozilla::EventMessage aMsg);
489
    bool               CheckForRollup(gdouble aMouseX, gdouble aMouseY,
490
                                      bool aIsWheel, bool aAlwaysRollup);
491
    void               CheckForRollupDuringGrab()
492
0
    {
493
0
      CheckForRollup(0, 0, false, true);
494
0
    }
495
496
    bool               GetDragInfo(mozilla::WidgetMouseEvent* aMouseEvent,
497
                                   GdkWindow** aWindow, gint* aButton,
498
                                   gint* aRootX, gint* aRootY);
499
    void               ClearCachedResources();
500
    nsIWidgetListener* GetListener();
501
502
    void               UpdateClientOffsetForCSDWindow();
503
504
    nsWindow*          GetTransientForWindowIfPopup();
505
    bool               IsHandlingTouchSequence(GdkEventSequence* aSequence);
506
507
#ifdef MOZ_X11
508
    typedef enum { GTK_WIDGET_COMPOSIDED_DEFAULT = 0,
509
                   GTK_WIDGET_COMPOSIDED_DISABLED = 1,
510
                   GTK_WIDGET_COMPOSIDED_ENABLED = 2
511
    } WindowComposeRequest;
512
513
    void                SetCompositorHint(WindowComposeRequest aState);
514
#endif
515
    nsCString           mGtkWindowTypeName;
516
    nsCString           mGtkWindowRoleName;
517
    void                RefreshWindowClass();
518
519
    GtkWidget          *mShell;
520
    MozContainer       *mContainer;
521
    GdkWindow          *mGdkWindow;
522
    PlatformCompositorWidgetDelegate* mCompositorWidgetDelegate;
523
524
525
    uint32_t            mHasMappedToplevel : 1,
526
                        mIsFullyObscured : 1,
527
                        mRetryPointerGrab : 1;
528
    nsSizeMode          mSizeState;
529
530
    int32_t             mTransparencyBitmapWidth;
531
    int32_t             mTransparencyBitmapHeight;
532
533
    nsIntPoint          mClientOffset;
534
535
#if GTK_CHECK_VERSION(3,4,0)
536
    // This field omits duplicate scroll events caused by GNOME bug 726878.
537
    guint32             mLastScrollEventTime;
538
539
    // for touch event handling
540
    nsRefPtrHashtable<nsPtrHashKey<GdkEventSequence>, mozilla::dom::Touch> mTouches;
541
#endif
542
543
#ifdef MOZ_X11
544
    Display*            mXDisplay;
545
    Window              mXWindow;
546
    Visual*             mXVisual;
547
    int                 mXDepth;
548
    mozilla::widget::WindowSurfaceProvider mSurfaceProvider;
549
#endif
550
551
    // Upper bound on pending ConfigureNotify events to be dispatched to the
552
    // window. See bug 1225044.
553
    unsigned int mPendingConfigures;
554
555
    // Window titlebar rendering mode, CSD_SUPPORT_NONE if it's disabled
556
    // for this window.
557
    CSDSupportLevel    mCSDSupportLevel;
558
    // If true, draw our own window titlebar.
559
    bool               mDrawInTitlebar;
560
    // Draggable titlebar region maintained by UpdateWindowDraggingRegion
561
    LayoutDeviceIntRegion mDraggableRegion;
562
563
#ifdef ACCESSIBILITY
564
    RefPtr<mozilla::a11y::Accessible> mRootAccessible;
565
566
    /**
567
     * Request to create the accessible for this window if it is top level.
568
     */
569
    void                CreateRootAccessible();
570
571
    /**
572
     * Dispatch accessible event for the top level window accessible.
573
     *
574
     * @param  aEventType  [in] the accessible event type to dispatch
575
     */
576
    void                DispatchEventToRootAccessible(uint32_t aEventType);
577
578
    /**
579
     * Dispatch accessible window activate event for the top level window
580
     * accessible.
581
     */
582
    void                DispatchActivateEventAccessible();
583
584
    /**
585
     * Dispatch accessible window deactivate event for the top level window
586
     * accessible.
587
     */
588
    void                DispatchDeactivateEventAccessible();
589
590
    /**
591
     * Dispatch accessible window maximize event for the top level window
592
     * accessible.
593
     */
594
    void                DispatchMaximizeEventAccessible();
595
596
    /**
597
     * Dispatch accessible window minize event for the top level window
598
     * accessible.
599
     */
600
    void                DispatchMinimizeEventAccessible();
601
602
    /**
603
     * Dispatch accessible window restore event for the top level window
604
     * accessible.
605
     */
606
    void                DispatchRestoreEventAccessible();
607
#endif
608
609
    // The cursor cache
610
    static GdkCursor   *gsGtkCursorCache[eCursorCount];
611
612
    // Transparency
613
    bool         mIsTransparent;
614
    // This bitmap tracks which pixels are transparent. We don't support
615
    // full translucency at this time; each pixel is either fully opaque
616
    // or fully transparent.
617
    gchar*       mTransparencyBitmap;
618
    // True when we're on compositing window manager and this
619
    // window is using visual with alpha channel.
620
    bool         mHasAlphaVisual;
621
622
    // all of our DND stuff
623
    void   InitDragEvent(mozilla::WidgetDragEvent& aEvent);
624
625
    float              mLastMotionPressure;
626
627
    // Remember the last sizemode so that we can restore it when
628
    // leaving fullscreen
629
    nsSizeMode         mLastSizeMode;
630
631
    static bool DragInProgress(void);
632
633
    void DispatchMissedButtonReleases(GdkEventCrossing *aGdkEvent);
634
635
    // nsBaseWidget
636
    virtual LayerManager* GetLayerManager(PLayerTransactionChild* aShadowManager = nullptr,
637
                                          LayersBackend aBackendHint = mozilla::layers::LayersBackend::LAYERS_NONE,
638
                                          LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT) override;
639
640
    void SetCompositorWidgetDelegate(CompositorWidgetDelegate* delegate) override;
641
642
    void CleanLayerManagerRecursive();
643
644
    virtual int32_t RoundsWidgetCoordinatesTo() override;
645
646
    /**
647
     * |mIMContext| takes all IME related stuff.
648
     *
649
     * This is owned by the top-level nsWindow or the topmost child
650
     * nsWindow embedded in a non-Gecko widget.
651
     *
652
     * The instance is created when the top level widget is created.  And when
653
     * the widget is destroyed, it's released.  All child windows refer its
654
     * ancestor widget's instance.  So, one set of IM contexts is created for
655
     * all windows in a hierarchy.  If the children are released after the top
656
     * level window is released, the children still have a valid pointer,
657
     * however, IME doesn't work at that time.
658
     */
659
    RefPtr<mozilla::widget::IMContextWrapper> mIMContext;
660
661
    mozilla::UniquePtr<mozilla::CurrentX11TimeGetter> mCurrentTimeGetter;
662
    static CSDSupportLevel sCSDSupportLevel;
663
};
664
665
#endif /* __nsWindow_h__ */