/****************************************************************************
- * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2009,2010 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 *
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_mouse.c,v 1.108 2009/07/04 19:51:08 tom Exp $")
+MODULE_ID("$Id: lib_mouse.c,v 1.111 2010/01/02 21:06:52 tom Exp $")
#include <tic.h>
NCURSES_EXPORT(int)
NCURSES_SP_NAME(getmouse) (NCURSES_SP_DCLx MEVENT * aevent)
{
- T((T_CALLED("getmouse(%p,%p)"), SP_PARM, aevent));
+ int result = ERR;
+
+ T((T_CALLED("getmouse(%p,%p)"), (void *) SP_PARM, (void *) aevent));
if ((aevent != 0) && (SP_PARM != 0) && (SP_PARM->_mouse_type != M_NONE)) {
MEVENT *eventp = SP_PARM->_mouse_eventp;
/* compute the current-event pointer */
MEVENT *prev = PREV(eventp);
- /* copy the event we find there */
- *aevent = *prev;
+ if (prev->id != INVALID_EVENT) {
+ /* copy the event we find there */
+ *aevent = *prev;
- TR(TRACE_IEVENT, ("getmouse: returning event %s from slot %ld",
- _nc_tracemouse(SP_PARM, prev),
- (long) IndexEV(SP_PARM, prev)));
+ TR(TRACE_IEVENT, ("getmouse: returning event %s from slot %ld",
+ _nc_tracemouse(SP_PARM, prev),
+ (long) IndexEV(SP_PARM, prev)));
- prev->id = INVALID_EVENT; /* so the queue slot becomes free */
- returnCode(OK);
+ prev->id = INVALID_EVENT; /* so the queue slot becomes free */
+ SP_PARM->_mouse_eventp = PREV(prev);
+ result = OK;
+ }
}
- returnCode(ERR);
+ returnCode(result);
}
#if NCURSES_SP_FUNCS
{
int result = ERR;
- T((T_CALLED("ungetmouse(%p,%p)"), SP_PARM, aevent));
+ T((T_CALLED("ungetmouse(%p,%p)"), (void *) SP_PARM, (void *) aevent));
if (aevent != 0 && SP_PARM != 0) {
MEVENT *eventp = SP_PARM->_mouse_eventp;
{
mmask_t result = 0;
- T((T_CALLED("mousemask(%p,%#lx,%p)"), SP_PARM, (unsigned long) newmask, oldmask));
+ T((T_CALLED("mousemask(%p,%#lx,%p)"),
+ (void *) SP_PARM,
+ (unsigned long) newmask,
+ (void *) oldmask));
if (SP_PARM != 0) {
if (oldmask)
{
bool result = FALSE;
- T((T_CALLED("wenclose(%p,%d,%d)"), win, y, x));
+ T((T_CALLED("wenclose(%p,%d,%d)"), (const void *) win, y, x));
if (win != 0) {
y -= win->_yoffset;
{
int oldval;
- T((T_CALLED("mouseinterval(%p,%d)"), SP_PARM, maxclick));
+ T((T_CALLED("mouseinterval(%p,%d)"), (void *) SP_PARM, maxclick));
if (SP_PARM != 0) {
oldval = SP_PARM->_maxclick;
{
bool result = FALSE;
- T((T_CALLED("wmouse_trafo(%p,%p,%p,%d)"), win, pY, pX, to_screen));
+ T((T_CALLED("wmouse_trafo(%p,%p,%p,%d)"),
+ (const void *) win,
+ (void *) pY,
+ (void *) pX,
+ to_screen));
if (win && pY && pX) {
int y = *pY;