Search
lxdream.org :: lxdream/src/display.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/display.c
changeset 1019:87f191f92f8f
prev1010:a506a2f66180
next1072:d82e04e6d497
author nkeynes
date Wed Jun 03 10:29:16 2009 +0000 (11 years ago)
permissions -rw-r--r--
last change Allow multiple input hooks to be registered for the same key - useful to allow
eg binding the same hotkey for run/stop so that it works as a toggle.
file annotate diff log raw
1.1 --- a/src/display.c Sun Apr 12 02:04:27 2009 +0000
1.2 +++ b/src/display.c Wed Jun 03 10:29:16 2009 +0000
1.3 @@ -251,10 +251,12 @@
1.4 while( *s != NULL ) {
1.5 keymap_entry_t *entryp = input_entry_from_keysym(*s);
1.6 if( entryp != NULL ) {
1.7 - *entryp = g_malloc0(sizeof(struct keymap_entry));
1.8 - (*entryp)->callback = callback;
1.9 - (*entryp)->data = data;
1.10 - (*entryp)->value = value;
1.11 + keymap_entry_t newentry = g_malloc0(sizeof(struct keymap_entry));
1.12 + newentry->next = *entryp;
1.13 + newentry->callback = callback;
1.14 + newentry->data = data;
1.15 + newentry->value = value;
1.16 + *entryp = newentry;
1.17 keys++;
1.18 }
1.19 s++;
1.20 @@ -274,10 +276,17 @@
1.21 gchar **s = strv;
1.22 while( *s != NULL ) {
1.23 keymap_entry_t *entryp = input_entry_from_keysym(*s);
1.24 - if( entryp != NULL && *entryp != NULL && (*entryp)->callback == callback &&
1.25 - (*entryp)->data == data && (*entryp)->value == value ) {
1.26 - g_free( *entryp );
1.27 - *entryp = NULL;
1.28 + if( entryp != NULL ) {
1.29 + while( *entryp != NULL ) {
1.30 + if( (*entryp)->callback == callback &&
1.31 + (*entryp)->data == data && (*entryp)->value == value ) {
1.32 + keymap_entry_t next = (*entryp)->next;
1.33 + g_free( *entryp );
1.34 + *entryp = next;
1.35 + break;
1.36 + }
1.37 + entryp = &(*entryp)->next; // Yes, really
1.38 + }
1.39 }
1.40 s++;
1.41 }
1.42 @@ -334,8 +343,12 @@
1.43 {
1.44 if( display_focused ) {
1.45 keymap_entry_t *entryp = input_entry_from_keycode(driver,keycode);
1.46 - if( entryp != NULL && *entryp != NULL ) {
1.47 - (*entryp)->callback( (*entryp)->data, (*entryp)->value, pressure, TRUE );
1.48 + if( entryp != NULL ) {
1.49 + keymap_entry_t key = *entryp;
1.50 + while( key != NULL ) {
1.51 + key->callback( key->data, key->value, pressure, TRUE );
1.52 + key = key->next;
1.53 + }
1.54 }
1.55 if( driver == NULL ) {
1.56 keymap_entry_t key = keyhooks;
1.57 @@ -358,8 +371,12 @@
1.58 {
1.59 if( display_focused ) {
1.60 keymap_entry_t *entryp = input_entry_from_keycode(driver,keycode);
1.61 - if( entryp != NULL && *entryp != NULL ) {
1.62 - (*entryp)->callback( (*entryp)->data, (*entryp)->value, 0, FALSE );
1.63 + if( entryp != NULL ) {
1.64 + keymap_entry_t key = *entryp;
1.65 + while( key != NULL ) {
1.66 + key->callback( key->data, key->value, 0, FALSE );
1.67 + key = key->next;
1.68 + }
1.69 }
1.70
1.71 if( driver == NULL ) {
.