From 52d38059f4b98784f3ef7f4c517bba3be79ddabc Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Thu, 4 Nov 2010 18:01:07 +0000 Subject: [PATCH] * XI2Mouse.cs: * X11Factory.cs: Removed window hooking, as it complicates code unnecessarily. --- Source/OpenTK/Platform/X11/X11Factory.cs | 6 ++--- Source/OpenTK/Platform/X11/XI2Mouse.cs | 31 ++++++++---------------- 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/Source/OpenTK/Platform/X11/X11Factory.cs b/Source/OpenTK/Platform/X11/X11Factory.cs index c3292637..6fd9c5eb 100644 --- a/Source/OpenTK/Platform/X11/X11Factory.cs +++ b/Source/OpenTK/Platform/X11/X11Factory.cs @@ -85,9 +85,9 @@ namespace OpenTK.Platform.X11 public virtual OpenTK.Input.IMouseDriver2 CreateMouseDriver() { - //if (XI2Mouse.IsSupported(IntPtr.Zero)) - // return new XI2Mouse(null); // Requires xorg 1.7 or higher. - //else + if (XI2Mouse.IsSupported(IntPtr.Zero)) + return new XI2Mouse(); // Requires xorg 1.7 or higher. + else return new X11Mouse(); // Always supported. } diff --git a/Source/OpenTK/Platform/X11/XI2Mouse.cs b/Source/OpenTK/Platform/X11/XI2Mouse.cs index a8f31832..69825805 100644 --- a/Source/OpenTK/Platform/X11/XI2Mouse.cs +++ b/Source/OpenTK/Platform/X11/XI2Mouse.cs @@ -45,23 +45,17 @@ namespace OpenTK.Platform.X11 static readonly Functions.EventPredicate PredicateImpl = IsEventValid; readonly IntPtr Predicate = Marshal.GetFunctionPointerForDelegate(PredicateImpl); - // Can either attach itself to the specified window or can hook the root window. - public XI2Mouse(X11WindowInfo win) + public XI2Mouse() { - if (win != null) + Debug.WriteLine("Using XI2Mouse."); + + using (new XLock(API.DefaultDisplay)) { - window = win; - } - else - { - using (new XLock(API.DefaultDisplay)) - { - window = new X11WindowInfo(); - window.Display = API.DefaultDisplay; - window.Screen = Functions.XDefaultScreen(window.Display); - window.RootWindow = Functions.XRootWindow(window.Display, window.Screen); - window.WindowHandle = window.RootWindow; - } + window = new X11WindowInfo(); + window.Display = API.DefaultDisplay; + window.Screen = Functions.XDefaultScreen(window.Display); + window.RootWindow = Functions.XRootWindow(window.Display, window.Screen); + window.WindowHandle = window.RootWindow; } if (!IsSupported(window.Display)) @@ -72,8 +66,6 @@ namespace OpenTK.Platform.X11 { Functions.XISelectEvents(window.Display, window.WindowHandle, mask); } - - Debug.WriteLine("Using XI2Mouse."); } // Checks whether XInput2 is supported on the specified display. @@ -96,10 +88,7 @@ namespace OpenTK.Platform.X11 return true; } - #region IMouseDriver Members - - // Todo: remove this - public IList Mouse { get { throw new NotSupportedException(); } } + #region IMouseDriver2 Members public MouseState GetState() {