Mercurial > octave
annotate libinterp/corefcn/display.cc @ 27266:596312d4f25d
don't use singleton pattern for display_info class
* display.h, display.cc (class display_info): Eliminate singleton pattern.
Change all uses.
* interpreter.h, interpreter.cc (interpreter::m_display_info):
New data member.
(interpreter::interpreter): Initialize m_display_info depending on
application context.
(interpreter::get_display_info): New function.
* interpreter-private.h, interpreter-private.cc
(__get_display_info__): New function.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 19 Jul 2019 10:02:20 -0400 |
parents | fff643eb3514 |
children | 1565c39aa940 |
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 |
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 |
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 |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24442
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:
24442
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. |
8561
66165de2cc42
add new files for previous changeset
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. |
8561
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 |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24442
diff
changeset
|
19 <https://www.gnu.org/licenses/>. |
8561
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 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
24 # include "config.h" |
20947
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" |
24442
98a03a1097b4
move have_window_system function from sysdep.cc to display.cc
John W. Eaton <jwe@octave.org>
parents:
23746
diff
changeset
|
30 #include "defun.h" |
20947
ecb95c6384f2
backout changeset e74e617060cf
John W. Eaton <jwe@octave.org>
parents:
20946
diff
changeset
|
31 #include "display.h" |
ecb95c6384f2
backout changeset e74e617060cf
John W. Eaton <jwe@octave.org>
parents:
20946
diff
changeset
|
32 #include "error.h" |
27266
596312d4f25d
don't use singleton pattern for display_info class
John W. Eaton <jwe@octave.org>
parents:
26377
diff
changeset
|
33 #include "interpreter.h" |
24442
98a03a1097b4
move have_window_system function from sysdep.cc to display.cc
John W. Eaton <jwe@octave.org>
parents:
23746
diff
changeset
|
34 #include "ov.h" |
98a03a1097b4
move have_window_system function from sysdep.cc to display.cc
John W. Eaton <jwe@octave.org>
parents:
23746
diff
changeset
|
35 #include "ovl.h" |
8561
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 |
23746
7f176909ab86
move display_info class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
37 namespace octave |
8561
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 { |
27266
596312d4f25d
don't use singleton pattern for display_info class
John W. Eaton <jwe@octave.org>
parents:
26377
diff
changeset
|
39 void display_info::initialize (void) |
23746
7f176909ab86
move display_info class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
40 { |
27266
596312d4f25d
don't use singleton pattern for display_info class
John W. Eaton <jwe@octave.org>
parents:
26377
diff
changeset
|
41 int avail = 0; |
8561
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 |
27266
596312d4f25d
don't use singleton pattern for display_info class
John W. Eaton <jwe@octave.org>
parents:
26377
diff
changeset
|
43 const char *msg |
596312d4f25d
don't use singleton pattern for display_info class
John W. Eaton <jwe@octave.org>
parents:
26377
diff
changeset
|
44 = octave_get_display_info (nullptr, &m_ht, &m_wd, &m_dp, |
596312d4f25d
don't use singleton pattern for display_info class
John W. Eaton <jwe@octave.org>
parents:
26377
diff
changeset
|
45 &m_rx, &m_ry, &avail); |
8561
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
46 |
27266
596312d4f25d
don't use singleton pattern for display_info class
John W. Eaton <jwe@octave.org>
parents:
26377
diff
changeset
|
47 m_dpy_avail = avail; |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13956
diff
changeset
|
48 |
27266
596312d4f25d
don't use singleton pattern for display_info class
John W. Eaton <jwe@octave.org>
parents:
26377
diff
changeset
|
49 if (msg) |
596312d4f25d
don't use singleton pattern for display_info class
John W. Eaton <jwe@octave.org>
parents:
26377
diff
changeset
|
50 warning ("%s", msg); |
23746
7f176909ab86
move display_info class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
51 } |
8561
66165de2cc42
add new files for previous changeset
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
52 } |
24442
98a03a1097b4
move have_window_system function from sysdep.cc to display.cc
John W. Eaton <jwe@octave.org>
parents:
23746
diff
changeset
|
53 |
27266
596312d4f25d
don't use singleton pattern for display_info class
John W. Eaton <jwe@octave.org>
parents:
26377
diff
changeset
|
54 DEFMETHOD (have_window_system, interp, , , |
596312d4f25d
don't use singleton pattern for display_info class
John W. Eaton <jwe@octave.org>
parents:
26377
diff
changeset
|
55 doc: /* -*- texinfo -*- |
24442
98a03a1097b4
move have_window_system function from sysdep.cc to display.cc
John W. Eaton <jwe@octave.org>
parents:
23746
diff
changeset
|
56 @deftypefn {} {} have_window_system () |
98a03a1097b4
move have_window_system function from sysdep.cc to display.cc
John W. Eaton <jwe@octave.org>
parents:
23746
diff
changeset
|
57 Return true if a window system is available (X11, Windows, or Apple OS X) |
98a03a1097b4
move have_window_system function from sysdep.cc to display.cc
John W. Eaton <jwe@octave.org>
parents:
23746
diff
changeset
|
58 and false otherwise. |
98a03a1097b4
move have_window_system function from sysdep.cc to display.cc
John W. Eaton <jwe@octave.org>
parents:
23746
diff
changeset
|
59 @seealso{isguirunning} |
98a03a1097b4
move have_window_system function from sysdep.cc to display.cc
John W. Eaton <jwe@octave.org>
parents:
23746
diff
changeset
|
60 @end deftypefn */) |
98a03a1097b4
move have_window_system function from sysdep.cc to display.cc
John W. Eaton <jwe@octave.org>
parents:
23746
diff
changeset
|
61 { |
27266
596312d4f25d
don't use singleton pattern for display_info class
John W. Eaton <jwe@octave.org>
parents:
26377
diff
changeset
|
62 octave::display_info& dpy_info = interp.get_display_info (); |
596312d4f25d
don't use singleton pattern for display_info class
John W. Eaton <jwe@octave.org>
parents:
26377
diff
changeset
|
63 |
596312d4f25d
don't use singleton pattern for display_info class
John W. Eaton <jwe@octave.org>
parents:
26377
diff
changeset
|
64 return ovl (dpy_info.display_available ()); |
24442
98a03a1097b4
move have_window_system function from sysdep.cc to display.cc
John W. Eaton <jwe@octave.org>
parents:
23746
diff
changeset
|
65 } |