static void install_grabs(void)
{
	XSync(dpy, False);

	hildon_set_non_compositing();

	XDefineCursor(dpy, win, CreateNullCursor(dpy, win));

	XGrabPointer(dpy, win, False, MOUSE_MASK, GrabModeAsync, GrabModeAsync,
		     win, None, CurrentTime);

	XGetPointerControl(dpy, &mouse_accel_numerator,
			   &mouse_accel_denominator, &mouse_threshold);

	XChangePointerControl(dpy, True, True, 1, 1, 0);

	XSync(dpy, False);

	mwx = glConfig.vidWidth / 2;
	mwy = glConfig.vidHeight / 2;
	mx = my = 0;

	XGrabKeyboard(dpy, win, False, GrabModeAsync, GrabModeAsync,
		      CurrentTime);

	XSync(dpy, False);
}
Beispiel #2
0
/*
===========
IN_GrabMouse
===========
*/
void IN_GrabMouse (void)
{
	if (mouse_available && !mouse_grab_active && x_win)
	{
		XWindowAttributes attribs_1;
		XSetWindowAttributes attribs_2;

		XGetWindowAttributes(x_disp, x_win, &attribs_1);
		attribs_2.event_mask = attribs_1.your_event_mask | KEY_MASK | MOUSE_MASK;
		XChangeWindowAttributes(x_disp, x_win, CWEventMask, &attribs_2);

		// hide cursor
		XDefineCursor(x_disp, x_win, CreateNullCursor());
		// grab pointer
		XGrabPointer(x_disp, x_win, True, 0, GrabModeAsync, GrabModeAsync, x_win, None, CurrentTime);

		if (dga_mouse_available)
		{
			if (!vidmode_fullscreen && (vid.width < 640 || vid.height < 480))
				Con_Warning ("Running low-res windowed mode, XFree86 DGA Mouse disabled\n");
			else
				IN_ActivateDGAMouse();

		}

		mouse_grab_active = true;
	}
}
static void install_grabs(void)
{
  // inviso cursor
  XWarpPointer(dpy, None, win,
               0, 0, 0, 0,
               glConfig.vidWidth / 2, glConfig.vidHeight / 2);
  XSync(dpy, False);

  XDefineCursor(dpy, win, CreateNullCursor(dpy, win));

  XGrabPointer(dpy, win, // bk010108 - do this earlier?
               False,
               MOUSE_MASK,
               GrabModeAsync, GrabModeAsync,
               win,
               None,
               CurrentTime);

  XGetPointerControl(dpy, &mouse_accel_numerator, &mouse_accel_denominator,
                     &mouse_threshold);

  XChangePointerControl(dpy, True, True, 1, 1, 0);

  XSync(dpy, False);

  mouseResetTime = Sys_Milliseconds ();

#ifdef HAVE_XF86DGA
  if (in_dgamouse->value)
  {
    int MajorVersion, MinorVersion;

    if (!XF86DGAQueryVersion(dpy, &MajorVersion, &MinorVersion))
    {
      // unable to query, probalby not supported, force the setting to 0
      ri.Printf( PRINT_ALL, "Failed to detect XF86DGA Mouse\n" );
      ri.Cvar_Set( "in_dgamouse", "0" );
    } else
    {
      XF86DGADirectVideo(dpy, DefaultScreen(dpy), XF86DGADirectMouse);
      XWarpPointer(dpy, None, win, 0, 0, 0, 0, 0, 0);
    }
  } else
#endif /* HAVE_XF86DGA */
  {
    mwx = glConfig.vidWidth / 2;
    mwy = glConfig.vidHeight / 2;
    mx = my = 0;
  }

  XGrabKeyboard(dpy, win,
                False,
                GrabModeAsync, GrabModeAsync,
                CurrentTime);

  XSync(dpy, False);
}
Beispiel #4
0
static void install_grabs_mouse( void )
{
	int i;
	int num_devices;
	XIDeviceInfo *info;
	XIEventMask mask;

	assert( x11display.dpy && x11display.win );

	if( mouse_active )
		return;

	XDefineCursor(x11display.dpy, x11display.win, CreateNullCursor(x11display.dpy, x11display.win));

	mask.deviceid = XIAllDevices;
	mask.mask_len = XIMaskLen(XI_LASTEVENT);
	mask.mask = calloc(mask.mask_len, sizeof(char));
	XISetMask(mask.mask, XI_Enter);
	XISetMask(mask.mask, XI_Leave);
	XISetMask(mask.mask, XI_ButtonPress);
	XISetMask(mask.mask, XI_ButtonRelease);

	info = XIQueryDevice(x11display.dpy, XIAllDevices, &num_devices);
	for(i = 0; i < num_devices; i++) {
		int id = info[i].deviceid;
		if(info[i].use == XISlavePointer) {
			mask.deviceid = id;
			XIGrabDevice(x11display.dpy, id, x11display.win, CurrentTime, None, GrabModeSync,
				GrabModeSync, True, &mask);
		}
		else if(info[i].use == XIMasterPointer) {
			if (x11display.features.wmStateFullscreen)
				XIWarpPointer(x11display.dpy, id, None, x11display.win, 0, 0, 0, 0, 0, 0);
			else
				XIWarpPointer(x11display.dpy, id, None, x11display.win, 0, 0, 0, 0, x11display.win_width/2, x11display.win_height/2);
		}
	}
	XIFreeDeviceInfo(info);

	mask.deviceid = XIAllDevices;
	memset(mask.mask, 0, mask.mask_len);
	XISetMask(mask.mask, XI_RawMotion);

	XISelectEvents(x11display.dpy, DefaultRootWindow(x11display.dpy), &mask, 1);

	free(mask.mask);

	XSync(x11display.dpy, True);

	mx = my = 0;
	mouse_active = qtrue;
}
Beispiel #5
0
static void install_grabs(void)
{
// inviso cursor
	XDefineCursor(dpy, win, CreateNullCursor(dpy, win));

	XGrabPointer(dpy, win,
				 False,
				 MOUSE_MASK,
				 GrabModeAsync, GrabModeAsync,
				 win,
				 None,
				 CurrentTime);

	XGetPointerControl(dpy, &mouse_accel_numerator, &mouse_accel_denominator,
		&mouse_threshold);

	XChangePointerControl(dpy, qtrue, qtrue, 2, 1, 0);

	if (in_dgamouse->value) {
		int MajorVersion, MinorVersion;

		if (!XF86DGAQueryVersion(dpy, &MajorVersion, &MinorVersion)) { 
			// unable to query, probalby not supported
			ri.Printf( PRINT_ALL, "Failed to detect XF86DGA Mouse\n" );
			ri.Cvar_Set( "in_dgamouse", "0" );
		} else {
			dgamouse = qtrue;
			XF86DGADirectVideo(dpy, DefaultScreen(dpy), XF86DGADirectMouse);
			XWarpPointer(dpy, None, win, 0, 0, 0, 0, 0, 0);
		}
	} else {
		XWarpPointer(dpy, None, win,
					 0, 0, 0, 0,
					 glConfig.vidWidth / 2, glConfig.vidHeight / 2);
	}

	XGrabKeyboard(dpy, win,
				  False,
				  GrabModeAsync, GrabModeAsync,
				  CurrentTime);

//	XSync(dpy, True);
}
Beispiel #6
0
static void install_grabs_keyboard( void )
{
	int i;
	int num_devices;
	XIDeviceInfo *info;
	XIEventMask mask;

	assert( x11display.dpy && x11display.win );

	if( input_active )
		return;

	XDefineCursor(x11display.dpy, x11display.win, CreateNullCursor(x11display.dpy, x11display.win));

	mask.deviceid = XIAllMasterDevices;
	mask.mask_len = XIMaskLen(XI_LASTEVENT);
	mask.mask = calloc(mask.mask_len, sizeof(char));
	XISetMask(mask.mask, XI_KeyPress);
	XISetMask(mask.mask, XI_KeyRelease);
	XISetMask(mask.mask, XI_ButtonPress);
	XISetMask(mask.mask, XI_ButtonRelease);
	XISelectEvents(x11display.dpy, x11display.win, &mask, 1);

	info = XIQueryDevice(x11display.dpy, XIAllDevices, &num_devices);
	for(i = 0; i < num_devices; i++) {
		int id = info[i].deviceid;
		if(info[i].use == XIMasterKeyboard)
		{
			XIGrabDevice(x11display.dpy, id, x11display.win, CurrentTime, None, GrabModeAsync, GrabModeAsync, False, &mask);
		}
	}
	XIFreeDeviceInfo(info);

	free(mask.mask);

	XSync(x11display.dpy, True);

	input_active = qtrue;
}
Beispiel #7
0
void
IN_GrabMouse(void)
{
    int err;

    if (mouse_available && !mouse_grab_active) {
	XDefineCursor(x_disp, x_win, CreateNullCursor());

	err = XGrabPointer(x_disp, x_win, True, 0, GrabModeAsync,
			   GrabModeAsync, x_win, None, CurrentTime);
	if (err) {
	    if (err == GrabNotViewable)
		Con_DPrintf("%s: GrabNotViewable\n", __func__);
	    if (err == AlreadyGrabbed)
		Con_DPrintf("%s: AlreadyGrabbed\n", __func__);
	    if (err == GrabFrozen)
		Con_DPrintf("%s: GrabFrozen\n", __func__);
	    if (err == GrabInvalidTime)
		Con_DPrintf("%s: GrabInvalidTime\n", __func__);
	    mouse_grab_active = true;
	    return;
	} else {
	    mouse_grab_active = true;
	}
#ifdef USE_XF86DGA
	// FIXME - need those cvar callbacks to fix changed values...
	if (dga_available) {
	    if (in_dgamouse.value)
		IN_ActivateDGAMouse();
	} else {
	    in_dgamouse.value = 0;
	}
#endif
    } else {
	Sys_Error("Bad grab?");
    }
}
Beispiel #8
0
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);
}
Beispiel #9
0
void VID_SetMouse(qboolean fullscreengrab, qboolean relative, qboolean hidecursor)
{
	static int originalmouseparms_num;
	static int originalmouseparms_denom;
	static int originalmouseparms_threshold;
	static qboolean restore_spi;

#ifdef USEDGA
	qboolean usedgamouse;
#endif

	if (!vidx11_display || !win)
		return;

	if (relative)
		fullscreengrab = true;

	if (!mouse_avail)
		fullscreengrab = relative = hidecursor = false;

#ifdef USEDGA
	usedgamouse = relative && vid_dgamouse.integer;
	if (!vid_x11_dgasupported)
		usedgamouse = false;
	if (fullscreengrab && vid_usingmouse && (vid_usingdgamouse != usedgamouse))
		VID_SetMouse(false, false, false); // ungrab first!
#endif

	if (vid_usingmousegrab != fullscreengrab)
	{
		vid_usingmousegrab = fullscreengrab;
		cl_ignoremousemoves = 2;
		if (fullscreengrab)
		{
			XGrabPointer(vidx11_display, win,  True, 0, GrabModeAsync, GrabModeAsync, win, None, CurrentTime);
			if (vid_grabkeyboard.integer || vid_isoverrideredirect)
				XGrabKeyboard(vidx11_display, win, False, GrabModeAsync, GrabModeAsync, CurrentTime);
		}
		else
		{
			XUngrabPointer(vidx11_display, CurrentTime);
			XUngrabKeyboard(vidx11_display, CurrentTime);
		}
	}

	if (relative)
	{
		if (!vid_usingmouse)
		{
			XWindowAttributes attribs_1;
			XSetWindowAttributes attribs_2;

			XGetWindowAttributes(vidx11_display, win, &attribs_1);
			attribs_2.event_mask = attribs_1.your_event_mask | KEY_MASK | MOUSE_MASK;
			XChangeWindowAttributes(vidx11_display, win, CWEventMask, &attribs_2);

#ifdef USEDGA
			vid_usingdgamouse = usedgamouse;
			if (usedgamouse)
			{
				XF86DGADirectVideo(vidx11_display, DefaultScreen(vidx11_display), XF86DGADirectMouse);
				XWarpPointer(vidx11_display, None, win, 0, 0, 0, 0, 0, 0);
			}
			else
#endif
				XWarpPointer(vidx11_display, None, win, 0, 0, 0, 0, vid.width / 2, vid.height / 2);

// COMMANDLINEOPTION: X11 Input: -noforcemparms disables setting of mouse parameters (not used with DGA, windows only)
#ifdef USEDGA
			if (!COM_CheckParm ("-noforcemparms") && !usedgamouse)
#else
			if (!COM_CheckParm ("-noforcemparms"))
#endif
			{
				XGetPointerControl(vidx11_display, &originalmouseparms_num, &originalmouseparms_denom, &originalmouseparms_threshold);
				XChangePointerControl (vidx11_display, true, false, 1, 1, -1); // TODO maybe change threshold here, or remove this comment
				restore_spi = true;
			}
			else
				restore_spi = false;

			cl_ignoremousemoves = 2;
			vid_usingmouse = true;
		}
	}
	else
	{
		if (vid_usingmouse)
		{
#ifdef USEDGA
			if (vid_usingdgamouse)
				XF86DGADirectVideo(vidx11_display, DefaultScreen(vidx11_display), 0);
			vid_usingdgamouse = false;
#endif
			cl_ignoremousemoves = 2;

			if (restore_spi)
				XChangePointerControl (vidx11_display, true, true, originalmouseparms_num, originalmouseparms_denom, originalmouseparms_threshold);
			restore_spi = false;

			vid_usingmouse = false;
		}
	}

	if (vid_usinghidecursor != hidecursor)
	{
		vid_usinghidecursor = hidecursor;
		if (hidecursor)
			XDefineCursor(vidx11_display, win, CreateNullCursor(vidx11_display, win));
		else
			XUndefineCursor(vidx11_display, win);
	}
}
Beispiel #10
0
/*
** SWimp_InitGraphics
**
** This initializes the software refresh's implementation specific
** graphics subsystem.  In the case of Windows it creates DIB or
** DDRAW surfaces.
**
** The necessary width and height parameters are grabbed from
** vid.width and vid.height.
*/
static qboolean SWimp_InitGraphics( qboolean fullscreen){
	int pnum, i;
	long template_mask;
	
	srandom(getpid());
	
	
	// free resources in use
	SWimp_Shutdown();
	
	// let the sound and input subsystems know about the new window
	ri.Vid_NewWindow(vid.width, vid.height);
	
	// for debugging only
	//	XSynchronize(x_disp, True);
	
	// check for command-line window size
	template_mask = 0;
	
	
	// setup attributes for main window
	{
		int attribmask = CWEventMask | CWBorderPixel;
		XSetWindowAttributes attribs;
		
		window_width = vid.width;
		window_height = vid.height;
		
		attribs.event_mask = STD_EVENT_MASK;
		attribs.border_pixel = 0;
		
		// create the main window
		x_win = XCreateWindow( x_disp,
							   XRootWindow( x_disp, DefaultScreen( x_disp)),
							   0, 0, 	// x, y
							   window_width, window_height,
							   0,  // borderwidth
							   CopyFromParent,
							   InputOutput,
							   CopyFromParent,
							   attribmask,
							   &attribs);
		XStoreName( x_disp, x_win, "Quake II");
		
	}
	
	// inviso cursor
	XDefineCursor( x_disp, x_win, CreateNullCursor( x_disp, x_win));
	
	// create the GC
	{
		XGCValues xgcvalues;
		int valuemask = GCGraphicsExposures;
		xgcvalues.graphics_exposures = False;
		x_gc = XCreateGC( x_disp, x_win, valuemask, &xgcvalues);
	}
	
	/* set the icon */
	{
		Pixmap icon;
		XWMHints hints;
		icon = XCreateBitmapFromData( x_disp, DefaultRootWindow( x_disp),
									  q2_bits, q2_width, q2_height);
		/*				  BlackPixel( x_disp, DefaultScreen( x_disp)),
		WhitePixel( x_disp, DefaultScreen( x_disp)),
		1);*/
		hints.icon_pixmap = icon;
		hints.flags = IconPixmapHint;
		XSetWMHints( x_disp, x_win, &hints);
	}
	
	// map the window
	XMapWindow( x_disp, x_win);
	
	// wait for first exposure event
	{
		XEvent event;
		do {
			XNextEvent( x_disp, &event);
		} while( event.type != Expose || event.xexpose.count != 0);
	}
	// now safe to draw
	
	ResetNEWTFrameBuffers();
	
	//	XSynchronize(x_disp, False);
	
	old_windowed_mouse = 0;
	X11_active = true;
	
	return true;
}
Beispiel #11
0
static void install_grabs( void )
{
	int res;
	int fevent;

	assert( x11display.dpy && x11display.win );

	if( !x11display.features.wmStateFullscreen )
	{
		res = XGrabKeyboard( x11display.dpy, x11display.win, False, GrabModeAsync, GrabModeAsync, CurrentTime );
		if( res != GrabSuccess )
		{
			Com_Printf( "Warning: XGrabKeyboard failed\n" );
			return;
		}
	}

	XDefineCursor( x11display.dpy, x11display.win, CreateNullCursor( x11display.dpy, x11display.win ) );

	res = XGrabPointer( x11display.dpy, x11display.win, True, 0, GrabModeAsync, GrabModeAsync, x11display.win, None, CurrentTime );
	if( res != GrabSuccess )
	{
		// TODO: Find a solution to Pointer Grabs at focus changes, which sometimes result
		// in Grabbing Errors. Like switches from Windowed/Fullscreen to Hidden State.
		//Com_Printf( "Warning: XGrabPointer failed\n" );
		XUngrabKeyboard( x11display.dpy, CurrentTime );
		XUndefineCursor( x11display.dpy, x11display.win );
		return;
	}

	if( in_dgamouse->integer )
	{
		int MajorVersion, MinorVersion;

		if( XF86DGAQueryVersion( x11display.dpy, &MajorVersion, &MinorVersion ) )
		{
			XF86DGADirectVideo( x11display.dpy, x11display.scr, XF86DGADirectMouse );
			XWarpPointer( x11display.dpy, None, x11display.win, 0, 0, 0, 0,
				x11display.win_width/2, x11display.win_height/2 );
			dgamouse = qtrue;
		}
		else
		{
			// unable to query, probalby not supported
			Com_Printf( "Failed to detect XF86DGA Mouse\n" );
			Cvar_Set( "in_dgamouse", "0" );
			dgamouse = qfalse;
		}
	}
	else
	{
		XWarpPointer( x11display.dpy, None, x11display.win, 0, 0, 0, 0,
			x11display.win_width/2, x11display.win_height/2 );
	}

	ignore_one = qtrue; // first mouse update after install_grabs is ignored
	mx = my = 0;
	mouse_active = qtrue;

	in_dgamouse->modified = qfalse;

	input_active = qtrue;

	// init X Input method, needed by Xutf8LookupString
	x11display.im = XOpenIM( x11display.dpy, NULL, NULL, NULL );
	x11display.ic = XCreateIC( x11display.im,
		XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
		XNClientWindow, x11display.win,
		NULL );
	if ( x11display.ic )
	{
		XGetICValues( x11display.ic, XNFilterEvents, &fevent, NULL );
		XSelectInput( x11display.dpy, x11display.win, fevent | x11display.wa.event_mask );
	}
}