commit e5a368f0575952b09b8773af228023dcafb20edc
parent 29f85de9ec6395a89720608c97358ddea2d139c5
Author: Kyle Milz <kmilz@ucalgary.ca>
Date: Sun, 14 Oct 2012 20:10:15 -0600
remove one more home rolled link list
replace with generic eina_list.
Diffstat:
5 files changed, 12 insertions(+), 31 deletions(-)
diff --git a/src/callbacks.c b/src/callbacks.c
@@ -294,14 +294,14 @@ webview_mousewheel_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
Eina_Bool
process_keypress(void *event_info, Window_Data *wd)
{
- KeyList *walk;
- Key key;
+ Key key, *inc_key;
App_Data *ad = wd->app;
Evas_Event_Key_Down *ev = event_info;
+ Eina_List *l;
- walk = ad->keylistroot;
- while (walk != NULL) {
- key = walk->Element;
+ EINA_LIST_FOREACH(ad->keylistroot, l, inc_key) {
+ /* avoid lots of dereferences */
+ key = *inc_key;
if ((key.mask == 0 || evas_key_modifier_is_set(ev->modifiers, key.mask))
&& (key.modkey == wd->current_modkey
|| (!key.modkey && !wd->current_modkey)
@@ -309,12 +309,10 @@ process_keypress(void *event_info, Window_Data *wd)
&& !strcmp(key.key, ev->key)
&& key.func)
if (key.func(&key.arg, wd)) {
- // printf("process_keypress() function for mask = %s modkey = %c key = %s called.\n", key.mask, ad->current_modkey, key.key);
wd->current_modkey = wd->count = 0;
update_state(wd);
return EINA_TRUE;
}
- walk = walk->next;
}
return EINA_FALSE;
}
diff --git a/src/main.c b/src/main.c
@@ -386,9 +386,9 @@ elm_main(int argc, char *argv[])
// evas_object_del(wd->win);
}
- /* need to free ->keyslistroot here too */
eina_list_free(ad->windows);
eina_list_free(ad->downloads);
+ eina_list_free(ad->keylistroot);
free(ad->modkeys);
free(ad);
diff --git a/src/utilities.c b/src/utilities.c
@@ -100,31 +100,19 @@ void save_command_history(Eina_Stringshare *line, Window_Data *wd)
wd->commandhistory = eina_list_append(wd->commandhistory, c);
}
-KeyList *
+Eina_List *
make_keyslist(void)
{
int i;
- KeyList *ptr, *current;
- KeyList *keylistroot = NULL;
+ Eina_List *keylistroot = NULL;
- ptr = NULL;
- current = NULL;
i = 0;
while ( keys[i].key != 0 ) {
- current = malloc(sizeof(KeyList));
- if (current == NULL) {
- printf("Not enough memory\n");
- exit(-1);
- }
- current->Element = keys[i];
- current->next = NULL;
- if (keylistroot == NULL) keylistroot = current;
- if (ptr != NULL) ptr->next = current;
- ptr = current;
+ keylistroot = eina_list_append(keylistroot, &keys[i]);
i++;
}
- // printf("make_keylist() processed %i keys.\n", i);
+ printf("make_keylist() processed %i keys.\n", i);
return keylistroot;
}
diff --git a/src/utilities.h b/src/utilities.h
@@ -13,7 +13,7 @@
char *strdup_printf(const char *, ...);
void save_command_history(const char*, Window_Data*);
// Eina_Bool process_save_qmark(const char *bm, WebKitWebView *webview);
-KeyList *make_keyslist(void);
+Eina_List *make_keyslist(void);
Eina_Bool parse_colour(char *color);
Eina_Bool process_line(const char *line, Window_Data*);
Eina_Bool process_line_arg(const Arg *, void *);
diff --git a/src/viking.h b/src/viking.h
@@ -115,11 +115,6 @@ typedef struct {
} Key;
typedef struct {
- void *next;
- Key Element;
-} KeyList;
-
-typedef struct {
const char *mask;
const char *modkey;
unsigned int button;
@@ -197,8 +192,8 @@ typedef struct
{
Eina_List *windows;
Eina_List *downloads;
+ Eina_List *keylistroot;
- KeyList *keylistroot;
float zoomstep;
char *modkeys;