mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1026803 part 4 - Convert GTK native event times to timestamps; r=karlt
This patch adds a helper class to widgets/gtk/nsWindow.cpp similar to the one in widgets/windows/nsWindow.cpp and uses it to convert native event times to mozilla::TimeStamp objects on events returned by this class. This is similar to the operations performed for Windows native event times that were added in bug 77992.
This commit is contained in:
parent
d0c832649d
commit
b59684e8fb
@ -122,6 +122,7 @@ STUB(gdk_x11_display_get_user_time)
|
||||
STUB(gdk_x11_display_get_xdisplay)
|
||||
STUB(gdk_x11_get_default_root_xwindow)
|
||||
STUB(gdk_x11_get_default_xdisplay)
|
||||
STUB(gdk_x11_get_server_time)
|
||||
STUB(gdk_x11_get_xatom_by_name)
|
||||
STUB(gdk_x11_lookup_xdisplay)
|
||||
STUB(gdk_x11_screen_get_xscreen)
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "nsDragService.h"
|
||||
#include "nsIWidgetListener.h"
|
||||
#include "nsIScreenManager.h"
|
||||
#include "SystemTimeConverter.h"
|
||||
|
||||
#include "nsGtkKeyUtils.h"
|
||||
#include "nsGtkCursors.h"
|
||||
@ -261,6 +262,28 @@ static nsresult initialize_prefs (void);
|
||||
static guint32 sLastUserInputTime = GDK_CURRENT_TIME;
|
||||
static guint32 sRetryGrabTime;
|
||||
|
||||
static SystemTimeConverter<guint32>&
|
||||
TimeConverter() {
|
||||
static SystemTimeConverter<guint32> sTimeConverterSingleton;
|
||||
return sTimeConverterSingleton;
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class MOZ_STACK_CLASS CurrentX11TimeGetter
|
||||
{
|
||||
public:
|
||||
CurrentX11TimeGetter(GdkWindow* aWindow) : mWindow(aWindow) { }
|
||||
guint32 operator() () {
|
||||
return gdk_x11_get_server_time(mWindow);
|
||||
}
|
||||
|
||||
private:
|
||||
GdkWindow* mWindow;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
static NS_DEFINE_IID(kCDragServiceCID, NS_DRAGSERVICE_CID);
|
||||
|
||||
// The window from which the focus manager asks us to dispatch key events.
|
||||
@ -2376,6 +2399,7 @@ nsWindow::OnEnterNotifyEvent(GdkEventCrossing *aEvent)
|
||||
event.refPoint.y = nscoord(aEvent->y);
|
||||
|
||||
event.time = aEvent->time;
|
||||
event.timeStamp = GetEventTimeStamp(aEvent->time);
|
||||
|
||||
LOG(("OnEnterNotify: %p\n", (void *)this));
|
||||
|
||||
@ -2417,6 +2441,7 @@ nsWindow::OnLeaveNotifyEvent(GdkEventCrossing *aEvent)
|
||||
event.refPoint.y = nscoord(aEvent->y);
|
||||
|
||||
event.time = aEvent->time;
|
||||
event.timeStamp = GetEventTimeStamp(aEvent->time);
|
||||
|
||||
event.exit = is_top_level_mouse_exit(mGdkWindow, aEvent)
|
||||
? WidgetMouseEvent::eTopLevel : WidgetMouseEvent::eChild;
|
||||
@ -2477,6 +2502,7 @@ nsWindow::OnMotionNotifyEvent(GdkEventMotion *aEvent)
|
||||
modifierState = xevent.xmotion.state;
|
||||
|
||||
event.time = xevent.xmotion.time;
|
||||
event.timeStamp = GetEventTimeStamp(xevent.xmotion.time);
|
||||
#else
|
||||
event.refPoint.x = nscoord(aEvent->x);
|
||||
event.refPoint.y = nscoord(aEvent->y);
|
||||
@ -2484,6 +2510,7 @@ nsWindow::OnMotionNotifyEvent(GdkEventMotion *aEvent)
|
||||
modifierState = aEvent->state;
|
||||
|
||||
event.time = aEvent->time;
|
||||
event.timeStamp = GetEventTimeStamp(aEvent->time);
|
||||
#endif /* MOZ_X11 */
|
||||
}
|
||||
else {
|
||||
@ -2500,6 +2527,7 @@ nsWindow::OnMotionNotifyEvent(GdkEventMotion *aEvent)
|
||||
modifierState = aEvent->state;
|
||||
|
||||
event.time = aEvent->time;
|
||||
event.timeStamp = GetEventTimeStamp(aEvent->time);
|
||||
}
|
||||
|
||||
KeymapWrapper::InitInputEvent(event, modifierState);
|
||||
@ -2596,6 +2624,7 @@ nsWindow::InitButtonEvent(WidgetMouseEvent& aEvent,
|
||||
KeymapWrapper::InitInputEvent(aEvent, modifierState);
|
||||
|
||||
aEvent.time = aGdkEvent->time;
|
||||
aEvent.timeStamp = GetEventTimeStamp(aGdkEvent->time);
|
||||
|
||||
switch (aGdkEvent->type) {
|
||||
case GDK_2BUTTON_PRESS:
|
||||
@ -2855,6 +2884,24 @@ nsWindow::DispatchKeyDownEvent(GdkEventKey *aEvent, bool *aCancelled)
|
||||
return true;
|
||||
}
|
||||
|
||||
TimeStamp
|
||||
nsWindow::GetEventTimeStamp(guint32 aEventTime)
|
||||
{
|
||||
if (MOZ_UNLIKELY(!mGdkWindow)) {
|
||||
// nsWindow has been Destroy()ed.
|
||||
return TimeStamp::Now();
|
||||
}
|
||||
if (aEventTime == 0) {
|
||||
// Some X11 and GDK events may be received with a time of 0 to indicate
|
||||
// that they are synthetic events. Some input method editors do this.
|
||||
// In this case too, just return the current timestamp.
|
||||
return TimeStamp::Now();
|
||||
}
|
||||
CurrentX11TimeGetter getCurrentTime = CurrentX11TimeGetter(mGdkWindow);
|
||||
return TimeConverter().GetTimeStampFromSystemTime(aEventTime,
|
||||
getCurrentTime);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nsWindow::OnKeyPressEvent(GdkEventKey *aEvent)
|
||||
{
|
||||
@ -2958,6 +3005,7 @@ nsWindow::OnKeyPressEvent(GdkEventKey *aEvent)
|
||||
|
||||
contextMenuEvent.refPoint = LayoutDeviceIntPoint(0, 0);
|
||||
contextMenuEvent.time = aEvent->time;
|
||||
contextMenuEvent.timeStamp = GetEventTimeStamp(aEvent->time);
|
||||
contextMenuEvent.clickCount = 1;
|
||||
KeymapWrapper::InitInputEvent(contextMenuEvent, aEvent->state);
|
||||
status = DispatchInputEvent(&contextMenuEvent);
|
||||
@ -2978,6 +3026,7 @@ nsWindow::OnKeyPressEvent(GdkEventKey *aEvent)
|
||||
textString[2] = 0;
|
||||
compositionChangeEvent.mData = textString;
|
||||
compositionChangeEvent.time = event.time;
|
||||
compositionChangeEvent.timeStamp = GetEventTimeStamp(aEvent->time);
|
||||
DispatchEvent(&compositionChangeEvent, status);
|
||||
}
|
||||
}
|
||||
@ -3084,6 +3133,7 @@ nsWindow::OnScrollEvent(GdkEventScroll *aEvent)
|
||||
KeymapWrapper::InitInputEvent(wheelEvent, aEvent->state);
|
||||
|
||||
wheelEvent.time = aEvent->time;
|
||||
wheelEvent.timeStamp = GetEventTimeStamp(aEvent->time);
|
||||
|
||||
DispatchAPZAwareEvent(&wheelEvent);
|
||||
}
|
||||
@ -3228,6 +3278,7 @@ nsWindow::DispatchDragEvent(uint32_t aMsg, const nsIntPoint& aRefPoint,
|
||||
|
||||
event.refPoint = LayoutDeviceIntPoint::FromUntyped(aRefPoint);
|
||||
event.time = aTime;
|
||||
event.timeStamp = GetEventTimeStamp(aTime);
|
||||
|
||||
DispatchInputEvent(&event);
|
||||
}
|
||||
|
@ -67,6 +67,10 @@ class nsPluginNativeWindowGtk;
|
||||
class nsShmImage;
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
class TimeStamp;
|
||||
}
|
||||
|
||||
class nsWindow : public nsBaseWidget
|
||||
{
|
||||
public:
|
||||
@ -263,6 +267,7 @@ public:
|
||||
// otherwise, FALSE.
|
||||
bool DispatchKeyDownEvent(GdkEventKey *aEvent,
|
||||
bool *aIsCancelled);
|
||||
mozilla::TimeStamp GetEventTimeStamp(guint32 aEventTime);
|
||||
|
||||
NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
|
||||
const InputContextAction& aAction) override;
|
||||
|
Loading…
Reference in New Issue
Block a user