wok-6.x rev 19011

busybox/fbvnc: wheelmouse support (again)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Mar 28 23:15:26 2016 +0200 (2016-03-28)
parents 364e68c766fd
children 564e1bce3c80
files busybox/stuff/busybox-1.23-diff.u busybox/stuff/busybox-1.23-fbvnc.u
line diff
     1.1 --- a/busybox/stuff/busybox-1.23-diff.u	Mon Mar 28 18:51:16 2016 +0200
     1.2 +++ b/busybox/stuff/busybox-1.23-diff.u	Mon Mar 28 23:15:26 2016 +0200
     1.3 @@ -31,7 +31,7 @@
     1.4   			i = MIN(i, j);
     1.5   		}
     1.6   		if (i == 0)
     1.7 -@@ -879,7 +879,9 @@
     1.8 +@@ -869,7 +879,9 @@
     1.9   		 * Using list.len to specify its length,
    1.10   		 * add_to_dirlist will remove it. */
    1.11   		list[i].len = strlen(p[i]);
    1.12 @@ -42,7 +42,7 @@
    1.13   				add_to_dirlist, skip_dir, &list[i], 0);
    1.14   		/* Sort dl alphabetically.
    1.15   		 * GNU diff does this ignoring any number of trailing dots.
    1.16 -@@ -993,7 +995,7 @@
    1.17 +@@ -983,7 +995,7 @@
    1.18   #if ENABLE_FEATURE_DIFF_LONG_OPTIONS
    1.19   	applet_long_options = diff_longopts;
    1.20   #endif
     2.1 --- a/busybox/stuff/busybox-1.23-fbvnc.u	Mon Mar 28 18:51:16 2016 +0200
     2.2 +++ b/busybox/stuff/busybox-1.23-fbvnc.u	Mon Mar 28 23:15:26 2016 +0200
     2.3 @@ -1,8 +1,8 @@
     2.4     text    data     bss     dec     hex filename
     2.5 -   3118       0       0    3118     c2e util-linux/fbvnc.o
     2.6 +   3119       0       0    3119     c2f util-linux/fbvnc.o
     2.7  --- /dev/null
     2.8  +++ busybox/util-linux/fbvnc.c
     2.9 -@@ -0,0 +1,562 @@
    2.10 +@@ -0,0 +1,549 @@
    2.11  +/* vi: set sw=4 ts=4: */
    2.12  +/*
    2.13  + * A small linux framebuffer VNC viewer
    2.14 @@ -30,8 +30,7 @@
    2.15  +//usage:	"[VNC_SERVER] [PORT]"
    2.16  +//usage:#define fbvnc_full_usage "\n\n"
    2.17  +//usage:     "A linux framebuffer VNC viewer."
    2.18 -+//usage:     "\nTo exit, move mouse to upper left corner and press ESC."
    2.19 -+//usage:     "\nor press any mouse button and press ESC or press ESC ^C."
    2.20 ++//usage:     "\nTo exit, press any mouse button and press ESC."
    2.21  +
    2.22  +#include "libbb.h"
    2.23  +#include "vnc.h"
    2.24 @@ -146,6 +145,7 @@
    2.25  +#define srv_rows	scroll[1].srv_size
    2.26  +#define or		scroll[1].offset
    2.27  +#define mr		scroll[1].pos
    2.28 ++	char rat_buttons;
    2.29  +	int fb_fd;
    2.30  +	void *fb_ptr;
    2.31  +	int bpp;
    2.32 @@ -401,32 +401,30 @@
    2.33  +	return status;
    2.34  +}
    2.35  +
    2.36 -+static char rat_buttons;
    2.37  +static void rat_event(void)
    2.38  +{
    2.39 ++	static u8 btn2vnc[8] = {
    2.40 ++		0, VNC_BUTTON1_MASK, VNC_BUTTON3_MASK, 
    2.41 ++		VNC_BUTTON1_MASK + VNC_BUTTON3_MASK, VNC_BUTTON2_MASK, 
    2.42 ++		VNC_BUTTON1_MASK + VNC_BUTTON2_MASK,
    2.43 ++		VNC_BUTTON2_MASK + VNC_BUTTON3_MASK,
    2.44 ++		VNC_BUTTON1_MASK + VNC_BUTTON2_MASK + VNC_BUTTON3_MASK
    2.45 ++	};
    2.46  +	signed char ie[4];
    2.47  +	struct vnc_client_ratevent me = {VNC_CLIENT_RATEVENT};
    2.48 -+	int mask = 0;
    2.49  +	int refresh;
    2.50  +
    2.51  +	xread(G.rat_fd, &ie, sizeof(ie));
    2.52  +	G.mc += ie[1];
    2.53  +	G.mr -= ie[2];
    2.54  +	refresh = 2 - update_scroll(&G.scroll[0]) - update_scroll(&G.scroll[1]);
    2.55 -+	rat_buttons = ie[0] & 7;
    2.56 -+	if (ie[0] & 0x01)
    2.57 -+		mask |= VNC_BUTTON1_MASK;
    2.58 -+	if (ie[0] & 0x04)
    2.59 -+		mask |= VNC_BUTTON2_MASK;
    2.60 -+	if (ie[0] & 0x02)
    2.61 -+		mask |= VNC_BUTTON3_MASK;
    2.62 ++	me.mask = btn2vnc[G.rat_buttons = ie[0] & 7];
    2.63  +	if (ie[3] > 0)		/* wheel up */
    2.64 -+		mask |= VNC_BUTTON4_MASK;
    2.65 ++		me.mask |= VNC_BUTTON4_MASK;
    2.66  +	if (ie[3] < 0)		/* wheel down */
    2.67 -+		mask |= VNC_BUTTON5_MASK;
    2.68 ++		me.mask |= VNC_BUTTON5_MASK;
    2.69  +	me.y = htons(G.mr);
    2.70  +	me.x = htons(G.mc);
    2.71 -+	me.mask = mask;
    2.72  +	write(G.vnc_fd, &me, sizeof(me));
    2.73  +	if (refresh)
    2.74  +		vnc_refresh(0);
    2.75 @@ -448,51 +446,43 @@
    2.76  +	if ((nr = read(0, key, sizeof(key))) <= 0 )
    2.77  +		killed(1);
    2.78  +	for (i = 0; i < nr; i++) {
    2.79 -+		int k = -1;
    2.80 ++		int j, k;
    2.81  +		int mod[4];
    2.82 -+		int nmod = 0;
    2.83 ++		int nmod;
    2.84 ++
    2.85 ++		k = nmod = 0;
    2.86  +		switch (key[i]) {
    2.87  +		case 0x08:
    2.88  +		case 0x7f:
    2.89  +			k = 0xff08;
    2.90  +			break;
    2.91 -+		case 0x09:
    2.92 -+			k = 0xff09;
    2.93 -+			break;
    2.94  +		case 0x1b:
    2.95 -+			if (G.oc + G.mc + G.or + G.mr == 0 || rat_buttons)
    2.96 ++			if (G.rat_buttons)
    2.97  +				killed(0);
    2.98  +			if (i + 2 < nr && key[i + 1] == '[') {
    2.99 -+				if (key[i + 2] == 'A')
   2.100 -+					k = 0xff52;
   2.101 -+				if (key[i + 2] == 'B')
   2.102 -+					k = 0xff54;
   2.103 -+				if (key[i + 2] == 'C')
   2.104 -+					k = 0xff53;
   2.105 -+				if (key[i + 2] == 'D')
   2.106 -+					k = 0xff51;
   2.107 -+				if (key[i + 2] == 'H')
   2.108 -+					k = 0xff50;
   2.109 -+				if (k > 0) {
   2.110 ++				static const char arr2vnc[] = "HDACB";
   2.111 ++				char *p = strchr(arr2vnc, key[i + 2]);
   2.112 ++
   2.113 ++				if (p) {
   2.114 ++					k = p - arr2vnc + 0xff50;
   2.115  +					i += 2;
   2.116  +					break;
   2.117  +				}
   2.118  +			}
   2.119 -+			k = 0xff1b;
   2.120  +			if (i + 1 < nr) {
   2.121  +				mod[nmod++] = 0xffe9;
   2.122 -+				k = key[++i];
   2.123 -+				if (k == 0x03) /* esc-^C quit */
   2.124 -+					killed(0);
   2.125 ++				i++;
   2.126  +			}
   2.127 -+			break;
   2.128 ++		case 0x09:
   2.129  +		case 0x0d:
   2.130 -+			k = 0xff0d;
   2.131 -+			break;
   2.132 -+		case 0x0c:	/* ^L: redraw */
   2.133 -+			vnc_refresh(0);
   2.134 ++			k = 0xff00;
   2.135 ++			goto getkey;
   2.136 ++		case 0x0c:	/* Mouse button + ^L: redraw */
   2.137 ++			if (G.rat_buttons)
   2.138 ++				vnc_refresh(0);
   2.139  +		default:
   2.140 -+			k = (unsigned char) key[i];
   2.141 ++		getkey:
   2.142 ++			k += (unsigned char) key[i];
   2.143  +		}
   2.144  +		if ((k >= 'A' && k <= 'Z') || strchr(":\"<>?{}|+_()*&^%$#@!~", k))
   2.145  +			mod[nmod++] = 0xffe1;
   2.146 @@ -500,15 +490,12 @@
   2.147  +			k += 'a' - 1;
   2.148  +			mod[nmod++] = 0xffe3;
   2.149  +		}
   2.150 -+		if (k > 0) {
   2.151 -+			int j;
   2.152 -+			mod[nmod] = k;
   2.153 -+			for (j = 0; j <= nmod; j++)
   2.154 -+				press(mod[j], 1);
   2.155 -+			press(k, 0);
   2.156 -+			for (j = 0; j < nmod; j++)
   2.157 -+				press(mod[j], 0);
   2.158 -+		}
   2.159 ++		mod[nmod] = k;
   2.160 ++		for (j = 0; j <= nmod; j++)
   2.161 ++			press(mod[j], 1);
   2.162 ++		press(k, 0);
   2.163 ++		for (j = 0; j < nmod; j++)
   2.164 ++			press(mod[j], 0);
   2.165  +	}
   2.166  +}
   2.167  +