2002-04-27 20:26:10 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim:expandtab:shiftwidth=4:tabstop=4:
|
|
|
|
*/
|
2012-05-21 15:12:37 +04: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/. */
|
2001-07-26 02:05:10 +04:00
|
|
|
|
2001-12-07 08:23:56 +03:00
|
|
|
#ifndef __nsWindow_h__
|
2007-01-23 02:51:15 +03:00
|
|
|
#define __nsWindow_h__
|
2001-12-07 08:23:56 +03:00
|
|
|
|
2001-12-04 19:58:04 +03:00
|
|
|
#include "mozcontainer.h"
|
2016-04-20 01:29:16 +03:00
|
|
|
#include "mozilla/RefPtr.h"
|
|
|
|
#include "mozilla/UniquePtr.h"
|
2002-08-10 20:18:44 +04:00
|
|
|
#include "nsIDragService.h"
|
|
|
|
#include "nsITimer.h"
|
2011-10-14 22:11:22 +04:00
|
|
|
#include "nsGkAtoms.h"
|
2015-04-29 23:29:34 +03:00
|
|
|
#include "nsRefPtrHashtable.h"
|
2002-08-10 20:18:44 +04:00
|
|
|
|
2008-10-19 05:13:27 +04:00
|
|
|
#include "nsBaseWidget.h"
|
2009-01-03 10:37:52 +03:00
|
|
|
#include <gdk/gdk.h>
|
2002-08-10 20:18:44 +04:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2008-08-07 00:48:55 +04:00
|
|
|
#ifdef MOZ_X11
|
2002-09-02 09:11:10 +04:00
|
|
|
#include <gdk/gdkx.h>
|
2008-08-07 00:48:55 +04:00
|
|
|
#endif /* MOZ_X11 */
|
2002-01-12 10:14:54 +03:00
|
|
|
|
2016-07-11 23:08:43 +03:00
|
|
|
#include "mozilla/widget/WindowSurface.h"
|
2016-07-22 20:23:07 +03:00
|
|
|
#include "mozilla/widget/WindowSurfaceProvider.h"
|
2016-02-18 18:56:15 +03:00
|
|
|
|
2002-10-14 12:43:35 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2012-05-29 05:18:45 +04:00
|
|
|
#include "mozilla/a11y/Accessible.h"
|
2002-10-14 12:43:35 +04:00
|
|
|
#endif
|
2013-10-22 17:27:35 +04:00
|
|
|
#include "mozilla/EventForwards.h"
|
2015-04-29 23:29:34 +03:00
|
|
|
#include "mozilla/TouchEvents.h"
|
2002-10-14 12:43:35 +04:00
|
|
|
|
2015-07-27 02:23:04 +03:00
|
|
|
#include "IMContextWrapper.h"
|
2002-09-26 10:20:01 +04:00
|
|
|
|
2013-08-12 03:15:10 +04:00
|
|
|
#undef LOG
|
2008-10-19 05:13:27 +04:00
|
|
|
#ifdef MOZ_LOGGING
|
|
|
|
|
2015-05-19 21:15:34 +03:00
|
|
|
#include "mozilla/Logging.h"
|
2009-01-22 07:15:34 +03:00
|
|
|
#include "nsTArray.h"
|
2015-03-30 18:35:25 +03:00
|
|
|
#include "Units.h"
|
2008-10-19 05:13:27 +04:00
|
|
|
|
|
|
|
extern PRLogModuleInfo *gWidgetLog;
|
|
|
|
extern PRLogModuleInfo *gWidgetFocusLog;
|
2009-06-15 04:48:52 +04:00
|
|
|
extern PRLogModuleInfo *gWidgetDragLog;
|
2008-10-19 05:13:27 +04:00
|
|
|
extern PRLogModuleInfo *gWidgetDrawLog;
|
|
|
|
|
2015-06-04 01:25:57 +03:00
|
|
|
#define LOG(args) MOZ_LOG(gWidgetLog, mozilla::LogLevel::Debug, args)
|
|
|
|
#define LOGFOCUS(args) MOZ_LOG(gWidgetFocusLog, mozilla::LogLevel::Debug, args)
|
|
|
|
#define LOGDRAG(args) MOZ_LOG(gWidgetDragLog, mozilla::LogLevel::Debug, args)
|
|
|
|
#define LOGDRAW(args) MOZ_LOG(gWidgetDrawLog, mozilla::LogLevel::Debug, args)
|
2008-10-19 05:13:27 +04:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define LOG(args)
|
|
|
|
#define LOGFOCUS(args)
|
2009-06-20 05:35:08 +04:00
|
|
|
#define LOGDRAG(args)
|
2008-10-19 05:13:27 +04:00
|
|
|
#define LOGDRAW(args)
|
|
|
|
|
|
|
|
#endif /* MOZ_LOGGING */
|
|
|
|
|
2013-09-20 06:00:35 +04:00
|
|
|
class gfxPattern;
|
2015-01-29 22:41:57 +03:00
|
|
|
class nsPluginNativeWindowGtk;
|
2008-10-19 05:13:27 +04:00
|
|
|
|
2015-08-11 10:40:34 +03:00
|
|
|
namespace mozilla {
|
|
|
|
class TimeStamp;
|
2015-08-11 11:13:44 +03:00
|
|
|
class CurrentX11TimeGetter;
|
2015-08-11 10:40:34 +03:00
|
|
|
}
|
|
|
|
|
2015-02-18 09:27:53 +03:00
|
|
|
class nsWindow : public nsBaseWidget
|
2006-03-14 09:07:54 +03:00
|
|
|
{
|
2002-04-27 20:26:10 +04:00
|
|
|
public:
|
2016-06-03 13:27:31 +03:00
|
|
|
typedef mozilla::gfx::DrawTarget DrawTarget;
|
2016-03-16 07:47:49 +03:00
|
|
|
typedef mozilla::WidgetEventTime WidgetEventTime;
|
|
|
|
|
2002-04-27 20:26:10 +04:00
|
|
|
nsWindow();
|
|
|
|
|
2003-07-02 23:27:38 +04:00
|
|
|
static void ReleaseGlobals();
|
|
|
|
|
2002-04-27 20:26:10 +04:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2016-07-22 11:56:13 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
void CommonCreate(nsIWidget *aParent, bool aListenForResizes);
|
2016-07-22 11:56:13 +03:00
|
|
|
|
2013-10-02 07:46:03 +04:00
|
|
|
virtual nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsEventStatus& aStatus) override;
|
2016-07-22 11:56:13 +03:00
|
|
|
|
2008-10-19 05:13:27 +04:00
|
|
|
// called when we are destroyed
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void OnDestroy(void) override;
|
2008-10-19 05:13:27 +04:00
|
|
|
|
|
|
|
// called to check and see if a widget's dimensions are sane
|
2011-09-29 10:19:26 +04:00
|
|
|
bool AreBoundsSane(void);
|
2002-04-27 20:26:10 +04:00
|
|
|
|
|
|
|
// nsIWidget
|
2016-01-13 10:32:55 +03:00
|
|
|
using nsBaseWidget::Create; // for Create signature not overridden here
|
2016-08-19 02:03:17 +03:00
|
|
|
virtual MOZ_MUST_USE nsresult Create(nsIWidget* aParent,
|
|
|
|
nsNativeWidget aNativeParent,
|
|
|
|
const LayoutDeviceIntRect& aRect,
|
|
|
|
nsWidgetInitData* aInitData) override;
|
2016-08-10 03:04:11 +03:00
|
|
|
virtual void Destroy() override;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsIWidget *GetParent() override;
|
|
|
|
virtual float GetDPI() override;
|
2016-07-22 11:56:13 +03:00
|
|
|
virtual double GetDefaultScaleInternal() override;
|
2016-01-18 15:24:06 +03:00
|
|
|
// Under Gtk, we manage windows using device pixels so no scaling is needed:
|
|
|
|
mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScale() final
|
|
|
|
{
|
|
|
|
return mozilla::DesktopToLayoutDeviceScale(1.0);
|
|
|
|
}
|
2016-12-16 02:54:11 +03:00
|
|
|
virtual void SetParent(nsIWidget* aNewParent) override;
|
2016-08-25 06:43:26 +03:00
|
|
|
virtual void SetModal(bool aModal) override;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsVisible() const override;
|
2016-08-25 06:43:27 +03:00
|
|
|
virtual void ConstrainPosition(bool aAllowSlop,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t *aX,
|
2015-03-21 19:28:04 +03:00
|
|
|
int32_t *aY) override;
|
|
|
|
virtual void SetSizeConstraints(const SizeConstraints& aConstraints) override;
|
2016-12-19 12:54:03 +03:00
|
|
|
virtual void Move(double aX,
|
2015-03-21 19:28:04 +03:00
|
|
|
double aY) override;
|
2016-12-21 03:12:54 +03:00
|
|
|
virtual void Show (bool aState) override;
|
2016-12-19 12:54:03 +03:00
|
|
|
virtual void Resize (double aWidth,
|
2012-12-12 13:57:38 +04:00
|
|
|
double aHeight,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aRepaint) override;
|
2016-12-19 12:54:03 +03:00
|
|
|
virtual void Resize (double aX,
|
2012-12-12 13:57:38 +04:00
|
|
|
double aY,
|
|
|
|
double aWidth,
|
|
|
|
double aHeight,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aRepaint) override;
|
|
|
|
virtual bool IsEnabled() const override;
|
2008-10-19 05:13:27 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
void SetZIndex(int32_t aZIndex) override;
|
2016-08-22 02:15:49 +03:00
|
|
|
virtual void SetSizeMode(nsSizeMode aMode) override;
|
2016-12-19 12:54:16 +03:00
|
|
|
virtual void Enable(bool aState) override;
|
2016-12-21 03:13:08 +03:00
|
|
|
virtual nsresult SetFocus(bool aRaise = false) override;
|
2016-08-19 02:03:04 +03:00
|
|
|
virtual LayoutDeviceIntRect GetScreenBounds() override;
|
|
|
|
virtual LayoutDeviceIntRect GetClientBounds() override;
|
2015-11-13 12:37:02 +03:00
|
|
|
virtual LayoutDeviceIntSize GetClientSize() override;
|
|
|
|
virtual LayoutDeviceIntPoint GetClientOffset() override;
|
2016-12-21 03:13:08 +03:00
|
|
|
virtual void SetCursor(nsCursor aCursor) override;
|
|
|
|
virtual nsresult SetCursor(imgIContainer* aCursor,
|
2015-03-21 19:28:04 +03:00
|
|
|
uint32_t aHotspotX, uint32_t aHotspotY) override;
|
2016-12-20 01:55:32 +03:00
|
|
|
virtual void Invalidate(const LayoutDeviceIntRect& aRect) override;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void* GetNativeData(uint32_t aDataType) override;
|
|
|
|
void SetNativeData(uint32_t aDataType, uintptr_t aVal) override;
|
2016-12-21 03:13:08 +03:00
|
|
|
virtual nsresult SetTitle(const nsAString& aTitle) override;
|
2016-12-16 02:54:11 +03:00
|
|
|
virtual void SetIcon(const nsAString& aIconSpec) override;
|
2016-08-25 06:43:27 +03:00
|
|
|
virtual void SetWindowClass(const nsAString& xulWinType) override;
|
2015-11-13 12:37:02 +03:00
|
|
|
virtual LayoutDeviceIntPoint WidgetToScreenOffset() override;
|
2016-08-25 07:10:02 +03:00
|
|
|
virtual void CaptureMouse(bool aCapture) override;
|
2016-08-25 06:43:27 +03:00
|
|
|
virtual void CaptureRollupEvents(nsIRollupListener *aListener,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aDoCapture) override;
|
2016-12-16 02:54:02 +03:00
|
|
|
virtual MOZ_MUST_USE nsresult GetAttention(int32_t aCycleCount) override;
|
2015-12-03 01:32:55 +03:00
|
|
|
virtual nsresult SetWindowClipRegion(const nsTArray<LayoutDeviceIntRect>& aRects,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aIntersectWithExisting) override;
|
|
|
|
virtual bool HasPendingInputEvent() override;
|
2009-04-22 03:53:52 +04:00
|
|
|
|
2015-07-24 02:45:00 +03:00
|
|
|
virtual bool PrepareForFullscreenTransition(nsISupports** aData) override;
|
|
|
|
virtual void PerformFullscreenTransition(FullscreenTransitionStage aStage,
|
|
|
|
uint16_t aDuration,
|
|
|
|
nsISupports* aData,
|
|
|
|
nsIRunnable* aCallback) override;
|
2016-08-19 02:27:28 +03:00
|
|
|
virtual nsresult MakeFullScreen(bool aFullScreen,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsIScreen* aTargetScreen = nullptr) override;
|
2016-12-16 02:54:12 +03:00
|
|
|
virtual void HideWindowChrome(bool aShouldHide) override;
|
2002-04-27 20:26:10 +04:00
|
|
|
|
2012-02-02 06:12:26 +04:00
|
|
|
/**
|
2012-02-14 00:19:59 +04:00
|
|
|
* GetLastUserInputTime returns a timestamp for the most recent user input
|
|
|
|
* event. This is intended for pointer grab requests (including drags).
|
2012-02-02 06:12:26 +04:00
|
|
|
*/
|
2012-02-14 00:19:59 +04:00
|
|
|
static guint32 GetLastUserInputTime();
|
2012-02-02 06:12:26 +04:00
|
|
|
|
2010-07-27 17:38:04 +04:00
|
|
|
// utility method, -1 if no change should be made, otherwise returns a
|
|
|
|
// value that can be passed to gdk_window_set_decorations
|
2003-05-01 06:32:24 +04:00
|
|
|
gint ConvertBorderStyles(nsBorderStyle aStyle);
|
2002-04-27 20:26:10 +04:00
|
|
|
|
2015-11-17 08:18:31 +03:00
|
|
|
GdkRectangle DevicePixelsToGdkRectRoundOut(LayoutDeviceIntRect aRect);
|
2015-07-27 08:37:02 +03:00
|
|
|
|
2002-04-27 20:26:10 +04:00
|
|
|
// event callbacks
|
2013-09-23 17:21:35 +04:00
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
2011-09-23 00:58:07 +04:00
|
|
|
gboolean OnExposeEvent(GdkEventExpose *aEvent);
|
|
|
|
#else
|
|
|
|
gboolean OnExposeEvent(cairo_t *cr);
|
|
|
|
#endif
|
2002-04-27 20:26:10 +04:00
|
|
|
gboolean OnConfigureEvent(GtkWidget *aWidget,
|
|
|
|
GdkEventConfigure *aEvent);
|
2012-10-23 02:33:30 +04:00
|
|
|
void OnContainerUnrealize();
|
|
|
|
void OnSizeAllocate(GtkAllocation *aAllocation);
|
|
|
|
void OnDeleteEvent();
|
|
|
|
void OnEnterNotifyEvent(GdkEventCrossing *aEvent);
|
|
|
|
void OnLeaveNotifyEvent(GdkEventCrossing *aEvent);
|
|
|
|
void OnMotionNotifyEvent(GdkEventMotion *aEvent);
|
|
|
|
void OnButtonPressEvent(GdkEventButton *aEvent);
|
|
|
|
void OnButtonReleaseEvent(GdkEventButton *aEvent);
|
|
|
|
void OnContainerFocusInEvent(GdkEventFocus *aEvent);
|
|
|
|
void OnContainerFocusOutEvent(GdkEventFocus *aEvent);
|
|
|
|
gboolean OnKeyPressEvent(GdkEventKey *aEvent);
|
|
|
|
gboolean OnKeyReleaseEvent(GdkEventKey *aEvent);
|
|
|
|
void OnScrollEvent(GdkEventScroll *aEvent);
|
|
|
|
void OnVisibilityNotifyEvent(GdkEventVisibility *aEvent);
|
2002-04-30 23:03:12 +04:00
|
|
|
void OnWindowStateEvent(GtkWidget *aWidget,
|
|
|
|
GdkEventWindowState *aEvent);
|
2002-08-10 21:07:40 +04:00
|
|
|
void OnDragDataReceivedEvent(GtkWidget *aWidget,
|
|
|
|
GdkDragContext *aDragContext,
|
|
|
|
gint aX,
|
|
|
|
gint aY,
|
|
|
|
GtkSelectionData*aSelectionData,
|
|
|
|
guint aInfo,
|
|
|
|
guint aTime,
|
|
|
|
gpointer aData);
|
2015-10-09 16:24:48 +03:00
|
|
|
gboolean OnPropertyNotifyEvent(GtkWidget *aWidget,
|
|
|
|
GdkEventProperty *aEvent);
|
2015-04-29 23:29:34 +03:00
|
|
|
#if GTK_CHECK_VERSION(3,4,0)
|
|
|
|
gboolean OnTouchEvent(GdkEventTouch* aEvent);
|
|
|
|
#endif
|
2002-08-10 21:07:40 +04:00
|
|
|
|
2015-06-17 17:00:52 +03:00
|
|
|
virtual already_AddRefed<mozilla::gfx::DrawTarget>
|
2016-02-19 04:57:29 +03:00
|
|
|
StartRemoteDrawingInRegion(LayoutDeviceIntRegion& aInvalidRegion,
|
|
|
|
mozilla::layers::BufferMode* aBufferMode) override;
|
2015-05-01 21:08:04 +03:00
|
|
|
virtual void EndRemoteDrawingInRegion(mozilla::gfx::DrawTarget* aDrawTarget,
|
2015-12-03 09:29:54 +03:00
|
|
|
LayoutDeviceIntRegion& aInvalidRegion) override;
|
2013-07-09 08:21:05 +04:00
|
|
|
|
2012-02-02 06:12:02 +04:00
|
|
|
private:
|
2015-11-11 18:15:40 +03:00
|
|
|
void UpdateAlpha(mozilla::gfx::SourceSurface* aSourceSurface, nsIntRect aBoundsRect);
|
2013-09-20 06:00:35 +04:00
|
|
|
|
2015-07-13 05:29:05 +03:00
|
|
|
void NativeMove();
|
2015-07-14 06:24:56 +03:00
|
|
|
void NativeResize();
|
|
|
|
void NativeMoveResize();
|
2002-04-27 20:26:10 +04:00
|
|
|
|
2012-02-02 06:12:02 +04:00
|
|
|
void NativeShow (bool aAction);
|
2011-09-29 10:19:26 +04:00
|
|
|
void SetHasMappedToplevel(bool aState);
|
2015-11-13 12:37:02 +03:00
|
|
|
LayoutDeviceIntSize GetSafeWindowSize(LayoutDeviceIntSize aSize);
|
2002-04-27 20:26:10 +04:00
|
|
|
|
|
|
|
void EnsureGrabs (void);
|
2012-02-02 06:12:26 +04:00
|
|
|
void GrabPointer (guint32 aTime);
|
2002-04-27 20:26:10 +04:00
|
|
|
void ReleaseGrabs (void);
|
2003-02-17 18:36:37 +03:00
|
|
|
|
2015-10-09 16:24:48 +03:00
|
|
|
void UpdateClientOffset();
|
|
|
|
|
2012-02-02 06:12:02 +04:00
|
|
|
public:
|
2003-09-16 05:44:41 +04:00
|
|
|
enum PluginType {
|
|
|
|
PluginType_NONE = 0, /* do not have any plugin */
|
|
|
|
PluginType_XEMBED, /* the plugin support xembed */
|
|
|
|
PluginType_NONXEMBED /* the plugin does not support xembed */
|
|
|
|
};
|
|
|
|
|
|
|
|
void SetPluginType(PluginType aPluginType);
|
2008-08-07 00:48:55 +04:00
|
|
|
#ifdef MOZ_X11
|
2003-02-17 18:36:37 +03:00
|
|
|
void SetNonXEmbedPluginFocus(void);
|
|
|
|
void LoseNonXEmbedPluginFocus(void);
|
2008-08-07 00:48:55 +04:00
|
|
|
#endif /* MOZ_X11 */
|
2002-04-27 20:26:10 +04:00
|
|
|
|
2004-09-17 10:27:01 +04:00
|
|
|
void ThemeChanged(void);
|
2016-02-24 12:58:58 +03:00
|
|
|
void OnDPIChanged(void);
|
2016-06-24 21:51:28 +03:00
|
|
|
void OnCheckResize(void);
|
2004-09-17 10:27:01 +04:00
|
|
|
|
2008-08-07 00:48:55 +04:00
|
|
|
#ifdef MOZ_X11
|
2003-02-17 21:50:01 +03:00
|
|
|
Window mOldFocusWindow;
|
2008-08-07 00:48:55 +04:00
|
|
|
#endif /* MOZ_X11 */
|
2003-02-17 21:50:01 +03:00
|
|
|
|
2010-03-24 06:37:06 +03:00
|
|
|
static guint32 sLastButtonPressTime;
|
2002-09-26 10:20:01 +04:00
|
|
|
|
2016-12-16 02:54:02 +03:00
|
|
|
virtual MOZ_MUST_USE nsresult
|
|
|
|
BeginResizeDrag(mozilla::WidgetGUIEvent* aEvent,
|
2013-10-02 07:46:03 +04:00
|
|
|
int32_t aHorizontal,
|
2015-03-21 19:28:04 +03:00
|
|
|
int32_t aVertical) override;
|
2016-12-16 02:54:02 +03:00
|
|
|
virtual MOZ_MUST_USE nsresult
|
|
|
|
BeginMoveDrag(mozilla::WidgetMouseEvent* aEvent) override;
|
2007-12-11 13:08:35 +03:00
|
|
|
|
2010-03-19 07:21:16 +03:00
|
|
|
MozContainer* GetMozContainer() { return mContainer; }
|
2012-04-19 10:18:31 +04:00
|
|
|
// GetMozContainerWidget returns the MozContainer even for undestroyed
|
|
|
|
// descendant windows
|
|
|
|
GtkWidget* GetMozContainerWidget();
|
2010-03-19 07:21:16 +03:00
|
|
|
GdkWindow* GetGdkWindow() { return mGdkWindow; }
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsDestroyed() { return mIsDestroyed; }
|
2010-03-19 07:21:16 +03:00
|
|
|
|
2015-08-26 15:56:59 +03:00
|
|
|
void DispatchDragEvent(mozilla::EventMessage aMsg,
|
2015-11-13 12:37:02 +03:00
|
|
|
const LayoutDeviceIntPoint& aRefPoint,
|
2012-04-17 05:00:25 +04:00
|
|
|
guint aTime);
|
2012-04-19 10:18:31 +04:00
|
|
|
static void UpdateDragStatus (GdkDragContext *aDragContext,
|
|
|
|
nsIDragService *aDragService);
|
2010-03-19 07:21:16 +03:00
|
|
|
// If this dispatched the keydown event actually, this returns TRUE,
|
|
|
|
// otherwise, FALSE.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool DispatchKeyDownEvent(GdkEventKey *aEvent,
|
|
|
|
bool *aIsCancelled);
|
2016-03-16 07:47:49 +03:00
|
|
|
WidgetEventTime GetWidgetEventTime(guint32 aEventTime);
|
2015-08-11 10:40:34 +03:00
|
|
|
mozilla::TimeStamp GetEventTimeStamp(guint32 aEventTime);
|
2015-08-11 11:13:44 +03:00
|
|
|
mozilla::CurrentX11TimeGetter* GetCurrentTimeGetter();
|
2006-03-14 09:07:54 +03:00
|
|
|
|
2016-12-21 07:27:20 +03:00
|
|
|
virtual void SetInputContext(const InputContext& aContext,
|
|
|
|
const InputContextAction& aAction) override;
|
|
|
|
virtual InputContext GetInputContext() override;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsIMEUpdatePreference GetIMEUpdatePreference() override;
|
2016-12-21 07:27:20 +03:00
|
|
|
virtual TextEventDispatcherListener*
|
2016-03-16 07:47:49 +03:00
|
|
|
GetNativeTextEventDispatcherListener() override;
|
2014-11-22 17:39:04 +03:00
|
|
|
bool ExecuteNativeKeyBindingRemapped(
|
|
|
|
NativeKeyBindingsType aType,
|
|
|
|
const mozilla::WidgetKeyboardEvent& aEvent,
|
|
|
|
DoCommandCallback aCallback,
|
|
|
|
void* aCallbackData,
|
|
|
|
uint32_t aGeckoKeyCode,
|
|
|
|
uint32_t aNativeKeyCode);
|
2016-12-21 07:27:20 +03:00
|
|
|
virtual bool ExecuteNativeKeyBinding(
|
2014-03-14 17:13:31 +04:00
|
|
|
NativeKeyBindingsType aType,
|
|
|
|
const mozilla::WidgetKeyboardEvent& aEvent,
|
|
|
|
DoCommandCallback aCallback,
|
2015-03-21 19:28:04 +03:00
|
|
|
void* aCallbackData) override;
|
2006-03-14 09:07:54 +03:00
|
|
|
|
2012-10-03 02:37:06 +04:00
|
|
|
// These methods are for toplevel windows only.
|
|
|
|
void ResizeTransparencyBitmap();
|
|
|
|
void ApplyTransparencyBitmap();
|
|
|
|
void ClearTransparencyBitmap();
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void SetTransparencyMode(nsTransparencyMode aMode) override;
|
|
|
|
virtual nsTransparencyMode GetTransparencyMode() override;
|
|
|
|
virtual nsresult ConfigureChildren(const nsTArray<Configuration>& aConfigurations) override;
|
2009-01-15 06:27:09 +03:00
|
|
|
nsresult UpdateTranslucentWindowAlphaInternal(const nsIntRect& aRect,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t* aAlphas, int32_t aStride);
|
2016-02-19 04:57:29 +03:00
|
|
|
|
2013-09-23 17:21:35 +04:00
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
2016-06-03 13:27:31 +03:00
|
|
|
static already_AddRefed<DrawTarget> GetDrawTargetForGdkDrawable(GdkDrawable* aDrawable,
|
2016-06-21 09:28:34 +03:00
|
|
|
const mozilla::gfx::IntSize& aSize);
|
2011-09-23 00:58:07 +04:00
|
|
|
#endif
|
2016-08-25 06:43:26 +03:00
|
|
|
virtual void ReparentNativeWidget(nsIWidget* aNewParent) override;
|
2008-06-18 13:20:29 +04:00
|
|
|
|
2015-11-13 12:37:02 +03:00
|
|
|
virtual nsresult SynthesizeNativeMouseEvent(LayoutDeviceIntPoint aPoint,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aNativeMessage,
|
2015-04-14 18:36:36 +03:00
|
|
|
uint32_t aModifierFlags,
|
|
|
|
nsIObserver* aObserver) override;
|
2012-04-12 01:55:21 +04:00
|
|
|
|
2015-11-13 12:37:02 +03:00
|
|
|
virtual nsresult SynthesizeNativeMouseMove(LayoutDeviceIntPoint aPoint,
|
2015-04-14 18:36:36 +03:00
|
|
|
nsIObserver* aObserver) override
|
|
|
|
{ return SynthesizeNativeMouseEvent(aPoint, GDK_MOTION_NOTIFY, 0, aObserver); }
|
2012-04-12 01:55:21 +04:00
|
|
|
|
2015-11-13 12:37:02 +03:00
|
|
|
virtual nsresult SynthesizeNativeMouseScrollEvent(LayoutDeviceIntPoint aPoint,
|
2015-05-12 00:21:34 +03:00
|
|
|
uint32_t aNativeMessage,
|
|
|
|
double aDeltaX,
|
|
|
|
double aDeltaY,
|
|
|
|
double aDeltaZ,
|
|
|
|
uint32_t aModifierFlags,
|
|
|
|
uint32_t aAdditionalFlags,
|
|
|
|
nsIObserver* aObserver) override;
|
|
|
|
|
2016-02-23 18:17:46 +03:00
|
|
|
#if GTK_CHECK_VERSION(3,4,0)
|
|
|
|
virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
|
|
|
|
TouchPointerState aPointerState,
|
2016-04-15 13:39:36 +03:00
|
|
|
LayoutDeviceIntPoint aPoint,
|
2016-02-23 18:17:46 +03:00
|
|
|
double aPointerPressure,
|
|
|
|
uint32_t aPointerOrientation,
|
|
|
|
nsIObserver* aObserver) override;
|
|
|
|
#endif
|
|
|
|
|
2016-10-27 21:39:59 +03:00
|
|
|
#ifdef MOZ_X11
|
|
|
|
Display* XDisplay() { return mXDisplay; }
|
|
|
|
#endif
|
2016-07-22 20:23:07 +03:00
|
|
|
virtual void GetCompositorWidgetInitData(mozilla::widget::CompositorWidgetInitData* aInitData) override;
|
|
|
|
|
2015-10-22 07:06:14 +03:00
|
|
|
// HiDPI scale conversion
|
|
|
|
gint GdkScaleFactor();
|
|
|
|
|
|
|
|
// To GDK
|
|
|
|
gint DevicePixelsToGdkCoordRoundUp(int pixels);
|
|
|
|
gint DevicePixelsToGdkCoordRoundDown(int pixels);
|
2015-11-23 07:32:29 +03:00
|
|
|
GdkPoint DevicePixelsToGdkPointRoundDown(LayoutDeviceIntPoint point);
|
|
|
|
GdkRectangle DevicePixelsToGdkSizeRoundUp(LayoutDeviceIntSize pixelSize);
|
2015-10-22 07:06:14 +03:00
|
|
|
|
|
|
|
// From GDK
|
|
|
|
int GdkCoordToDevicePixels(gint coord);
|
2015-11-13 12:37:02 +03:00
|
|
|
LayoutDeviceIntPoint GdkPointToDevicePixels(GdkPoint point);
|
|
|
|
LayoutDeviceIntPoint GdkEventCoordsToDevicePixels(gdouble x, gdouble y);
|
2015-11-23 07:32:29 +03:00
|
|
|
LayoutDeviceIntRect GdkRectToDevicePixels(GdkRectangle rect);
|
2015-10-22 07:06:14 +03:00
|
|
|
|
2016-10-07 12:08:32 +03:00
|
|
|
virtual bool WidgetTypeSupportsAcceleration() override;
|
2008-10-19 05:13:27 +04:00
|
|
|
protected:
|
2014-07-09 01:23:18 +04:00
|
|
|
virtual ~nsWindow();
|
|
|
|
|
2012-10-23 02:46:45 +04:00
|
|
|
// event handling code
|
|
|
|
void DispatchActivateEvent(void);
|
|
|
|
void DispatchDeactivateEvent(void);
|
2015-11-10 05:09:52 +03:00
|
|
|
void DispatchResized();
|
2015-11-11 03:50:04 +03:00
|
|
|
void MaybeDispatchResized();
|
2012-10-23 02:46:45 +04:00
|
|
|
|
2010-09-18 15:28:50 +04:00
|
|
|
// Helper for SetParent and ReparentNativeWidget.
|
|
|
|
void ReparentNativeWidgetInternal(nsIWidget* aNewParent,
|
|
|
|
GtkWidget* aNewContainer,
|
|
|
|
GdkWindow* aNewParentWindow,
|
|
|
|
GtkWidget* aOldContainer);
|
2015-01-28 09:27:31 +03:00
|
|
|
|
2015-04-29 23:29:34 +03:00
|
|
|
virtual void RegisterTouchWindow() override;
|
|
|
|
|
2008-10-19 05:13:27 +04:00
|
|
|
nsCOMPtr<nsIWidget> mParent;
|
|
|
|
// Is this a toplevel window?
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIsTopLevel;
|
2008-10-19 05:13:27 +04:00
|
|
|
// Has this widget been destroyed yet?
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIsDestroyed;
|
2008-10-19 05:13:27 +04:00
|
|
|
|
|
|
|
// Should we send resize events on all resizes?
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mListenForResizes;
|
2015-11-11 03:50:04 +03:00
|
|
|
// Does WindowResized need to be called on listeners?
|
|
|
|
bool mNeedsDispatchResized;
|
2008-10-19 05:13:27 +04:00
|
|
|
// This flag tracks if we're hidden or shown.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIsShown;
|
|
|
|
bool mNeedsShow;
|
2008-10-19 05:13:27 +04:00
|
|
|
// is this widget enabled?
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mEnabled;
|
2008-10-19 05:13:27 +04:00
|
|
|
// has the native window for this been created yet?
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mCreated;
|
2015-04-29 23:29:34 +03:00
|
|
|
#if GTK_CHECK_VERSION(3,4,0)
|
|
|
|
// whether we handle touch event
|
|
|
|
bool mHandleTouchEvent;
|
|
|
|
#endif
|
2015-11-17 15:13:22 +03:00
|
|
|
// true if this is a drag and drop feedback popup
|
|
|
|
bool mIsDragPopup;
|
2016-06-22 09:10:00 +03:00
|
|
|
// Can we access X?
|
|
|
|
bool mIsX11Display;
|
2008-10-19 05:13:27 +04:00
|
|
|
|
2002-04-27 20:26:10 +04:00
|
|
|
private:
|
2009-11-11 00:57:25 +03:00
|
|
|
void DestroyChildWindows();
|
2012-11-07 01:50:37 +04:00
|
|
|
GtkWidget *GetToplevelWidget();
|
2009-02-20 05:07:08 +03:00
|
|
|
nsWindow *GetContainerWindow();
|
2011-09-29 10:19:26 +04:00
|
|
|
void SetUrgencyHint(GtkWidget *top_window, bool state);
|
2002-09-02 09:11:10 +04:00
|
|
|
void *SetupPluginPort(void);
|
2002-11-16 04:22:10 +03:00
|
|
|
void SetDefaultIcon(void);
|
2013-10-02 10:38:27 +04:00
|
|
|
void InitButtonEvent(mozilla::WidgetMouseEvent& aEvent,
|
|
|
|
GdkEventButton* aGdkEvent);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool DispatchCommandEvent(nsIAtom* aCommand);
|
2015-08-26 15:56:59 +03:00
|
|
|
bool DispatchContentCommandEvent(mozilla::EventMessage aMsg);
|
2012-10-26 17:15:22 +04:00
|
|
|
bool CheckForRollup(gdouble aMouseX, gdouble aMouseY,
|
|
|
|
bool aIsWheel, bool aAlwaysRollup);
|
2016-05-04 17:07:52 +03:00
|
|
|
void CheckForRollupDuringGrab()
|
|
|
|
{
|
|
|
|
CheckForRollup(0, 0, false, true);
|
|
|
|
}
|
|
|
|
|
2013-10-02 10:38:27 +04:00
|
|
|
bool GetDragInfo(mozilla::WidgetMouseEvent* aMouseEvent,
|
2010-07-17 12:11:54 +04:00
|
|
|
GdkWindow** aWindow, gint* aButton,
|
|
|
|
gint* aRootX, gint* aRootY);
|
2011-01-22 00:45:23 +03:00
|
|
|
void ClearCachedResources();
|
2016-05-11 06:58:47 +03:00
|
|
|
nsIWidgetListener* GetListener();
|
2002-04-27 20:26:10 +04:00
|
|
|
|
|
|
|
GtkWidget *mShell;
|
|
|
|
MozContainer *mContainer;
|
2009-07-27 05:39:36 +04:00
|
|
|
GdkWindow *mGdkWindow;
|
2002-04-27 20:26:10 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mHasMappedToplevel : 1,
|
2009-11-02 05:03:12 +03:00
|
|
|
mIsFullyObscured : 1,
|
2011-02-16 23:10:16 +03:00
|
|
|
mRetryPointerGrab : 1;
|
2012-08-15 22:52:42 +04:00
|
|
|
nsSizeMode mSizeState;
|
2003-09-16 05:44:41 +04:00
|
|
|
PluginType mPluginType;
|
2002-05-08 11:42:34 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mTransparencyBitmapWidth;
|
|
|
|
int32_t mTransparencyBitmapHeight;
|
2006-10-16 16:13:54 +04:00
|
|
|
|
2015-10-09 16:24:48 +03:00
|
|
|
nsIntPoint mClientOffset;
|
|
|
|
|
2015-10-19 14:22:55 +03:00
|
|
|
#if GTK_CHECK_VERSION(3,4,0)
|
2014-07-07 13:54:13 +04:00
|
|
|
// This field omits duplicate scroll events caused by GNOME bug 726878.
|
|
|
|
guint32 mLastScrollEventTime;
|
2015-04-29 23:29:34 +03:00
|
|
|
|
|
|
|
// for touch event handling
|
|
|
|
nsRefPtrHashtable<nsPtrHashKey<GdkEventSequence>, mozilla::dom::Touch> mTouches;
|
2015-10-19 14:22:55 +03:00
|
|
|
#endif
|
2014-07-07 13:54:13 +04:00
|
|
|
|
2015-09-15 23:46:39 +03:00
|
|
|
#ifdef MOZ_X11
|
|
|
|
Display* mXDisplay;
|
2016-02-28 07:16:57 +03:00
|
|
|
Window mXWindow;
|
2015-09-15 23:46:39 +03:00
|
|
|
Visual* mXVisual;
|
|
|
|
int mXDepth;
|
2016-07-22 20:23:07 +03:00
|
|
|
mozilla::widget::WindowSurfaceProvider mSurfaceProvider;
|
2015-09-15 23:46:39 +03:00
|
|
|
#endif
|
|
|
|
|
2016-06-24 21:51:28 +03:00
|
|
|
// Upper bound on pending ConfigureNotify events to be dispatched to the
|
|
|
|
// window. See bug 1225044.
|
2017-01-13 17:23:29 +03:00
|
|
|
unsigned int mPendingConfigures;
|
2016-06-24 21:51:28 +03:00
|
|
|
|
2002-05-08 11:42:34 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<mozilla::a11y::Accessible> mRootAccessible;
|
2010-05-12 10:47:35 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Request to create the accessible for this window if it is top level.
|
|
|
|
*/
|
2003-04-23 09:28:41 +04:00
|
|
|
void CreateRootAccessible();
|
2010-05-12 10:47:35 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Dispatch accessible event for the top level window accessible.
|
|
|
|
*
|
|
|
|
* @param aEventType [in] the accessible event type to dispatch
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
void DispatchEventToRootAccessible(uint32_t aEventType);
|
2010-05-12 10:47:35 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Dispatch accessible window activate event for the top level window
|
|
|
|
* accessible.
|
|
|
|
*/
|
2008-10-19 05:13:27 +04:00
|
|
|
void DispatchActivateEventAccessible();
|
2010-05-12 10:47:35 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Dispatch accessible window deactivate event for the top level window
|
|
|
|
* accessible.
|
|
|
|
*/
|
2008-10-19 05:13:27 +04:00
|
|
|
void DispatchDeactivateEventAccessible();
|
2011-03-26 19:06:00 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Dispatch accessible window maximize event for the top level window
|
|
|
|
* accessible.
|
|
|
|
*/
|
|
|
|
void DispatchMaximizeEventAccessible();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Dispatch accessible window minize event for the top level window
|
|
|
|
* accessible.
|
|
|
|
*/
|
|
|
|
void DispatchMinimizeEventAccessible();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Dispatch accessible window restore event for the top level window
|
|
|
|
* accessible.
|
|
|
|
*/
|
|
|
|
void DispatchRestoreEventAccessible();
|
2002-05-08 11:42:34 +04:00
|
|
|
#endif
|
2002-08-10 20:18:44 +04:00
|
|
|
|
2015-01-29 22:41:57 +03:00
|
|
|
// Updates the bounds of the socket widget we manage for remote plugins.
|
|
|
|
void ResizePluginSocketWidget();
|
|
|
|
|
2015-01-29 22:41:57 +03:00
|
|
|
// e10s specific - for managing the socket widget this window hosts.
|
|
|
|
nsPluginNativeWindowGtk* mPluginNativeWindow;
|
|
|
|
|
2002-08-10 22:07:20 +04:00
|
|
|
// The cursor cache
|
2003-05-03 02:23:55 +04:00
|
|
|
static GdkCursor *gsGtkCursorCache[eCursorCount];
|
2002-08-10 22:07:20 +04:00
|
|
|
|
2004-07-24 16:42:32 +04:00
|
|
|
// Transparency
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIsTransparent;
|
2004-07-24 16:42:32 +04:00
|
|
|
// This bitmap tracks which pixels are transparent. We don't support
|
|
|
|
// full translucency at this time; each pixel is either fully opaque
|
|
|
|
// or fully transparent.
|
|
|
|
gchar* mTransparencyBitmap;
|
2016-07-22 11:56:13 +03:00
|
|
|
|
2002-08-10 21:07:40 +04:00
|
|
|
// all of our DND stuff
|
2013-10-01 11:23:02 +04:00
|
|
|
void InitDragEvent(mozilla::WidgetDragEvent& aEvent);
|
2002-08-10 20:18:44 +04:00
|
|
|
|
2008-12-12 02:55:15 +03:00
|
|
|
float mLastMotionPressure;
|
2002-08-10 20:18:44 +04:00
|
|
|
|
2009-08-27 04:09:47 +04:00
|
|
|
// Remember the last sizemode so that we can restore it when
|
|
|
|
// leaving fullscreen
|
|
|
|
nsSizeMode mLastSizeMode;
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool DragInProgress(void);
|
2003-12-03 04:50:50 +03:00
|
|
|
|
2010-03-24 06:37:06 +03:00
|
|
|
void DispatchMissedButtonReleases(GdkEventCrossing *aGdkEvent);
|
|
|
|
|
2012-09-24 03:22:28 +04:00
|
|
|
// nsBaseWidget
|
2013-04-24 22:42:40 +04:00
|
|
|
virtual LayerManager* GetLayerManager(PLayerTransactionChild* aShadowManager = nullptr,
|
2014-01-23 22:26:41 +04:00
|
|
|
LayersBackend aBackendHint = mozilla::layers::LayersBackend::LAYERS_NONE,
|
2016-06-24 03:53:27 +03:00
|
|
|
LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT) override;
|
2012-09-24 03:22:28 +04:00
|
|
|
|
|
|
|
void CleanLayerManagerRecursive();
|
|
|
|
|
2015-06-29 18:50:00 +03:00
|
|
|
virtual int32_t RoundsWidgetCoordinatesTo() override;
|
|
|
|
|
2010-03-19 07:21:16 +03:00
|
|
|
/**
|
2015-07-27 02:23:04 +03:00
|
|
|
* |mIMContext| takes all IME related stuff.
|
2010-03-19 07:21:16 +03:00
|
|
|
*
|
|
|
|
* This is owned by the top-level nsWindow or the topmost child
|
|
|
|
* nsWindow embedded in a non-Gecko widget.
|
|
|
|
*
|
|
|
|
* The instance is created when the top level widget is created. And when
|
|
|
|
* the widget is destroyed, it's released. All child windows refer its
|
|
|
|
* ancestor widget's instance. So, one set of IM contexts is created for
|
|
|
|
* all windows in a hierarchy. If the children are released after the top
|
|
|
|
* level window is released, the children still have a valid pointer,
|
|
|
|
* however, IME doesn't work at that time.
|
|
|
|
*/
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<mozilla::widget::IMContextWrapper> mIMContext;
|
2015-01-21 07:53:00 +03:00
|
|
|
|
2016-04-20 01:29:16 +03:00
|
|
|
mozilla::UniquePtr<mozilla::CurrentX11TimeGetter> mCurrentTimeGetter;
|
2001-07-26 02:05:10 +04:00
|
|
|
};
|
2001-12-07 08:23:56 +03:00
|
|
|
|
|
|
|
class nsChildWindow : public nsWindow {
|
2002-04-27 20:26:10 +04:00
|
|
|
public:
|
|
|
|
nsChildWindow();
|
|
|
|
~nsChildWindow();
|
2001-12-07 08:23:56 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* __nsWindow_h__ */
|