]> icculus.org git repositories - dana/openbox.git/blob - src/actions.hh
can resize now too. compress motion events.
[dana/openbox.git] / src / actions.hh
1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2 #ifndef __actions_hh
3 #define __actions_hh
4
5 /*! @file actions.hh
6   @brief The action interface for user-available actions
7 */
8
9 #include "otk/point.hh"
10 #include "otk/rect.hh"
11 #include "otk/eventhandler.hh"
12
13 extern "C" {
14 #include <X11/Xlib.h>
15 }
16
17 namespace ob {
18
19 //! The action interface for user-available actions
20 /*!
21   When these actions are fired, hooks to the guile engine are fired so that
22   guile code is run.
23 */
24 class OBActions : public otk::OtkEventHandler {
25 public:
26   struct ButtonReleaseAction {
27     Window win;
28     unsigned int button;
29     Time time;
30     ButtonReleaseAction() { win = 0; button = 0; time = 0; }
31   };
32
33   struct ButtonPressAction {
34     unsigned int button;
35     otk::Point pos;
36     otk::Rect clientarea;
37     ButtonPressAction() { button = 0; }
38   };
39   
40 private:
41   // milliseconds XXX: config option
42   static const unsigned int DOUBLECLICKDELAY;
43   static const int BUTTONS = 5;
44   
45   //! The mouse button currently being watched from a press for a CLICK
46   unsigned int _button;
47   //! The last button release processed for CLICKs
48   ButtonReleaseAction _release;
49   //! The point where the mouse was when each mouse button was pressed
50   /*!
51     Used for motion events as the starting position.
52   */
53   ButtonPressAction *_posqueue[BUTTONS];
54   //! The delta x/y of the last motion sequence
55   int _dx, _dy;
56
57   //! Insert a button/position in the _posqueue
58   void insertPress(const XButtonEvent &e);
59   //! Remove a button/position from the _posqueue
60   void removePress(const XButtonEvent &e);
61   
62 public:
63   //! Constructs an OBActions object
64   OBActions();
65   //! Destroys the OBActions object
66   virtual ~OBActions();
67
68   virtual void buttonPressHandler(const XButtonEvent &e);
69   virtual void buttonReleaseHandler(const XButtonEvent &e);
70   
71   virtual void enterHandler(const XCrossingEvent &e);
72   virtual void leaveHandler(const XCrossingEvent &e);
73
74   virtual void keyPressHandler(const XKeyEvent &e);
75
76   virtual void motionHandler(const XMotionEvent &e);
77 };
78
79 }
80
81 #endif // __actions_hh