access X11 window manager;
authorwenzelm
Thu, 09 Jan 2014 20:17:15 +0100
changeset 54962 993aab23894c
parent 54957 99eebac5fcb3
child 54963 260ad8b204f5
access X11 window manager;
src/Pure/GUI/gui.scala
--- a/src/Pure/GUI/gui.scala	Thu Jan 09 17:51:52 2014 +0100
+++ b/src/Pure/GUI/gui.scala	Thu Jan 09 20:17:15 2014 +0100
@@ -8,6 +8,7 @@
 package isabelle
 
 
+import java.lang.{ClassLoader, ClassNotFoundException, NoSuchMethodException}
 import java.awt.{Image, Component, Container, Toolkit, Window, Font}
 import java.awt.font.{TextAttribute, TransformAttribute, FontRenderContext, LineMetrics}
 import java.awt.geom.AffineTransform
@@ -38,6 +39,26 @@
     UIManager.getSystemLookAndFeelClassName() == UIManager.getLookAndFeel.getClass.getName
 
 
+  /* X11 window manager */
+
+  def window_manager(): Option[String] =
+  {
+    try {
+      val XWM = Class.forName("sun.awt.X11.XWM", true, ClassLoader.getSystemClassLoader)
+      val getWM = XWM.getDeclaredMethod("getWM")
+      getWM.setAccessible(true)
+      getWM.invoke(null) match {
+        case null => None
+        case wm => Some(wm.toString)
+      }
+    }
+    catch {
+      case _: ClassNotFoundException => None
+      case _: NoSuchMethodException => None
+    }
+  }
+
+
   /* simple dialogs */
 
   def scrollable_text(txt: String, width: Int = 60, height: Int = 20, editable: Boolean = false)