summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2002-12-04 08:12:09 +0000
committerDana Jansens <danakj@orodu.net>2002-12-04 08:12:09 +0000
commit90ae66cc44a93ab1419821944c258e72d1e4b559 (patch)
tree0c5e9b161b1d9fc3f7369f90c6f499b2fdcacfcd /src
parent0a15728be441cf687ef93fd2ab8c38266adacd94 (diff)
better double click processing
Diffstat (limited to 'src')
-rw-r--r--src/actions.cc31
-rw-r--r--src/actions.hh11
2 files changed, 16 insertions, 26 deletions
diff --git a/src/actions.cc b/src/actions.cc
index d8162a50..6043ad0e 100644
--- a/src/actions.cc
+++ b/src/actions.cc
@@ -15,8 +15,6 @@ const unsigned int OBActions::DOUBLECLICKDELAY = 300;
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
@@ -28,17 +26,6 @@ OBActions::~OBActions()
}
-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
@@ -48,8 +35,6 @@ void OBActions::buttonPressHandler(const XButtonEvent &e)
if (_button) return; // won't count toward CLICK events
_button = e.button;
-
- insertPress(e.window, e.button, e.time);
}
@@ -60,7 +45,7 @@ void OBActions::buttonReleaseHandler(const XButtonEvent &e)
(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;
@@ -77,14 +62,22 @@ void OBActions::buttonReleaseHandler(const XButtonEvent &e)
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;
}
}
diff --git a/src/actions.hh b/src/actions.hh
index 924a8dc0..35e8e313 100644
--- a/src/actions.hh
+++ b/src/actions.hh
@@ -20,22 +20,19 @@ namespace ob {
*/
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)