New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear image `w3mimgdisplay` op behaving erratically in some terminal emulators #94

Open
dvejmz opened this Issue Oct 17, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@dvejmz
Copy link

dvejmz commented Oct 17, 2017

Description

Images are not being cleared out correctly in some terminal emulators (see list below). When invoking w3mimgdisplay from an X11 environment, sending op. 6 (clear image) doesn't remove the image from the screen completely, leaving in some cases a black patch or not doing anything at all.

This issue comes from the ranger community and has been a problem there for quite some time now, as you can see from this list of issues:

This is a non-exhaustive list of all the terminal emulators where w3mimgdisplay has been found to be partially broken at least, especially the image clearing op:

  • Konsole: "clear image" functionality doesn't work
  • Terminator: "clear image" functionality doesn't work
  • gnome-terminal: "clear image" functionality works partially. Image is "blacked out" instead of being completely cleared off (see below)
  • Termite
  • st

Conversely, w3mimgdisplay seems to work almost perfectly in xterm (which is to be expected) and, to a slightly lesser degree, in rxvt and derivatives.

I've not tried with more emulators yet but will do as soon as I have some more free time, although I wager few of them will support it any better than xterm, rxvt (and forks) would do...

I'm not very familiar with the codebase but a quick glance at it might point us in the direction of this file

w3m/w3mimg/x11/x11_w3mimg.c

Perhaps this function or the way XClearArea from the X11 libs is invoked from within?

static int
x11_clear(w3mimg_op * self, int x, int y, int w, int h)
{
    struct x11_info *xi;
    if (self == NULL)
	return 0;
    xi = (struct x11_info *)self->priv;
    if (xi == NULL)
	return 0;

    if (x < 0)
	x = 0;
    if (y < 0)
	y = 0;

    XClearArea(xi->display, xi->window, x, y, w, h, False);
    return 1;
}

Do you think it'd be feasible to fix this somehow?

Environment

Can't really tell what environments all the people reporting these problems in the past were running but mine is:

  • Fedora 26 (4.13.5-200.fc26.x86_64 #1 SMP Thu Oct 5 16:53:13 UTC 2017 GNU/Linux).
  • X.Org X Server 1.19.3

Examples

I've tested w3mimgdisplay in isolation with the "draw" and "clear" image commands. For that I used this script (credit to this guy for the script), which you can see me launching in the examples below.

For clarity, the commands that I'm running in the examples below are

# ./view-pic-2.0.sh -d mfw.jpg
echo -e '0;1;0;0;133;200;;;;;mfw.jpg\n4;\n3;' | /usr/libexec/w3m/w3mimgdisplay
# ./view-pic-2.0.sh -c mfw.jpg
echo -e '6;0;0;133;200;\n4;\n3;' | /usr/libexec/w3m/w3mimgdisplay

Nevermind the pic, it was the first one I grabbed :)

xterm

859-xterm

gnome-terminal

859-gnome-terminal

Konsole

859-konsole

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment