9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] [PATCH] winwatch: always reflow when possible
@ 2021-02-01 19:05 telephil9
  2021-02-02 11:05 ` Sigrid Solveig Haflínudóttir
  0 siblings, 1 reply; 2+ messages in thread
From: telephil9 @ 2021-02-01 19:05 UTC (permalink / raw)
  To: 9front

Hi

Currently winwatch does not reflow its content unless there is the need to 
add a new row or column.
This leads to the rectangles not filling the window and leaving unused blank spaces.
The patch below changes this behaviour by reflowing as soon as the number of rows or
columns changes.

--phil


diff -r f020e57da8d6 sys/src/cmd/winwatch.c
--- a/sys/src/cmd/winwatch.c	Thu Dec 17 20:26:38 2020 -0800
+++ b/sys/src/cmd/winwatch.c	Mon Feb 01 20:01:23 2021 +0100
@@ -185,19 +185,21 @@
 int
 geometry(void)
 {
-	int i, ncols, z;
+	int i, nrows, ncols, z;
 	Rectangle r;
 
 	z = 0;
-	rows = (Dy(screen->r)-2*MARGIN+PAD)/(font->height+PAD);
-	if(rows <= 0)
-		rows = 1;
-	if(rows*cols < nwin || rows*cols >= nwin*2){
-		ncols = nwin <= 0 ? 1 : (nwin+rows-1)/rows;
-		if(ncols != cols){
-			cols = ncols;
-			z = 1;
-		}
+	nrows = (Dy(screen->r)-2*MARGIN+PAD)/(font->height+PAD);
+	if(nrows <= 0)
+		nrows = 1;
+	if(nrows != rows){
+		rows = nrows;
+		z = 1;
+	}
+	ncols = nwin <= 0 ? 1 : (nwin+rows-1)/rows;
+	if(ncols != cols){
+		cols = ncols;
+		z = 1;
 	}
 
 	r = Rect(0,0,(Dx(screen->r)-2*MARGIN+PAD)/cols-PAD, font->height);

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [9front] [PATCH] winwatch: always reflow when possible
  2021-02-01 19:05 [9front] [PATCH] winwatch: always reflow when possible telephil9
@ 2021-02-02 11:05 ` Sigrid Solveig Haflínudóttir
  0 siblings, 0 replies; 2+ messages in thread
From: Sigrid Solveig Haflínudóttir @ 2021-02-02 11:05 UTC (permalink / raw)
  To: 9front, telephil9

Applied, thanks.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-02-03  2:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-01 19:05 [9front] [PATCH] winwatch: always reflow when possible telephil9
2021-02-02 11:05 ` Sigrid Solveig Haflínudóttir

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).