1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
6 @brief The action interface for user-available actions
10 #include "otk/point.hh"
11 #include "otk/rect.hh"
12 #include "otk/eventhandler.hh"
23 //! The action interface for user-available actions
25 When these actions are fired, hooks to the guile engine are fired so that
28 class OBActions
: public otk::OtkEventHandler
{
30 // update the same enum in openbox.i when making changes to this
39 struct ButtonReleaseAction
{
43 ButtonReleaseAction() { win
= 0; button
= 0; time
= 0; }
46 struct ButtonPressAction
{
50 ButtonPressAction() { button
= 0; }
54 // milliseconds XXX: config option
55 static const unsigned int DOUBLECLICKDELAY
;
56 static const int BUTTONS
= 5;
58 //! The mouse button currently being watched from a press for a CLICK
60 //! The last button release processed for CLICKs
61 ButtonReleaseAction _release
;
62 //! The point where the mouse was when each mouse button was pressed
64 Used for motion events as the starting position.
66 ButtonPressAction
*_posqueue
[BUTTONS
];
69 void insertPress(const XButtonEvent
&e
);
70 void removePress(const XButtonEvent
&e
);
72 typedef std::multimap
<ActionType
, PyObject
*> CallbackMap
;
73 typedef std::pair
<ActionType
, PyObject
*> CallbackMapPair
;
74 CallbackMap _callbacks
;
76 void doCallback(ActionType action
, Window window
, OBWidget::WidgetType type
,
77 unsigned int state
, unsigned int button
,
78 int xroot
, int yroot
, Time time
);
81 //! Constructs an OBActions object
83 //! Destroys the OBActions object
86 virtual void buttonPressHandler(const XButtonEvent
&e
);
87 virtual void buttonReleaseHandler(const XButtonEvent
&e
);
89 virtual void enterHandler(const XCrossingEvent
&e
);
90 virtual void leaveHandler(const XCrossingEvent
&e
);
92 virtual void keyPressHandler(const XKeyEvent
&e
);
94 virtual void motionHandler(const XMotionEvent
&e
);
96 virtual void mapRequestHandler(const XMapRequestEvent
&e
);
97 virtual void unmapHandler(const XUnmapEvent
&e
);
98 virtual void destroyHandler(const XDestroyWindowEvent
&e
);
100 //! Add a callback funtion to the back of the hook list
102 Registering functions for KeyPress events is pointless. Use
103 OBSCript::bindKey instead to do this.
105 bool registerCallback(ActionType action
, PyObject
*func
, bool atfront
);
107 //! Remove a callback function from the hook list
108 bool unregisterCallback(ActionType action
, PyObject
*func
);
110 //! Remove all callback functions from the hook list
111 bool unregisterAllCallbacks(ActionType action
);
116 #endif // __actions_hh