@ -30,6 +30,8 @@ namespace Avalonia.Win32
private UnmanagedMethods . WndProc _ wndProcDelegate ;
private UnmanagedMethods . WndProc _ wndProcDelegate ;
private string _ className ;
private string _ className ;
private IntPtr _ hwnd ;
private IntPtr _ hwnd ;
private bool _ multitouch ;
private TouchDevice _ touchDevice = new TouchDevice ( ) ;
private IInputRoot _ owner ;
private IInputRoot _ owner ;
private bool _ trackingMouse ;
private bool _ trackingMouse ;
private bool _d ecorated = true ;
private bool _d ecorated = true ;
@ -414,6 +416,15 @@ namespace Avalonia.Win32
IntPtr . Zero ) ;
IntPtr . Zero ) ;
}
}
bool ShouldIgnoreTouchEmulatedMessage ( )
{
if ( ! _ multitouch )
return false ;
var marker = 0xFF515700L ;
var info = GetMessageExtraInfo ( ) . ToInt64 ( ) ;
return ( info & marker ) = = marker ;
}
[SuppressMessage("Microsoft.StyleCop.CSharp.NamingRules", "SA1305:FieldNamesMustNotUseHungarianNotation", Justification = "Using Win32 naming for consistency.")]
[SuppressMessage("Microsoft.StyleCop.CSharp.NamingRules", "SA1305:FieldNamesMustNotUseHungarianNotation", Justification = "Using Win32 naming for consistency.")]
protected virtual IntPtr WndProc ( IntPtr hWnd , uint msg , IntPtr wParam , IntPtr lParam )
protected virtual IntPtr WndProc ( IntPtr hWnd , uint msg , IntPtr wParam , IntPtr lParam )
{
{
@ -519,6 +530,8 @@ namespace Avalonia.Win32
case UnmanagedMethods . WindowsMessage . WM_LBUTTONDOWN :
case UnmanagedMethods . WindowsMessage . WM_LBUTTONDOWN :
case UnmanagedMethods . WindowsMessage . WM_RBUTTONDOWN :
case UnmanagedMethods . WindowsMessage . WM_RBUTTONDOWN :
case UnmanagedMethods . WindowsMessage . WM_MBUTTONDOWN :
case UnmanagedMethods . WindowsMessage . WM_MBUTTONDOWN :
if ( ShouldIgnoreTouchEmulatedMessage ( ) )
break ;
e = new RawMouseEventArgs (
e = new RawMouseEventArgs (
WindowsMouseDevice . Instance ,
WindowsMouseDevice . Instance ,
timestamp ,
timestamp ,
@ -534,6 +547,8 @@ namespace Avalonia.Win32
case UnmanagedMethods . WindowsMessage . WM_LBUTTONUP :
case UnmanagedMethods . WindowsMessage . WM_LBUTTONUP :
case UnmanagedMethods . WindowsMessage . WM_RBUTTONUP :
case UnmanagedMethods . WindowsMessage . WM_RBUTTONUP :
case UnmanagedMethods . WindowsMessage . WM_MBUTTONUP :
case UnmanagedMethods . WindowsMessage . WM_MBUTTONUP :
if ( ShouldIgnoreTouchEmulatedMessage ( ) )
break ;
e = new RawMouseEventArgs (
e = new RawMouseEventArgs (
WindowsMouseDevice . Instance ,
WindowsMouseDevice . Instance ,
timestamp ,
timestamp ,
@ -547,6 +562,8 @@ namespace Avalonia.Win32
break ;
break ;
case UnmanagedMethods . WindowsMessage . WM_MOUSEMOVE :
case UnmanagedMethods . WindowsMessage . WM_MOUSEMOVE :
if ( ShouldIgnoreTouchEmulatedMessage ( ) )
break ;
if ( ! _ trackingMouse )
if ( ! _ trackingMouse )
{
{
var tm = new UnmanagedMethods . TRACKMOUSEEVENT
var tm = new UnmanagedMethods . TRACKMOUSEEVENT
@ -611,7 +628,30 @@ namespace Avalonia.Win32
: RawMouseEventType . MiddleButtonDown ,
: RawMouseEventType . MiddleButtonDown ,
new Point ( 0 , 0 ) , GetMouseModifiers ( wParam ) ) ;
new Point ( 0 , 0 ) , GetMouseModifiers ( wParam ) ) ;
break ;
break ;
case WindowsMessage . WM_TOUCH :
var touchInputs = new TOUCHINPUT [ wParam . ToInt32 ( ) ] ;
if ( GetTouchInputInfo ( lParam , ( uint ) wParam . ToInt32 ( ) , touchInputs , Marshal . SizeOf < TOUCHINPUT > ( ) ) )
{
foreach ( var touchInput in touchInputs )
{
var pt = new POINT { X = touchInput . X / 1 0 0 , Y = touchInput . Y / 1 0 0 } ;
UnmanagedMethods . ScreenToClient ( _ hwnd , ref pt ) ;
Input ? . Invoke ( new RawTouchEventArgs ( _ touchDevice , touchInput . Time ,
_ owner ,
touchInput . Flags . HasFlag ( TouchInputFlags . TOUCHEVENTF_UP ) ?
RawMouseEventType . TouchEnd :
touchInput . Flags . HasFlag ( TouchInputFlags . TOUCHEVENTF_DOWN ) ?
RawMouseEventType . TouchBegin :
RawMouseEventType . TouchUpdate ,
new Point ( pt . X , pt . Y ) ,
WindowsKeyboardDevice . Instance . Modifiers ,
touchInput . Id ) ) ;
}
CloseTouchInputHandle ( lParam ) ;
return IntPtr . Zero ;
}
break ;
case WindowsMessage . WM_NCPAINT :
case WindowsMessage . WM_NCPAINT :
if ( ! _d ecorated )
if ( ! _d ecorated )
{
{
@ -754,6 +794,10 @@ namespace Avalonia.Win32
Handle = new PlatformHandle ( _ hwnd , PlatformConstants . WindowHandleType ) ;
Handle = new PlatformHandle ( _ hwnd , PlatformConstants . WindowHandleType ) ;
_ multitouch = Win32Platform . Options . EnableMultitouch ? ? false ;
if ( _ multitouch )
RegisterTouchWindow ( _ hwnd , 0 ) ;
if ( UnmanagedMethods . ShCoreAvailable )
if ( UnmanagedMethods . ShCoreAvailable )
{
{
uint dpix , dpiy ;
uint dpix , dpiy ;