]> icculus.org git repositories - mikachu/openbox.git/blob - src/actions.cc
enter/leave actions work!
[mikachu/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 = 300;
14
15 OBActions::OBActions()
16   : _button(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   OtkEventHandler::buttonPressHandler(e);
32   
33   // XXX: run the PRESS guile hook
34   printf("GUILE: PRESS: win %lx modifiers %u button %u time %lx\n",
35          (long)e.window, e.state, e.button, e.time);
36     
37   if (_button) return; // won't count toward CLICK events
38
39   _button = e.button;
40 }
41   
42
43 void OBActions::buttonReleaseHandler(const XButtonEvent &e)
44 {
45   OtkEventHandler::buttonReleaseHandler(e);
46   
47   // XXX: run the RELEASE guile hook
48   printf("GUILE: RELEASE: win %lx modifiers %u button %u time %lx\n",
49          (long)e.window, e.state, e.button, e.time);
50
51   // not for the button we're watching?
52   if (_button != e.button) return;
53
54   _button = 0;
55
56   // find the area of the window
57   XWindowAttributes attr;
58   if (!XGetWindowAttributes(otk::OBDisplay::display, e.window, &attr)) return;
59
60   // if not on the window any more, it isnt a CLICK
61   if (!(e.same_screen && e.x >= 0 && e.y >= 0 &&
62         e.x < attr.width && e.y < attr.height))
63     return;
64
65   // XXX: run the CLICK guile hook
66   printf("GUILE: CLICK: win %lx modifiers %u button %u time %lx\n",
67          (long)e.window, e.state, e.button, e.time);
68
69   if (e.time - _release.time < DOUBLECLICKDELAY &&
70       _release.win == e.window && _release.button == e.button) {
71
72     // XXX: run the DOUBLECLICK guile hook
73     printf("GUILE: DOUBLECLICK: win %lx modifiers %u button %u time %lx\n",
74            (long)e.window, e.state, e.button, e.time);
75
76     // reset so you cant triple click for 2 doubleclicks
77     _release.win = 0;
78     _release.button = 0;
79     _release.time = 0;
80   } else {
81     // save the button release, might be part of a double click
82     _release.win = e.window;
83     _release.button = e.button;
84     _release.time = e.time;
85   }
86 }
87
88
89 void OBActions::enterHandler(const XCrossingEvent &e)
90 {
91   OtkEventHandler::enterHandler(e);
92   
93   // XXX: run the ENTER guile hook
94   printf("GUILE: ENTER: win %lx modifiers %u\n", (long)e.window, e.state);
95 }
96
97
98 void OBActions::leaveHandler(const XCrossingEvent &e)
99 {
100   OtkEventHandler::leaveHandler(e);
101
102   // XXX: run the LEAVE guile hook
103   printf("GUILE: LEAVE: win %lx modifiers %u\n", (long)e.window, e.state);
104 }
105
106
107 void OBActions::drag(Window win, otk::Point delta, unsigned int modifiers,
108                      unsigned int button, Time time)
109 {
110   (void)win;(void)delta;(void)modifiers;(void)button;(void)time;
111
112   // XXX: some guile shit...
113 }
114
115
116 void OBActions::key(Window win, unsigned int modifiers, unsigned int keycode)
117 {
118   (void)win;(void)modifiers;(void)keycode;
119
120   // XXX: some guile shit...
121 }
122
123
124 }