Changeset 07b59ea for global.c


Ignore:
Timestamp:
Jun 3, 2010, 2:58:30 AM (11 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.7, release-1.8, release-1.9
Children:
e8128c5
Parents:
4dd115f
Message:
Maintain the cursor location with the context stack
File:
1 edited

Legend:

Unmodified
Added
Removed
  • global.c

    r4dd115f r07b59ea  
    3434
    3535  g->context_stack = NULL;
    36   owl_global_push_context(g, OWL_CTX_STARTUP, NULL, NULL);
     36  owl_global_push_context(g, OWL_CTX_STARTUP, NULL, NULL, NULL);
    3737
    3838  g->curmsg=0;
     
    177177}
    178178
    179 static void owl_global_lookup_keymap(owl_global *g) {
    180   owl_context *c = owl_global_get_context(g);
    181   if (!c || !c->keymap)
     179static void owl_global_activate_context(owl_global *g, owl_context *c) {
     180  if (!c)
    182181    return;
    183182
    184   if (!owl_keyhandler_activate(owl_global_get_keyhandler(g), c->keymap)) {
    185     owl_function_error("Unable to activate keymap '%s'", c->keymap);
    186   }
    187 }
    188 
    189 void owl_global_push_context(owl_global *g, int mode, void *data, const char *keymap) {
     183  if (c->keymap) {
     184    if (!owl_keyhandler_activate(owl_global_get_keyhandler(g), c->keymap)) {
     185      owl_function_error("Unable to activate keymap '%s'", c->keymap);
     186    }
     187  }
     188  owl_window_set_cursor(c->cursor);
     189}
     190
     191void owl_global_push_context(owl_global *g, int mode, void *data, const char *keymap, owl_window *cursor) {
    190192  owl_context *c;
    191193  if (!(mode & OWL_CTX_MODE_BITS))
     
    194196  c->mode = mode;
    195197  c->data = data;
     198  c->cursor = cursor ? g_object_ref(cursor) : NULL;
    196199  c->keymap = owl_strdup(keymap);
    197200  g->context_stack = g_list_prepend(g->context_stack, c);
    198   owl_global_lookup_keymap(g);
     201  owl_global_activate_context(g, owl_global_get_context(g));
    199202}
    200203
     
    206209  g->context_stack = g_list_delete_link(g->context_stack,
    207210                                        g->context_stack);
     211  if (c->cursor)
     212    g_object_unref(c->cursor);
    208213  owl_free(c->keymap);
    209214  owl_free(c);
    210   owl_global_lookup_keymap(g);
     215  owl_global_activate_context(g, owl_global_get_context(g));
    211216}
    212217
Note: See TracChangeset for help on using the changeset viewer.