From ab9da248d46a8e2da20cc69bc0c450811c5b1973 Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Sat, 4 Jun 2005 19:02:23 +0000
Subject: [PATCH] Fix K_DEUCEEXIT (Was defined the same as K_DECIMAL!) and
 define its behavious better. Add WIN_UNGETMOUSE which, when the mouse is
 clicked outside the window ungets the mouse event and returns -2-WINMOUSE

---
 src/uifc/uifc.h   |  6 ++++--
 src/uifc/uifc32.c | 10 ++++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/uifc/uifc.h b/src/uifc/uifc.h
index a0c9ec6e32..2e317d4a00 100644
--- a/src/uifc/uifc.h
+++ b/src/uifc/uifc.h
@@ -191,6 +191,8 @@
 							 * Return value is -2 - keyvalue */
 #define WIN_NOBRDR	(1<<24)	/* Do not draw a border around the window */
 #define WIN_FIXEDHEIGHT	(1<<25)	/* Use list_height from uifc struct */
+#define WIN_UNGETMOUSE  (1<<26) /* If the mouse is clicked outside the window, */
+								/* Put the mouse event back into the event queue */
 
 #define WIN_MID WIN_L2R|WIN_T2B  /* Place window in middle of screen */
 
@@ -213,8 +215,8 @@
 #define K_SCANNING	(1L<<11)	/* UPC Scanner is active... return on '%'	*/
 #define K_TABEXIT	(1L<<12)	/* Return on TAB or BACKTAB			    	*/
 #define K_DECIMAL	(1L<<13)	/* Allow floating point numbers only		*/
-#define K_DEUCEEXIT	(1L<<13)	/* Return whenever Deuce wants to exit		*/
-								/* Define this behaviour better - ToDo		*/
+#define K_DEUCEEXIT	(1L<<14)	/* Return whenever Deuce wants to exit		*/
+								/* Returns on up/down/F2					*/
 
 #define HELPBUF_SIZE 4000
 
diff --git a/src/uifc/uifc32.c b/src/uifc/uifc32.c
index 6d13a266d2..c27f48789c 100644
--- a/src/uifc/uifc32.c
+++ b/src/uifc/uifc32.c
@@ -957,8 +957,14 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
 							|| mevnt.starty<s_top+top
 							|| mevnt.starty>s_top+top+height-1)
 							&& (mevnt.event==CIOLIB_BUTTON_1_CLICK
-							|| mevnt.event==CIOLIB_BUTTON_3_CLICK))
-						i=ESC;
+							|| mevnt.event==CIOLIB_BUTTON_3_CLICK)) {
+						if(mode&WIN_UNGETMOUSE) {
+							ungetmouse(mevnt);
+						}
+						else {
+							i=ESC;
+						}
+					}
 				}
 			}
 			/* For compatibility with terminals lacking special keys */
-- 
GitLab