Changeset 7a6e6c7 for popwin.c


Ignore:
Timestamp:
Jun 1, 2010, 1:27:14 AM (11 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.7, release-1.8, release-1.9
Children:
05ca0d8
Parents:
7a70e26
Message:
Use signals for redraw and resize
File:
1 edited

Legend:

Unmodified
Added
Removed
  • popwin.c

    r053f751 r7a6e6c7  
    1111  pw->border = owl_window_new(NULL);
    1212  pw->content = owl_window_new(pw->border);
    13   owl_window_set_redraw_cb(pw->border, owl_popwin_draw_border, pw, 0);
    14   owl_window_set_size_cb(pw->border, owl_popwin_size_border, 0, 0);
    15   owl_window_set_size_cb(pw->content, owl_popwin_size_content, 0, 0);
     13  g_signal_connect(pw->border, "redraw", G_CALLBACK(owl_popwin_draw_border), 0);
     14  pw->screen_resize_id = g_signal_connect_object(owl_window_get_screen(), "resized", G_CALLBACK(owl_popwin_size_border), pw->border, 0);
     15  g_signal_connect_object(pw->border, "resized", G_CALLBACK(owl_popwin_size_content), pw->content, 0);
     16
     17  /* bootstrap sizing */
     18  owl_popwin_size_border(owl_window_get_screen(), pw->border);
     19
    1620  owl_window_show_all(pw->border);
    1721
     
    2024}
    2125
    22 void owl_popwin_size_border(owl_window *border, void *user_data)
     26void owl_popwin_size_border(owl_window *parent, void *user_data)
    2327{
    2428  int lines, cols, startline, startcol;
    2529  int glines, gcols;
    26   owl_window *parent = owl_window_get_parent(border);
     30  owl_window *border = user_data;
    2731
    2832  owl_window_get_position(parent, &glines, &gcols, 0, 0);
     
    3640}
    3741
    38 void owl_popwin_size_content(owl_window *content, void *user_data)
     42void owl_popwin_size_content(owl_window *parent, void *user_data)
    3943{
    4044  int lines, cols;
    41   owl_window *parent = owl_window_get_parent(content);
     45  owl_window *content = user_data;
    4246  owl_window_get_position(parent, &lines, &cols, 0, 0);
    4347  owl_window_set_position(content, lines-2, cols-2, 1, 1);
     
    6872  g_object_unref(pw->border);
    6973  g_object_unref(pw->content);
     74
     75  /* See comment on g_signal_connect_object; it only prevents the closure from
     76   * being invoked. The signal handler itself still gets leaked. The other
     77   * signal is okay, since we delete both at the same time. */
     78  if (g_signal_handler_is_connected(owl_window_get_screen(), pw->screen_resize_id))
     79      g_signal_handler_disconnect(owl_window_get_screen(), pw->screen_resize_id);
     80
    7081  pw->border = 0;
    7182  pw->content = 0;
Note: See TracChangeset for help on using the changeset viewer.