1 // -*- mode: C++; indent-tabs-mode: nil; -*-
4 # include "../config.h"
13 const unsigned int OBActions::DOUBLECLICKDELAY = 300;
15 OBActions::OBActions()
16 : _button(0), _enter_win(0)
18 _presses[0] = new MousePressAction();
19 _presses[1] = new MousePressAction();
21 // XXX: load a configuration out of somewhere
26 OBActions::~OBActions()
31 void OBActions::insertPress(Window win, unsigned int button, Time time)
33 MousePressAction *a = _presses[1];
34 _presses[1] = _presses[0];
42 void OBActions::buttonPressHandler(const XButtonEvent &e)
44 // XXX: run the PRESS guile hook
45 printf("GUILE: PRESS: win %lx modifiers %u button %u time %lx\n",
46 (long)e.window, e.state, e.button, e.time);
48 if (_button) return; // won't count toward CLICK events
52 insertPress(e.window, e.button, e.time);
56 void OBActions::buttonReleaseHandler(const XButtonEvent &e)
58 // XXX: run the RELEASE guile hook
59 printf("GUILE: RELEASE: win %lx modifiers %u button %u time %lx\n",
60 (long)e.window, e.state, e.button, e.time);
62 // not for the button we're watching?
63 if (_button && _button != e.button) return;
67 // find the area of the window
68 XWindowAttributes attr;
69 if (!XGetWindowAttributes(otk::OBDisplay::display, e.window, &attr)) return;
71 // if not on the window any more, it isnt a CLICK
72 if (!(e.same_screen && e.x >= 0 && e.y >= 0 &&
73 e.x < attr.width && e.y < attr.height))
76 // XXX: run the CLICK guile hook
77 printf("GUILE: CLICK: win %lx modifiers %u button %u time %lx\n",
78 (long)e.window, e.state, e.button, e.time);
80 if (_presses[0]->win == _presses[1]->win &&
81 _presses[0]->button == _presses[1]->button &&
82 e.time - _presses[1]->time < DOUBLECLICKDELAY) {
84 // XXX: run the DOUBLECLICK guile hook
85 printf("GUILE: DOUBLECLICK: win %lx modifiers %u button %u time %lx\n",
86 (long)e.window, e.state, e.button, e.time);
92 void OBActions::enter(Window win, unsigned int modifiers)
97 // XXX: run the ENTER guile hook
98 printf("GUILE: ENTER: win %lx modifiers %u\n", (long)win, modifiers);
103 void OBActions::leave(unsigned int modifiers)
106 // XXX: run the LEAVE guile hook
107 printf("GUILE: LEAVE: win %lx modifiers %u\n", (long)_enter_win, modifiers);
113 void OBActions::drag(Window win, otk::Point delta, unsigned int modifiers,
114 unsigned int button, Time time)
116 (void)win;(void)delta;(void)modifiers;(void)button;(void)time;
118 // XXX: some guile shit...
122 void OBActions::key(Window win, unsigned int modifiers, unsigned int keycode)
124 (void)win;(void)modifiers;(void)keycode;
126 // XXX: some guile shit...