Welcome to Linux Knowledge Base and Tutorial
"The place where you learn linux"
International Rescue Committe

 Create an AccountHome | Submit News | Your Account  

Tutorial Menu
Linux Tutorial Home
Table of Contents

· Introduction to Operating Systems
· Linux Basics
· Working with the System
· Shells and Utilities
· Editing Files
· Basic Administration
· The Operating System
· The X Windowing System
· The Computer Itself
· Networking
· System Monitoring
· Solving Problems
· Security
· Installing and Upgrading
· Linux and Windows

Glossary
MoreInfo
Man Pages
Linux Topics
Test Your Knowledge

Site Menu
Site Map
FAQ
Copyright Info
Terms of Use
Privacy Info
Disclaimer
WorkBoard
Thanks
Donations
Advertising
Masthead / Impressum
Your Account

Communication
Feedback
Forums
Private Messages
Surveys

Features
HOWTOs
News Archive
Submit News
Topics
User Articles
Web Links

Google
Google


The Web
linux-tutorial.info

Who's Online
There are currently, 61 guest(s) and 0 member(s) that are online.

You are an Anonymous user. You can register for free by clicking here

  

HOWTO Home

Current HOWTO: LinuxGL-QuakeWorld-mini-HOWTO


Fix the mouse grabbing

5. Fix the mouse grabbing

Fix the mouse hide problem.

The quake code, as it is, does not hide the mouse when you use it. The pointer would remain visible and jitter around a fixed point in the middle of the screen - very annoying. I found the following simple fix in a mail archive about glx development at: http://lists.openprojects.net/pipermail/glx-dev/1999-October/000994.html

See the patch listing and the link to download it below, or you can make the changes yourself.

	cd q1src/QW/client
	edit the file: gl_vidlinuxglx.c
        

At the top of the function called install_grabs(void) (Line 234), add the following code:


	static void install_grabs(void)
	{
		/* vars to make blank cursor */
		Pixmap blank;
		XColor dummy;
		char data[1] = {0};
		Cursor cursor;

		/* make a blank cursor */
		blank = XCreateBitmapFromData (dpy, win, data, 1, 1);
		if(blank == None) fprintf(stderr, "error: out of memory.\n");
		cursor = XCreatePixmapCursor(dpy, blank, blank, &dummy, &dummy, 0, 0);
		XFreePixmap (dpy, blank);
		Con_Printf("Cursor blanked.\n");
        

The 8th parameter to XGrabPointer should be changed from "None" to "cursor" to use the blank cursor:


	XGrabPointer(dpy, win,
			 True,
			 0,
			 GrabModeAsync, GrabModeAsync,
			 win,
			 cursor,
			 CurrentTime);
        
(see: man XGrabPointer)

This fix might work for the other client builds if you make similar changes in the appropriate *vid*.c file. As it is, this creates a memory leak as it allocates another Cursor object everytime through and doesn't call XFreeCursor() but this is probably not a problem since I don't think a 1x1 cursor is using much memory. If you want, you can apply the following patch against q1src/QW/client/gl_vidlinuxglx.c (patch gl_vidlinuxglx.c patchfile). Just cut and paste the contents between the begin/end patchfile lines into a file called gl_vidlinuxglx.c.patch (or whatever you want to call it). Save patchfile in the q1src/QW/client directory where gl_vidlinuxglx.c is. Then run the command:


	patch gl_vidlinuxglx.c gl_vidlinuxglx.c.patch
        

This patch file will make gl_vidlinuxglx.c such that it doesn't have any memory leak. You can download this patch file at: http://www.comptechnews.com/~reaster/mini-HOWTO/LinuxGL-QuakeWorld-mini-HOWTO/gl_vidlinuxglx.c.patch.

*************************** begin patchfile ************************************
*** q1src-p/QW/client/gl_vidlinuxglx.c	Tue Dec 21 18:45:54 1999
--- gl_vidlinuxglx.c	Sat Aug 19 20:47:42 2000
***************
*** 1,22 ****
! /*
! Copyright (C) 1996-1997 Id Software, Inc.
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License
! as published by the Free Software Foundation; either version 2
! of the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
!
! See the GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program; if not, write to the Free Software
! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
!
! */
  #include <termios.h>
  #include <sys/ioctl.h>
  #include <sys/stat.h>
--- 1,22 ----
! /*
! Copyright (C) 1996-1997 Id Software, Inc.
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License
! as published by the Free Software Foundation; either version 2
! of the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
!
! See the GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program; if not, write to the Free Software
! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
!
! */
  #include <termios.h>
  #include <sys/ioctl.h>
  #include <sys/stat.h>
***************
*** 66,71 ****
--- 66,74 ----

  static int scr_width, scr_height;

+ /* blank cursor - gets initialized in VID_Init, freed in VID_Shutdown */
+ Cursor cursor;
+
  /*-----------------------------------------------------------------------*/

  //int		texture_mode = GL_NEAREST;
***************
*** 236,243 ****
  				 0,
  				 GrabModeAsync, GrabModeAsync,
  				 win,
! 				 None,
  				 CurrentTime);

  #ifdef USE_DGA
  	XF86DGADirectVideo(dpy, DefaultScreen(dpy), XF86DGADirectMouse);
--- 239,247 ----
  				 0,
  				 GrabModeAsync, GrabModeAsync,
  				 win,
! 				 cursor,
  				 CurrentTime);
+ 	Con_Printf("Cursor blanked.\n");

  #ifdef USE_DGA
  	XF86DGADirectVideo(dpy, DefaultScreen(dpy), XF86DGADirectMouse);
***************
*** 350,355 ****
--- 354,360 ----
  	if (!ctx)
  		return;

+ 	XFreeCursor(dpy, cursor);
  	glXDestroyContext(dpy, ctx);
  }

***************
*** 602,608 ****
  	unsigned long mask;
  	Window root;
  	XVisualInfo *visinfo;
!
  	S_Init();

  	Cvar_RegisterVariable (&vid_mode);
--- 607,617 ----
  	unsigned long mask;
  	Window root;
  	XVisualInfo *visinfo;
! 	/* vars to make blank cursor */
! 	Pixmap blank;
! 	XColor dummy;
! 	char data[1] = {0};
!
  	S_Init();

  	Cvar_RegisterVariable (&vid_mode);
***************
*** 701,706 ****
--- 710,720 ----
  	Con_SafePrintf ("Video mode %dx%d initialized.\n", width, height);

  	vid.recalc_refdef = 1;				// force a surface cache flush
+
+ 	blank = XCreateBitmapFromData(dpy, win, data, 1, 1);
+ 	if(blank == None) fprintf(stderr, "error: out of memory.\n");
+ 	cursor = XCreatePixmapCursor(dpy, blank, blank, &dummy, &dummy, 0, 0);
+ 	XFreePixmap(dpy, blank);
  }

  void Sys_SendKeyEvents(void)

*************************** end patchfile   ************************************
        

It is handy to bind some keys at the quake console to toggle mouse grabbing:

	bind q "_windowed_mouse 0"
	bind w "_windowed_mouse 1"
        


The Linux Tutorial completely respects the rights of authors and artists to decide for themselves if and how their works can be used, independent of any existing licenses. This means if you are the author of any document presented on this site and do no wish it to be displayed as it is on this site or do not wish it to be displayed at all, please contact us and we will do our very best to accommodate you. If we are unable to accommodate you, we will, at your request, remove your document as quickly as possible.

If you are the author of any document presented on this site and would like a share of the advertising revenue, please contact us using the standard Feedback Form.


  




Login
Nickname

Password

Security Code
Security Code
Type Security Code


Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.

Help if you can!


Amazon Wish List

Did You Know?
You can get all the latest Site and Linux news by checking out our news page.


Friends



Tell a Friend About Us

Bookmark and Share



Web site powered by PHP-Nuke

Is this information useful? At the very least you can help by spreading the word to your favorite newsgroups, mailing lists and forums.
All logos and trademarks in this site are property of their respective owner. The comments are property of their posters. Articles are the property of their respective owners. Unless otherwise stated in the body of the article, article content (C) 1994-2013 by James Mohr. All rights reserved. The stylized page/paper, as well as the terms "The Linux Tutorial", "The Linux Server Tutorial", "The Linux Knowledge Base and Tutorial" and "The place where you learn Linux" are service marks of James Mohr. All rights reserved.
The Linux Knowledge Base and Tutorial may contain links to sites on the Internet, which are owned and operated by third parties. The Linux Tutorial is not responsible for the content of any such third-party site. By viewing/utilizing this web site, you have agreed to our disclaimer, terms of use and privacy policy. Use of automated download software ("harvesters") such as wget, httrack, etc. causes the site to quickly exceed its bandwidth limitation and are therefore expressly prohibited. For more details on this, take a look here

PHP-Nuke Copyright © 2004 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.
Page Generation: 0.21 Seconds