Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 24 Jan 2009 12:08:05 +0100 (CET)
From:      Roland Smith <rsmith@xs4all.nl>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        alepulver@FreeBSD.org
Subject:   ports/130936: [PATCH] fix games/tyrquake to work without DGA
Message-ID:  <20090124110805.A86C5BA89@slackbox.xs4all.nl>
Resent-Message-ID: <200901241110.n0OBA1sl084287@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         130936
>Category:       ports
>Synopsis:       [PATCH] fix games/tyrquake to work without DGA
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jan 24 11:10:01 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Roland Smith
>Release:        FreeBSD 7.1-RELEASE amd64
>Organization:
>Environment:
System: FreeBSD slackbox.xs4all.nl 7.1-RELEASE FreeBSD 7.1-RELEASE #0: Wed Jan 7 15:44:17 CET 2009 rsmith@slackbox.xs4all.nl:/usr/obj/usr/src/sys/QUADSLACK amd64


	
>Description:
        On Xorg 7.x with DisableVidModeExtension set, this program dies
        with a bad X request concerning DGA. Enabling the vidmode extension
        messes up the screen. 
>How-To-Repeat:
        Run unmodified tyr-glquake or tyr-quake
>Fix:
        I patched the source to remove all traces of DGA. The program works
        fine without it. Other quake ports might benefit from the same
	treatment. 

--- tyrquake.patch begins here ---
diff -ruN tyrquake.orig/Makefile tyrquake/Makefile
--- tyrquake.orig/Makefile	2009-01-24 11:38:27.000000000 +0100
+++ tyrquake/Makefile	2009-01-24 11:39:02.000000000 +0100
@@ -15,7 +15,6 @@
 
 USE_GL=		yes
 USE_GMAKE=	yes
-USE_XORG=	xxf86dga
 MAKE_ENV=	QBASEDIR="${Q1DIR}"
 
 OPTIONS=	OPTIMIZED_CFLAGS "Enable compilation optimizations" on \
diff -ruN tyrquake.orig/files/patch-common::gl_vidlinuxglx.c tyrquake/files/patch-common::gl_vidlinuxglx.c
--- tyrquake.orig/files/patch-common::gl_vidlinuxglx.c	1970-01-01 01:00:00.000000000 +0100
+++ tyrquake/files/patch-common::gl_vidlinuxglx.c	2009-01-24 11:36:24.000000000 +0100
@@ -0,0 +1,20 @@
+--- common/gl_vidlinuxglx.c.orig	2009-01-24 11:35:16.000000000 +0100
++++ common/gl_vidlinuxglx.c	2009-01-24 11:35:26.000000000 +0100
+@@ -387,16 +387,12 @@
+ 
+ 	case MotionNotify:
+ 	    if (mouse_grab_active) {
+-		if (dga_mouse_active) {
+-		    mouse_x += event.xmotion.x_root;
+-		    mouse_y += event.xmotion.y_root;
+-		} else {
+ 		    mouse_x = event.xmotion.x - (int)(vid.width / 2);
+ 		    mouse_y = event.xmotion.y - (int)(vid.height / 2);
+ 
+ 		    if (mouse_x || mouse_y)
+ 			dowarp = true;
+-		}
++
+ 	    }
+ 	    break;
+ 
diff -ruN tyrquake.orig/files/patch-common::in_x11.c tyrquake/files/patch-common::in_x11.c
--- tyrquake.orig/files/patch-common::in_x11.c	1970-01-01 01:00:00.000000000 +0100
+++ tyrquake/files/patch-common::in_x11.c	2009-01-24 11:29:00.000000000 +0100
@@ -0,0 +1,116 @@
+--- common/in_x11.c.orig	2009-01-24 11:18:46.000000000 +0100
++++ common/in_x11.c	2009-01-24 11:27:30.000000000 +0100
+@@ -25,15 +25,11 @@
+ #include "vid.h"
+ #include "sys.h"
+ 
+-#include <X11/extensions/xf86dga.h>
+-
+ // FIXME - make static when possible
+ qboolean mouse_available = false;	// Mouse available for use
+ 
+ static qboolean keyboard_grab_active = false;
+ qboolean mouse_grab_active = false;
+-static qboolean dga_available = false;
+-qboolean dga_mouse_active = false;
+ 
+ int mouse_x, mouse_y;
+ 
+@@ -58,41 +54,7 @@
+ }
+ 
+ 
+-static void
+-IN_ActivateDGAMouse(void)
+-{
+-    if (dga_available && !dga_mouse_active) {
+-	XF86DGADirectVideo(x_disp, DefaultScreen(x_disp), XF86DGADirectMouse);
+-	dga_mouse_active = true;
+-    }
+-}
+-
+-static void
+-IN_DeactivateDGAMouse(void)
+-{
+-    if (dga_available && dga_mouse_active) {
+-	XF86DGADirectVideo(x_disp, DefaultScreen(x_disp), 0);
+-	dga_mouse_active = false;
+-	IN_CenterMouse();	// maybe set mouse_x = 0 and mouse_y = 0?
+-    }
+-}
+-
+-static void
+-in_dgamouse_f(struct cvar_s *var)
+-{
+-    if (var->value) {
+-	Con_DPrintf("Callback: in_dgamouse ON\n");
+-	IN_ActivateDGAMouse();
+-    } else {
+-	Con_DPrintf("Callback: in_dgamouse OFF\n");
+-	IN_DeactivateDGAMouse();
+-    }
+-}
+-
+ cvar_t in_mouse = { "in_mouse", "1", false };
+-cvar_t in_dgamouse = { "in_dgamouse", "1", false, false, 0,
+-    in_dgamouse_f
+-};
+ cvar_t _windowed_mouse = { "_windowed_mouse", "0", true, false, 0,
+     windowed_mouse_f
+ };
+@@ -154,13 +116,6 @@
+ 	}
+ 	mouse_grab_active = true;
+ 
+-	// FIXME - need those cvar callbacks to fix changed values...
+-	if (dga_available) {
+-	    if (in_dgamouse.value)
+-		IN_ActivateDGAMouse();
+-	} else {
+-	    in_dgamouse.value = 0;
+-	}
+     } else {
+ 	Sys_Error("Bad grab?");
+     }
+@@ -174,10 +129,6 @@
+ 	XUndefineCursor(x_disp, x_win);
+ 	mouse_grab_active = false;
+     }
+-
+-    if (dga_mouse_active) {
+-	IN_DeactivateDGAMouse();
+-    }
+ }
+ 
+ void
+@@ -208,7 +159,6 @@
+ IN_InitCvars(void)
+ {
+     Cvar_RegisterVariable(&in_mouse);
+-    Cvar_RegisterVariable(&in_dgamouse);
+     Cvar_RegisterVariable(&m_filter);
+     Cvar_RegisterVariable(&_windowed_mouse);
+ }
+@@ -220,7 +170,6 @@
+ 
+     keyboard_grab_active = false;
+     mouse_grab_active = false;
+-    dga_mouse_active = false;
+ 
+     // FIXME - do proper detection?
+     //       - Also, look at other vid_*.c files for clues
+@@ -229,14 +178,6 @@
+     if (x_disp == NULL)
+ 	Sys_Error("x_disp not initialised before input...");
+ 
+-    if (!XF86DGAQueryVersion(x_disp, &MajorVersion, &MinorVersion)) {
+-	Con_Printf("Failed to detect XF86DGA Mouse\n");
+-	in_dgamouse.value = 0;
+-	dga_available = false;
+-    } else {
+-	dga_available = true;
+-    }
+-
+     // Need to grab the input focus at startup, just in case...
+     // FIXME - must be viewable or get BadMatch
+     XSetInputFocus(x_disp, x_win, RevertToParent, CurrentTime);
diff -ruN tyrquake.orig/files/patch-common::vid_x.c tyrquake/files/patch-common::vid_x.c
--- tyrquake.orig/files/patch-common::vid_x.c	1970-01-01 01:00:00.000000000 +0100
+++ tyrquake/files/patch-common::vid_x.c	2009-01-24 11:33:10.000000000 +0100
@@ -0,0 +1,19 @@
+--- common/vid_x.c.orig	2009-01-24 11:30:23.000000000 +0100
++++ common/vid_x.c	2009-01-24 11:32:14.000000000 +0100
+@@ -1059,16 +1059,11 @@
+ 
+ 	case MotionNotify:
+ 	    if (mouse_grab_active) {
+-		if (dga_mouse_active) {
+-		    mouse_x += x_event.xmotion.x_root;
+-		    mouse_y += x_event.xmotion.y_root;
+-		} else {
+ 		    mouse_x = x_event.xmotion.x - (int)(vid.width / 2);
+ 		    mouse_y = x_event.xmotion.y - (int)(vid.height / 2);
+ 
+ 		    if (mouse_x || mouse_y)
+ 			dowarp = true;
+-		}
+ 	    }
+ 	    break;
+ 
--- tyrquake.patch ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090124110805.A86C5BA89>