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
,
79 BeginResizeRelative
, // picks a corner based on the mouse cursor's position
94 // for keyboard events, this is applied to the focused window.
95 // for mouse events, this is applied to the window that was clicked on.
98 KeyBinding(unsigned int button
, unsigned int state
, Action action
) {
100 assert(action
>= 0 && action
< NUM_ACTIONS
);
101 this->button
= button
;
103 this->action
= action
;
107 struct MouseBinding
: public KeyBinding
{
110 MouseBinding(unsigned int button
, unsigned int state
, MouseEvent event
,
111 Action action
) : KeyBinding(button
, state
, action
) {
112 assert(event
>= 0 && event
< NUM_MOUSEEVENTS
);
117 typedef std::list
<MouseBinding
> MouseBindingList
;
118 typedef std::list
<KeyBinding
> KeyBindingList
;
124 MouseBindingList _mousebind
;
125 KeyBindingList _keybind
;
127 void doAction(BlackboxWindow
*window
, Action action
) const;
133 void add(unsigned int button
, unsigned int state
, MouseEvent event
,
135 void remove(unsigned int button
, unsigned int state
, MouseEvent event
,
137 void add(unsigned int button
, unsigned int state
, Action action
);
138 void remove(unsigned int button
, unsigned int state
, Action action
);
140 // execute a keyboard binding
141 // returns false if the specified binding doesnt exist
142 bool doAction(BlackboxWindow
*window
, unsigned int keycode
,
143 unsigned int state
) const;
144 // execute a mouse binding
145 // returns false if the specified binding doesnt exist
146 bool doAction(BlackboxWindow
*window
, unsigned int keycode
,
147 unsigned int state
, MouseEvent eventtype
) const;
149 // determine if a keyboard binding exists
150 bool hasAction(unsigned int keycode
, unsigned int state
) const;
151 // determine if a mouse binding exists
152 bool hasAction(unsigned int button
, unsigned int state
,
153 MouseEvent eventtype
) const;
155 const MouseBindingList
&getMouseBindings(void) { return _mousebind
; }
156 const KeyBindingList
&getKeyBindings(void) { return _keybind
; }