示例#1
0
void MouseController::mouseMove(int x, int y)
{
    Display *displayMain = XOpenDisplay(NULL);

    if(displayMain == NULL)
    {
        fprintf(stderr, "Errore nell'apertura del Display !!!\n");
        exit(EXIT_FAILURE);
    }

    XWarpPointer(displayMain, None, None, 0, 0, 0, 0, x, y);

    XCloseDisplay(displayMain);
};
示例#2
0
文件: main.c 项目: daschuer/Cinnamon
static void
center_pointer_on_screen ()
{
  Display *dpy;
  Window root_window;
  Screen *screen;
  
  dpy = XOpenDisplay(0);
  root_window = XRootWindow(dpy, 0);
  XSelectInput(dpy, root_window, KeyReleaseMask);
  screen = DefaultScreenOfDisplay(dpy);
  XWarpPointer(dpy, None, root_window, 0, 0, 0, 0, WidthOfScreen(screen)/2, HeightOfScreen(screen)/2);
  XFlush(dpy);
}
void mouseMove(int x, int y)
{
	Display *displayMain = XOpenDisplay(NULL);

	if(displayMain == NULL)
	{
		fprintf(stderr, "Error Opening the Display !!!\n");
		exit(EXIT_FAILURE);
	}

	XWarpPointer(displayMain, None, None, 0, 0, 0, 0, x, y);

	XCloseDisplay(displayMain);
}
示例#4
0
文件: vid_glx.c 项目: matatk/agrip
static void install_grabs(void)
{
    int MajorVersion, MinorVersion;

    input_grabbed = true;

    // don't show mouse cursor icon
    XDefineCursor(x_disp, x_win, CreateNullCursor(x_disp, x_win));

    XGrabPointer(x_disp, x_win,
                 True,
                 0,
                 GrabModeAsync, GrabModeAsync,
                 x_win,
                 None,
                 CurrentTime);

#ifdef USE_DGA
    if (!COM_CheckParm("-nodga") &&
            XF86DGAQueryVersion(x_disp, &MajorVersion, &MinorVersion)) {
        // let us hope XF86DGADirectMouse will work
        XF86DGADirectVideo(x_disp, DefaultScreen(x_disp), XF86DGADirectMouse);
        dgamouse = true;
        XWarpPointer(x_disp, None, x_win, 0, 0, 0, 0, 0, 0); // oldman: this should be here really
    }
    else
#endif
        XWarpPointer(x_disp, None, x_win,
                     0, 0, 0, 0,
                     vid.width / 2, vid.height / 2);

    XGrabKeyboard(x_disp, x_win,
                  False,
                  GrabModeAsync, GrabModeAsync,
                  CurrentTime);
}
示例#5
0
void InputImpl::setMousePosition(const Vector2i& position, const Window& relativeTo)
{
    // Open a connection with the X server
    Display* display = OpenDisplay();

    WindowHandle handle = relativeTo.getSystemHandle();
    if (handle)
    {
        XWarpPointer(display, None, handle, 0, 0, 0, 0, position.x, position.y);
        XFlush(display);
    }

    // Close the connection with the X server
    CloseDisplay(display);
}
示例#6
0
static void
gtkmouse_reset_pointer( void )
{
  /* Ugh. GDK doesn't have its own move-pointer function :-|
   * Framebuffer users and win32 users will have to make their own
   * arrangements here.
   *
   * For Win32, use SetCursorPos() -- see sdpGtkWarpPointer() at
   * http://k3d.cvs.sourceforge.net/k3d/projects/sdplibs/sdpgtk/sdpgtkutility.cpp?view=markup
   */
  GdkWindow *window = gtk_widget_get_window( gtkui_drawing_area );

  XWarpPointer( GDK_WINDOW_XDISPLAY( window ), None, 
                GDK_WINDOW_XID( window ), 0, 0, 0, 0, 128, 128 );
}
示例#7
0
void CMD_WarpToWindow(F_CMD_ARGS)
{
  int val1_unit, val2_unit, n;
  int val1, val2;

  n = GetTwoArguments(action, &val1, &val2, &val1_unit, &val2_unit);
  if (context != C_UNMANAGED)
  {
    if (DeferExecution(eventp,&w,&tmp_win,&context,CRS_SELECT,ButtonRelease))
      return;
    if (n == 2)
      warp_to_fvwm_window(eventp, tmp_win, val1, val1_unit, val2, val2_unit);
    else
      warp_to_fvwm_window(eventp, tmp_win, 0, 0, 0, 0);
  }
  else
  {
    int x = 0;
    int y = 0;

    if (n == 2)
    {
      int wx;
      int wy;
      unsigned int ww;
      unsigned int wh;

      if (!XGetGeometry(
	dpy, w, &JunkRoot, &wx, &wy, &ww, &wh, &JunkBW, &JunkDepth))
      {
	return;
      }
      if (val1_unit != Scr.MyDisplayWidth)
	x = val1;
      else
	x = (ww - 1) * val1 / 100;
      if (val2_unit != Scr.MyDisplayHeight)
	y = val2;
      else
	y = (wh - 1) * val2 / 100;
      if (x < 0)
	x += ww;
      if (y < 0)
	y += wh;
    }
    XWarpPointer(dpy, None, w, 0, 0, 0, 0, x, y);
  }
}
示例#8
0
/* _xwin_mousedrv_position:
 *  Sets the position of the mickey-mode mouse.
 */
static void _xwin_mousedrv_position(int x, int y)
{
   XLOCK();

   _mouse_x = x;
   _mouse_y = y;

   mymickey_x = mymickey_y = 0;

   if (_xwin.hw_cursor_ok)
      XWarpPointer(_xwin.display, _xwin.window, _xwin.window, 0, 0, 
                   _xwin.window_width, _xwin.window_height, x, y);
   XUNLOCK();

   _xwin_set_warped_mouse_mode(FALSE);
}
示例#9
0
void clViewport::SetMousePosition( float X, float Y )
{
#if defined(OS_WINDOWS)
    POINT Pnt;
    Pnt.x = static_cast<int>( X * FWidth );
    Pnt.y = static_cast<int>( Y * FHeight );
    ClientToScreen( FWindowHandle, &Pnt );
    SetCursorPos( Pnt.x, Pnt.y );
#elif defined(OS_LINUX) && !defined(OS_ANDROID)
    XWarpPointer( FDisplay, None, *FWindow, 0, 0, 0, 0, static_cast<int>( X * FWidth ), static_cast<int>( Y * FHeight ) );
#elif defined(OS_ANDROID)
    TODO( "Implement" );
#else
#error Target OS not recognized
#endif
}
示例#10
0
void X11_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
{
	if ( using_dga & DGA_MOUSE ) {
		SDL_PrivateMouseMotion(0, 0, x, y);
	} else if ( mouse_relative) {
		/*	RJR: March 28, 2000
			leave physical cursor at center of screen if
			mouse hidden and grabbed */
		SDL_PrivateMouseMotion(0, 0, x, y);
	} else {
		SDL_Lock_EventThread();
		XWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0, x, y);
		XSync(SDL_Display, False);
		SDL_Unlock_EventThread();
	}
}
示例#11
0
int main(int argc,char * argv[]) {
    int x , y;
    x=atoi(argv[1]);
    y=atoi(argv[2]);
    Display *display = XOpenDisplay(0);
    Window root = DefaultRootWindow(display);

    XWarpPointer(display, None, root, 0, 0, 0, 0, x, y);

    //mouseClick(Button1);
    XFlush(display);


    //XCloseDisplay(display);
    return 0;
}
示例#12
0
void OS_X11::warp_mouse_pos(const Point2& p_to) {

	if (mouse_mode==MOUSE_MODE_CAPTURED) {

		last_mouse_pos=p_to;
	} else {

		/*XWindowAttributes xwa;
		XGetWindowAttributes(x11_display, x11_window, &xwa);
		printf("%d %d\n", xwa.x, xwa.y); needed? */

		XWarpPointer(x11_display, None, x11_window,
			      0,0,0,0, (int)p_to.x , (int)p_to.y);
	}

}
示例#13
0
文件: xui.c 项目: twinaphex/sdcell
int ui_event(void)
{
  XEvent event;

  while(XCheckMaskEvent(display,~NoEventMask,&event)) {
    switch(event.type) {
    case ConfigureNotify:
      xdisplay_configure_notify(event.xconfigure.width,
				event.xconfigure.height);
      break;
    case Expose:
      xdisplay_area( event.xexpose.x, event.xexpose.y,
		     event.xexpose.width, event.xexpose.height );
      break;
    case ButtonPress:
      ui_mouse_button( event.xbutton.button, 1 );
      break;
    case ButtonRelease:
      ui_mouse_button( event.xbutton.button, 0 );
      break;
    case MotionNotify:
      if( ui_mouse_grabbed ) {
        ui_mouse_motion( event.xmotion.x - 128, event.xmotion.y - 128 );
        if( event.xmotion.x != 128 || event.xmotion.y != 128 )
          XWarpPointer( display, None, xui_mainWindow, 0, 0, 0, 0, 128, 128 );
      }
      break;
    case FocusOut:
      keyboard_release_all();
      ui_mouse_suspend();
      break;
    case FocusIn:
      ui_mouse_resume();
      break;
    case KeyPress:
      xkeyboard_keypress(&(event.xkey));
      break;
    case KeyRelease:
      xkeyboard_keyrelease(&(event.xkey));
      break;
    case ClientMessage:
      if( event.xclient.data.l[0] == delete_window_atom ) fuse_exiting = 1;
      break;
    }
  }
  return 0;
}
// ----------------------------------------------------------------------------
// Description:
// Timer set on each render step. Handle mouse, keyboard and gamepad movement and move the camera accordingly.
void vtkInteractorStyleGame::OnTimer()
{
    vtkRenderWindowInteractor *rwi = this->Interactor;
    vtkXOpenGLRenderWindow *rw = static_cast<vtkXOpenGLRenderWindow *>(rwi->GetRenderWindow());
    int *size = rw->GetSize();
    Window Win = rw->GetWindowId();
    Display* Disp = rw->GetDisplayId();

    if (this->gamepad->IsActive())
    {
        // Get updated gamepad state
        this->handleGamepadState(this->gamepad->getGamepadState());
    }

    double dt = ((double)(clock() - t))/CLOCKS_PER_SEC;
    t = clock();

    if(this->gamepadSpeed.y != 0 || this->keyboardSpeed.y != 0)
        this->MoveToFocalPoint(dt);
    if(this->gamepadSpeed.x != 0 || this->keyboardSpeed.x != 0)
        this->Pan(dt);

    if(this->gamepadRoll != 0 || this->keyboardRoll != 0)
        this->CameraRoll(dt);
    if(this->gamepaddt.x !=0)
        //this->ModelRotate(dt);
        this->CameraYaw(dt);
    if(this->gamepaddt.y !=0)
        this->Up(dt);
        //this->CameraPitch(dt);

    if(this->flying)
        this->Fly(dt);

    if (this->modelRotateSpeed != 0)
    {
        //printf("modelRotateSpeed = %g\n", this->modelRotateSpeed);
        this->ModelRotate(dt);
    }

    //if(this->rotate)
        //this->Rotate(dt);

    mousedt.x = 0;
    mousedt.y = 0;
    XWarpPointer(Disp, Win, Win, 0,0,size[0],size[1], roundl(size[0]/2), roundl(size[1]/2));
}
示例#15
0
int iupdrvSetGlobal(const char *name, const char *value)
{
  if (iupStrEqual(name, "LANGUAGE"))
  {
    iupStrMessageUpdateLanguage(value);
    return 1;
  }
  if (iupStrEqual(name, "AUTOREPEAT"))
  {
    XKeyboardControl values;
    if (iupStrBoolean(value))
      values.auto_repeat_mode = 1;
    else
      values.auto_repeat_mode = 0;
    XChangeKeyboardControl(iupmot_display, KBAutoRepeatMode, &values);
    return 0;
  }
  if (iupStrEqual(name, "CURSORPOS"))
  {
    int x, y;
    if (iupStrToIntInt(value, &x, &y, 'x') == 2)
      XWarpPointer(iupmot_display,None,RootWindow(iupmot_display, iupmot_screen),0,0,0,0,x,y);
    return 0;
  }
  if (iupStrEqual(name, "KEYPRESS"))
  {
    int key;
    if (iupStrToInt(value, &key))
      motGlobalSendKey(key, 0x01);
    return 0;
  }
  if (iupStrEqual(name, "KEYRELEASE"))
  {
    int key;
    if (iupStrToInt(value, &key))
      motGlobalSendKey(key, 0x02);
    return 0;
  }
  if (iupStrEqual(name, "KEY"))
  {
    int key;
    if (iupStrToInt(value, &key))
      motGlobalSendKey(key, 0x03);
    return 0;
  }
  return 1;
}
示例#16
0
void xinput_update(int keyb_leds, int flags)
{
  xinput_keyb_leds = keyb_leds;
  if (xinput_focus)
     xinput_set_leds(keyb_leds);

  if (!xinput_force_grab && (flags & SYSDEP_DISPLAY_HOTKEY_GRABMOUSE))
  {
     if (xinput_mouse_grabbed)
     {
        XUngrabPointer (display, CurrentTime);
        if (xinput_cursors_allocated && xinput_show_cursor)
           XDefineCursor (display, window, xinput_normal_cursor);
        xinput_mouse_grabbed = 0;
        xinput_grab_mouse = 0;
     }
     else if (!XGrabPointer (display, window, True,
                 PointerMotionMask|ButtonPressMask|ButtonReleaseMask,
                 GrabModeAsync, GrabModeAsync, window, None, CurrentTime))
     {
        if (xinput_cursors_allocated && xinput_show_cursor)
           XDefineCursor (display, window, xinput_invisible_cursor);
	XWarpPointer(display, None, window, 0, 0, 0, 0,
	  window_width/2, window_height/2);
        xinput_mouse_grabbed = 1;
        xinput_grab_mouse = 1;
     }
  }

  /* toggle keyboard grabbing */
  if ((xinput_force_grab!=X11_FORCE_INPUT_GRAB) &&
      (flags & SYSDEP_DISPLAY_HOTKEY_GRABKEYB))
  {
    if (xinput_keyboard_grabbed)
    {
      XUngrabKeyboard (display, CurrentTime);
      xinput_keyboard_grabbed = 0;
      xinput_grab_keyboard = 0;
    }
    else if (!XGrabKeyboard(display, window, True, GrabModeAsync, GrabModeAsync, CurrentTime))
    {
      xinput_keyboard_grabbed = 1;
      xinput_grab_keyboard = 1;
    }
  }
}
示例#17
0
void PopMouse(Display *disp)
{
    t_mpos *old;

    old = mpos;
    if (!old)
    {
        return;
    }

    XWarpPointer(disp, None, DefaultRootWindow(disp), 0, 0, 0, 0, old->x, old->y);
#ifdef DEBUG
    fprintf(stderr, "Popmouse %d, %d\n", old->x, old->y);
#endif
    mpos = old->prev;
    sfree(old);
}
示例#18
0
void
panel_warp_pointer (GdkWindow *gdk_window,
		    int        x,
		    int        y)
{
	Display *display;
	Window   window;

	g_return_if_fail (GDK_IS_WINDOW (gdk_window));

	display = GDK_WINDOW_XDISPLAY (gdk_window);
	window  = GDK_WINDOW_XID (gdk_window);

	gdk_error_trap_push ();
	XWarpPointer (display, None, window, 0, 0, 0, 0, x, y);
	gdk_error_trap_pop_ignored ();
}
示例#19
0
void lock_cursor_x11(bool lock,bool *locked,Display *display,
                     Window win,Cursor blankCursor,
                     int cursorX,int cursorY) {
   //





  if(lock) {
    XWindowAttributes window_attributes;
    XGetWindowAttributes(display,win,&window_attributes);

    int w=window_attributes.width;
    int h=window_attributes.height;

    XWarpPointer(display,win,win,0,0,w,h,
                 cursorX,cursorY );


    int event_mask= ButtonPressMask|
      ButtonReleaseMask|
      // OwnerGrabButtonMask | Expose|PointerMotionHintMask|
      PointerMotionMask |FocusChangeMask|
      EnterWindowMask|LeaveWindowMask;

    if(!(*locked)) {
      XDefineCursor(display,win,blankCursor);
      int grabResult=XGrabPointer(display,win, False,
                                  event_mask,GrabModeAsync,GrabModeAsync,
                                  win, None, CurrentTime);

      if(grabResult==GrabSuccess) {
        *locked=true;
      }
    }
  } else {
    if(*locked) {
      XUndefineCursor(display,win);
       XUngrabPointer(display,CurrentTime);
    }

    *locked=false;
  }
}
void CUnixEventEmitter::emulateMouseRawMode(bool enable)
{
	_emulateRawMode = enable;

	if(_emulateRawMode)
	{
		XWindowAttributes xwa;
		XGetWindowAttributes(_dpy, _win, &xwa);
		XWarpPointer(_dpy, None, _win, None, None, None, None,
			(xwa.width / 2), (xwa.height / 2));

		// remove all outstanding mouse move events, they happened before the mouse
		// was pulled back to 0.5 / 0.5, so a wrong movement delta would be
		// reported otherwise
		XEvent event;
		while(XCheckIfEvent(_dpy, &event, &isMouseMoveEvent, NULL)) { };
	}
}
示例#21
0
文件: screen.c 项目: wavebeem/wmfs
/** Set the selected screen
 *\param screen Number of the wanted selected screen
*/
void
screen_set_sel(int screen)
{
     if(screen < 0 || screen > screen_count() - 1)
          screen = 0;

     if(selscreen != screen)
          prevselscreen = selscreen;

     client_focus(NULL);
     XWarpPointer(dpy, None, ROOT, 0, 0, 0, 0,
                  sgeo[screen].x + sgeo[screen].width / 2,
                  sgeo[screen].y + sgeo[screen].height / 2);

     selscreen = screen;

     return;
}
示例#22
0
文件: clientwin.c 项目: z24/skippy-xd
static void
childwin_focus(ClientWin *cw) {
	session_t * const ps = cw->mainwin->ps;

	if (ps->o.movePointerOnRaise)
		XWarpPointer(cw->mainwin->ps->dpy, None, cw->wid_client, 0, 0, 0, 0, cw->src.width / 2, cw->src.height / 2);

        XEvent ev;
        ev.xclient.type = ClientMessage;
        ev.xclient.window = cw->wid_client;
        ev.xclient.message_type = XInternAtom(cw->mainwin->ps->dpy, "_NET_ACTIVE_WINDOW", False);
        ev.xclient.format = 32;
        XSendEvent(cw->mainwin->ps->dpy, DefaultRootWindow(cw->mainwin->ps->dpy), False, SubstructureRedirectMask | SubstructureNotifyMask, &ev);
        XMapRaised(cw->mainwin->ps->dpy, cw->wid_client);

        /* XRaiseWindow(cw->mainwin->ps->dpy, cw->wid_client); */
	/* XSetInputFocus(cw->mainwin->ps->dpy, cw->wid_client, RevertToParent, CurrentTime); */
}
示例#23
0
bool shgPhases::altPress(int x, int y) {
   // returns true if a redraw is called for (in which case a scroll
   // is done as well as an XWarpPointer)
   if (!existsCurrent())
      return false;

   if (currInstalledAltMoveHandler) {
      if (ignoreNextShgAltMove) {
         ignoreNextShgAltMove = false;
         return false;
      }

      int deltax = x - shgAltAnchorX;
      int deltay = y - shgAltAnchorY;

      // add some extra speedup juice as an incentive to use alt-mousemove scrolling
      deltax *= 4;
      deltay *= 4;

      getCurrent().adjustHorizSBOffsetFromDeltaPix(deltax);
      getCurrent().adjustVertSBOffsetFromDeltaPix(deltay);

#if !defined(i386_unknown_nt4_0)
      XWarpPointer(Tk_Display(theTkWindow),
		   Tk_WindowId(theTkWindow),
		   Tk_WindowId(theTkWindow),
		   0, 0, 0, 0,
		   shgAltAnchorX, shgAltAnchorY);
#else // !defined(i386_unknown_nt4_0)
	// TODO - implement warping support
#endif // !defined(i386_unknown_nt4_0)

      ignoreNextShgAltMove = true;
         
      return true;
   }
   else {
      shgAltAnchorX = x;
      shgAltAnchorY = y;

      currInstalledAltMoveHandler = true;
      return false;
   }
}
示例#24
0
文件: ifr_xkbd.c 项目: clemej/ifrac
int kbd_interface_start(void)
{
   int mask;	

#ifdef USE_XDGA
  if (dgaModeCurrent >= 0)
  {
	mask= KeyPressMask;
#ifdef	USE_MOUSE
	if (MouseInUse) mask |= ButtonPressMask;
#endif	 
	XDGASelectInput(disp, scrno,  mask); 
	flush_all_pane(PT_FOREGROUND);
  }
  else 
#endif
  {  
	mask = ExposureMask | KeyPressMask | 
	       StructureNotifyMask | SubstructureNotifyMask |
	       VisibilityChangeMask;
#ifdef	USE_MOUSE
	if (MouseInUse) mask |= ButtonPressMask;
#endif	 
	XSelectInput(disp, wnd, mask);

	WMProtAtom = XInternAtom(disp, "WM_PROTOCOLS", True);
	WMDelAtom = XInternAtom(disp, "WM_DELETE_WINDOW", True);
    
	if (WMProtAtom != (Atom)None && WMDelAtom != (Atom)None)
		XSetWMProtocols(disp, wnd, &WMDelAtom, 1);
	XMapWindow(disp, wnd);

		flush_all_pane(PT_FOREGROUND);

/*   if (cm_type == CM_PALETTE) */
		{	  XWarpPointer(disp, None, wnd, 0, 0, 0, 0, 10, 10);
/*      XSetInputFocus(disp, wnd, RevertToParent, CurrentTime);   */
    }    
  }
#ifdef	USE_MOUSE
	if (MouseInUse)	mouse_interface_start();
#endif	 
  return 1;
}
示例#25
0
void InvokeMouseEvent( PRENDERER hVideo, GLWindow *x11_gl_window  )
{
    if( l.flags.bRotateLock  )
    {
        RCOORD delta_x = x11_gl_window->mouse_x - (hVideo->WindowPos.cx/2);
        RCOORD delta_y = x11_gl_window->mouse_y - (hVideo->WindowPos.cy/2);
        //lprintf( WIDE("mouse came in we're at %d,%d %g,%g"), x11_gl_window->mouse_x, x11_gl_window->mouse_y, delta_x, delta_y );
        if( delta_y && delta_y )
        {
            static int toggle;
            delta_x /= hVideo->WindowPos.cx;
            delta_y /= hVideo->WindowPos.cy;
            if( toggle )
            {
                RotateRel( l.origin, delta_y, 0, 0 );
                RotateRel( l.origin, 0, delta_x, 0 );
            }
            else
            {
                RotateRel( l.origin, 0, delta_x, 0 );
                RotateRel( l.origin, delta_y, 0, 0 );
            }
            toggle = 1-toggle;
            x11_gl_window->mouse_x = hVideo->WindowPos.cx/2;
            x11_gl_window->mouse_y = hVideo->WindowPos.cy/2;
				lprintf( WIDE("Set curorpos.. %d,%d")
						 , x11_gl_window->mouse_x, x11_gl_window->mouse_y
						 );
            XWarpPointer( x11_gl_window->dpy, None
                         , XRootWindow( x11_gl_window->dpy, 0)
                         , 0, 0, 0, 0
                         , x11_gl_window->mouse_x, x11_gl_window->mouse_y);
            //SetCursorPos( hVideo->pWindowPos.cx/2, hVideo->pWindowPos.cy / 2 );
            //lprintf( WIDE("Set curorpos Done..") );
        }
    }
    else if (hVideo->pMouseCallback)
    {
        hVideo->pMouseCallback (hVideo->dwMouseData
                                , x11_gl_window->mouse_x
                                , x11_gl_window->mouse_y
                                , x11_gl_window->mouse_b);
    }
}
示例#26
0
int main() {
    Window w, c;
    int x, y, wx, wy;
    unsigned int m;

    Display *display = XOpenDisplay(NULL);
    if(display == NULL)
        return EXIT_FAILURE;

    Window root = DefaultRootWindow(display);
    XQueryPointer(display, root, &w, &c, &x, &y, &wx, &wy, &m);

    XWarpPointer(display, None, root, 0, 0, 0, 0, (x + SCREEN_WIDTH) % (SCREEN_WIDTH * 2), y);

    XFlush(display);
    XCloseDisplay(display);

    return EXIT_SUCCESS;
}
示例#27
0
static void uninstall_grabs( void ) {
	if ( dgamouse ) {
		dgamouse = qfalse;
		XF86DGADirectVideo( dpy, DefaultScreen( dpy ), 0 );
	}

	XChangePointerControl( dpy, qtrue, qtrue, mouse_accel_numerator,
						   mouse_accel_denominator, mouse_threshold );

	XUngrabPointer( dpy, CurrentTime );
	XUngrabKeyboard( dpy, CurrentTime );

	XWarpPointer( dpy, None, win,
				  0, 0, 0, 0,
				  glConfig.vidWidth / 2, glConfig.vidHeight / 2 );

	// inviso cursor
	XUndefineCursor( dpy, win );
}
示例#28
0
/*
 * Moves the mouse pointer to given window coordinates
 */
void glutWarpPointer( int x, int y )
{
    if (dpy == NULL)
    {
      fprintf(stderr, "glutWarpPointer failed: MicroGlut not initialized!\n");
    	return;
    }

    XWarpPointer(
        dpy, // fgDisplay.Display,
        None,
        win, // fgStructure.CurrentWindow->Window.Handle,
        0, 0, 0, 0,
        x, y
    );
    /* Make the warp visible immediately. */
    XFlush( dpy );
//    XFlush( fgDisplay.Display );
}
示例#29
0
文件: xui.c 项目: twinaphex/sdcell
int
ui_mouse_grab( int startup )
{
  if( startup ) return 0;

  switch( XGrabPointer( display, xui_mainWindow, True,
			ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
			GrabModeAsync, GrabModeAsync, xui_mainWindow,
			nullpointer, CurrentTime )
	) {
  case GrabSuccess:
  case GrabNotViewable:
    XWarpPointer( display, None, xui_mainWindow, 0, 0, 0, 0, 128, 128 );
    return 1;
  default:
    ui_error( UI_ERROR_WARNING, "Mouse grab failed" );
    return 0;
  }
}
示例#30
-1
void sysdep_display_update_mouse(void)
{
	int i;
	/* DGA? */
	if ((sysdep_display_params.video_mode == X11_WINDOW) &&
	    sysdep_display_params.fullscreen)
	{
		/* 2 should be MOUSE_AXES but we don't support more
		   than 2 axes at the moment so this is faster */
		for (i=0; i<2; i++)
		{
			sysdep_display_mouse_data[0].deltas[i] = xinput_mouse_motion[i];
			xinput_mouse_motion[i] = 0;
		}
	}
	else
	{
		Window root,child;
		int root_x, root_y, pos_x, pos_y;
		unsigned int keys_buttons;

		if (!XQueryPointer(display, window, &root,&child, &root_x,&root_y,
					&pos_x,&pos_y,&keys_buttons) )
		{
			sysdep_display_mouse_data[0].deltas[0] = 0;
			sysdep_display_mouse_data[0].deltas[1] = 0;
			return;
		}

		if ( xinput_mouse_grabbed )
		{
			XWarpPointer(display, None, window, 0, 0, 0, 0,
					window_width/2, window_height/2);
			sysdep_display_mouse_data[0].deltas[0] = pos_x - window_width/2;
			sysdep_display_mouse_data[0].deltas[1] = pos_y - window_height/2;
		}
		else if ( xinput_always_use_mouse )
		{
			sysdep_display_mouse_data[0].deltas[0] = pos_x - xinput_current_mouse[0];
			sysdep_display_mouse_data[0].deltas[1] = pos_y - xinput_current_mouse[1];
		}
		else
		{
			sysdep_display_mouse_data[0].deltas[0] = 0;
			sysdep_display_mouse_data[0].deltas[1] = 0;
		}
		xinput_current_mouse[0] = pos_x;
		xinput_current_mouse[1] = pos_y;
	}
}