示例#1
0
文件: lib_mouse.c 项目: ysleu/RTL8685
wmouse_trafo(const WINDOW *win, int *pY, int *pX, bool to_screen)
{
    bool result = FALSE;

    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;
	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;
	}
    }
    returnBool(result);
}
/* 
 * called by the messages dispatcher when the window is focused
 */
static int wdg_percentage_get_msg(struct wdg_object *wo, int key, struct wdg_mouse_event *mouse)
{
   WDG_WO_EXT(struct wdg_percentage, ww);
   
   /* handle the message */
   switch (key) {
      case KEY_MOUSE:
         /* is the mouse event within our edges ? */
         if (wenclose(ww->win, mouse->y, mouse->x))
            wdg_set_focus(wo);
         else 
            return -WDG_E_NOTHANDLED;
         break;

      case KEY_ESC:
      case CTRL('Q'):
         WDG_DEBUG_MSG("wdg_percentage_get_msg: user interrupt");
         /* 
          * user has requested to stop this task.
          * the next time the percentage will be set
          * the object will be destroyed and a correct value
          * will be returned.
          */
         ww->interrupt = 1;
         break;
         
      /* message not handled */
      default:
         return -WDG_E_NOTHANDLED;
         break;
   }
  
   return WDG_E_SUCCESS;
}
示例#3
0
int main (void) {
    MEVENT pos;
    int l_mouse;
    chtype button;

    initscr();

    noecho();
    keypad(stdscr, TRUE);
    l_mouse = mousemask(BUTTON1_PRESSED, NULL);
    (void)l_mouse;
    
    while (1) {
	button = wgetch(stdscr);
	if (button == KEY_MOUSE) {
		if (getmouse(&pos) == OK) {
			wenclose(stdscr, pos.y, pos.x);
			mvwprintw(stdscr, 1, 0, "y = %2d x = %2d",
				  pos.y, pos.x);
		}
	}
	wrefresh(stdscr);
    }

    endwin();
    
    return 0;
}
示例#4
0
/* 
 * called by the messages dispatcher when the window is focused
 */
static int wdg_dialog_get_msg(struct wdg_object *wo, int key, struct wdg_mouse_event *mouse)
{
   WDG_WO_EXT(struct wdg_dialog, ww);

   /* handle the message */
   switch (key) {
      case KEY_MOUSE:
         /* is the mouse event within our edges ? */
         if (wenclose(ww->win, mouse->y, mouse->x)) {
            wdg_set_focus(wo);
            /* if the mouse click was over a button */
            if (wdg_dialog_mouse_move(wo, mouse) == WDG_ESUCCESS)
               wdg_dialog_callback(wo);
         } else 
            return -WDG_ENOTHANDLED;
         break;

      case KEY_LEFT:
      case KEY_RIGHT:
         wdg_dialog_move(wo, key);
         wdg_dialog_redraw(wo);
         break;

      case KEY_RETURN:
         wdg_dialog_callback(wo);
         break;
         
      /* message not handled */
      default:
         return -WDG_ENOTHANDLED;
         break;
   }
  
   return WDG_ESUCCESS;
}
示例#5
0
/* 
 * called by the messages dispatcher when the window is focused
 */
static int wdg_scroll_get_msg(struct wdg_object *wo, int key, struct wdg_mouse_event *mouse)
{
   WDG_WO_EXT(struct wdg_scroll, ww);
   size_t c = wdg_get_ncols(wo);
   size_t l = wdg_get_nlines(wo);
   size_t x = wdg_get_begin_x(wo);
   size_t y = wdg_get_begin_y(wo);
  
   /* handle the message */
   switch (key) {
         
      case KEY_MOUSE:
         /* is the mouse event within our edges ? */
         if (wenclose(ww->win, mouse->y, mouse->x)) {
            /* get the focus only if it was not focused */
            if (!(wo->flags & WDG_OBJ_FOCUSED))
               wdg_set_focus(wo);
            if (mouse->x == x + c - 1 && (mouse->y >= y + 1 && mouse->y <= y + l - 1)) {
               wdg_mouse_scroll(wo, mouse->y);
               WDG_PAD_REFRESH(ww, c, l, x, y);
               wnoutrefresh(ww->win);
            }
         } else 
            return -WDG_ENOTHANDLED;
         break;

      /* handle scrolling of the pad */
      case KEY_UP:
         wdg_set_scroll(wo, ww->y_scroll - 1);
         WDG_PAD_REFRESH(ww, c, l, x, y);
         wnoutrefresh(ww->win);
         break;
         
      case KEY_DOWN:
         wdg_set_scroll(wo, ww->y_scroll + 1);
         WDG_PAD_REFRESH(ww, c, l, x, y);
         wnoutrefresh(ww->win);
         break;
         
      case KEY_NPAGE:
         wdg_set_scroll(wo, ww->y_scroll + (l - 2));
         WDG_PAD_REFRESH(ww, c, l, x, y);
         wnoutrefresh(ww->win);
         break;
         
      case KEY_PPAGE:
         wdg_set_scroll(wo, ww->y_scroll - (l - 2));
         WDG_PAD_REFRESH(ww, c, l, x, y);
         wnoutrefresh(ww->win);
         break;
         
      /* message not handled */
      default:
         return -WDG_ENOTHANDLED;
         break;
   }
  
   return WDG_ESUCCESS;
}
示例#6
0
文件: mouse.c 项目: bhaggerty/wwiv
bool wmouse_trafo(const WINDOW *win, int *y, int *x, bool to_screen)
{
	int newy, newx;

	PDC_LOG(("wmouse_trafo() - called\n"));

	if (!win || !y || !x)
		return FALSE;

	newy = *y;
	newx = *x;

	if (to_screen)
	{
		newy += win->_begy;
		newx += win->_begx;

		if (!wenclose(win, newy, newx))
			return FALSE;
	}
	else
	{
		if (wenclose(win, newy, newx))
		{
			newy -= win->_begy;
			newx -= win->_begx;
		}
		else
			return FALSE;
	}

	*y = newy;
	*x = newx;

	return TRUE;
}
示例#7
0
/* 
 * called by the messages dispatcher when the file dialog is focused
 */
static int wdg_file_get_msg(struct wdg_object *wo, int key, struct wdg_mouse_event *mouse)
{
   WDG_WO_EXT(struct wdg_file_handle, ww);

   /* handle the message */
   switch (key) {
         
      case KEY_MOUSE:
         /* is the mouse event within our edges ? */
         if (wenclose(ww->win, mouse->y, mouse->x)) {
            wdg_set_focus(wo);
            /* pass it to the menu */
            if (wdg_file_driver(wo, key, mouse) != WDG_E_SUCCESS)
               wdg_file_redraw(wo);
         } else 
            return -WDG_E_NOTHANDLED;
         break;

      case KEY_RETURN:
      case KEY_DOWN:
      case KEY_UP:
      case KEY_PPAGE:
      case KEY_NPAGE:
         /* move only if focused */
         if (wo->flags & WDG_OBJ_FOCUSED) {
            if (wdg_file_driver(wo, key, mouse) != WDG_E_SUCCESS)
               wdg_file_redraw(wo);
         } else
            return -WDG_E_NOTHANDLED;
         break;
        
      case KEY_ESC:
      case CTRL('Q'):
         wdg_destroy_object(&wo);
         wdg_redraw_all();
         break;
         
      /* message not handled */
      default:
         return -WDG_E_NOTHANDLED;
         break;
   }
  
   return WDG_E_SUCCESS;
}
示例#8
0
文件: mouse.c 项目: bhaggerty/wwiv
void wmouse_position(WINDOW *win, int *y, int *x)
{
	PDC_LOG(("wmouse_position() - called\n"));

	if (win && wenclose(win, MOUSE_Y_POS, MOUSE_X_POS))
	{
		if (y)
			*y = MOUSE_Y_POS - win->_begy;
		if (x)
			*x = MOUSE_X_POS - win->_begx;
	}
	else
	{
		if (y)
			*y = -1;
		if (x)
			*x = -1;
	}
}
示例#9
0
/* 
 * called by the messages dispatcher when the window is focused
 */
static int wdg_window_get_msg(struct wdg_object *wo, int key, struct wdg_mouse_event *mouse)
{
   WDG_WO_EXT(struct wdg_window, ww);

   /* handle the message */
   switch (key) {
      case KEY_MOUSE:
         /* is the mouse event within our edges ? */
         if (wenclose(ww->win, mouse->y, mouse->x))
            wdg_set_focus(wo);
         else 
            return -WDG_ENOTHANDLED;
         break;

      /* message not handled */
      default:
         return -WDG_ENOTHANDLED;
         break;
   }
  
   return WDG_ESUCCESS;
}
示例#10
0
/* 
 * called by the messages dispatcher when the menu is focused
 */
static int wdg_input_get_msg(struct wdg_object *wo, int key, struct wdg_mouse_event *mouse)
{
   WDG_WO_EXT(struct wdg_input_handle, ww);

   WDG_DEBUG_MSG("keypress get msg: %d", key);
   
   /* handle the message */
   switch (key) {
         
      case KEY_MOUSE:
         /* is the mouse event within our edges ? */
         if (wenclose(ww->win, mouse->y, mouse->x)) {
            wdg_set_focus(wo);
            /* redraw the menu */
            wdg_input_redraw(wo);
         } else {
            return -WDG_E_NOTHANDLED;
         }
         break;
      
      case KEY_ESC:
      case CTRL('Q'):
         wdg_destroy_object(&wo);
         wdg_redraw_all();
         return WDG_EFINISHED;
         break;

      /* message not handled */
      default:
         if (wo->flags & WDG_OBJ_FOCUSED) {
            return wdg_input_driver(wo, key, mouse);
         } else {
            return -WDG_E_NOTHANDLED;
         }
         break;
   }
   
   return WDG_E_SUCCESS;
}
示例#11
0
menu_driver(MENU * menu, int c)
{
#define NAVIGATE(dir) \
  if (!item->dir)\
     result = E_REQUEST_DENIED;\
  else\
     item = item->dir

  int result = E_OK;
  ITEM *item;
  int my_top_row, rdiff;

  T((T_CALLED("menu_driver(%p,%d)"), (void *)menu, c));

  if (!menu)
    RETURN(E_BAD_ARGUMENT);

  if (menu->status & _IN_DRIVER)
    RETURN(E_BAD_STATE);
  if (!(menu->status & _POSTED))
    RETURN(E_NOT_POSTED);

  item = menu->curitem;

  my_top_row = menu->toprow;
  assert(item);

  if ((c > KEY_MAX) && (c <= MAX_MENU_COMMAND))
    {
      if (!((c == REQ_BACK_PATTERN)
	    || (c == REQ_NEXT_MATCH) || (c == REQ_PREV_MATCH)))
	{
	  assert(menu->pattern);
	  Reset_Pattern(menu);
	}

      switch (c)
	{
	case REQ_LEFT_ITEM:
	    /*=================*/
	  NAVIGATE(left);
	  break;

	case REQ_RIGHT_ITEM:
	    /*==================*/
	  NAVIGATE(right);
	  break;

	case REQ_UP_ITEM:
	    /*===============*/
	  NAVIGATE(up);
	  break;

	case REQ_DOWN_ITEM:
	    /*=================*/
	  NAVIGATE(down);
	  break;

	case REQ_SCR_ULINE:
	    /*=================*/
	  if (my_top_row == 0 || !(item->up))
	    result = E_REQUEST_DENIED;
	  else
	    {
	      --my_top_row;
	      item = item->up;
	    }
	  break;

	case REQ_SCR_DLINE:
	    /*=================*/
	  if ((my_top_row + menu->arows >= menu->rows) || !(item->down))
	    {
	      /* only if the menu has less items than rows, we can deny the
	         request. Otherwise the epilogue of this routine adjusts the
	         top row if necessary */
	      result = E_REQUEST_DENIED;
	    }
	  else
	    {
	      my_top_row++;
	      item = item->down;
	    }
	  break;

	case REQ_SCR_DPAGE:
	    /*=================*/
	  rdiff = menu->rows - (menu->arows + my_top_row);
	  if (rdiff > menu->arows)
	    rdiff = menu->arows;
	  if (rdiff <= 0)
	    result = E_REQUEST_DENIED;
	  else
	    {
	      my_top_row += rdiff;
	      while (rdiff-- > 0 && item != 0 && item->down != 0)
		item = item->down;
	    }
	  break;

	case REQ_SCR_UPAGE:
	    /*=================*/
	  rdiff = (menu->arows < my_top_row) ? menu->arows : my_top_row;
	  if (rdiff <= 0)
	    result = E_REQUEST_DENIED;
	  else
	    {
	      my_top_row -= rdiff;
	      while (rdiff-- > 0 && item != 0 && item->up != 0)
		item = item->up;
	    }
	  break;

	case REQ_FIRST_ITEM:
	    /*==================*/
	  item = menu->items[0];
	  break;

	case REQ_LAST_ITEM:
	    /*=================*/
	  item = menu->items[menu->nitems - 1];
	  break;

	case REQ_NEXT_ITEM:
	    /*=================*/
	  if ((item->index + 1) >= menu->nitems)
	    {
	      if (menu->opt & O_NONCYCLIC)
		result = E_REQUEST_DENIED;
	      else
		item = menu->items[0];
	    }
	  else
	    item = menu->items[item->index + 1];
	  break;

	case REQ_PREV_ITEM:
	    /*=================*/
	  if (item->index <= 0)
	    {
	      if (menu->opt & O_NONCYCLIC)
		result = E_REQUEST_DENIED;
	      else
		item = menu->items[menu->nitems - 1];
	    }
	  else
	    item = menu->items[item->index - 1];
	  break;

	case REQ_TOGGLE_ITEM:
	    /*===================*/
	  if (menu->opt & O_ONEVALUE)
	    {
	      result = E_REQUEST_DENIED;
	    }
	  else
	    {
	      if (menu->curitem->opt & O_SELECTABLE)
		{
		  menu->curitem->value = !menu->curitem->value;
		  Move_And_Post_Item(menu, menu->curitem);
		  _nc_Show_Menu(menu);
		}
	      else
		result = E_NOT_SELECTABLE;
	    }
	  break;

	case REQ_CLEAR_PATTERN:
	    /*=====================*/
	  /* already cleared in prologue */
	  break;

	case REQ_BACK_PATTERN:
	    /*====================*/
	  if (menu->pindex > 0)
	    {
	      assert(menu->pattern);
	      Remove_Character_From_Pattern(menu);
	      pos_menu_cursor(menu);
	    }
	  else
	    result = E_REQUEST_DENIED;
	  break;

	case REQ_NEXT_MATCH:
	    /*==================*/
	  assert(menu->pattern);
	  if (menu->pattern[0])
	    result = _nc_Match_Next_Character_In_Item_Name(menu, 0, &item);
	  else
	    {
	      if ((item->index + 1) < menu->nitems)
		item = menu->items[item->index + 1];
	      else
		{
		  if (menu->opt & O_NONCYCLIC)
		    result = E_REQUEST_DENIED;
		  else
		    item = menu->items[0];
		}
	    }
	  break;

	case REQ_PREV_MATCH:
	    /*==================*/
	  assert(menu->pattern);
	  if (menu->pattern[0])
	    result = _nc_Match_Next_Character_In_Item_Name(menu, BS, &item);
	  else
	    {
	      if (item->index)
		item = menu->items[item->index - 1];
	      else
		{
		  if (menu->opt & O_NONCYCLIC)
		    result = E_REQUEST_DENIED;
		  else
		    item = menu->items[menu->nitems - 1];
		}
	    }
	  break;

	default:
	    /*======*/
	  result = E_UNKNOWN_COMMAND;
	  break;
	}
    }
  else
    {				/* not a command */
      if (!(c & ~((int)MAX_REGULAR_CHARACTER)) && isprint(UChar(c)))
	result = _nc_Match_Next_Character_In_Item_Name(menu, c, &item);
#ifdef NCURSES_MOUSE_VERSION
      else if (KEY_MOUSE == c)
	{
	  MEVENT event;
	  WINDOW *uwin = Get_Menu_UserWin(menu);

	  getmouse(&event);
	  if ((event.bstate & (BUTTON1_CLICKED |
			       BUTTON1_DOUBLE_CLICKED |
			       BUTTON1_TRIPLE_CLICKED))
	      && wenclose(uwin, event.y, event.x))
	    {			/* we react only if the click was in the userwin, that means
				 * inside the menu display area or at the decoration window.
				 */
	      WINDOW *sub = Get_Menu_Window(menu);
	      int ry = event.y, rx = event.x;	/* screen coordinates */

	      result = E_REQUEST_DENIED;
	      if (mouse_trafo(&ry, &rx, FALSE))
		{		/* rx, ry are now "curses" coordinates */
		  if (ry < sub->_begy)
		    {		/* we clicked above the display region; this is
				 * interpreted as "scroll up" request
				 */
		      if (event.bstate & BUTTON1_CLICKED)
			result = menu_driver(menu, REQ_SCR_ULINE);
		      else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
			result = menu_driver(menu, REQ_SCR_UPAGE);
		      else if (event.bstate & BUTTON1_TRIPLE_CLICKED)
			result = menu_driver(menu, REQ_FIRST_ITEM);
		      RETURN(result);
		    }
		  else if (ry > sub->_begy + sub->_maxy)
		    {		/* we clicked below the display region; this is
				 * interpreted as "scroll down" request
				 */
		      if (event.bstate & BUTTON1_CLICKED)
			result = menu_driver(menu, REQ_SCR_DLINE);
		      else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
			result = menu_driver(menu, REQ_SCR_DPAGE);
		      else if (event.bstate & BUTTON1_TRIPLE_CLICKED)
			result = menu_driver(menu, REQ_LAST_ITEM);
		      RETURN(result);
		    }
		  else if (wenclose(sub, event.y, event.x))
		    {		/* Inside the area we try to find the hit item */
		      int i, x, y, err;

		      ry = event.y;
		      rx = event.x;
		      if (wmouse_trafo(sub, &ry, &rx, FALSE))
			{
			  for (i = 0; i < menu->nitems; i++)
			    {
			      err = _nc_menu_cursor_pos(menu, menu->items[i],
							&y, &x);
			      if (E_OK == err)
				{
				  if ((ry == y) &&
				      (rx >= x) &&
				      (rx < x + menu->itemlen))
				    {
				      item = menu->items[i];
				      result = E_OK;
				      break;
				    }
				}
			    }
			  if (E_OK == result)
			    {	/* We found an item, now we can handle the click.
				 * A single click just positions the menu cursor
				 * to the clicked item. A double click toggles
				 * the item.
				 */
			      if (event.bstate & BUTTON1_DOUBLE_CLICKED)
				{
				  _nc_New_TopRow_and_CurrentItem(menu,
								 my_top_row,
								 item);
				  menu_driver(menu, REQ_TOGGLE_ITEM);
				  result = E_UNKNOWN_COMMAND;
				}
			    }
			}
		    }
		}
	    }
	  else
	    result = E_REQUEST_DENIED;
	}
#endif /* NCURSES_MOUSE_VERSION */
      else
	result = E_UNKNOWN_COMMAND;
    }

  if (E_OK == result)
    {
      /* Adjust the top row if it turns out that the current item unfortunately
         doesn't appear in the menu window */
      if (item->y < my_top_row)
	my_top_row = item->y;
      else if (item->y >= (my_top_row + menu->arows))
	my_top_row = item->y - menu->arows + 1;

      _nc_New_TopRow_and_CurrentItem(menu, my_top_row, item);

    }

  RETURN(result);
}
示例#12
0
pms_pending_keys	Input::dispatch_normal()
{
	MEVENT			mouseevent;
	int			mousewinx, mousewiny;
	bool			mousecurwin = false;
	bool			mousetopbar = false;
	bool			mousestatusbar = false;
	bool			mousepositionreadout = false;
	bool			mousemodshift = false;
	bool			mousemodctrl = false;
	bool			mousemodalt = false;
	int			mouselistindex;

	if (ch == -1)
		return PEND_NONE;

	if (ch == KEY_RESIZE)
	{
		pending = PEND_RESIZE;
		return pending;
	}

	/* Mouse event */
	if (ch == KEY_MOUSE)
	{
		if (getmouse(&mouseevent) == ERR)
		{
			pms->log(MSG_DEBUG, 0, "error with getmouse()\n");
			ch = -1; // prevents weird results
			return PEND_NONE;
		}

		pms->log(MSG_DEBUG, 0, "mevent x:%d, y:%d, z:%d\n", mouseevent.x, mouseevent.y, mouseevent.z);

		if (mouseevent.bstate & BUTTON_SHIFT)
		{
			pms->log(MSG_DEBUG, 0, "shift is down\n");
			mousemodshift = true;
		}
		if (mouseevent.bstate & BUTTON_CTRL)
		{
			pms->log(MSG_DEBUG, 0, "ctrl is down\n");
			mousemodctrl = true;
		}
		if (mouseevent.bstate & BUTTON_ALT)
		{
			pms->log(MSG_DEBUG, 0, "alt is down\n");
			mousemodctrl = true;
		}

		mousewinx = mouseevent.x;
		mousewiny = mouseevent.y;

		if (pms->disp->actwin() && wenclose(pms->disp->actwin()->h(), mouseevent.y, mouseevent.x))
		{
			pms->log(MSG_DEBUG, 0, "mouse event in current window\n");
			mousecurwin = true;
			wmouse_trafo(pms->disp->actwin()->h(), &mousewiny, &mousewinx, false);

			//take window title and column titles away
			mousewiny -= 2;

			mouselistindex = pms->disp->actwin()->cursordrawstart() + mousewiny;
			if (!pms->disp->actwin()->plist() || mouselistindex >= pms->disp->actwin()->plist()->size())
			{
				//not a playlist or clicked off the end of the 
				//list
				mouselistindex = -1;
				pms->log(MSG_DEBUG, 0, "mouse event off the end of the list of songs or not a playlist\n");
			}
		}
		else if (wenclose(pms->disp->topbar->h(), mouseevent.y, mouseevent.x))
		{
			pms->log(MSG_DEBUG, 0, "mouse event in topbar\n");
			mousetopbar = true;
			wmouse_trafo(pms->disp->topbar->h(), &mousewiny, &mousewinx, false);
		}
		else if (wenclose(pms->disp->statusbar->h(), mouseevent.y, mouseevent.x))
		{
			pms->log(MSG_DEBUG, 0, "mouse event in statusbar\n");
			mousestatusbar = true;
			wmouse_trafo(pms->disp->statusbar->h(), &mousewiny, &mousewinx, false);
		}
		else if (wenclose(pms->disp->positionreadout->h(), mouseevent.y, mouseevent.x))
		{
			pms->log(MSG_DEBUG, 0, "mouse event in positionreadout\n");
			mousepositionreadout = true;
			wmouse_trafo(pms->disp->positionreadout->h(), &mousewiny, &mousewinx, false);
		}
		else
		{
			pms->log(MSG_DEBUG, 0, "mouse event doesn't seem to be enclosed in any of our windows\n");
			return PEND_NONE;
		}

		pms->log(MSG_DEBUG, 0, "mouse event at row %d, col %d of window\n", mousewiny, mousewinx);

		if (mouseevent.bstate & MOUSEWHEEL_DOWN)
		{
			pms->log(MSG_DEBUG, 0, "mousewheel down\n");
			if (mousetopbar)
			{
				if (mousemodctrl)
				{
					param = "-3";
					return PEND_VOLUME;
				}
				return PEND_NEXT;
			}
			if (mousecurwin)
			{
				if (mousewiny == -2) //heading bar
					return PEND_NEXTWIN;
				return PEND_SCROLL_DOWN;
			}
			return PEND_NONE;
		}
		else if (mouseevent.bstate & MOUSEWHEEL_UP)
		{
			pms->log(MSG_DEBUG, 0, "mousewheel up\n");
			if (mousetopbar)
			{
				if (mousemodctrl) {
					param = "+3";
					return PEND_VOLUME;
				}
				return PEND_PREV;
			}
			if (mousecurwin)
			{
				if (mousewiny == -2) //heading bar
					return PEND_PREVWIN;
				return PEND_SCROLL_UP;
			}
			return PEND_NONE;
		}
		else if (mouseevent.bstate & BUTTON1_PRESSED)
		{
			pms->log(MSG_DEBUG, 0, "button 1 down\n");
			return PEND_NONE;
		}
		else if (mouseevent.bstate & BUTTON1_RELEASED)
		{
			pms->log(MSG_DEBUG, 0, "button 1 released\n");
			return PEND_NONE;
		}
		else if (mouseevent.bstate & BUTTON1_CLICKED)
		{
			pms->log(MSG_DEBUG, 0, "button 1 clicked\n");
			if (mousetopbar)
				return PEND_TOGGLEPLAY;
			if (mousecurwin)
			{
				if (mousewiny == -2) //heading bar
					return PEND_NEXTWIN;
				if (mouselistindex >= 0) //song
				{
					pms->disp->actwin()->plist()->setcursor(mouselistindex);
					if (mousemodctrl)
						pms->disp->actwin()->plist()->selectsong(pms->disp->actwin()->plist()->song(mouselistindex), !pms->disp->actwin()->plist()->song(mouselistindex)->selected);
					return PEND_NONE;
				}
			}
			if (mousestatusbar)
				return PEND_COMMANDMODE;
			return PEND_NONE;
		}
		else if (mouseevent.bstate & BUTTON1_DOUBLE_CLICKED)
		{
			pms->log(MSG_DEBUG, 0, "button 1 doubleclicked\n");
			if (mousetopbar)
				return PEND_STOP;
			if (mousecurwin)
			{
				if (mousewiny == -2) //heading bar
					return PEND_PREVWIN;
				if (mouselistindex >= 0) //song
				{
					pms->disp->actwin()->plist()->setcursor(mouselistindex);
					return PEND_PLAY;
				}
			}
			return PEND_NONE;
		}
		else if (mouseevent.bstate & BUTTON1_TRIPLE_CLICKED)
		{
			pms->log(MSG_DEBUG, 0, "button 1 tripleclicked\n");
			if (mousecurwin && mouselistindex >= 0)
			{
				pms->disp->actwin()->plist()->setcursor(mouselistindex);
				return PEND_ADD;
			}
			return PEND_NONE;
		}
		else if (mouseevent.bstate & BUTTON2_PRESSED)
		{
			pms->log(MSG_DEBUG, 0, "button 2 down\n");
			return PEND_NONE;
		}
		else if (mouseevent.bstate & BUTTON2_RELEASED)
		{
			pms->log(MSG_DEBUG, 0, "button 2 released\n");
			return PEND_NONE;
		}
		else if (mouseevent.bstate & BUTTON2_CLICKED)
		{
			pms->log(MSG_DEBUG, 0, "button 2 clicked\n");
			return PEND_NONE;
		}
		else if (mouseevent.bstate & BUTTON2_DOUBLE_CLICKED)
		{
			pms->log(MSG_DEBUG, 0, "button 2 doubleclicked\n");
			return PEND_NONE;
		}
		else if (mouseevent.bstate & BUTTON2_TRIPLE_CLICKED)
		{
			pms->log(MSG_DEBUG, 0, "button 2 tripleclicked\n");
			return PEND_NONE;
		}
		else if (mouseevent.bstate & BUTTON3_PRESSED)
		{
			pms->log(MSG_DEBUG, 0, "button 3 down\n");
			return PEND_NONE;
		}
		else if (mouseevent.bstate & BUTTON3_RELEASED)
		{
			pms->log(MSG_DEBUG, 0, "button 3 released\n");
			return PEND_NONE;
		}
		else if (mouseevent.bstate & BUTTON3_CLICKED)
		{
			pms->log(MSG_DEBUG, 0, "button 3 clicked\n");
			if (mousecurwin)
			{
				if (mouselistindex >= 0) //song
				{
					pms->disp->actwin()->plist()->setcursor(mouselistindex);
					pms->disp->actwin()->plist()->selectsong(pms->disp->actwin()->plist()->song(mouselistindex), !pms->disp->actwin()->plist()->song(mouselistindex)->selected);
					return PEND_NONE;
				}
			}
			return PEND_NONE;
		}
		else if (mouseevent.bstate & BUTTON3_DOUBLE_CLICKED)
		{
			pms->log(MSG_DEBUG, 0, "button 3 doubleclicked\n");
			return PEND_NONE;
		}
		else if (mouseevent.bstate & BUTTON3_TRIPLE_CLICKED)
		{
			pms->log(MSG_DEBUG, 0, "button 3 tripleclicked\n");
			return PEND_NONE;
		}
		else if (mouseevent.bstate & BUTTON4_PRESSED)
		{
			pms->log(MSG_DEBUG, 0, "button 4 down\n");
			return PEND_NONE;
		}
		else if (mouseevent.bstate & BUTTON4_RELEASED)
		{
			pms->log(MSG_DEBUG, 0, "button 4 released\n");
			return PEND_NONE;
		}
		else if (mouseevent.bstate & BUTTON4_CLICKED)
		{
			pms->log(MSG_DEBUG, 0, "button 4 clicked\n");
			return PEND_NONE;
		}
		else if (mouseevent.bstate & BUTTON4_DOUBLE_CLICKED)
		{
			pms->log(MSG_DEBUG, 0, "button 4 doubleclicked\n");
			return PEND_NONE;
		}
		else if (mouseevent.bstate & BUTTON4_TRIPLE_CLICKED)
		{
			pms->log(MSG_DEBUG, 0, "button 4 tripleclicked\n");
			return PEND_NONE;
		}
#if NCURSES_MOUSE_VERSION > 1
		else if (mouseevent.bstate & BUTTON5_PRESSED)
		{
			pms->log(MSG_DEBUG, 0, "button 5 down\n");
			return PEND_NONE;
		}
		else if (mouseevent.bstate & BUTTON5_RELEASED)
		{
			pms->log(MSG_DEBUG, 0, "button 5 released\n");
			return PEND_NONE;
		}
		else if (mouseevent.bstate & BUTTON5_CLICKED)
		{
			pms->log(MSG_DEBUG, 0, "button 5 clicked\n");
			return PEND_NONE;
		}
		else if (mouseevent.bstate & BUTTON5_DOUBLE_CLICKED)
		{
			pms->log(MSG_DEBUG, 0, "button 5 doubleclicked\n");
			return PEND_NONE;
		}
		else if (mouseevent.bstate & BUTTON5_TRIPLE_CLICKED)
		{
			pms->log(MSG_DEBUG, 0, "button 5 tripleclicked\n");
			return PEND_NONE;
		}
#endif
		else if (mouseevent.bstate & REPORT_MOUSE_POSITION)
		{
			pms->log(MSG_DEBUG, 0, "mouse position -- what does this do?\n");
			return PEND_NONE;
		}
		else
		{
			pms->log(MSG_DEBUG, 0, "mevent state (%d) unknown\n", mouseevent.bstate);
			return PEND_NONE;
		}
	}

	/* Key pressed */
	pending = pms->bindings->act(ch, &param);

	if (pending == PEND_NONE)
	{
		pms->log(MSG_STATUS, STERR, _("Key is not bound."));
		pms->log(MSG_DEBUG, 0, "Key %3d '%c' pressed but not bound.\n", ch, ch);
	}

	return pending;
}
示例#13
0
文件: term.c 项目: Toeger/f-irc
BOOL is_in_window(NEWWIN *win, int x, int y)
{
	return wenclose(win -> win, y, x);
}