[X11] Warn when XI2Mouse is not supported.
authorthefiddler <stapostol@gmail.com>
Tue, 13 May 2014 21:34:27 +0000 (23:34 +0200)
committerthefiddler <stapostol@gmail.com>
Tue, 13 May 2014 21:34:27 +0000 (23:34 +0200)
Without the XI2 extension, mouse support will suffer significantly.
More specifically, low-level mouse events will not be available.

Source/OpenTK/Platform/X11/XI2Mouse.cs

index 97f6a5a..4e93cc5 100644 (file)
@@ -156,30 +156,38 @@ namespace OpenTK.Platform.X11
         // If a display is not specified, the default display is used.
         internal static bool IsSupported(IntPtr display)
         {
-            if (display == IntPtr.Zero)
+            try
             {
-                display = API.DefaultDisplay;
-            }
-
-            using (new XLock(display))
-            {
-                int major, ev, error;
-                if (Functions.XQueryExtension(display, "XInputExtension", out major, out ev, out error) != 0)
+                if (display == IntPtr.Zero)
                 {
-                    XIOpCode = major;
+                    display = API.DefaultDisplay;
+                }
 
-                    int minor = 2;
-                    while (minor >= 0)
+                using (new XLock(display))
+                {
+                    int major, ev, error;
+                    if (Functions.XQueryExtension(display, "XInputExtension", out major, out ev, out error) != 0)
                     {
-                        if (XI.QueryVersion(display, ref major, ref minor) == ErrorCodes.Success)
+                        XIOpCode = major;
+
+                        int minor = 2;
+                        while (minor >= 0)
                         {
-                            XIVersion = major * 100 + minor * 10;
-                            return true;
+                            if (XI.QueryVersion(display, ref major, ref minor) == ErrorCodes.Success)
+                            {
+                                XIVersion = major * 100 + minor * 10;
+                                return true;
+                            }
+                            minor--;
                         }
-                        minor--;
                     }
                 }
             }
+            catch (DllNotFoundException e)
+            {
+                Debug.Print(e.ToString());
+                Debug.Print("XInput2 extension not supported. Mouse support will suffer.");
+            }
 
             return false;
         }