Mercurial > octave
annotate libinterp/corefcn/display.cc @ 20947:ecb95c6384f2
backout changeset e74e617060cf
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 19 Dec 2015 07:54:00 -0600 |
parents | 6eff66fb8a02 |
children | 850e3d2533d4 |
rev | line source |
---|---|
8561
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1 /* |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
18932
diff
changeset
|
3 Copyright (C) 2009-2015 John W. Eaton |
8561
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4 |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5 This file is part of Octave. |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
7 Octave is free software; you can redistribute it and/or modify it |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
8 under the terms of the GNU General Public License as published by the |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
9 Free Software Foundation; either version 3 of the License, or (at your |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
10 option) any later version. |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
15 for more details. |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
19 <http://www.gnu.org/licenses/>. |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 */ |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 |
20947
ecb95c6384f2
backout changeset e74e617060cf
John W. Eaton <jwe@octave.org>
parents:
20946
diff
changeset
|
23 #ifdef HAVE_CONFIG_H |
ecb95c6384f2
backout changeset e74e617060cf
John W. Eaton <jwe@octave.org>
parents:
20946
diff
changeset
|
24 #include <config.h> |
ecb95c6384f2
backout changeset e74e617060cf
John W. Eaton <jwe@octave.org>
parents:
20946
diff
changeset
|
25 #endif |
8561
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 |
20947
ecb95c6384f2
backout changeset e74e617060cf
John W. Eaton <jwe@octave.org>
parents:
20946
diff
changeset
|
27 #include "singleton-cleanup.h" |
ecb95c6384f2
backout changeset e74e617060cf
John W. Eaton <jwe@octave.org>
parents:
20946
diff
changeset
|
28 |
ecb95c6384f2
backout changeset e74e617060cf
John W. Eaton <jwe@octave.org>
parents:
20946
diff
changeset
|
29 #include "cdisplay.h" |
ecb95c6384f2
backout changeset e74e617060cf
John W. Eaton <jwe@octave.org>
parents:
20946
diff
changeset
|
30 #include "display.h" |
ecb95c6384f2
backout changeset e74e617060cf
John W. Eaton <jwe@octave.org>
parents:
20946
diff
changeset
|
31 #include "error.h" |
8561
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 display_info *display_info::instance = 0; |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 void |
9335
f2d354df53ee
new option, --no-window-system
John W. Eaton <jwe@octave.org>
parents:
8642
diff
changeset
|
36 display_info::init (bool query) |
8561
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 { |
20947
ecb95c6384f2
backout changeset e74e617060cf
John W. Eaton <jwe@octave.org>
parents:
20946
diff
changeset
|
38 if (query) |
9335
f2d354df53ee
new option, --no-window-system
John W. Eaton <jwe@octave.org>
parents:
8642
diff
changeset
|
39 { |
20947
ecb95c6384f2
backout changeset e74e617060cf
John W. Eaton <jwe@octave.org>
parents:
20946
diff
changeset
|
40 int avail = 0; |
8561
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 |
20947
ecb95c6384f2
backout changeset e74e617060cf
John W. Eaton <jwe@octave.org>
parents:
20946
diff
changeset
|
42 const char *msg = octave_get_display_info (&ht, &wd, &dp, &rx, &ry, |
ecb95c6384f2
backout changeset e74e617060cf
John W. Eaton <jwe@octave.org>
parents:
20946
diff
changeset
|
43 &avail); |
15160
973296940c89
don't start GUI if display is not available
John W. Eaton <jwe@octave.org>
parents:
15096
diff
changeset
|
44 |
20947
ecb95c6384f2
backout changeset e74e617060cf
John W. Eaton <jwe@octave.org>
parents:
20946
diff
changeset
|
45 dpy_avail = avail; |
9335
f2d354df53ee
new option, --no-window-system
John W. Eaton <jwe@octave.org>
parents:
8642
diff
changeset
|
46 |
20947
ecb95c6384f2
backout changeset e74e617060cf
John W. Eaton <jwe@octave.org>
parents:
20946
diff
changeset
|
47 if (msg) |
ecb95c6384f2
backout changeset e74e617060cf
John W. Eaton <jwe@octave.org>
parents:
20946
diff
changeset
|
48 err_msg = msg; |
9335
f2d354df53ee
new option, --no-window-system
John W. Eaton <jwe@octave.org>
parents:
8642
diff
changeset
|
49 } |
8561
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
50 } |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
51 |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
52 bool |
9335
f2d354df53ee
new option, --no-window-system
John W. Eaton <jwe@octave.org>
parents:
8642
diff
changeset
|
53 display_info::instance_ok (bool query) |
8561
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
54 { |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 bool retval = true; |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
56 |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
57 if (! instance) |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13956
diff
changeset
|
58 { |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13956
diff
changeset
|
59 instance = new display_info (query); |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13956
diff
changeset
|
60 |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13956
diff
changeset
|
61 if (instance) |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13956
diff
changeset
|
62 singleton_cleanup_list::add (cleanup_instance); |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13956
diff
changeset
|
63 } |
8561
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
64 |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
65 if (! instance) |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
66 { |
20428
7ac907da9fba
Use error() rather than ::error() unless explicitly required.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
67 error ("unable to create display_info object!"); |
8561
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
68 |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
69 retval = false; |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
70 } |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
71 |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
72 return retval; |
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
73 } |