]> Dogcows Code - chaz/openbox/blob - src/actions.cc
better double click processing
[chaz/openbox] / src / actions.cc
1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2
3 #ifdef HAVE_CONFIG_H
4 # include "../config.h"
5 #endif
6
7 #include "actions.hh"
8
9 #include <stdio.h>
10
11 namespace ob {
12
13 const unsigned int OBActions::DOUBLECLICKDELAY = 300;
14
15 OBActions::OBActions()
16 : _button(0), _enter_win(0)
17 {
18
19 // XXX: load a configuration out of somewhere
20
21 }
22
23
24 OBActions::~OBActions()
25 {
26 }
27
28
29 void OBActions::buttonPressHandler(const XButtonEvent &e)
30 {
31 // XXX: run the PRESS guile hook
32 printf("GUILE: PRESS: win %lx modifiers %u button %u time %lx\n",
33 (long)e.window, e.state, e.button, e.time);
34
35 if (_button) return; // won't count toward CLICK events
36
37 _button = e.button;
38 }
39
40
41 void OBActions::buttonReleaseHandler(const XButtonEvent &e)
42 {
43 // XXX: run the RELEASE guile hook
44 printf("GUILE: RELEASE: win %lx modifiers %u button %u time %lx\n",
45 (long)e.window, e.state, e.button, e.time);
46
47 // not for the button we're watching?
48 if (_button != e.button) return;
49
50 _button = 0;
51
52 // find the area of the window
53 XWindowAttributes attr;
54 if (!XGetWindowAttributes(otk::OBDisplay::display, e.window, &attr)) return;
55
56 // if not on the window any more, it isnt a CLICK
57 if (!(e.same_screen && e.x >= 0 && e.y >= 0 &&
58 e.x < attr.width && e.y < attr.height))
59 return;
60
61 // XXX: run the CLICK guile hook
62 printf("GUILE: CLICK: win %lx modifiers %u button %u time %lx\n",
63 (long)e.window, e.state, e.button, e.time);
64
65 if (e.time - _release.time < DOUBLECLICKDELAY &&
66 _release.win == e.window && _release.button == e.button) {
67
68 // XXX: run the DOUBLECLICK guile hook
69 printf("GUILE: DOUBLECLICK: win %lx modifiers %u button %u time %lx\n",
70 (long)e.window, e.state, e.button, e.time);
71
72 // reset so you cant triple click for 2 doubleclicks
73 _release.win = 0;
74 _release.button = 0;
75 _release.time = 0;
76 } else {
77 // save the button release, might be part of a double click
78 _release.win = e.window;
79 _release.button = e.button;
80 _release.time = e.time;
81 }
82 }
83
84
85 void OBActions::enter(Window win, unsigned int modifiers)
86 {
87 _enter_win = win;
88
89 (void)modifiers;
90 // XXX: run the ENTER guile hook
91 printf("GUILE: ENTER: win %lx modifiers %u\n", (long)win, modifiers);
92
93 }
94
95
96 void OBActions::leave(unsigned int modifiers)
97 {
98 (void)modifiers;
99 // XXX: run the LEAVE guile hook
100 printf("GUILE: LEAVE: win %lx modifiers %u\n", (long)_enter_win, modifiers);
101
102 _enter_win = 0;
103 }
104
105
106 void OBActions::drag(Window win, otk::Point delta, unsigned int modifiers,
107 unsigned int button, Time time)
108 {
109 (void)win;(void)delta;(void)modifiers;(void)button;(void)time;
110
111 // XXX: some guile shit...
112 }
113
114
115 void OBActions::key(Window win, unsigned int modifiers, unsigned int keycode)
116 {
117 (void)win;(void)modifiers;(void)keycode;
118
119 // XXX: some guile shit...
120 }
121
122
123 }
This page took 0.038336 seconds and 4 git commands to generate.