]> git.vomp.tv Git - vompclient.git/blob - boxstack.h
WIN32 compatibility
[vompclient.git] / boxstack.h
1 /*
2     Copyright 2004-2005 Chris Tallon
3
4     This file is part of VOMP.
5
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
18 */
19
20 #ifndef BOXSTACK_H
21 #define BOXSTACK_H
22
23 #include <stdio.h>
24 #include <time.h>
25 #include <signal.h>
26 #include <list>
27 #include <stack>
28 #include <mutex>
29
30 #include "boxx.h"
31 #include "region.h"
32 #include "message.h"
33 #include "video.h"
34
35
36
37 typedef std::list<Region> RegionList;
38 typedef std::stack<std::pair<Boxx*,VideoDisplay> > VideoDisplayStack;
39
40 class BoxStack
41 {
42   public:
43     BoxStack();
44     virtual ~BoxStack();
45     static BoxStack* getInstance();
46
47     int init();
48     int shutdown();
49
50     // These functions do internal locking, so can be called directly from any thread. Hopefully.
51     int add(Boxx*);
52     int remove(Boxx*);
53     void removeAllExceptWallpaper();
54     void removeAll();
55     void update(Boxx*, Region* regionToUpdate = NULL);
56     void redrawAllBoxes();
57     // -- end
58
59     int handleCommand(int command);
60     void processMessage(Message* m);
61
62   private:
63     static BoxStack* instance;
64     int initted;
65
66     Boxx* boxes[20];
67     int numBoxes;
68
69     VideoDisplayStack videoStack;
70
71     std::mutex boxLock;
72
73     void deleteBox(int z);
74     void repaintRevealed(int x, Region r);
75     void boxSplit(Region r, int start, int end, int direction, RegionList& rl);
76     int addVideoDisplay(Boxx*,VideoDisplay);
77 };
78
79 #endif