Mercurial > octave
annotate libinterp/corefcn/cdisplay.c @ 26376:00f796120a6d stable
maint: Update copyright dates in all source files.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 02 Jan 2019 16:32:43 -0500 |
parents | 6652d3823428 |
children | 5754e8d8199a |
rev | line source |
---|---|
18932
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1 /* |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 |
26376
00f796120a6d
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
3 Copyright (C) 2009-2019 John W. Eaton |
18932
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5 This file is part of Octave. |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24118
diff
changeset
|
7 Octave is free software: you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24118
diff
changeset
|
9 the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
10 (at your option) any later version. |
18932
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
15 GNU General Public License for more details. |
18932
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24118
diff
changeset
|
19 <https://www.gnu.org/licenses/>. |
18932
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 */ |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
21691
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
24 # include "config.h" |
18932
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 #endif |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 #include <stdlib.h> |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 #if defined (OCTAVE_USE_WINDOWS_API) |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 #include <windows.h> |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 #elif defined (HAVE_FRAMEWORK_CARBON) |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 #include <Carbon/Carbon.h> |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 #elif defined (HAVE_X_WINDOWS) |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 #include <X11/Xlib.h> |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 #endif |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 #include "cdisplay.h" |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 |
20948
babc439a224f
* cdisplay.c: Add comment explaining existence of file.
John W. Eaton <jwe@octave.org>
parents:
18932
diff
changeset
|
39 // Programming Note: This file exists so that we can hide system |
babc439a224f
* cdisplay.c: Add comment explaining existence of file.
John W. Eaton <jwe@octave.org>
parents:
18932
diff
changeset
|
40 // header files that make heavy use of macros and C-style casts in a C |
babc439a224f
* cdisplay.c: Add comment explaining existence of file.
John W. Eaton <jwe@octave.org>
parents:
18932
diff
changeset
|
41 // language file and avoid warnings about using old-style casts in C++. |
20949
e456327188f9
* cdisplay.c: Additional programming notes.
John W. Eaton <jwe@octave.org>
parents:
20948
diff
changeset
|
42 // Additionally, on OS X systems, including the Carbon.h header file |
e456327188f9
* cdisplay.c: Additional programming notes.
John W. Eaton <jwe@octave.org>
parents:
20948
diff
changeset
|
43 // results in the declaration of a "panic" function that conflicts with |
e456327188f9
* cdisplay.c: Additional programming notes.
John W. Eaton <jwe@octave.org>
parents:
20948
diff
changeset
|
44 // Octave's global panic function, so Carbon.h can't be included in any |
e456327188f9
* cdisplay.c: Additional programming notes.
John W. Eaton <jwe@octave.org>
parents:
20948
diff
changeset
|
45 // file that also includes Octave's error.h header file. |
e456327188f9
* cdisplay.c: Additional programming notes.
John W. Eaton <jwe@octave.org>
parents:
20948
diff
changeset
|
46 |
e456327188f9
* cdisplay.c: Additional programming notes.
John W. Eaton <jwe@octave.org>
parents:
20948
diff
changeset
|
47 // Please do NOT eliminate this file and move code from here to |
e456327188f9
* cdisplay.c: Additional programming notes.
John W. Eaton <jwe@octave.org>
parents:
20948
diff
changeset
|
48 // display.cc. |
20948
babc439a224f
* cdisplay.c: Add comment explaining existence of file.
John W. Eaton <jwe@octave.org>
parents:
18932
diff
changeset
|
49 |
18932
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
50 const char * |
23746
7f176909ab86
move display_info class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
51 octave_get_display_info (const char *dpy_name, int *ht, int *wd, int *dp, |
7f176909ab86
move display_info class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
52 double *rx, double *ry, int *dpy_avail) |
18932
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
53 { |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
54 const char *msg = NULL; |
18932
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
56 *dpy_avail = 0; |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
57 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
58 #if defined (OCTAVE_USE_WINDOWS_API) |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
59 |
24118
f87c9f5c0f43
maint: silence several compiler warnings when building for Windows
Mike Miller <mtmiller@octave.org>
parents:
23746
diff
changeset
|
60 octave_unused_parameter (dpy_name); |
f87c9f5c0f43
maint: silence several compiler warnings when building for Windows
Mike Miller <mtmiller@octave.org>
parents:
23746
diff
changeset
|
61 |
18932
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
62 HDC hdc = GetDC (0); |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
63 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
64 if (hdc) |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
65 { |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
66 *dp = GetDeviceCaps (hdc, BITSPIXEL); |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
67 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
68 *ht = GetDeviceCaps (hdc, VERTRES); |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
69 *wd = GetDeviceCaps (hdc, HORZRES); |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
70 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
71 double ht_mm = GetDeviceCaps (hdc, VERTSIZE); |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
72 double wd_mm = GetDeviceCaps (hdc, HORZSIZE); |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
73 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
74 *rx = *wd * 25.4 / wd_mm; |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
75 *ry = *ht * 25.4 / ht_mm; |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
76 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
77 *dpy_avail = 1; |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
78 } |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
79 else |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
80 msg = "no graphical display found"; |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
81 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
82 #elif defined (HAVE_FRAMEWORK_CARBON) |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
83 |
24118
f87c9f5c0f43
maint: silence several compiler warnings when building for Windows
Mike Miller <mtmiller@octave.org>
parents:
23746
diff
changeset
|
84 octave_unused_parameter (dpy_name); |
f87c9f5c0f43
maint: silence several compiler warnings when building for Windows
Mike Miller <mtmiller@octave.org>
parents:
23746
diff
changeset
|
85 |
18932
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
86 CGDirectDisplayID display = CGMainDisplayID (); |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
87 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
88 if (display) |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
89 { |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
90 #if defined (HAVE_CARBON_CGDISPLAYBITSPERPIXEL) |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
91 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
92 *dp = CGDisplayBitsPerPixel (display); |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
93 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
94 #else |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
95 |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
96 /* FIXME: This will only work for MacOS > 10.5. For earlier versions |
18932
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
97 this code is not needed (use CGDisplayBitsPerPixel instead). */ |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
98 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
99 CGDisplayModeRef mode = CGDisplayCopyDisplayMode (display); |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
100 CFStringRef pixelEncoding = CGDisplayModeCopyPixelEncoding (mode); |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
101 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
102 if (CFStringCompare (pixelEncoding, CFSTR (IO32BitDirectPixels), 0) == 0) |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
103 *dp = 32; |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
104 else if (CFStringCompare (pixelEncoding, |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
105 CFSTR (IO16BitDirectPixels), 0) == 0) |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
106 *dp = 16; |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
107 else |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
108 *dp = 8; |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
109 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
110 #endif |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
111 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
112 *ht = CGDisplayPixelsHigh (display); |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
113 *wd = CGDisplayPixelsWide (display); |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
114 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
115 CGSize sz_mm = CGDisplayScreenSize (display); |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
116 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
117 /* For MacOS >= 10.6, CGSize is a struct keeping 2 CGFloat |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
118 values, but the CGFloat typedef is not present on older |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
119 systems, so use double instead. */ |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
120 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
121 double ht_mm = sz_mm.height; |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
122 double wd_mm = sz_mm.width; |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
123 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
124 *rx = *wd * 25.4 / wd_mm; |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
125 *ry = *ht * 25.4 / ht_mm; |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
126 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
127 *dpy_avail = 1; |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
128 } |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
129 else |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
130 msg = "no graphical display found"; |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
131 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
132 #elif defined (HAVE_X_WINDOWS) |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
133 |
23746
7f176909ab86
move display_info class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
134 /* If dpy_name is NULL, XopenDisplay will look for DISPLAY in the |
7f176909ab86
move display_info class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
135 environment. */ |
18932
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
136 |
23746
7f176909ab86
move display_info class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
137 Display *display = XOpenDisplay (dpy_name); |
18932
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
138 |
23746
7f176909ab86
move display_info class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
139 if (display) |
7f176909ab86
move display_info class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
140 { |
7f176909ab86
move display_info class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
141 Screen *screen = DefaultScreenOfDisplay (display); |
18932
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
142 |
23746
7f176909ab86
move display_info class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
143 if (screen) |
7f176909ab86
move display_info class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
144 { |
7f176909ab86
move display_info class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
145 *dp = DefaultDepthOfScreen (screen); |
18932
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
146 |
23746
7f176909ab86
move display_info class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
147 *ht = HeightOfScreen (screen); |
7f176909ab86
move display_info class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
148 *wd = WidthOfScreen (screen); |
18932
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
149 |
23746
7f176909ab86
move display_info class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
150 int screen_number = XScreenNumberOfScreen (screen); |
18932
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
151 |
23746
7f176909ab86
move display_info class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
152 double ht_mm = DisplayHeightMM (display, screen_number); |
7f176909ab86
move display_info class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
153 double wd_mm = DisplayWidthMM (display, screen_number); |
18932
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
154 |
23746
7f176909ab86
move display_info class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
155 *rx = *wd * 25.4 / wd_mm; |
7f176909ab86
move display_info class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
156 *ry = *ht * 25.4 / ht_mm; |
18932
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
157 } |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
158 else |
23746
7f176909ab86
move display_info class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
159 msg = "X11 display has no default screen"; |
7f176909ab86
move display_info class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
160 |
7f176909ab86
move display_info class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
161 XCloseDisplay (display); |
7f176909ab86
move display_info class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
162 |
7f176909ab86
move display_info class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
163 *dpy_avail = 1; |
18932
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
164 } |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
165 else |
23746
7f176909ab86
move display_info class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
166 msg = "unable to open X11 DISPLAY"; |
18932
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
167 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
168 #else |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
169 |
24118
f87c9f5c0f43
maint: silence several compiler warnings when building for Windows
Mike Miller <mtmiller@octave.org>
parents:
23746
diff
changeset
|
170 octave_unused_parameter (dpy_name); |
21691
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
171 octave_unused_parameter (ht); |
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
172 octave_unused_parameter (wd); |
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
173 octave_unused_parameter (dp); |
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
174 octave_unused_parameter (rx); |
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
175 octave_unused_parameter (ry); |
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
176 |
18932
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
177 msg = "no graphical display found"; |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
178 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
179 #endif |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
180 |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
181 return msg; |
edc4791fbcb2
avoid some old-style cast warnings
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
182 } |