cvar.h cvar.c:

add int_val field to cvar_t. this should be used instead of value for
	boolean / integral values (no conversions done yet).
in_*.c:
	Add IN_HandlePause
vid_*.c:
	Add VID_HandlePause
context_x11.h vid_glx.c vid_x11.c context_x11.c:
	move some common code out of vid_*.c into context_x11.c. Also, disable
	the screen saver while nuq is running. NOTE: while vid_glx.c compiles,
	it has not been tested yes as glx crashes this machine :(
This commit is contained in:
Bill Currie 2000-08-30 22:45:44 +00:00
parent 775d9ebe54
commit e1965a27b9
25 changed files with 318 additions and 290 deletions

View file

@ -33,14 +33,19 @@
#include <qtypes.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
void GetEvent( void );
extern Display *x_disp;
extern Window x_win;
extern qboolean doShm;
extern int x_shmeventtype;
extern qboolean oktodraw;
extern Display *x_disp;
extern int x_screen;
extern Window x_root;
extern XVisualInfo *x_visinfo;
extern Visual *x_vis;
extern Window x_win;
extern qboolean doShm;
extern int x_shmeventtype;
extern qboolean oktodraw;
qboolean x11_add_event( int event, void (*event_handler)(XEvent *));
qboolean x11_del_event( int event, void (*event_handler)(XEvent *));
@ -48,5 +53,10 @@ void x11_process_event( void );
void x11_process_events( void );
void x11_open_display( void );
void x11_close_display( void );
void x11_create_null_cursor(void);
void x11_set_vidmode(int width, int height);
void x11_restore_vidmode(void);
void x11_create_window(int width, int height);
void x11_grab_keyboard(void);
#endif // __CONTEXT_X11_H__

View file

@ -40,6 +40,7 @@ typedef struct cvar_s
int flags;
char *description; // for "help" command
float value;
int int_val;
struct cvar_s *next;
} cvar_t;

View file

@ -47,6 +47,8 @@ void IN_ClearStates (void);
void IN_SendKeyEvents (void);
void IN_HandlePause (qboolean pause);
extern cvar_t *_windowed_mouse;

View file

@ -43,6 +43,7 @@
#include "server.h"
#include "qdefs.h"
#include "glquake.h"
#include "input.h"
char *svc_strings[] =
{
@ -894,16 +895,14 @@ void CL_ParseServerMessage (void)
if (cl.paused)
{
CDAudio_Pause ();
#ifdef _WIN32
IN_HandlePause (true);
VID_HandlePause (true);
#endif
}
else
{
CDAudio_Resume ();
#ifdef _WIN32
VID_HandlePause (false);
#endif
IN_HandlePause (false);
CDAudio_Resume ();
}
}
break;

View file

@ -49,11 +49,20 @@
#include <X11/keysym.h>
#include <X11/extensions/XShm.h>
#include <errno.h>
#include <values.h>
#include <context_x11.h>
#include <qtypes.h>
#include <vid.h>
#include <sys.h>
#ifdef HAVE_VIDMODE
# include <X11/extensions/xf86vmode.h>
#endif
#include "context_x11.h"
#include "dga_check.h"
#include "qtypes.h"
#include "vid.h"
#include "sys.h"
#include "console.h"
#include "cvar.h"
#include "input.h"
static void (*event_handlers[LASTEvent]) (XEvent *);
qboolean oktodraw = false;
@ -62,6 +71,27 @@ int x_shmeventtype;
static int x_disp_ref_count = 0;
Display *x_disp = NULL;
int x_screen;
Window x_root = None;
XVisualInfo *x_visinfo;
Visual *x_vis;
Window x_win;
Cursor nullcursor = None;
static Atom aWMDelete = 0;
#define X_MASK (VisibilityChangeMask | StructureNotifyMask | ExposureMask)
#ifdef HAVE_VIDMODE
static XF86VidModeModeInfo **vidmodes;
static int nummodes, hasvidmode = 0;
#endif
cvar_t *vid_fullscreen;
static int xss_timeout;
static int xss_interval;
static int xss_blanking;
static int xss_exposures;
qboolean
x11_add_event(int event, void (*event_handler)(XEvent *))
@ -134,6 +164,9 @@ x11_open_display( void )
{
if ( !x_disp ) {
x_disp = XOpenDisplay( NULL );
x_screen = DefaultScreen (x_disp);
x_root = RootWindow (x_disp, x_screen);
if ( !x_disp ) {
Sys_Error("x11_open_display: Could not open display [%s]\n", XDisplayName( NULL ));
}
@ -162,8 +195,163 @@ x11_open_display( void )
void
x11_close_display( void )
{
if (nullcursor != None) {
XFreeCursor(x_disp, nullcursor);
nullcursor = None;
}
if (!--x_disp_ref_count) {
XCloseDisplay( x_disp );
x_disp = NULL;
}
}
/*
x11_create_null_cursor
Create an empty cursor
*/
void
x11_create_null_cursor(void)
{
Pixmap cursormask;
XGCValues xgc;
GC gc;
XColor dummycolour;
if (nullcursor != None) return;
cursormask = XCreatePixmap(x_disp, x_root, 1, 1, 1/*depth*/);
xgc.function = GXclear;
gc = XCreateGC(x_disp, cursormask, GCFunction, &xgc);
XFillRectangle(x_disp, cursormask, gc, 0, 0, 1, 1);
dummycolour.pixel = 0;
dummycolour.red = 0;
dummycolour.flags = 04;
nullcursor = XCreatePixmapCursor(x_disp, cursormask, cursormask,
&dummycolour,&dummycolour, 0,0);
XFreePixmap(x_disp,cursormask);
XFreeGC(x_disp,gc);
XDefineCursor(x_disp, x_win, nullcursor);
}
void
x11_set_vidmode(int width, int height)
{
int i;
vid_fullscreen = Cvar_Get ("vid_fullscreen","0",0,"None");
XGetScreenSaver (x_disp, &xss_timeout, &xss_interval, &xss_blanking,
&xss_exposures);
XSetScreenSaver (x_disp, 0, xss_interval, xss_blanking,
xss_exposures);
#ifdef XMESA
const char *str = getenv("MESA_GLX_FX");
if (str != NULL && *str != 'd') {
if (tolower(*str) == 'w') {
Cvar_Set (vid_fullscreen, "0");
} else {
Cvar_Set (vid_fullscreen, "1");
}
}
#endif
#ifdef HAVE_VIDMODE
hasvidmode = VID_CheckVMode(x_disp, NULL, NULL);
if (hasvidmode) {
if (! XF86VidModeGetAllModeLines(x_disp, DefaultScreen(x_disp),
&nummodes, &vidmodes)
|| nummodes <= 0) {
hasvidmode = 0;
}
}
Con_SafePrintf ("hasvidmode = %i\nnummodes = %i\n", hasvidmode, nummodes);
if (hasvidmode && vid_fullscreen->value) {
int smallest_mode=0, x=MAXINT, y=MAXINT;
// FIXME: does this depend on mode line order in XF86Config?
for (i=0; i<nummodes; i++) {
if (x>vidmodes[i]->hdisplay || y>vidmodes[i]->vdisplay) {
smallest_mode=i;
x=vidmodes[i]->hdisplay;
y=vidmodes[i]->vdisplay;
}
printf("%dx%d\n",vidmodes[i]->hdisplay,vidmodes[i]->vdisplay);
}
// chose the smallest mode that our window fits into;
for (i=smallest_mode;
i!=(smallest_mode+1)%nummodes;
i=(i?i-1:nummodes-1)) {
if (vidmodes[i]->hdisplay>=width
&& vidmodes[i]->vdisplay>=height) {
XF86VidModeSwitchToMode (x_disp, DefaultScreen (x_disp),
vidmodes[i]);
break;
}
}
XF86VidModeSetViewPort(x_disp, DefaultScreen (x_disp), 0, 0);
_windowed_mouse = Cvar_Get ("_windowed_mouse","1",CVAR_ARCHIVE|CVAR_ROM,"None");
} else
#endif
_windowed_mouse = Cvar_Get ("_windowed_mouse","0",CVAR_ARCHIVE,"None");
}
void
x11_create_window(int width, int height)
{
XSetWindowAttributes attr;
unsigned long mask;
/* window attributes */
attr.background_pixel = 0;
attr.border_pixel = 0;
attr.colormap = XCreateColormap(x_disp, x_root, x_vis, AllocNone);
attr.event_mask = X_MASK;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
if (hasvidmode && vid_fullscreen->value) {
attr.override_redirect=1;
mask|=CWOverrideRedirect;
}
x_win = XCreateWindow(x_disp, x_root, 0, 0, width, height,
0, x_visinfo->depth, InputOutput,
x_vis, mask, &attr);
/* Give it a title */
XStoreName(x_disp, x_win, "XQuake");
/* Make window respond to Delete events */
aWMDelete = XInternAtom(x_disp, "WM_DELETE_WINDOW", False);
XSetWMProtocols(x_disp, x_win, &aWMDelete, 1);
XMapWindow(x_disp, x_win);
XRaiseWindow(x_disp, x_win);
}
void
x11_restore_vidmode(void)
{
XSetScreenSaver (x_disp, xss_timeout, xss_interval, xss_blanking,
xss_exposures);
#ifdef HAVE_VIDMODE
if (hasvidmode) {
XF86VidModeSwitchToMode (x_disp, DefaultScreen (x_disp),
vidmodes[0]);
XFree(vidmodes);
}
#endif
}
void
x11_grab_keyboard(void)
{
#ifdef HAVE_VIDMODE
if (hasvidmode && vid_fullscreen->value) {
XGrabKeyboard(x_disp, x_win, 1, GrabModeAsync, GrabModeAsync,
CurrentTime);
}
#endif
}

View file

@ -198,6 +198,7 @@ void Cvar_Set (cvar_t *var, char *value)
var->string = malloc (strlen(value)+1);
strcpy (var->string, value);
var->value = atof (var->string);
var->int_val = atoi (var->string);
if ((var->flags & CVAR_SERVERINFO) && changed) {
if (sv.active)

View file

@ -623,3 +623,6 @@ Con_DPrintf("OUT: y:%f p:%f r:%f f:%f s:%f u:%f\n", extern_control->viewangles[Y
V_StopPitchDrift ();
}
void IN_HandlePause (qboolean pause)
{
}

View file

@ -47,3 +47,6 @@ void IN_Move (usercmd_t *cmd)
{
}
void IN_HandlePause (qboolean pause)
{
}

View file

@ -253,3 +253,7 @@ IN_Move (usercmd_t *cmd)
else cmd->forwardmove -= m_forward->value * dy;
}
}
void IN_HandlePause (qboolean pause)
{
}

View file

@ -383,3 +383,7 @@ void IN_Move(usercmd_t *cmd)
}
}
}
void IN_HandlePause (qboolean pause)
{
}

View file

@ -1246,3 +1246,7 @@ void IN_JoyMove (usercmd_t *cmd)
if (cl.viewangles[PITCH] < -70.0)
cl.viewangles[PITCH] = -70.0;
}
void IN_HandlePause (qboolean pause)
{
}

View file

@ -459,3 +459,7 @@ IN_Init(void)
return 1;
}
void IN_HandlePause (qboolean pause)
{
}

View file

@ -649,3 +649,7 @@ VID_UnlockBuffer ( void )
void VID_SetCaption (char *text)
{
}
void VID_HandlePause (qboolean pause)
{
}

View file

@ -789,3 +789,7 @@ void VID_MenuKey (int key)
}
}
void VID_HandlePause (qboolean pause)
{
}

View file

@ -798,3 +798,7 @@ void VID_ExtraSwapBuffers (viddef_t *lvid, vmode_t *pcurrentmode,
}
}
void VID_HandlePause (qboolean pause)
{
}

View file

@ -966,3 +966,7 @@ IN_Move(usercmd_t *cmd)
}
mouse_x = mouse_y = 0.0;
}
void VID_HandlePause (qboolean pause)
{
}

View file

@ -56,9 +56,6 @@
#ifdef HAVE_DGA
# include <X11/extensions/xf86dga.h>
#endif
#ifdef HAVE_VIDMODE
# include <X11/extensions/xf86vmode.h>
#endif
#ifdef XMESA
# include <GL/xmesa.h>
@ -86,26 +83,16 @@
static qboolean vid_initialized = false;
static int screen;
Window x_win;
static GLXContext ctx = NULL;
static Cursor nullcursor = None;
#define X_MASK (VisibilityChangeMask | StructureNotifyMask)
unsigned short d_8to16table[256];
unsigned d_8to24table[256];
unsigned char d_15to8table[65536];
cvar_t *vid_mode;
cvar_t *vid_fullscreen;
extern cvar_t *gl_triplebuffer;
extern cvar_t *in_dga_mouseaccel;
#ifdef HAVE_VIDMODE
static XF86VidModeModeInfo **vidmodes;
static int nummodes, hasvidmode = 0;
#endif
#ifdef HAVE_DGA
static int hasdgavideo = 0;
static int hasdga = 0;
@ -151,35 +138,6 @@ int gl_mtex_enum = TEXTURE0_SGIS;
qboolean gl_arb_mtex = false;
qboolean gl_mtexable = false;
/*
======================
Create an empty cursor
======================
*/
static void
CreateNullCursor(Display *display, Window root)
{
Pixmap cursormask;
XGCValues xgc;
GC gc;
XColor dummycolour;
if (nullcursor != None) return;
cursormask = XCreatePixmap(display, root, 1, 1, 1/*depth*/);
xgc.function = GXclear;
gc = XCreateGC(display, cursormask, GCFunction, &xgc);
XFillRectangle(display, cursormask, gc, 0, 0, 1, 1);
dummycolour.pixel = 0;
dummycolour.red = 0;
dummycolour.flags = 04;
nullcursor = XCreatePixmapCursor(display, cursormask, cursormask,
&dummycolour,&dummycolour, 0,0);
XFreePixmap(display,cursormask);
XFreeGC(display,gc);
}
/*-----------------------------------------------------------------------*/
void D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height)
@ -200,28 +158,13 @@ VID_Shutdown(void)
XDestroyWindow(x_disp, x_win);
glXDestroyContext(x_disp, ctx);
#ifdef HAVE_VIDMODE
if (hasvidmode) {
int i;
XF86VidModeSwitchToMode (x_disp, DefaultScreen (x_disp),
vidmodes[0]);
for (i = 0; i < nummodes; i++) {
// if (vidmodes[i]->privsize) XFree(vidmodes[i]->private);
}
XFree(vidmodes);
}
#endif
x11_restore_vidmode();
#ifdef HAVE_DLOPEN
if (dlhand) {
dlclose(dlhand);
dlhand = NULL;
}
#endif
if (nullcursor != None) {
XFreeCursor(x_disp, nullcursor);
nullcursor = None;
}
x11_close_display();
}
#if 0
@ -512,13 +455,8 @@ void VID_Init(unsigned char *palette)
};
char gldir[MAX_OSPATH];
int width = 640, height = 480;
XSetWindowAttributes attr;
unsigned long mask;
Window root;
XVisualInfo *visinfo;
vid_mode = Cvar_Get ("vid_mode","0",0,"None");
vid_fullscreen = Cvar_Get ("vid_fullscreen","0",0,"None");
#ifdef HAVE_DGA
in_dga_mouseaccel = Cvar_Get("vid_dga_mouseaccel","1",CVAR_ARCHIVE,
"None");
@ -557,14 +495,12 @@ void VID_Init(unsigned char *palette)
x11_open_display();
screen = DefaultScreen(x_disp);
root = RootWindow(x_disp, screen);
visinfo = glXChooseVisual(x_disp, screen, attrib);
if (!visinfo) {
x_visinfo = glXChooseVisual(x_disp, x_screen, attrib);
if (!x_visinfo) {
fprintf(stderr, "Error couldn't get an RGB, Double-buffered, Depth visual\n");
exit(1);
}
x_vis = x_visinfo->visual;
#ifdef HAVE_DGA
{
@ -577,17 +513,6 @@ void VID_Init(unsigned char *palette)
}
Con_SafePrintf ("hasdga = %i\nhasdgavideo = %i\n", hasdga, hasdgavideo);
#endif
#ifdef HAVE_VIDMODE
hasvidmode = VID_CheckVMode(x_disp, NULL, NULL);
if (hasvidmode) {
if (! XF86VidModeGetAllModeLines(x_disp, DefaultScreen(x_disp),
&nummodes, &vidmodes)
|| nummodes <= 0) {
hasvidmode = 0;
}
}
Con_SafePrintf ("hasvidmode = %i\nnummodes = %i\n", hasvidmode, nummodes);
#endif
#ifdef HAVE_DLOPEN
dlhand = dlopen(NULL, RTLD_LAZY);
if (dlhand) {
@ -619,69 +544,19 @@ void VID_Init(unsigned char *palette)
// hasdga = 0;
}
/* window attributes */
attr.background_pixel = 0;
attr.border_pixel = 0;
attr.colormap = XCreateColormap(x_disp, root, visinfo->visual, AllocNone);
attr.event_mask = X_MASK;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
#ifdef HAVE_VIDMODE
if (hasvidmode && vid_fullscreen->value) {
int smallest_mode=0, x=MAXINT, y=MAXINT;
attr.override_redirect=1;
mask|=CWOverrideRedirect;
// FIXME: does this depend on mode line order in XF86Config?
for (i=0; i<nummodes; i++) {
if (x>vidmodes[i]->hdisplay || y>vidmodes[i]->vdisplay) {
smallest_mode=i;
x=vidmodes[i]->hdisplay;
y=vidmodes[i]->vdisplay;
}
printf("%dx%d\n",vidmodes[i]->hdisplay,vidmodes[i]->vdisplay);
}
// chose the smallest mode that our window fits into;
for (i=smallest_mode;
i!=(smallest_mode+1)%nummodes;
i=(i?i-1:nummodes-1)) {
if (vidmodes[i]->hdisplay>=width
&& vidmodes[i]->vdisplay>=height) {
XF86VidModeSwitchToMode (x_disp, DefaultScreen (x_disp),
vidmodes[i]);
break;
}
}
XF86VidModeSetViewPort(x_disp, DefaultScreen (x_disp), 0, 0);
_windowed_mouse = Cvar_Get ("_windowed_mouse","1",CVAR_ARCHIVE|CVAR_ROM,"None");
} else
#endif
_windowed_mouse = Cvar_Get ("_windowed_mouse","0",CVAR_ARCHIVE,"None");
x_win = XCreateWindow(x_disp, root, 0, 0, width, height,
0, visinfo->depth, InputOutput,
visinfo->visual, mask, &attr);
XMapWindow(x_disp, x_win);
XRaiseWindow(x_disp, x_win);
x11_set_vidmode(width, height);
x11_create_window(width, height);
/* Invisible cursor */
CreateNullCursor(x_disp, x_win);
XDefineCursor(x_disp, x_win, nullcursor);
x11_create_null_cursor();
XWarpPointer(x_disp, None, x_win, 0, 0, 0, 0,
vid.width+2, vid.height+2);
#ifdef HAVE_VIDMODE
if (hasvidmode && vid_fullscreen->value) {
XGrabKeyboard(x_disp, x_win, 1, GrabModeAsync, GrabModeAsync,
CurrentTime);
}
#endif
x11_grab_keyboard();
XSync(x_disp, 0);
ctx = glXCreateContext(x_disp, visinfo, NULL, True);
ctx = glXCreateContext(x_disp, x_visinfo, NULL, True);
glXMakeCurrent(x_disp, x_win, ctx);
@ -727,3 +602,7 @@ void VID_InitCvars()
void VID_SetCaption (char *text)
{
}
void VID_HandlePause (qboolean pause)
{
}

View file

@ -100,3 +100,7 @@ void D_EndDirectRect (int x, int y, int width, int height)
}
void VID_HandlePause (qboolean pause)
{
}

View file

@ -515,3 +515,11 @@ VID_SetCaption (char *text)
SDL_WM_SetCaption(text, NULL);
}
void VID_HandlePause (qboolean pause)
{
}
void IN_HandlePause (qboolean pause)
{
}

View file

@ -710,3 +710,11 @@ VID_SetCaption (char *text)
SDL_WM_SetCaption(text, NULL);
}
void VID_HandlePause (qboolean pause)
{
}
void IN_HandlePause (qboolean pause)
{
}

View file

@ -1268,3 +1268,7 @@ void IN_Move (usercmd_t *cmd)
}
mouse_x = mouse_y = 0.0;
}
void VID_HandlePause (qboolean pause)
{
}

View file

@ -1297,3 +1297,7 @@ void IN_Move (usercmd_t *cmd)
//void VID_UnlockBuffer(void) { }
//void VID_LockBuffer(void) { }
void VID_HandlePause (qboolean pause)
{
}

View file

@ -709,3 +709,7 @@ void outb(unsigned char value, unsigned short port)
{
__asm__ __volatile__ ("outb %b0,%w1" : : "a" (value) , "Nd" (port));
}
void VID_HandlePause (qboolean pause)
{
}

View file

@ -482,3 +482,7 @@ void VGA_SwapBuffers (viddef_t *lvid, vmode_t *pcurrentmode, vrect_t *rects)
VGA_SwapBuffersCopy (lvid, pcurrentmode, rects);
}
void VID_HandlePause (qboolean pause)
{
}

View file

@ -79,18 +79,8 @@
extern viddef_t vid; // global video state
unsigned short d_8to16table[256];
Window x_win;
static Colormap x_cmap;
static GC x_gc;
static Visual *x_vis;
static XVisualInfo *x_visinfo;
static Atom aWMDelete = 0;
static Cursor nullcursor = None;
#ifdef HAVE_VIDMODE
static XF86VidModeModeInfo **vidmodes;
static int nummodes, hasvidmode = 0;
#endif
int XShmQueryExtension(Display *);
int XShmGetEventBase(Display *);
@ -121,40 +111,6 @@ static long X11_highhunkmark;
int scr_width, scr_height;
#define STD_EVENT_MASK \
( VisibilityChangeMask | ExposureMask | StructureNotifyMask)
/*
======================
Create an empty cursor
======================
*/
static void
CreateNullCursor(Display *display, Window root)
{
Pixmap cursormask;
XGCValues xgc;
GC gc;
XColor dummycolour;
if (nullcursor != None) return;
cursormask = XCreatePixmap(display, root, 1, 1, 1/*depth*/);
xgc.function = GXclear;
gc = XCreateGC(display, cursormask, GCFunction, &xgc);
XFillRectangle(display, cursormask, gc, 0, 0, 1, 1);
dummycolour.pixel = 0;
dummycolour.red = 0;
dummycolour.flags = 04;
nullcursor = XCreatePixmapCursor(display, cursormask, cursormask,
&dummycolour,&dummycolour, 0,0);
XFreePixmap(display,cursormask);
XFreeGC(display,gc);
}
static void
shiftmask_init( void )
{
@ -522,18 +478,6 @@ void VID_Init (unsigned char *palette)
// open the display
x11_open_display();
#ifdef HAVE_VIDMODE
hasvidmode = VID_CheckVMode(x_disp, NULL, NULL);
if (hasvidmode) {
if (! XF86VidModeGetAllModeLines(x_disp, DefaultScreen(x_disp),
&nummodes, &vidmodes)
|| nummodes <= 0) {
hasvidmode = 0;
}
}
Con_SafePrintf ("hasvidmode = %i\nnummodes = %i\n", hasvidmode, nummodes);
#endif
// check for command-line window size
if ((pnum=COM_CheckParm("-winsize")))
{
@ -573,15 +517,15 @@ void VID_Init (unsigned char *palette)
// If not specified, use default visual
else
{
int screen;
screen = XDefaultScreen(x_disp);
template.visualid =
XVisualIDFromVisual(XDefaultVisual(x_disp, screen));
XVisualIDFromVisual(XDefaultVisual(x_disp, x_screen));
template_mask = VisualIDMask;
}
// pick a visual- warn if more than one was available
x_visinfo = XGetVisualInfo(x_disp, template_mask, &template, &num_visuals);
x_vis = x_visinfo->visual;
if (num_visuals > 1) {
printf("Found more than one visual id at depth %d:\n", template.depth);
for (i=0 ; i<num_visuals ; i++)
@ -608,71 +552,17 @@ void VID_Init (unsigned char *palette)
printf(" bits_per_rgb %d\n", x_visinfo->bits_per_rgb);
}
x_vis = x_visinfo->visual;
/* Setup attributes for main window */
{
int attribmask = CWEventMask | CWBorderPixel;
XSetWindowAttributes attribs;
x11_set_vidmode(vid.width, vid.height);
attribs.event_mask = STD_EVENT_MASK;
attribs.border_pixel = 0;
/* Create the main window */
x11_create_window(vid.width, vid.height);
#ifdef HAVE_VIDMODE
if (hasvidmode && vid_fullscreen->value) {
int smallest_mode=0, x=INT_MAX, y=INT_MAX;
/* Invisible cursor */
x11_create_null_cursor();
attribs.override_redirect=1;
attribmask|=CWOverrideRedirect;
// FIXME: does this depend on mode line order in XF86Config?
for (i=0; i<nummodes; i++) {
if (x>vidmodes[i]->hdisplay || y>vidmodes[i]->vdisplay) {
smallest_mode=i;
x=vidmodes[i]->hdisplay;
y=vidmodes[i]->vdisplay;
}
printf("%dx%d\n",vidmodes[i]->hdisplay,vidmodes[i]->vdisplay);
}
// chose the smallest mode that our window fits into;
for (i=smallest_mode;
i!=(smallest_mode+1)%nummodes;
i=(i?i-1:nummodes-1)) {
if (vidmodes[i]->hdisplay>=vid.width
&& vidmodes[i]->vdisplay>=vid.height) {
XF86VidModeSwitchToMode (x_disp, DefaultScreen (x_disp),
vidmodes[i]);
break;
}
}
XF86VidModeSetViewPort(x_disp, DefaultScreen (x_disp), 0, 0);
_windowed_mouse = Cvar_Get ("_windowed_mouse","1",CVAR_ARCHIVE|CVAR_ROM,"None");
} else
#endif
_windowed_mouse = Cvar_Get ("_windowed_mouse","0",CVAR_ARCHIVE,"None");
/* Create the main window */
x_win = XCreateWindow(x_disp,
XRootWindow(x_disp, x_visinfo->screen),
0, 0, vid.width, vid.height,
0, /* borderwidth */
x_visinfo->depth, InputOutput, x_vis,
attribmask, &attribs);
scr_width = vid.width;
scr_height = vid.height;
/* Give it a title */
XStoreName(x_disp, x_win, "XQuake");
/* Make window respond to Delete events */
aWMDelete = XInternAtom(x_disp, "WM_DELETE_WINDOW", False);
XSetWMProtocols(x_disp, x_win, &aWMDelete, 1);
/* Invisible cursor */
CreateNullCursor(x_disp, x_win);
XDefineCursor(x_disp, x_win, nullcursor);
}
scr_width = vid.width;
scr_height = vid.height;
if (x_visinfo->depth == 8) {
/* Create and upload the palette */
@ -695,12 +585,7 @@ void VID_Init (unsigned char *palette)
// map the window
XMapWindow(x_disp, x_win);
XRaiseWindow(x_disp, x_win);
#ifdef HAVE_VIDMODE
if (hasvidmode && vid_fullscreen->value) {
XGrabKeyboard(x_disp, x_win, 1, GrabModeAsync, GrabModeAsync,
CurrentTime);
}
#endif
x11_grab_keyboard();
// wait for first exposure event
{
@ -798,22 +683,7 @@ VID_Shutdown(void)
{
Sys_Printf("VID_Shutdown\n");
if (x_disp) {
#ifdef HAVE_VIDMODE
if (hasvidmode) {
int i;
XF86VidModeSwitchToMode (x_disp, DefaultScreen (x_disp),
vidmodes[0]);
for (i = 0; i < nummodes; i++) {
if (vidmodes[i]->private) XFree(vidmodes[i]->private);
}
XFree(vidmodes);
}
#endif
if (nullcursor != None) {
XFreeCursor(x_disp, nullcursor);
nullcursor = None;
}
x11_restore_vidmode();
XAutoRepeatOn(x_disp);
x11_close_display();
x_disp = 0;
@ -927,3 +797,7 @@ void VID_InitCvars ()
void VID_SetCaption (char *text)
{
}
void VID_HandlePause (qboolean pause)
{
}