]> Dogcows Code - chaz/openbox/blob - src/actions.hh
new mouse button code is seeming to work. you can move windows
[chaz/openbox] / src / actions.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
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 "widget.hh"
10 #include "otk/point.hh"
11 #include "otk/rect.hh"
12 #include "otk/eventhandler.hh"
13
14 extern "C" {
15 #include <X11/Xlib.h>
16 #include <Python.h>
17 }
18
19 #include <map>
20
21 namespace ob {
22
23 //! The action interface for user-available actions
24 /*!
25 When these actions are fired, hooks to the guile engine are fired so that
26 guile code is run.
27 */
28 class OBActions : public otk::OtkEventHandler {
29 public:
30 // update the same enum in openbox.i when making changes to this
31 enum ActionType {
32 Action_EnterWindow,
33 Action_LeaveWindow,
34 Action_NewWindow,
35 Action_CloseWindow,
36 NUM_ACTIONS
37 };
38
39 struct ButtonReleaseAction {
40 Window win;
41 unsigned int button;
42 Time time;
43 ButtonReleaseAction() { win = 0; button = 0; time = 0; }
44 };
45
46 struct ButtonPressAction {
47 unsigned int button;
48 otk::Point pos;
49 otk::Rect clientarea;
50 ButtonPressAction() { button = 0; }
51 };
52
53 private:
54 // milliseconds XXX: config option
55 static const unsigned int DOUBLECLICKDELAY;
56 static const int BUTTONS = 5;
57
58 //! The mouse button currently being watched from a press for a CLICK
59 unsigned int _button;
60 //! The last button release processed for CLICKs
61 ButtonReleaseAction _release;
62 //! The point where the mouse was when each mouse button was pressed
63 /*!
64 Used for motion events as the starting position.
65 */
66 ButtonPressAction *_posqueue[BUTTONS];
67 //! The delta x/y of the last motion sequence
68 int _dx, _dy;
69
70
71 void insertPress(const XButtonEvent &e);
72 void removePress(const XButtonEvent &e);
73
74 typedef std::multimap<ActionType, PyObject*> CallbackMap;
75 typedef std::pair<ActionType, PyObject*> CallbackMapPair;
76 CallbackMap _callbacks;
77
78 void doCallback(ActionType action, Window window, OBWidget::WidgetType type,
79 unsigned int state, unsigned int button,
80 int xroot, int yroot, Time time);
81
82 public:
83 //! Constructs an OBActions object
84 OBActions();
85 //! Destroys the OBActions object
86 virtual ~OBActions();
87
88 virtual void buttonPressHandler(const XButtonEvent &e);
89 virtual void buttonReleaseHandler(const XButtonEvent &e);
90
91 virtual void enterHandler(const XCrossingEvent &e);
92 virtual void leaveHandler(const XCrossingEvent &e);
93
94 virtual void keyPressHandler(const XKeyEvent &e);
95
96 virtual void motionHandler(const XMotionEvent &e);
97
98 virtual void mapRequestHandler(const XMapRequestEvent &e);
99 virtual void unmapHandler(const XUnmapEvent &e);
100 virtual void destroyHandler(const XDestroyWindowEvent &e);
101
102
103 //! Add a callback funtion to the back of the hook list
104 /*!
105 Registering functions for KeyPress events is pointless. Use
106 OBSCript::bindKey instead to do this.
107 */
108 bool registerCallback(ActionType action, PyObject *func, bool atfront);
109
110 //! Remove a callback function from the hook list
111 bool unregisterCallback(ActionType action, PyObject *func);
112
113 //! Remove all callback functions from the hook list
114 bool unregisterAllCallbacks(ActionType action);
115 };
116
117 }
118
119 #endif // __actions_hh
This page took 0.036982 seconds and 4 git commands to generate.