diff src/display.cc @ 9335:f2d354df53ee

new option, --no-window-system
author John W. Eaton <jwe@octave.org>
date Thu, 11 Jun 2009 14:20:36 -0400
parents 016e14be00c6
children cd96d29c5efa
line wrap: on
line diff
--- a/src/display.cc	Thu Jun 11 07:23:32 2009 -0400
+++ b/src/display.cc	Thu Jun 11 14:20:36 2009 -0400
@@ -40,102 +40,105 @@
 display_info *display_info::instance = 0;
 
 void
-display_info::init (void)
+display_info::init (bool query)
 {
+  if (query)
+    {
 #if defined (OCTAVE_USE_WINDOWS_API)
 
-  HDC hdc = GetDC (0);
+      HDC hdc = GetDC (0);
 
-  if (hdc)
-    {
-      dp = GetDeviceCaps (hdc, BITSPIXEL);
+      if (hdc)
+	{
+	  dp = GetDeviceCaps (hdc, BITSPIXEL);
 
-      ht = GetDeviceCaps (hdc, VERTRES);
-      wd = GetDeviceCaps (hdc, HORZRES);
+	  ht = GetDeviceCaps (hdc, VERTRES);
+	  wd = GetDeviceCaps (hdc, HORZRES);
 
-      double ht_mm = GetDeviceCaps (hdc, VERTSIZE);
-      double wd_mm = GetDeviceCaps (hdc, HORZSIZE);
+	  double ht_mm = GetDeviceCaps (hdc, VERTSIZE);
+	  double wd_mm = GetDeviceCaps (hdc, HORZSIZE);
 
-      rx = wd * 25.4 / wd_mm;
-      ry = ht * 25.4 / ht_mm;
-    }
-  else
-    warning ("no graphical display found");
+	  rx = wd * 25.4 / wd_mm;
+	  ry = ht * 25.4 / ht_mm;
+	}
+      else
+	warning ("no graphical display found");
 
 #elif defined (HAVE_FRAMEWORK_CARBON)
 
-  CGDirectDisplayID display = CGMainDisplayID ();
-
-  if (display)
-    {
-      dp = CGDisplayBitsPerPixel (display);
-
-      ht = CGDisplayPixelsHigh (display);
-      wd = CGDisplayPixelsWide (display);
-
-      CGSize sz_mm = CGDisplayScreenSize (display);
-
-      // On modern Mac systems (>= 10.5) CGSize is a struct keeping 2
-      // CGFloat values, but the CGFloat typedef is not present on
-      // older systems, so use double instead.
-      double ht_mm = sz_mm.height;
-      double wd_mm = sz_mm.width;
-
-      rx = wd * 25.4 / wd_mm;
-      ry = ht * 25.4 / ht_mm;
-    }
-  else
-    warning ("no graphical display found");
-
-#elif defined (HAVE_X_WINDOWS)
-
-  const char *display_name = getenv ("DISPLAY");
-
-  if (display_name && *display_name)
-    {
-      Display *display = XOpenDisplay (display_name);
+      CGDirectDisplayID display = CGMainDisplayID ();
 
       if (display)
 	{
-	  Screen *screen = DefaultScreenOfDisplay (display);
+	  dp = CGDisplayBitsPerPixel (display);
+
+	  ht = CGDisplayPixelsHigh (display);
+	  wd = CGDisplayPixelsWide (display);
+
+	  CGSize sz_mm = CGDisplayScreenSize (display);
 
-	  if (screen)
-	    {
-	      dp = DefaultDepthOfScreen (screen);
+	  // On modern Mac systems (>= 10.5) CGSize is a struct keeping 2
+	  // CGFloat values, but the CGFloat typedef is not present on
+	  // older systems, so use double instead.
+	  double ht_mm = sz_mm.height;
+	  double wd_mm = sz_mm.width;
+
+	  rx = wd * 25.4 / wd_mm;
+	  ry = ht * 25.4 / ht_mm;
+	}
+      else
+	warning ("no graphical display found");
+
+#elif defined (HAVE_X_WINDOWS)
+
+      const char *display_name = getenv ("DISPLAY");
 
-	      ht = HeightOfScreen (screen);
-	      wd = WidthOfScreen (screen);
+      if (display_name && *display_name)
+	{
+	  Display *display = XOpenDisplay (display_name);
 
-	      int screen_number = XScreenNumberOfScreen (screen);
+	  if (display)
+	    {
+	      Screen *screen = DefaultScreenOfDisplay (display);
+
+	      if (screen)
+		{
+		  dp = DefaultDepthOfScreen (screen);
 
-	      double ht_mm = DisplayHeightMM (display, screen_number);
-	      double wd_mm = DisplayWidthMM (display, screen_number);
+		  ht = HeightOfScreen (screen);
+		  wd = WidthOfScreen (screen);
+
+		  int screen_number = XScreenNumberOfScreen (screen);
 
-	      rx = wd * 25.4 / wd_mm;
-	      ry = ht * 25.4 / ht_mm;
+		  double ht_mm = DisplayHeightMM (display, screen_number);
+		  double wd_mm = DisplayWidthMM (display, screen_number);
+
+		  rx = wd * 25.4 / wd_mm;
+		  ry = ht * 25.4 / ht_mm;
+		}
+	      else
+		warning ("X11 display has no default screen");
 	    }
 	  else
-	    warning ("X11 display has no default screen");
+	    warning ("unable to open X11 DISPLAY");
 	}
       else
-	warning ("unable to open X11 DISPLAY");
-    }
-  else
-    warning ("X11 DISPLAY environment variable not set");
+	warning ("X11 DISPLAY environment variable not set");
 #else
 
-  warning ("no graphical display found");
+      warning ("no graphical display found");
 
 #endif
+    }
 }
 
 bool
-display_info::instance_ok (void)
+display_info::instance_ok (bool query)
 {
   bool retval = true;
 
   if (! instance)
-    instance = new display_info ();
+    instance = new display_info (query);
 
   if (! instance)
     {