tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

wsmoused broken since 9.1



/usr/sbin/wsmoused has been non-working since slightly
before 9.1 was released. Specifically, any button click
or release generates:

wsmoused: ioctl(WSDISPLAYIO_GETWSCHAR) failed: Invalid argument

and click+drags produce a torrent of the same. Here is a patch
which fixes this problem:

---START---
diff -urN a/wsmoused/selection.c b/wsmoused/selection.c
--- a/wsmoused/selection.c	2007-05-27 15:05:00.000000000 +0000
+++ b/wsmoused/selection.c	2020-10-21 06:17:38.666544347 +0000
@@ -144,6 +144,7 @@
 static void selarea_start(void);
 static void selarea_end(void);
 static void selarea_calculate(void);
+static void selarea_getrowcol(size_t, size_t*, size_t*);
 static void selarea_hide(void);
 static void selarea_show(void);
 static void selarea_paste(void);
@@ -624,14 +625,29 @@

 /* ---------------------------------------------------------------------- */

+/* Turns selection absolute position in the screen buffer back into
+   row, col co-ordinates */
+static void
+selarea_getrowcol(size_t pos, size_t* row, size_t* col)
+{
+	size_t xres = Selmouse.sm_max_x + 1;
+
+	*row = pos / xres;
+	*col = pos - (*row * xres);
+}
+
+/* ---------------------------------------------------------------------- */
+
 /* Hides the highlighted region, returning it to normal colors. */
 static void
 selarea_hide(void)
 {
-	size_t i;
+	size_t i, row, col;

-	for (i = Selarea.sa_startoff; i <= Selarea.sa_endoff; i++)
-		char_invert(0, i);
+	for (i = Selarea.sa_startoff; i <= Selarea.sa_endoff; i++) {
+		selarea_getrowcol(i, &row, &col);
+		char_invert(row, col);
+	}
 }

 /* ---------------------------------------------------------------------- */
@@ -640,11 +656,13 @@
 static void
 selarea_show(void)
 {
-	size_t i;
+	size_t i, row, col;

 	selarea_calculate();
-	for (i = Selarea.sa_startoff; i <= Selarea.sa_endoff; i++)
-		char_invert(0, i);
+	for (i = Selarea.sa_startoff; i <= Selarea.sa_endoff; i++) {
+		selarea_getrowcol(i, &row, &col);
+		char_invert(row, col);
+	}
 }

 /* ---------------------------------------------------------------------- */
diff -urN a/wsmoused/wsmoused.c b/wsmoused/wsmoused.c
--- a/wsmoused/wsmoused.c	2011-05-31 03:37:02.000000000 +0000
+++ b/wsmoused/wsmoused.c	2020-10-21 06:17:38.666544347 +0000
@@ -71,7 +71,7 @@
 static int X_Console = -1;
 static int X_Console_Delay = 5;

-#ifdef WSMOUSED_SELECTION_MODE
+#ifdef WSMOUSED_ACTION_MODE
 extern struct mode_bootstrap Action_Mode;
 #endif
 #ifdef WSMOUSED_SELECTION_MODE
---END---

Thanks,
-RVP


Home | Main Index | Thread Index | Old Index