zsh-workers
 help / color / mirror / code / Atom feed
* Re: Strange bug with tiling wm, urxvt and zsh
       [not found] <20071205141643.GA19714@codernet.org>
@ 2007-12-05 14:56 ` Peter Stephenson
  2007-12-05 16:25   ` Nico R. Wohlgemuth
  2007-12-18 17:41 ` Nico R. Wohlgemuth
  2008-09-02 21:33 ` martin f krafft
  2 siblings, 1 reply; 10+ messages in thread
From: Peter Stephenson @ 2007-12-05 14:56 UTC (permalink / raw)
  To: Nico R. Wohlgemuth, zsh-workers

On Wed, 5 Dec 2007 15:16:44 +0100
nico@codernet.org (Nico R. Wohlgemuth) wrote:
> Everytime I open a window it gets resized to fit the screen (which is
> the job of a tiling wm). Now, If I open a terminal window, dwm resizes it
> directly to fit the screen - after that the first prompt I get is
> 'unusable'.
...
> I have tested a bit around and someone from #zsh gave me a dirty hack to
> bypass this behaviour: "sleep 0.1 && kill -SIGWINCH $$" at the end of the
> .zshrc - which works but is very dirty and only a termporaly solution for
> this.

(Moved to zsh-workers; I don't think there are any user-serviceable parts
inside.)

If this fixes the problem, it means zsh isn't receiving or (more likely)
handling a SIGWINCH generated while it's starting up which is when the
window is resized.

Can you try the following patch?  I'm not entirely sure of its possible
ramifications (though it doesn't look like it should cause new problems)
but it would at least be useful to find out if it helps.

Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.172
diff -u -r1.172 utils.c
--- Src/utils.c	3 Dec 2007 22:46:11 -0000	1.172
+++ Src/utils.c	5 Dec 2007 14:48:44 -0000
@@ -1506,12 +1506,12 @@
 /* check the size of the window and adjust if necessary. *
  * The value of from:					 *
  *   0: called from update_job or setupvals		 *
- *   1: called from the SIGWINCH handler		 *
+ *   1: called from the SIGWINCH handler (or faked)      *
  *   2: called from the LINES parameter callback	 *
  *   3: called from the COLUMNS parameter callback	 */
 
 /**/
-void
+mod_export void
 adjustwinsize(int from)
 {
     static int getwinsz = 1;
Index: Src/Zle/zle_main.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v
retrieving revision 1.100
diff -u -r1.100 zle_main.c
--- Src/Zle/zle_main.c	19 Oct 2007 01:33:09 -0000	1.100
+++ Src/Zle/zle_main.c	5 Dec 2007 14:48:44 -0000
@@ -1106,6 +1106,22 @@
 	if (termflags & TERM_UNKNOWN)
 	    init_term();
     }
+#ifdef TIOCGWINSZ
+    {
+	struct winsize winsize;
+	/*
+	 * We may not handle window changes that happened while the
+	 * shell was starting up.  Just before we draw the prompt,
+	 * do this fairly cheap test to see if we need to fake a
+	 * SIGWINCH.
+	 */
+	if (ioctl(SHTTY, TIOCGWINSZ, (char *)&winsize) == 0) {
+	    if (shttyinfo.winsize.ws_row != winsize.ws_row ||
+		shttyinfo.winsize.ws_col != winsize.ws_col)
+		adjustwinsize(1);
+	}
+    }
+#endif
 
     fflush(shout);
     fflush(stderr);



-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


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

* Re: Strange bug with tiling wm, urxvt and zsh
  2007-12-05 14:56 ` Strange bug with tiling wm, urxvt and zsh Peter Stephenson
@ 2007-12-05 16:25   ` Nico R. Wohlgemuth
  2007-12-05 17:28     ` Peter Stephenson
  0 siblings, 1 reply; 10+ messages in thread
From: Nico R. Wohlgemuth @ 2007-12-05 16:25 UTC (permalink / raw)
  To: zsh-workers

On 14:56 Wed 05 Dec     , Peter Stephenson wrote:
> On Wed, 5 Dec 2007 15:16:44 +0100
> nico@codernet.org (Nico R. Wohlgemuth) wrote:
> > Everytime I open a window it gets resized to fit the screen (which is
> > the job of a tiling wm). Now, If I open a terminal window, dwm resizes it
> > directly to fit the screen - after that the first prompt I get is
> > 'unusable'.
> ...
> > I have tested a bit around and someone from #zsh gave me a dirty hack to
> > bypass this behaviour: "sleep 0.1 && kill -SIGWINCH $$" at the end of the
> > .zshrc - which works but is very dirty and only a termporaly solution for
> > this.
> 
> (Moved to zsh-workers; I don't think there are any user-serviceable parts
> inside.)
> 
> If this fixes the problem, it means zsh isn't receiving or (more likely)
> handling a SIGWINCH generated while it's starting up which is when the
> window is resized.
> 
> Can you try the following patch?  I'm not entirely sure of its possible
> ramifications (though it doesn't look like it should cause new problems)
> but it would at least be useful to find out if it helps.
> 
> Index: Src/utils.c
> ===================================================================
> RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
> retrieving revision 1.172
> diff -u -r1.172 utils.c
> --- Src/utils.c	3 Dec 2007 22:46:11 -0000	1.172
> +++ Src/utils.c	5 Dec 2007 14:48:44 -0000
> @@ -1506,12 +1506,12 @@
>  /* check the size of the window and adjust if necessary. *
>   * The value of from:					 *
>   *   0: called from update_job or setupvals		 *
> - *   1: called from the SIGWINCH handler		 *
> + *   1: called from the SIGWINCH handler (or faked)      *
>   *   2: called from the LINES parameter callback	 *
>   *   3: called from the COLUMNS parameter callback	 */
>  
>  /**/
> -void
> +mod_export void
>  adjustwinsize(int from)
>  {
>      static int getwinsz = 1;
> Index: Src/Zle/zle_main.c
> ===================================================================
> RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v
> retrieving revision 1.100
> diff -u -r1.100 zle_main.c
> --- Src/Zle/zle_main.c	19 Oct 2007 01:33:09 -0000	1.100
> +++ Src/Zle/zle_main.c	5 Dec 2007 14:48:44 -0000
> @@ -1106,6 +1106,22 @@
>  	if (termflags & TERM_UNKNOWN)
>  	    init_term();
>      }
> +#ifdef TIOCGWINSZ
> +    {
> +	struct winsize winsize;
> +	/*
> +	 * We may not handle window changes that happened while the
> +	 * shell was starting up.  Just before we draw the prompt,
> +	 * do this fairly cheap test to see if we need to fake a
> +	 * SIGWINCH.
> +	 */
> +	if (ioctl(SHTTY, TIOCGWINSZ, (char *)&winsize) == 0) {
> +	    if (shttyinfo.winsize.ws_row != winsize.ws_row ||
> +		shttyinfo.winsize.ws_col != winsize.ws_col)
> +		adjustwinsize(1);
> +	}
> +    }
> +#endif
>  
>      fflush(shout);
>      fflush(stderr);
> 
> 
> 
> -- 
> Peter Stephenson <pws@csr.com>                  Software Engineer
> CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
> Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070

The patch (sadly) does not solve the problem.
-- 
regards,
Nico R. Wohlgemuth


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

* Re: Strange bug with tiling wm, urxvt and zsh
  2007-12-05 16:25   ` Nico R. Wohlgemuth
@ 2007-12-05 17:28     ` Peter Stephenson
  2007-12-05 18:29       ` Nico R. Wohlgemuth
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Stephenson @ 2007-12-05 17:28 UTC (permalink / raw)
  To: Nico R. Wohlgemuth, zsh-workers

On Wed, 5 Dec 2007 17:25:01 +0100
nico@codernet.org (Nico R. Wohlgemuth) wrote:
> The patch (sadly) does not solve the problem.

OK, that means (E&OE) that the rows and columns are set correctly when
we get to zle.  Next guess:  the SIGWINCH is happening too early, before
we've set up the terminal, so that adjustwinsize() is being called but is
doing the wrong thing.

The following patch stops adjustwinsize() from doing anything until we're
sure it's OK which is at the call during normal initialization.

Index: Src/jobs.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/jobs.c,v
retrieving revision 1.60
diff -u -r1.60 jobs.c
--- Src/jobs.c	5 Sep 2007 16:16:17 -0000	1.60
+++ Src/jobs.c	5 Dec 2007 17:22:05 -0000
@@ -379,7 +379,7 @@
 		if (somestopped || (pgrp > 1 && kill(-pgrp, 0) == -1)) {
 		    attachtty(mypgrp);
 		    /* check window size and adjust if necessary */
-		    adjustwinsize(0);
+		    adjustwinsize(4);
 		} else {
 		    /*
 		     * Oh, dear, we're right in the middle of some confusion
@@ -406,7 +406,7 @@
 	    } else {
 		attachtty(mypgrp);
 		/* check window size and adjust if necessary */
-		adjustwinsize(0);
+		adjustwinsize(4);
 	    }
 	}
     } else if (list_pipe && (val & 0200) && inforeground == 1 &&
@@ -1067,7 +1067,7 @@
     deletefilelist(jn->filelist);
     if (jn->stat & STAT_ATTACH) {
 	attachtty(mypgrp);
-	adjustwinsize(0);
+	adjustwinsize(4);
     }
 
     freejob(jn, 1);
Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.172
diff -u -r1.172 utils.c
--- Src/utils.c	3 Dec 2007 22:46:11 -0000	1.172
+++ Src/utils.c	5 Dec 2007 17:22:06 -0000
@@ -1504,21 +1504,37 @@
 }
 
 /* check the size of the window and adjust if necessary. *
- * The value of from:					 *
- *   0: called from update_job or setupvals		 *
- *   1: called from the SIGWINCH handler		 *
- *   2: called from the LINES parameter callback	 *
- *   3: called from the COLUMNS parameter callback	 */
+ * The value of from:                                    *
+ *   0: called from setupvals                            *
+ *   1: called from the SIGWINCH handler                 *
+ *   2: called from the LINES parameter callback         *
+ *   3: called from the COLUMNS parameter callback       *
+ *   4: called from update_job                           */
 
 /**/
 void
 adjustwinsize(int from)
 {
+    static int init_ok = 0;
     static int getwinsz = 1;
     int ttyrows = shttyinfo.winsize.ws_row;
     int ttycols = shttyinfo.winsize.ws_col;
     int resetzle = 0;
 
+    if (!init_ok) {
+	/*
+	 * We don't set up until the call from setupvals().
+	 */
+	if (from)
+	    return;
+	init_ok = 1;
+    }
+    /*
+     * The call from update_job() behaves the same as the initial call.
+     */
+    if (from == 4)
+	from = 0;
+
     if (getwinsz || from == 1) {
 #ifdef TIOCGWINSZ
 	if (SHTTY == -1)



-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


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

* Re: Strange bug with tiling wm, urxvt and zsh
  2007-12-05 17:28     ` Peter Stephenson
@ 2007-12-05 18:29       ` Nico R. Wohlgemuth
  2007-12-07 11:54         ` Peter Stephenson
  0 siblings, 1 reply; 10+ messages in thread
From: Nico R. Wohlgemuth @ 2007-12-05 18:29 UTC (permalink / raw)
  To: zsh-workers

On 17:28 Wed 05 Dec     , Peter Stephenson wrote:
> On Wed, 5 Dec 2007 17:25:01 +0100
> nico@codernet.org (Nico R. Wohlgemuth) wrote:
> > The patch (sadly) does not solve the problem.
> 
> OK, that means (E&OE) that the rows and columns are set correctly when
> we get to zle.  Next guess:  the SIGWINCH is happening too early, before
> we've set up the terminal, so that adjustwinsize() is being called but is
> doing the wrong thing.
> 
> The following patch stops adjustwinsize() from doing anything until we're
> sure it's OK which is at the call during normal initialization.
> 
>  ...
> 
> -- 
> Peter Stephenson <pws@csr.com>                  Software Engineer
> CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
> Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070

That doesn't work either.
Also I'm wondering why I don't have this big with xterm and zsh.
-- 
regards,
Nico R. Wohlgemuth


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

* Re: Strange bug with tiling wm, urxvt and zsh
  2007-12-05 18:29       ` Nico R. Wohlgemuth
@ 2007-12-07 11:54         ` Peter Stephenson
  2007-12-07 12:04           ` Christian Walther
  2007-12-09 18:54           ` Peter Stephenson
  0 siblings, 2 replies; 10+ messages in thread
From: Peter Stephenson @ 2007-12-07 11:54 UTC (permalink / raw)
  To: Nico R. Wohlgemuth, zsh-workers

On Wed, 5 Dec 2007 19:29:23 +0100
nico@codernet.org (Nico R. Wohlgemuth) wrote:
> That doesn't work either.

This will need some work reproducing easily (i.e without me having to
change my entire X environment).  Then I think we will need to add some
fprintf's.

> Also I'm wondering why I don't have this big with xterm and zsh.

It's likely to be a race; xterm may initialize more quickly (or possibly
more slowly) so the shell is in a different state at that point.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


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

* Re: Strange bug with tiling wm, urxvt and zsh
  2007-12-07 11:54         ` Peter Stephenson
@ 2007-12-07 12:04           ` Christian Walther
  2007-12-09 18:54           ` Peter Stephenson
  1 sibling, 0 replies; 10+ messages in thread
From: Christian Walther @ 2007-12-07 12:04 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: Nico R. Wohlgemuth, zsh-workers

Hi,

On 07/12/2007, Peter Stephenson <pws@csr.com> wrote:
> On Wed, 5 Dec 2007 19:29:23 +0100
> nico@codernet.org (Nico R. Wohlgemuth) wrote:
> > That doesn't work either.
>
[...]
>
> > Also I'm wondering why I don't have this big with xterm and zsh.
>
> It's likely to be a race; xterm may initialize more quickly (or possibly
> more slowly) so the shell is in a different state at that point.

I've a similar environment using ion3, mrxvt and zsh. I never
encountered a problem as described above, so it really might be an
issue related the term.

Regards
Christian


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

* Re: Strange bug with tiling wm, urxvt and zsh
  2007-12-07 11:54         ` Peter Stephenson
  2007-12-07 12:04           ` Christian Walther
@ 2007-12-09 18:54           ` Peter Stephenson
  1 sibling, 0 replies; 10+ messages in thread
From: Peter Stephenson @ 2007-12-09 18:54 UTC (permalink / raw)
  To: Nico R. Wohlgemuth, zsh-workers

On Fri, 7 Dec 2007 11:54:48 +0000
Peter Stephenson <pws@csr.com> wrote:
> On Wed, 5 Dec 2007 19:29:23 +0100
> nico@codernet.org (Nico R. Wohlgemuth) wrote:
> > That doesn't work either.
> 
> This will need some work reproducing easily (i.e without me having to
> change my entire X environment).  Then I think we will need to add some
> fprintf's.

I'm not able to get this with dwm (which wasn't hard to install as it
took an unmeasurably small time to compile) in tiling mode, urxvt, and
your .zshrc, so it will certainly need some work.  I can send a guess at
where the fprintf's might reveal something, if you like.  You might want
to try the imminent 4.3.5, though I don't have any good reason to
suppose that helps.

> > Also I'm wondering why I don't have this big with xterm and zsh.
> 
> It's likely to be a race; xterm may initialize more quickly (or possibly
> more slowly) so the shell is in a different state at that point.

..as it presumably is on my Fedora 7 x86_64 T5500 system.

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


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

* Re: Strange bug with tiling wm, urxvt and zsh
       [not found] <20071205141643.GA19714@codernet.org>
  2007-12-05 14:56 ` Strange bug with tiling wm, urxvt and zsh Peter Stephenson
@ 2007-12-18 17:41 ` Nico R. Wohlgemuth
  2008-09-02 21:34   ` martin f krafft
  2008-09-02 21:33 ` martin f krafft
  2 siblings, 1 reply; 10+ messages in thread
From: Nico R. Wohlgemuth @ 2007-12-18 17:41 UTC (permalink / raw)
  To: zsh-workers

It seems like this was a urxvt issue, 8.8 was released, I upgraded and
now it works. If someone else expires this problem with urxvt he should
upgrade to 8.8 or later. Thanks to people who helped here.

-- 
regards,
Nico R. Wohlgemuth


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

* Re: Strange bug with tiling wm, urxvt and zsh
       [not found] <20071205141643.GA19714@codernet.org>
  2007-12-05 14:56 ` Strange bug with tiling wm, urxvt and zsh Peter Stephenson
  2007-12-18 17:41 ` Nico R. Wohlgemuth
@ 2008-09-02 21:33 ` martin f krafft
  2 siblings, 0 replies; 10+ messages in thread
From: martin f krafft @ 2008-09-02 21:33 UTC (permalink / raw)
  To: zsh-users; +Cc: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 932 bytes --]

also sprach Nico R. Wohlgemuth <nico@codernet.org> [2007.12.05.1416 +0000]:
> Everytime I open a window it gets resized to fit the screen (which is
> the job of a tiling wm). Now, If I open a terminal window, dwm resizes it
> directly to fit the screen - after that the first prompt I get is
> 'unusable'. Completion does not work (it works but I just does not get
> displayed). I am able to write and exec but not to delete, complete etc.
> You can see this at http://nico.codernet.org/pub/zshbug/. Also if I
> press return, the written line gets echoed and then the command is
> execed.

I can confirm this bug with zsh/urxvt/awesome. If I move my
configuration[0] out of the way, I cannot reproduce it.

0. http://git.madduck.net/v/etc/zsh.git?a=tree

-- 
martin | http://madduck.net/ | http://two.sentenc.es/
 
bush/cheney '04: the last vote you'll ever have to cast.
 
spamtraps: madduck.bogus@madduck.net

[-- Attachment #2: Digital signature (see http://martin-krafft.net/gpg/) --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: Strange bug with tiling wm, urxvt and zsh
  2007-12-18 17:41 ` Nico R. Wohlgemuth
@ 2008-09-02 21:34   ` martin f krafft
  0 siblings, 0 replies; 10+ messages in thread
From: martin f krafft @ 2008-09-02 21:34 UTC (permalink / raw)
  To: Nico R. Wohlgemuth; +Cc: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 579 bytes --]

also sprach Nico R. Wohlgemuth <nico@codernet.org> [2007.12.18.1741 +0000]:
> It seems like this was a urxvt issue, 8.8 was released, I upgraded and
> now it works. If someone else expires this problem with urxvt he should
> upgrade to 8.8 or later. Thanks to people who helped here.

It doesn't work with 9.05-1 here (Debian).

-- 
martin | http://madduck.net/ | http://two.sentenc.es/
 
a woman is an occasional pleasure
but a cigar is always a smoke.
                                                       -- groucho marx
 
spamtraps: madduck.bogus@madduck.net

[-- Attachment #2: Digital signature (see http://martin-krafft.net/gpg/) --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

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

end of thread, other threads:[~2008-09-02 21:36 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20071205141643.GA19714@codernet.org>
2007-12-05 14:56 ` Strange bug with tiling wm, urxvt and zsh Peter Stephenson
2007-12-05 16:25   ` Nico R. Wohlgemuth
2007-12-05 17:28     ` Peter Stephenson
2007-12-05 18:29       ` Nico R. Wohlgemuth
2007-12-07 11:54         ` Peter Stephenson
2007-12-07 12:04           ` Christian Walther
2007-12-09 18:54           ` Peter Stephenson
2007-12-18 17:41 ` Nico R. Wohlgemuth
2008-09-02 21:34   ` martin f krafft
2008-09-02 21:33 ` martin f krafft

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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