26#if defined (HAVE_CONFIG_H)
32#if defined (OCTAVE_USE_WINDOWS_API)
34#elif defined (HAVE_FRAMEWORK_CARBON)
35# include <Carbon/Carbon.h>
37# if defined (HAVE_X_WINDOWS)
40# if defined (HAVE_WAYLAND_CLIENT)
42# include <wayland-client.h>
59#if defined (HAVE_WAYLAND_CLIENT)
62struct s_display_info {
74oct_wl_geometry (
void *data,
struct wl_output *output,
int x,
int y,
75 int physical_width,
int physical_height,
int subpixel,
76 const char *make,
const char *model,
int transform)
78 struct s_display_info *info = data;
79 info->ht_mm = physical_height;
80 info->wd_mm = physical_width;
82 octave_unused_parameter (output);
83 octave_unused_parameter (
x);
84 octave_unused_parameter (y);
85 octave_unused_parameter (subpixel);
86 octave_unused_parameter (make);
87 octave_unused_parameter (model);
92oct_wl_mode (
void *data,
struct wl_output *output,
unsigned int flags,
93 int width,
int height,
int refresh)
95 struct s_display_info *info = data;
97 if (flags & WL_OUTPUT_MODE_CURRENT)
104 octave_unused_parameter (output);
105 octave_unused_parameter (refresh);
108static void oct_wl_done (
void *data,
struct wl_output *output)
110 octave_unused_parameter (data);
111 octave_unused_parameter (output);
115oct_wl_scale (
void *data,
struct wl_output *output, int32_t factor)
117 struct s_display_info *info = data;
118 info->scale = factor;
120 octave_unused_parameter (output);
123static const struct wl_output_listener output_listener = {
124 .geometry = oct_wl_geometry,
127 .scale = oct_wl_scale
133oct_wl_global (
void *data,
struct wl_registry *registry, uint32_t name,
134 const char *interface, uint32_t version)
136 struct s_display_info *info = data;
139 if (
strcmp (interface, wl_output_interface.name) == 0)
142 struct wl_output *output = wl_registry_bind (registry, name,
143 &wl_output_interface, 1);
145 wl_output_add_listener (output, &output_listener, info);
148 octave_unused_parameter (version);
152oct_wl_global_remove (
void *data,
struct wl_registry *registry, uint32_t name)
154 octave_unused_parameter (data);
155 octave_unused_parameter (registry);
156 octave_unused_parameter (name);
159static const struct wl_registry_listener registry_listener = {
160 .global = oct_wl_global,
161 .global_remove = oct_wl_global_remove
168 double *rx,
double *ry,
int *dpy_avail)
170 const char *msg = NULL;
177#if defined (OCTAVE_USE_WINDOWS_API)
179 octave_unused_parameter (dpy_name);
185 *dp = GetDeviceCaps (hdc, BITSPIXEL);
187 *ht = GetDeviceCaps (hdc, VERTRES);
188 *wd = GetDeviceCaps (hdc, HORZRES);
190 ht_mm = GetDeviceCaps (hdc, VERTSIZE);
191 wd_mm = GetDeviceCaps (hdc, HORZSIZE);
196 msg =
"no graphical display found";
198#elif defined (HAVE_FRAMEWORK_CARBON)
200 octave_unused_parameter (dpy_name);
202 CGDirectDisplayID display = CGMainDisplayID ();
206#if defined (HAVE_CARBON_CGDISPLAYBITSPERPIXEL)
208 *dp = CGDisplayBitsPerPixel (display);
215 CGDisplayModeRef mode = CGDisplayCopyDisplayMode (display);
216 CFStringRef pixelEncoding = CGDisplayModeCopyPixelEncoding (mode);
218 if (CFStringCompare (pixelEncoding, CFSTR (IO32BitDirectPixels), 0) == 0)
220 else if (CFStringCompare (pixelEncoding,
221 CFSTR (IO16BitDirectPixels), 0) == 0)
228 *ht = CGDisplayPixelsHigh (display);
229 *wd = CGDisplayPixelsWide (display);
231 CGSize sz_mm = CGDisplayScreenSize (display);
237 ht_mm = sz_mm.height;
243 msg =
"no graphical display found";
245#elif defined (HAVE_X_WINDOWS) || defined (HAVE_WAYLAND_CLIENT)
247# if defined (HAVE_X_WINDOWS)
252 Display *display = XOpenDisplay (dpy_name);
256 Screen *screen = DefaultScreenOfDisplay (display);
260 *dp = DefaultDepthOfScreen (screen);
262 *ht = HeightOfScreen (screen);
263 *wd = WidthOfScreen (screen);
265 int screen_number = XScreenNumberOfScreen (screen);
267 ht_mm = DisplayHeightMM (display, screen_number);
268 wd_mm = DisplayWidthMM (display, screen_number);
272# if ! defined (HAVE_WAYLAND_CLIENT)
274 msg =
"X11 display has no default screen";
277 XCloseDisplay (display);
279# if ! defined (HAVE_WAYLAND_CLIENT)
281 msg =
"unable to open X11 DISPLAY";
285# if defined (HAVE_WAYLAND_CLIENT)
289 struct wl_display *wldisplay = wl_display_connect (dpy_name);
293 struct s_display_info info = {0};
296 struct wl_registry *registry = wl_display_get_registry (wldisplay);
298 wl_registry_add_listener (registry, ®istry_listener, &info);
301 wl_display_roundtrip (wldisplay);
303 wl_display_roundtrip (wldisplay);
305 wl_display_disconnect (wldisplay);
325# if defined (HAVE_X_WINDOWS)
326 msg =
"no Wayland or X11 display available";
328 msg =
"no Wayland display available";
332# if defined (HAVE_X_WINDOWS)
333 msg =
"unable to open Wayland or X11 display";
335 msg =
"unable to open Wayland display";
342 octave_unused_parameter (dpy_name);
343 octave_unused_parameter (ht);
344 octave_unused_parameter (wd);
345 octave_unused_parameter (dp);
346 octave_unused_parameter (rx);
347 octave_unused_parameter (ry);
349 msg =
"no graphical display found";
355 if (wd_mm == 0 || ht_mm == 0)
357 msg =
"screen width or height reported to be zero";
369 *rx = *wd * 25.4 / wd_mm;
370 *ry = *ht * 25.4 / ht_mm;
const char * octave_get_display_info(const char *dpy_name, int *ht, int *wd, int *dp, double *rx, double *ry, int *dpy_avail)
void scale(Matrix &m, double x, double y, double z)
ColumnVector transform(const Matrix &m, double x, double y, double z)
bool strcmp(const T &str_a, const T &str_b)
Octave string utility functions.
F77_RET_T const F77_DBLE * x