first stab at doing vid_mode the right way, thanks to james111

(James Andariese - james@ja.ath.cx) doesn't quite work properly for all
window managers, but NICE :)
This commit is contained in:
Bill Currie 2001-05-17 06:55:47 +00:00
parent 4606c6c63a
commit 9bea21a930
3 changed files with 42 additions and 8 deletions

View file

@ -101,6 +101,7 @@ cvar_t *vid_fullscreen;
cvar_t *vid_system_gamma;
qboolean vid_gamma_avail;
qboolean vid_fullscreen_active;
static qboolean vid_context_created = false;
static double x_gamma;
static int xss_timeout;
@ -384,6 +385,8 @@ X11_CreateWindow (int width, int height)
aWMDelete = XInternAtom (x_disp, "WM_DELETE_WINDOW", False);
XSetWMProtocols (x_disp, x_win, &aWMDelete, 1);
vid_context_created = true;
if (vidmode_active && vid_fullscreen->int_val) {
XMoveWindow (x_disp, x_win, 0, 0);
XWarpPointer (x_disp, None, x_win, 0, 0, 0, 0,
@ -435,15 +438,31 @@ void
X11_ForceViewPort (void)
{
#ifdef HAVE_VIDMODE
int x, y;
if (vidmode_active && vid_fullscreen->int_val) {
do {
XF86VidModeSetViewPort (x_disp, x_screen, 0, 0);
poll (0, 0, 50);
XF86VidModeGetViewPort (x_disp, x_screen, &x, &y);
} while (x || y);
printf("in thinger\n");
if (vidmode_avail && vid_context_created) {
Window theroot,scrap;
int x,y,ax,ay;
unsigned int width,height,bdwidth,depth;
if ((XGetGeometry(x_disp,x_win,&theroot,&x,&y,&width,&height,
&bdwidth,&depth) == False)) {
Con_Printf ("XGetWindowAttributes failed in vid_center.\n");
} else {
XTranslateCoordinates(x_disp,x_win,theroot,-bdwidth,-bdwidth,
&ax,&ay,&scrap);
Con_Printf("Setting viewport to %dx%d (%d,%d)\n",ax,ay,
width,height);
XF86VidModeSetViewPort(x_disp,x_screen,ax,ay);
}
} else {
/* "icky kludge code" */
XWarpPointer(x_disp,x_win,x_win,0,0,0,0, 0,0);
XWarpPointer(x_disp,x_win,x_win,0,0,0,0, scr_width,scr_height);
}
#else
/* "icky kludge code" */
XWarpPointer(x_disp,x_win,x_win,0,0,0,0, 0,0);
XWarpPointer(x_disp,x_win,x_win,0,0,0,0, scr_width,scr_height);
#endif
}

View file

@ -46,6 +46,7 @@
# include <X11/extensions/xf86dga.h>
#endif
#include "QF/cmd.h"
#include "QF/compat.h"
#include "QF/console.h"
#include "QF/input.h"
@ -130,6 +131,11 @@ GL_EndRendering (void)
Sbar_Changed ();
}
void
VID_Center_f (void) {
X11_ForceViewPort ();
}
void
VID_Init (unsigned char *palette)
{
@ -144,6 +150,8 @@ VID_Init (unsigned char *palette)
None
};
Cmd_AddCommand ("vid_center", VID_Center_f, "Center the view port on the quake window in a virtual desktop.\n");
VID_GetWindowSize (640, 480);
Con_CheckResize (); // Now that we have a window size, fix console

View file

@ -399,6 +399,11 @@ event_shm (XEvent * event)
oktodraw = true;
}
void
VID_Center_f (void) {
X11_ForceViewPort ();
}
/*
VID_Init
@ -414,6 +419,8 @@ VID_Init (unsigned char *palette)
int num_visuals;
int template_mask;
Cmd_AddCommand ("vid_center", VID_Center_f, "Center the view port on the quake window in a virtual desktop.\n");
VID_GetWindowSize (320, 200);
vid.width = vid_width->int_val;