]> icculus.org git repositories - dana/openbox.git/blob - src/actions.cc
actions class can sorta handle mouse enter/leave and press/release events
[dana/openbox.git] / 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;
14
15 OBActions::OBActions()
16   : _button(0), _enter_win(0)
17 {
18   _presses[0] = new MousePressAction();
19   _presses[1] = new MousePressAction();
20   _presses[2] = new MousePressAction();
21
22   // XXX: load a configuration out of somewhere
23
24 }
25
26
27 OBActions::~OBActions()
28 {
29 }
30
31
32 void OBActions::insertPress(Window win, unsigned int button, Time time)
33 {
34   MousePressAction *a = _presses[1];
35   _presses[1] = _presses[0];
36   _presses[0] = a;
37   a->win = win;
38   a->button = button;
39   a->time = time;
40 }
41
42
43 void OBActions::bpress(Window win, unsigned int modifiers, unsigned int button,
44                        Time time)
45 {
46   (void)modifiers;
47   // XXX: run the PRESS guile hook
48   printf("GUILE: PRESS: win %lx modifiers %ux button %ud time %lx",
49          (long)win, modifiers, button, time);
50     
51   if (_button) return; // won't count toward CLICK events
52
53   _button = button;
54
55   insertPress(win, button, time);
56 }
57   
58
59 void OBActions::brelease(Window win, const otk::Rect &area,
60                          const otk::Point &mpos, 
61                          unsigned int modifiers, unsigned int button,
62                          Time time)
63 {
64   (void)modifiers;
65   // XXX: run the RELEASE guile hook
66   printf("GUILE: RELEASE: win %lx modifiers %ux button %ud time %lx",
67          (long)win, modifiers, button, time);
68
69   if (_button && _button != button) return; // not for the button we're watchin
70
71   _button = 0;
72
73   if (!area.contains(mpos)) return; // not on the window any more
74
75   // XXX: run the CLICK guile hook
76   printf("GUILE: CLICK: win %lx modifiers %ux button %ud time %lx",
77          (long)win, modifiers, button, time);
78
79   if (_presses[0]->win == _presses[1]->win &&
80       _presses[0]->button == _presses[1]->button &&
81       time - _presses[1]->time < DOUBLECLICKDELAY) {
82
83     // XXX: run the DOUBLECLICK guile hook
84     printf("GUILE: DOUBLECLICK: win %lx modifiers %ux button %ud time %lx",
85            (long)win, modifiers, button, time);
86
87   }
88 }
89
90
91 void OBActions::enter(Window win, unsigned int modifiers)
92 {
93   _enter_win = win;
94
95   (void)modifiers;
96   // XXX: run the ENTER guile hook
97   printf("GUILE: ENTER: win %lx modifiers %ux", (long)win, modifiers);
98
99 }
100
101
102 void OBActions::leave(unsigned int modifiers)
103 {
104   (void)modifiers;
105   // XXX: run the LEAVE guile hook
106   printf("GUILE: LEAVE: win %lx modifiers %ux", (long)_enter_win, modifiers);
107
108   _enter_win = 0;
109 }
110
111
112 void OBActions::drag(Window win, otk::Point delta, unsigned int modifiers,
113                      unsigned int button, Time time)
114 {
115   (void)win;(void)delta;(void)modifiers;(void)button;(void)time;
116
117   // XXX: some guile shit...
118 }
119
120
121 void OBActions::key(Window win, unsigned int modifiers, unsigned int keycode)
122 {
123   (void)win;(void)modifiers;(void)keycode;
124
125   // XXX: some guile shit...
126 }
127
128
129 }