aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2004-05-02 21:26:07 (GMT)
committerfluxgen <fluxgen>2004-05-02 21:26:07 (GMT)
commit4880851f132fc3874c5bb01db2f68bc66320063c (patch)
tree537f4ddea65065bb3b702c1a65b4ad824771ebe2
parent955c2358fbd8364be5629504cc720e0a9227d630 (diff)
downloadfluxbox_pavel-4880851f132fc3874c5bb01db2f68bc66320063c.zip
fluxbox_pavel-4880851f132fc3874c5bb01db2f68bc66320063c.tar.bz2
movetest
-rw-r--r--src/tests/movetest.cc83
1 files changed, 83 insertions, 0 deletions
diff --git a/src/tests/movetest.cc b/src/tests/movetest.cc
new file mode 100644
index 0000000..7db0c39
--- /dev/null
+++ b/src/tests/movetest.cc
@@ -0,0 +1,83 @@
1#include <iostream>
2
3#include "../FbTk/FbWindow.hh"
4#include "../FbTk/App.hh"
5#include "../FbTk/EventManager.hh"
6#include "../FbTk/EventHandler.hh"
7#include "../FbTk/Color.hh"
8
9using namespace std;
10using namespace FbTk;
11
12class Ev: public EventHandler {
13public:
14 Ev():m_window(0,
15 0, 0,
16 512, 512,
17 ExposureMask | ButtonPressMask |
18 ButtonReleaseMask | ButtonMotionMask | SubstructureRedirectMask),
19 m_drag(m_window,
20 0, 0,
21 32, 32,
22
23 ExposureMask) { /* | ButtonPressMask) {
24 ButtonReleaseMask | ButtonMotionMask) {
25 */
26 m_window.setName("hello");
27 m_window.show();
28 m_drag.setBackgroundColor(Color("blue", 0));
29 m_drag.show();
30 EventManager::instance()->add(*this, m_window);
31 EventManager::instance()->add(*this, m_drag);
32 drag = false;
33 }
34
35 void exposeEvent(XExposeEvent &event) {
36 m_drag.clear();
37 m_window.clear();
38 }
39
40 void buttonPressEvent(XButtonEvent &event) {
41 if (m_drag != event.subwindow)
42 return;
43
44 cerr<<"drag!"<<endl;
45 drag = true;
46 grab_x = event.x - m_drag.x();
47 grab_y = event.y - m_drag.y();
48 }
49
50 void buttonReleaseEvent(XButtonEvent &event) {
51 drag = false;
52 }
53
54 void motionNotifyEvent(XMotionEvent &event) {
55 if (!drag)
56 return;
57 cerr<<"event.x_root: "<<event.x_root<<endl;
58 cerr<<"event.y_root: "<<event.y_root<<endl;
59 cerr<<"event.x: "<<event.x<<endl;
60 cerr<<"event.y: "<<event.y<<endl;
61 cerr<<"event.window: "<<hex<<event.window<<endl;
62 cerr<<"event.subwindow: "<<event.subwindow<<endl;
63 cerr<<"event.root: "<<event.root<<dec<<endl;
64 cerr<<"event.is_hint: "<<event.is_hint<<endl;
65 cerr<<"event.same_screen: "<<event.same_screen<<endl;
66 cerr<<"event.send_event: "<<event.send_event<<endl;
67 cerr<<"window pos: "<<m_window.x()<<", "<<m_window.y()<<endl;
68
69 m_drag.move(event.x - grab_x,
70 event.y - grab_y);
71 }
72 int grab_x, grab_y;
73 bool drag;
74 FbWindow m_window, m_drag;
75};
76
77int main() {
78 App app;
79 Ev ev;
80 cerr<<"Drag the blue rectangle! ...please :D"<<endl;
81 app.eventLoop();
82
83}