aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-01-29 21:39:52 (GMT)
committerrathnor <rathnor>2003-01-29 21:39:52 (GMT)
commit0f5247ccce2d55d36ba823fe4cc6adcd3801c02d (patch)
treea7ce82fdfc46b3f0f9a547cdca5d545a8f6b6e3b
parentb0d9aa11246fc23f8296d25dfc9f72310a93f614 (diff)
downloadfluxbox_pavel-0f5247ccce2d55d36ba823fe4cc6adcd3801c02d.zip
fluxbox_pavel-0f5247ccce2d55d36ba823fe4cc6adcd3801c02d.tar.bz2
added simple test file for layering (Simon)
-rw-r--r--src/tests/Makefile34
-rw-r--r--src/tests/testLayers.cc222
2 files changed, 241 insertions, 15 deletions
diff --git a/src/tests/Makefile b/src/tests/Makefile
index 4e1d80c..a6cc02f 100644
--- a/src/tests/Makefile
+++ b/src/tests/Makefile
@@ -1,36 +1,36 @@
1CXX=g++ 1CXX=g++
2CXXFLAGS= -I.. -DDEBUG -DUSE_XFT -Wall -g -O2 2CXXFLAGS= -I.. -I../FbTk -DDEBUG -DUSE_XFT -Wall -g -O2
3LIBS= 3LIBS=
4XFLAGS= -I/usr/X11R6/include 4XFLAGS= -I/usr/X11R6/include
5XLIBS= -L/usr/X11R6/lib -lX11 -lXft 5XLIBS= -L/usr/X11R6/lib -lX11 -lXft
6COMPILEFILE=$(CXX) -c $(CXXFLAGS) 6COMPILEFILE=$(CXX) -c $(CXXFLAGS)
7FONT_OBJ = ../BaseDisplay.o ../Font.o ../XFontImp.o ../XftFontImp.o ../XmbFontImp.o \ 7FONT_OBJ = ../BaseDisplay.o ../FbTk/Font.o ../FbTk/XFontImp.o ../FbTk/XftFontImp.o ../FbTk/XmbFontImp.o \
8 ../Timer.o ../StringUtil.o ../i18n.o 8 ../FbTk/Timer.o ../StringUtil.o ../i18n.o
9 9
10all: testStringUtil testKeys testResource testSignal 10all: testLayers testStringUtil testKeys testResource testSignal
11 11
12.cc.o: 12.cc.o:
13 $(CXX) -c $(CXXFLAGS) $< -o $@ 13 $(CXX) -c $(CXXFLAGS) $< -o $@
14
15../XftFontImp.o: ../XftFontImp.hh ../XftFontImp.cc
16 14
17../XmbFontImp.o: ../XmbFontImp.hh ../XmbFontImp.cc 15../FbTk/XftFontImp.o: ../FbTk/XftFontImp.hh ../FbTk/XftFontImp.cc
18 16
19../XFontImp.o: ../XFontImp.hh ../XFontImp.cc 17../FbTk/XmbFontImp.o: ../FbTk/XmbFontImp.hh ../FbTk/XmbFontImp.cc
20 18
21../Font.o: ../XFontImp.hh ../XftFontImp.hh ../XmbFontImp.hh ../Font.hh ../Font.cc 19../FbTk/XFontImp.o: ../FbTk/XFontImp.hh ../FbTk/XFontImp.cc
20
21../FbTk/Font.o: ../FbTk/XFontImp.hh ../FbTk/XftFontImp.hh ../FbTk/XmbFontImp.hh ../FbTk/Font.hh ../FbTk/Font.cc
22 22
23StringUtil.o: ../StringUtil.cc ../StringUtil.hh 23StringUtil.o: ../StringUtil.cc ../StringUtil.hh
24 $(CXX) -c $(CXXFLAGS) ../StringUtil.cc -o StringUtil.o 24 $(CXX) -c $(CXXFLAGS) ../StringUtil.cc -o StringUtil.o
25 25
26Keys.o: ../Keys.cc ../Keys.hh 26Keys.o: ../Keys.cc ../Keys.hh
27 $(CXX) -c $(CXXFLAGS) $(XFLAGS) ../Keys.cc -o Keys.o 27 $(CXX) -c $(CXXFLAGS) $(XFLAGS) ../Keys.cc -o Keys.o
28 28
29Resource.o: ../Resource.cc ../Resource.hh 29Resource.o: ../Resource.cc ../Resource.hh
30 $(CXX) -c $(CXXFLAGS) $(XFLAGS) ../Resource.cc -o Resource.o 30 $(CXX) -c $(CXXFLAGS) $(XFLAGS) ../Resource.cc -o Resource.o
31 31
32../SignalHandler.o: 32../FbTk/SignalHandler.o:
33 ${COMPILEFILE} ../SignalHandler.cc -o ../SignalHandler.o 33 ${COMPILEFILE} ../FbTk/SignalHandler.cc -o ../FbTk/SignalHandler.o
34 34
35testStringUtil: StringUtiltest.o StringUtil.o 35testStringUtil: StringUtiltest.o StringUtil.o
36 $(CXX) $(LIBS) StringUtiltest.o StringUtil.o -o testStringUtil 36 $(CXX) $(LIBS) StringUtiltest.o StringUtil.o -o testStringUtil
@@ -41,13 +41,17 @@ testKeys: Keys.o testKeys.o StringUtil.o
41testResource: Resourcetest.o Resource.o 41testResource: Resourcetest.o Resource.o
42 ${CXX} ${LIBS} ${XLIBS} Resourcetest.o Resource.o -o testResource 42 ${CXX} ${LIBS} ${XLIBS} Resourcetest.o Resource.o -o testResource
43 43
44testSignal: signaltest.cc ../SignalHandler.o 44testSignal: signaltest.cc ../FbTk/SignalHandler.o
45 ${CXX} ${LIBS} signaltest.cc ../SignalHandler.o -o testSignal 45 ${CXX} ${LIBS} signaltest.cc ../FbTk/SignalHandler.o -o testSignal
46 46
47testFont: testFont.cc ${FONT_OBJ} 47testFont: testFont.cc ${FONT_OBJ}
48 ${CXX} ${CXXFLAGS} ${XLIBS} testFont.cc ${FONT_OBJ} -o testFont 48 ${CXX} ${CXXFLAGS} ${XLIBS} testFont.cc ${FONT_OBJ} -o testFont
49 49
50run: testResource testKeys testStringUtil testFont 50testLayers: testLayers.cc
51 ${CXX} ${CXXFLAGS} ${XLIBS} testLayers.cc ../FbTk/libFbTk.a -o testLayers
52
53run: testLayers testResource testKeys testStringUtil testFont
54 ./testLayers
51 ./testKeys 55 ./testKeys
52 ./testStringUtil 56 ./testStringUtil
53 ./testResource 57 ./testResource
diff --git a/src/tests/testLayers.cc b/src/tests/testLayers.cc
new file mode 100644
index 0000000..59a5d01
--- /dev/null
+++ b/src/tests/testLayers.cc
@@ -0,0 +1,222 @@
1#include "App.hh"
2#include "FbWindow.hh"
3#include "Color.hh"
4#include "EventManager.hh"
5#include <iostream>
6#include "XLayer.hh"
7#include "XLayerItem.hh"
8#include "MultLayers.hh"
9
10using namespace FbTk;
11using namespace std;
12int main() {
13 FbTk::App app;
14 int mask = ButtonPressMask;
15 FbWindow win_red(0, 0, 0, 60, 60, mask, true);
16 FbWindow win_redB(0, 0, 0, 60, 60, mask, true);
17 FbWindow win_blue(0, 30, 0, 60, 60, mask, true);
18 FbWindow win_green(0, 60, 0, 60, 60, mask, true);
19 FbWindow win_red2(0, 0, 0, 60, 60, mask, true);
20 FbWindow win_blue2(0, 30, 0, 60, 60, mask, true);
21 FbWindow win_green2(0, 60, 0, 60, 60, mask, true);
22 FbWindow win_red3(0, 0, 0, 60, 60, mask, true);
23 FbWindow win_blue3(0, 30, 0, 60, 60, mask, true);
24 FbWindow win_green3(0, 60, 0, 60, 60, mask, true);
25 Color red("red", 0);
26 Color blue("blue", 0);
27 Color green("green", 0);
28 Color red2("magenta", 0);
29 Color blue2("cyan", 0);
30 Color green2("yellow", 0);
31 Color red3("pink", 0);
32 Color blue3("navy", 0);
33 Color green3("brown", 0);
34 win_red.setBackgroundColor(red);
35 win_red.clear();
36 win_redB.setBackgroundColor(red);
37 win_redB.clear();
38 win_blue.setBackgroundColor(blue);
39 win_blue.clear();
40 win_green.setBackgroundColor(green);
41 win_green.clear();
42
43 win_red2.setBackgroundColor(red2);
44 win_red2.clear();
45 win_blue2.setBackgroundColor(blue2);
46 win_blue2.clear();
47 win_green2.setBackgroundColor(green2);
48 win_green2.clear();
49
50 win_red3.setBackgroundColor(red3);
51 win_red3.clear();
52 win_blue3.setBackgroundColor(blue3);
53 win_blue3.clear();
54 win_green3.setBackgroundColor(green3);
55 win_green3.clear();
56
57 win_red.show();
58 win_red.move(10, 10);
59 win_redB.show();
60 win_redB.move(30, 30);
61 win_blue.show();
62 win_blue.move(40, 40);
63 win_green.show();
64 win_green.move(50, 20);
65
66 win_red2.show();
67 win_red2.move(15, 15);
68 win_blue2.show();
69 win_blue2.move(45, 45);
70 win_green2.show();
71 win_green2.move(45, 15);
72
73 /*
74 win_red3.show();
75 win_red3.move(5, 5);
76 win_blue3.show();
77 win_blue3.move(35, 35);
78 win_green3.show();
79 win_green3.move(45, 5);
80 */
81
82 EventManager &evm = *EventManager::instance();
83 Display *disp = app.display();
84 XEvent event;
85 MultLayers *ml = new MultLayers(3);
86 XLayerItem *item_red = new XLayerItem(win_red.window());
87 item_red->addWindow(win_redB.window());
88 XLayerItem *item_green = new XLayerItem(win_green.window());
89 XLayerItem *item_blue = new XLayerItem(win_blue.window());
90
91 ml->addToTop(*item_blue, 0);
92 ml->addToTop(*item_green, 0);
93 ml->addToTop(*item_red, 0);
94
95 XLayerItem *item_red2 = new XLayerItem(win_red2.window());
96 XLayerItem *item_green2 = new XLayerItem(win_green2.window());
97 XLayerItem *item_blue2 = new XLayerItem(win_blue2.window());
98
99 ml->addToTop(*item_blue2, 1);
100 ml->addToTop(*item_green2, 1);
101 ml->addToTop(*item_red2, 1);
102
103 XLayerItem *item_red3 = new XLayerItem(win_red3.window());
104 XLayerItem *item_green3 = new XLayerItem(win_green3.window());
105 XLayerItem *item_blue3 = new XLayerItem(win_blue3.window());
106
107 ml->addToTop(*item_blue3, 2);
108 ml->addToTop(*item_green3, 2);
109 ml->addToTop(*item_red3, 2);
110
111 //item_blue.setLayer(*layer);
112 //item_green.setLayer(*layer);
113 //item_red.setLayer(*layer);
114 cerr<<"red: "<<hex<<win_red.window()<<endl;
115 cerr<<"blue: "<<hex<<win_blue.window()<<endl;
116 cerr<<"green: "<<hex<<win_green.window()<<endl;
117 cerr<<"Left click on color to raise one step"<<endl;
118 cerr<<"Right click on color to raise to next level up"<<endl;
119 cerr<<"Middle click on color to lower to next level down"<<endl;
120 XFlush(disp);
121 //layer.restack();
122 while (1) {
123 while (XNextEvent(disp, &event))
124 continue;
125 if (event.xbutton.button == 1) {
126 if (event.xany.window == win_red.window() || event.xany.window == win_redB.window()) {
127 item_red->raise();
128 cerr<<"Raise red"<<endl;
129 } else if (event.xany.window == win_blue.window()) {
130 item_blue->raise();
131 cerr<<"Raise blue"<<endl;
132 } else if (event.xany.window == win_green.window()) {
133 item_green->raise();
134 cerr<<"Raise green"<<endl;
135 } else if (event.xany.window == win_red2.window()) {
136 item_red2->raise();
137 cerr<<"Raise red2"<<endl;
138 } else if (event.xany.window == win_blue2.window()) {
139 item_blue2->raise();
140 cerr<<"Raise blue2"<<endl;
141 } else if (event.xany.window == win_green2.window()) {
142 item_green2->raise();
143 cerr<<"Raise green2"<<endl;
144 } else if (event.xany.window == win_red3.window()) {
145 item_red3->raise();
146 cerr<<"Raise red3"<<endl;
147 } else if (event.xany.window == win_blue3.window()) {
148 item_blue3->raise();
149 cerr<<"Raise blue3"<<endl;
150 } else if (event.xany.window == win_green3.window()) {
151 item_green3->raise();
152 cerr<<"Raise green3"<<endl;
153 } else {
154 cerr<<"Unknown window"<<endl;
155 }
156
157 } else if (event.xbutton.button == 3) {
158 if (event.xany.window == win_red.window() || event.xany.window == win_redB.window()) {
159 ml->raise(*item_red);
160 } else if (event.xany.window == win_blue.window()) {
161 ml->raise(*item_blue);
162 } else if (event.xany.window == win_green.window()) {
163 ml->raise(*item_green);
164 } else if (event.xany.window == win_red2.window()) {
165 ml->raise(*item_red2);
166 } else if (event.xany.window == win_blue2.window()) {
167 ml->raise(*item_blue2);
168 } else if (event.xany.window == win_green2.window()) {
169 ml->raise(*item_green2);
170 } else if (event.xany.window == win_red3.window()) {
171 ml->raise(*item_red3);
172 } else if (event.xany.window == win_blue3.window()) {
173 ml->raise(*item_blue3);
174 } else if (event.xany.window == win_green3.window()) {
175 ml->raise(*item_green3);
176 } else {
177 cerr<<"Unknown window"<<endl;
178 }
179
180 } else if (event.xbutton.button == 2) {
181 if (event.xany.window == win_red.window() || event.xany.window == win_redB.window()) {
182 ml->lower(*item_red);
183 } else if (event.xany.window == win_blue.window()) {
184 ml->lower(*item_blue);
185 } else if (event.xany.window == win_green.window()) {
186 ml->lower(*item_green);
187 } else if (event.xany.window == win_red2.window()) {
188 ml->lower(*item_red2);
189 } else if (event.xany.window == win_blue2.window()) {
190 ml->lower(*item_blue2);
191 } else if (event.xany.window == win_green2.window()) {
192 ml->lower(*item_green2);
193 } else if (event.xany.window == win_red3.window()) {
194 ml->lower(*item_red3);
195 } else if (event.xany.window == win_blue3.window()) {
196 ml->lower(*item_blue3);
197 } else if (event.xany.window == win_green3.window()) {
198 ml->lower(*item_green3);
199 } else {
200 cerr<<"Unknown window"<<endl;
201 }
202
203 } else {
204 cerr<<"Button: "<<event.xbutton.button<<endl;
205 if (event.xany.window == win_red.window() || event.xany.window == win_redB.window()) {
206 item_red->raise();
207 cerr<<"Raise red"<<endl;
208 } else if (event.xany.window == win_blue.window()) {
209 item_blue->raise();
210 cerr<<"Raise blue"<<endl;
211 } else if (event.xany.window == win_green.window()) {
212 item_green->raise();
213 cerr<<"Raise green"<<endl;
214 } else {
215 cerr<<"Unknown window"<<endl;
216 }
217
218 }
219
220 }
221
222}