mirror of
https://github.com/awesomeWM/awesome
synced 2024-11-17 07:47:41 +01:00
5a07ee4946
This patch sorts keybindings in arrays by keycode or keysym to speed up look up using binary searches. This is a preliminary work to enable more powerful keybindings stuff, where keybindings can be cascaded or why not, attached to specific clients. Interstingly enough, this patch saves 100ko of initial memory (Heap) usage here. The underlying idea is that we should be able to define keybindings_t as trees of keybindings_t which would then define key sequences. The OO approach kind of make sense in fact, since you create a base keybinding (e.g. reacting on Mod4-w) and then you will probably (with appropriate apis) be able to populate new submaps from that point more or less dynamically. And if you have two keybindings on Mod4-w, then adding them will replace the previous one. This means that you can fake per-client bindings with e.g.: k_default = keybindings.new({"Mod4"}, "w", something); k_mplayer = keybindings.new({"Mod4"}, "w", something_else); k_default:add() and in your focus hook: if /* code for testing if it's mplayer */ then k_mplayer:add() else k_default:add() end This would not work before, it does now. It will take way more sense with submaps of course. Signed-off-by: Pierre Habouzit <madcoder@debian.org>
38 lines
1.3 KiB
C
38 lines
1.3 KiB
C
/*
|
|
* keybinding.h - Keybinding helpers
|
|
*
|
|
* Copyright © 2008 Pierre Habouzit <madcoder@debian.org>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
*
|
|
*/
|
|
|
|
#ifndef AWESOME_KEYBINDING_H
|
|
#define AWESOME_KEYBINDING_H
|
|
|
|
#include "structs.h"
|
|
|
|
void keybinding_delete(keybinding_t **);
|
|
DO_RCNT(keybinding_t, keybinding, keybinding_delete)
|
|
ARRAY_FUNCS(keybinding_t *, keybinding, keybinding_unref)
|
|
|
|
void keybinding_idx_wipe(keybinding_idx_t *);
|
|
|
|
void keybinding_register_root(keybinding_t *);
|
|
void keybinding_unregiste_rootr(keybinding_t **);
|
|
keybinding_t *keybinding_find(const keybinding_idx_t *,
|
|
const xcb_key_press_event_t *);
|
|
|
|
#endif
|