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?
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 is Tscope5 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  }
94 
95  al_free(_ts5_data.display);
96  al_free(_ts5_data.display_buffer);
97  al_free(_ts5_status.display);
98 
99  _ts5_status.display = NULL;
100  _ts5_data.display = NULL;
101  _ts5_data.display_buffer = NULL;
102  _ts5_data.target = NULL;
103 
104  #endif
105 
106  _ts5_status.num_displays = 0;
107  _ts5_status.active_display = -1;
108 }
109