X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fbase%2Flib_mouse.c;h=f4ad054d7ebef61af8c20b18f7bf49f2c7c52e56;hp=783ed0c25307f1af90848ff42523bfd200d3e2d1;hb=b0916ab669030bac5c8590c0d66e36e1b9b34e9b;hpb=03f728e5bb3630a54fffc4a2ff2f8dbfcce9088e;ds=sidebyside diff --git a/ncurses/base/lib_mouse.c b/ncurses/base/lib_mouse.c index 783ed0c2..f4ad054d 100644 --- a/ncurses/base/lib_mouse.c +++ b/ncurses/base/lib_mouse.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc. * + * Copyright (c) 1998-2011,2012 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -84,7 +84,7 @@ #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_mouse.c,v 1.133 2011/10/22 23:01:26 tom Exp $") +MODULE_ID("$Id: lib_mouse.c,v 1.138 2012/02/29 10:38:46 tom Exp $") #include @@ -120,6 +120,17 @@ make an error #endif #endif /* use_SYSMOUSE */ +#if USE_KLIBC_MOUSE +#include +#define pipe(handles) socketpair(AF_LOCAL, SOCK_STREAM, 0, handles) +#define DosWrite(hfile, pbuffer, cbwrite, pcbactual) \ + write(hfile, pbuffer, cbwrite) +#define DosExit(action, result ) /* do nothing */ +#define DosCreateThread(ptid, pfn, param, flag, cbStack) \ + (*(ptid) = _beginthread(pfn, NULL, cbStack, \ + (void *)param), (*(ptid) == -1)) +#endif + #define MY_TRACE TRACE_ICALLS|TRACE_IEVENT #define MASK_RELEASE(x) (mmask_t) NCURSES_MOUSE_MASK(x, 001) @@ -222,7 +233,11 @@ write_event(SCREEN *sp, int down, int button, int x, int y) } static void +#if USE_KLIBC_MOUSE +mouse_server(void *param) +#else mouse_server(unsigned long param) +#endif { SCREEN *sp = (SCREEN *) param; unsigned short fWait = MOU_WAIT; @@ -248,7 +263,8 @@ mouse_server(unsigned long param) /* sit and wait on the event queue */ rc = MouReadEventQue(&mouev, &fWait, hmou); if (rc) { - sprintf(err, "Error reading mouse queue, rc=%lu.\r\n", rc); + _nc_SPRINTF(err, _nc_SLIMIT(sizeof(err)) + "Error reading mouse queue, rc=%lu.\r\n", rc); break; } if (!sp->_emxmouse_activated) @@ -274,9 +290,11 @@ mouse_server(unsigned long param) finish: oldstate = mouev.fs; } - } else - sprintf(err, "Error setting event mask, buttons=%d, rc=%lu.\r\n", - nbuttons, rc); + } else { + _nc_SPRINTF(err, _nc_SLIMIT(sizeof(err)) + "Error setting event mask, buttons=%d, rc=%lu.\r\n", + nbuttons, rc); + } DosWrite(2, err, strlen(err), &rc); MouClose(hmou); @@ -379,11 +397,19 @@ enable_xterm_mouse(SCREEN *sp, int enable) #if USE_GPM_SUPPORT static bool -allow_gpm_mouse(void) +allow_gpm_mouse(SCREEN *sp) { bool result = FALSE; - /* GPM does printf's without checking if stdout is a terminal */ +#if USE_WEAK_SYMBOLS + /* Danger Robinson: do not use dlopen for libgpm if already loaded */ + if ((Gpm_Wgetch)) { + if (!sp->_mouse_gpm_loaded) { + T(("GPM library was already dlopen'd, not by us")); + } + } else +#endif + /* GPM does printf's without checking if stdout is a terminal */ if (isatty(fileno(stdout))) { char *list = getenv("NCURSES_GPM_TERMS"); char *env = getenv("TERM"); @@ -509,7 +535,7 @@ initialize_mousetype(SCREEN *sp) /* Try gpm first, because gpm may be configured to run in xterm */ #if USE_GPM_SUPPORT - if (allow_gpm_mouse()) { + if (allow_gpm_mouse(sp)) { if (!sp->_mouse_gpm_loaded) { #ifdef HAVE_LIBDL load_gpm_library(sp);