@@ -275,7 +275,7 @@ private void OnDeviceEvent(IXI2Client client, ParsedDeviceEvent ev)
275
275
PixelRect screenBounds = default ;
276
276
if ( ev . Valuators . TryGetValue ( touchMajorXIValuatorClassInfo . Number , out var touchMajorValue ) )
277
277
{
278
- var screen = _platform . X11Screens . ScreenFromPoint ( new PixelPoint ( ( int ) ev . Position . X , ( int ) ev . Position . Y ) ) ;
278
+ var screen = _platform . X11Screens . ScreenFromPoint ( new PixelPoint ( ( int ) ev . RootPosition . X , ( int ) ev . RootPosition . Y ) ) ;
279
279
Debug . Assert ( screen != null ) ;
280
280
if ( screen != null )
281
281
{
@@ -284,6 +284,17 @@ private void OnDeviceEvent(IXI2Client client, ParsedDeviceEvent ev)
284
284
// As https://www.kernel.org/doc/html/latest/input/multi-touch-protocol.html says, using `screenBounds.Width` is not accurate enough.
285
285
touchMajor = ( touchMajorValue - touchMajorXIValuatorClassInfo . Min ) /
286
286
( touchMajorXIValuatorClassInfo . Max - touchMajorXIValuatorClassInfo . Min ) * screenBounds . Width ;
287
+
288
+ var windowScreenWidth = 0d ;
289
+ var isSameAsTouchScreen = false ;
290
+ if ( client is IWindowImpl windowImpl )
291
+ {
292
+ var windowScreen = _platform . X11Screens . ScreenFromWindow ( windowImpl ) ;
293
+ isSameAsTouchScreen = windowScreen == screen ;
294
+ windowScreenWidth = windowScreen ? . Bounds . Width ?? windowScreenWidth ;
295
+ }
296
+
297
+ Console . WriteLine ( $ "Position={ ev . Position . X : 0.00} ,{ ev . Position . Y : 0.00} ; TouchMajor={ touchMajorValue : 0.00} ;Max={ touchMajorXIValuatorClassInfo . Max : 0.00} ;Min={ touchMajorXIValuatorClassInfo . Min : 0.00} ;ScreenWidth={ screenBounds . Width } ;TouchWidth={ touchMajor } ; IsSameAsTouchScreen={ isSameAsTouchScreen } ; WindowScreenWidth={ windowScreenWidth } \r \n ") ;
287
298
}
288
299
}
289
300
@@ -295,6 +306,8 @@ private void OnDeviceEvent(IXI2Client client, ParsedDeviceEvent ev)
295
306
{
296
307
touchMinor = ( touchMinorValue - touchMinorXIValuatorClassInfo . Min ) /
297
308
( touchMinorXIValuatorClassInfo . Max - touchMinorXIValuatorClassInfo . Min ) * screenBounds . Height ;
309
+
310
+ Console . WriteLine ( $ "TouchMinor={ touchMinorValue : 0.00} ;Max={ touchMinorXIValuatorClassInfo . Max : 0.00} ;Min={ touchMinorXIValuatorClassInfo . Min : 0.00} ;ScreenHeight={ screenBounds . Height } ;TouchWidth={ touchMajor } ;r\n ") ;
298
311
}
299
312
}
300
313
@@ -397,6 +410,7 @@ internal unsafe class ParsedDeviceEvent
397
410
public RawInputModifiers Modifiers { get ; }
398
411
public ulong Timestamp { get ; }
399
412
public Point Position { get ; }
413
+ public Point RootPosition { get ; }
400
414
public int Button { get ; set ; }
401
415
public int Detail { get ; set ; }
402
416
public bool Emulated { get ; set ; }
@@ -442,6 +456,7 @@ public ParsedDeviceEvent(XIDeviceEvent* ev)
442
456
443
457
Valuators = new Dictionary < int , double > ( ) ;
444
458
Position = new Point ( ev ->event_x , ev ->event_y ) ;
459
+ RootPosition = new Point ( ev ->root_x , ev ->root_y ) ;
445
460
var values = ev ->valuators . Values ;
446
461
if ( ev ->valuators . Mask != null )
447
462
for ( var c = 0 ; c < ev ->valuators . MaskLen * 8 ; c ++ )
0 commit comments