Changeset 03ca005


Ignore:
Timestamp:
Sep 18, 2010, 5:07:39 PM (10 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.7, release-1.8, release-1.9
Children:
61c1f19
Parents:
b3b1b05
git-author:
David Benjamin <davidben@mit.edu> (08/01/10 13:50:19)
git-committer:
David Benjamin <davidben@mit.edu> (09/18/10 17:07:39)
Message:
Create a new owl_popwin every time instead of rewiring the old one

Constantly rewiring things is weird.
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    r4cf7b1b r03ca005  
    12371237  owl_viewwin *v;
    12381238
    1239   pw=owl_global_get_popwin(&g);
    12401239  v=owl_global_get_viewwin(&g);
    12411240
    1242   if (owl_popwin_up(pw) != 0) {
     1241  if (owl_global_get_popwin(&g)) {
    12431242    owl_function_error("Popwin already in use.");
    12441243    return;
    12451244  }
     1245  pw = owl_popwin_new();
     1246  owl_global_set_popwin(&g, pw);
     1247  owl_popwin_up(pw);
    12461248  owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless", NULL);
    12471249  owl_viewwin_init_text(v, owl_popwin_get_content(pw), text);
     
    12531255  owl_viewwin *v;
    12541256
    1255   pw=owl_global_get_popwin(&g);
    12561257  v=owl_global_get_viewwin(&g);
    12571258
    1258   if (owl_popwin_up(pw) != 0) {
     1259  if (owl_global_get_popwin(&g)) {
    12591260    owl_function_error("Popwin already in use.");
    12601261    return;
    12611262  }
     1263  pw = owl_popwin_new();
     1264  owl_global_set_popwin(&g, pw);
     1265  owl_popwin_up(pw);
    12621266  owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless", NULL);
    12631267  owl_viewwin_init_fmtext(v, owl_popwin_get_content(pw), fm);
  • global.c

    r5b68c05 r03ca005  
    4848  g->rightshift=0;
    4949
     50  g->pw = NULL;
    5051  g->tw = NULL;
    5152
     
    126127  /* Create the widgets */
    127128  owl_mainwin_init(&(g->mw), g->mainpanel.recwin);
    128   owl_popwin_init(&(g->pw));
    129129  owl_msgwin_init(&(g->msgwin), g->mainpanel.msgwin);
    130130  owl_sepbar_init(g->mainpanel.sepwin);
     
    255255
    256256owl_popwin *owl_global_get_popwin(owl_global *g) {
    257   return(&(g->pw));
     257  return g->pw;
     258}
     259
     260void owl_global_set_popwin(owl_global *g, owl_popwin *pw) {
     261  g->pw = pw;
    258262}
    259263
  • owl.h

    rb3b1b05 r03ca005  
    410410  gulong sig_redraw_id;
    411411  gulong sig_resize_id;
    412   int active;
    413412} owl_popwin;
    414413 
     
    563562typedef struct _owl_global {
    564563  owl_mainwin mw;
    565   owl_popwin pw;
     564  owl_popwin *pw;
    566565  owl_msgwin msgwin;
    567566  owl_history cmdhist;          /* command history */
  • popexec.c

    r4cf7b1b r03ca005  
    1717  pid_t pid;
    1818
     19  if (owl_global_get_popwin(&g)) {
     20    owl_function_error("Popwin already in use.");
     21    return NULL;
     22  }
     23
    1924  pe = owl_malloc(sizeof(owl_popexec));
    2025  if (!pe) return NULL;
     
    2328  pe->refcount=0;
    2429
    25   pw=owl_global_get_popwin(&g);
    2630  pe->vwin=v=owl_global_get_viewwin(&g);
     31  pw = owl_popwin_new();
     32  owl_global_set_popwin(&g, pw);
     33  owl_popwin_up(pw);
    2734
    28   if (owl_popwin_up(pw) != 0) {
    29     owl_function_error("Popwin already in use.");
    30     return NULL;
    31   }
    3235  owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless", NULL);
    3336  owl_viewwin_init_text(v, owl_popwin_get_content(pw), "");
  • popwin.c

    rb3b1b05 r03ca005  
    11#include "owl.h"
    22
    3 int owl_popwin_init(owl_popwin *pw)
     3owl_popwin *owl_popwin_new(void)
    44{
    5   pw->active=0;
    6   return(0);
    7 }
     5  owl_popwin *pw = owl_malloc(sizeof(owl_popwin));
     6  memset(pw, 0, sizeof(*pw));
    87
    9 int owl_popwin_up(owl_popwin *pw)
    10 {
    11   if (pw->active)
    12     return 1;
    138  pw->border = owl_window_new(NULL);
    149  pw->content = owl_window_new(pw->border);
     
    2318  owl_popwin_size_border(owl_window_get_screen(), pw->border);
    2419
    25   owl_window_show_all(pw->border);
     20  owl_window_show(pw->content);
    2621
    27   pw->active=1;
    28   return(0);
     22  return pw;
     23}
     24
     25int owl_popwin_up(owl_popwin *pw)
     26{
     27  if (owl_window_is_shown(pw->border))
     28    return 1;
     29  owl_window_show(pw->border);
     30  return 0;
    2931}
    3032
     
    7476int owl_popwin_close(owl_popwin *pw)
    7577{
    76   if (!pw->active)
     78  if (!owl_window_is_shown(pw->border))
    7779    return 1;
     80  owl_window_hide(pw->border);
     81  return 0;
     82}
     83
     84void owl_popwin_delete(owl_popwin *pw)
     85{
     86  owl_popwin_close(pw);
     87
     88  /* Remove everything that references us. */
    7889  g_signal_handler_disconnect(pw->border, pw->sig_resize_id);
    7990  g_signal_handler_disconnect(pw->border, pw->sig_redraw_id);
     
    8293  g_object_unref(pw->content);
    8394
    84   pw->border = 0;
    85   pw->content = 0;
    86   pw->active=0;
    87   return(0);
     95  owl_free(pw);
    8896}
    8997
    9098int owl_popwin_is_active(const owl_popwin *pw)
    9199{
    92   return pw->active;
     100  return owl_window_is_shown(pw->border);
    93101}
    94102
Note: See TracChangeset for help on using the changeset viewer.