]>
Dogcows Code - chaz/openbox/blob - src/actions.cc
af33f51c60d562914dd31cf7db99a2e4b4099f86
1 // -*- mode: C++; indent-tabs-mode: nil; -*-
4 # include "../config.h"
8 #include "otk/display.hh"
14 const unsigned int OBActions::DOUBLECLICKDELAY
= 300;
15 const int OBActions::BUTTONS
;
17 OBActions::OBActions()
20 for (int i
=0; i
<BUTTONS
; ++i
)
21 _posqueue
[i
] = new ButtonPressAction();
23 // XXX: load a configuration out of somewhere
28 OBActions::~OBActions()
30 for (int i
=0; i
<BUTTONS
; ++i
)
35 void OBActions::insertPress(const XButtonEvent
&e
)
37 ButtonPressAction
*a
= _posqueue
[BUTTONS
- 1];
38 for (int i
=BUTTONS
-1; i
>0;)
39 _posqueue
[i
] = _posqueue
[--i
];
42 a
->pos
.setPoint(e
.x
, e
.y
);
45 void OBActions::removePress(const XButtonEvent
&e
)
47 ButtonPressAction
*a
= 0;
48 for (int i
=0; i
<BUTTONS
; ++i
) {
49 if (_posqueue
[i
]->button
== e
.button
)
51 if (a
) // found one and removed it
52 _posqueue
[i
] = _posqueue
[i
+1];
55 _posqueue
[BUTTONS
-1] = a
;
60 void OBActions::buttonPressHandler(const XButtonEvent
&e
)
62 OtkEventHandler::buttonPressHandler(e
);
65 // XXX: run the PRESS guile hook
66 printf("GUILE: PRESS: win %lx modifiers %u button %u time %lx\n",
67 (long)e
.window
, e
.state
, e
.button
, e
.time
);
69 if (_button
) return; // won't count toward CLICK events
75 void OBActions::buttonReleaseHandler(const XButtonEvent
&e
)
77 OtkEventHandler::buttonReleaseHandler(e
);
80 // XXX: run the RELEASE guile hook
81 printf("GUILE: RELEASE: win %lx modifiers %u button %u time %lx\n",
82 (long)e
.window
, e
.state
, e
.button
, e
.time
);
84 // not for the button we're watching?
85 if (_button
!= e
.button
) return;
89 // find the area of the window
90 XWindowAttributes attr
;
91 if (!XGetWindowAttributes(otk::OBDisplay::display
, e
.window
, &attr
)) return;
93 // if not on the window any more, it isnt a CLICK
94 if (!(e
.same_screen
&& e
.x
>= 0 && e
.y
>= 0 &&
95 e
.x
< attr
.width
&& e
.y
< attr
.height
))
98 // XXX: run the CLICK guile hook
99 printf("GUILE: CLICK: win %lx modifiers %u button %u time %lx\n",
100 (long)e
.window
, e
.state
, e
.button
, e
.time
);
102 if (e
.time
- _release
.time
< DOUBLECLICKDELAY
&&
103 _release
.win
== e
.window
&& _release
.button
== e
.button
) {
105 // XXX: run the DOUBLECLICK guile hook
106 printf("GUILE: DOUBLECLICK: win %lx modifiers %u button %u time %lx\n",
107 (long)e
.window
, e
.state
, e
.button
, e
.time
);
109 // reset so you cant triple click for 2 doubleclicks
114 // save the button release, might be part of a double click
115 _release
.win
= e
.window
;
116 _release
.button
= e
.button
;
117 _release
.time
= e
.time
;
122 void OBActions::enterHandler(const XCrossingEvent
&e
)
124 OtkEventHandler::enterHandler(e
);
126 // XXX: run the ENTER guile hook
127 printf("GUILE: ENTER: win %lx modifiers %u\n", (long)e
.window
, e
.state
);
131 void OBActions::leaveHandler(const XCrossingEvent
&e
)
133 OtkEventHandler::leaveHandler(e
);
135 // XXX: run the LEAVE guile hook
136 printf("GUILE: LEAVE: win %lx modifiers %u\n", (long)e
.window
, e
.state
);
140 void OBActions::keyPressHandler(const XKeyEvent
&e
)
142 // XXX: run the KEY guile hook
143 printf("GUILE: KEY: win %lx modifiers %u keycode %u\n",
144 (long)e
.window
, e
.state
, e
.keycode
);
148 void OBActions::motionHandler(const XMotionEvent
&e
)
150 // XXX: i can envision all sorts of crazy shit with this.. gestures, etc
151 printf("GUILE: MOTION: win %lx modifiers %u x %d y %d\n",
152 (long)e
.window
, e
.state
,
153 e
.x
- _posqueue
[0]->pos
.x(), e
.y
- _posqueue
[0]->pos
.y());
This page took 0.038273 seconds and 4 git commands to generate.