rayzor

diff 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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/scrman.cc	Thu Apr 10 02:31:31 2014 +0300
     1.3 @@ -0,0 +1,50 @@
     1.4 +#include <string.h>
     1.5 +#include "vector.h"
     1.6 +#include "scrman.h"
     1.7 +
     1.8 +static vector<Screen*> screens;
     1.9 +static vector<Screen*> active;
    1.10 +
    1.11 +void add_screen(Screen *s)
    1.12 +{
    1.13 +	screens.push_back(s);
    1.14 +}
    1.15 +
    1.16 +Screen *get_screen(const char *name)
    1.17 +{
    1.18 +	for(size_t i=0; i<screens.size(); i++) {
    1.19 +		if(strcmp(screens[i]->get_name(), name) == 0) {
    1.20 +			return screens[i];
    1.21 +		}
    1.22 +	}
    1.23 +	return 0;
    1.24 +}
    1.25 +
    1.26 +void destroy_screens()
    1.27 +{
    1.28 +	for(size_t i=0; i<screens.size(); i++) {
    1.29 +		screens[i]->shutdown();
    1.30 +		delete screens[i];
    1.31 +	}
    1.32 +	screens.clear();
    1.33 +	active.clear();
    1.34 +}
    1.35 +
    1.36 +void activate_screen(Screen *s)
    1.37 +{
    1.38 +	active.push_back(s);
    1.39 +}
    1.40 +
    1.41 +Screen *deactivate_screen()
    1.42 +{
    1.43 +	Screen *s = active_screen();
    1.44 +	if(!s) return 0;
    1.45 +
    1.46 +	active.pop_back();
    1.47 +	return s;
    1.48 +}
    1.49 +
    1.50 +Screen *active_screen()
    1.51 +{
    1.52 +	return active.empty() ? 0 : active.back();
    1.53 +}