issue #380 and friends. the windows path was reading cursor pos via gdk_window_get_pointer and setting via SetCursorPos, doing some bs coord adjustment based on information read from SPI_GETWORKAREA.

This commit is contained in:
Timothee Besset 2017-02-25 17:19:39 -06:00
parent ed15d78e2b
commit 03f5911b57
2 changed files with 15 additions and 9 deletions

View file

@ -2466,6 +2466,7 @@ void MainFrame::Create(){
gdk_offset_y = MAX( gdk_offset_y, -monitorInfo.win_monitors[monitorInfo.i_win_mon].y );
}
// We do not use these offsets anymore. This could all probably be trashed. I doubt the multi monitor does anything useful/works either.
Sys_Printf( "GDK's coordinate system is offset by %d over the x-axis and %d over the y-axis from Windows' coordinate system.\n", gdk_offset_x, gdk_offset_y );
if ( g_PrefsDlg.m_bStartOnPrimMon ) {

View file

@ -1294,20 +1294,25 @@ void WINAPI Sys_EndWait( void ){
}
void Sys_GetCursorPos( int *x, int *y ){
// FIXME: not multihead safe
#ifdef _WIN32
POINT p;
if ( !GetCursorPos( &p ) ) {
Sys_Printf( "GetCursorPos failed: GetLastError()=0x%08x", GetLastError() );
return;
}
*x = p.x;
*y = p.y;
#else
gdk_window_get_pointer( NULL, x, y, NULL );
#endif
}
void Sys_SetCursorPos( int x, int y ){
// NOTE: coordinates are in GDK space, not OS space
#ifdef _WIN32
int sys_x = x - g_pParentWnd->GetGDKOffsetX();
int sys_y = y - g_pParentWnd->GetGDKOffsetY();
SetCursorPos( sys_x, sys_y );
#endif
#if defined ( __linux__ ) || defined ( __APPLE__ )
if ( !SetCursorPos( x, y ) ) {
Sys_Printf( "SetCursorPos failed: GetLastError()=0x%08x", GetLastError() );
}
#else
XWarpPointer( GDK_DISPLAY(), None, GDK_ROOT_WINDOW(), 0, 0, 0, 0, x, y );
#endif
}