[jsword-svn] r2307 - trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop

dmsmith at crosswire.org dmsmith at crosswire.org
Mon Mar 18 10:59:44 MST 2013


Author: dmsmith
Date: 2013-03-18 10:59:44 -0700 (Mon, 18 Mar 2013)
New Revision: 2307

Modified:
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java
Log:
BD-179 Fix Gnome3 full screen mouse bug

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java	2013-03-17 13:53:11 UTC (rev 2306)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java	2013-03-18 17:59:44 UTC (rev 2307)
@@ -24,7 +24,9 @@
 import java.awt.Component;
 import java.awt.event.ActionEvent;
 import java.io.IOException;
+import java.lang.reflect.Field;
 import java.net.URI;
+import java.util.Arrays;
 
 import javax.swing.JCheckBoxMenuItem;
 import javax.swing.ToolTipManager;
@@ -77,6 +79,7 @@
         actions = new ActionFactory(this);
 
         osxRegistered = macOSXRegistration();
+        fixGnome();
     }
 
     /**
@@ -132,6 +135,45 @@
         return false;
     }
 
+    public void fixGnome() {
+        // BUGFIX: openJDK and Gnome 3 have an odd problem when JFrame is maximized.
+        // The window location is not updated so mouse movements are relative to the location of the window
+        // prior to the window being maximized.
+        // This workaround is from netbeans and is adapted based upon problems with DESKTOP_SESSION having
+        // other values than just "gnome_shell" for Gnome 3.
+        // See http://hg.netbeans.org/core-main/rev/409566c2aa65
+        if (Arrays.asList("gnome-shell", "gnome", "mate", "other...").contains(System.getenv("DESKTOP_SESSION"))) {
+            Throwable th = null;
+            try {
+                Class<?> xwm = Class.forName("sun.awt.X11.XWM");
+                Field awt_wmgr = xwm.getDeclaredField("awt_wmgr");
+                awt_wmgr.setAccessible(true);
+                Field other_wm = xwm.getDeclaredField("OTHER_WM");
+                other_wm.setAccessible(true);
+                if (awt_wmgr.get(null).equals(other_wm.get(null))) {
+                    Field metacity_wm = xwm.getDeclaredField("METACITY_WM");
+                    metacity_wm.setAccessible(true);
+                    awt_wmgr.set(null, metacity_wm.get(null));
+                }
+            } catch (ClassNotFoundException ex) {
+                th = ex;
+            } catch (SecurityException ex) {
+                th = ex;
+            } catch (NoSuchFieldException ex) {
+                th = ex;
+            } catch (IllegalArgumentException ex) {
+                th = ex;
+            } catch (IllegalAccessException ex) {
+                th = ex;
+            }
+            if (th != null) {
+                log.error("Could not fix Gnome3 mouse problem", th);
+            } else {
+                log.warn("Fixed Gnome3 mouse problem");
+            }
+        }
+    }
+
     /**
      * Determines whether MacOSX has been registered.
      * 




More information about the jsword-svn mailing list