summaryrefslogtreecommitdiff
path: root/lib/libcurses/base
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1999-12-28 15:58:00 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1999-12-28 15:58:00 +0000
commit29b9ba0641956d02f20ecf79f3c5012baf5bd8e8 (patch)
treec060b138de336bc24abca99acb5a4d7c2753dd31 /lib/libcurses/base
parent031c7ae2dc97a1f984a63e6e5c37a962a15b01e2 (diff)
Update to ncurses-19991218
o reorder tests during mouse initialization to allow for gpm to run in xterm, or for xterm to be used under OS/2 EMX. Also drop test for $DISPLAY in favor of kmous=\E[M or $TERM containing "xterm" (report by Christian Weisgerber <naddy@mips.rhein-neckar.de>). o modify raw() and noraw() to clear/restore IEXTEN flag which affects stty lnext on systems such as FreeBSD (report by Bruce Evans <bde@zeta.org.au>, via Jason Evans <jasone@canonware.com>). o add manual-page for ncurses extensions, documented curses_version(), use_extended_names().
Diffstat (limited to 'lib/libcurses/base')
-rw-r--r--lib/libcurses/base/lib_mouse.c481
1 files changed, 246 insertions, 235 deletions
diff --git a/lib/libcurses/base/lib_mouse.c b/lib/libcurses/base/lib_mouse.c
index b0263f20cdb..e3ef84222d5 100644
--- a/lib/libcurses/base/lib_mouse.c
+++ b/lib/libcurses/base/lib_mouse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_mouse.c,v 1.5 1999/11/28 17:49:53 millert Exp $ */
+/* $OpenBSD: lib_mouse.c,v 1.6 1999/12/28 15:57:59 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999 Free Software Foundation, Inc. *
@@ -87,13 +87,13 @@
#endif
#endif
-MODULE_ID("$From: lib_mouse.c,v 1.45 1999/10/22 21:39:02 tom Exp $")
+MODULE_ID("$From: lib_mouse.c,v 1.47 1999/12/19 01:49:40 tom Exp $")
#define MY_TRACE TRACE_ICALLS|TRACE_IEVENT
#define INVALID_EVENT -1
-static int mousetype;
+static int mousetype;
#define M_XTERM -1 /* use xterm's mouse tracking? */
#define M_NONE 0 /* no mouse device */
#define M_GPM 1 /* use GPM */
@@ -106,7 +106,7 @@ static Gpm_Connect gpm_connect;
#endif
#endif
-static mmask_t eventmask; /* current event mask */
+static mmask_t eventmask; /* current event mask */
static bool _nc_mouse_parse(int);
static void _nc_mouse_resume(SCREEN *);
@@ -118,22 +118,23 @@ static void _nc_mouse_wrap(SCREEN *);
* wgetch() may refer to the size and call _nc_mouse_parse() before circular
* list overflow.
*/
-static MEVENT events[EV_MAX]; /* hold the last mouse event seen */
-static MEVENT *eventp = events; /* next free slot in event queue */
+static MEVENT events[EV_MAX]; /* hold the last mouse event seen */
+static MEVENT *eventp = events; /* next free slot in event queue */
#define NEXT(ep) ((ep == events + EV_MAX - 1) ? events : ep + 1)
#define PREV(ep) ((ep == events) ? events + EV_MAX - 1 : ep - 1)
#ifdef TRACE
-static void _trace_slot(const char *tag)
+static void
+_trace_slot(const char *tag)
{
- MEVENT *ep;
+ MEVENT *ep;
- _tracef(tag);
+ _tracef(tag);
- for (ep = events; ep < events + EV_MAX; ep++)
- _tracef("mouse event queue slot %ld = %s",
- (long) (ep - events),
- _tracemouse(ep));
+ for (ep = events; ep < events + EV_MAX; ep++)
+ _tracef("mouse event queue slot %ld = %s",
+ (long) (ep - events),
+ _tracemouse(ep));
}
#endif
@@ -145,8 +146,8 @@ static void _trace_slot(const char *tag)
static int mouse_wfd;
static int mouse_thread;
static int mouse_activated;
-static char mouse_buttons[] = { 0, 1, 3, 2};
-
+static char mouse_buttons[] =
+{0, 1, 3, 2};
# define M_FD(sp) sp->_mouse_fd
@@ -176,34 +177,34 @@ mouse_server(unsigned long ignored GCC_UNUSED)
unsigned long ignore;
/* open the handle for the mouse */
- if (MouOpen(NULL,&hmou) == 0) {
+ if (MouOpen(NULL, &hmou) == 0) {
- if (MouSetEventMask(&mask,hmou) == 0
- && MouDrawPtr(hmou) == 0) {
+ if (MouSetEventMask(&mask, hmou) == 0
+ && MouDrawPtr(hmou) == 0) {
for (;;) {
/* sit and wait on the event queue */
- if (MouReadEventQue(&mouev,&fWait,hmou))
- break;
+ if (MouReadEventQue(&mouev, &fWait, hmou))
+ break;
if (!mouse_activated)
goto finish;
/*
* OS/2 numbers a 3-button mouse inconsistently from other
* platforms:
- * 1 = left
- * 2 = right
- * 3 = middle.
+ * 1 = left
+ * 2 = right
+ * 3 = middle.
*/
if ((mouev.fs ^ oldstate) & MOUSE_BN1_DOWN)
- write_event(mouev.fs & MOUSE_BN1_DOWN,
- mouse_buttons[1], mouev.col, mouev.row);
+ write_event(mouev.fs & MOUSE_BN1_DOWN,
+ mouse_buttons[1], mouev.col, mouev.row);
if ((mouev.fs ^ oldstate) & MOUSE_BN2_DOWN)
- write_event(mouev.fs & MOUSE_BN2_DOWN,
- mouse_buttons[3], mouev.col, mouev.row);
+ write_event(mouev.fs & MOUSE_BN2_DOWN,
+ mouse_buttons[3], mouev.col, mouev.row);
if ((mouev.fs ^ oldstate) & MOUSE_BN3_DOWN)
- write_event(mouev.fs & MOUSE_BN3_DOWN,
- mouse_buttons[2], mouev.col, mouev.row);
+ write_event(mouev.fs & MOUSE_BN3_DOWN,
+ mouse_buttons[2], mouev.col, mouev.row);
finish:
oldstate = mouev.fs;
@@ -213,11 +214,11 @@ mouse_server(unsigned long ignored GCC_UNUSED)
DosWrite(2, errmess, strlen(errmess), &ignore);
MouClose(hmou);
}
- DosExit(EXIT_THREAD, 0L );
+ DosExit(EXIT_THREAD, 0L);
}
static void
server_state(const int state)
-{ /* It would be nice to implement pointer-off and stop looping... */
+{ /* It would be nice to implement pointer-off and stop looping... */
mouse_activated = state;
}
@@ -225,44 +226,30 @@ server_state(const int state)
static int initialized;
-static void _nc_mouse_init(void)
-/* initialize the mouse */
+static void
+initialize_mousetype(void)
{
- int i;
-
- if (initialized) {
- return;
- }
- initialized = TRUE;
-
- TR(MY_TRACE, ("_nc_mouse_init() called"));
-
- for (i = 0; i < EV_MAX; i++)
- events[i].id = INVALID_EVENT;
-
- /* we know how to recognize mouse events under xterm */
- if (key_mouse != 0
- && getenv("DISPLAY") != 0)
- mousetype = M_XTERM;
+ static char *xterm_kmous = "\033[M";
+ /* Try gpm first, because gpm may be configured to run in xterm */
#if USE_GPM_SUPPORT
- else if (!strncmp(cur_term->type.term_names, "linux", 5))
- {
- /* GPM: initialize connection to gpm server */
- gpm_connect.eventMask = GPM_DOWN|GPM_UP;
- gpm_connect.defaultMask = ~(gpm_connect.eventMask|GPM_HARD);
- gpm_connect.minMod = 0;
- gpm_connect.maxMod = ~((1<<KG_SHIFT)|(1<<KG_SHIFTL)|(1<<KG_SHIFTR));
- if (Gpm_Open (&gpm_connect, 0) >= 0) { /* returns the file-descriptor */
- mousetype = M_GPM;
- SP->_mouse_fd = gpm_fd;
- }
+ /* GPM: initialize connection to gpm server */
+ gpm_connect.eventMask = GPM_DOWN | GPM_UP;
+ gpm_connect.defaultMask = ~(gpm_connect.eventMask | GPM_HARD);
+ gpm_connect.minMod = 0;
+ gpm_connect.maxMod = ~((1 << KG_SHIFT) | (1 << KG_SHIFTL) | (1 << KG_SHIFTR));
+ if (Gpm_Open(&gpm_connect, 0) >= 0) { /* returns the file-descriptor */
+ mousetype = M_GPM;
+ SP->_mouse_fd = gpm_fd;
+ return;
}
#endif
/* OS/2 VIO */
#ifdef USE_EMX_MOUSE
- if (!mouse_thread && mousetype != M_XTERM && key_mouse) {
+ if (!mouse_thread
+ && strstr(cur_term->type.term_names, "xterm") == 0
+ && key_mouse) {
int handles[2];
if (pipe(handles) < 0) {
perror("mouse pipe error");
@@ -285,19 +272,53 @@ static void _nc_mouse_init(void)
setmode(handles[0], O_BINARY);
setmode(handles[1], O_BINARY);
/* Do not use CRT functions, we may single-threaded. */
- rc = DosCreateThread((unsigned long*)&mouse_thread, mouse_server, 0, 0, 8192);
- if (rc)
+ rc = DosCreateThread((unsigned long *) &mouse_thread,
+ mouse_server, 0, 0, 8192);
+ if (rc) {
printf("mouse thread error %d=%#x", rc, rc);
- else
+ } else {
mousetype = M_XTERM;
+ return;
+ }
}
}
#endif
- T(("_nc_mouse_init() set mousetype to %d", mousetype));
+ /* we know how to recognize mouse events under "xterm" */
+ if (key_mouse != 0) {
+ if (!strcmp(key_mouse, xterm_kmous)) {
+ mousetype = M_XTERM;
+ return;
+ }
+ } else if (strstr(cur_term->type.term_names, "xterm") != 0) {
+ (void) _nc_add_to_try(&(SP->_keytry), xterm_kmous, KEY_MOUSE);
+ mousetype = M_XTERM;
+ return;
+ }
+}
+
+static void
+_nc_mouse_init(void)
+/* initialize the mouse */
+{
+ int i;
+
+ if (!initialized) {
+ initialized = TRUE;
+
+ TR(MY_TRACE, ("_nc_mouse_init() called"));
+
+ for (i = 0; i < EV_MAX; i++)
+ events[i].id = INVALID_EVENT;
+
+ initialize_mousetype();
+
+ T(("_nc_mouse_init() set mousetype to %d", mousetype));
+ }
}
-static bool _nc_mouse_event(SCREEN *sp GCC_UNUSED)
+static bool
+_nc_mouse_event(SCREEN * sp GCC_UNUSED)
/* query to see if there is a pending mouse event */
{
#if USE_GPM_SUPPORT
@@ -305,23 +326,27 @@ static bool _nc_mouse_event(SCREEN *sp GCC_UNUSED)
Gpm_Event ev;
if (gpm_fd >= 0
- && _nc_timed_wait(2, 0, (int *)0)
- && Gpm_GetEvent(&ev) == 1)
- {
+ && _nc_timed_wait(2, 0, (int *) 0)
+ && Gpm_GetEvent(&ev) == 1) {
eventp->id = 0; /* there's only one mouse... */
eventp->bstate = 0;
- switch (ev.type & 0x0f)
- {
- case(GPM_DOWN):
- if (ev.buttons & GPM_B_LEFT) eventp->bstate |= BUTTON1_PRESSED;
- if (ev.buttons & GPM_B_MIDDLE) eventp->bstate |= BUTTON2_PRESSED;
- if (ev.buttons & GPM_B_RIGHT) eventp->bstate |= BUTTON3_PRESSED;
+ switch (ev.type & 0x0f) {
+ case (GPM_DOWN):
+ if (ev.buttons & GPM_B_LEFT)
+ eventp->bstate |= BUTTON1_PRESSED;
+ if (ev.buttons & GPM_B_MIDDLE)
+ eventp->bstate |= BUTTON2_PRESSED;
+ if (ev.buttons & GPM_B_RIGHT)
+ eventp->bstate |= BUTTON3_PRESSED;
break;
- case(GPM_UP):
- if (ev.buttons & GPM_B_LEFT) eventp->bstate |= BUTTON1_RELEASED;
- if (ev.buttons & GPM_B_MIDDLE) eventp->bstate |= BUTTON2_RELEASED;
- if (ev.buttons & GPM_B_RIGHT) eventp->bstate |= BUTTON3_RELEASED;
+ case (GPM_UP):
+ if (ev.buttons & GPM_B_LEFT)
+ eventp->bstate |= BUTTON1_RELEASED;
+ if (ev.buttons & GPM_B_MIDDLE)
+ eventp->bstate |= BUTTON2_RELEASED;
+ if (ev.buttons & GPM_B_RIGHT)
+ eventp->bstate |= BUTTON3_RELEASED;
break;
default:
break;
@@ -338,20 +363,20 @@ static bool _nc_mouse_event(SCREEN *sp GCC_UNUSED)
#endif
/* xterm: never have to query, mouse events are in the keyboard stream */
- return(FALSE); /* no event waiting */
+ return (FALSE); /* no event waiting */
}
-static bool _nc_mouse_inline(SCREEN *sp)
+static bool
+_nc_mouse_inline(SCREEN * sp)
/* mouse report received in the keyboard stream -- parse its info */
{
TR(MY_TRACE, ("_nc_mouse_inline() called"));
- if (mousetype == M_XTERM)
- {
- unsigned char kbuf[4];
- MEVENT *prev;
- size_t grabbed;
- int res;
+ if (mousetype == M_XTERM) {
+ unsigned char kbuf[4];
+ MEVENT *prev;
+ size_t grabbed;
+ int res;
/* This code requires that your xterm entry contain the kmous
* capability and that it be set to the \E[M documented in the
@@ -383,28 +408,27 @@ static bool _nc_mouse_inline(SCREEN *sp)
* single clist item. It always does under Linux but often
* fails to under Solaris.
*/
- for (grabbed = 0; grabbed < 3; grabbed += res)
- {
+ for (grabbed = 0; grabbed < 3; grabbed += res) {
- /* For VIO mouse we add extra bit 64 to disambiguate button-up. */
+ /* For VIO mouse we add extra bit 64 to disambiguate button-up. */
#ifdef USE_EMX_MOUSE
- res = read( M_FD(sp) >= 0 ? M_FD(sp) : sp->_ifd, &kbuf, 3);
+ res = read(M_FD(sp) >= 0 ? M_FD(sp) : sp->_ifd, &kbuf, 3);
#else
- res = read(sp->_ifd, kbuf + grabbed, 3-grabbed);
+ res = read(sp->_ifd, kbuf + grabbed, 3 - grabbed);
#endif
- if (res == -1)
- break;
+ if (res == -1)
+ break;
}
kbuf[3] = '\0';
- TR(TRACE_IEVENT, ("_nc_mouse_inline sees the following xterm data: '%s'", kbuf));
+ TR(TRACE_IEVENT,
+ ("_nc_mouse_inline sees the following xterm data: '%s'", kbuf));
eventp->id = 0; /* there's only one mouse... */
/* processing code goes here */
eventp->bstate = 0;
- switch (kbuf[0] & 0x3)
- {
+ switch (kbuf[0] & 0x3) {
case 0x0:
eventp->bstate = BUTTON1_PRESSED;
#ifdef USE_EMX_MOUSE
@@ -436,8 +460,8 @@ static bool _nc_mouse_inline(SCREEN *sp)
*/
eventp->bstate =
(BUTTON1_RELEASED |
- BUTTON2_RELEASED |
- BUTTON3_RELEASED);
+ BUTTON2_RELEASED |
+ BUTTON3_RELEASED);
/*
* ...however, because there are no kinds of mouse events under
* xterm that can intervene between press and release, we can
@@ -446,11 +470,11 @@ static bool _nc_mouse_inline(SCREEN *sp)
*/
prev = PREV(eventp);
if (!(prev->bstate & BUTTON1_PRESSED))
- eventp->bstate &=~ BUTTON1_RELEASED;
+ eventp->bstate &= ~BUTTON1_RELEASED;
if (!(prev->bstate & BUTTON2_PRESSED))
- eventp->bstate &=~ BUTTON2_RELEASED;
+ eventp->bstate &= ~BUTTON2_RELEASED;
if (!(prev->bstate & BUTTON3_PRESSED))
- eventp->bstate &=~ BUTTON3_RELEASED;
+ eventp->bstate &= ~BUTTON3_RELEASED;
break;
}
@@ -466,21 +490,23 @@ static bool _nc_mouse_inline(SCREEN *sp)
eventp->x = (kbuf[1] - ' ') - 1;
eventp->y = (kbuf[2] - ' ') - 1;
- TR(MY_TRACE, ("_nc_mouse_inline: primitive mouse-event %s has slot %ld",
+ TR(MY_TRACE,
+ ("_nc_mouse_inline: primitive mouse-event %s has slot %ld",
_tracemouse(eventp),
(long) (eventp - events)));
/* bump the next-free pointer into the circular list */
eventp = NEXT(eventp);
-#if 0 /* this return would be needed for QNX's mods to lib_getch.c */
- return(TRUE);
+#if 0 /* this return would be needed for QNX's mods to lib_getch.c */
+ return (TRUE);
#endif
}
- return(FALSE);
+ return (FALSE);
}
-static void mouse_activate(bool on)
+static void
+mouse_activate(bool on)
{
if (!on && !initialized)
return;
@@ -510,11 +536,11 @@ static void mouse_activate(bool on)
/* Make runtime binding to cut down on object size of applications that
* do not use the mouse (e.g., 'clear').
*/
- SP->_mouse_event = _nc_mouse_event;
+ SP->_mouse_event = _nc_mouse_event;
SP->_mouse_inline = _nc_mouse_inline;
- SP->_mouse_parse = _nc_mouse_parse;
+ SP->_mouse_parse = _nc_mouse_parse;
SP->_mouse_resume = _nc_mouse_resume;
- SP->_mouse_wrap = _nc_mouse_wrap;
+ SP->_mouse_wrap = _nc_mouse_wrap;
} else {
@@ -542,12 +568,13 @@ static void mouse_activate(bool on)
*
**************************************************************************/
-static bool _nc_mouse_parse(int runcount)
+static bool
+_nc_mouse_parse(int runcount)
/* parse a run of atomic mouse events into a gesture */
{
- MEVENT *ep, *runp, *next, *prev = PREV(eventp);
- int n;
- bool merge;
+ MEVENT *ep, *runp, *next, *prev = PREV(eventp);
+ int n;
+ bool merge;
TR(MY_TRACE, ("_nc_mouse_parse(%d) called", runcount));
@@ -572,14 +599,14 @@ static bool _nc_mouse_parse(int runcount)
* button basis, as long as the device-dependent mouse code puts stuff
* on the queue in MEVENT format.
*/
- if (runcount == 1)
- {
- TR(MY_TRACE, ("_nc_mouse_parse: returning simple mouse event %s at slot %ld",
- _tracemouse(prev),
- (long) (prev - events)));
+ if (runcount == 1) {
+ TR(MY_TRACE,
+ ("_nc_mouse_parse: returning simple mouse event %s at slot %ld",
+ _tracemouse(prev),
+ (long) (prev - events)));
return (prev->id >= 0)
- ? ((prev->bstate & eventmask) ? TRUE : FALSE)
- : FALSE;
+ ? ((prev->bstate & eventmask) ? TRUE : FALSE)
+ : FALSE;
}
/* find the start of the run */
@@ -589,12 +616,11 @@ static bool _nc_mouse_parse(int runcount)
}
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT)
- {
+ if (_nc_tracing & TRACE_IEVENT) {
_trace_slot("before mouse press/release merge:");
_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
(long) (runp - events),
- (long) ((eventp - events) + (EV_MAX-1)) % EV_MAX,
+ (long) ((eventp - events) + (EV_MAX - 1)) % EV_MAX,
runcount);
}
#endif /* TRACE */
@@ -602,36 +628,31 @@ static bool _nc_mouse_parse(int runcount)
/* first pass; merge press/release pairs */
do {
merge = FALSE;
- for (ep = runp; next = NEXT(ep), next != eventp; ep = next)
- {
+ for (ep = runp; next = NEXT(ep), next != eventp; ep = next) {
if (ep->x == next->x && ep->y == next->y
- && (ep->bstate & (BUTTON1_PRESSED|BUTTON2_PRESSED|BUTTON3_PRESSED))
+ && (ep->bstate & (BUTTON1_PRESSED | BUTTON2_PRESSED | BUTTON3_PRESSED))
&& (!(ep->bstate & BUTTON1_PRESSED)
== !(next->bstate & BUTTON1_RELEASED))
&& (!(ep->bstate & BUTTON2_PRESSED)
== !(next->bstate & BUTTON2_RELEASED))
&& (!(ep->bstate & BUTTON3_PRESSED)
== !(next->bstate & BUTTON3_RELEASED))
- )
- {
+ ) {
if ((eventmask & BUTTON1_CLICKED)
- && (ep->bstate & BUTTON1_PRESSED))
- {
- ep->bstate &=~ BUTTON1_PRESSED;
+ && (ep->bstate & BUTTON1_PRESSED)) {
+ ep->bstate &= ~BUTTON1_PRESSED;
ep->bstate |= BUTTON1_CLICKED;
merge = TRUE;
}
if ((eventmask & BUTTON2_CLICKED)
- && (ep->bstate & BUTTON2_PRESSED))
- {
- ep->bstate &=~ BUTTON2_PRESSED;
+ && (ep->bstate & BUTTON2_PRESSED)) {
+ ep->bstate &= ~BUTTON2_PRESSED;
ep->bstate |= BUTTON2_CLICKED;
merge = TRUE;
}
if ((eventmask & BUTTON3_CLICKED)
- && (ep->bstate & BUTTON3_PRESSED))
- {
- ep->bstate &=~ BUTTON3_PRESSED;
+ && (ep->bstate & BUTTON3_PRESSED)) {
+ ep->bstate &= ~BUTTON3_PRESSED;
ep->bstate |= BUTTON3_CLICKED;
merge = TRUE;
}
@@ -643,12 +664,11 @@ static bool _nc_mouse_parse(int runcount)
(merge);
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT)
- {
+ if (_nc_tracing & TRACE_IEVENT) {
_trace_slot("before mouse click merge:");
_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
(long) (runp - events),
- (long) ((eventp - events) + (EV_MAX-1)) % EV_MAX,
+ (long) ((eventp - events) + (EV_MAX - 1)) % EV_MAX,
runcount);
}
#endif /* TRACE */
@@ -670,12 +690,11 @@ static bool _nc_mouse_parse(int runcount)
* which would get us into portability trouble.
*/
do {
- MEVENT *follower;
+ MEVENT *follower;
merge = FALSE;
for (ep = runp; next = NEXT(ep), next != eventp; ep = next)
- if (ep->id != INVALID_EVENT)
- {
+ if (ep->id != INVALID_EVENT) {
if (next->id != INVALID_EVENT)
continue;
follower = NEXT(next);
@@ -686,26 +705,22 @@ static bool _nc_mouse_parse(int runcount)
if ((ep->bstate &
(BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED))
&& (follower->bstate &
- (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED)))
- {
+ (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED))) {
if ((eventmask & BUTTON1_DOUBLE_CLICKED)
- && (follower->bstate & BUTTON1_CLICKED))
- {
- follower->bstate &=~ BUTTON1_CLICKED;
+ && (follower->bstate & BUTTON1_CLICKED)) {
+ follower->bstate &= ~BUTTON1_CLICKED;
follower->bstate |= BUTTON1_DOUBLE_CLICKED;
merge = TRUE;
}
if ((eventmask & BUTTON2_DOUBLE_CLICKED)
- && (follower->bstate & BUTTON2_CLICKED))
- {
- follower->bstate &=~ BUTTON2_CLICKED;
+ && (follower->bstate & BUTTON2_CLICKED)) {
+ follower->bstate &= ~BUTTON2_CLICKED;
follower->bstate |= BUTTON2_DOUBLE_CLICKED;
merge = TRUE;
}
if ((eventmask & BUTTON3_DOUBLE_CLICKED)
- && (follower->bstate & BUTTON3_CLICKED))
- {
- follower->bstate &=~ BUTTON3_CLICKED;
+ && (follower->bstate & BUTTON3_CLICKED)) {
+ follower->bstate &= ~BUTTON3_CLICKED;
follower->bstate |= BUTTON3_DOUBLE_CLICKED;
merge = TRUE;
}
@@ -716,29 +731,25 @@ static bool _nc_mouse_parse(int runcount)
/* merge double-click events forward */
if ((ep->bstate &
(BUTTON1_DOUBLE_CLICKED
- | BUTTON2_DOUBLE_CLICKED
- | BUTTON3_DOUBLE_CLICKED))
+ | BUTTON2_DOUBLE_CLICKED
+ | BUTTON3_DOUBLE_CLICKED))
&& (follower->bstate &
- (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED)))
- {
+ (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED))) {
if ((eventmask & BUTTON1_TRIPLE_CLICKED)
- && (follower->bstate & BUTTON1_CLICKED))
- {
- follower->bstate &=~ BUTTON1_CLICKED;
+ && (follower->bstate & BUTTON1_CLICKED)) {
+ follower->bstate &= ~BUTTON1_CLICKED;
follower->bstate |= BUTTON1_TRIPLE_CLICKED;
merge = TRUE;
}
if ((eventmask & BUTTON2_TRIPLE_CLICKED)
- && (follower->bstate & BUTTON2_CLICKED))
- {
- follower->bstate &=~ BUTTON2_CLICKED;
+ && (follower->bstate & BUTTON2_CLICKED)) {
+ follower->bstate &= ~BUTTON2_CLICKED;
follower->bstate |= BUTTON2_TRIPLE_CLICKED;
merge = TRUE;
}
if ((eventmask & BUTTON3_TRIPLE_CLICKED)
- && (follower->bstate & BUTTON3_CLICKED))
- {
- follower->bstate &=~ BUTTON3_CLICKED;
+ && (follower->bstate & BUTTON3_CLICKED)) {
+ follower->bstate &= ~BUTTON3_CLICKED;
follower->bstate |= BUTTON3_TRIPLE_CLICKED;
merge = TRUE;
}
@@ -750,12 +761,11 @@ static bool _nc_mouse_parse(int runcount)
(merge);
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT)
- {
+ if (_nc_tracing & TRACE_IEVENT) {
_trace_slot("before mouse event queue compaction:");
_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
(long) (runp - events),
- (long) ((eventp - events) + (EV_MAX-1)) % EV_MAX,
+ (long) ((eventp - events) + (EV_MAX - 1)) % EV_MAX,
runcount);
}
#endif /* TRACE */
@@ -768,28 +778,28 @@ static bool _nc_mouse_parse(int runcount)
if (prev->id == INVALID_EVENT || !(prev->bstate & eventmask)) {
eventp = prev;
}
-
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT)
- {
+ if (_nc_tracing & TRACE_IEVENT) {
_trace_slot("after mouse event queue compaction:");
_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
(long) (runp - events),
- (long) ((eventp - events) + (EV_MAX-1)) % EV_MAX,
+ (long) ((eventp - events) + (EV_MAX - 1)) % EV_MAX,
runcount);
}
for (ep = runp; ep != eventp; ep = NEXT(ep))
if (ep->id != INVALID_EVENT)
- TR(MY_TRACE, ("_nc_mouse_parse: returning composite mouse event %s at slot %ld",
- _tracemouse(ep),
- (long) (ep - events)));
+ TR(MY_TRACE,
+ ("_nc_mouse_parse: returning composite mouse event %s at slot %ld",
+ _tracemouse(ep),
+ (long) (ep - events)));
#endif /* TRACE */
/* after all this, do we have a valid event? */
- return(PREV(eventp)->id != INVALID_EVENT);
+ return (PREV(eventp)->id != INVALID_EVENT);
}
-static void _nc_mouse_wrap(SCREEN *sp GCC_UNUSED)
+static void
+_nc_mouse_wrap(SCREEN * sp GCC_UNUSED)
/* release mouse -- called by endwin() before shellout/exit */
{
TR(MY_TRACE, ("_nc_mouse_wrap() called"));
@@ -801,13 +811,14 @@ static void _nc_mouse_wrap(SCREEN *sp GCC_UNUSED)
break;
#if USE_GPM_SUPPORT
/* GPM: pass all mouse events to next client */
- case M_GPM:
- break;
+ case M_GPM:
+ break;
#endif
}
}
-static void _nc_mouse_resume(SCREEN *sp GCC_UNUSED)
+static void
+_nc_mouse_resume(SCREEN * sp GCC_UNUSED)
/* re-connect to mouse -- called by doupdate() after shellout */
{
TR(MY_TRACE, ("_nc_mouse_resume() called"));
@@ -825,22 +836,22 @@ static void _nc_mouse_resume(SCREEN *sp GCC_UNUSED)
*
**************************************************************************/
-int getmouse(MEVENT *aevent)
+int
+getmouse(MEVENT * aevent)
/* grab a copy of the current mouse event */
{
T((T_CALLED("getmouse(%p)"), aevent));
- if (aevent && (mousetype != M_NONE))
- {
+ if (aevent && (mousetype != M_NONE)) {
/* compute the current-event pointer */
- MEVENT *prev = PREV(eventp);
+ MEVENT *prev = PREV(eventp);
/* copy the event we find there */
*aevent = *prev;
TR(TRACE_IEVENT, ("getmouse: returning event %s from slot %ld",
- _tracemouse(prev),
- (long) (prev - events)));
+ _tracemouse(prev),
+ (long) (prev - events)));
prev->id = INVALID_EVENT; /* so the queue slot becomes free */
returnCode(OK);
@@ -848,7 +859,8 @@ int getmouse(MEVENT *aevent)
returnCode(ERR);
}
-int ungetmouse(MEVENT *aevent)
+int
+ungetmouse(MEVENT * aevent)
/* enqueue a synthesized mouse event to be seen by the next wgetch() */
{
/* stick the given event in the next-free slot */
@@ -861,7 +873,8 @@ int ungetmouse(MEVENT *aevent)
return ungetch(KEY_MOUSE);
}
-mmask_t mousemask(mmask_t newmask, mmask_t *oldmask)
+mmask_t
+mousemask(mmask_t newmask, mmask_t * oldmask)
/* set the mouse event mask */
{
mmask_t result = 0;
@@ -875,16 +888,15 @@ mmask_t mousemask(mmask_t newmask, mmask_t *oldmask)
returnCode(0);
_nc_mouse_init();
- if ( mousetype != M_NONE )
- {
+ if (mousetype != M_NONE) {
eventmask = newmask &
(BUTTON_ALT | BUTTON_CTRL | BUTTON_SHIFT
- | BUTTON1_PRESSED | BUTTON1_RELEASED | BUTTON1_CLICKED
- | BUTTON1_DOUBLE_CLICKED | BUTTON1_TRIPLE_CLICKED
- | BUTTON2_PRESSED | BUTTON2_RELEASED | BUTTON2_CLICKED
- | BUTTON2_DOUBLE_CLICKED | BUTTON2_TRIPLE_CLICKED
- | BUTTON3_PRESSED | BUTTON3_RELEASED | BUTTON3_CLICKED
- | BUTTON3_DOUBLE_CLICKED | BUTTON3_TRIPLE_CLICKED);
+ | BUTTON1_PRESSED | BUTTON1_RELEASED | BUTTON1_CLICKED
+ | BUTTON1_DOUBLE_CLICKED | BUTTON1_TRIPLE_CLICKED
+ | BUTTON2_PRESSED | BUTTON2_RELEASED | BUTTON2_CLICKED
+ | BUTTON2_DOUBLE_CLICKED | BUTTON2_TRIPLE_CLICKED
+ | BUTTON3_PRESSED | BUTTON3_RELEASED | BUTTON3_CLICKED
+ | BUTTON3_DOUBLE_CLICKED | BUTTON3_TRIPLE_CLICKED);
mouse_activate(eventmask != 0);
@@ -894,21 +906,22 @@ mmask_t mousemask(mmask_t newmask, mmask_t *oldmask)
returnCode(result);
}
-bool wenclose(const WINDOW *win, int y, int x)
+bool
+wenclose(const WINDOW *win, int y, int x)
/* check to see if given window encloses given screen location */
{
- if (win)
- {
+ if (win) {
y -= win->_yoffset;
return ((win->_begy <= y &&
- win->_begx <= x &&
- (win->_begx + win->_maxx) >= x &&
- (win->_begy + win->_maxy) >= y) ? TRUE : FALSE);
+ win->_begx <= x &&
+ (win->_begx + win->_maxx) >= x &&
+ (win->_begy + win->_maxy) >= y) ? TRUE : FALSE);
}
return FALSE;
}
-int mouseinterval(int maxclick)
+int
+mouseinterval(int maxclick)
/* set the maximum mouse interval within which to recognize a click */
{
int oldval;
@@ -921,46 +934,44 @@ int mouseinterval(int maxclick)
oldval = DEFAULT_MAXCLICK;
}
- return(oldval);
+ return (oldval);
}
/* This may be used by other routines to ask for the existence of mouse
support */
-int _nc_has_mouse(void) {
- return (mousetype==M_NONE ? 0:1);
+int
+_nc_has_mouse(void)
+{
+ return (mousetype == M_NONE ? 0 : 1);
}
-bool wmouse_trafo(const WINDOW* win, int* pY, int* pX, bool to_screen)
+bool
+wmouse_trafo(const WINDOW *win, int *pY, int *pX, bool to_screen)
{
- bool result = FALSE;
-
- if (win && pY && pX)
- {
- int y = *pY; int x = *pX;
-
- if (to_screen)
- {
- y += win->_begy + win->_yoffset;
- x += win->_begx;
- if (wenclose(win,y,x))
- result = TRUE;
- }
- else
- {
- if (wenclose(win,y,x))
- {
- y -= (win->_begy + win->_yoffset);
- x -= win->_begx;
- result = TRUE;
+ bool result = FALSE;
+
+ if (win && pY && pX) {
+ int y = *pY;
+ int x = *pX;
+
+ if (to_screen) {
+ y += win->_begy + win->_yoffset;
+ x += win->_begx;
+ if (wenclose(win, y, x))
+ result = TRUE;
+ } else {
+ if (wenclose(win, y, x)) {
+ y -= (win->_begy + win->_yoffset);
+ x -= win->_begx;
+ result = TRUE;
}
}
- if (result)
- {
- *pX = x;
- *pY = y;
+ if (result) {
+ *pX = x;
+ *pY = y;
}
}
- return(result);
+ return (result);
}
/* lib_mouse.c ends here */