1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2 // Input.hh for Blackbox - an X11 Window manager
3 // Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
4 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
6 // Permission is hereby granted, free of charge, to any person obtaining a
7 // copy of this software and associated documentation files (the "Software"),
8 // to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 // and/or sell copies of the Software, and to permit persons to whom the
11 // Software is furnished to do so, subject to the following conditions:
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 // DEALINGS IN THE SOFTWARE.
29 #include <X11/Xutil.h>
48 WindowTitleDoublePress
,
81 BeginResizeRelative
, // picks a corner based on the mouse cursor's position
96 // for keyboard events, this is applied to the focused window.
97 // for mouse events, this is applied to the window that was clicked on.
100 KeyBinding(unsigned int button
, unsigned int state
, Action action
) {
102 assert(action
>= 0 && action
< NUM_ACTIONS
);
103 this->button
= button
;
105 this->action
= action
;
109 struct MouseBinding
: public KeyBinding
{
112 MouseBinding(unsigned int button
, unsigned int state
, MouseEvent event
,
113 Action action
) : KeyBinding(button
, state
, action
) {
114 assert(event
>= 0 && event
< NUM_MOUSEEVENTS
);
119 typedef std::list
<MouseBinding
> MouseBindingList
;
120 typedef std::list
<KeyBinding
> KeyBindingList
;
126 MouseBindingList _mousebind
;
127 KeyBindingList _keybind
;
129 void doAction(BlackboxWindow
*window
, Action action
) const;
135 void add(unsigned int button
, unsigned int state
, MouseEvent event
,
137 void remove(unsigned int button
, unsigned int state
, MouseEvent event
,
139 void add(unsigned int button
, unsigned int state
, Action action
);
140 void remove(unsigned int button
, unsigned int state
, Action action
);
142 // execute a keyboard binding
143 // returns false if the specified binding doesnt exist
144 bool doAction(BlackboxWindow
*window
, unsigned int keycode
,
145 unsigned int state
) const;
146 // execute a mouse binding
147 // returns false if the specified binding doesnt exist
148 bool doAction(BlackboxWindow
*window
, unsigned int keycode
,
149 unsigned int state
, MouseEvent eventtype
) const;
151 // determine if a keyboard binding exists
152 bool hasAction(unsigned int keycode
, unsigned int state
) const;
153 // determine if a mouse binding exists
154 bool hasAction(unsigned int button
, unsigned int state
,
155 MouseEvent eventtype
) const;
157 const MouseBindingList
&getMouseBindings(void) { return _mousebind
; }
158 const KeyBindingList
&getKeyBindings(void) { return _keybind
; }