29 #if defined (OCTAVE_USE_WINDOWS_API)
31 #elif defined (HAVE_FRAMEWORK_CARBON)
32 #include <Carbon/Carbon.h>
33 #elif defined (HAVE_X_WINDOWS)
44 #if defined (HAVE_FRAMEWORK_CARBON) && ! defined (HAVE_CARBON_CGDISPLAYBITSPERPIXEL)
47 size_t DisplayBitsPerPixel (CGDirectDisplayID display)
49 CGDisplayModeRef mode = CGDisplayCopyDisplayMode (display);
50 CFStringRef pixelEncoding = CGDisplayModeCopyPixelEncoding (mode);
52 if (CFStringCompare (pixelEncoding, CFSTR (IO32BitDirectPixels), 0) == 0)
54 else if (CFStringCompare (pixelEncoding, CFSTR (IO16BitDirectPixels), 0) == 0)
66 #if defined (OCTAVE_USE_WINDOWS_API)
72 dp = GetDeviceCaps (hdc, BITSPIXEL);
74 ht = GetDeviceCaps (hdc, VERTRES);
75 wd = GetDeviceCaps (hdc, HORZRES);
77 double ht_mm = GetDeviceCaps (hdc, VERTSIZE);
78 double wd_mm = GetDeviceCaps (hdc, HORZSIZE);
80 rx =
wd * 25.4 / wd_mm;
81 ry =
ht * 25.4 / ht_mm;
86 err_msg =
"no graphical display found";
88 #elif defined (HAVE_FRAMEWORK_CARBON)
90 CGDirectDisplayID display = CGMainDisplayID ();
94 # if defined (HAVE_CARBON_CGDISPLAYBITSPERPIXEL)
96 dp = CGDisplayBitsPerPixel (display);
99 dp = DisplayBitsPerPixel (display);
102 ht = CGDisplayPixelsHigh (display);
103 wd = CGDisplayPixelsWide (display);
105 CGSize sz_mm = CGDisplayScreenSize (display);
109 double ht_mm = sz_mm.height;
110 double wd_mm = sz_mm.width;
112 rx =
wd * 25.4 / wd_mm;
113 ry =
ht * 25.4 / ht_mm;
118 err_msg =
"no graphical display found";
120 #elif defined (HAVE_X_WINDOWS)
122 const char *display_name = getenv (
"DISPLAY");
124 if (display_name && *display_name)
126 Display *display = XOpenDisplay (display_name);
130 Screen *screen = DefaultScreenOfDisplay (display);
134 dp = DefaultDepthOfScreen (screen);
136 ht = HeightOfScreen (screen);
137 wd = WidthOfScreen (screen);
139 int screen_number = XScreenNumberOfScreen (screen);
141 double ht_mm = DisplayHeightMM (display, screen_number);
142 double wd_mm = DisplayWidthMM (display, screen_number);
144 rx =
wd * 25.4 / wd_mm;
145 ry =
ht * 25.4 / ht_mm;
148 err_msg =
"X11 display has no default screen";
150 XCloseDisplay (display);
155 err_msg =
"unable to open X11 DISPLAY";
158 err_msg =
"X11 DISPLAY environment variable not set";
161 err_msg =
"no graphical display found";
182 ::error (
"unable to create display_info object!");