mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 17:40:40 -05:00
Removed const qualifier from key_handlers[] so we can modify it; use find_handler() in meta_keybindings_set_custom_handler().
This commit is contained in:
parent
b5b37d72a3
commit
986bdac451
@ -106,7 +106,7 @@ static void regrab_key_bindings (MetaDisplay *display);
|
|||||||
|
|
||||||
#define keybind(name, handler, param, flags, stroke, description) \
|
#define keybind(name, handler, param, flags, stroke, description) \
|
||||||
{ #name, handler, param, flags, NULL, NULL },
|
{ #name, handler, param, flags, NULL, NULL },
|
||||||
static const MetaKeyHandler key_handlers[] = {
|
static MetaKeyHandler key_handlers[] = {
|
||||||
#include "all-keybindings.h"
|
#include "all-keybindings.h"
|
||||||
{ NULL, NULL, 0, 0, NULL, NULL }
|
{ NULL, NULL, 0, 0, NULL, NULL }
|
||||||
};
|
};
|
||||||
@ -316,11 +316,11 @@ count_bindings (const MetaKeyPref *prefs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: replace this with a temporary hash */
|
/* FIXME: replace this with a temporary hash */
|
||||||
static const MetaKeyHandler*
|
static MetaKeyHandler*
|
||||||
find_handler (const MetaKeyHandler *handlers,
|
find_handler (MetaKeyHandler *handlers,
|
||||||
const char *name)
|
const char *name)
|
||||||
{
|
{
|
||||||
const MetaKeyHandler *iter;
|
MetaKeyHandler *iter;
|
||||||
|
|
||||||
iter = handlers;
|
iter = handlers;
|
||||||
while (iter->name)
|
while (iter->name)
|
||||||
@ -360,7 +360,7 @@ rebuild_binding_table (MetaDisplay *display,
|
|||||||
|
|
||||||
if (combo && (combo->keysym != None || combo->keycode != 0))
|
if (combo && (combo->keysym != None || combo->keycode != 0))
|
||||||
{
|
{
|
||||||
const MetaKeyHandler *handler = find_handler (key_handlers, prefs[src].name);
|
MetaKeyHandler *handler = find_handler (key_handlers, prefs[src].name);
|
||||||
|
|
||||||
(*bindings_p)[dest].name = prefs[src].name;
|
(*bindings_p)[dest].name = prefs[src].name;
|
||||||
(*bindings_p)[dest].handler = handler;
|
(*bindings_p)[dest].handler = handler;
|
||||||
@ -1163,7 +1163,7 @@ process_event (MetaKeyBinding *bindings,
|
|||||||
*/
|
*/
|
||||||
for (i=0; i<n_bindings; i++)
|
for (i=0; i<n_bindings; i++)
|
||||||
{
|
{
|
||||||
const MetaKeyHandler *handler = bindings[i].handler;
|
MetaKeyHandler *handler = bindings[i].handler;
|
||||||
|
|
||||||
if ((!on_window && handler->flags & BINDING_PER_WINDOW) ||
|
if ((!on_window && handler->flags & BINDING_PER_WINDOW) ||
|
||||||
event->type != KeyPress ||
|
event->type != KeyPress ||
|
||||||
@ -3375,28 +3375,13 @@ meta_keybindings_set_custom_handler (const gchar *name,
|
|||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
MetaKeyHandlerDataFreeFunc free_data)
|
MetaKeyHandlerDataFreeFunc free_data)
|
||||||
{
|
{
|
||||||
MetaKeyHandler *key_handler = NULL;
|
MetaKeyHandler *key_handler = find_handler (key_handlers, name);
|
||||||
guint i;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* FIXME -- the bindings should be in a hashtable or at least sorted somehow.
|
|
||||||
*/
|
|
||||||
for (i = 0; i < G_N_ELEMENTS (key_handlers); ++i)
|
|
||||||
{
|
|
||||||
if (!g_strcmp0 (key_handlers[i].name, name))
|
|
||||||
{
|
|
||||||
key_handler = (MetaKeyHandler*)&key_handlers[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!key_handler)
|
if (!key_handler)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (key_handler->user_data_free_func && key_handler->user_data)
|
if (key_handler->user_data_free_func && key_handler->user_data)
|
||||||
{
|
|
||||||
key_handler->user_data_free_func (key_handler->user_data);
|
key_handler->user_data_free_func (key_handler->user_data);
|
||||||
}
|
|
||||||
|
|
||||||
key_handler->func = handler;
|
key_handler->func = handler;
|
||||||
key_handler->user_data = user_data;
|
key_handler->user_data = user_data;
|
||||||
|
@ -48,7 +48,7 @@ struct _MetaKeyBinding
|
|||||||
KeyCode keycode;
|
KeyCode keycode;
|
||||||
unsigned int mask;
|
unsigned int mask;
|
||||||
MetaVirtualModifier modifiers;
|
MetaVirtualModifier modifiers;
|
||||||
const MetaKeyHandler *handler;
|
MetaKeyHandler *handler;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user