From f04882c76d0d23a35942e736e89ef19268f541b5 Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Sat, 7 Feb 2009 20:00:26 -0500 Subject: Copyright for 2009 --- src/window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/window.c') diff --git a/src/window.c b/src/window.c index 5b15878..4754a98 100644 --- a/src/window.c +++ b/src/window.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2008 +/* Copyright (c) 2008, 2009 * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de) * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de) * Micah Cowan (micah@cowan.name) -- cgit v1.2.1 From e8ab383af46b75a2b14d446fc6305912c773a7e6 Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Thu, 23 Jul 2009 19:26:24 +0200 Subject: - change status message code so that Flush is no longer called - add progress parameter to flush - try to get the window's wait status when EOF is reached --- src/window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/window.c') diff --git a/src/window.c b/src/window.c index 4754a98..fb271d2 100644 --- a/src/window.c +++ b/src/window.c @@ -2099,7 +2099,7 @@ int len; D_readev.condpos = D_readev.condneg = 0; while (len-- > 0) AddChar(*bp++); - Flush(); + Flush(0); Activate(D_fore ? D_fore->w_norefresh : 0); return 1; } -- cgit v1.2.1 From e8d36bf10b784da5d7ba9a503c77e2e4688c6cda Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Mon, 7 Dec 2009 22:01:08 -0500 Subject: Refresh cleverly to improve scrolling speed. This should fix a lot of complaints about slow scrolling in vertical splits. The idea is to update the display once at the end of a screen write, rather than a lot of time during the write, which was the root of the slowness. It is possible that LayPauseUpdateRegion needs to be called in a few more places, but this works for now for the tests I have done. --- src/window.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/window.c') diff --git a/src/window.c b/src/window.c index fb271d2..ea406a5 100644 --- a/src/window.c +++ b/src/window.c @@ -1906,7 +1906,11 @@ char *data; p->w_pwin->p_inlen += len; } #endif + + LayPause(&p->w_layer, 1); WriteString(p, bp, len); + LayPause(&p->w_layer, 0); + return; } -- cgit v1.2.1 From 33b7c9ca3968e42fdfb9c4e031434e4d87864146 Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Thu, 17 Dec 2009 17:48:05 -0500 Subject: Wait a bit before killing a window. Wait a few seconds (10) before killing a window when wait() returns the pid for the child process in the window. This is so the output of the window doesn't get truncated in zombie mode. Micah pointed out the bug and Juergen pointed out the fix at #27061. --- src/window.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/window.c') diff --git a/src/window.c b/src/window.c index ea406a5..dc9fd3a 100644 --- a/src/window.c +++ b/src/window.c @@ -93,6 +93,7 @@ static void pseu_readev_fn __P((struct event *, char *)); static void pseu_writeev_fn __P((struct event *, char *)); #endif static void win_silenceev_fn __P((struct event *, char *)); +static void win_destroyev_fn __P((struct event *, char *)); static int OpenDevice __P((char **, int, int *, char **)); static int ForkWindow __P((struct win *, char **, char *)); @@ -840,6 +841,9 @@ struct NewWindow *newwin; SetTimeout(&p->w_silenceev, p->w_silencewait * 1000); evenq(&p->w_silenceev); } + p->w_destroyev.type = EV_TIMEOUT; + p->w_destroyev.data = 0; + p->w_destroyev.handler = win_destroyev_fn; SetForeWindow(p); Activate(p->w_norefresh); @@ -1026,6 +1030,7 @@ struct win *wp; evdeq(&wp->w_readev); /* just in case */ evdeq(&wp->w_writeev); /* just in case */ evdeq(&wp->w_silenceev); + evdeq(&wp->w_destroyev); #ifdef COPY_PASTE FreePaster(&wp->w_paster); #endif @@ -2053,6 +2058,15 @@ char *data; } } +static void +win_destroyev_fn(ev, data) +struct event *ev; +char *data; +{ + struct win *p = (struct win *)ev->data; + WindowDied(p, p->w_exitstatus, 1); +} + #ifdef ZMODEM static int -- cgit v1.2.1 From 84b8ef5de3aa94d6b49e81fe4562694fb12c5d0a Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Sat, 19 Dec 2009 12:32:50 -0500 Subject: Report impermissible write failure to attached display Fixes savannah bug #26401. --- src/window.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/window.c') diff --git a/src/window.c b/src/window.c index dc9fd3a..bb232c2 100644 --- a/src/window.c +++ b/src/window.c @@ -281,8 +281,7 @@ int *lenp; debug2("window %d, user %s: ", fore->w_number, D_user->u_name); debug2("writelock %d (wlockuser %s)\n", fore->w_wlock, fore->w_wlockuser ? fore->w_wlockuser->u_name : "NULL"); - /* XXX FIXME only display !*/ - WBell(fore, visual_bell); + Msg(0, "write: permission denied (user %s)", D_user->u_name); *bufpp += *lenp; *lenp = 0; return; -- cgit v1.2.1 From a6eea7b4d6dd3e4385919b4a50a58688f9a6b52b Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Thu, 24 Dec 2009 15:28:51 -0500 Subject: Re-optimize screen updates. In only the top line and the bottom line had to be updated, we were updating the entire region in between as well! This clearly is bad. So instead of doing that, just update the lines that need changing. Thanks to Chris Jones for reporting the bug. --- src/window.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/window.c') diff --git a/src/window.c b/src/window.c index bb232c2..aaad8ad 100644 --- a/src/window.c +++ b/src/window.c @@ -1022,6 +1022,7 @@ struct win *wp; wp->w_layer.l_cvlist = 0; if (flayer == &wp->w_layer) flayer = 0; + LayerCleanupMemory(&wp->w_layer); #ifdef MULTIUSER FreeWindowAcl(wp); -- cgit v1.2.1 From f33e5cdecb7bf3b6ae8e4a5c0ca394dd5a06a416 Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Tue, 26 Jan 2010 15:15:24 -0500 Subject: Increase the max-window limit. The limit can be increased using the 'maxwin' command. There is still an upper-limit of 2048 windows. --- src/window.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/window.c') diff --git a/src/window.c b/src/window.c index aaad8ad..addd83b 100644 --- a/src/window.c +++ b/src/window.c @@ -41,7 +41,7 @@ #include "logfile.h" /* logfopen() */ extern struct display *displays, *display; -extern struct win *windows, *fore, *wtab[], *console_window; +extern struct win *windows, *fore, *console_window; extern char *ShellArgs[]; extern char *ShellProg; extern char screenterm[]; @@ -104,6 +104,7 @@ static int zmodem_parse __P((struct win *, char *, int)); #endif +struct win **wtab; /* window table */ int VerboseCreate = 0; /* XXX move this to user.h */ @@ -553,6 +554,11 @@ struct NewWindow *newwin; extern struct acluser *users; #endif + if (!wtab) + { + wtab = calloc(maxwin, sizeof(struct win *)); + } + debug1("NewWindow: StartAt %d\n", newwin->StartAt); debug1("NewWindow: aka %s\n", newwin->aka?newwin->aka:"NULL"); debug1("NewWindow: dir %s\n", newwin->dir?newwin->dir:"NULL"); -- cgit v1.2.1 From 54791bc9f973699cd2c20acd3da1666686fc7c23 Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Mon, 8 Feb 2010 14:55:28 -0500 Subject: Fix a crash caused by configurable maxwin. --- src/window.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/window.c') diff --git a/src/window.c b/src/window.c index addd83b..1826b33 100644 --- a/src/window.c +++ b/src/window.c @@ -556,6 +556,8 @@ struct NewWindow *newwin; if (!wtab) { + if (!maxwin) + maxwin = MAXWIN; wtab = calloc(maxwin, sizeof(struct win *)); } -- cgit v1.2.1 From 97059b7ad521cf796daee07397c658d9716dd1e7 Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Mon, 15 Feb 2010 21:47:39 -0500 Subject: Fix compilation on systems where execvpe is defined. --- src/window.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/window.c') diff --git a/src/window.c b/src/window.c index 1826b33..20bceac 100644 --- a/src/window.c +++ b/src/window.c @@ -1449,6 +1449,7 @@ char **args, *ttyn; return pid; } +#ifndef HAVE_EXECVPE void execvpe(prog, args, env) char *prog, **args, **env; @@ -1494,6 +1495,7 @@ char *prog, **args, **env; if (eaccess) errno = EACCES; } +#endif #ifdef PSEUDOS -- cgit v1.2.1 From d1d0cc4d63eed5234f55aa0228196815f9969ae0 Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Wed, 24 Feb 2010 08:46:57 -0500 Subject: Allow moving windows around from the window list. Press ',' to switch the selected window with its previous window (in the same group). Similarly, press '.' to switch with the next window. --- src/window.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) (limited to 'src/window.c') diff --git a/src/window.c b/src/window.c index 20bceac..edf04dd 100644 --- a/src/window.c +++ b/src/window.c @@ -1,4 +1,7 @@ -/* Copyright (c) 2008, 2009 +/* Copyright (c) 2010 + * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de) + * Sadrul Habib Chowdhury (sadrul@users.sourceforge.net) + * Copyright (c) 2008, 2009 * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de) * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de) * Micah Cowan (micah@cowan.name) @@ -2261,3 +2264,54 @@ struct display *d; } #endif + +int +WindowChangeNumber(struct win *win, int n) +{ + struct win *p; + int old = win->w_number; + + if (n < 0 || n >= maxwin) + { + Msg(0, "Given window position is invalid."); + return 0; + } + + p = wtab[n]; + wtab[n] = win; + win->w_number = n; + wtab[old] = p; + if (p) + p->w_number = old; +#ifdef MULTIUSER + /* exchange the acls for these windows. */ + AclWinSwap(old, n); +#endif +#ifdef UTMPOK + /* exchange the utmp-slots for these windows */ + if ((win->w_slot != (slot_t) -1) && (win->w_slot != (slot_t) 0)) + { + RemoveUtmp(win); + SetUtmp(win); + } + if (p && (p->w_slot != (slot_t) -1) && (p->w_slot != (slot_t) 0)) + { + /* XXX: first display wins? */ +#if 0 + /* Does this make more sense? */ + display = p->w_lastdisp ? p->w_lastdisp : p->w_layer.l_cvlist ? p->w_layer.l_cvlist->c_display : 0; +#else + display = win->w_layer.l_cvlist ? win->w_layer.l_cvlist->c_display : 0; +#endif + RemoveUtmp(p); + SetUtmp(p); + } +#endif + + WindowChanged(win, 'n'); + WindowChanged((struct win *)0, 'w'); + WindowChanged((struct win *)0, 'W'); + WindowChanged((struct win *)0, 0); + return 1; +} + -- cgit v1.2.1 From 4f28ba8c8fd9032763eac42ed3591a6b2751f84c Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Fri, 26 Feb 2010 11:31:19 -0500 Subject: Some more fixes for the list management. Make sure the allocated memory is always freed. Also, do not reference freed memory. Thank you valgrind. --- src/window.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/window.c') diff --git a/src/window.c b/src/window.c index edf04dd..99e0bc7 100644 --- a/src/window.c +++ b/src/window.c @@ -212,7 +212,8 @@ struct LayFuncs WinLf = WinClearLine, WinRewrite, WinResize, - WinRestore + WinRestore, + 0 }; static int -- cgit v1.2.1 From 261a022ce947d17471b73a71345c265df9bfe7a4 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Sun, 7 Mar 2010 19:29:39 -0500 Subject: Fix build with -Werror=format-security Some distributions ( mandriva for example ) use -Werror=format-security by default when build C software to try to enhance code quality and prevent security bugs. As the policy is to correct all occurences of the error ( so there is no false positive, nor question about to fix it or not ), a patch that fix the error on gnu screen 4.0.3 have been added to the package. I have rediffed it against latest git snapshot, to be sent upstream. It mainly add "%s" where applicable. --- src/window.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/window.c') diff --git a/src/window.c b/src/window.c index 99e0bc7..a800d4a 100644 --- a/src/window.c +++ b/src/window.c @@ -613,7 +613,7 @@ struct NewWindow *newwin; if ((p = (struct win *)calloc(1, sizeof(struct win))) == 0) { close(f); - Msg(0, strnomem); + Msg(0, "%s", strnomem); return -1; } @@ -649,7 +649,7 @@ struct NewWindow *newwin; { free((char *)p); close(f); - Msg(0, strnomem); + Msg(0, "%s", strnomem); return -1; } #endif @@ -1530,7 +1530,7 @@ char **av; } if (!(pwin = (struct pseudowin *)calloc(1, sizeof(struct pseudowin)))) { - Msg(0, strnomem); + Msg(0, "%s", strnomem); return -1; } -- cgit v1.2.1 From 8a6abbab0161e6df1cea2ae0033a4c7f4a47f8e9 Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Sun, 14 Mar 2010 23:02:37 -0400 Subject: Add special rendition for silence'd windows. The default rendition for silence'd windows in caption/hardstatus or in the windowlist is =u (underline). Closes savannah bug #29205. --- src/window.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/window.c') diff --git a/src/window.c b/src/window.c index a800d4a..1716796 100644 --- a/src/window.c +++ b/src/window.c @@ -2069,6 +2069,8 @@ char *data; continue; #endif Msg(0, "Window %d: silence for %d seconds", p->w_number, p->w_silencewait); + p->w_silence = SILENCE_FOUND; + WindowChanged(p, 'f'); } } -- cgit v1.2.1