9front - general discussion about 9front
 help / color / mirror / Atom feed
From: telephil9@gmail.com
To: 9front@9front.org
Subject: [9front] [PATCH] winwatch: always reflow when possible
Date: Mon, 01 Feb 2021 20:05:58 +0100	[thread overview]
Message-ID: <EC4093E7F4DDFBEBFE5F79F6D7E91ADB@gmail.com> (raw)

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);

             reply	other threads:[~2021-02-02  6:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-01 19:05 telephil9 [this message]
2021-02-02 11:05 ` Sigrid Solveig Haflínudóttir

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=EC4093E7F4DDFBEBFE5F79F6D7E91ADB@gmail.com \
    --to=telephil9@gmail.com \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).