rayzor
view src/scrman.cc @ 9:70e332156d02
moving along
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 10 Apr 2014 02:31:31 +0300 |
parents | |
children |
line source
1 #include <string.h>
2 #include "vector.h"
3 #include "scrman.h"
5 static vector<Screen*> screens;
6 static vector<Screen*> active;
8 void add_screen(Screen *s)
9 {
10 screens.push_back(s);
11 }
13 Screen *get_screen(const char *name)
14 {
15 for(size_t i=0; i<screens.size(); i++) {
16 if(strcmp(screens[i]->get_name(), name) == 0) {
17 return screens[i];
18 }
19 }
20 return 0;
21 }
23 void destroy_screens()
24 {
25 for(size_t i=0; i<screens.size(); i++) {
26 screens[i]->shutdown();
27 delete screens[i];
28 }
29 screens.clear();
30 active.clear();
31 }
33 void activate_screen(Screen *s)
34 {
35 active.push_back(s);
36 }
38 Screen *deactivate_screen()
39 {
40 Screen *s = active_screen();
41 if(!s) return 0;
43 active.pop_back();
44 return s;
45 }
47 Screen *active_screen()
48 {
49 return active.empty() ? 0 : active.back();
50 }