示例#1
0
文件: mouse.c 项目: AXElements/mouse
/*
 * Perform a double click at the given mouse position
 *
 * Implemented by first generating a single click, and then a double click.,
 * Apps seem to respond more consistently to this behaviour since that is
 * how a human would have to generate a double click event.
 *
 * You can optionally specify a point to click; the mouse cursor will
 * instantly jump to the given point; otherwise the click event happens
 * at the current cursor position.
 *
 * @overload double_click()
 *   @return [CGPoint]
 * @overload double_click(point)
 *   @param point [CGPoint]
 *   @return [CGPoint]
 */
static
VALUE
rb_mouse_double_click(const int argc,
                      VALUE* const argv,
                      UNUSED const VALUE self)
{
    switch (argc) {
    case 0:
        mouse_double_click();
        break;
    case 1:
    default:
        mouse_double_click2(rb_mouse_unwrap_point(argv[0]));
    }

    return CURRENT_POSITION;
}
示例#2
0
int Header::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: mouse_release((*reinterpret_cast< QMouseEvent*(*)>(_a[1]))); break;
        case 1: mouse_move((*reinterpret_cast< QMouseEvent*(*)>(_a[1]))); break;
        case 2: mouse_left_press((*reinterpret_cast< QMouseEvent*(*)>(_a[1]))); break;
        case 3: mouse_left_press(); break;
        case 4: mouse_right_press(); break;
        case 5: mouse_mid_press(); break;
        case 6: mouse_double_click(); break;
        case 7: frame_close(); break;
        case 8: quit_frame(); break;
        default: ;
        }
        _id -= 9;
    }
    return _id;
}
示例#3
0
int mouse()
{
 int ret=-1, go=1;
 char cmd1[]= "AT*EAID=1,1,\"Use joystick to move mouse & keypad for clicks\"\r";
 char cmd2[]= "AT+CMER=3,2,,,\r";
 char cmd3[]= "AT+CMER=0,0,,,\r";
 char buf[MAXLEN]="";
 char key;
 int status, mdelta=15, mwait=MOUSE_DELAY;
 int mup=0, mdown=0, mleft=0, mright=0;
 int mbleft=0, mbright=0, mbmiddle=0, mtoggle=0;

 Display *dpy = XOpenDisplay (NULL);

 if(dpy==NULL) return -1;
 writeport(cmd1, strlen(cmd1));
 if(waitfor("OK", 1, TIMEOUT) != 1) go = 0;
 
 writeport(cmd2, strlen(cmd2));
 if(waitfor("OK", 1, TIMEOUT) != 1) go = 0;
 
 while(go)
 {
  buf[0]=0;
  ret = readport(buf, MAXLEN, mwait);
  if( (ret <= 0 && ret != -EINTR) || strncmp(buf, "ERROR", 5)==0 )
  {
   ret=-1;
   break;
  }
  if(strncmp(buf, "*EAII: ", 7)==0 || strncmp(buf, "*EAAI", 5)==0)
  {
   ret=1;
   break;
  }
  if(strncmp(buf, "+CKEV: ", 7)==0)
  {
   key=buf[7];
   status=strchr(buf,',')[1]-'0';
   switch(key)
   {
    //Simply assume it's joy up coz T610 key report is buggy
    //case 27:
    // K700i is not buggy!
    case '^':
    case '5':
	mup=status;
	mwait=MOUSE_DELAY;
	break;
    case 'v':
    case '8':
	mdown=status;
	mwait=MOUSE_DELAY;
	break;
    case '<':
    case '4':
    case '7':
	mleft=status;
	mwait=MOUSE_DELAY;
	break;
    case '>':
    case '6':
    case '9':
	mright=status;
	mwait=MOUSE_DELAY;
	break;
    case '1':
    	if(mtoggle && status)
	{
	 mbleft = !mbleft;
	 mouse_down_up(dpy, 1, mbleft);
	}
	if(!mtoggle) mouse_down_up(dpy, 1, status);
	break;
    case '2':
    	if(mtoggle && status)
	{
	 mbmiddle = !mbmiddle;
	 mouse_down_up(dpy, 2, mbmiddle);
	}
	if(!mtoggle) mouse_down_up(dpy, 2, status);
	break;
    case '3':
    	if(mtoggle && status)
	{
	 mbright = !mbright;
	 mouse_down_up(dpy, 3, mbright);
	}
	if(!mtoggle) mouse_down_up(dpy, 3, status);
	break;
    case '*':
	if(status && !mtoggle) mouse_double_click(dpy);
	break;
    case '#':
	if(status)
	{
	 mtoggle = !mtoggle;
	 mbleft = mbright = mbmiddle = 0;
	}
	break;
   }
   if((key=='1' || key=='2' || key =='3') && !status
      && mtoggle && !mbleft && !mbmiddle && !mbright) mtoggle=0;
  }
  if(ret == -EINTR) mwait=MOUSE_RRATE;
  if(mup) mouse_rel_move(dpy, 0, -mdelta);
  if(mdown) mouse_rel_move(dpy, 0, mdelta);
  if(mright) mouse_rel_move(dpy, mdelta, 0);
  if(mleft) mouse_rel_move(dpy, -mdelta, 0);
 }
 
 writeport(cmd3, strlen(cmd3));
 if(waitfor("OK", 5, TIMEOUT) != 1) ret = -1;
 
 XCloseDisplay (dpy);
 return ret;
}
示例#4
0
文件: frame.cpp 项目: Fxrh/antico
void Frame::create_borders()
{
    layout = new QGridLayout(this); // 3x3 grid for window borders
    layout->setMargin(0);
    layout->setSpacing(0);
    setLayout(layout);

    // center frame where client apps is shown
    c_bdr = new Border(this);
    layout->addWidget(c_bdr, 1, 1);
    // top left border (icon)
    tl_bdr = new Border(this);
    tl_bdr->setToolTip(tr("Minimize(L)/Maximize(R)"));
    tl_bdr->setFixedSize(top_bdr_height, top_bdr_height);
    tl_bdr->setPixmap(minmax_pix);
    tl_bdr->setScaledContents(true);
    tl_bdr->setAlignment(Qt::AlignCenter);
    layout->addWidget(tl_bdr, 0, 0);
    // top right border (icon)
    tr_bdr = new Border(this);
    tr_bdr->setToolTip(tr("Close"));
    tr_bdr->setFixedSize(top_bdr_height, top_bdr_height);
    tr_bdr->setPixmap(close_pix);
    tr_bdr->setScaledContents(true);
    tr_bdr->setAlignment(Qt::AlignCenter);
    layout->addWidget(tr_bdr, 0, 2);
    // top mid header border (header frame)
    tm_bdr = new Header(cl_icon(), cl_name(), this);
    tm_bdr->set_pixmap(QPixmap(header_active_pix), QPixmap(header_inactive_pix), title_color);
    tm_bdr->setFixedHeight(top_bdr_height);
    layout->addWidget(tm_bdr, 0, 1);
    // bottom mid border
    bm_bdr = new Border(this);
    bm_bdr->setFixedHeight(bottom_bdr_height);
    bm_bdr->setCursor(Qt::SizeVerCursor);
    layout->addWidget(bm_bdr, 2, 1);
    // bottom left border
    bl_bdr = new Border(this);
    bl_bdr->setFixedSize(top_bdr_height, bottom_bdr_height);
    bl_bdr->setCursor(Qt::SizeBDiagCursor);
    layout->addWidget(bl_bdr, 2, 0);
    // bottom right border
    br_bdr = new Border(this);
    br_bdr->setFixedSize(top_bdr_height, bottom_bdr_height);
    br_bdr->setCursor(Qt::SizeFDiagCursor);
    layout->addWidget(br_bdr, 2, 2);
    // left border
    l_bdr = new Border(this);
    l_bdr->setCursor(Qt::SizeHorCursor);
    layout->addWidget(l_bdr, 1, 0);
    // right border
    r_bdr = new Border(this);
    r_bdr->setCursor(Qt::SizeHorCursor);
    layout->addWidget(r_bdr, 1, 2);

    if (frame_type == "Dialog") // no Max/Min on Dialog frames
    {
        tl_bdr->setEnabled(false);
    }

    // top left (icon)
    connect(tl_bdr, SIGNAL(mouse_left_press()), this, SLOT(iconify_it()));
    connect(tl_bdr, SIGNAL(mouse_right_press()), this, SLOT(maximize_it()));
    // top right (icon)
    connect(tr_bdr, SIGNAL(mouse_left_press()), this, SLOT(destroy_it()));
    // top mid (title bar)
    connect(tm_bdr, SIGNAL(mouse_double_click()), this, SLOT(iconify_it()));
    connect(tm_bdr, SIGNAL(mouse_left_press(QMouseEvent *)), this, SLOT(press_top_mid(QMouseEvent *)));
    connect(tm_bdr, SIGNAL(mouse_right_press()), this, SLOT(maximize_it()));
    connect(tm_bdr, SIGNAL(mouse_move(QMouseEvent *)), this, SLOT(move_top_mid(QMouseEvent *)));
    // bottom left
    connect(bl_bdr, SIGNAL(mouse_left_press(QMouseEvent *)), this, SLOT(press_bottom_left(QMouseEvent *)));
    connect(bl_bdr, SIGNAL(mouse_move(QMouseEvent *)), this, SLOT(move_bottom_left(QMouseEvent *)));
    // bottom right
    connect(br_bdr, SIGNAL(mouse_left_press(QMouseEvent *)), this, SLOT(press_bottom_right(QMouseEvent *)));
    connect(br_bdr, SIGNAL(mouse_move(QMouseEvent *)), this, SLOT(move_bottom_right(QMouseEvent *)));
    // bottom mid
    connect(bm_bdr, SIGNAL(mouse_left_press(QMouseEvent *)), this, SLOT(press_bottom_mid(QMouseEvent *)));
    connect(bm_bdr, SIGNAL(mouse_move(QMouseEvent *)), this, SLOT(move_bottom_mid(QMouseEvent *)));
    // left
    connect(l_bdr, SIGNAL(mouse_left_press(QMouseEvent *)), this, SLOT(press_left(QMouseEvent *)));
    connect(l_bdr, SIGNAL(mouse_move(QMouseEvent *)), this, SLOT(move_left(QMouseEvent *)));
    // right
    connect(r_bdr, SIGNAL(mouse_left_press(QMouseEvent *)), this, SLOT(press_right(QMouseEvent *)));
    connect(r_bdr, SIGNAL(mouse_move(QMouseEvent *)), this, SLOT(move_right(QMouseEvent *)));
}