Tscope5
display_internal.c
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // __ ______
4 // / /_______________ ____ ___ / ____/
5 // / __/ ___/ ___/ __ \/ __ \/ _ \ /___ )
6 // / /_(__ ) /__/ /_/ / /_/ / __/ ____/ /
7 // \__/____/\___/\____/ .___/\___/ /_____/
8 // /_/
9 //
10 /// \file display_internal.c
11 /// Definitions of internal display functions.
12 ////////////////////////////////////////////////////////////////////////////////
13 
14 #include "../include/tscope5/display.h"
15 #include "../include/tscope5/display_internal.h"
16 #include "../include/tscope5/system_internal.h"
17 
18 /// Is the display subsystem installed?w
20 
21 
22 ////////////////////////////////////////////////////////////////////////////////
23 /// Do some checks at the start of each display function.
24 ///
25 /// \param calling_function Name the function that calls for
26 /// this check or installation.
27 ///
28 /// Checks whether Tscope5 is installed. If not, Tscope5 is installed.
29 ////////////////////////////////////////////////////////////////////////////////
30 void ts5_check_display(char *calling_function)
31 {
32  ts5_log(TS5_LOGLEVEL_6, "%s: ts5_check_display\n", calling_function);
34  ts5_install_tscope5(calling_function);
35  }
36 }
37 
38 
39 ////////////////////////////////////////////////////////////////////////////////
40 /// Do some checks at the start of each display function.
41 ///
42 /// \param calling_function Name the function that calls for
43 /// this check or installation.
44 ///
45 /// \param display Index of the display that has to be checked.
46 ///
47 /// Checks whether display 'display' is a valid display.
48 /// If not, the program is aborted.
49 ////////////////////////////////////////////////////////////////////////////////
50 void ts5_check_display2(char *calling_function, const int display)
51 {
52  ts5_check_display(calling_function);
53  ts5_log(TS5_LOGLEVEL_6, "%s: ts5_check_display2\n", calling_function);
54 
55  if (display < 0 || display > _ts5_status.num_displays) {
56  ts5_fatal("%s: display index not valid\n", calling_function);
57  }
58 }
59 
60 
61 ////////////////////////////////////////////////////////////////////////////////
62 /// Close all open displays.
63 ///
64 /// Currently all displays are closed at once,
65 /// there is no option to close only one display
66 /// and leave the others open.
67 ///
68 /// This function is called automatically at the end of the program.
69 ///
70 /// \warning Do not call this function yourself
71 /// and try to reopen a new window in the same program.
72 /// This will result in undefined behavior
73 /// (i.e. sometimes it will work fine, sometimes it will crash).
74 ////////////////////////////////////////////////////////////////////////////////
76 {
77  ts5_check_display("ts5_uninstall_displays");
78  ts5_log(TS5_LOGLEVEL_1, "Uninstalling Tscope5 displays\n");
79 // ts5_uninstall_mouse();
80 // ts5_uninstall_keyboard();
81 
82  #ifdef TS5_MACOSX
83  int i;
84  for (i = 0; i < _ts5_status.num_displays; i++) {
85 
86  if (_ts5_status.display[i].display_mode == TS5_FULLSCREEN_WINDOW) {
87  al_toggle_display_flag(_ts5_data.display[i],
88  ALLEGRO_FULLSCREEN_WINDOW, 0);
89  }
90 
91  al_destroy_display(_ts5_data.display[i]);
92  al_destroy_bitmap(_ts5_data.display_buffer[i]);
93  al_destroy_bitmap(_ts5_data.display_backup[i]);
94  }
95 
96  al_free(_ts5_data.display);
97  al_free(_ts5_data.display_buffer);
98  al_free(_ts5_data.display_backup);
99  al_free(_ts5_status.display);
100 
101  _ts5_status.display = NULL;
102  _ts5_data.display = NULL;
103  _ts5_data.display_buffer = NULL;
104  _ts5_data.display_backup = NULL;
105  _ts5_data.target = NULL;
106 
107  #endif
108 
109  _ts5_status.num_displays = 0;
110  _ts5_status.active_display = -1;
111 }
112 
int _ts5_is_tscope5_installed
Is Tscope5 installed?
void ts5_check_display(char *calling_function)
Do some checks at the start of each display function.
void ts5_check_display2(char *calling_function, const int display)
Do some checks at the start of each display function.
int _ts5_is_display_installed
Is the display subsystem installed?w.
void ts5_uninstall_displays()
Close all open displays.
void ts5_log(const unsigned int level, const char *format,...)
Send info to a logging window.
Definition: system.c:45
void ts5_install_tscope5(char *calling_function)
Install Tscope5.
void ts5_fatal(const char *format,...)
Exit safely with an error message.
Definition: system.c:533