mirror of
https://github.com/blendogames/thirtyflightsofloving.git
synced 2025-02-21 19:21:18 +00:00
Preliminary work for borderless window support on Linux.
This commit is contained in:
parent
9912c694d0
commit
240a4f089f
6 changed files with 158 additions and 114 deletions
|
@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
*/
|
||||
|
||||
/*
|
||||
** gl_fxmesa.c
|
||||
** GL_FXMESA.C
|
||||
**
|
||||
** This file contains ALL Linux specific stuff having to do with the
|
||||
** OpenGL refresh. When a port is being made the following functions
|
||||
|
|
|
@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
*/
|
||||
|
||||
/*
|
||||
** gl_glx.c
|
||||
** GL_GLX.C
|
||||
**
|
||||
** This file contains ALL Linux specific stuff having to do with the
|
||||
** OpenGL refresh. When a port is being made the following functions
|
||||
|
@ -109,7 +109,7 @@ static cvar_t *m_pitch;
|
|||
static cvar_t *m_forward;
|
||||
static cvar_t *freelook;
|
||||
|
||||
static Cursor CreateNullCursor(Display *display, Window root)
|
||||
static Cursor CreateNullCursor (Display *display, Window root)
|
||||
{
|
||||
Pixmap cursormask;
|
||||
XGCValues xgc;
|
||||
|
@ -131,7 +131,7 @@ static Cursor CreateNullCursor(Display *display, Window root)
|
|||
return cursor;
|
||||
}
|
||||
|
||||
static void install_grabs(void)
|
||||
static void install_grabs (void)
|
||||
{
|
||||
|
||||
// inviso cursor
|
||||
|
@ -173,7 +173,7 @@ static void install_grabs(void)
|
|||
// XSync(dpy, True);
|
||||
}
|
||||
|
||||
static void uninstall_grabs(void)
|
||||
static void uninstall_grabs (void)
|
||||
{
|
||||
if (!dpy || !win)
|
||||
return;
|
||||
|
@ -208,7 +208,7 @@ static void RW_IN_MLookUp (void)
|
|||
in_state->IN_CenterView_fp ();
|
||||
}
|
||||
|
||||
void RW_IN_Init(in_state_t *in_state_p)
|
||||
void RW_IN_Init (in_state_t *in_state_p)
|
||||
{
|
||||
int mtype;
|
||||
int i;
|
||||
|
@ -236,7 +236,7 @@ void RW_IN_Init(in_state_t *in_state_p)
|
|||
mouse_avail = true;
|
||||
}
|
||||
|
||||
void RW_IN_Shutdown(void)
|
||||
void RW_IN_Shutdown (void)
|
||||
{
|
||||
mouse_avail = false;
|
||||
}
|
||||
|
@ -292,7 +292,7 @@ void RW_IN_Move (usercmd_t *cmd)
|
|||
mx = my = 0;
|
||||
}
|
||||
|
||||
static void IN_DeactivateMouse( void )
|
||||
static void IN_DeactivateMouse (void)
|
||||
{
|
||||
if (!mouse_avail || !dpy || !win)
|
||||
return;
|
||||
|
@ -303,7 +303,7 @@ static void IN_DeactivateMouse( void )
|
|||
}
|
||||
}
|
||||
|
||||
static void IN_ActivateMouse( void )
|
||||
static void IN_ActivateMouse (void)
|
||||
{
|
||||
if (!mouse_avail || !dpy || !win)
|
||||
return;
|
||||
|
@ -319,7 +319,7 @@ void RW_IN_Frame (void)
|
|||
{
|
||||
}
|
||||
|
||||
void RW_IN_Activate(qboolean active)
|
||||
void RW_IN_Activate (qboolean active)
|
||||
{
|
||||
if (active || vidmode_active)
|
||||
IN_ActivateMouse();
|
||||
|
@ -331,7 +331,7 @@ void RW_IN_Activate(qboolean active)
|
|||
/* KEYBOARD */
|
||||
/*****************************************************************************/
|
||||
|
||||
static int XLateKey(XKeyEvent *ev)
|
||||
static int XLateKey (XKeyEvent *ev)
|
||||
{
|
||||
|
||||
int key;
|
||||
|
@ -423,7 +423,7 @@ static int XLateKey(XKeyEvent *ev)
|
|||
case XK_Insert:key = K_INS; break;
|
||||
case XK_KP_Insert: key = K_KP_INS; break;
|
||||
|
||||
case XK_KP_Multiply: key = '*'; break;
|
||||
case XK_KP_Multiply: key = K_KP_MULT; break; // was '*'
|
||||
case XK_KP_Add: key = K_KP_PLUS; break;
|
||||
case XK_KP_Subtract: key = K_KP_MINUS; break;
|
||||
case XK_KP_Divide: key = K_KP_SLASH; break;
|
||||
|
@ -462,7 +462,7 @@ static int XLateKey(XKeyEvent *ev)
|
|||
}
|
||||
|
||||
|
||||
static void HandleEvents(void)
|
||||
static void HandleEvents (void)
|
||||
{
|
||||
XEvent event;
|
||||
int b;
|
||||
|
@ -548,34 +548,34 @@ static void HandleEvents(void)
|
|||
|
||||
Key_Event_fp_t Key_Event_fp;
|
||||
|
||||
void KBD_Init(Key_Event_fp_t fp)
|
||||
void KBD_Init (Key_Event_fp_t fp)
|
||||
{
|
||||
Key_Event_fp = fp;
|
||||
}
|
||||
|
||||
void KBD_Update(void)
|
||||
void KBD_Update (void)
|
||||
{
|
||||
// get events from x server
|
||||
HandleEvents();
|
||||
}
|
||||
|
||||
void KBD_Close(void)
|
||||
void KBD_Close (void)
|
||||
{
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static qboolean GLimp_SwitchFullscreen( int width, int height );
|
||||
static qboolean GLimp_SwitchFullscreen (int width, int height);
|
||||
qboolean GLimp_InitGL (void);
|
||||
|
||||
static void signal_handler(int sig)
|
||||
static void signal_handler (int sig)
|
||||
{
|
||||
printf("Received signal %d, exiting...\n", sig);
|
||||
GLimp_Shutdown();
|
||||
_exit(0);
|
||||
}
|
||||
|
||||
static void InitSig(void)
|
||||
static void InitSig (void)
|
||||
{
|
||||
signal(SIGHUP, signal_handler);
|
||||
signal(SIGQUIT, signal_handler);
|
||||
|
@ -591,7 +591,8 @@ static void InitSig(void)
|
|||
/*
|
||||
** GLimp_SetMode
|
||||
*/
|
||||
int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
|
||||
//int GLimp_SetMode (int *pwidth, int *pheight, int mode, qboolean fullscreen)
|
||||
int GLimp_SetMode (int *pwidth, int *pheight, int mode, dispType_t fullscreen)
|
||||
{
|
||||
int width, height;
|
||||
int attrib[] = {
|
||||
|
@ -615,9 +616,12 @@ int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
|
|||
|
||||
ri.Con_Printf( PRINT_ALL, "Initializing OpenGL display\n");
|
||||
|
||||
if (fullscreen)
|
||||
// if (fullscreen)
|
||||
if ( fullscreen == dt_fullscreen ) // borderless support
|
||||
ri.Con_Printf (PRINT_ALL, "...setting fullscreen mode %d:", mode );
|
||||
else
|
||||
else if ( fullscreen == dt_borderless ) // borderless support
|
||||
Com_Printf ( "...setting borderless window mode %d:", mode );
|
||||
else // if ( fullscreen == dt_windowed )
|
||||
ri.Con_Printf (PRINT_ALL, "...setting mode %d:", mode );
|
||||
|
||||
if ( !ri.Vid_GetModeInfo( &width, &height, mode ) )
|
||||
|
@ -649,7 +653,8 @@ int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
|
|||
MajorVersion = MinorVersion = 0;
|
||||
if (!XF86VidModeQueryVersion(dpy, &MajorVersion, &MinorVersion)) {
|
||||
vidmode_ext = false;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ri.Con_Printf(PRINT_ALL, "Using XFree86-VidModeExtension Version %d.%d\n",
|
||||
MajorVersion, MinorVersion);
|
||||
vidmode_ext = true;
|
||||
|
@ -661,17 +666,21 @@ int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
|
|||
return rserr_invalid_mode;
|
||||
}
|
||||
|
||||
if (vidmode_ext) {
|
||||
if (vidmode_ext)
|
||||
{
|
||||
int best_fit, best_dist, dist, x, y;
|
||||
|
||||
XF86VidModeGetAllModeLines(dpy, scrnum, &num_vidmodes, &vidmodes);
|
||||
|
||||
// Are we going fullscreen? If so, let's change video mode
|
||||
if (fullscreen && !r_fakeFullscreen->value) {
|
||||
// if (fullscreen && !r_fakeFullscreen->value)
|
||||
if ( (fullscreen == dt_fullscreen) && !r_fakeFullscreen->value ) // borderless support
|
||||
{
|
||||
best_dist = 9999999;
|
||||
best_fit = -1;
|
||||
|
||||
for (i = 0; i < num_vidmodes; i++) {
|
||||
for (i = 0; i < num_vidmodes; i++)
|
||||
{
|
||||
if (width > vidmodes[i]->hdisplay ||
|
||||
height > vidmodes[i]->vdisplay)
|
||||
continue;
|
||||
|
@ -685,7 +694,8 @@ int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
|
|||
}
|
||||
}
|
||||
|
||||
if (best_fit != -1) {
|
||||
if (best_fit != -1)
|
||||
{
|
||||
actualWidth = vidmodes[best_fit]->hdisplay;
|
||||
actualHeight = vidmodes[best_fit]->vdisplay;
|
||||
|
||||
|
@ -695,7 +705,8 @@ int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
|
|||
|
||||
// Move the viewport to top left
|
||||
XF86VidModeSetViewPort(dpy, scrnum, 0, 0);
|
||||
} else
|
||||
}
|
||||
else
|
||||
fullscreen = 0;
|
||||
}
|
||||
}
|
||||
|
@ -705,13 +716,15 @@ int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
|
|||
attr.border_pixel = 0;
|
||||
attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
|
||||
attr.event_mask = X_MASK;
|
||||
if (vidmode_active) {
|
||||
if (vidmode_active)
|
||||
{
|
||||
mask = CWBackPixel | CWColormap | CWSaveUnder | CWBackingStore |
|
||||
CWEventMask | CWOverrideRedirect;
|
||||
attr.override_redirect = True;
|
||||
attr.backing_store = NotUseful;
|
||||
attr.save_under = False;
|
||||
} else
|
||||
}
|
||||
else
|
||||
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
|
||||
|
||||
win = XCreateWindow(dpy, root, 0, 0, width, height,
|
||||
|
@ -719,7 +732,8 @@ int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
|
|||
visinfo->visual, mask, &attr);
|
||||
XMapWindow(dpy, win);
|
||||
|
||||
if (vidmode_active) {
|
||||
if (vidmode_active)
|
||||
{
|
||||
XMoveWindow(dpy, win, 0, 0);
|
||||
XRaiseWindow(dpy, win);
|
||||
XWarpPointer(dpy, None, win, 0, 0, 0, 0, 0, 0);
|
||||
|
@ -754,7 +768,7 @@ int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
|
|||
** for the window. The state structure is also nulled out.
|
||||
**
|
||||
*/
|
||||
void GLimp_Shutdown( void )
|
||||
void GLimp_Shutdown (void)
|
||||
{
|
||||
uninstall_grabs();
|
||||
mouse_active = false;
|
||||
|
@ -781,9 +795,9 @@ void GLimp_Shutdown( void )
|
|||
** This routine is responsible for initializing the OS specific portions
|
||||
** of OpenGL.
|
||||
*/
|
||||
int GLimp_Init( void *hinstance, void *wndproc )
|
||||
int GLimp_Init (void *hinstance, void *wndproc)
|
||||
{
|
||||
InitSig();
|
||||
InitSig ();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -791,7 +805,7 @@ int GLimp_Init( void *hinstance, void *wndproc )
|
|||
/*
|
||||
** GLimp_BeginFrame
|
||||
*/
|
||||
void GLimp_BeginFrame( float camera_seperation )
|
||||
void GLimp_BeginFrame (float camera_seperation)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -804,20 +818,20 @@ void GLimp_BeginFrame( float camera_seperation )
|
|||
*/
|
||||
void GLimp_EndFrame (void)
|
||||
{
|
||||
qglFlush();
|
||||
qglFlush ();
|
||||
qglXSwapBuffers(dpy, win);
|
||||
}
|
||||
|
||||
/*
|
||||
** GLimp_AppActivate
|
||||
*/
|
||||
void GLimp_AppActivate( qboolean active )
|
||||
void GLimp_AppActivate (qboolean active)
|
||||
{
|
||||
}
|
||||
|
||||
void Fake_glColorTableEXT( GLenum target, GLenum internalformat,
|
||||
void Fake_glColorTableEXT (GLenum target, GLenum internalformat,
|
||||
GLsizei width, GLenum format, GLenum type,
|
||||
const GLvoid *table )
|
||||
const GLvoid *table)
|
||||
{
|
||||
byte temptable[256][4];
|
||||
byte *intbl;
|
||||
|
|
|
@ -58,6 +58,7 @@ static char exe_dir[MAX_OSPATH];
|
|||
static char pref_dir[MAX_OSPATH];
|
||||
static char download_dir[MAX_OSPATH];
|
||||
|
||||
|
||||
// =======================================================================
|
||||
// General routines
|
||||
// =======================================================================
|
||||
|
@ -88,7 +89,6 @@ void Sys_Printf (char *fmt, ...)
|
|||
unsigned char *p;
|
||||
|
||||
va_start (argptr, fmt);
|
||||
// vsprintf (text, fmt, argptr);
|
||||
Q_vsnprintf (text, sizeof(text), fmt, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
|
@ -122,19 +122,18 @@ void Sys_Init(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
void Sys_Error (char *error, ...)
|
||||
void Sys_Error (const char *error, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char string[1024];
|
||||
|
||||
// change stdin to non blocking
|
||||
// change stdin to non blocking
|
||||
fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
|
||||
|
||||
CL_Shutdown ();
|
||||
Qcommon_Shutdown ();
|
||||
|
||||
va_start (argptr, error);
|
||||
// vsprintf (string, error, argptr);
|
||||
Q_vsnprintf (string, sizeof(string), error, argptr);
|
||||
va_end (argptr);
|
||||
fprintf(stderr, "Error: %s\n", string);
|
||||
|
@ -148,7 +147,6 @@ void Sys_Warn (char *warning, ...)
|
|||
char string[1024];
|
||||
|
||||
va_start (argptr, warning);
|
||||
// vsprintf (string, warning, argptr);
|
||||
Q_vsnprintf (string, sizeof(string), warning, argptr);
|
||||
va_end (argptr);
|
||||
fprintf(stderr, "Warning: %s", string);
|
||||
|
@ -275,10 +273,11 @@ void *Sys_GetGameAPI (void *parms)
|
|||
path = NULL;
|
||||
while (1)
|
||||
{
|
||||
path = FS_NextPath (path);
|
||||
// path = FS_NextPath (path);
|
||||
path = FS_NextGamePath (path);
|
||||
if (!path)
|
||||
return NULL; // couldn't find one anywhere
|
||||
sprintf (name, "%s/%s/%s", curpath, path, gamename);
|
||||
Com_sprintf (name, sizeof(name), "%s/%s/%s", curpath, path, gamename);
|
||||
game_library = dlopen (name, RTLD_LAZY );
|
||||
if (game_library)
|
||||
{
|
||||
|
@ -471,21 +470,21 @@ void Sys_CopyProtect(void)
|
|||
if (strcmp(ent->mnt_type, "iso9660") == 0) {
|
||||
// found a cd file system
|
||||
found_cd = true;
|
||||
sprintf(path, "%s/%s", ent->mnt_dir, "install/data/quake2.exe");
|
||||
Com_sprintf(path, sizeof(path), "%s/%s", ent->mnt_dir, "install/data/quake2.exe");
|
||||
if (stat(path, &st) == 0) {
|
||||
// found it
|
||||
checked = true;
|
||||
endmntent(mnt);
|
||||
return;
|
||||
}
|
||||
sprintf(path, "%s/%s", ent->mnt_dir, "Install/Data/quake2.exe");
|
||||
Com_sprintf(path, sizeof(path), "%s/%s", ent->mnt_dir, "Install/Data/quake2.exe");
|
||||
if (stat(path, &st) == 0) {
|
||||
// found it
|
||||
checked = true;
|
||||
endmntent(mnt);
|
||||
return;
|
||||
}
|
||||
sprintf(path, "%s/%s", ent->mnt_dir, "quake2.exe");
|
||||
Com_sprintf(path, sizeof(path), "%s/%s", ent->mnt_dir, "quake2.exe");
|
||||
if (stat(path, &st) == 0) {
|
||||
// found it
|
||||
checked = true;
|
||||
|
|
|
@ -435,11 +435,18 @@ void VID_Init (void)
|
|||
else
|
||||
vid_ref = Cvar_Get ("vid_ref", "soft", CVAR_ARCHIVE);
|
||||
vid_xpos = Cvar_Get ("vid_xpos", "3", CVAR_ARCHIVE);
|
||||
Cvar_SetDescription ("vid_ref", "Video renderer module in use. This is always set to \"gl\" in KMQuake2.");
|
||||
vid_ypos = Cvar_Get ("vid_ypos", "22", CVAR_ARCHIVE);
|
||||
Cvar_SetDescription ("vid_xpos", "Sets horizontal desktop position of window in windowed mode.");
|
||||
vid_fullscreen = Cvar_Get ("vid_fullscreen", "0", CVAR_ARCHIVE);
|
||||
// Cvar_SetDescription ("vid_fullscreen", "Enables fullscreen video mode.");
|
||||
Cvar_SetDescription ("vid_fullscreen", "Sets fullscreen or borderless video mode. 0 = windowed, 1 = fullscreen, 2 = borderless"); // borderless support
|
||||
vid_gamma = Cvar_Get( "vid_gamma", "1", CVAR_ARCHIVE );
|
||||
Cvar_SetDescription ("vid_gamma", "Screen brightness value. Uses inverse scale.");
|
||||
r_customwidth = Cvar_Get( "r_customwidth", "1600", CVAR_ARCHIVE );
|
||||
Cvar_SetDescription ("r_customwidth", "Sets resolution width when using custom video mode (-1).");
|
||||
r_customheight = Cvar_Get( "r_customheight", "1024", CVAR_ARCHIVE );
|
||||
Cvar_SetDescription ("r_customheight", "Sets resolution height when using custom video mode (-1).");
|
||||
|
||||
/* Add some console commands that we want to handle */
|
||||
Cmd_AddCommand ("vid_restart", VID_Restart_f);
|
||||
|
|
137
unix/gl_glx.c
137
unix/gl_glx.c
|
@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
*/
|
||||
|
||||
/*
|
||||
** gl_glx.c
|
||||
** GL_GLX.C
|
||||
**
|
||||
** This file contains ALL Linux specific stuff having to do with the
|
||||
** OpenGL refresh. When a port is being made the following functions
|
||||
|
@ -48,6 +48,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
#include "../renderer/r_local.h"
|
||||
|
||||
#include "../ui/ui_local.h"
|
||||
|
||||
#include "../client/keys.h"
|
||||
|
||||
#include "glw_unix.h"
|
||||
|
@ -105,11 +107,11 @@ qboolean vidmode_ext = false;
|
|||
|
||||
static Time myxtime;
|
||||
|
||||
extern cursor_t ui_mousecursor;
|
||||
//extern cursor_t cursor;
|
||||
|
||||
qboolean have_stencil = false; //Knightmare 12/24/2001- stencil shadows
|
||||
qboolean have_stencil = false; // Knightmare 12/24/2001- stencil shadows
|
||||
|
||||
static Cursor CreateNullCursor(Display *display, Window root)
|
||||
static Cursor CreateNullCursor (Display *display, Window root)
|
||||
{
|
||||
Pixmap cursormask;
|
||||
XGCValues xgc;
|
||||
|
@ -131,7 +133,7 @@ static Cursor CreateNullCursor(Display *display, Window root)
|
|||
return cursor;
|
||||
}
|
||||
|
||||
void install_grabs(void)
|
||||
void install_grabs (void)
|
||||
{
|
||||
|
||||
// inviso cursor
|
||||
|
@ -177,7 +179,7 @@ void install_grabs(void)
|
|||
mouse_active = true;
|
||||
}
|
||||
|
||||
void uninstall_grabs(void)
|
||||
void uninstall_grabs (void)
|
||||
{
|
||||
if (!dpy || !win)
|
||||
return;
|
||||
|
@ -196,7 +198,7 @@ void uninstall_grabs(void)
|
|||
mouse_active = false;
|
||||
}
|
||||
|
||||
void IN_DeactivateMouse( void )
|
||||
void IN_DeactivateMouse (void)
|
||||
{
|
||||
if (!dpy || !win)
|
||||
return;
|
||||
|
@ -207,7 +209,7 @@ void IN_DeactivateMouse( void )
|
|||
}
|
||||
}
|
||||
|
||||
static void IN_ActivateMouse( void )
|
||||
static void IN_ActivateMouse (void)
|
||||
{
|
||||
if (!dpy || !win)
|
||||
return;
|
||||
|
@ -232,7 +234,7 @@ void IN_Activate (qboolean active)
|
|||
/* KEYBOARD */
|
||||
/*****************************************************************************/
|
||||
|
||||
static int XLateKey(XKeyEvent *ev)
|
||||
static int XLateKey (XKeyEvent *ev)
|
||||
{
|
||||
|
||||
int key;
|
||||
|
@ -324,7 +326,7 @@ static int XLateKey(XKeyEvent *ev)
|
|||
case XK_Insert:key = K_INS; break;
|
||||
case XK_KP_Insert: key = K_KP_INS; break;
|
||||
|
||||
case XK_KP_Multiply: key = '*'; break;
|
||||
case XK_KP_Multiply: key = K_KP_MULT; break; // was '*'
|
||||
case XK_KP_Add: key = K_KP_PLUS; break;
|
||||
case XK_KP_Subtract: key = K_KP_MINUS; break;
|
||||
case XK_KP_Divide: key = K_KP_SLASH; break;
|
||||
|
@ -341,7 +343,7 @@ static int XLateKey(XKeyEvent *ev)
|
|||
return key;
|
||||
}
|
||||
|
||||
void HandleEvents(void)
|
||||
void HandleEvents (void)
|
||||
{
|
||||
XEvent event;
|
||||
qboolean dowarp = false;
|
||||
|
@ -397,21 +399,20 @@ void HandleEvents(void)
|
|||
|
||||
case ButtonPress:
|
||||
myxtime = event.xbutton.time;
|
||||
if (event.xbutton.button)
|
||||
{
|
||||
if (Sys_Milliseconds() - ui_mousecursor.buttontime[mouse_button] < multiclicktime)
|
||||
if (event.xbutton.button) {
|
||||
if (Sys_Milliseconds()-ui_mousecursor.buttontime[mouse_button] < multiclicktime)
|
||||
ui_mousecursor.buttonclicks[mouse_button] += 1;
|
||||
else
|
||||
ui_mousecursor.buttonclicks[mouse_button] = 1;
|
||||
|
||||
if (ui_mousecursor.buttonclicks[mouse_button] > 3)
|
||||
ui_mousecursor.buttonclicks[mouse_button] = 3;
|
||||
if (ui_mousecursor.buttonclicks[mouse_button]>3)
|
||||
ui_mousecursor.buttonclicks[mouse_button] = 3;
|
||||
|
||||
ui_mousecursor.buttontime[mouse_button] = Sys_Milliseconds();
|
||||
ui_mousecursor.buttontime[mouse_button] = Sys_Milliseconds();
|
||||
|
||||
ui_mousecursor.buttondown[mouse_button] = true;
|
||||
ui_mousecursor.buttonused[mouse_button] = false;
|
||||
ui_mousecursor.mouseaction = true;
|
||||
ui_mousecursor.buttondown[mouse_button] = true;
|
||||
ui_mousecursor.buttonused[mouse_button] = false;
|
||||
ui_mousecursor.mouseaction = true;
|
||||
}
|
||||
if (event.xbutton.button == 1) Key_Event(K_MOUSE1, 1, Sys_Milliseconds());
|
||||
else if (event.xbutton.button == 2) Key_Event(K_MOUSE3, 1, Sys_Milliseconds());
|
||||
|
@ -465,14 +466,14 @@ void HandleEvents(void)
|
|||
|
||||
qboolean GLimp_InitGL (void);
|
||||
|
||||
static void signal_handler(int sig)
|
||||
static void signal_handler (int sig)
|
||||
{
|
||||
printf("Received signal %d, exiting...\n", sig);
|
||||
GLimp_Shutdown();
|
||||
_exit(0);
|
||||
}
|
||||
|
||||
static void InitSig(void)
|
||||
static void InitSig (void)
|
||||
{
|
||||
signal(SIGHUP, signal_handler);
|
||||
signal(SIGQUIT, signal_handler);
|
||||
|
@ -488,10 +489,11 @@ static void InitSig(void)
|
|||
/*
|
||||
** GLimp_SetMode
|
||||
*/
|
||||
int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
|
||||
//int GLimp_SetMode (int *pwidth, int *pheight, int mode, qboolean fullscreen)
|
||||
rserr_t GLimp_SetMode (int *pwidth, int *pheight, int mode, dispType_t fullscreen)
|
||||
{
|
||||
int width, height;
|
||||
int attrib[] = {
|
||||
int width, height;
|
||||
int attrib[] = {
|
||||
GLX_RGBA,
|
||||
GLX_RED_SIZE, 1,
|
||||
GLX_GREEN_SIZE, 1,
|
||||
|
@ -501,23 +503,26 @@ int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
|
|||
GLX_STENCIL_SIZE, 1,
|
||||
None
|
||||
};
|
||||
Window root;
|
||||
XVisualInfo *visinfo;
|
||||
XSetWindowAttributes attr;
|
||||
unsigned int mask;
|
||||
int MajorVersion, MinorVersion;
|
||||
int actualWidth, actualHeight;
|
||||
XSizeHints *sizehints;
|
||||
XWMHints *wmhints;
|
||||
int i;
|
||||
Window root;
|
||||
XVisualInfo *visinfo;
|
||||
XSetWindowAttributes attr;
|
||||
unsigned int mask;
|
||||
int MajorVersion, MinorVersion;
|
||||
int actualWidth, actualHeight;
|
||||
XSizeHints *sizehints;
|
||||
XWMHints *wmhints;
|
||||
int i;
|
||||
char titleBuf[32];
|
||||
|
||||
r_fakeFullscreen = Cvar_Get( "r_fakeFullscreen", "0", CVAR_ARCHIVE);
|
||||
|
||||
Com_Printf( "Initializing OpenGL display\n");
|
||||
|
||||
if (fullscreen)
|
||||
if ( fullscreen == dt_fullscreen ) // borderless support
|
||||
Com_Printf ( "...setting fullscreen mode %d:", mode );
|
||||
else
|
||||
else if ( fullscreen == dt_borderless ) // borderless support
|
||||
Com_Printf ( "...setting borderless window mode %d:", mode );
|
||||
else // if ( fullscreen == dt_windowed )
|
||||
Com_Printf ( "...setting mode %d:", mode );
|
||||
|
||||
if ( !VID_GetModeInfo( &width, &height, mode ) )
|
||||
|
@ -543,7 +548,8 @@ int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
|
|||
MajorVersion = MinorVersion = 0;
|
||||
if (!XF86VidModeQueryVersion(dpy, &MajorVersion, &MinorVersion)) {
|
||||
vidmode_ext = false;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Com_Printf( "Using XFree86-VidModeExtension Version %d.%d\n",
|
||||
MajorVersion, MinorVersion);
|
||||
vidmode_ext = true;
|
||||
|
@ -557,17 +563,21 @@ int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
|
|||
|
||||
gl_state.gammaramp = false;
|
||||
|
||||
if (vidmode_ext) {
|
||||
if (vidmode_ext)
|
||||
{
|
||||
int best_fit, best_dist, dist, x, y;
|
||||
|
||||
XF86VidModeGetAllModeLines(dpy, scrnum, &num_vidmodes, &vidmodes);
|
||||
|
||||
// Are we going fullscreen? If so, let's change video mode
|
||||
if (fullscreen && !r_fakeFullscreen->value) {
|
||||
// if (fullscreen && !r_fakeFullscreen->value)
|
||||
if ( (fullscreen == dt_fullscreen) && !r_fakeFullscreen->value ) // borderless support
|
||||
{
|
||||
best_dist = 9999999;
|
||||
best_fit = -1;
|
||||
|
||||
for (i = 0; i < num_vidmodes; i++) {
|
||||
for (i = 0; i < num_vidmodes; i++)
|
||||
{
|
||||
if (width > vidmodes[i]->hdisplay ||
|
||||
height > vidmodes[i]->vdisplay)
|
||||
continue;
|
||||
|
@ -581,7 +591,8 @@ int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
|
|||
}
|
||||
}
|
||||
|
||||
if (best_fit != -1) {
|
||||
if (best_fit != -1)
|
||||
{
|
||||
actualWidth = vidmodes[best_fit]->hdisplay;
|
||||
actualHeight = vidmodes[best_fit]->vdisplay;
|
||||
|
||||
|
@ -589,7 +600,8 @@ int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
|
|||
XF86VidModeSwitchToMode(dpy, scrnum, vidmodes[best_fit]);
|
||||
vidmode_active = true;
|
||||
|
||||
if (XF86VidModeGetGamma(dpy, scrnum, &oldgamma)) {
|
||||
if (XF86VidModeGetGamma(dpy, scrnum, &oldgamma))
|
||||
{
|
||||
gl_state.gammaramp = true;
|
||||
/* We can no reliably detect hardware gamma
|
||||
changes across software gamma calls, which
|
||||
|
@ -600,7 +612,8 @@ int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
|
|||
|
||||
// Move the viewport to top left
|
||||
XF86VidModeSetViewPort(dpy, scrnum, 0, 0);
|
||||
} else
|
||||
}
|
||||
else
|
||||
fullscreen = 0;
|
||||
}
|
||||
}
|
||||
|
@ -610,23 +623,28 @@ int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
|
|||
attr.border_pixel = 0;
|
||||
attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
|
||||
attr.event_mask = X_MASK;
|
||||
if (vidmode_active) {
|
||||
if (vidmode_active)
|
||||
{
|
||||
mask = CWBackPixel | CWColormap | CWSaveUnder | CWBackingStore |
|
||||
CWEventMask | CWOverrideRedirect;
|
||||
attr.override_redirect = True;
|
||||
attr.backing_store = NotUseful;
|
||||
attr.save_under = False;
|
||||
} else
|
||||
}
|
||||
else
|
||||
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
|
||||
|
||||
win = XCreateWindow(dpy, root, 0, 0, width, height,
|
||||
0, visinfo->depth, InputOutput,
|
||||
visinfo->visual, mask, &attr);
|
||||
|
||||
XStoreName(dpy, win, "KMQuake2 0.19");
|
||||
|
||||
// XStoreName(dpy, win, "KMQuake2 0.20");
|
||||
Com_sprintf (titleBuf, sizeof(titleBuf), "KMQuake2 v%4.2fu%d", VERSION, VERSION_UPDATE);
|
||||
XStoreName(dpy, win, titleBuf);
|
||||
|
||||
sizehints = XAllocSizeHints();
|
||||
if (sizehints) {
|
||||
if (sizehints)
|
||||
{
|
||||
sizehints->min_width = width;
|
||||
sizehints->min_height = height;
|
||||
sizehints->max_width = width;
|
||||
|
@ -638,7 +656,8 @@ int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
|
|||
}
|
||||
|
||||
wmhints = XAllocWMHints();
|
||||
if (wmhints) {
|
||||
if (wmhints)
|
||||
{
|
||||
#include "q2icon.xbm"
|
||||
|
||||
Pixmap icon_pixmap, icon_mask;
|
||||
|
@ -668,7 +687,8 @@ int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
|
|||
XSetWMProtocols(dpy, win, &wmDeleteWindow, 1);
|
||||
XMapWindow(dpy, win);
|
||||
|
||||
if (vidmode_active) {
|
||||
if (vidmode_active)
|
||||
{
|
||||
XMoveWindow(dpy, win, 0, 0);
|
||||
XRaiseWindow(dpy, win);
|
||||
XWarpPointer(dpy, None, win, 0, 0, 0, 0, 0, 0);
|
||||
|
@ -702,7 +722,6 @@ int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
|
|||
*/
|
||||
|
||||
return rserr_ok;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -714,7 +733,7 @@ int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
|
|||
** for the window. The state structure is also nulled out.
|
||||
**
|
||||
*/
|
||||
void GLimp_Shutdown( void )
|
||||
void GLimp_Shutdown (void)
|
||||
{
|
||||
uninstall_grabs();
|
||||
mouse_active = false;
|
||||
|
@ -747,7 +766,7 @@ void GLimp_Shutdown( void )
|
|||
** This routine is responsible for initializing the OS specific portions
|
||||
** of OpenGL.
|
||||
*/
|
||||
int GLimp_Init( void *hinstance, void *wndproc )
|
||||
int GLimp_Init (void *hinstance, void *wndproc)
|
||||
{
|
||||
InitSig();
|
||||
|
||||
|
@ -760,8 +779,8 @@ int GLimp_Init( void *hinstance, void *wndproc )
|
|||
/*
|
||||
** GLimp_BeginFrame
|
||||
*/
|
||||
void CIN_ProcessCins(void);
|
||||
void GLimp_BeginFrame( float camera_seperation )
|
||||
void CIN_ProcessCins (void);
|
||||
void GLimp_BeginFrame (float camera_seperation)
|
||||
{
|
||||
//Heffo - CIN Texture Update
|
||||
CIN_ProcessCins();
|
||||
|
@ -783,13 +802,13 @@ void GLimp_EndFrame (void)
|
|||
/*
|
||||
** GLimp_AppActivate
|
||||
*/
|
||||
void GLimp_AppActivate( qboolean active )
|
||||
void GLimp_AppActivate (qboolean active)
|
||||
{
|
||||
}
|
||||
|
||||
void Fake_glColorTableEXT( GLenum target, GLenum internalformat,
|
||||
void Fake_glColorTableEXT (GLenum target, GLenum internalformat,
|
||||
GLsizei width, GLenum format, GLenum type,
|
||||
const GLvoid *table )
|
||||
const GLvoid *table)
|
||||
{
|
||||
byte temptable[256][4];
|
||||
byte *intbl;
|
||||
|
@ -826,7 +845,7 @@ void UpdateGammaRamp (void)
|
|||
XF86VidModeSetGamma(dpy, scrnum, &gamma);
|
||||
}
|
||||
|
||||
char *Sys_GetClipboardData()
|
||||
char *Sys_GetClipboardData (void)
|
||||
{
|
||||
Window sowner;
|
||||
Atom type, property;
|
||||
|
|
|
@ -59,15 +59,14 @@ DLL GLUE
|
|||
==========================================================================
|
||||
*/
|
||||
|
||||
#define MAXPRINTMSG 8192 // was 4096
|
||||
#define MAXPRINTMSG 16384 // was 4096
|
||||
void VID_Printf (int print_level, char *fmt, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char msg[MAXPRINTMSG];
|
||||
// static qboolean inupdate;
|
||||
|
||||
|
||||
va_start (argptr, fmt);
|
||||
// vsprintf (msg, fmt, argptr);
|
||||
Q_vsnprintf (msg, sizeof(msg), fmt, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
|
@ -84,7 +83,6 @@ void VID_Error (int err_level, char *fmt, ...)
|
|||
// static qboolean inupdate;
|
||||
|
||||
va_start (argptr, fmt);
|
||||
// vsprintf (msg, fmt, argptr);
|
||||
Q_vsnprintf (msg, sizeof(msg), fmt, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
|
@ -117,7 +115,6 @@ typedef struct vidmode_s
|
|||
int mode;
|
||||
} vidmode_t;
|
||||
|
||||
// Knightmare- added 1280x1024, 1400x1050, 856x480, 1024x480 modes
|
||||
vidmode_t vid_modes[] =
|
||||
{
|
||||
#include "../qcommon/vid_modes.h"
|
||||
|
@ -125,6 +122,13 @@ vidmode_t vid_modes[] =
|
|||
|
||||
qboolean VID_GetModeInfo( int *width, int *height, int mode )
|
||||
{
|
||||
if (mode == -1) // custom mode
|
||||
{
|
||||
*width = r_customwidth->value;
|
||||
*height = r_customheight->value;
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( mode < 0 || mode >= VID_NUM_MODES )
|
||||
return false;
|
||||
|
||||
|
@ -282,7 +286,8 @@ void VID_Init (void)
|
|||
vid_ypos = Cvar_Get ("vid_ypos", "22", CVAR_ARCHIVE);
|
||||
Cvar_SetDescription ("vid_ypos", "Sets vertical desktop position of window in windowed mode.");
|
||||
vid_fullscreen = Cvar_Get ("vid_fullscreen", "0", CVAR_ARCHIVE);
|
||||
Cvar_SetDescription ("vid_fullscreen", "Enables fullscreen video mode.");
|
||||
// Cvar_SetDescription ("vid_fullscreen", "Enables fullscreen video mode.");
|
||||
Cvar_SetDescription ("vid_fullscreen", "Sets fullscreen or borderless video mode. 0 = windowed, 1 = fullscreen, 2 = borderless"); // borderless support
|
||||
vid_gamma = Cvar_Get( "vid_gamma", "0.8", CVAR_ARCHIVE );
|
||||
Cvar_SetDescription ("vid_gamma", "Screen brightness value. Uses inverse scale.");
|
||||
r_customwidth = Cvar_Get( "r_customwidth", "1600", CVAR_ARCHIVE );
|
||||
|
|
Loading…
Reference in a new issue