Sat May 29 09:11:14 2021 UTC ()
wresize: don't bound pads to the size of the screen

allows avoiding a workaround in aiomixer,

ok blymn uwe


(nia)
diff -r1.30 -r1.31 src/lib/libcurses/resize.c

cvs diff -r1.30 -r1.31 src/lib/libcurses/resize.c (expand / switch to unified diff)

--- src/lib/libcurses/resize.c 2018/11/02 04:17:39 1.30
+++ src/lib/libcurses/resize.c 2021/05/29 09:11:14 1.31
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: resize.c,v 1.30 2018/11/02 04:17:39 blymn Exp $ */ 1/* $NetBSD: resize.c,v 1.31 2021/05/29 09:11:14 nia Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001 4 * Copyright (c) 2001
5 * Brett Lymn. 5 * Brett Lymn.
6 * 6 *
7 * This code has been donated to The NetBSD Foundation by the Author. 7 * This code has been donated to The NetBSD Foundation by the Author.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -23,27 +23,27 @@ @@ -23,27 +23,27 @@
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE. 28 * SUCH DAMAGE.
29 */ 29 */
30 30
31#include <sys/cdefs.h> 31#include <sys/cdefs.h>
32#ifndef lint 32#ifndef lint
33#if 0 33#if 0
34static char sccsid[] = "@(#)resize.c blymn 2001/08/26"; 34static char sccsid[] = "@(#)resize.c blymn 2001/08/26";
35#else 35#else
36__RCSID("$NetBSD: resize.c,v 1.30 2018/11/02 04:17:39 blymn Exp $"); 36__RCSID("$NetBSD: resize.c,v 1.31 2021/05/29 09:11:14 nia Exp $");
37#endif 37#endif
38#endif /* not lint */ 38#endif /* not lint */
39 39
40#include <stdlib.h> 40#include <stdlib.h>
41 41
42#include "curses.h" 42#include "curses.h"
43#include "curses_private.h" 43#include "curses_private.h"
44 44
45static int __resizeterm(WINDOW *win, int nlines, int ncols); 45static int __resizeterm(WINDOW *win, int nlines, int ncols);
46static int __resizewin(WINDOW *win, int nlines, int ncols); 46static int __resizewin(WINDOW *win, int nlines, int ncols);
47 47
48/* 48/*
49 * wresize -- 49 * wresize --
@@ -52,27 +52,45 @@ static int __resizewin(WINDOW *win, int  @@ -52,27 +52,45 @@ static int __resizewin(WINDOW *win, int
52int 52int
53wresize(WINDOW *win, int req_nlines, int req_ncols) 53wresize(WINDOW *win, int req_nlines, int req_ncols)
54{ 54{
55 int nlines = req_nlines; 55 int nlines = req_nlines;
56 int ncols = req_ncols; 56 int ncols = req_ncols;
57 57
58 if (win == NULL) 58 if (win == NULL)
59 return ERR; 59 return ERR;
60 60
61#ifdef DEBUG 61#ifdef DEBUG
62 __CTRACE(__CTRACE_WINDOW, "wresize: (%p, %d, %d)\n", 62 __CTRACE(__CTRACE_WINDOW, "wresize: (%p, %d, %d)\n",
63 win, nlines, ncols); 63 win, nlines, ncols);
64#endif 64#endif
65 if (win->orig == NULL) { 65 if (win->orig != NULL) {
 66 /* subwins must fit inside the parent - check this */
 67 if (win->begy > win->orig->begy + win->orig->maxy)
 68 win->begy = win->orig->begy + win->orig->maxy - 1;
 69 if (win->begy + nlines > win->orig->begy + win->orig->maxy)
 70 nlines = 0;
 71 if (nlines <= 0)
 72 nlines += win->orig->begy + win->orig->maxy - win->begy;
 73 if (nlines < 1)
 74 nlines = 1;
 75 if (win->begx > win->orig->begx + win->orig->maxx)
 76 win->begx = win->orig->begx + win->orig->maxx - 1;
 77 if (win->begx + ncols > win->orig->begx + win->orig->maxx)
 78 ncols = 0;
 79 if (ncols <= 0)
 80 ncols += win->orig->begx + win->orig->maxx - win->begx;
 81 if (ncols < 1)
 82 ncols = 1;
 83 } else if (!(win->flags & __ISPAD)) {
66 /* bound "our" windows by the screen size */ 84 /* bound "our" windows by the screen size */
67 if (win == curscr || win == __virtscr || win == stdscr) { 85 if (win == curscr || win == __virtscr || win == stdscr) {
68 if (nlines > LINES) 86 if (nlines > LINES)
69 nlines = LINES; 87 nlines = LINES;
70 if (nlines < 1) 88 if (nlines < 1)
71 nlines = 1; 89 nlines = 1;
72 if (ncols > COLS) 90 if (ncols > COLS)
73 ncols = COLS; 91 ncols = COLS;
74 if (ncols < 1) 92 if (ncols < 1)
75 ncols = 1; 93 ncols = 1;
76 } else { 94 } else {
77 if (win->begy > LINES) 95 if (win->begy > LINES)
78 win->begy = 0; 96 win->begy = 0;
@@ -81,44 +99,26 @@ wresize(WINDOW *win, int req_nlines, int @@ -81,44 +99,26 @@ wresize(WINDOW *win, int req_nlines, int
81 if (nlines <= 0) 99 if (nlines <= 0)
82 nlines += LINES - win->begy; 100 nlines += LINES - win->begy;
83 if (nlines < 1) 101 if (nlines < 1)
84 nlines = 1; 102 nlines = 1;
85 if (win->begx > COLS) 103 if (win->begx > COLS)
86 win->begx = 0; 104 win->begx = 0;
87 if (win->begx + ncols > COLS) 105 if (win->begx + ncols > COLS)
88 ncols = 0; 106 ncols = 0;
89 if (ncols <= 0) 107 if (ncols <= 0)
90 ncols += COLS - win->begx; 108 ncols += COLS - win->begx;
91 if (ncols < 1) 109 if (ncols < 1)
92 ncols = 1; 110 ncols = 1;
93 } 111 }
94 } else { 
95 /* subwins must fit inside the parent - check this */ 
96 if (win->begy > win->orig->begy + win->orig->maxy) 
97 win->begy = win->orig->begy + win->orig->maxy - 1; 
98 if (win->begy + nlines > win->orig->begy + win->orig->maxy) 
99 nlines = 0; 
100 if (nlines <= 0) 
101 nlines += win->orig->begy + win->orig->maxy - win->begy; 
102 if (nlines < 1) 
103 nlines = 1; 
104 if (win->begx > win->orig->begx + win->orig->maxx) 
105 win->begx = win->orig->begx + win->orig->maxx - 1; 
106 if (win->begx + ncols > win->orig->begx + win->orig->maxx) 
107 ncols = 0; 
108 if (ncols <= 0) 
109 ncols += win->orig->begx + win->orig->maxx - win->begx; 
110 if (ncols < 1) 
111 ncols = 1; 
112 } 112 }
113 113
114 if ((__resizewin(win, nlines, ncols)) == ERR) 114 if ((__resizewin(win, nlines, ncols)) == ERR)
115 return ERR; 115 return ERR;
116 116
117 win->reqy = req_nlines; 117 win->reqy = req_nlines;
118 win->reqx = req_ncols; 118 win->reqx = req_ncols;
119 119
120 /* If someone resizes curscr, we must also resize __virtscr */ 120 /* If someone resizes curscr, we must also resize __virtscr */
121 if (win == curscr) { 121 if (win == curscr) {
122 if ((__resizewin(__virtscr, nlines, ncols)) == ERR) 122 if ((__resizewin(__virtscr, nlines, ncols)) == ERR)
123 return ERR; 123 return ERR;
124 __virtscr->reqy = req_nlines; 124 __virtscr->reqy = req_nlines;