]> Dogcows Code - chaz/openbox/blob - src/actions.cc
button press/releases WORK
[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 _presses[0] = new MousePressAction();
19 _presses[1] = new MousePressAction();
20
21 // XXX: load a configuration out of somewhere
22
23 }
24
25
26 OBActions::~OBActions()
27 {
28 }
29
30
31 void OBActions::insertPress(Window win, unsigned int button, Time time)
32 {
33 MousePressAction *a = _presses[1];
34 _presses[1] = _presses[0];
35 _presses[0] = a;
36 a->win = win;
37 a->button = button;
38 a->time = time;
39 }
40
41
42 void OBActions::buttonPressHandler(const XButtonEvent &e)
43 {
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);
47
48 if (_button) return; // won't count toward CLICK events
49
50 _button = e.button;
51
52 insertPress(e.window, e.button, e.time);
53 }
54
55
56 void OBActions::buttonReleaseHandler(const XButtonEvent &e)
57 {
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);
61
62 // not for the button we're watching?
63 if (_button && _button != e.button) return;
64
65 _button = 0;
66
67 // find the area of the window
68 XWindowAttributes attr;
69 if (!XGetWindowAttributes(otk::OBDisplay::display, e.window, &attr)) return;
70
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))
74 return;
75
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);
79
80 if (_presses[0]->win == _presses[1]->win &&
81 _presses[0]->button == _presses[1]->button &&
82 e.time - _presses[1]->time < DOUBLECLICKDELAY) {
83
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);
87
88 }
89 }
90
91
92 void OBActions::enter(Window win, unsigned int modifiers)
93 {
94 _enter_win = win;
95
96 (void)modifiers;
97 // XXX: run the ENTER guile hook
98 printf("GUILE: ENTER: win %lx modifiers %u\n", (long)win, modifiers);
99
100 }
101
102
103 void OBActions::leave(unsigned int modifiers)
104 {
105 (void)modifiers;
106 // XXX: run the LEAVE guile hook
107 printf("GUILE: LEAVE: win %lx modifiers %u\n", (long)_enter_win, modifiers);
108
109 _enter_win = 0;
110 }
111
112
113 void OBActions::drag(Window win, otk::Point delta, unsigned int modifiers,
114 unsigned int button, Time time)
115 {
116 (void)win;(void)delta;(void)modifiers;(void)button;(void)time;
117
118 // XXX: some guile shit...
119 }
120
121
122 void OBActions::key(Window win, unsigned int modifiers, unsigned int keycode)
123 {
124 (void)win;(void)modifiers;(void)keycode;
125
126 // XXX: some guile shit...
127 }
128
129
130 }
This page took 0.039159 seconds and 5 git commands to generate.