Fix X11 event timing so that we correctly correlate X11 timing and
Wine timing and dynamically adjust it as we go.
This commit is contained in:
parent
0de5671ee9
commit
77502e7e62
|
@ -187,6 +187,40 @@ DWORD X11DRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* EVENT_x11_time_to_win32_time
|
||||||
|
*
|
||||||
|
* Make our timer and the X timer line up as best we can
|
||||||
|
* Pass 0 to retrieve the current adjustment value (times -1)
|
||||||
|
*/
|
||||||
|
DWORD EVENT_x11_time_to_win32_time(Time time)
|
||||||
|
{
|
||||||
|
static DWORD adjust = 0;
|
||||||
|
DWORD now = GetTickCount();
|
||||||
|
DWORD ret;
|
||||||
|
|
||||||
|
if (! adjust && time != 0)
|
||||||
|
{
|
||||||
|
ret = now;
|
||||||
|
adjust = time - now;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* If we got an event in the 'future', then our clock is clearly wrong.
|
||||||
|
If we got it more than 10000 ms in the future, then it's most likely
|
||||||
|
that the clock has wrapped. */
|
||||||
|
|
||||||
|
ret = time - adjust;
|
||||||
|
if (ret > now && ((ret - now) < 10000) && time != 0)
|
||||||
|
{
|
||||||
|
adjust += ret - now;
|
||||||
|
ret -= ret - now;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* EVENT_ProcessEvent
|
* EVENT_ProcessEvent
|
||||||
|
|
|
@ -1103,7 +1103,7 @@ void X11DRV_KeyEvent( HWND hwnd, XKeyEvent *event )
|
||||||
DWORD dwFlags;
|
DWORD dwFlags;
|
||||||
int ascii_chars;
|
int ascii_chars;
|
||||||
XIC xic = X11DRV_get_ic( hwnd );
|
XIC xic = X11DRV_get_ic( hwnd );
|
||||||
DWORD event_time = event->time - X11DRV_server_startticks;
|
DWORD event_time = EVENT_x11_time_to_win32_time(event->time);
|
||||||
Status status = 0;
|
Status status = 0;
|
||||||
|
|
||||||
TRACE_(key)("type %d, window %lx, state 0x%04x, keycode 0x%04x\n",
|
TRACE_(key)("type %d, window %lx, state 0x%04x, keycode 0x%04x\n",
|
||||||
|
|
|
@ -141,7 +141,7 @@ static void send_mouse_event( HWND hwnd, DWORD flags, DWORD posX, DWORD posY,
|
||||||
input.u.mi.dy = posY;
|
input.u.mi.dy = posY;
|
||||||
input.u.mi.mouseData = data;
|
input.u.mi.mouseData = data;
|
||||||
input.u.mi.dwFlags = flags;
|
input.u.mi.dwFlags = flags;
|
||||||
input.u.mi.time = time - X11DRV_server_startticks;
|
input.u.mi.time = EVENT_x11_time_to_win32_time(time);
|
||||||
input.u.mi.dwExtraInfo = (ULONG_PTR)hwnd;
|
input.u.mi.dwExtraInfo = (ULONG_PTR)hwnd;
|
||||||
SendInput( 1, &input, sizeof(input) );
|
SendInput( 1, &input, sizeof(input) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -1317,7 +1317,8 @@ void X11DRV_SetFocus( HWND hwnd )
|
||||||
/* we must not use CurrentTime (ICCCM), so try to use last message time instead */
|
/* we must not use CurrentTime (ICCCM), so try to use last message time instead */
|
||||||
/* FIXME: this is not entirely correct */
|
/* FIXME: this is not entirely correct */
|
||||||
XSetInputFocus( display, win, RevertToParent,
|
XSetInputFocus( display, win, RevertToParent,
|
||||||
/*CurrentTime*/ GetMessageTime() + X11DRV_server_startticks );
|
/* CurrentTime */
|
||||||
|
GetMessageTime() - EVENT_x11_time_to_win32_time(0));
|
||||||
if (X11DRV_PALETTE_PaletteFlags & X11DRV_PALETTE_PRIVATE)
|
if (X11DRV_PALETTE_PaletteFlags & X11DRV_PALETTE_PRIVATE)
|
||||||
XInstallColormap( display, X11DRV_PALETTE_PaletteXColormap );
|
XInstallColormap( display, X11DRV_PALETTE_PaletteXColormap );
|
||||||
}
|
}
|
||||||
|
|
|
@ -598,7 +598,7 @@ int X11DRV_ProcessTabletEvent(HWND hwnd, XEvent *event)
|
||||||
|
|
||||||
TRACE_(event)("Received tablet motion event (%p)\n",hwnd);
|
TRACE_(event)("Received tablet motion event (%p)\n",hwnd);
|
||||||
TRACE("Received tablet motion event (%p)\n",hwnd);
|
TRACE("Received tablet motion event (%p)\n",hwnd);
|
||||||
gMsgPacket.pkTime = motion->time;
|
gMsgPacket.pkTime = EVENT_x11_time_to_win32_time(motion->time);
|
||||||
gMsgPacket.pkSerialNumber = gSerial++;
|
gMsgPacket.pkSerialNumber = gSerial++;
|
||||||
gMsgPacket.pkCursor = motion->deviceid;
|
gMsgPacket.pkCursor = motion->deviceid;
|
||||||
gMsgPacket.pkX = motion->axis_data[0];
|
gMsgPacket.pkX = motion->axis_data[0];
|
||||||
|
|
|
@ -110,8 +110,6 @@ extern Pixmap BITMAP_stock_pixmap; /* pixmap for the default stock bitmap */
|
||||||
#define BITMAP_GC(bmp) \
|
#define BITMAP_GC(bmp) \
|
||||||
(((bmp)->bitmap.bmBitsPixel == 1) ? BITMAP_monoGC : BITMAP_colorGC)
|
(((bmp)->bitmap.bmBitsPixel == 1) ? BITMAP_monoGC : BITMAP_colorGC)
|
||||||
|
|
||||||
extern unsigned int X11DRV_server_startticks;
|
|
||||||
|
|
||||||
/* Wine driver X11 functions */
|
/* Wine driver X11 functions */
|
||||||
|
|
||||||
extern BOOL X11DRV_AlphaBlend( X11DRV_PDEVICE *physDevDst, INT xDst, INT yDst,
|
extern BOOL X11DRV_AlphaBlend( X11DRV_PDEVICE *physDevDst, INT xDst, INT yDst,
|
||||||
|
@ -504,6 +502,7 @@ extern INPUT_TYPE X11DRV_EVENT_SetInputMethod(INPUT_TYPE type);
|
||||||
void X11DRV_EVENT_SetDGAStatus(HWND hwnd, int event_base) ;
|
void X11DRV_EVENT_SetDGAStatus(HWND hwnd, int event_base) ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern DWORD EVENT_x11_time_to_win32_time(Time time);
|
||||||
extern int X11DRV_ProcessTabletEvent(HWND hwnd, XEvent *event);
|
extern int X11DRV_ProcessTabletEvent(HWND hwnd, XEvent *event);
|
||||||
|
|
||||||
/* x11drv private window data */
|
/* x11drv private window data */
|
||||||
|
|
|
@ -98,8 +98,6 @@ int client_side_antialias_with_core = 1;
|
||||||
int client_side_antialias_with_render = 1;
|
int client_side_antialias_with_render = 1;
|
||||||
int using_wine_desktop = 0;
|
int using_wine_desktop = 0;
|
||||||
|
|
||||||
unsigned int X11DRV_server_startticks;
|
|
||||||
|
|
||||||
static BOOL synchronous; /* run in synchronous mode? */
|
static BOOL synchronous; /* run in synchronous mode? */
|
||||||
static BOOL desktop_dbl_buf = TRUE;
|
static BOOL desktop_dbl_buf = TRUE;
|
||||||
static char *desktop_geometry;
|
static char *desktop_geometry;
|
||||||
|
@ -214,19 +212,6 @@ void wine_tsx11_unlock(void)
|
||||||
LeaveCriticalSection( &X11DRV_CritSection );
|
LeaveCriticalSection( &X11DRV_CritSection );
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* get_server_startup
|
|
||||||
*
|
|
||||||
* Get the server startup time
|
|
||||||
* Won't be exact, but should be sufficient
|
|
||||||
*/
|
|
||||||
static void get_server_startup(void)
|
|
||||||
{
|
|
||||||
struct timeval t;
|
|
||||||
gettimeofday( &t, NULL );
|
|
||||||
X11DRV_server_startticks = ((t.tv_sec * 1000) + (t.tv_usec / 1000)) - GetTickCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* get_config_key
|
* get_config_key
|
||||||
|
@ -341,7 +326,6 @@ static BOOL process_attach(void)
|
||||||
{
|
{
|
||||||
Display *display;
|
Display *display;
|
||||||
|
|
||||||
get_server_startup();
|
|
||||||
setup_options();
|
setup_options();
|
||||||
|
|
||||||
/* Open display */
|
/* Open display */
|
||||||
|
|
Loading…
Reference in New Issue