Module Name:    src
Committed By:   roy
Date:           Mon Mar 23 13:37:37 UTC 2020

Modified Files:
        src/distrib/sets/lists/comp: mi
        src/lib/libcurses: Makefile curses.h
Added Files:
        src/lib/libcurses: mouse.c

Log Message:
curses: Add stubs for mouse functions

No mouse support actually included.
But that doesn't matter because most terms don't actually support a mouse.

We should look into hooking these into wsmouse(4) and xterm mouse
in the future.

Compatable with nCurses mouse API version 2.


To generate a diff of this commit:
cvs rdiff -u -r1.2313 -r1.2314 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.93 -r1.94 src/lib/libcurses/Makefile
cvs rdiff -u -r1.128 -r1.129 src/lib/libcurses/curses.h
cvs rdiff -u -r0 -r1.1 src/lib/libcurses/mouse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.2313 src/distrib/sets/lists/comp/mi:1.2314
--- src/distrib/sets/lists/comp/mi:1.2313	Sun Mar 22 14:27:33 2020
+++ src/distrib/sets/lists/comp/mi	Mon Mar 23 13:37:37 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.2313 2020/03/22 14:27:33 ad Exp $
+#	$NetBSD: mi,v 1.2314 2020/03/23 13:37:37 roy Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.comp				comp-sys-root
@@ -6402,6 +6402,7 @@
 ./usr/share/man/cat3/curses_insertln.0		comp-c-catman		.cat
 ./usr/share/man/cat3/curses_keyname.0		comp-c-catman		.cat
 ./usr/share/man/cat3/curses_line.0		comp-c-catman		.cat
+./usr/share/man/cat3/curses_mouse.0		comp-c-catman		.cat
 ./usr/share/man/cat3/curses_pad.0		comp-c-catman		.cat
 ./usr/share/man/cat3/curses_print.0		comp-c-catman		.cat
 ./usr/share/man/cat3/curses_refresh.0		comp-c-catman		.cat
@@ -7308,6 +7309,7 @@
 ./usr/share/man/cat3/getmntopts.0		comp-c-catman		.cat
 ./usr/share/man/cat3/getmntoptstr.0		comp-c-catman		.cat
 ./usr/share/man/cat3/getmode.0			comp-c-catman		.cat
+./usr/share/man/cat3/getmouse.0			comp-c-catman		.cat
 ./usr/share/man/cat3/getnameinfo.0		comp-c-catman		.cat
 ./usr/share/man/cat3/getnetbyaddr.0		comp-c-catman		.cat
 ./usr/share/man/cat3/getnetbyname.0		comp-c-catman		.cat
@@ -7428,6 +7430,7 @@
 ./usr/share/man/cat3/has_ic.0			comp-c-catman		.cat
 ./usr/share/man/cat3/has_il.0			comp-c-catman		.cat
 ./usr/share/man/cat3/has_key.0			comp-c-catman		.cat
+./usr/share/man/cat3/has_mouse.0		comp-c-catman		.cat
 ./usr/share/man/cat3/hash.0			comp-c-catman		.cat
 ./usr/share/man/cat3/hcreate.0			comp-c-catman		.cat
 ./usr/share/man/cat3/hcreate_r.0		comp-c-catman		.cat
@@ -8542,6 +8545,8 @@
 ./usr/share/man/cat3/modfl.0			comp-c-catman		.cat
 ./usr/share/man/cat3/moncontrol.0		comp-c-catman		.cat
 ./usr/share/man/cat3/monstartup.0		comp-c-catman		.cat
+./usr/share/man/cat3/mouse_trafo.0		comp-c-catman		.cat
+./usr/share/man/cat3/mouseinterval.0		comp-c-catman		.cat
 ./usr/share/man/cat3/move.0			comp-c-catman		.cat
 ./usr/share/man/cat3/move_field.0		comp-c-catman		.cat
 ./usr/share/man/cat3/move_panel.0		comp-c-catman		.cat
@@ -10277,6 +10282,7 @@
 ./usr/share/man/cat3/underscore.0		comp-c-catman		.cat
 ./usr/share/man/cat3/ungetc.0			comp-c-catman		.cat
 ./usr/share/man/cat3/ungetch.0			comp-c-catman		.cat
+./usr/share/man/cat3/ungetmouse.0		comp-c-catman		.cat
 ./usr/share/man/cat3/ungetwc.0			comp-c-catman		.cat
 ./usr/share/man/cat3/unistd.0			comp-c-catman		.cat
 ./usr/share/man/cat3/unlockpt.0			comp-c-catman		.cat
@@ -10424,6 +10430,7 @@
 ./usr/share/man/cat3/wdelch.0			comp-c-catman		.cat
 ./usr/share/man/cat3/wdeleteln.0		comp-c-catman		.cat
 ./usr/share/man/cat3/wechochar.0		comp-c-catman		.cat
+./usr/share/man/cat3/wenclose.0			comp-c-catman		.cat
 ./usr/share/man/cat3/werase.0			comp-c-catman		.cat
 ./usr/share/man/cat3/wgetch.0			comp-c-catman		.cat
 ./usr/share/man/cat3/wgetnstr.0			comp-c-catman		.cat
@@ -10442,6 +10449,7 @@
 ./usr/share/man/cat3/wmemcpy.0			comp-c-catman		.cat
 ./usr/share/man/cat3/wmemmove.0			comp-c-catman		.cat
 ./usr/share/man/cat3/wmemset.0			comp-c-catman		.cat
+./usr/share/man/cat3/wmouse_trafo.0		comp-c-catman		.cat
 ./usr/share/man/cat3/wmove.0			comp-c-catman		.cat
 ./usr/share/man/cat3/wnoutrefresh.0		comp-c-catman		.cat
 ./usr/share/man/cat3/wordexp.0			comp-c-catman		.cat
@@ -14426,6 +14434,7 @@
 ./usr/share/man/html3/curses_insertln.html	comp-c-htmlman		html
 ./usr/share/man/html3/curses_keyname.html	comp-c-htmlman		html
 ./usr/share/man/html3/curses_line.html		comp-c-htmlman		html
+./usr/share/man/html3/curses_mouse.html		comp-c-htmlman		html
 ./usr/share/man/html3/curses_pad.html		comp-c-htmlman		html
 ./usr/share/man/html3/curses_print.html		comp-c-htmlman		html
 ./usr/share/man/html3/curses_refresh.html	comp-c-htmlman		html
@@ -15339,6 +15348,7 @@
 ./usr/share/man/html3/getmntopts.html		comp-c-htmlman		html
 ./usr/share/man/html3/getmntoptstr.html		comp-c-htmlman		html
 ./usr/share/man/html3/getmode.html		comp-c-htmlman		html
+./usr/share/man/html3/getmouse.html		comp-c-htmlman		html
 ./usr/share/man/html3/getnameinfo.html		comp-c-htmlman		html
 ./usr/share/man/html3/getnetbyaddr.html		comp-c-htmlman		html
 ./usr/share/man/html3/getnetbyname.html		comp-c-htmlman		html
@@ -15458,6 +15468,7 @@
 ./usr/share/man/html3/has_ic.html		comp-c-htmlman		html
 ./usr/share/man/html3/has_il.html		comp-c-htmlman		html
 ./usr/share/man/html3/has_key.html		comp-c-htmlman		html
+./usr/share/man/html3/has_mouse.html		comp-c-htmlman		html
 ./usr/share/man/html3/hash.html			comp-c-htmlman		html
 ./usr/share/man/html3/hcreate.html		comp-c-htmlman		html
 ./usr/share/man/html3/hcreate_r.html		comp-c-htmlman		html
@@ -16540,6 +16551,8 @@
 ./usr/share/man/html3/modfl.html		comp-c-htmlman		html
 ./usr/share/man/html3/moncontrol.html		comp-c-htmlman		html
 ./usr/share/man/html3/monstartup.html		comp-c-htmlman		html
+./usr/share/man/html3/mouse_trafo.html		comp-c-htmlman		html
+./usr/share/man/html3/mouseinterval.html	comp-c-htmlman		html
 ./usr/share/man/html3/move.html			comp-c-htmlman		html
 ./usr/share/man/html3/move_field.html		comp-c-htmlman		html
 ./usr/share/man/html3/move_panel.html		comp-c-htmlman		html
@@ -18257,6 +18270,7 @@
 ./usr/share/man/html3/underscore.html		comp-c-htmlman		html
 ./usr/share/man/html3/ungetc.html		comp-c-htmlman		html
 ./usr/share/man/html3/ungetch.html		comp-c-htmlman		html
+./usr/share/man/html3/ungetmouse.html		comp-c-htmlman		html
 ./usr/share/man/html3/ungetwc.html		comp-c-htmlman		html
 ./usr/share/man/html3/unistd.html		comp-c-htmlman		html
 ./usr/share/man/html3/unlockpt.html		comp-c-htmlman		html
@@ -18400,6 +18414,7 @@
 ./usr/share/man/html3/wdelch.html		comp-c-htmlman		html
 ./usr/share/man/html3/wdeleteln.html		comp-c-htmlman		html
 ./usr/share/man/html3/wechochar.html		comp-c-htmlman		html
+./usr/share/man/html3/wenclose.html		comp-c-htmlman		html
 ./usr/share/man/html3/werase.html		comp-c-htmlman		html
 ./usr/share/man/html3/wgetch.html		comp-c-htmlman		html
 ./usr/share/man/html3/wgetnstr.html		comp-c-htmlman		html
@@ -18418,6 +18433,7 @@
 ./usr/share/man/html3/wmemcpy.html		comp-c-htmlman		html
 ./usr/share/man/html3/wmemmove.html		comp-c-htmlman		html
 ./usr/share/man/html3/wmemset.html		comp-c-htmlman		html
+./usr/share/man/html3/wmouse_trafo.html		comp-c-htmlman		html
 ./usr/share/man/html3/wmove.html		comp-c-htmlman		html
 ./usr/share/man/html3/wnoutrefresh.html		comp-c-htmlman		html
 ./usr/share/man/html3/wordexp.html		comp-c-htmlman		html
@@ -22393,6 +22409,7 @@
 ./usr/share/man/man3/curses_insertln.3		comp-c-man		.man
 ./usr/share/man/man3/curses_keyname.3		comp-c-man		.man
 ./usr/share/man/man3/curses_line.3		comp-c-man		.man
+./usr/share/man/man3/curses_mouse.3		comp-c-man		.man
 ./usr/share/man/man3/curses_pad.3		comp-c-man		.man
 ./usr/share/man/man3/curses_print.3		comp-c-man		.man
 ./usr/share/man/man3/curses_refresh.3		comp-c-man		.man
@@ -23310,6 +23327,7 @@
 ./usr/share/man/man3/getmntopts.3		comp-c-man		.man
 ./usr/share/man/man3/getmntoptstr.3		comp-c-man		.man
 ./usr/share/man/man3/getmode.3			comp-c-man		.man
+./usr/share/man/man3/getmouse.3			comp-c-man		.man
 ./usr/share/man/man3/getnameinfo.3		comp-c-man		.man
 ./usr/share/man/man3/getnetbyaddr.3		comp-c-man		.man
 ./usr/share/man/man3/getnetbyname.3		comp-c-man		.man
@@ -23430,6 +23448,7 @@
 ./usr/share/man/man3/has_ic.3			comp-c-man		.man
 ./usr/share/man/man3/has_il.3			comp-c-man		.man
 ./usr/share/man/man3/has_key.3			comp-c-man		.man
+./usr/share/man/man3/has_mouse.3		comp-c-man		.man
 ./usr/share/man/man3/hash.3			comp-c-man		.man
 ./usr/share/man/man3/hcreate.3			comp-c-man		.man
 ./usr/share/man/man3/hcreate_r.3		comp-c-man		.man
@@ -24545,6 +24564,8 @@
 ./usr/share/man/man3/modfl.3			comp-c-man		.man
 ./usr/share/man/man3/moncontrol.3		comp-c-man		.man
 ./usr/share/man/man3/monstartup.3		comp-c-man		.man
+./usr/share/man/man3/mouse_trafo.3		comp-c-man		.man
+./usr/share/man/man3/mouseinterval.3		comp-c-man		.man
 ./usr/share/man/man3/move.3			comp-c-man		.man
 ./usr/share/man/man3/move_field.3		comp-c-man		.man
 ./usr/share/man/man3/move_panel.3		comp-c-man		.man
@@ -26299,6 +26320,7 @@
 ./usr/share/man/man3/underscore.3		comp-c-man		.man
 ./usr/share/man/man3/ungetc.3			comp-c-man		.man
 ./usr/share/man/man3/ungetch.3			comp-c-man		.man
+./usr/share/man/man3/ungetmouse.3		comp-c-man		.man
 ./usr/share/man/man3/ungetwc.3			comp-c-man		.man
 ./usr/share/man/man3/unistd.3			comp-c-man		.man
 ./usr/share/man/man3/unlockpt.3			comp-c-man		.man
@@ -26447,6 +26469,7 @@
 ./usr/share/man/man3/wdeleteln.3		comp-c-man		.man
 ./usr/share/man/man3/wechochar.3		comp-c-man		.man
 ./usr/share/man/man3/werase.3			comp-c-man		.man
+./usr/share/man/man3/wenclose.3			comp-c-man		.man
 ./usr/share/man/man3/wgetch.3			comp-c-man		.man
 ./usr/share/man/man3/wgetnstr.3			comp-c-man		.man
 ./usr/share/man/man3/wgetstr.3			comp-c-man		.man
@@ -26464,6 +26487,7 @@
 ./usr/share/man/man3/wmemcpy.3			comp-c-man		.man
 ./usr/share/man/man3/wmemmove.3			comp-c-man		.man
 ./usr/share/man/man3/wmemset.3			comp-c-man		.man
+./usr/share/man/man3/wmouse_trafo.3		comp-c-man		.man
 ./usr/share/man/man3/wmove.3			comp-c-man		.man
 ./usr/share/man/man3/wnoutrefresh.3		comp-c-man		.man
 ./usr/share/man/man3/wordexp.3			comp-c-man		.man

Index: src/lib/libcurses/Makefile
diff -u src/lib/libcurses/Makefile:1.93 src/lib/libcurses/Makefile:1.94
--- src/lib/libcurses/Makefile:1.93	Tue Sep  3 13:43:34 2019
+++ src/lib/libcurses/Makefile	Mon Mar 23 13:37:36 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.93 2019/09/03 13:43:34 roy Exp $
+#	$NetBSD: Makefile,v 1.94 2020/03/23 13:37:36 roy Exp $
 #	@(#)Makefile	8.2 (Berkeley) 1/2/94
 
 .include <bsd.own.mk>
@@ -21,7 +21,7 @@ SRCS=	acs.c addbytes.c addch.c addchnstr
 	flushok.c fullname.c getch.c getstr.c getyx.c id_subwins.c idlok.c \
 	idcok.c immedok.c inch.c inchstr.c initscr.c insch.c insdelln.c \
 	insertln.c insstr.c instr.c keypad.c keyname.c leaveok.c line.c \
-	meta.c move.c \
+	meta.c mouse.c move.c \
 	mvwin.c newwin.c nodelay.c notimeout.c overlay.c overwrite.c pause.c \
 	printw.c putchar.c refresh.c resize.c ripoffline.c scanw.c screen.c \
 	scroll.c scrollok.c setterm.c slk.c standout.c syncok.c timeout.c \
@@ -34,7 +34,8 @@ MAN=	curses.3 curses_addch.3 curses_addc
 	curses_cursor.3 curses_default_colors.3 \
 	curses_delch.3 curses_deleteln.3 curses_echochar.3 curses_fileio.3 \
 	curses_inch.3 curses_input.3 curses_insch.3 curses_insertln.3 \
-	curses_insdelln.3 curses_keyname.3 curses_line.3 curses_pad.3 \
+	curses_insdelln.3 curses_keyname.3 curses_line.3 \
+	curses_mouse.3 curses_pad.3 \
 	curses_print.3 curses_refresh.3 curses_scanw.3 curses_screen.3 \
 	curses_scroll.3 curses_slk.3 curses_standout.3 curses_termcap.3 \
 	curses_touch.3 curses_tty.3 curses_underscore.3 curses_version.3 \
@@ -203,7 +204,11 @@ MLINKS+= curses_addch.3 addch.3 curses_a
 	 curses_standout.3 wstandout.3 curses_touch.3 wsyncup.3 \
 	 curses_input.3 wtimeout.3 \
 	 curses_touch.3 wtouchln.3 curses_underscore.3 wunderend.3 \
-	 curses_underscore.3 wunderscore.3 curses_line.3 wvline.3
+	 curses_underscore.3 wunderscore.3 curses_line.3 wvline.3 \
+	 curses_mouse.3 has_mouse.3 \
+	 curses_mouse.3 getmouse.3 curses_mouse.3 ungetmouse.3 \
+	 curses_mouse.3 mouse_trafo.3 curses_mouse.3 wmouse_trafo.3 \
+	 curses_mouse.3 wenclose.3 curses_mouse.3 mouseinterval.3
 
 SUBDIR.roff+= PSD.doc
 

Index: src/lib/libcurses/curses.h
diff -u src/lib/libcurses/curses.h:1.128 src/lib/libcurses/curses.h:1.129
--- src/lib/libcurses/curses.h:1.128	Fri Mar 13 02:57:26 2020
+++ src/lib/libcurses/curses.h	Mon Mar 23 13:37:36 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses.h,v 1.128 2020/03/13 02:57:26 roy Exp $	*/
+/*	$NetBSD: curses.h,v 1.129 2020/03/23 13:37:36 roy Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -980,6 +980,74 @@ bool is_keypad(const WINDOW *);
 bool is_leaveok(const WINDOW *);
 bool is_pad(const WINDOW *);
 
+/* ncurses mouse support */
+#define	NB_MOUSE_MASK(b, m)	((m) << (((b) - 1) * 5))
+#define	NB_BUTTON_RELEASED	001L
+#define	NB_BUTTON_PRESSED	002L
+#define	NB_BUTTON_CLICKED	004L
+#define	NB_DOUBLE_CLICKED	010L
+#define	NB_TRIPLE_CLICKED	020L
+#define	NB_RESERVED_EVENT	040L
+
+#define	BUTTON1_RELEASED	NB_MOUSE_MASK(1, NB_BUTTON_RELEASED)
+#define	BUTTON1_PRESSED		NB_MOUSE_MASK(1, NB_BUTTON_PRESSED)
+#define	BUTTON1_CLICKED		NB_MOUSE_MASK(1, NB_BUTTON_CLICKED)
+#define	BUTTON1_DOUBLE_CLICKED	NB_MOUSE_MASK(1, NB_DOUBLE_CLICKED)
+#define	BUTTON1_TRIPLE_CLICKED	NB_MOUSE_MASK(1, NB_TRIPLE_CLICKED)
+
+#define	BUTTON2_RELEASED	NB_MOUSE_MASK(2, NB_BUTTON_RELEASED)
+#define	BUTTON2_PRESSED		NB_MOUSE_MASK(2, NB_BUTTON_PRESSED)
+#define	BUTTON2_CLICKED		NB_MOUSE_MASK(2, NB_BUTTON_CLICKED)
+#define	BUTTON2_DOUBLE_CLICKED	NB_MOUSE_MASK(2, NB_DOUBLE_CLICKED)
+#define	BUTTON2_TRIPLE_CLICKED	NB_MOUSE_MASK(2, NB_TRIPLE_CLICKED)
+
+#define	BUTTON3_RELEASED	NB_MOUSE_MASK(3, NB_BUTTON_RELEASED)
+#define	BUTTON3_PRESSED		NB_MOUSE_MASK(3, NB_BUTTON_PRESSED)
+#define	BUTTON3_CLICKED		NB_MOUSE_MASK(3, NB_BUTTON_CLICKED)
+#define	BUTTON3_DOUBLE_CLICKED	NB_MOUSE_MASK(3, NB_DOUBLE_CLICKED)
+#define	BUTTON3_TRIPLE_CLICKED	NB_MOUSE_MASK(3, NB_TRIPLE_CLICKED)
+
+#define	BUTTON4_RELEASED	NB_MOUSE_MASK(4, NB_BUTTON_RELEASED)
+#define	BUTTON4_PRESSED		NB_MOUSE_MASK(4, NB_BUTTON_PRESSED)
+#define	BUTTON4_CLICKED		NB_MOUSE_MASK(4, NB_BUTTON_CLICKED)
+#define	BUTTON4_DOUBLE_CLICKED	NB_MOUSE_MASK(4, NB_DOUBLE_CLICKED)
+#define	BUTTON4_TRIPLE_CLICKED	NB_MOUSE_MASK(4, NB_TRIPLE_CLICKED)
+
+#define	BUTTON5_RELEASED	NB_MOUSE_MASK(5, NB_BUTTON_RELEASED)
+#define	BUTTON5_PRESSED		NB_MOUSE_MASK(5, NB_BUTTON_PRESSED)
+#define	BUTTON5_CLICKED		NB_MOUSE_MASK(5, NB_BUTTON_CLICKED)
+#define	BUTTON5_DOUBLE_CLICKED	NB_MOUSE_MASK(5, NB_DOUBLE_CLICKED)
+#define	BUTTON5_TRIPLE_CLICKED	NB_MOUSE_MASK(5, NB_TRIPLE_CLICKED)
+
+#define	BUTTON_CTRL		NB_MOUSE_MASK(6, 0001L)
+#define	BUTTON_SHIFT		NB_MOUSE_MASK(6, 0002L)
+#define	BUTTON_ALT		NB_MOUSE_MASK(6, 0004L)
+#define	REPORT_MOUSE_POSITION	NB_MOUSE_MASK(6, 0010L)
+#define	ALL_MOUSE_EVENTS	(REPORT_MOUSE_POSITION - 1)
+
+#define	BUTTON_RELEASE(e, x)		((e) & NB_MOUSE_MASK(x, 001))
+#define	BUTTON_PRESS(e, x)		((e) & NB_MOUSE_MASK(x, 002))
+#define	BUTTON_CLICK(e, x)		((e) & NB_MOUSE_MASK(x, 004))
+#define	BUTTON_DOUBLE_CLICK(e, x)	((e) & NB_MOUSE_MASK(x, 010))
+#define	BUTTON_TRIPLE_CLICK(e, x)	((e) & NB_MOUSE_MASK(x, 020))
+#define	BUTTON_RESERVED_EVENT(e, x)	((e) & NB_MOUSE_MASK(x, 040))
+
+typedef unsigned long mmask_t;
+typedef struct {
+	short id;	/* ID to distinguish multiple devices */
+	int x, y, z;	/* event coordinates */
+	mmask_t bstate;   /* button state bits */
+} MEVENT;
+
+bool has_mouse(void);
+int getmouse(MEVENT *);
+int ungetmouse(MEVENT *);
+mmask_t mousemask(mmask_t, mmask_t *);
+bool wenclose(const WINDOW *, int, int);
+bool mouse_trafo(int *, int *, bool);
+bool wmouse_trafo(const WINDOW *, int *, int *, bool);
+int mouseinterval(int);
+
 /* ncurses version for compat */
 const char *curses_version(void);
 

Added files:

Index: src/lib/libcurses/mouse.c
diff -u /dev/null src/lib/libcurses/mouse.c:1.1
--- /dev/null	Mon Mar 23 13:37:37 2020
+++ src/lib/libcurses/mouse.c	Mon Mar 23 13:37:36 2020
@@ -0,0 +1,125 @@
+/*	$NetBSD: mouse.c,v 1.1 2020/03/23 13:37:36 roy Exp $	*/
+
+/*-
+ * Copyright (c) 2020 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Roy Marples.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#ifndef lint
+__RCSID("$NetBSD: mouse.c,v 1.1 2020/03/23 13:37:36 roy Exp $");
+#endif				/* not lint */
+
+#include "curses.h"
+#include "curses_private.h"
+
+#define	DEFAULT_MAXCLICK	166	/* ncurses default */
+
+/*
+ * Return true if screen relative y and x are enclosed by the window.
+ */
+bool
+wenclose(const WINDOW *win, int y, int x)
+{
+
+	if (y < win->begy || y > win->begy + win->maxy ||
+	    x < win->begx || x > win->begx + win->maxx)
+		return false;
+	return true;
+}
+
+bool
+mouse_trafo(int *y, int *x, bool to_screen)
+{
+
+	return wmouse_trafo(stdscr, y, x, to_screen);
+}
+
+/*
+ * Transform y and x from screen relative to window relative
+ */
+bool wmouse_trafo(const WINDOW *win, int *y, int *x, bool to_screen)
+{
+	int wy = *y, wx = *x;
+
+	if (to_screen) {
+		wy += win->begy;
+		wx += win->begx;
+	}
+
+	if (!wenclose(win, wy, wx))
+		return false;
+
+	if (!to_screen) {
+		wy -= win->begy;
+		wx -= win->begx;
+	}
+
+	*y = wy;
+	*x = wx;
+	return true;
+}
+
+/*
+ * The below functions actually need some kind of mouse support.
+ * We should look into wsmouse(4) support at least as well as xterm.
+ */
+
+bool
+has_mouse(void)
+{
+
+	return false;
+}
+
+int
+getmouse(__unused MEVENT *event)
+{
+
+	return ERR;
+}
+
+int
+ungetmouse(__unused MEVENT *event)
+{
+
+	return ERR;
+}
+
+mmask_t
+mousemask(__unused mmask_t newmask, __unused mmask_t *oldmask)
+{
+
+	return 0;
+}
+
+int
+mouseinterval(__unused int erval)
+{
+
+	return DEFAULT_MAXCLICK;
+}

Reply via email to