qulogic/libgnt

irssi: Fix layout on terminal resize
refresh-fixes
2019-04-06, Petteri Pitkänen
25df955b4486
irssi: Fix layout on terminal resize

This bug appeared when halving the width of an xterm or st window.

Fixes #12208. The patch was originally submitted to the issue tracker by
btmura, I added a comment about the exact cause of this behavior.
  • +15 -2
    wms/irssi.c
  • --- a/wms/irssi.c Sat Apr 06 16:05:38 2019 +0200
    +++ b/wms/irssi.c Sat Apr 06 16:13:46 2019 +0200
    @@ -305,14 +305,27 @@
    name = gnt_widget_get_name(widget);
    if (name && strstr(name, "conversation-window")) {
    int cx, cy, cw, ch;
    +
    gnt_widget_get_position(widget, &cx, &cy);
    gnt_widget_get_size(widget, &cw, &ch);
    +
    find_window_position(irssi, widget, &hor, &vert);
    get_xywh_for_frame(irssi, hor, vert, &x, &y, &w, &h);
    +
    + /*
    + * Refreshing the windows on terminal resize, without breaking the layout, depends
    + * currently on the order of the following calls:
    + *
    + * gnt_wm_move_window() emits the "window_moved" signal which will eventually get to
    + * refresh_node(), which asks sanitize_position() to give maximum space to a widget
    + * that extends out of screen, and this process may change the widget's position,
    + * which breaks the irssi layout. To prevent that we first resize the conversation
    + * widget to fit on the screen.
    + */
    + if (w != cw || h != ch)
    + gnt_wm_resize_window(GNT_WM(irssi), widget, w, h);
    if (x != cx || y != cy)
    gnt_wm_move_window(GNT_WM(irssi), widget, x, y);
    - if (w != cw || h != ch)
    - gnt_wm_resize_window(GNT_WM(irssi), widget, w, h);
    }
    }