OBActions::OBActions()
: _button(0), _enter_win(0)
{
- for (int i = 0; i < 2; ++i)
- _presses[i] = new MousePressAction();
// XXX: load a configuration out of somewhere
}
-void OBActions::insertPress(Window win, unsigned int button, Time time)
-{
- MousePressAction *a = _presses[1];
- _presses[1] = _presses[0];
- _presses[0] = a;
- a->win = win;
- a->button = button;
- a->time = time;
-}
-
-
void OBActions::buttonPressHandler(const XButtonEvent &e)
{
// XXX: run the PRESS guile hook
if (_button) return; // won't count toward CLICK events
_button = e.button;
-
- insertPress(e.window, e.button, e.time);
}
(long)e.window, e.state, e.button, e.time);
// not for the button we're watching?
- if (_button && _button != e.button) return;
+ if (_button != e.button) return;
_button = 0;
printf("GUILE: CLICK: win %lx modifiers %u button %u time %lx\n",
(long)e.window, e.state, e.button, e.time);
- if (_presses[0]->win == _presses[1]->win &&
- _presses[0]->button == _presses[1]->button &&
- e.time - _presses[1]->time < DOUBLECLICKDELAY) {
+ if (e.time - _release.time < DOUBLECLICKDELAY &&
+ _release.win == e.window && _release.button == e.button) {
// XXX: run the DOUBLECLICK guile hook
printf("GUILE: DOUBLECLICK: win %lx modifiers %u button %u time %lx\n",
(long)e.window, e.state, e.button, e.time);
+ // reset so you cant triple click for 2 doubleclicks
+ _release.win = 0;
+ _release.button = 0;
+ _release.time = 0;
+ } else {
+ // save the button release, might be part of a double click
+ _release.win = e.window;
+ _release.button = e.button;
+ _release.time = e.time;
}
}
*/
class OBActions : public otk::OtkEventHandler {
public:
- struct MousePressAction {
+ struct MouseButtonAction {
Window win;
unsigned int button;
Time time;
- MousePressAction() { win = 0; button = 0; time = 0; }
+ MouseButtonAction() { win = 0; button = 0; time = 0; }
};
private:
// milliseconds XXX: config option
static const unsigned int DOUBLECLICKDELAY;
- //! The last 2 button presses processed for CLICKs
- /*!
- Inserted such that index 0 is the latest action.
- */
- MousePressAction *_presses[2];
+ //! The last 2 button release processed for CLICKs
+ MouseButtonAction _release;
//! The mouse button currently being watched from a press for a CLICK
unsigned int _button;
//! The window the last enter action occured on (where the mouse is located)