2004-08-22 22:29:09 +00:00
/*
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
2005-06-15 04:36:20 +00:00
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE .
2004-08-22 22:29:09 +00:00
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 .
*/
2013-03-12 22:54:12 +00:00
2014-03-30 00:39:37 +00:00
/*
Small note : anything concerning EGL in here is specific to egl - with - x11 .
if you want egl - with - framebuffer , look elsewhere .
*/
2013-03-12 22:54:12 +00:00
/*
X11 is a huge pile of shit . I don ' t mean just the old x11 protocol , but all the _current_ standards that don ' t even try to fix the issues too .
Its fucking retarded the crap that you have to do to get something to work .
timeouts to ensure alt + tab between two apps doesn ' t fuck up gamma ramps is NOT a nice thing to have to do .
_MOUSE_ grabs cause alt + tab to fuck up
if I use xinput2 to get raw mouse events ( so that I don ' t have to use some random hack to disable acceleration and risk failing to reset it on crashes ) , then the mouse still moves outside of our window , and trying to fire then looses focus . . .
xf86vm extension results in scrolling around a larger viewport . dependant upon the mouse position . even if we constrain the mouse to our window , it ' ll still scroll .
warping the pointer still triggers ' raw ' mouse move events . in what world does that make any sense ? ! ?
alt - tab task lists are a window in their own right . that ' s okay , but what ' s not okay is that they destroy that window without giving focus to the new window first , so the old one gets focus and that fucks everything up too . yay for timeouts .
to allow alt - tabbing with window managers that do not respect requests to not shove stuff on us , we have to hide ourselves completely and create a separate window that can still accept focus from the window manager . its fecking vile .
window managers reparent us too , in much the same way . which is a bad thing because we keep getting reparented and that makes a mess of focus events . its a nightmare .
the whole thing is bloody retarded .
none of these issues will be fixed by a compositing window manager , because there ' s still a window manager there .
*/
2004-08-22 22:29:09 +00:00
# include <termios.h>
# include <sys/ioctl.h>
# include <sys/stat.h>
2005-04-19 19:31:15 +00:00
# ifdef __linux__
2004-08-22 22:29:09 +00:00
# include <sys/vt.h>
# endif
# include <stdarg.h>
# include <stdio.h>
# include <signal.h>
2018-09-23 19:35:24 +00:00
# include <unistd.h>
2004-08-22 22:29:09 +00:00
# include <dlfcn.h>
# include "quakedef.h"
2018-08-23 07:04:55 +00:00
2020-09-08 05:11:09 +00:00
# ifdef NO_X11
# ifdef VKQUAKE
rendererinfo_t vkrendererinfo ;
# endif
# else
2018-08-23 07:04:55 +00:00
2013-03-12 22:47:42 +00:00
# include <X11/Xlib.h>
# include <X11/Xatom.h>
2016-07-12 00:40:13 +00:00
# include <X11/Xutil.h>
2004-08-22 22:29:09 +00:00
2016-07-12 00:40:13 +00:00
# ifdef VKQUAKE
# include "vk/vkrenderer.h"
2018-05-21 13:47:53 +00:00
# ifdef VK_USE_PLATFORM_XLIB_KHR
2016-07-30 17:59:55 +00:00
static qboolean XVK_SetupSurface_XLib ( void ) ;
2018-05-21 13:47:53 +00:00
# endif
# ifdef VK_USE_PLATFORM_XCB_KHR
2016-07-30 17:59:55 +00:00
static qboolean XVK_SetupSurface_XCB ( void ) ;
2016-07-12 00:40:13 +00:00
# endif
2018-05-21 13:47:53 +00:00
# endif
2016-07-12 00:40:13 +00:00
# ifdef GLQUAKE
2004-08-22 22:29:09 +00:00
# include <GL/glx.h>
2011-02-06 20:56:39 +00:00
# ifdef USE_EGL
2011-03-24 14:35:24 +00:00
# include "gl_videgl.h"
2011-02-06 20:56:39 +00:00
# endif
2014-03-30 00:39:37 +00:00
# include "glquake.h"
2020-05-14 15:50:26 +00:00
# include "vr.h"
2016-07-12 00:40:13 +00:00
# endif
2004-08-22 22:29:09 +00:00
2017-09-02 05:13:33 +00:00
# define USE_VMODE
2020-01-09 15:35:40 +00:00
# ifndef NO_X11_RANDR
# define USE_XRANDR
# endif
2017-09-02 05:13:33 +00:00
2004-08-22 22:29:09 +00:00
# include <X11/keysym.h>
# include <X11/cursorfont.h>
2018-11-27 16:48:19 +00:00
# include <wchar.h>
2004-08-22 22:29:09 +00:00
static Display * vid_dpy = NULL ;
2017-10-25 08:10:35 +00:00
static Cursor vid_nullcursor ; //'cursor' to use when none should be shown
static Cursor vid_newcursor ; //cursor that the game is trying to use
static Cursor vid_activecursor ; //cursor that is currently active
2004-08-22 22:29:09 +00:00
static Window vid_window ;
2013-03-12 22:47:42 +00:00
static Window vid_decoywindow ; //for legacy mode, this is a boring window that we can reparent into as needed
static Window vid_root ;
2016-07-12 00:40:13 +00:00
# ifdef GLQUAKE
2004-08-22 22:29:09 +00:00
static GLXContext ctx = NULL ;
2016-07-12 00:40:13 +00:00
# endif
2021-07-01 01:16:11 +00:00
extern qboolean vid_isfullscreen ;
2013-03-12 22:47:42 +00:00
static int scrnum ;
2014-03-30 00:39:37 +00:00
static long vid_x_eventmask ;
2013-03-12 22:49:04 +00:00
static enum
{
PSL_NONE ,
2016-07-12 00:40:13 +00:00
# ifdef GLQUAKE
2013-03-12 22:49:04 +00:00
# ifdef USE_EGL
PSL_EGL ,
# endif
2016-07-12 00:40:13 +00:00
PSL_GLX ,
# endif
# ifdef VKQUAKE
PSL_VULKAN ,
# endif
2013-03-12 22:49:04 +00:00
} currentpsl ;
2004-08-22 22:29:09 +00:00
2018-03-24 04:02:09 +00:00
extern cvar_t vid_conautoscale , vid_vsync ;
2004-08-22 22:29:09 +00:00
2013-03-12 23:03:46 +00:00
extern int sys_parentleft ;
extern int sys_parenttop ;
extern int sys_parentwidth ;
extern int sys_parentheight ;
extern long sys_parentwindow ;
2018-10-11 10:31:23 +00:00
static qboolean X11_CheckFeature ( const char * featurename , qboolean defaultval )
2017-09-02 05:13:33 +00:00
{
cvar_t * var ;
if ( COM_CheckParm ( va ( " -no%s " , featurename ) ) )
return false ;
if ( COM_CheckParm ( va ( " -force%s " , featurename ) ) )
return true ;
var = Cvar_Get ( va ( " x11_allow_%s " , featurename ) , defaultval ? " 1 " : " 0 " , 0 , NULL ) ;
if ( var )
return ! ! var - > ival ;
return defaultval ;
}
2018-10-11 10:31:23 +00:00
static qboolean X11_Clipboard_Notify ( XSelectionEvent * xselection ) ;
2017-09-02 05:13:33 +00:00
2004-08-22 22:29:09 +00:00
# define KEY_MASK (KeyPressMask | KeyReleaseMask)
# define MOUSE_MASK (ButtonPressMask | ButtonReleaseMask | \
PointerMotionMask )
2004-12-05 08:25:01 +00:00
# define X_MASK (KEY_MASK | MOUSE_MASK | ResizeRequest | StructureNotifyMask | FocusChangeMask | VisibilityChangeMask)
2004-08-22 22:29:09 +00:00
2014-03-30 00:39:37 +00:00
struct _XrmHashBucketRec ;
2018-03-04 14:41:16 +00:00
typedef int ( * qXErrorHandler ) ( Display * , XErrorEvent * ) ;
2013-03-12 23:04:11 +00:00
static struct
{
void * lib ;
int ( * pXChangeProperty ) ( Display * display , Window w , Atom property , Atom type , int format , int mode , unsigned char * data , int nelements ) ;
int ( * pXCloseDisplay ) ( Display * display ) ;
int ( * pXConvertSelection ) ( Display * display , Atom selection , Atom target , Atom property , Window requestor , Time time ) ;
Colormap ( * pXCreateColormap ) ( Display * display , Window w , Visual * visual , int alloc ) ;
GC ( * pXCreateGC ) ( Display * display , Drawable d , unsigned long valuemask , XGCValues * values ) ;
Pixmap ( * pXCreatePixmap ) ( Display * display , Drawable d , unsigned int width , unsigned int height , unsigned int depth ) ;
Cursor ( * pXCreatePixmapCursor ) ( Display * display , Pixmap source , Pixmap mask , XColor * foreground_color , XColor * background_color , unsigned int x , unsigned int y ) ;
Window ( * pXCreateWindow ) ( Display * display , Window parent , int x , int y , unsigned int width , unsigned int height , unsigned int border_width , int depth , unsigned int class , Visual * visual , unsigned long valuemask , XSetWindowAttributes * attributes ) ;
int ( * pXDefineCursor ) ( Display * display , Window w , Cursor cursor ) ;
2018-08-23 06:03:31 +00:00
int ( * pXDeleteProperty ) ( Display * display , Window w , Atom property ) ;
2013-03-12 23:04:11 +00:00
int ( * pXDestroyWindow ) ( Display * display , Window w ) ;
int ( * pXFillRectangle ) ( Display * display , Drawable d , GC gc , int x , int y , unsigned int width , unsigned int height ) ;
int ( * pXFlush ) ( Display * display ) ;
int ( * pXFree ) ( void * data ) ;
int ( * pXFreeCursor ) ( Display * display , Cursor cursor ) ;
void ( * pXFreeEventData ) ( Display * display , XGenericEventCookie * cookie ) ;
int ( * pXFreeGC ) ( Display * display , GC gc ) ;
int ( * pXFreePixmap ) ( Display * display , Pixmap pixmap ) ;
char * ( * pXGetAtomName ) ( Display * display , Atom atom ) ;
Bool ( * pXGetEventData ) ( Display * display , XGenericEventCookie * cookie ) ;
Window ( * pXGetSelectionOwner ) ( Display * display , Atom selection ) ;
Status ( * pXGetWindowAttributes ) ( Display * display , Window w , XWindowAttributes * window_attributes_return ) ;
int ( * pXGetWindowProperty ) ( Display * display , Window w , Atom property , long long_offset , long long_length , Bool delete , Atom req_type , Atom * actual_type_return , int * actual_format_return , unsigned long * nitems_return , unsigned long * bytes_after_return , unsigned char * * prop_return ) ;
int ( * pXGrabKeyboard ) ( Display * display , Window grab_window , Bool owner_events , int pointer_mode , int keyboard_mode , Time time ) ;
int ( * pXGrabPointer ) ( Display * display , Window grab_window , Bool owner_events , unsigned int event_mask , int pointer_mode , int keyboard_mode , Window confine_to , Cursor cursor , Time time ) ;
2020-06-27 19:31:55 +00:00
Status ( * pXInitThreads ) ( void ) ;
2013-03-12 23:04:11 +00:00
Atom ( * pXInternAtom ) ( Display * display , char * atom_name , Bool only_if_exists ) ;
KeySym ( * pXLookupKeysym ) ( XKeyEvent * key_event , int index ) ;
int ( * pXLookupString ) ( XKeyEvent * event_struct , char * buffer_return , int bytes_buffer , KeySym * keysym_return , XComposeStatus * status_in_out ) ;
int ( * pXMapWindow ) ( Display * display , Window w ) ;
int ( * pXMoveResizeWindow ) ( Display * display , Window w , int x , int y , unsigned width , unsigned height ) ;
int ( * pXMoveWindow ) ( Display * display , Window w , int x , int y ) ;
int ( * pXNextEvent ) ( Display * display , XEvent * event_return ) ;
2020-02-11 03:59:01 +00:00
int ( * pXPeekEvent ) ( Display * display , XEvent * event_return ) ;
2013-03-12 23:04:11 +00:00
Display * ( * pXOpenDisplay ) ( char * display_name ) ;
int ( * pXPending ) ( Display * display ) ;
Bool ( * pXQueryExtension ) ( Display * display , const char * name , int * major_opcode_return , int * first_event_return , int * first_error_return ) ;
int ( * pXRaiseWindow ) ( Display * display , Window w ) ;
int ( * pXReparentWindow ) ( Display * display , Window w , Window parent , int x , int y ) ;
int ( * pXResizeWindow ) ( Display * display , Window w , unsigned width , unsigned height ) ;
int ( * pXSelectInput ) ( Display * display , Window w , long event_mask ) ;
Status ( * pXSendEvent ) ( Display * display , Window w , Bool propagate , long event_mask , XEvent * event_send ) ;
int ( * pXSetIconName ) ( Display * display , Window w , char * icon_name ) ;
int ( * pXSetInputFocus ) ( Display * display , Window focus , int revert_to , Time time ) ;
int ( * pXSetSelectionOwner ) ( Display * display , Atom selection , Window owner , Time time ) ;
void ( * pXSetWMNormalHints ) ( Display * display , Window w , XSizeHints * hints ) ;
Status ( * pXSetWMProtocols ) ( Display * display , Window w , Atom * protocols , int count ) ;
int ( * pXStoreName ) ( Display * display , Window w , char * window_name ) ;
int ( * pXSync ) ( Display * display , Bool discard ) ;
int ( * pXUndefineCursor ) ( Display * display , Window w ) ;
int ( * pXUngrabKeyboard ) ( Display * display , Time time ) ;
int ( * pXUngrabPointer ) ( Display * display , Time time ) ;
int ( * pXWarpPointer ) ( Display * display , Window src_w , Window dest_w , int src_x , int src_y , unsigned int src_width , unsigned int src_height , int dest_x , int dest_y ) ;
2014-03-30 00:39:37 +00:00
Status ( * pXMatchVisualInfo ) ( Display * display , int screen , int depth , int class , XVisualInfo * vinfo_return ) ;
2019-07-16 02:59:12 +00:00
XVisualInfo * ( * pXGetVisualInfo ) ( Display * display , long vinfo_mask , XVisualInfo * vinfo_template , int * nitems_return ) ;
2014-03-30 00:39:37 +00:00
2018-03-04 14:41:16 +00:00
qXErrorHandler ( * pXSetErrorHandler ) ( XErrorHandler ) ;
2020-09-08 05:11:09 +00:00
int ( * pXGetErrorText ) ( Display * display , int code , char * buffer_return , int length ) ;
2018-03-04 14:41:16 +00:00
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
int ( * pXGrabServer ) ( Display * display ) ;
int ( * pXUngrabServer ) ( Display * display ) ;
2017-01-15 13:13:09 +00:00
# define XI_RESOURCENAME "FTEQW"
# define XI_RESOURCECLASS "FTEQW"
2014-03-30 00:39:37 +00:00
char * ( * pXSetLocaleModifiers ) ( char * modifier_list ) ;
Bool ( * pXSupportsLocale ) ( void ) ;
XIM ( * pXOpenIM ) ( Display * display , struct _XrmHashBucketRec * db , char * res_name , char * res_class ) ;
2015-09-10 10:16:26 +00:00
char * ( * pXGetIMValues ) ( XIM im , . . . ) ;
2014-03-30 00:39:37 +00:00
XIC ( * pXCreateIC ) ( XIM im , . . . ) ;
void ( * pXSetICFocus ) ( XIC ic ) ;
2017-01-15 13:13:09 +00:00
void ( * pXUnsetICFocus ) ( XIC ic ) ;
2018-11-27 16:48:19 +00:00
char * ( * pXGetICValues ) ( XIC ic , . . . ) ;
char * ( * pXSetICValues ) ( XIC ic , . . . ) ;
2014-03-30 00:39:37 +00:00
Bool ( * pXFilterEvent ) ( XEvent * event , Window w ) ;
int ( * pXutf8LookupString ) ( XIC ic , XKeyPressedEvent * event , char * buffer_return , int bytes_buffer , KeySym * keysym_return , Status * status_return ) ;
int ( * pXwcLookupString ) ( XIC ic , XKeyPressedEvent * event , wchar_t * buffer_return , int bytes_buffer , KeySym * keysym_return , Status * status_return ) ;
void ( * pXDestroyIC ) ( XIC ic ) ;
Status ( * pXCloseIM ) ( XIM im ) ;
qboolean dounicode ;
2018-11-27 16:48:19 +00:00
int ime_shown ;
2014-03-30 00:39:37 +00:00
XIC unicodecontext ;
XIM inputmethod ;
2018-11-27 16:48:19 +00:00
XPoint ime_pos ;
2018-08-23 06:03:31 +00:00
struct
{
Window source ; //the source window to send dndFinished to.
Atom type ; //the type of the data. usually text/uri-list.
Atom myprop ; //the property on our window that we're copying the data to.
} dnd ;
2013-03-12 23:04:11 +00:00
} x11 ;
2016-07-30 17:59:55 +00:00
2018-03-04 14:41:16 +00:00
static int X11_ErrorHandler ( Display * dpy , XErrorEvent * e )
{
char msg [ 80 ] ;
* msg = 0 ;
2020-09-08 05:11:09 +00:00
x11 . pXGetErrorText ( dpy , e - > error_code , msg , sizeof ( msg ) ) ;
2018-03-04 14:41:16 +00:00
Con_Printf ( CON_ERROR " XLib Error %d (%s): request %d.%d \n " , e - > error_code , msg , e - > request_code , e - > minor_code ) ;
return 0 ; //ignored.
}
2013-03-12 23:04:11 +00:00
static qboolean x11_initlib ( void )
{
2016-07-30 17:59:55 +00:00
static dllfunction_t x11_functable [ ] =
2013-03-12 23:04:11 +00:00
{
{ ( void * * ) & x11 . pXChangeProperty , " XChangeProperty " } ,
{ ( void * * ) & x11 . pXCloseDisplay , " XCloseDisplay " } ,
{ ( void * * ) & x11 . pXConvertSelection , " XConvertSelection " } ,
{ ( void * * ) & x11 . pXCreateColormap , " XCreateColormap " } ,
{ ( void * * ) & x11 . pXCreateGC , " XCreateGC " } ,
{ ( void * * ) & x11 . pXCreatePixmap , " XCreatePixmap " } ,
{ ( void * * ) & x11 . pXCreatePixmapCursor , " XCreatePixmapCursor " } ,
{ ( void * * ) & x11 . pXCreateWindow , " XCreateWindow " } ,
{ ( void * * ) & x11 . pXDefineCursor , " XDefineCursor " } ,
2018-08-23 06:03:31 +00:00
{ ( void * * ) & x11 . pXDeleteProperty , " XDeleteProperty " } ,
2013-03-12 23:04:11 +00:00
{ ( void * * ) & x11 . pXDestroyWindow , " XDestroyWindow " } ,
{ ( void * * ) & x11 . pXFillRectangle , " XFillRectangle " } ,
{ ( void * * ) & x11 . pXFlush , " XFlush " } ,
{ ( void * * ) & x11 . pXFree , " XFree " } ,
{ ( void * * ) & x11 . pXFreeCursor , " XFreeCursor " } ,
{ ( void * * ) & x11 . pXFreeGC , " XFreeGC " } ,
{ ( void * * ) & x11 . pXFreePixmap , " XFreePixmap " } ,
{ ( void * * ) & x11 . pXGetAtomName , " XGetAtomName " } ,
{ ( void * * ) & x11 . pXGetSelectionOwner , " XGetSelectionOwner " } ,
{ ( void * * ) & x11 . pXGetWindowAttributes , " XGetWindowAttributes " } ,
{ ( void * * ) & x11 . pXGetWindowProperty , " XGetWindowProperty " } ,
{ ( void * * ) & x11 . pXGrabKeyboard , " XGrabKeyboard " } ,
{ ( void * * ) & x11 . pXGrabPointer , " XGrabPointer " } ,
2020-06-27 19:31:55 +00:00
{ ( void * * ) & x11 . pXInitThreads , " XInitThreads " } ,
2013-03-12 23:04:11 +00:00
{ ( void * * ) & x11 . pXInternAtom , " XInternAtom " } ,
{ ( void * * ) & x11 . pXLookupKeysym , " XLookupKeysym " } ,
{ ( void * * ) & x11 . pXLookupString , " XLookupString " } ,
{ ( void * * ) & x11 . pXMapWindow , " XMapWindow " } ,
{ ( void * * ) & x11 . pXMoveResizeWindow , " XMoveResizeWindow " } ,
{ ( void * * ) & x11 . pXMoveWindow , " XMoveWindow " } ,
{ ( void * * ) & x11 . pXNextEvent , " XNextEvent " } ,
2020-02-11 03:59:01 +00:00
{ ( void * * ) & x11 . pXPeekEvent , " XPeekEvent " } ,
2013-03-12 23:04:11 +00:00
{ ( void * * ) & x11 . pXOpenDisplay , " XOpenDisplay " } ,
{ ( void * * ) & x11 . pXPending , " XPending " } ,
{ ( void * * ) & x11 . pXQueryExtension , " XQueryExtension " } ,
{ ( void * * ) & x11 . pXRaiseWindow , " XRaiseWindow " } ,
{ ( void * * ) & x11 . pXReparentWindow , " XReparentWindow " } ,
{ ( void * * ) & x11 . pXResizeWindow , " XResizeWindow " } ,
{ ( void * * ) & x11 . pXSelectInput , " XSelectInput " } ,
{ ( void * * ) & x11 . pXSendEvent , " XSendEvent " } ,
{ ( void * * ) & x11 . pXSetIconName , " XSetIconName " } ,
{ ( void * * ) & x11 . pXSetInputFocus , " XSetInputFocus " } ,
{ ( void * * ) & x11 . pXSetSelectionOwner , " XSetSelectionOwner " } ,
{ ( void * * ) & x11 . pXSetWMNormalHints , " XSetWMNormalHints " } ,
{ ( void * * ) & x11 . pXSetWMProtocols , " XSetWMProtocols " } ,
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
{ ( void * * ) & x11 . pXStoreName , " XStoreName " } ,
{ ( void * * ) & x11 . pXSync , " XSync " } ,
2013-03-12 23:04:11 +00:00
{ ( void * * ) & x11 . pXUndefineCursor , " XUndefineCursor " } ,
{ ( void * * ) & x11 . pXUngrabKeyboard , " XUngrabKeyboard " } ,
{ ( void * * ) & x11 . pXUngrabPointer , " XUngrabPointer " } ,
{ ( void * * ) & x11 . pXWarpPointer , " XWarpPointer " } ,
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
{ ( void * * ) & x11 . pXMatchVisualInfo , " XMatchVisualInfo " } ,
2019-07-16 02:59:12 +00:00
{ ( void * * ) & x11 . pXGetVisualInfo , " XGetVisualInfo " } ,
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
{ ( void * * ) & x11 . pXGrabServer , " XGrabServer " } ,
{ ( void * * ) & x11 . pXUngrabServer , " XUngrabServer " } ,
2013-03-12 23:04:11 +00:00
{ NULL , NULL }
} ;
if ( ! x11 . lib )
{
2013-11-21 23:02:28 +00:00
# ifdef __CYGWIN__
x11 . lib = Sys_LoadLibrary ( " cygX11-6.dll " , x11_functable ) ;
# else
2013-05-13 13:43:18 +00:00
x11 . lib = Sys_LoadLibrary ( " libX11.so.6 " , x11_functable ) ;
2013-11-21 23:02:28 +00:00
# endif
2013-05-13 13:43:18 +00:00
if ( ! x11 . lib )
x11 . lib = Sys_LoadLibrary ( " libX11 " , x11_functable ) ;
2013-03-12 23:04:11 +00:00
//these ones are extensions, and the reason we're doing this.
if ( x11 . lib )
{
2018-03-04 14:41:16 +00:00
x11 . pXSetErrorHandler = Sys_GetAddressForName ( x11 . lib , " XSetErrorHandler " ) ;
2020-09-08 05:11:09 +00:00
x11 . pXGetErrorText = Sys_GetAddressForName ( x11 . lib , " XGetErrorText " ) ;
2018-03-04 14:41:16 +00:00
2020-09-08 05:11:09 +00:00
if ( x11 . pXSetErrorHandler & & x11 . pXGetErrorText )
2018-03-04 14:41:16 +00:00
x11 . pXSetErrorHandler ( X11_ErrorHandler ) ;
2014-03-30 00:39:37 +00:00
//raw input (yay mouse deltas)
x11 . pXGetEventData = Sys_GetAddressForName ( x11 . lib , " XGetEventData " ) ;
x11 . pXFreeEventData = Sys_GetAddressForName ( x11 . lib , " XFreeEventData " ) ;
//internationalisation
x11 . pXSetLocaleModifiers = Sys_GetAddressForName ( x11 . lib , " XSetLocaleModifiers " ) ;
x11 . pXSupportsLocale = Sys_GetAddressForName ( x11 . lib , " XSupportsLocale " ) ;
x11 . pXOpenIM = Sys_GetAddressForName ( x11 . lib , " XOpenIM " ) ;
2015-09-10 10:16:26 +00:00
x11 . pXGetIMValues = Sys_GetAddressForName ( x11 . lib , " XGetIMValues " ) ;
2014-03-30 00:39:37 +00:00
x11 . pXCreateIC = Sys_GetAddressForName ( x11 . lib , " XCreateIC " ) ;
x11 . pXSetICFocus = Sys_GetAddressForName ( x11 . lib , " XSetICFocus " ) ;
2017-01-15 13:13:09 +00:00
x11 . pXUnsetICFocus = Sys_GetAddressForName ( x11 . lib , " XUnsetICFocus " ) ;
2014-03-30 00:39:37 +00:00
x11 . pXGetICValues = Sys_GetAddressForName ( x11 . lib , " XGetICValues " ) ;
2018-11-27 16:48:19 +00:00
x11 . pXSetICValues = Sys_GetAddressForName ( x11 . lib , " XSetICValues " ) ;
2014-03-30 00:39:37 +00:00
x11 . pXFilterEvent = Sys_GetAddressForName ( x11 . lib , " XFilterEvent " ) ;
x11 . pXutf8LookupString = Sys_GetAddressForName ( x11 . lib , " Xutf8LookupString " ) ;
x11 . pXwcLookupString = Sys_GetAddressForName ( x11 . lib , " XwcLookupString " ) ;
x11 . pXDestroyIC = Sys_GetAddressForName ( x11 . lib , " XDestroyIC " ) ;
x11 . pXCloseIM = Sys_GetAddressForName ( x11 . lib , " XCloseIM " ) ;
2013-03-12 23:04:11 +00:00
}
2013-05-13 13:43:18 +00:00
else
{
Con_Printf ( " Unable to load libX11 \n " ) ;
}
2013-03-12 23:04:11 +00:00
}
return ! ! x11 . lib ;
}
2004-08-22 22:29:09 +00:00
2016-07-30 17:59:55 +00:00
# ifdef VK_USE_PLATFORM_XCB_KHR
static struct
{
void * lib ;
xcb_connection_t * ( * pXGetXCBConnection ) ( Display * dpy ) ;
} x11xcb ;
static qboolean x11xcb_initlib ( void )
{
static dllfunction_t x11xcb_functable [ ] =
{
{ ( void * * ) & x11xcb . pXGetXCBConnection , " XGetXCBConnection " } ,
{ NULL , NULL }
} ;
if ( ! x11xcb . lib )
{
x11xcb . lib = Sys_LoadLibrary ( " libX11-xcb.so.1 " , x11xcb_functable ) ;
if ( ! x11xcb . lib )
x11xcb . lib = Sys_LoadLibrary ( " libX11-xcb " , x11xcb_functable ) ;
if ( ! x11xcb . lib )
Con_Printf ( " Unable to load libX11-xcb \n " ) ;
}
return ! ! x11xcb . lib ;
}
# endif
2017-09-02 05:13:33 +00:00
# define FULLSCREEN_DESKTOP (1u<<0) //we didn't need to change video modes at all.
# define FULLSCREEN_VMODE (1u<<1) //using xf86 vidmode (we can actually change modes)
# define FULLSCREEN_VMODEACTIVE (1u<<2) //xf86 vidmode currently forced
# define FULLSCREEN_XRANDR (1u<<3) //using xf86 vidmode (we can actually change modes)
# define FULLSCREEN_XRANDRACTIVE (1u<<4) //xf86 vidmode currently forced
# define FULLSCREEN_LEGACY (1u<<5) //override redirect used (window is hidden from other programs, with a dummy window for alt+tab detection)
# define FULLSCREEN_WM (1u<<6) //fullscreen hint used (desktop environment is expected to 'do the right thing', but it won't change actual video modes)
# define FULLSCREEN_ACTIVE (1u<<7) //currently considered fullscreen
# define FULLSCREEN_ANYMODE (FULLSCREEN_DESKTOP|FULLSCREEN_VMODE|FULLSCREEN_XRANDR)
static unsigned int fullscreenflags ;
static int fullscreenx ;
static int fullscreeny ;
2013-03-12 22:47:42 +00:00
static int fullscreenwidth ;
static int fullscreenheight ;
void X_GoFullscreen ( void ) ;
void X_GoWindowed ( void ) ;
/*when alt-tabbing or whatever, the window manager creates a window, then destroys it again, resulting in weird focus events that trigger mode switches and grabs. using a timer reduces the weirdness and allows alt-tab to work properly. or at least better than it was working. that's the theory anyway*/
static unsigned int modeswitchtime ;
static int modeswitchpending ;
2017-09-02 05:13:33 +00:00
# ifdef USE_VMODE
2013-03-12 22:54:12 +00:00
typedef struct
{
unsigned int dotclock ;
unsigned short hdisplay ;
unsigned short hsyncstart ;
unsigned short hsyncend ;
unsigned short htotal ;
unsigned short hskew ;
unsigned short vdisplay ;
unsigned short vsyncstart ;
unsigned short vsyncend ;
unsigned short vtotal ;
unsigned int flags ;
} XF86VidModeModeInfo ; //we don't touch this struct
static struct
{
int opcode , event , error ;
int vmajor , vminor ;
void * lib ;
Bool ( * pXF86VidModeQueryVersion ) ( Display * dpy , int * majorVersion , int * minorVersion ) ;
Bool ( * pXF86VidModeGetGammaRampSize ) ( Display * dpy , int screen , int * size ) ;
Bool ( * pXF86VidModeGetGammaRamp ) ( Display * dpy , int screen , int size , unsigned short * red , unsigned short * green , unsigned short * blue ) ;
Bool ( * pXF86VidModeSetGammaRamp ) ( Display * dpy , int screen , int size , unsigned short * red , unsigned short * green , unsigned short * blue ) ;
Bool ( * pXF86VidModeSetViewPort ) ( Display * dpy , int screen , int x , int y ) ;
Bool ( * pXF86VidModeSwitchToMode ) ( Display * dpy , int screen , XF86VidModeModeInfo * modeline ) ;
Bool ( * pXF86VidModeGetAllModeLines ) ( Display * dpy , int screen , int * modecount , XF86VidModeModeInfo * * * modelinesPtr ) ;
XF86VidModeModeInfo * * modes ;
int num_modes ;
int usemode ;
2016-07-28 15:57:22 +00:00
unsigned short originalramps [ 3 ] [ 2048 ] ;
2013-03-12 22:54:12 +00:00
qboolean originalapplied ; //states that the origionalramps arrays are valid, and contain stuff that we should revert to on close
2016-07-28 15:57:22 +00:00
int originalrampsize ;
2013-03-12 22:54:12 +00:00
} vm ;
static qboolean VMODE_Init ( void )
{
2016-07-30 17:59:55 +00:00
static dllfunction_t vm_functable [ ] =
2013-03-12 22:54:12 +00:00
{
{ ( void * * ) & vm . pXF86VidModeQueryVersion , " XF86VidModeQueryVersion " } ,
{ ( void * * ) & vm . pXF86VidModeGetGammaRampSize , " XF86VidModeGetGammaRampSize " } ,
{ ( void * * ) & vm . pXF86VidModeGetGammaRamp , " XF86VidModeGetGammaRamp " } ,
{ ( void * * ) & vm . pXF86VidModeSetGammaRamp , " XF86VidModeSetGammaRamp " } ,
{ ( void * * ) & vm . pXF86VidModeSetViewPort , " XF86VidModeSetViewPort " } ,
{ ( void * * ) & vm . pXF86VidModeSwitchToMode , " XF86VidModeSwitchToMode " } ,
{ ( void * * ) & vm . pXF86VidModeGetAllModeLines , " XF86VidModeGetAllModeLines " } ,
{ NULL , NULL }
} ;
vm . vmajor = 0 ;
vm . vminor = 0 ;
vm . usemode = - 1 ;
vm . originalapplied = false ;
2017-09-02 05:13:33 +00:00
if ( ! X11_CheckFeature ( " vmode " , true ) )
2013-03-12 22:54:12 +00:00
return false ;
2013-03-12 23:04:11 +00:00
if ( ! x11 . pXQueryExtension ( vid_dpy , " XFree86-VidModeExtension " , & vm . opcode , & vm . event , & vm . error ) )
2013-03-12 22:54:12 +00:00
{
2014-03-30 00:39:37 +00:00
Con_Printf ( " VidModeExtension extension not available. \n " ) ;
2013-03-12 22:54:12 +00:00
return false ;
}
if ( ! vm . lib )
vm . lib = Sys_LoadLibrary ( " libXxf86vm " , vm_functable ) ;
if ( vm . lib )
{
2014-03-30 00:39:37 +00:00
if ( vm . pXF86VidModeQueryVersion ( vid_dpy , & vm . vmajor , & vm . vminor ) )
2018-03-24 04:02:09 +00:00
Con_DPrintf ( " Using XF86-VidModeExtension Ver. %d.%d \n " , vm . vmajor , vm . vminor ) ;
2013-03-12 22:54:12 +00:00
else
2014-03-30 00:39:37 +00:00
{
Con_Printf ( " No XF86-VidModeExtension support \n " ) ;
2013-03-12 22:54:12 +00:00
vm . vmajor = 0 ;
2014-03-30 00:39:37 +00:00
vm . vminor = 0 ;
}
2013-03-12 22:54:12 +00:00
}
return vm . vmajor ;
}
2017-09-02 05:13:33 +00:00
static void VMODE_SelectMode ( int * width , int * height , float rate )
{
if ( COM_CheckParm ( " -current " ) )
return ;
if ( vm . vmajor )
{
int best_fit , best_dist , dist , x , y , z , r , i ;
vm . pXF86VidModeGetAllModeLines ( vid_dpy , scrnum , & vm . num_modes , & vm . modes ) ;
best_dist = 9999999 ;
best_fit = - 1 ;
if ( ( ! * width | | * width = = DisplayWidth ( vid_dpy , scrnum ) ) & & ( ! * height | | * height = = DisplayHeight ( vid_dpy , scrnum ) ) & & ! rate )
{
2018-03-24 04:02:09 +00:00
Con_DPrintf ( " XF86VM: mode change not needed \n " ) ;
2017-09-02 05:13:33 +00:00
fullscreenflags | = FULLSCREEN_DESKTOP ;
return ;
}
for ( i = 0 ; i < vm . num_modes ; i + + )
{
//fixme: check this formula. should be the full refresh rate
r = vm . modes [ i ] - > dotclock * 1000 / ( vm . modes [ i ] - > htotal * vm . modes [ i ] - > vtotal ) ;
if ( * width > vm . modes [ i ] - > hdisplay | |
* height > vm . modes [ i ] - > vdisplay | |
rate > r )
continue ;
x = * width - vm . modes [ i ] - > hdisplay ;
y = * height - vm . modes [ i ] - > vdisplay ;
z = rate ? ( rate - r ) : 0 ;
dist = ( x * x ) + ( y * y ) + ( z * z ) ;
if ( dist < best_dist )
{
best_dist = dist ;
best_fit = i ;
}
}
if ( best_fit ! = - 1 )
{
// change to the mode
if ( vm . pXF86VidModeSwitchToMode ( vid_dpy , scrnum , vm . modes [ vm . usemode = best_fit ] ) )
{
* width = vm . modes [ best_fit ] - > hdisplay ;
* height = vm . modes [ best_fit ] - > vdisplay ;
// Move the viewport to top left
vm . pXF86VidModeSetViewPort ( vid_dpy , scrnum , 0 , 0 ) ;
x11 . pXSync ( vid_dpy , False ) ;
fullscreenflags | = FULLSCREEN_VMODE | FULLSCREEN_VMODEACTIVE ;
Con_Printf ( " XF86VM: changed mode \n " ) ;
}
else
Con_Printf ( " Failed to apply mode %i*%i \n " , vm . modes [ best_fit ] - > hdisplay , vm . modes [ best_fit ] - > vdisplay ) ;
}
}
}
# endif
# ifdef USE_XRANDR
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
# if 1
2017-09-02 05:13:33 +00:00
# include <X11/extensions/Xrandr.h>
# else
//stuff to avoid dependancies
typedef struct _XRRScreenConfiguration XRRScreenConfiguration ;
typedef unsigned short Rotation ;
typedef unsigned short SizeID ;
typedef unsigned short SubpixelOrder ;
typedef unsigned short Connection ;
# define RR_Connected 0
typedef XID RROutput ;
typedef XID RRCrtc ;
typedef XID RRMode ;
typedef unsigned long XRRModeFlags ;
typedef struct {
int width , height ;
int mwidth , mheight ;
} XRRScreenSize ;
typedef struct _XRROutputInfo {
Time timestamp ;
RRCrtc crtc ;
char * name ;
int nameLen ;
unsigned long mm_width ;
unsigned long mm_height ;
Connection connection ;
SubpixelOrder subpixel_order ;
int ncrtc ;
RRCrtc * crtcs ;
int nclone ;
RROutput * clones ;
int nmode ;
int npreferred ;
RRMode * modes ;
} XRROutputInfo ;
typedef struct _XRRModeInfo {
RRMode id ;
unsigned int width ;
unsigned int height ;
unsigned long dotClock ;
unsigned int hSyncStart ;
unsigned int hSyncEnd ;
unsigned int hTotal ;
unsigned int hSkew ;
unsigned int vSyncStart ;
unsigned int vSyncEnd ;
unsigned int vTotal ;
char * name ;
unsigned int nameLength ;
XRRModeFlags modeFlags ;
} XRRModeInfo ;
typedef struct _XRRScreenResources {
Time timestamp ;
Time configTimestamp ;
int ncrtc ;
RRCrtc * crtcs ;
int noutput ;
RROutput * outputs ;
int nmode ;
XRRModeInfo * modes ;
} XRRScreenResources ;
typedef struct _XRRCrtcInfo {
Time timestamp ;
int x , y ;
unsigned int width , height ;
RRMode mode ;
Rotation rotation ;
int noutput ;
RROutput * outputs ;
Rotation rotations ;
int npossible ;
RROutput * possible ;
} XRRCrtcInfo ;
typedef struct _XRRCrtcGamma {
int size ;
unsigned short * red ;
unsigned short * green ;
unsigned short * blue ;
} XRRCrtcGamma ;
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
typedef struct _XRRPanning {
Time timestamp ;
unsigned int left ;
unsigned int top ;
unsigned int width ;
unsigned int height ;
unsigned int track_left ;
unsigned int track_top ;
unsigned int track_width ;
unsigned int track_height ;
int border_left ;
int border_top ;
int border_right ;
int border_bottom ;
} XRRPanning ;
2017-09-02 05:13:33 +00:00
# endif
static struct
{
//caps
qboolean canmodechange11 ;
qboolean canmodechange12 ;
qboolean cangamma ;
// qboolean cangetmonitor;
//general stuff
void * lib ;
int opcode , event , error ;
int vmajor , vminor ;
Bool ( * pQueryExtension ) ( Display * dpy , int * event_base_return , int * error_base_return ) ;
Status ( * pQueryVersion ) ( Display * dpy , int * major_version_return , int * minor_version_return ) ;
//for v1.1
//this is only aware of a single screen, so that's a bit poo really.
//if we go fullscreen, we have no real way to restore multi-display things after
XRRScreenConfiguration * screenconfig ;
Time origtime ;
int origmode ;
Rotation origrot ;
int origrate ;
int targmode ;
int targrate ;
//stuff to query video modes
XRRScreenConfiguration * ( * pGetScreenInfo ) ( Display * dpy , Window window ) ;
XRRScreenSize * ( * pConfigSizes ) ( XRRScreenConfiguration * config , int * nsizes ) ;
short * ( * pConfigRates ) ( XRRScreenConfiguration * config , int sizeID , int * nrates ) ;
SizeID ( * pConfigCurrentConfiguration ) ( XRRScreenConfiguration * config , Rotation * rotation ) ;
short ( * pConfigCurrentRate ) ( XRRScreenConfiguration * config ) ;
//stuff to change modes
Time ( * pConfigTimes ) ( XRRScreenConfiguration * config , Time * config_timestamp ) ;
short ( * pSetScreenConfigAndRate ) ( Display * dpy , XRRScreenConfiguration * config , Drawable draw , int size_index , Rotation rotation , short rate , Time timestamp ) ;
//for v1.2
//we gain gamma and multiple outputs+crts+etc
XRRScreenResources * res ; //all the resources on the system (including modes etc)
XRROutputInfo * * outputs ; //list of info for all outputs
XRROutputInfo * output ; //the output device that we're using
2019-08-20 11:45:43 +00:00
RRCrtc crtc ; //the output device's screen that we're focusing on (modes and gamma)
XRRCrtcInfo * crtcinfo ; //the info to restore
2017-09-02 05:13:33 +00:00
XRRModeInfo * crtcmode ; //the mode we want to use
XRRCrtcGamma * origgamma ;
2019-08-20 11:45:43 +00:00
// Status (*pGetScreenSizeRange) (Display *dpy, Window window, int *minwidth, int *minheight, int *maxwidth, int *maxheight);
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
void ( * pSetScreenSize ) ( Display * dpy , Window window , int width , int height , int mmwidth , int mmheight ) ;
2017-09-02 05:13:33 +00:00
XRRScreenResources * ( * pGetScreenResources ) ( Display * dpy , Window window ) ;
2019-08-20 11:45:43 +00:00
void * ( * pFreeScreenResources ) ( XRRScreenResources * ) ;
XRROutputInfo * ( * pGetOutputInfo ) ( Display * dpy , XRRScreenResources * resources , RROutput output ) ;
void * ( * pFreeOutputInfo ) ( XRROutputInfo * outputinfo ) ;
XRRCrtcInfo * ( * pGetCrtcInfo ) ( Display * dpy , XRRScreenResources * resources , RRCrtc crtc ) ;
void * ( * pFreeCrtcInfo ) ( XRRCrtcInfo * crtcinfo ) ;
Status ( * pSetCrtcConfig ) ( Display * dpy , XRRScreenResources * resources , RRCrtc crtc , Time timestamp , int x , int y , RRMode mode , Rotation rotation , RROutput * output , int noutputs ) ;
XRRCrtcGamma * ( * pGetCrtcGamma ) ( Display * dpy , RRCrtc crtc ) ;
void ( * pFreeGamma ) ( XRRCrtcGamma * gamma ) ;
void ( * pSetCrtcGamma ) ( Display * dpy , RRCrtc crtc , XRRCrtcGamma * gamma ) ;
//v1.3 has non-0 primary monitors.
RROutput ( * pGetOutputPrimary ) ( Display * dpy , Window window ) ;
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
Status ( * pSetPanning ) ( Display * dpy , XRRScreenResources * resources , RRCrtc crtc , XRRPanning * panning ) ; //we need this just in case.
XRRPanning * ( * pGetPanning ) ( Display * dpy , XRRScreenResources * resources , RRCrtc crtc ) ;
void ( * pFreePanning ) ( XRRPanning * panning ) ;
int pan [ 4 ] ; //for restoring panning. pan region the screen may move to
int pantrack [ 4 ] ; //screen region where the mouse may be for the mouse to be tracked in
int panborder [ 4 ] ; //border region of crtc for panning to take place in. typically >=0...
int nvidiabug ; //nvidia completely ignores panning requests, which fucks over fullscreen gameplay. we have to work around it by shrinking the screen which doesn't work with multiple displays (and risks fucking over everything else)
int origscreenwidth , origscreenwidthmm ;
int origscreenheight , origscreenheightmm ;
2017-09-02 05:13:33 +00:00
} xrandr ;
static qboolean XRandR_Init ( void )
{
static dllfunction_t xrandr_functable [ ] =
{
2019-08-20 11:45:43 +00:00
{ ( void * * ) & xrandr . pQueryExtension , " XRRQueryExtension " } ,
{ ( void * * ) & xrandr . pQueryVersion , " XRRQueryVersion " } ,
2017-09-02 05:13:33 +00:00
//1.0
2019-08-20 11:45:43 +00:00
{ ( void * * ) & xrandr . pGetScreenInfo , " XRRGetScreenInfo " } ,
{ ( void * * ) & xrandr . pConfigTimes , " XRRConfigTimes " } ,
{ ( void * * ) & xrandr . pConfigSizes , " XRRConfigSizes " } ,
{ ( void * * ) & xrandr . pConfigRates , " XRRConfigRates " } ,
2017-09-02 05:13:33 +00:00
{ ( void * * ) & xrandr . pConfigCurrentConfiguration , " XRRConfigCurrentConfiguration " } ,
2019-08-20 11:45:43 +00:00
{ ( void * * ) & xrandr . pConfigCurrentRate , " XRRConfigCurrentRate " } ,
2017-09-02 05:13:33 +00:00
//1.1
2019-08-20 11:45:43 +00:00
{ ( void * * ) & xrandr . pSetScreenConfigAndRate , " XRRSetScreenConfigAndRate " } ,
2017-09-02 05:13:33 +00:00
{ NULL , NULL }
} ;
xrandr . vmajor = 0 ;
xrandr . vminor = 0 ;
xrandr . canmodechange11 = false ;
xrandr . canmodechange12 = false ;
// xrandr.cangamma = false;
xrandr . crtcinfo = NULL ;
xrandr . res = NULL ;
xrandr . outputs = NULL ;
//enable by default once this is properly tested, and supports hwgamma.
2019-02-16 19:09:07 +00:00
if ( ! X11_CheckFeature ( " xrandr " , true ) )
2017-09-02 05:13:33 +00:00
return false ;
2013-03-12 22:54:12 +00:00
2017-09-02 05:13:33 +00:00
if ( ! xrandr . lib )
xrandr . lib = Sys_LoadLibrary ( " libXrandr " , xrandr_functable ) ;
if ( xrandr . lib )
{
if ( xrandr . pQueryExtension ( vid_dpy , & xrandr . event , & xrandr . error ) )
{
xrandr . pQueryVersion ( vid_dpy , & xrandr . vmajor , & xrandr . vminor ) ;
if ( xrandr . vmajor > 1 | | ( xrandr . vmajor = = 1 & & xrandr . vminor > = 1 ) )
xrandr . canmodechange11 = true ;
if ( xrandr . vmajor > 1 | | ( xrandr . vmajor = = 1 & & xrandr . vminor > = 2 ) )
{ //1.2 functions
xrandr . pGetScreenResources = Sys_GetAddressForName ( xrandr . lib , " XRRGetScreenResources " ) ;
xrandr . pFreeScreenResources = Sys_GetAddressForName ( xrandr . lib , " XRRFreeScreenResources " ) ;
xrandr . pGetOutputInfo = Sys_GetAddressForName ( xrandr . lib , " XRRGetOutputInfo " ) ;
xrandr . pFreeOutputInfo = Sys_GetAddressForName ( xrandr . lib , " XRRFreeOutputInfo " ) ;
xrandr . pGetCrtcInfo = Sys_GetAddressForName ( xrandr . lib , " XRRGetCrtcInfo " ) ;
xrandr . pFreeCrtcInfo = Sys_GetAddressForName ( xrandr . lib , " XRRFreeCrtcInfo " ) ;
xrandr . pSetCrtcConfig = Sys_GetAddressForName ( xrandr . lib , " XRRSetCrtcConfig " ) ;
xrandr . pGetCrtcGamma = Sys_GetAddressForName ( xrandr . lib , " XRRGetCrtcGamma " ) ;
xrandr . pFreeGamma = Sys_GetAddressForName ( xrandr . lib , " XRRFreeGamma " ) ;
xrandr . pSetCrtcGamma = Sys_GetAddressForName ( xrandr . lib , " XRRSetCrtcGamma " ) ;
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
xrandr . pSetScreenSize = Sys_GetAddressForName ( xrandr . lib , " XRRSetScreenSize " ) ;
2017-09-02 05:13:33 +00:00
if ( xrandr . pGetScreenResources & & xrandr . pFreeScreenResources & & xrandr . pFreeOutputInfo
& & xrandr . pGetCrtcInfo & & xrandr . pFreeCrtcInfo & & xrandr . pSetCrtcConfig
& & xrandr . pGetCrtcGamma & & xrandr . pFreeGamma & & xrandr . pSetCrtcGamma
)
xrandr . canmodechange12 = true ;
}
2019-08-20 11:45:43 +00:00
if ( xrandr . vmajor > 1 | | ( xrandr . vmajor = = 1 & & xrandr . vminor > = 3 ) )
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
{
2019-08-20 11:45:43 +00:00
xrandr . pGetOutputPrimary = Sys_GetAddressForName ( xrandr . lib , " XRRGetOutputPrimary " ) ;
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
xrandr . pSetPanning = Sys_GetAddressForName ( xrandr . lib , " XRRSetPanning " ) ;
xrandr . pGetPanning = Sys_GetAddressForName ( xrandr . lib , " XRRGetPanning " ) ;
xrandr . pFreePanning = Sys_GetAddressForName ( xrandr . lib , " XRRFreePanning " ) ;
}
xrandr . nvidiabug = false ; //hopeful...
{
int op , firstev , firsterr ;
if ( x11 . pXQueryExtension ( vid_dpy , " NV-CONTROL " , & op , & firstev , & firsterr ) )
xrandr . nvidiabug = true ; //our dreams are so cruely shattered.
}
2018-10-13 12:19:58 +00:00
//FIXME: query monitor sizes and calculate dpi for vid.dpy_[x|y]
2017-09-02 05:13:33 +00:00
return true ;
}
}
else
Con_Printf ( " XRandR library not available. \n " ) ;
return false ;
}
static float XRandR_CalcRate ( XRRModeInfo * mode )
{
if ( ! mode - > hTotal | | ! mode - > vTotal )
return 0 ;
return mode - > dotClock / ( ( float ) mode - > hTotal * mode - > vTotal ) ;
}
static XRRModeInfo * XRandR_FindMode ( RRMode mode )
{ //just looks up the right mode info.
int i ;
for ( i = 0 ; i < xrandr . res - > nmode ; i + + )
{
if ( xrandr . res - > modes [ i ] . id = = mode )
return & xrandr . res - > modes [ i ] ;
}
return NULL ;
}
static XRRModeInfo * XRandR_FindBestMode ( int width , int height , int rate )
{
int best_dist , dist , x , y , z , r , i ;
XRRModeInfo * mode , * best_mode ;
best_dist = 9999999 ;
best_mode = NULL ;
for ( i = 0 ; i < xrandr . output - > nmode ; i + + )
{
mode = XRandR_FindMode ( xrandr . output - > modes [ i ] ) ;
if ( ! mode )
continue ;
r = XRandR_CalcRate ( mode ) ;
if ( width > mode - > width | |
height > mode - > height | |
rate > r )
continue ;
//FIXME: do rates differently - match width+height then come back for rate
x = width - mode - > width ;
y = height - mode - > height ;
z = rate - r ;
dist = ( x * x ) + ( y * y ) + ( z * z ) ;
if ( dist < best_dist )
{
best_dist = dist ;
best_mode = mode ;
}
}
return best_mode ;
}
static void XRandR_RevertMode ( void )
{
Time config_timestamp ;
if ( fullscreenflags & FULLSCREEN_XRANDRACTIVE )
{
XRRCrtcInfo * c = xrandr . crtcinfo ;
if ( c )
{
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
x11 . pXGrabServer ( vid_dpy ) ;
if ( xrandr . nvidiabug = = 1 )
2020-09-08 05:11:09 +00:00
{ //attempt to undo at least part of the damage we inflicted to work around nvidia's defects.
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
if ( Success = = xrandr . pSetCrtcConfig ( vid_dpy , xrandr . res , xrandr . crtc , CurrentTime , c - > x , c - > y , None , c - > rotation , NULL , 0 ) )
xrandr . pSetScreenSize ( vid_dpy , DefaultRootWindow ( vid_dpy ) , xrandr . origscreenwidth , xrandr . origscreenheight , xrandr . origscreenwidthmm , xrandr . origscreenheightmm ) ;
}
2017-09-02 05:13:33 +00:00
if ( Success = = xrandr . pSetCrtcConfig ( vid_dpy , xrandr . res , xrandr . crtc , CurrentTime , c - > x , c - > y , c - > mode , c - > rotation , c - > outputs , c - > noutput ) )
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
{
if ( xrandr . pSetPanning )
{ //and try to reset panning back to its original values.
XRRPanning panning ;
panning . timestamp = c - > timestamp ;
panning . left = xrandr . pan [ 0 ] ;
panning . top = xrandr . pan [ 1 ] ;
panning . width = xrandr . pan [ 2 ] ;
panning . height = xrandr . pan [ 3 ] ;
panning . track_left = xrandr . pantrack [ 0 ] ;
panning . track_top = xrandr . pantrack [ 1 ] ;
panning . track_width = xrandr . pantrack [ 2 ] ;
panning . track_height = xrandr . pantrack [ 3 ] ;
panning . border_left = xrandr . panborder [ 0 ] ;
panning . border_top = xrandr . panborder [ 1 ] ;
panning . border_right = xrandr . panborder [ 2 ] ;
panning . border_bottom = xrandr . panborder [ 3 ] ;
if ( Success ! = xrandr . pSetPanning ( vid_dpy , xrandr . res , xrandr . crtc , & panning ) )
Con_Printf ( " Revert panning configuration failed \n " ) ;
else
Con_DPrintf ( " Panning configuration succeeded \n " ) ;
}
2017-09-02 05:13:33 +00:00
Con_DPrintf ( " Reverted mode \n " ) ;
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
}
2017-09-02 05:13:33 +00:00
else
Con_Printf ( " Couldn't revert XRandR mode! \n " ) ;
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
x11 . pXUngrabServer ( vid_dpy ) ;
2017-09-02 05:13:33 +00:00
}
else
{
if ( ! xrandr . pSetScreenConfigAndRate ( vid_dpy , xrandr . screenconfig , DefaultRootWindow ( vid_dpy ) , xrandr . origmode , xrandr . origrot , xrandr . origrate , xrandr . origtime ) )
xrandr . origtime = xrandr . pConfigTimes ( xrandr . screenconfig , & config_timestamp ) ;
}
fullscreenflags & = ~ FULLSCREEN_XRANDRACTIVE ;
}
}
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
static qboolean XRandR_ApplyMode ( void )
2017-09-02 05:13:33 +00:00
{
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
qboolean ret = false ;
2017-09-02 05:13:33 +00:00
Time config_timestamp ;
if ( ! ( fullscreenflags & FULLSCREEN_XRANDRACTIVE ) )
{
XRRCrtcInfo * c = xrandr . crtcinfo ;
if ( c )
{
if ( xrandr . crtcmode )
{
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
x11 . pXGrabServer ( vid_dpy ) ;
if ( xrandr . nvidiabug = = 1 )
{
/* nvidia's drivers are a bit shite and behave differently from every other driver
unlike other drivers they force panning enabled ( and refuse to disable it ) , which then bugs out in SDL and Wine too .
( specifically , the panning width + height values are recalculated ( completely ignoring any passed args ) , but left + top are not , the tracking + border areas are preserved but affect nothing )
the workaround is to :
lock the server ( so other programs don ' t bug out too much ) ,
disable the screen ( for the next step to work ) ,
change the virtual size to one that won ' t cause a problem with panning ,
re - enable the screen with the desired video mode ,
and unlock the server again .
This will not help with multimonitor setups , xrandr video mode switches are disabled entirely there .
*/
int screen_width = c - > x + xrandr . crtcmode - > width ;
int screen_height = c - > y + xrandr . crtcmode - > height ;
if ( Success = = xrandr . pSetCrtcConfig ( vid_dpy , xrandr . res , xrandr . crtc , CurrentTime , c - > x , c - > y , None , c - > rotation , NULL , 0 ) )
xrandr . pSetScreenSize ( vid_dpy , DefaultRootWindow ( vid_dpy ) , screen_width , screen_height , ( screen_width * xrandr . origscreenwidthmm ) / xrandr . origscreenwidth , ( screen_height * xrandr . origscreenheightmm ) / xrandr . origscreenheight ) ;
}
2017-09-02 05:13:33 +00:00
if ( Success = = xrandr . pSetCrtcConfig ( vid_dpy , xrandr . res , xrandr . crtc , CurrentTime , c - > x , c - > y , xrandr . crtcmode - > id , c - > rotation , c - > outputs , c - > noutput ) )
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
{
if ( xrandr . pSetPanning )
{ //disable panning, in case panning was previously enabled via exterior means
XRRPanning panning ;
panning . timestamp = c - > timestamp ;
panning . left = c - > x ;
panning . top = c - > y ;
panning . width = panning . height = 0 ; //disables panning - "but RRSetScreenSize will silently enable panning if the screen size is increased. This does not happen if set to 0."
//set the tracking area inside of the border area, to make doubly sure
panning . track_left = c - > x + 1 ;
panning . track_top = c - > y + 1 ;
panning . track_width = xrandr . crtcmode - > width - 2 ;
panning . track_height = xrandr . crtcmode - > height - 2 ;
panning . border_left = panning . border_top = panning . border_right = panning . border_bottom = - 16384 ; //border area is the region of this screen in which panning might be triggered.
if ( Success ! = xrandr . pSetPanning ( vid_dpy , xrandr . res , xrandr . crtc , & panning ) )
Con_Printf ( " Panning configuration failed \n " ) ;
else
Con_DPrintf ( " Panning configuration succeeded \n " ) ;
}
2017-09-02 05:13:33 +00:00
Con_DPrintf ( " Applied mode \n " ) ;
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
ret = true ;
}
2017-09-02 05:13:33 +00:00
else
Con_Printf ( " Couldn't apply mode \n " ) ;
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
x11 . pXUngrabServer ( vid_dpy ) ;
2017-09-02 05:13:33 +00:00
}
}
else
{
if ( ! xrandr . pSetScreenConfigAndRate ( vid_dpy , xrandr . screenconfig , DefaultRootWindow ( vid_dpy ) , xrandr . targmode , xrandr . origrot , xrandr . targrate , xrandr . origtime ) )
xrandr . origtime = xrandr . pConfigTimes ( xrandr . screenconfig , & config_timestamp ) ;
}
fullscreenflags | = FULLSCREEN_XRANDRACTIVE ;
}
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
return ret ;
2017-09-02 05:13:33 +00:00
}
static void XRandR_Shutdown ( void )
{
int i ;
if ( xrandr . origgamma )
{
xrandr . pSetCrtcGamma ( vid_dpy , xrandr . crtc , xrandr . origgamma ) ;
xrandr . pFreeGamma ( xrandr . origgamma ) ;
xrandr . origgamma = NULL ;
}
if ( vid_dpy )
XRandR_RevertMode ( ) ;
if ( xrandr . outputs )
{
for ( i = 0 ; i < xrandr . res - > noutput ; i + + )
xrandr . pFreeOutputInfo ( xrandr . outputs [ i ] ) ;
Z_Free ( xrandr . outputs ) ;
xrandr . outputs = NULL ;
}
if ( xrandr . crtcinfo )
{
xrandr . pFreeCrtcInfo ( xrandr . crtcinfo ) ;
xrandr . crtcinfo = NULL ;
}
if ( xrandr . res )
{
xrandr . pFreeScreenResources ( xrandr . res ) ;
xrandr . res = NULL ;
}
}
static qboolean XRandR_FindOutput ( const char * name )
{
2019-08-20 11:45:43 +00:00
RROutput p ;
2017-09-02 05:13:33 +00:00
int i ;
2019-03-01 22:39:30 +00:00
if ( ! xrandr . canmodechange12 )
return false ;
if ( ! xrandr . res )
xrandr . res = xrandr . pGetScreenResources ( vid_dpy , DefaultRootWindow ( vid_dpy ) ) ;
if ( ! xrandr . res )
return false ;
2017-09-02 05:13:33 +00:00
if ( ! xrandr . outputs )
{
xrandr . outputs = Z_Malloc ( sizeof ( * xrandr . outputs ) * xrandr . res - > noutput ) ;
for ( i = 0 ; i < xrandr . res - > noutput ; i + + )
xrandr . outputs [ i ] = xrandr . pGetOutputInfo ( vid_dpy , xrandr . res , xrandr . res - > outputs [ i ] ) ;
}
2019-08-20 11:45:43 +00:00
if ( xrandr . pGetOutputPrimary )
p = xrandr . pGetOutputPrimary ( vid_dpy , DefaultRootWindow ( vid_dpy ) ) ;
else if ( xrandr . res - > noutput )
p = xrandr . res - > outputs [ 0 ] ;
else
p = 0 ;
2017-09-02 05:13:33 +00:00
xrandr . output = NULL ;
xrandr . crtc = None ;
2019-03-01 22:39:30 +00:00
if ( xrandr . origgamma )
{
xrandr . pSetCrtcGamma ( vid_dpy , xrandr . crtc , xrandr . origgamma ) ;
xrandr . pFreeGamma ( xrandr . origgamma ) ;
xrandr . origgamma = NULL ;
}
2017-09-02 05:13:33 +00:00
if ( xrandr . crtcinfo )
xrandr . pFreeCrtcInfo ( xrandr . crtcinfo ) ;
xrandr . crtcinfo = NULL ;
for ( i = 0 ; i < xrandr . res - > noutput ; i + + )
{
2019-02-16 19:09:07 +00:00
if ( xrandr . outputs [ i ] - > connection ! = RR_Connected | | ! xrandr . outputs [ i ] - > ncrtc )
continue ; //not usable...
2019-08-20 11:45:43 +00:00
if ( ! xrandr . output & & xrandr . res - > outputs [ i ] = = p )
xrandr . output = xrandr . outputs [ i ] ;
2019-02-16 19:09:07 +00:00
if ( * name & & ! strncmp ( xrandr . outputs [ i ] - > name , name , xrandr . outputs [ i ] - > nameLen ) )
{ //this is the one they asked for
xrandr . output = xrandr . outputs [ i ] ;
break ;
2017-09-02 05:13:33 +00:00
}
}
if ( xrandr . output )
{
2019-08-20 11:45:43 +00:00
xrandr . crtc = xrandr . output - > crtc ;
2017-09-02 05:13:33 +00:00
xrandr . crtcinfo = xrandr . pGetCrtcInfo ( vid_dpy , xrandr . res , xrandr . crtc ) ;
if ( xrandr . crtcinfo )
{
xrandr . origgamma = xrandr . pGetCrtcGamma ( vid_dpy , xrandr . crtc ) ;
return true ;
}
}
return false ;
}
//called if we're not using randr to change video modes.
//(sets up crtc data
static qboolean XRandr_PickScreen ( const char * devicename , int * x , int * y , int * width , int * height )
{
2019-03-01 22:39:30 +00:00
if ( xrandr . crtcinfo | | XRandR_FindOutput ( devicename ) )
2017-09-02 05:13:33 +00:00
{
2019-03-01 22:39:30 +00:00
XRRCrtcInfo * c = xrandr . crtcinfo ;
* x = c - > x ;
* y = c - > y ;
* width = c - > width ;
* height = c - > height ;
2019-08-20 11:45:43 +00:00
Con_Printf ( " Found monitor %s %ix%i %i,%i \n " , xrandr . output - > name , c - > width , c - > height , c - > x , c - > y ) ;
2019-03-01 22:39:30 +00:00
return true ;
2017-09-02 05:13:33 +00:00
}
return false ;
}
//called when first changing video mode
static void XRandR_SelectMode ( const char * devicename , int * x , int * y , int * width , int * height , int rate )
{
if ( COM_CheckParm ( " -current " ) )
return ;
2019-05-10 09:31:21 +00:00
if ( xrandr . crtcinfo )
2017-09-02 05:13:33 +00:00
{
XRRCrtcInfo * c ;
2019-03-01 22:39:30 +00:00
xrandr . crtcmode = XRandR_FindBestMode ( * width , * height , rate ) ;
c = xrandr . crtcinfo ;
2021-08-04 21:17:04 +00:00
if ( ! * width | | ! * height | | ( xrandr . crtcmode & & c - > mode = = xrandr . crtcmode - > id ) )
2017-09-02 05:13:33 +00:00
{
2019-03-01 22:39:30 +00:00
fullscreenflags | = FULLSCREEN_DESKTOP ;
Con_Printf ( " XRRSetCrtcConfig not needed \n " ) ;
}
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
else if ( ! xrandr . crtcmode )
Con_Printf ( " XRRSetCrtcConfig failed \n " ) ;
else
2019-03-01 22:39:30 +00:00
{
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
xrandr . origscreenwidth = DisplayWidth ( vid_dpy , scrnum ) ;
xrandr . origscreenheight = DisplayHeight ( vid_dpy , scrnum ) ;
xrandr . origscreenwidthmm = DisplayWidthMM ( vid_dpy , scrnum ) ;
xrandr . origscreenheightmm = DisplayHeightMM ( vid_dpy , scrnum ) ;
if ( xrandr . pGetPanning )
{
XRRPanning * panning = xrandr . pGetPanning ( vid_dpy , xrandr . res , xrandr . crtc ) ;
if ( panning )
{
xrandr . pan [ 0 ] = panning - > left ? panning - > left : c - > x ; //apparently some drivers can be buggy and forget left+top when panning was previously disabled, snappnig them to the wrong place when re-enabled.
xrandr . pan [ 1 ] = panning - > top ? panning - > top : c - > y ;
xrandr . pan [ 2 ] = panning - > width ;
xrandr . pan [ 3 ] = panning - > height ;
xrandr . pantrack [ 0 ] = panning - > track_left ;
xrandr . pantrack [ 1 ] = panning - > track_top ;
xrandr . pantrack [ 2 ] = panning - > track_width ;
xrandr . pantrack [ 3 ] = panning - > track_height ;
xrandr . panborder [ 0 ] = panning - > border_left ;
xrandr . panborder [ 1 ] = panning - > border_top ;
xrandr . panborder [ 2 ] = panning - > border_right ;
xrandr . panborder [ 3 ] = panning - > border_bottom ;
xrandr . pFreePanning ( panning ) ;
}
}
if ( xrandr . nvidiabug & & ( c - > x ! = 0 | | c - > y ! = 0 | | c - > noutput > 1 ) )
{
2020-09-08 05:11:09 +00:00
Con_Printf ( " Nvidia and multimonitor detected. XRandR cannot be used safely in this situation. \n " ) ;
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
xrandr . crtcmode = NULL ;
}
else
{
if ( xrandr . nvidiabug )
2020-09-08 05:11:09 +00:00
Con_Printf ( CON_ERROR " Attempting NVIDIA panning workaround. Try 'xrandr --output foo --auto' to fix if this breaks things. \n " ) ;
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
fullscreenflags | = FULLSCREEN_XRANDR ;
if ( XRandR_ApplyMode ( ) )
{ //worked
* x = c - > x ;
* y = c - > y ;
* width = xrandr . crtcmode - > width ;
* height = xrandr . crtcmode - > height ;
}
else
fullscreenflags & = ~ FULLSCREEN_XRANDR ;
}
2017-09-02 05:13:33 +00:00
}
}
else if ( xrandr . canmodechange11 )
{
int best_fit , best_dist , best_rate , dist , x , y ;
int i , nummodes ;
XRRScreenSize * modes ;
Time config_timestamp ;
Drawable draw = DefaultRootWindow ( vid_dpy ) ;
xrandr . screenconfig = xrandr . pGetScreenInfo ( vid_dpy , DefaultRootWindow ( vid_dpy ) ) ;
xrandr . origtime = xrandr . pConfigTimes ( xrandr . screenconfig , & config_timestamp ) ;
xrandr . origmode = xrandr . pConfigCurrentConfiguration ( xrandr . screenconfig , & xrandr . origrot ) ;
xrandr . origrate = xrandr . pConfigCurrentRate ( xrandr . screenconfig ) ;
modes = xrandr . pConfigSizes ( xrandr . screenconfig , & nummodes ) ;
best_dist = 9999999 ;
best_fit = - 1 ;
best_rate = - 1 ;
for ( i = 0 ; i < nummodes ; i + + )
{
//fixme: check this formula. should be the full refresh rate
if ( * width > modes [ i ] . width | | * height > modes [ i ] . height )
continue ;
x = * width - modes [ i ] . width ;
y = * height - modes [ i ] . height ;
dist = ( x * x ) + ( y * y ) ;
if ( dist < best_dist )
{
best_dist = dist ;
best_fit = i ;
}
}
if ( best_fit ! = - 1 )
{
//okay, there's a usable mode, and now we need to figure out what rate to use...
//pick the higest rate under the target rate
short * rates = xrandr . pConfigRates ( xrandr . screenconfig , best_fit , & nummodes ) ;
for ( i = 0 ; i < nummodes ; i + + )
{
if ( rate > 0 & & rates [ i ] > rate )
continue ;
if ( best_rate < rates [ i ] )
best_rate = rates [ i ] ;
}
//change to the mode
Con_DPrintf ( " Setting XRandR Mode %i: %i*%i@%i \n " , best_fit , modes [ best_fit ] . width , modes [ best_fit ] . height , best_rate ) ;
if ( ! xrandr . pSetScreenConfigAndRate ( vid_dpy , xrandr . screenconfig , draw , best_fit , xrandr . origrot , best_rate , xrandr . origtime ) )
{
xrandr . targmode = best_fit ;
xrandr . targrate = best_rate ;
* width = modes [ best_fit ] . width ;
* height = modes [ best_fit ] . height ;
x11 . pXSync ( vid_dpy , False ) ;
fullscreenflags | = FULLSCREEN_XRANDR | FULLSCREEN_XRANDRACTIVE ;
}
else
Con_Printf ( " Failed to apply mode %i*%i@%i \n " , modes [ best_fit ] . width , modes [ best_fit ] . height , best_rate ) ;
}
}
}
# endif
2013-03-12 22:54:12 +00:00
2017-10-25 08:10:35 +00:00
static float mouse_grabbed = 0 ;
2013-03-12 22:54:12 +00:00
static enum
{
XIM_ORIG ,
XIM_DGA ,
XIM_XI2 ,
} x11_input_method ;
2017-10-25 08:10:35 +00:00
int x11_mouseqdev = 0 ;
2013-03-12 22:54:12 +00:00
# define XF86DGADirectMouse 0x0004
static struct
{
int opcode , event , error ;
void * lib ;
Status ( * pXF86DGADirectVideo ) ( Display * dpy , int screen , int enable ) ;
} dgam ;
static qboolean DGAM_Init ( void )
{
2016-07-30 17:59:55 +00:00
static dllfunction_t dgam_functable [ ] =
2013-03-12 22:54:12 +00:00
{
{ ( void * * ) & dgam . pXF86DGADirectVideo , " XF86DGADirectVideo " } ,
{ NULL , NULL }
} ;
2013-03-12 23:04:11 +00:00
if ( ! x11 . pXQueryExtension ( vid_dpy , " XFree86-DGA " , & dgam . opcode , & dgam . event , & dgam . error ) )
2013-03-12 22:54:12 +00:00
{
Con_Printf ( " DGA extension not available. \n " ) ;
return false ;
}
if ( ! dgam . lib )
dgam . lib = Sys_LoadLibrary ( " libXxf86dga " , dgam_functable ) ;
return ! ! dgam . lib ;
}
2013-03-12 22:58:55 +00:00
#if 0
2013-03-12 22:54:12 +00:00
# include <X11/extensions/XInput2.h>
2013-03-12 22:58:55 +00:00
# else
# define XISetMask(ptr, event) (((unsigned char*)(ptr))[(event)>>3] |= (1 << ((event) & 7)))
# define XIMaskIsSet(ptr, event) (((unsigned char*)(ptr))[(event)>>3] & (1 << ((event) & 7)))
# define XIMaskLen(event) (((event + 7) >> 3))
typedef struct {
2014-03-30 08:55:06 +00:00
int mask_len ;
unsigned char * mask ;
double * values ;
2013-03-12 22:58:55 +00:00
} XIValuatorState ;
typedef struct
{
2014-03-30 08:55:06 +00:00
int deviceid ;
int mask_len ;
unsigned char * mask ;
2013-03-12 22:58:55 +00:00
} XIEventMask ;
2017-10-25 08:10:35 +00:00
# define XIMasterPointer 1
# define XIMasterKeyboard 2
# define XISlavePointer 3
# define XISlaveKeyboard 4
# define XIAllDevices 0
# define XIAllMasterDevices 1
# define XI_RawButtonPress 15
# define XI_RawButtonRelease 16
# define XI_RawMotion 17
2013-03-12 22:58:55 +00:00
# define XI_LASTEVENT XI_RawMotion
typedef struct {
2014-03-30 08:55:06 +00:00
int type ; /* GenericEvent */
unsigned long serial ; /* # of last request processed by server */
Bool send_event ; /* true if this came from a SendEvent request */
Display * display ; /* Display the event was read from */
int extension ; /* XI extension offset */
int evtype ; /* XI_RawKeyPress, XI_RawKeyRelease, etc. */
Time time ;
int deviceid ;
int sourceid ; /* Bug: Always 0. https://bugs.freedesktop.org//show_bug.cgi?id=34240 */
int detail ;
int flags ;
XIValuatorState valuators ;
double * raw_values ;
2013-03-12 22:58:55 +00:00
} XIRawEvent ;
2017-10-25 08:10:35 +00:00
typedef struct
{
int type ;
int sourceid ;
} XIAnyClassInfo ;
typedef struct
{
int deviceid ;
char * name ;
int use ;
int attachment ;
Bool enabled ;
int num_classes ;
XIAnyClassInfo * * classes ;
} XIDeviceInfo ;
# define XIValuatorClass 2
typedef struct
{
int type ;
int sourceid ;
int number ;
Atom label ;
double min ;
double max ;
double value ;
int resolution ;
int mode ;
} XIValuatorClassInfo ;
# define XIModeAbsolute 1
2013-03-12 22:58:55 +00:00
# endif
2013-03-12 22:54:12 +00:00
static struct
{
int opcode , event , error ;
int vmajor , vminor ;
void * libxi ;
2017-10-25 08:10:35 +00:00
int devicegroup ;
size_t ndeviceinfos ;
struct xidevinfo
{
int qdev ;
struct
{
qboolean abs ;
double min , max ;
float old ;
2018-03-07 20:31:09 +00:00
} axis [ 2 ] ; //the meaning of any other axis is unknown. beware that they DO happen.
2017-10-25 08:10:35 +00:00
qboolean abs ;
} * deviceinfo ;
int nextqdev ;
2013-03-12 22:54:12 +00:00
Status ( * pXIQueryVersion ) ( Display * display , int * major_version_inout , int * minor_version_inout ) ;
int ( * pXISelectEvents ) ( Display * dpy , Window win , XIEventMask * masks , int num_masks ) ;
2017-10-25 08:10:35 +00:00
XIDeviceInfo * ( * pXIQueryDevice ) ( Display * dpy , int deviceid , int * ndevices_return ) ;
void ( * pXIFreeDeviceInfo ) ( XIDeviceInfo * info ) ;
2013-03-12 22:54:12 +00:00
} xi2 ;
2017-10-25 08:10:35 +00:00
static struct xidevinfo * XI2_GetDeviceInfo ( int devid )
{
if ( devid > = xi2 . ndeviceinfos )
{
struct xidevinfo * n = Z_Malloc ( ( devid + 1 ) * sizeof ( * xi2 . deviceinfo ) ) ;
memcpy ( n , xi2 . deviceinfo , xi2 . ndeviceinfos * sizeof ( * xi2 . deviceinfo ) ) ;
Z_Free ( xi2 . deviceinfo ) ;
xi2 . deviceinfo = n ;
while ( xi2 . ndeviceinfos < = devid )
{
xi2 . deviceinfo [ xi2 . ndeviceinfos ] . qdev = DEVID_UNSET ;
if ( devid > = 2 )
{
int devs ;
XIDeviceInfo * dev = xi2 . pXIQueryDevice ( vid_dpy , xi2 . ndeviceinfos , & devs ) ;
2019-03-01 22:39:30 +00:00
if ( dev )
2017-10-25 08:10:35 +00:00
{
2019-03-01 22:39:30 +00:00
if ( devs = = 1 )
2017-10-25 08:10:35 +00:00
{
2019-03-01 22:39:30 +00:00
int j ;
for ( j = 0 ; j < dev - > num_classes ; j + + )
2017-10-25 08:10:35 +00:00
{
2019-03-01 22:39:30 +00:00
if ( dev - > classes [ j ] - > sourceid = = xi2 . ndeviceinfos & & dev - > classes [ j ] - > type = = XIValuatorClass )
2017-10-25 08:10:35 +00:00
{
2019-03-01 22:39:30 +00:00
XIValuatorClassInfo * v = ( XIValuatorClassInfo * ) dev - > classes [ j ] ;
if ( v - > mode = = XIModeAbsolute & & v - > number > = 0 & & v - > number < countof ( xi2 . deviceinfo [ xi2 . ndeviceinfos ] . axis ) )
{
xi2 . deviceinfo [ xi2 . ndeviceinfos ] . abs = xi2 . deviceinfo [ xi2 . ndeviceinfos ] . axis [ v - > number ] . abs = true ;
xi2 . deviceinfo [ xi2 . ndeviceinfos ] . axis [ v - > number ] . min = v - > min ;
xi2 . deviceinfo [ xi2 . ndeviceinfos ] . axis [ v - > number ] . max = v - > max ;
}
2017-10-25 08:10:35 +00:00
}
}
2019-03-01 22:39:30 +00:00
}
xi2 . pXIFreeDeviceInfo ( dev ) ;
2017-10-25 08:10:35 +00:00
}
}
xi2 . ndeviceinfos + + ;
}
}
return & xi2 . deviceinfo [ devid ] ;
}
2013-03-12 22:54:12 +00:00
static qboolean XI2_Init ( void )
{
2016-07-30 17:59:55 +00:00
static dllfunction_t xi2_functable [ ] =
2013-03-12 22:54:12 +00:00
{
{ ( void * * ) & xi2 . pXIQueryVersion , " XIQueryVersion " } ,
{ ( void * * ) & xi2 . pXISelectEvents , " XISelectEvents " } ,
2017-10-25 08:10:35 +00:00
{ ( void * * ) & xi2 . pXIQueryDevice , " XIQueryDevice " } ,
{ ( void * * ) & xi2 . pXIFreeDeviceInfo , " XIFreeDeviceInfo " } ,
2013-03-12 22:54:12 +00:00
{ NULL , NULL }
} ;
XIEventMask evm ;
unsigned char maskbuf [ XIMaskLen ( XI_LASTEVENT ) ] ;
2013-03-12 23:04:11 +00:00
if ( ! x11 . pXQueryExtension ( vid_dpy , " XInputExtension " , & xi2 . opcode , & xi2 . event , & xi2 . error ) )
2013-03-12 22:54:12 +00:00
{
Con_Printf ( " XInput extension not available. \n " ) ;
return false ;
}
if ( ! xi2 . libxi )
{
2014-03-30 00:39:37 +00:00
# ifdef __CYGWIN__
if ( ! xi2 . libxi )
xi2 . libxi = Sys_LoadLibrary ( " cygXi-6.dll " , xi2_functable ) ;
# endif
if ( ! xi2 . libxi )
xi2 . libxi = Sys_LoadLibrary ( " libXi.so.6 " , xi2_functable ) ;
2013-05-13 13:43:18 +00:00
if ( ! xi2 . libxi )
xi2 . libxi = Sys_LoadLibrary ( " libXi " , xi2_functable ) ;
2013-03-12 22:54:12 +00:00
if ( ! xi2 . libxi )
2013-03-12 22:58:55 +00:00
Con_Printf ( " XInput library not available or too old. \n " ) ;
2013-03-12 22:54:12 +00:00
}
if ( xi2 . libxi )
{
2017-10-25 08:10:35 +00:00
// xi2.nextqdev = 0; //start with 0, for player0
// xi2.nqdevices = 0;
2013-03-12 22:54:12 +00:00
xi2 . vmajor = 2 ;
xi2 . vminor = 0 ;
2017-10-25 08:10:35 +00:00
// xi2.devicegroup = XIAllMasterDevices;
xi2 . devicegroup = XIAllDevices ;
2013-03-12 22:54:12 +00:00
if ( xi2 . pXIQueryVersion ( vid_dpy , & xi2 . vmajor , & xi2 . vminor ) )
{
Con_Printf ( " XInput library or server is too old \n " ) ;
return false ;
}
2017-10-25 08:10:35 +00:00
evm . deviceid = xi2 . devicegroup ;
2013-03-12 22:54:12 +00:00
evm . mask_len = sizeof ( maskbuf ) ;
evm . mask = maskbuf ;
memset ( maskbuf , 0 , sizeof ( maskbuf ) ) ;
XISetMask ( maskbuf , XI_RawMotion ) ;
XISetMask ( maskbuf , XI_RawButtonPress ) ;
XISetMask ( maskbuf , XI_RawButtonRelease ) ;
/* if (xi2.vmajor >= 2 && xi2.vminor >= 2)
{
2014-03-30 08:55:06 +00:00
XISetMask ( maskbuf , XI_RawTouchBegin ) ;
XISetMask ( maskbuf , XI_RawTouchUpdate ) ;
XISetMask ( maskbuf , XI_RawTouchEnd ) ;
2013-03-12 22:54:12 +00:00
}
*/ xi2 . pXISelectEvents ( vid_dpy , DefaultRootWindow ( vid_dpy ) , & evm , 1 ) ;
return true ;
}
return false ;
}
2004-08-22 22:29:09 +00:00
/*-----------------------------------------------------------------------*/
2013-03-12 22:47:42 +00:00
//qboolean is8bit = false;
//qboolean isPermedia = false;
2015-05-16 08:02:05 +00:00
extern qboolean sys_gracefulexit ;
2013-03-12 22:47:42 +00:00
2018-10-14 16:16:34 +00:00
char * clipboard_buffer [ 2 ] ;
2004-08-22 22:29:09 +00:00
/*-----------------------------------------------------------------------*/
2016-07-12 00:40:13 +00:00
# ifdef GLQUAKE
2018-03-04 14:41:16 +00:00
static struct
{
dllhandle_t * gllibrary ;
const char * glxextensions ;
2004-08-22 22:29:09 +00:00
2018-03-04 14:41:16 +00:00
XVisualInfo * ( * ChooseVisual ) ( Display * dpy , int screen , int * attribList ) ;
void ( * SwapBuffers ) ( Display * dpy , GLXDrawable drawable ) ;
Bool ( * MakeCurrent ) ( Display * dpy , GLXDrawable drawable , GLXContext ctx ) ;
GLXContext ( * CreateContext ) ( Display * dpy , XVisualInfo * vis , GLXContext shareList , Bool direct ) ;
void ( * DestroyContext ) ( Display * dpy , GLXContext ctx ) ;
const char * ( * QueryExtensionsString ) ( Display * dpy , int screen ) ;
void * ( * GetProcAddress ) ( char * name ) ;
2019-01-13 16:51:50 +00:00
void ( * SwapIntervalSGI ) ( int interval ) ; //FFS!
void ( * SwapIntervalMESA ) ( unsigned int interval ) ; //FFS!
void ( * SwapIntervalEXT ) ( Display * dpy , GLXDrawable drawable , int interval ) ;
qboolean swaptear ;
2018-03-04 14:41:16 +00:00
GLXFBConfig * ( * ChooseFBConfig ) ( Display * dpy , int screen , const int * attrib_list , int * nelements ) ;
int ( * GetFBConfigAttrib ) ( Display * dpy , GLXFBConfig config , int attribute , int * value ) ;
XVisualInfo * ( * GetVisualFromFBConfig ) ( Display * dpy , GLXFBConfig config ) ;
GLXContext ( * CreateContextAttribs ) ( Display * dpy , GLXFBConfig config , GLXContext share_context , Bool direct , const int * attrib_list ) ;
2018-03-24 04:02:09 +00:00
int swapint ;
2018-03-04 14:41:16 +00:00
} glx ;
2004-08-22 22:29:09 +00:00
2018-10-11 10:31:23 +00:00
/*Note: closing the GLX library is unsafe as nvidia's drivers like to crash once its reloaded.
static void GLX_CloseLibrary ( void )
2004-08-22 22:29:09 +00:00
{
2018-03-04 14:41:16 +00:00
Sys_CloseLibrary ( glx . gllibrary ) ;
glx . gllibrary = NULL ;
}
2018-10-11 10:31:23 +00:00
*/
2018-03-04 14:41:16 +00:00
2018-12-28 00:04:36 +00:00
#if 0 //def _DEBUG
//this is a list of the functions that exist in opengles2, as well as wglCreateContextAttribsARB.
//functions not in this list *should* be stubs that just return errors, but we can't always depend on drivers for that... they shouldn't get called.
//this list is just to make it easier to test+debug android gles2 stuff using windows.
static char * gles2funcs [ ] =
{
# define f(n) #n,
f ( glActiveTexture )
f ( glAttachShader )
f ( glBindAttribLocation )
f ( glBindBuffer )
f ( glBindFramebuffer )
f ( glBindRenderbuffer )
f ( glBindTexture )
f ( glBlendColor )
f ( glBlendEquation )
f ( glBlendEquationSeparate )
f ( glBlendFunc )
f ( glBlendFuncSeparate )
f ( glBufferData )
f ( glBufferSubData )
f ( glCheckFramebufferStatus )
f ( glClear )
f ( glClearColor )
f ( glClearDepthf )
f ( glClearStencil )
f ( glColorMask )
f ( glCompileShader )
f ( glCompressedTexImage2D )
f ( glCompressedTexSubImage2D )
f ( glCopyTexImage2D )
f ( glCopyTexSubImage2D )
f ( glCreateProgram )
f ( glCreateShader )
f ( glCullFace )
f ( glDeleteBuffers )
f ( glDeleteFramebuffers )
f ( glDeleteProgram )
f ( glDeleteRenderbuffers )
f ( glDeleteShader )
f ( glDeleteTextures )
f ( glDepthFunc )
f ( glDepthMask )
f ( glDepthRangef )
f ( glDetachShader )
f ( glDisable )
f ( glDisableVertexAttribArray )
f ( glDrawArrays )
f ( glDrawElements )
f ( glEnable )
f ( glEnableVertexAttribArray )
f ( glFinish )
f ( glFlush )
f ( glFramebufferRenderbuffer )
f ( glFramebufferTexture2D )
f ( glFrontFace )
f ( glGenBuffers )
f ( glGenerateMipmap )
f ( glGenFramebuffers )
f ( glGenRenderbuffers )
f ( glGenTextures )
f ( glGetActiveAttrib )
f ( glGetActiveUniform )
f ( glGetAttachedShaders )
f ( glGetAttribLocation )
f ( glGetBooleanv )
f ( glGetBufferParameteriv )
f ( glGetError )
f ( glGetFloatv )
f ( glGetFramebufferAttachmentParameteriv )
f ( glGetIntegerv )
f ( glGetProgramiv )
f ( glGetProgramInfoLog )
f ( glGetRenderbufferParameteriv )
f ( glGetShaderiv )
f ( glGetShaderInfoLog )
f ( glGetShaderPrecisionFormat )
f ( glGetShaderSource )
f ( glGetString )
f ( glGetTexParameterfv )
f ( glGetTexParameteriv )
f ( glGetUniformfv )
f ( glGetUniformiv )
f ( glGetUniformLocation )
f ( glGetVertexAttribfv )
f ( glGetVertexAttribiv )
f ( glGetVertexAttribPointerv )
f ( glHint )
f ( glIsBuffer )
f ( glIsEnabled )
f ( glIsFramebuffer )
f ( glIsProgram )
f ( glIsRenderbuffer )
f ( glIsShader )
f ( glIsTexture )
f ( glLineWidth )
f ( glLinkProgram )
f ( glPixelStorei )
f ( glPolygonOffset )
f ( glReadPixels )
f ( glReleaseShaderCompiler )
f ( glRenderbufferStorage )
f ( glSampleCoverage )
f ( glScissor )
f ( glShaderBinary )
f ( glShaderSource )
f ( glStencilFunc )
f ( glStencilFuncSeparate )
f ( glStencilMask )
f ( glStencilMaskSeparate )
f ( glStencilOp )
f ( glStencilOpSeparate )
f ( glTexImage2D )
f ( glTexParameterf )
f ( glTexParameterfv )
f ( glTexParameteri )
f ( glTexParameteriv )
f ( glTexSubImage2D )
f ( glUniform1f )
f ( glUniform1fv )
f ( glUniform1i )
f ( glUniform1iv )
f ( glUniform2f )
f ( glUniform2fv )
f ( glUniform2i )
f ( glUniform2iv )
f ( glUniform3f )
f ( glUniform3fv )
f ( glUniform3i )
f ( glUniform3iv )
f ( glUniform4f )
f ( glUniform4fv )
f ( glUniform4i )
f ( glUniform4iv )
f ( glUniformMatrix2fv )
f ( glUniformMatrix3fv )
f ( glUniformMatrix4fv )
f ( glUseProgram )
f ( glValidateProgram )
f ( glVertexAttrib1f )
f ( glVertexAttrib1fv )
f ( glVertexAttrib2f )
f ( glVertexAttrib2fv )
f ( glVertexAttrib3f )
f ( glVertexAttrib3fv )
f ( glVertexAttrib4f )
f ( glVertexAttrib4fv )
f ( glVertexAttribPointer )
f ( glViewport )
f ( wglCreateContextAttribsARB )
NULL
} ;
//this is a list of the functions that exist in opengles2, as well as wglCreateContextAttribsARB.
//functions not in this list *should* be stubs that just return errors, but we can't always depend on drivers for that... they shouldn't get called.
//this list is just to make it easier to test+debug android gles2 stuff using windows.
static char * gles1funcs [ ] =
{
# define f(n) #n,
/* Available only in Common profile */
f ( glAlphaFunc )
f ( glClearColor )
f ( glClearDepthf )
f ( glClipPlanef )
f ( glColor4f )
f ( glDepthRangef )
f ( glFogf )
f ( glFogfv )
f ( glFrustumf )
f ( glGetClipPlanef )
f ( glGetFloatv )
f ( glGetLightfv )
f ( glGetMaterialfv )
f ( glGetTexEnvfv )
f ( glGetTexParameterfv )
f ( glLightModelf )
f ( glLightModelfv )
f ( glLightf )
f ( glLightfv )
f ( glLineWidth )
f ( glLoadMatrixf )
f ( glMaterialf )
f ( glMaterialfv )
f ( glMultMatrixf )
f ( glMultiTexCoord4f )
f ( glNormal3f )
f ( glOrthof )
f ( glPointParameterf )
f ( glPointParameterfv )
f ( glPointSize )
f ( glPolygonOffset )
f ( glRotatef )
f ( glScalef )
f ( glTexEnvf )
f ( glTexEnvfv )
f ( glTexParameterf )
f ( glTexParameterfv )
f ( glTranslatef )
/* Available in both Common and Common-Lite profiles */
f ( glActiveTexture )
f ( glAlphaFuncx )
f ( glBindBuffer )
f ( glBindTexture )
f ( glBlendFunc )
f ( glBufferData )
f ( glBufferSubData )
f ( glClear )
f ( glClearColorx )
f ( glClearDepthx )
f ( glClearStencil )
f ( glClientActiveTexture )
f ( glClipPlanex )
f ( glColor4ub )
f ( glColor4x )
f ( glColorMask )
f ( glColorPointer )
f ( glCompressedTexImage2D )
f ( glCompressedTexSubImage2D )
f ( glCopyTexImage2D )
f ( glCopyTexSubImage2D )
f ( glCullFace )
f ( glDeleteBuffers )
f ( glDeleteTextures )
f ( glDepthFunc )
f ( glDepthMask )
f ( glDepthRangex )
f ( glDisable )
f ( glDisableClientState )
f ( glDrawArrays )
f ( glDrawElements )
f ( glEnable )
f ( glEnableClientState )
f ( glFinish )
f ( glFlush )
f ( glFogx )
f ( glFogxv )
f ( glFrontFace )
f ( glFrustumx )
f ( glGetBooleanv )
f ( glGetBufferParameteriv )
f ( glGetClipPlanex )
f ( glGenBuffers )
f ( glGenTextures )
f ( glGetError )
f ( glGetFixedv )
f ( glGetIntegerv )
f ( glGetLightxv )
f ( glGetMaterialxv )
f ( glGetPointerv )
f ( glGetString )
f ( glGetTexEnviv )
f ( glGetTexEnvxv )
f ( glGetTexParameteriv )
f ( glGetTexParameterxv )
f ( glHint )
f ( glIsBuffer )
f ( glIsEnabled )
f ( glIsTexture )
f ( glLightModelx )
f ( glLightModelxv )
f ( glLightx )
f ( glLightxv )
f ( glLineWidthx )
f ( glLoadIdentity )
f ( glLoadMatrixx )
f ( glLogicOp )
f ( glMaterialx )
f ( glMaterialxv )
f ( glMatrixMode )
f ( glMultMatrixx )
f ( glMultiTexCoord4x )
f ( glNormal3x )
f ( glNormalPointer )
f ( glOrthox )
f ( glPixelStorei )
f ( glPointParameterx )
f ( glPointParameterxv )
f ( glPointSizex )
f ( glPolygonOffsetx )
f ( glPopMatrix )
f ( glPushMatrix )
f ( glReadPixels )
f ( glRotatex )
f ( glSampleCoverage )
f ( glSampleCoveragex )
f ( glScalex )
f ( glScissor )
f ( glShadeModel )
f ( glStencilFunc )
f ( glStencilMask )
f ( glStencilOp )
f ( glTexCoordPointer )
f ( glTexEnvi )
f ( glTexEnvx )
f ( glTexEnviv )
f ( glTexEnvxv )
f ( glTexImage2D )
f ( glTexParameteri )
f ( glTexParameterx )
f ( glTexParameteriv )
f ( glTexParameterxv )
f ( glTexSubImage2D )
f ( glTranslatex )
f ( glVertexPointer )
f ( glViewport )
/*required to switch stuff around*/
f ( wglCreateContextAttribsARB )
f ( glXGetProcAddress )
f ( glXQueryExtensionsString )
f ( glXChooseFBConfig )
f ( glXGetFBConfigAttrib )
f ( glXGetVisualFromFBConfig )
f ( glXCreateContextAttribsARB )
NULL
} ;
# endif
2018-10-11 10:31:23 +00:00
static void * GLX_GetSymbol ( char * name )
2018-03-04 14:41:16 +00:00
{
void * symb ;
2018-12-28 00:04:36 +00:00
#if 0 //def _DEBUG
if ( 1 )
{
int i ;
for ( i = 0 ; gles1funcs [ i ] ; i + + )
{
if ( ! strcmp ( name , gles1funcs [ i ] ) )
break ;
}
if ( ! gles1funcs [ i ] )
return NULL ; //not in the list
}
# endif
2018-03-04 14:41:16 +00:00
if ( glx . GetProcAddress )
symb = glx . GetProcAddress ( name ) ;
else
symb = NULL ;
if ( ! symb )
symb = Sys_GetAddressForName ( glx . gllibrary , name ) ;
return symb ;
2004-08-22 22:29:09 +00:00
}
2019-01-13 16:51:50 +00:00
static qboolean GLX_CheckExtension ( const char * ext )
{
const char * e = glx . glxextensions , * n ;
size_t el = strlen ( ext ) ;
while ( e & & * e )
{
while ( * e = = ' ' )
e + + ;
n = strchr ( e , ' ' ) ;
if ( ! n )
n = n + strlen ( e ) ;
if ( n - e = = el & & ! strncmp ( ext , e , el ) )
{
Con_DPrintf ( " GLX: Found %s \n " , ext ) ;
return true ;
}
e = n ;
}
Con_DPrintf ( " GLX: Missing %s \n " , ext ) ;
return false ;
}
2018-10-11 10:31:23 +00:00
static qboolean GLX_InitLibrary ( char * driver )
2004-08-22 22:29:09 +00:00
{
2013-11-21 23:02:28 +00:00
dllfunction_t funcs [ ] =
{
2018-03-04 14:41:16 +00:00
{ ( void * ) & glx . ChooseVisual , " glXChooseVisual " } ,
{ ( void * ) & glx . SwapBuffers , " glXSwapBuffers " } ,
{ ( void * ) & glx . MakeCurrent , " glXMakeCurrent " } ,
{ ( void * ) & glx . CreateContext , " glXCreateContext " } ,
{ ( void * ) & glx . DestroyContext , " glXDestroyContext " } ,
2013-11-21 23:02:28 +00:00
{ NULL , NULL }
} ;
2018-03-04 14:41:16 +00:00
memset ( & glx , 0 , sizeof ( glx ) ) ;
2013-11-21 23:02:28 +00:00
2004-08-22 22:29:09 +00:00
if ( driver & & * driver )
2018-03-04 14:41:16 +00:00
glx . gllibrary = Sys_LoadLibrary ( driver , funcs ) ;
2004-08-22 22:29:09 +00:00
else
2018-03-04 14:41:16 +00:00
glx . gllibrary = NULL ;
2014-03-30 00:39:37 +00:00
# ifdef __CYGWIN__
2018-03-04 14:41:16 +00:00
if ( ! glx . gllibrary )
glx . gllibrary = Sys_LoadLibrary ( " cygGL-1.dll " , funcs ) ;
# endif
if ( ! glx . gllibrary ) //I hate this.
glx . gllibrary = Sys_LoadLibrary ( " libGL.so.1 " , funcs ) ;
if ( ! glx . gllibrary )
glx . gllibrary = Sys_LoadLibrary ( " libGL " , funcs ) ;
if ( ! glx . gllibrary )
2004-08-22 22:29:09 +00:00
return false ;
2019-01-13 16:51:50 +00:00
glx . QueryExtensionsString = GLX_GetSymbol ( " glXQueryExtensionsString " ) ;
2018-03-04 14:41:16 +00:00
glx . GetProcAddress = GLX_GetSymbol ( " glXGetProcAddress " ) ;
if ( ! glx . GetProcAddress )
glx . GetProcAddress = GLX_GetSymbol ( " glXGetProcAddressARB " ) ;
glx . ChooseFBConfig = GLX_GetSymbol ( " glXChooseFBConfig " ) ;
glx . GetFBConfigAttrib = GLX_GetSymbol ( " glXGetFBConfigAttrib " ) ;
glx . GetVisualFromFBConfig = GLX_GetSymbol ( " glXGetVisualFromFBConfig " ) ;
glx . CreateContextAttribs = GLX_GetSymbol ( " glXCreateContextAttribsARB " ) ;
2004-08-22 22:29:09 +00:00
return true ;
}
2018-03-04 14:41:16 +00:00
# ifndef GLX_RGBA_FLOAT_BIT
# define GLX_RGBA_FLOAT_BIT 0x00000004
# endif
# ifndef GLX_CONTEXT_OPENGL_NO_ERROR_ARB
# define GLX_CONTEXT_OPENGL_NO_ERROR_ARB 0x31B3
# endif
//Since GLX1.3 (equivelent to gl1.2)
2018-10-11 10:31:23 +00:00
static GLXFBConfig GLX_GetFBConfig ( rendererstate_t * info )
2018-03-04 14:41:16 +00:00
{
int attrib [ 32 ] ;
int n , i ;
int numconfigs ;
GLXFBConfig * fbconfigs ;
2018-09-23 19:35:24 +00:00
qboolean hassrgb , hasmultisample ; //, hasfloats;
2018-03-04 14:41:16 +00:00
if ( ! glx . ChooseFBConfig | | ! glx . GetVisualFromFBConfig )
{
Con_Printf ( " Missing function pointer \n " ) ;
return NULL ;
}
if ( ! glx . CreateContextAttribs )
{
Con_Printf ( " Missing CreateContextAttribs \n " ) ;
return NULL ; //don't worry about it
}
2018-09-23 19:35:24 +00:00
hassrgb = GLX_CheckExtension ( " GLX_ARB_framebuffer_sRGB " ) | | GLX_CheckExtension ( " GLX_EXT_framebuffer_sRGB " ) ;
2018-03-04 14:41:16 +00:00
hasmultisample = GLX_CheckExtension ( " GLX_ARB_multisample " ) ;
2018-09-23 19:35:24 +00:00
// hasfloats = GLX_CheckExtension("GLX_ARB_fbconfig_float");
2018-03-04 14:41:16 +00:00
//do it in a loop, mostly to disable extensions that are unlikely to be supported on various glx implementations.
for ( i = 0 ; i < ( 16 < < 1 ) ; i + + )
{
n = 0 ;
//attrib[n++] = GLX_LEVEL; attrib[n++] = 0; //overlays
attrib [ n + + ] = GLX_DOUBLEBUFFER ; attrib [ n + + ] = True ;
if ( ! ( i & 1 ) )
{
if ( ! info - > stereo )
continue ;
attrib [ n + + ] = GLX_STEREO ; attrib [ n + + ] = True ;
}
if ( ! ( i & 2 ) )
{
if ( ! info - > srgb | | ! hassrgb )
continue ;
attrib [ n + + ] = GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB ; attrib [ n + + ] = True ;
}
//attrib[n++] = GLX_AUX_BUFFERS; attrib[n++] = 0;
2018-09-23 19:35:24 +00:00
#if 0
2018-03-04 14:41:16 +00:00
if ( ! ( i & 4 ) )
2018-09-23 19:35:24 +00:00
{ //unlike on windows, this is explicitly blocked except for pbuffers. ffs.
if ( info - > srgb < 2 | | ! hasfloats )
2018-03-04 14:41:16 +00:00
continue ; //skip fp16 framebuffers
2018-09-23 19:35:24 +00:00
//unlike on windows, this is explicitly blocked except for pbuffers. ffs.
2018-03-04 14:41:16 +00:00
attrib [ n + + ] = GLX_RENDER_TYPE ; attrib [ n + + ] = GLX_RGBA_FLOAT_BIT ;
attrib [ n + + ] = GLX_RED_SIZE ; attrib [ n + + ] = info - > bpp ? info - > bpp / 3 : 4 ;
attrib [ n + + ] = GLX_GREEN_SIZE ; attrib [ n + + ] = info - > bpp ? info - > bpp / 3 : 4 ;
attrib [ n + + ] = GLX_BLUE_SIZE ; attrib [ n + + ] = info - > bpp ? info - > bpp / 3 : 4 ;
}
else
2018-09-23 19:35:24 +00:00
# endif
2018-03-04 14:41:16 +00:00
{
2018-09-23 19:35:24 +00:00
if ( info - > bpp = = 32 )
{ //bpp32 is an alias for 24 (we ignore the alpha channel)
2018-03-04 14:41:16 +00:00
attrib [ n + + ] = GLX_RED_SIZE ; attrib [ n + + ] = 8 ;
attrib [ n + + ] = GLX_GREEN_SIZE ; attrib [ n + + ] = 8 ;
attrib [ n + + ] = GLX_BLUE_SIZE ; attrib [ n + + ] = 8 ;
}
else
2018-09-23 19:35:24 +00:00
{ //clamp requested bitdepth to 8bits on the second pass, so that bpp30 doesn't fail
attrib [ n + + ] = GLX_RED_SIZE ; attrib [ n + + ] = bound ( 1 , info - > bpp ? info - > bpp / 3 : 4 , ( i & 4 ) ? 8 : 16 ) ;
attrib [ n + + ] = GLX_GREEN_SIZE ; attrib [ n + + ] = bound ( 1 , info - > bpp ? info - > bpp / 3 : 4 , ( i & 4 ) ? 8 : 16 ) ;
attrib [ n + + ] = GLX_BLUE_SIZE ; attrib [ n + + ] = bound ( 1 , info - > bpp ? info - > bpp / 3 : 4 , ( i & 4 ) ? 8 : 16 ) ;
2018-03-04 14:41:16 +00:00
}
}
//attrib[n++] = GLX_ALPHA_SIZE; attrib[n++] = GLX_DONT_CARE;
2020-06-12 23:29:58 +00:00
attrib [ n + + ] = GLX_DEPTH_SIZE ; attrib [ n + + ] = info - > depthbits ? info - > depthbits : 16 ;
2018-03-04 14:41:16 +00:00
attrib [ n + + ] = GLX_STENCIL_SIZE ; attrib [ n + + ] = ( i & 16 ) ? 0 : 4 ;
if ( ! ( i & 8 ) )
{
if ( ! info - > multisample | | ! hasmultisample )
continue ;
attrib [ n + + ] = GLX_SAMPLE_BUFFERS_ARB ; attrib [ n + + ] = True ;
2019-01-13 16:51:50 +00:00
attrib [ n + + ] = GLX_SAMPLES_ARB ; attrib [ n + + ] = info - > multisample ;
2018-03-04 14:41:16 +00:00
}
//attrib[n++] = GLX_ACCUM_RED_SIZE; attrib[n++] = 0;
//attrib[n++] = GLX_ACCUM_GREEN_SIZE; attrib[n++] = 0;
//attrib[n++] = GLX_ACCUM_BLUE_SIZE; attrib[n++] = 0;
//attrib[n++] = GLX_ACCUM_ALPHA_SIZE; attrib[n++] = 0;
attrib [ n + + ] = GLX_DRAWABLE_TYPE ; attrib [ n + + ] = GLX_WINDOW_BIT ;
attrib [ n + + ] = GLX_X_RENDERABLE ; attrib [ n + + ] = True ;
//attrib[n++] = GLX_X_VISUAL_TYPE; attrib[n++] = info->srgb?GLX_TRUE_COLOR:GLX_DIRECT_COLOR;
//attrib[n++] = GLX_CONFIG_CAVEAT; attrib[n++] = GLX_DONT_CARE; GLX_NONE||GLX_SLOW_CONFIG||GLX_NON_CONFORMANT_CONFIG
//attrib[n++] = GLX_TRANSPARENT_TYPE;attrib[n++] = GLX_NONE;
//attrib[n++] = GLX_TRANSPARENT_ALPHA_VALUE;attrib[n++] = 0;
attrib [ n + + ] = None ;
numconfigs = 0 ;
fbconfigs = glx . ChooseFBConfig ( vid_dpy , scrnum , attrib , & numconfigs ) ;
if ( fbconfigs )
{
if ( numconfigs )
{
GLXFBConfig r = fbconfigs [ 0 ] ;
x11 . pXFree ( fbconfigs ) ;
return r ;
}
x11 . pXFree ( fbconfigs ) ;
}
}
return NULL ;
}
//for GLX<1.3
2018-10-11 10:31:23 +00:00
static XVisualInfo * GLX_GetVisual ( rendererstate_t * info )
2018-03-04 14:41:16 +00:00
{
XVisualInfo * visinfo ;
int attrib [ 32 ] ;
int numattrib , i ;
//do it in a loop, mostly to disable extensions that are unlikely to be supported on various glx implementations.
for ( i = 0 ; i < ( 8 < < 1 ) ; i + + )
{
numattrib = 0 ;
attrib [ numattrib + + ] = GLX_RGBA ;
attrib [ numattrib + + ] = GLX_DOUBLEBUFFER ;
if ( ! ( i & 1 ) )
{
if ( ! info - > stereo )
continue ;
attrib [ numattrib + + ] = GLX_STEREO ;
}
if ( ! ( i & 2 ) )
{
if ( ! info - > srgb )
continue ;
attrib [ numattrib + + ] = GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB ;
}
if ( ! ( i & 4 ) )
{
if ( ! info - > multisample )
continue ;
attrib [ numattrib + + ] = GLX_SAMPLE_BUFFERS_ARB ; attrib [ numattrib + + ] = info - > multisample ;
}
if ( ! ( i & 8 ) )
{
attrib [ numattrib + + ] = GLX_STENCIL_SIZE ; attrib [ numattrib + + ] = 4 ;
}
attrib [ numattrib + + ] = GLX_RED_SIZE ; attrib [ numattrib + + ] = 4 ;
attrib [ numattrib + + ] = GLX_GREEN_SIZE ; attrib [ numattrib + + ] = 4 ;
attrib [ numattrib + + ] = GLX_BLUE_SIZE ; attrib [ numattrib + + ] = 4 ;
attrib [ numattrib + + ] = GLX_DEPTH_SIZE ; attrib [ numattrib + + ] = 16 ;
attrib [ numattrib + + ] = None ;
visinfo = glx . ChooseVisual ( vid_dpy , scrnum , attrib ) ;
if ( visinfo )
return visinfo ;
}
return NULL ;
}
2018-10-11 10:31:23 +00:00
static qboolean GLX_Init ( rendererstate_t * info , GLXFBConfig fbconfig , XVisualInfo * visinfo )
2018-03-04 14:41:16 +00:00
{
extern cvar_t vid_gl_context_version ;
extern cvar_t vid_gl_context_forwardcompatible ;
extern cvar_t vid_gl_context_compatibility ;
extern cvar_t vid_gl_context_debug ;
extern cvar_t vid_gl_context_es ;
extern cvar_t vid_gl_context_robustness ;
// extern cvar_t vid_gl_context_selfreset;
extern cvar_t vid_gl_context_noerror ;
2020-05-14 15:50:26 +00:00
vrsetup_t setup = { sizeof ( setup ) } ;
setup . vrplatform = VR_X11_GLX ;
setup . x11_glx . display = vid_dpy ;
setup . x11_glx . visualid = visinfo - > visualid ;
setup . x11_glx . glxfbconfig = fbconfig ;
setup . x11_glx . drawable = vid_window ;
if ( info - > vr & & ! info - > vr - > Prepare ( & setup ) )
{
info - > vr - > Shutdown ( ) ;
info - > vr = NULL ;
}
2018-03-04 14:41:16 +00:00
if ( fbconfig & & glx . CreateContextAttribs )
{
unsigned int majorver = 1 , minorver = 1 ;
unsigned profile = 0 ;
unsigned contextflags = 0 ;
int attrib [ 16 * 2 + 1 ] ;
int n , val ;
char * ver ;
ver = vid_gl_context_version . string ;
if ( ! * ver & & vid_gl_context_es . ival & & GLX_CheckExtension ( " GLX_EXT_create_context_es_profile " ) )
ver = vid_gl_context_es . string ;
if ( ! * ver & & ! vid_gl_context_compatibility . ival & & * vid_gl_context_compatibility . string )
ver = " 3.2 " ; //if the user explicitly disabled compat, then they'll want a version that actually supports doing so.
majorver = strtoul ( ver , & ver , 10 ) ;
if ( * ver = = ' . ' )
minorver = strtoul ( ver + 1 , & ver , 10 ) ;
else
minorver = 0 ;
2020-05-14 15:50:26 +00:00
if ( majorver < setup . minver . major | | ( majorver = = setup . minver . major & & minorver < setup . minver . minor ) )
{ //if vr stuff requires a minimum version then try and ask for that now
majorver = setup . minver . major ;
minorver = setup . minver . minor ;
}
2018-03-04 14:41:16 +00:00
//some weirdness for you:
//3.0 simply marked stuff as deprecated, without removing it.
//3.1 removed it (moved to the optional GL_ARB_compatibility extension, which shouldn't be supported in a forward-compatible context).
//3.2 added the concept of profiles.
if ( vid_gl_context_debug . ival )
contextflags | = GLX_CONTEXT_DEBUG_BIT_ARB ;
if ( vid_gl_context_forwardcompatible . ival ) //treat this as a dev/debug thing.
contextflags | = GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB ;
if ( vid_gl_context_robustness . ival & & GLX_CheckExtension ( " GLX_ARB_create_context_robustness " ) )
contextflags | = GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB ;
if ( vid_gl_context_es . ival & & GLX_CheckExtension ( " GLX_EXT_create_context_es_profile " ) )
profile = GLX_CONTEXT_ES_PROFILE_BIT_EXT ;
else if ( majorver > 3 | | ( majorver = = 3 & & minorver > = 2 ) )
{ //profiles only started with 3.2
if ( vid_gl_context_compatibility . ival )
profile = GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB ;
else
profile = GLX_CONTEXT_CORE_PROFILE_BIT_ARB ;
}
else
profile = 0 ;
n = 0 ;
if ( majorver | | minorver )
{
attrib [ n + + ] = GLX_CONTEXT_MAJOR_VERSION_ARB ; attrib [ n + + ] = majorver ;
attrib [ n + + ] = GLX_CONTEXT_MINOR_VERSION_ARB ; attrib [ n + + ] = minorver ;
}
if ( contextflags )
{
attrib [ n + + ] = GLX_CONTEXT_FLAGS_ARB ; attrib [ n + + ] = contextflags ;
}
if ( profile )
{
attrib [ n + + ] = GLX_CONTEXT_PROFILE_MASK_ARB ; attrib [ n + + ] = profile ;
}
if ( vid_gl_context_noerror . ival & & GLX_CheckExtension ( " GLX_ARB_create_context_no_error " ) )
{
attrib [ n + + ] = GLX_CONTEXT_OPENGL_NO_ERROR_ARB ; attrib [ n + + ] = ! vid_gl_context_robustness . ival & & ! vid_gl_context_debug . ival ;
}
attrib [ n + + ] = None ;
if ( glx . GetFBConfigAttrib )
{
2018-09-23 19:35:24 +00:00
if ( ! glx . GetFBConfigAttrib ( vid_dpy , fbconfig , GLX_RENDER_TYPE , & val ) & & val = = GLX_RGBA_FLOAT_BIT )
2018-03-04 14:41:16 +00:00
vid . flags | = VID_FP16 ; //other things need to be 16bit too, to avoid loss of precision.
2018-09-23 19:35:24 +00:00
if ( ! glx . GetFBConfigAttrib ( vid_dpy , fbconfig , GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB , & val ) & & val )
2018-03-04 14:41:16 +00:00
vid . flags | = VID_SRGB_CAPABLE ; //can use srgb properly, without faking it etc.
}
ctx = glx . CreateContextAttribs ( vid_dpy , fbconfig , NULL , True , attrib ) ;
}
2004-08-22 22:29:09 +00:00
else
2018-03-04 14:41:16 +00:00
ctx = glx . CreateContext ( vid_dpy , visinfo , NULL , True ) ;
if ( ! ctx )
{
Con_Printf ( " Failed to create GLX context. \n " ) ;
return false ;
}
2004-08-22 22:29:09 +00:00
2018-03-04 14:41:16 +00:00
if ( ! glx . MakeCurrent ( vid_dpy , vid_window , ctx ) )
{
Con_Printf ( " glXMakeCurrent failed \n " ) ;
return false ;
}
2020-05-14 15:50:26 +00:00
setup . x11_glx . glxcontext = ctx ;
if ( info - > vr & & ! info - > vr - > Init ( & setup , info ) )
{
info - > vr - > Shutdown ( ) ;
return false ;
}
vid . vr = info - > vr ;
2018-03-04 14:41:16 +00:00
//okay, we have a context, now init OpenGL-proper.
return GL_Init ( info , & GLX_GetSymbol ) ;
2004-08-22 22:29:09 +00:00
}
2016-07-12 00:40:13 +00:00
# endif
2004-08-22 22:29:09 +00:00
2014-03-30 00:39:37 +00:00
static void X_ShutdownUnicode ( void )
{
if ( x11 . unicodecontext )
x11 . pXDestroyIC ( x11 . unicodecontext ) ;
2014-07-07 17:18:45 +00:00
x11 . unicodecontext = NULL ;
2014-03-30 00:39:37 +00:00
if ( x11 . inputmethod )
x11 . pXCloseIM ( x11 . inputmethod ) ;
2014-07-07 17:18:45 +00:00
x11 . inputmethod = NULL ;
2014-03-30 00:39:37 +00:00
x11 . dounicode = false ;
}
2018-11-27 16:48:19 +00:00
static int XIMPreEditStartCallback ( XIC ic , XPointer client_data , XPointer call_data )
{
Z_Free ( vid . ime_preview ) ; //just in case
vid . ime_preview = NULL ;
vid . ime_previewlen = 0 ;
// Con_Printf("XIMPreEditStartCallback\n");
return - 1 ; //length of string we can handle (negative for unlimited)
}
static void XIMPreEditDoneCallback ( XIC ic , XPointer client_data , XPointer call_data )
{
// Con_Printf("XIMPreEditDoneCallback\n");
Z_Free ( vid . ime_preview ) ;
vid . ime_preview = NULL ;
vid . ime_previewlen = 0 ;
}
static void XIMPreEditDrawCallback ( XIM ic , XPointer client_data , XIMPreeditDrawCallbackStruct * d )
{
//if chg_length, wipe chg_length chars @chg_first.
//if text, insert at chg_first (with per-char feedback properties)
//if feedback (without text) then change text char flags
//caret should then be moved accordingly.
// Con_Printf("XIMPreEditDrawCallback %i %i %i %i %s\n", d->caret, d->chg_first, d->chg_length, d->text?d->text->encoding_is_wchar:0, d->text?d->text->string.multi_byte:"???");
conchar_t * part [ 3 ] ;
size_t clen [ 3 ] , c ;
conchar_t * n ;
unsigned int wc ;
unsigned int defaultfl = CON_WHITEMASK , fl ;
if ( d - > chg_length | | ( d - > text & & d - > text - > length ) )
{
//so inputs are in terms of chars.
//our conchar_t struct is variable-sized (*sigh*), so we always use our longchar encoding.
//so we end up with two conchars per wchar.
part [ 0 ] = vid . ime_preview ;
clen [ 0 ] = bound ( 0 , d - > chg_first , vid . ime_previewlen / 2 ) * 2 ;
part [ 1 ] = NULL ;
clen [ 1 ] = 0 ;
part [ 2 ] = part [ 0 ] + clen [ 0 ] + bound ( 0 , d - > chg_length , vid . ime_previewlen / 2 ) * 2 ;
clen [ 2 ] = 0 ;
if ( part [ 2 ] )
while ( part [ 2 ] [ clen [ 2 ] ] )
clen [ 2 ] + = 1 ;
if ( d - > text & & d - > text - > encoding_is_wchar & & d - > text - > string . wide_char )
{
part [ 1 ] = alloca ( d - > text - > length * 2 * sizeof ( wchar_t ) ) ;
for ( c = 0 ; c < d - > text - > length ; c + + )
{
wc = d - > text - > string . wide_char [ c ] ;
if ( ! wc )
break ; //erk? nulls confuse things
part [ 1 ] [ c * 2 + 0 ] = CON_LONGCHAR | ( wc > > 16 ) ;
part [ 1 ] [ c * 2 + 1 ] = defaultfl | ( wc & CON_CHARMASK ) ;
}
clen [ 1 ] = c * 2 ;
}
else if ( d - > text & & ! d - > text - > encoding_is_wchar & & d - > text - > string . multi_byte )
{
const char * in = d - > text - > string . multi_byte ;
int error ;
part [ 1 ] = alloca ( d - > text - > length * 2 * sizeof ( wchar_t ) ) ;
//FIXME: d->text->length is meant to be chars, but fcitx always reports 1.
for ( c = 0 ; c < d - > text - > length ; c + + )
{
//FIXME: This should use mbcstowcs, but that would require switching locales all the frikkin time, which isn't thread-safe.
wc = utf8_decode ( & error , in , & in ) ;
if ( ! wc )
break ; //abort if there's a null...
part [ 1 ] [ c * 2 + 0 ] = CON_LONGCHAR | ( wc > > 16 ) ;
part [ 1 ] [ c * 2 + 1 ] = defaultfl | ( wc & CON_CHARMASK ) ;
}
clen [ 1 ] = c * 2 ;
}
n = Z_Malloc ( ( clen [ 0 ] + clen [ 1 ] + clen [ 2 ] + 1 ) * sizeof ( * n ) ) ;
memcpy ( n , part [ 0 ] , clen [ 0 ] * sizeof ( * n ) ) ;
memcpy ( n + clen [ 0 ] , part [ 1 ] , clen [ 1 ] * sizeof ( * n ) ) ;
memcpy ( n + clen [ 0 ] + clen [ 1 ] , part [ 2 ] , clen [ 2 ] * sizeof ( * n ) ) ;
n [ clen [ 0 ] + clen [ 1 ] + clen [ 2 ] ] = 0 ;
Z_Free ( vid . ime_preview ) ;
vid . ime_preview = n ;
vid . ime_previewlen = clen [ 0 ] + clen [ 1 ] + clen [ 2 ] ;
}
if ( d - > text & & d - > text - > feedback & & d - > chg_first > = 0 & & d - > chg_first + d - > text - > length < = vid . ime_previewlen / 2 )
{
for ( c = 0 ; c < d - > text - > length ; c + + )
{
fl = defaultfl ;
if ( d - > text - > feedback [ c ] & XIMPrimary )
fl = COLOR_RED < < CON_FGSHIFT ;
if ( d - > text - > feedback [ c ] & XIMSecondary )
fl = COLOR_GREEN < < CON_FGSHIFT ;
if ( d - > text - > feedback [ c ] & XIMTertiary )
fl = COLOR_BLUE < < CON_FGSHIFT ;
if ( d - > text - > feedback [ c ] & XIMUnderline )
fl = COLOR_MAGENTA < < CON_FGSHIFT ;
if ( d - > text - > feedback [ c ] & XIMReverse )
fl = ( ( fl & CON_FGMASK ) < < ( CON_BGSHIFT - CON_FGSHIFT ) ) | ( ( fl & CON_BGMASK ) > > ( CON_BGSHIFT - CON_FGSHIFT ) ) ;
if ( d - > text - > feedback [ c ] & XIMHighlight )
fl | = CON_2NDCHARSETTEXT ;
vid . ime_preview [ ( d - > chg_first + c ) * 2 + 1 ] = ( ( vid . ime_preview [ ( d - > chg_first + c ) * 2 + 1 ] ) & ~ CON_FLAGSMASK ) | fl ;
}
}
vid . ime_caret = bound ( 0 , d - > caret , vid . ime_previewlen / 2 ) * 2 ;
}
static void XIMPreEditCaretCallback ( XIC ic , XPointer client_data , XIMPreeditCaretCallbackStruct * d )
{
// Con_Printf("XIMPreEditCaretCallback %i %i %i\n", d->direction, d->position, d->style);
}
static qboolean XIMSupportedStyle ( XIMStyle preedit , XIMStyle status )
{
if ( ! ( //preedit==XIMPreeditCallbacks|| //FIXME: this should actually work, but we still need an ime that actually supports it properly to be sure.
//preedit==XIMPreeditPosition||
//preedit==XIMPreeditArea|| //FIXME: assume the bottom half of the screen
preedit = = XIMPreeditNothing | |
preedit = = XIMPreeditNone ) )
return false ;
if ( ! ( //status==XIMStatusCallbacks||
//status==XIMStatusArea||
status = = XIMStatusNothing | |
status = = XIMStatusNone ) )
return false ;
return true ;
}
static XIMStyle XIMPreferredStyle ( XIMStyle old , XIMStyle new )
{ //favour the more complicated (supported) preedit styles, *THEN* choose the preferred status style.
XIMStyle p1 = old & 0x00ff ;
XIMStyle p2 = new & 0x00ff ;
XIMStyle s1 = old & 0xff00 ;
XIMStyle s2 = new & 0xff00 ;
if ( ! XIMSupportedStyle ( p2 , s2 ) )
return old ;
if ( ! XIMSupportedStyle ( p1 , s1 ) )
return new ;
if ( p1 ! = p2 )
{ //choose based upon the preedit flags
if ( ( p1 ^ p2 ) & XIMPreeditCallbacks ) //FIXME: support this one properly some time.
return ( p1 & XIMPreeditCallbacks ) ? old : new ;
if ( ( p1 ^ p2 ) & XIMPreeditPosition )
return ( p1 & XIMPreeditPosition ) ? old : new ;
if ( ( p1 ^ p2 ) & XIMPreeditArea )
return ( p1 & XIMPreeditArea ) ? old : s2 ;
if ( ( p1 ^ p2 ) & XIMPreeditNothing )
return ( p1 & XIMPreeditNothing ) ? old : new ;
if ( ( p1 ^ p2 ) & XIMPreeditNone )
return ( p1 & XIMPreeditNone ) ? old : new ;
}
else
{ //preedit flags are equal, now pick the better
if ( ( s1 ^ s2 ) & XIMStatusCallbacks )
return ( s1 & XIMStatusCallbacks ) ? old : new ;
if ( ( s1 ^ s2 ) & XIMStatusArea )
return ( s1 & XIMStatusArea ) ? old : new ;
if ( ( s1 ^ s2 ) & XIMStatusNothing )
return ( s1 & XIMStatusNothing ) ? old : new ;
if ( ( s1 ^ s2 ) & XIMStatusNone )
return ( s1 & XIMStatusNone ) ? old : new ;
}
//difference not known. stick with the first
return old ;
}
2014-03-30 00:39:37 +00:00
# include <locale.h>
static long X_InitUnicode ( void )
2004-08-22 22:29:09 +00:00
{
2014-03-30 00:39:37 +00:00
long requiredevents = 0 ;
X_ShutdownUnicode ( ) ;
2017-09-02 05:13:33 +00:00
//FIXME: enable by default if ubuntu's issue can ever be resolved.
2018-11-27 16:48:19 +00:00
if ( X11_CheckFeature ( " xim " , true ) )
2014-03-30 00:39:37 +00:00
{
2018-11-27 16:48:19 +00:00
if ( x11 . pXSetLocaleModifiers & & x11 . pXSupportsLocale & & x11 . pXOpenIM & & x11 . pXGetIMValues & & x11 . pXCreateIC & & x11 . pXSetICFocus & & x11 . pXUnsetICFocus & & x11 . pXGetICValues & & x11 . pXSetICValues & & x11 . pXFilterEvent & & ( x11 . pXutf8LookupString | | x11 . pXwcLookupString ) & & x11 . pXDestroyIC & & x11 . pXCloseIM )
2014-03-30 00:39:37 +00:00
{
2018-11-27 16:48:19 +00:00
setlocale ( LC_ALL , " " ) ; //just in case.
2014-03-30 08:55:06 +00:00
x11 . pXSetLocaleModifiers ( " " ) ;
2018-11-27 16:48:19 +00:00
2014-03-30 08:55:06 +00:00
if ( x11 . pXSupportsLocale ( ) )
2014-03-30 00:39:37 +00:00
{
2017-01-15 13:13:09 +00:00
x11 . inputmethod = x11 . pXOpenIM ( vid_dpy , NULL , XI_RESOURCENAME , XI_RESOURCECLASS ) ;
2014-03-30 08:55:06 +00:00
if ( x11 . inputmethod )
2014-03-30 00:39:37 +00:00
{
2015-09-10 10:16:26 +00:00
XIMStyles * sup = NULL ;
XIMStyle st = 0 ;
int i ;
x11 . pXGetIMValues ( x11 . inputmethod , XNQueryInputStyle , & sup , NULL ) ;
for ( i = 0 ; sup & & i < sup - > count_styles ; i + + )
2018-11-27 16:48:19 +00:00
st = XIMPreferredStyle ( st , sup - > supported_styles [ i ] ) ;
2015-09-10 10:16:26 +00:00
x11 . pXFree ( sup ) ;
2018-11-27 16:48:19 +00:00
Con_DPrintf ( " Chosen XIM Input Style: %x \n " , ( unsigned ) st ) ;
// st=XIMPreeditCallbacks|XIMStatusArea;
// st=XIMPreeditCallbacks|XIMStatusNothing;
2015-09-10 10:16:26 +00:00
if ( st ! = 0 )
2014-03-30 08:55:06 +00:00
{
2018-11-27 16:48:19 +00:00
XIMCallback pe_cb_start = { NULL , ( XIMProc ) XIMPreEditStartCallback } ;
XIMCallback pe_cb_done = { NULL , ( XIMProc ) XIMPreEditDoneCallback } ;
XIMCallback pe_cb_draw = { NULL , ( XIMProc ) XIMPreEditDrawCallback } ;
XIMCallback pe_cb_caret = { NULL , ( XIMProc ) XIMPreEditCaretCallback } ;
void * preedit [ ] = {
//should probably add in fonts, but that's kinda messy if we don't know the language/charset very well
XNPreeditStartCallback , & pe_cb_start ,
XNPreeditDoneCallback , & pe_cb_done ,
XNPreeditDrawCallback , & pe_cb_draw ,
XNPreeditCaretCallback , & pe_cb_caret ,
XNSpotLocation , & x11 . ime_pos ,
NULL } ;
void * status [ ] = {
NULL } ;
2015-09-10 10:16:26 +00:00
x11 . unicodecontext = x11 . pXCreateIC ( x11 . inputmethod ,
XNInputStyle , st ,
XNClientWindow , vid_window ,
2018-11-27 16:48:19 +00:00
// XNFocusWindow, vid_window,
2017-01-15 13:13:09 +00:00
XNResourceName , XI_RESOURCENAME ,
XNResourceClass , XI_RESOURCECLASS ,
2018-11-27 16:48:19 +00:00
XNPreeditAttributes , preedit ,
XNStatusAttributes , status ,
2015-09-10 10:16:26 +00:00
NULL ) ;
if ( x11 . unicodecontext )
{
2018-11-27 16:48:19 +00:00
x11 . ime_shown = - 1 ;
2015-09-10 10:16:26 +00:00
x11 . dounicode = true ;
x11 . pXGetICValues ( x11 . unicodecontext , XNFilterEvents , & requiredevents , NULL ) ;
2018-11-27 16:48:19 +00:00
requiredevents | = KeyPressMask ;
2015-09-10 10:16:26 +00:00
}
2014-03-30 08:55:06 +00:00
}
2014-03-30 00:39:37 +00:00
}
}
2018-11-27 16:48:19 +00:00
setlocale ( LC_ALL , " C " ) ;
2014-03-30 00:39:37 +00:00
}
}
2014-03-30 08:55:06 +00:00
Con_DPrintf ( " Unicode support: %s \n " , x11 . dounicode ? " available " : " unavailable " ) ;
2014-03-30 00:39:37 +00:00
return requiredevents ;
}
2014-03-30 08:55:06 +00:00
static void X_KeyEvent ( XKeyEvent * ev , qboolean pressed , qboolean filtered )
2014-03-30 00:39:37 +00:00
{
int i ;
2004-08-22 22:29:09 +00:00
int key ;
2009-07-07 21:32:54 +00:00
KeySym keysym , shifted ;
2014-03-30 00:39:37 +00:00
unsigned int unichar [ 64 ] ;
int unichars = 0 ;
2004-08-22 22:29:09 +00:00
key = 0 ;
2013-03-12 23:04:11 +00:00
keysym = x11 . pXLookupKeysym ( ev , 0 ) ;
2014-03-30 08:55:06 +00:00
if ( pressed & & ! filtered )
2013-05-13 13:43:18 +00:00
{
2018-11-27 16:48:19 +00:00
if ( x11 . dounicode & & vid . ime_allow )
2014-03-30 00:39:37 +00:00
{
Status status = XLookupNone ;
if ( x11 . pXutf8LookupString )
{
2018-11-27 16:48:19 +00:00
char buf1 [ 512 ] = { 0 } ;
char * buf = buf1 ;
const char * c ;
2014-03-30 00:39:37 +00:00
int count = x11 . pXutf8LookupString ( x11 . unicodecontext , ( XKeyPressedEvent * ) ev , buf1 , sizeof ( buf1 ) , NULL , & status ) ;
if ( status = = XBufferOverflow )
{
buf = alloca ( count + 1 ) ;
count = x11 . pXutf8LookupString ( x11 . unicodecontext , ( XKeyPressedEvent * ) ev , buf , count , NULL , & status ) ;
}
for ( c = buf ; c < & buf [ count ] ; )
{
int error ;
unsigned int uc = utf8_decode ( & error , c , & c ) ;
if ( uc )
unichar [ unichars + + ] = uc ;
}
}
else
{
//is allowed some weird encodings...
2018-11-27 16:48:19 +00:00
wchar_t buf1 [ 512 ] = { 0 } ;
2014-03-30 00:39:37 +00:00
wchar_t * buf = buf1 ;
int count = x11 . pXwcLookupString ( x11 . unicodecontext , ( XKeyPressedEvent * ) ev , buf , sizeof ( buf1 ) , & shifted , & status ) ;
if ( status = = XBufferOverflow )
{
buf = alloca ( sizeof ( wchar_t ) * ( count + 1 ) ) ;
count = x11 . pXwcLookupString ( x11 . unicodecontext , ( XKeyPressedEvent * ) ev , buf , count , NULL , & status ) ;
}
//if wchar_t is 16bit, then expect problems when we completely ignore surrogates. this is why we favour the utf8 route as it doesn't care whether wchar_t is defined as 16bit or 32bit.
for ( i = 0 ; i < count ; i + + )
if ( buf [ i ] )
unichar [ unichars + + ] = buf [ i ] ;
}
}
2013-05-13 13:43:18 +00:00
else
{
2014-03-30 00:39:37 +00:00
char buf [ 64 ] ;
if ( ( keysym & 0xff000000 ) = = 0x01000000 )
unichar [ unichars + + ] = keysym & 0x00ffffff ;
else
{
int count = x11 . pXLookupString ( ev , buf , sizeof ( buf ) , & shifted , 0 ) ;
for ( i = 0 ; i < count ; i + + )
if ( buf [ i ] )
unichar [ unichars + + ] = ( unsigned char ) buf [ i ] ;
}
2013-05-13 13:43:18 +00:00
}
}
2004-08-22 22:29:09 +00:00
switch ( keysym )
{
2013-05-03 04:28:08 +00:00
case XK_KP_Page_Up : key = K_KP_PGUP ; break ;
case XK_Page_Up : key = K_PGUP ; break ;
2004-08-22 22:29:09 +00:00
2013-05-03 04:28:08 +00:00
case XK_KP_Page_Down : key = K_KP_PGDN ; break ;
case XK_Page_Down : key = K_PGDN ; break ;
2004-08-22 22:29:09 +00:00
2013-05-03 04:28:08 +00:00
case XK_KP_Home : key = K_KP_HOME ; break ;
case XK_Home : key = K_HOME ; break ;
2004-08-22 22:29:09 +00:00
2013-05-03 04:28:08 +00:00
case XK_KP_End : key = K_KP_END ; break ;
case XK_End : key = K_END ; break ;
2004-08-22 22:29:09 +00:00
2013-05-03 04:28:08 +00:00
case XK_KP_Left : key = K_KP_LEFTARROW ; break ;
case XK_Left : key = K_LEFTARROW ; break ;
2004-08-22 22:29:09 +00:00
2013-05-03 04:28:08 +00:00
case XK_KP_Right : key = K_KP_RIGHTARROW ; break ;
case XK_Right : key = K_RIGHTARROW ; break ;
2004-08-22 22:29:09 +00:00
2013-05-03 04:28:08 +00:00
case XK_KP_Down : key = K_KP_DOWNARROW ; break ;
case XK_Down : key = K_DOWNARROW ; break ;
2004-08-22 22:29:09 +00:00
2013-05-03 04:28:08 +00:00
case XK_KP_Up : key = K_KP_UPARROW ; break ;
case XK_Up : key = K_UPARROW ; break ;
2004-08-22 22:29:09 +00:00
2013-05-03 04:28:08 +00:00
case XK_Escape : key = K_ESCAPE ; break ;
2004-08-22 22:29:09 +00:00
2013-05-03 04:28:08 +00:00
case XK_KP_Enter : key = K_KP_ENTER ; break ;
case XK_Return : key = K_ENTER ; break ;
2004-08-22 22:29:09 +00:00
2021-06-21 13:45:26 +00:00
case XK_Num_Lock : key = K_KP_NUMLOCK ; break ;
case XK_Caps_Lock : key = K_CAPSLOCK ; break ;
case XK_Scroll_Lock : key = K_SCRLCK ; break ;
case XK_Print : key = K_PRINTSCREEN ; break ;
case XK_Super_L : key = K_LWIN ; break ;
case XK_Super_R : key = K_RWIN ; break ;
2013-05-03 04:28:08 +00:00
case XK_Tab : key = K_TAB ; break ;
2004-08-22 22:29:09 +00:00
2013-05-03 04:28:08 +00:00
case XK_F1 : key = K_F1 ; break ;
case XK_F2 : key = K_F2 ; break ;
case XK_F3 : key = K_F3 ; break ;
case XK_F4 : key = K_F4 ; break ;
case XK_F5 : key = K_F5 ; break ;
case XK_F6 : key = K_F6 ; break ;
case XK_F7 : key = K_F7 ; break ;
case XK_F8 : key = K_F8 ; break ;
case XK_F9 : key = K_F9 ; break ;
case XK_F10 : key = K_F10 ; break ;
case XK_F11 : key = K_F11 ; break ;
case XK_F12 : key = K_F12 ; break ;
2020-06-27 19:31:55 +00:00
case XK_F13 : key = K_F13 ; break ;
case XK_F14 : key = K_F14 ; break ;
case XK_F15 : key = K_F15 ; break ;
2004-08-22 22:29:09 +00:00
2013-05-03 04:28:08 +00:00
case XK_BackSpace : key = K_BACKSPACE ; break ;
2004-08-22 22:29:09 +00:00
2013-05-03 04:28:08 +00:00
case XK_KP_Delete : key = K_KP_DEL ; break ;
case XK_Delete : key = K_DEL ; break ;
2004-08-22 22:29:09 +00:00
2013-05-03 04:28:08 +00:00
case XK_Pause : key = K_PAUSE ; break ;
2004-08-22 22:29:09 +00:00
2013-05-03 04:28:08 +00:00
case XK_Shift_L : key = K_LSHIFT ; break ;
case XK_Shift_R : key = K_RSHIFT ; break ;
2004-08-22 22:29:09 +00:00
2013-05-03 04:28:08 +00:00
case XK_Execute : key = K_LCTRL ; break ;
case XK_Control_L : key = K_LCTRL ; break ;
case XK_Control_R : key = K_RCTRL ; break ;
2004-08-22 22:29:09 +00:00
2013-05-03 04:28:08 +00:00
case XK_Alt_L : key = K_LALT ; break ;
case XK_Meta_L : key = K_LALT ; break ;
case XK_Alt_R : key = K_RALT ; break ;
case XK_Meta_R : key = K_RALT ; break ;
2020-06-13 20:02:55 +00:00
case XK_Menu : key = K_APP ; break ;
2004-08-22 22:29:09 +00:00
2013-05-03 04:28:08 +00:00
case XK_KP_Begin : key = K_KP_5 ; break ;
2004-08-22 22:29:09 +00:00
2013-05-03 04:28:08 +00:00
case XK_KP_Insert : key = K_KP_INS ; break ;
case XK_Insert : key = K_INS ; break ;
2004-08-22 22:29:09 +00:00
2013-05-03 04:28:08 +00:00
case XK_KP_Multiply : key = K_KP_STAR ; break ;
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 ;
2004-08-22 22:29:09 +00:00
#if 0
case 0x021 : key = ' 1 ' ; break ; /* [!] */
case 0x040 : key = ' 2 ' ; break ; /* [@] */
case 0x023 : key = ' 3 ' ; break ; /* [#] */
case 0x024 : key = ' 4 ' ; break ; /* [$] */
case 0x025 : key = ' 5 ' ; break ; /* [%] */
case 0x05e : key = ' 6 ' ; break ; /* [^] */
case 0x026 : key = ' 7 ' ; break ; /* [&] */
case 0x02a : key = ' 8 ' ; break ; /* [*] */
case 0x028 : key = ' 9 ' ; ; break ; /* [(] */
case 0x029 : key = ' 0 ' ; break ; /* [)] */
case 0x05f : key = ' - ' ; break ; /* [_] */
case 0x02b : key = ' = ' ; break ; /* [+] */
case 0x07c : key = ' \' ' ; break ; /* [|] */
case 0x07d : key = ' [ ' ; break ; /* [}] */
case 0x07b : key = ' ] ' ; break ; /* [{] */
case 0x022 : key = ' \' ' ; break ; /* ["] */
case 0x03a : key = ' ; ' ; break ; /* [:] */
case 0x03f : key = ' / ' ; break ; /* [?] */
case 0x03e : key = ' . ' ; break ; /* [>] */
case 0x03c : key = ' , ' ; break ; /* [<] */
# endif
default :
2013-05-13 13:43:18 +00:00
key = keysym ;
if ( key < 32 )
key = 0 ;
else if ( key > 127 )
key = 0 ;
else if ( key > = ' A ' & & key < = ' Z ' )
2004-08-22 22:29:09 +00:00
key = key - ' A ' + ' a ' ;
break ;
2005-06-15 04:36:20 +00:00
}
2004-08-22 22:29:09 +00:00
2014-03-30 00:39:37 +00:00
if ( unichars )
{
//we got some text, this is fun isn't it?
//the key value itself is sent with the last text char. this avoids multiple presses, and dead keys were already sent.
for ( i = 0 ; i < unichars - 1 ; i + + )
{
IN_KeyEvent ( 0 , pressed , 0 , unichar [ i ] ) ;
}
IN_KeyEvent ( 0 , pressed , key , unichar [ i ] ) ;
}
else
{
//no text available, just do the keypress
IN_KeyEvent ( 0 , pressed , key , 0 ) ;
}
2004-08-22 22:29:09 +00:00
}
static void install_grabs ( void )
{
2017-10-25 08:10:35 +00:00
if ( ! mouse_grabbed )
{
//XGrabPointer can cause alt+tab type shortcuts to be skipped by the window manager. This means we don't want to use it unless we have no choice.
//the grab is purely to constrain the pointer to the window
if ( GrabSuccess ! = x11 . pXGrabPointer ( vid_dpy , DefaultRootWindow ( vid_dpy ) ,
True ,
0 ,
GrabModeAsync , GrabModeAsync ,
vid_window ,
None ,
CurrentTime ) )
2019-09-25 20:23:24 +00:00
{
2017-10-25 08:10:35 +00:00
Con_Printf ( " Pointer grab failed \n " ) ;
2019-09-25 20:23:24 +00:00
return ;
}
Con_DLPrintf ( 2 , " Grabbed mouse \n " ) ;
mouse_grabbed = true ;
2017-10-25 08:10:35 +00:00
if ( x11_input_method = = XIM_DGA )
{
dgam . pXF86DGADirectVideo ( vid_dpy , DefaultScreen ( vid_dpy ) , XF86DGADirectMouse ) ;
}
else
{
x11 . pXWarpPointer ( vid_dpy , None , vid_window ,
0 , 0 , 0 , 0 ,
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
vid . pixelwidth / 2 , vid . pixelheight / 2 ) ;
2017-10-25 08:10:35 +00:00
}
2013-03-12 22:54:12 +00:00
2017-10-25 08:10:35 +00:00
// x11.pXSync(vid_dpy, True);
2008-05-13 11:16:20 +00:00
}
2004-08-22 22:29:09 +00:00
}
static void uninstall_grabs ( void )
{
2017-10-25 08:10:35 +00:00
if ( mouse_grabbed & & vid_dpy )
2011-01-27 01:34:08 +00:00
{
2018-09-23 19:35:24 +00:00
Con_DLPrintf ( 2 , " Releasing mouse grab \n " ) ;
2017-10-25 08:10:35 +00:00
mouse_grabbed = false ;
if ( x11_input_method = = XIM_DGA )
{
dgam . pXF86DGADirectVideo ( vid_dpy , DefaultScreen ( vid_dpy ) , 0 ) ;
}
2004-08-22 22:29:09 +00:00
2013-03-12 23:04:11 +00:00
x11 . pXUngrabPointer ( vid_dpy , CurrentTime ) ;
2004-08-22 22:29:09 +00:00
2017-10-25 08:10:35 +00:00
// x11.pXSync(vid_dpy, True);
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
if ( ! vid . forcecursor )
{
vid . forcecursor = true ;
vid . forcecursorpos [ 0 ] = vid . pixelwidth / 2 ;
vid . forcecursorpos [ 1 ] = vid . pixelheight / 2 ;
}
}
if ( vid . forcecursor )
{
vid . forcecursor = false ;
x11 . pXWarpPointer ( vid_dpy , vid_window , vid_window ,
0 , 0 , vid . pixelwidth , vid . pixelheight ,
vid . forcecursorpos [ 0 ] , vid . forcecursorpos [ 1 ] ) ;
2017-10-25 08:10:35 +00:00
}
}
static void UpdateGrabs ( void )
{
qboolean wantmgrabs , allownullcursor ;
Cursor wantcursor ;
2019-04-15 18:43:42 +00:00
wantmgrabs = ( fullscreenflags & FULLSCREEN_ACTIVE ) | | ! ! in_windowed_mouse . value ;
2017-10-25 08:10:35 +00:00
if ( ! vid . activeapp )
wantmgrabs = false ;
allownullcursor = wantmgrabs ; //this says whether we can possibly want it. if false then we disallow the null cursor. Yes, this might break mods that do their own sw cursors. such mods are flawed in other ways too.
2021-12-20 10:06:43 +00:00
if ( ! vrui . enabled & & Key_MouseShouldBeFree ( ) )
2017-10-25 08:10:35 +00:00
wantmgrabs = false ;
2019-03-01 22:39:30 +00:00
// if (modeswitchpending)
// wantmgrabs = false;
2017-10-25 08:10:35 +00:00
if ( wantmgrabs )
install_grabs ( ) ;
else
uninstall_grabs ( ) ;
if ( mouse_grabbed )
wantcursor = vid_nullcursor ;
else if ( vid_newcursor )
wantcursor = vid_newcursor ;
else if ( ! allownullcursor )
wantcursor = None ;
else
wantcursor = vid_nullcursor ;
if ( wantcursor ! = vid_activecursor )
{
vid_activecursor = wantcursor ;
if ( vid_activecursor )
x11 . pXDefineCursor ( vid_dpy , vid_window , vid_activecursor ) ;
else
x11 . pXUndefineCursor ( vid_dpy , vid_window ) ;
}
2004-08-22 22:29:09 +00:00
}
2013-03-12 22:47:42 +00:00
static void ClearAllStates ( void )
2005-01-24 03:07:16 +00:00
{
int i ;
2005-06-15 04:36:20 +00:00
2005-01-24 03:07:16 +00:00
// send an up event for each key, to make sure the server clears them all
2018-10-11 10:31:23 +00:00
for ( i = 0 ; i < K_MAX ; i + + )
2005-01-24 03:07:16 +00:00
{
2010-08-14 03:17:33 +00:00
Key_Event ( 0 , i , 0 , false ) ;
2005-01-24 03:07:16 +00:00
}
Key_ClearStates ( ) ;
// IN_ClearStates ();
}
2004-08-22 22:29:09 +00:00
static void GetEvent ( void )
{
2013-03-12 22:47:42 +00:00
XEvent event , rep ;
2004-08-22 22:29:09 +00:00
int b ;
2008-02-05 00:38:41 +00:00
qboolean x11violations = true ;
2013-03-12 22:47:42 +00:00
Window mw ;
2014-03-30 08:55:06 +00:00
qboolean filtered = false ;
2004-08-22 22:29:09 +00:00
2013-03-12 23:04:11 +00:00
x11 . pXNextEvent ( vid_dpy , & event ) ;
2004-08-22 22:29:09 +00:00
2014-03-30 00:39:37 +00:00
if ( x11 . dounicode )
2018-11-27 16:48:19 +00:00
{
if ( x11 . pXFilterEvent ( & event , None ) ) //vid_window))
{
if ( vid . ime_allow )
return ;
2014-03-30 08:55:06 +00:00
filtered = true ;
2018-11-27 16:48:19 +00:00
}
}
2014-03-30 00:39:37 +00:00
2013-03-12 22:54:12 +00:00
switch ( event . type )
{
case GenericEvent :
2013-03-12 23:04:11 +00:00
if ( x11 . pXGetEventData ( vid_dpy , & event . xcookie ) )
2013-03-12 22:54:12 +00:00
{
if ( event . xcookie . extension = = xi2 . opcode )
{
switch ( event . xcookie . evtype )
{
case XI_RawButtonPress :
case XI_RawButtonRelease :
2017-10-25 08:10:35 +00:00
if ( mouse_grabbed )
2013-03-12 22:54:12 +00:00
{
XIRawEvent * raw = event . xcookie . data ;
2017-10-25 08:10:35 +00:00
int * qdev = & XI2_GetDeviceInfo ( raw - > sourceid ) - > qdev ;
2013-03-12 22:54:12 +00:00
int button = raw - > detail ; //1-based
2017-10-25 08:10:35 +00:00
if ( raw - > sourceid ! = raw - > deviceid )
return ; //ignore master devices to avoid dupes.
if ( * qdev = = DEVID_UNSET )
* qdev = xi2 . nextqdev + + ;
2013-03-12 22:54:12 +00:00
switch ( button )
{
case 1 : button = K_MOUSE1 ; break ;
case 2 : button = K_MOUSE3 ; break ;
case 3 : button = K_MOUSE2 ; break ;
case 4 : button = K_MWHEELUP ; break ; //so much for 'raw'.
case 5 : button = K_MWHEELDOWN ; break ;
case 6 : button = K_MOUSE4 ; break ;
case 7 : button = K_MOUSE5 ; break ;
case 8 : button = K_MOUSE6 ; break ;
case 9 : button = K_MOUSE7 ; break ;
case 10 : button = K_MOUSE8 ; break ;
case 11 : button = K_MOUSE9 ; break ;
case 12 : button = K_MOUSE10 ; break ;
default : button = 0 ; break ;
}
if ( button )
2019-09-25 20:23:24 +00:00
IN_KeyEvent ( * qdev , ( event . xcookie . evtype = = XI_RawButtonPress ) , button , 0 ) ;
2013-03-12 22:54:12 +00:00
}
break ;
case XI_RawMotion :
2017-10-25 08:10:35 +00:00
if ( mouse_grabbed )
2013-03-12 22:54:12 +00:00
{
XIRawEvent * raw = event . xcookie . data ;
2017-10-25 08:10:35 +00:00
struct xidevinfo * dev = XI2_GetDeviceInfo ( raw - > sourceid ) ;
2013-03-12 22:54:12 +00:00
double * val , * raw_val ;
2017-10-25 08:10:35 +00:00
double axis [ 2 ] = { 0 , 0 } ;
2013-03-12 22:54:12 +00:00
int i ;
2017-10-25 08:10:35 +00:00
if ( raw - > sourceid ! = raw - > deviceid )
return ; //ignore master devices to avoid dupes (we have our own device remapping stuff which should be slightly more friendly).
if ( dev - > qdev = = DEVID_UNSET )
dev - > qdev = xi2 . nextqdev + + ;
2013-03-12 22:54:12 +00:00
val = raw - > valuators . values ;
raw_val = raw - > raw_values ;
2017-10-25 08:10:35 +00:00
if ( dev - > abs )
axis [ 0 ] = axis [ 1 ] = FLT_MIN ;
2013-03-12 22:54:12 +00:00
for ( i = 0 ; i < raw - > valuators . mask_len * 8 ; i + + )
{
if ( XIMaskIsSet ( raw - > valuators . mask , i ) )
{
2017-10-25 08:10:35 +00:00
if ( i = = 0 ) axis [ 0 ] = * raw_val ;
if ( i = = 1 ) axis [ 1 ] = * raw_val ;
2013-03-12 22:54:12 +00:00
val + + ;
raw_val + + ;
}
}
2017-10-25 08:10:35 +00:00
if ( dev - > abs )
{ //tablets use weird 16bit coords or whatever. rescale to window coords (we have grabs, so offscreen stuff shouldn't matter).
for ( i = 0 ; i < 2 ; i + + )
{
if ( axis [ i ] = = FLT_MIN )
axis [ i ] = dev - > axis [ i ] . old ;
dev - > axis [ i ] . old = axis [ i ] ;
axis [ i ] = ( axis [ i ] - dev - > axis [ i ] . min ) / ( dev - > axis [ 1 ] . max + 1 - dev - > axis [ i ] . min ) ;
axis [ i ] * = i ? vid . pixelheight : vid . pixelwidth ;
}
}
IN_MouseMove ( dev - > qdev , dev - > abs , axis [ 0 ] , axis [ 1 ] , 0 , 0 ) ;
2013-03-12 22:54:12 +00:00
}
break ;
default :
Con_Printf ( " Unknown xinput event %u! \n " , event . xcookie . evtype ) ;
break ;
}
}
else
Con_Printf ( " Unknown generic event! \n " ) ;
}
2013-03-12 23:04:11 +00:00
x11 . pXFreeEventData ( vid_dpy , & event . xcookie ) ;
2013-03-12 22:54:12 +00:00
break ;
2004-12-05 08:25:01 +00:00
case ResizeRequest :
2016-07-28 15:57:22 +00:00
# ifdef VKQUAKE
vk . neednewswapchain = true ;
# endif
2009-11-04 21:16:50 +00:00
vid . pixelwidth = event . xresizerequest . width ;
vid . pixelheight = event . xresizerequest . height ;
2014-03-30 08:55:06 +00:00
Cvar_ForceCallback ( & vid_conautoscale ) ;
2013-03-12 22:47:42 +00:00
// if (fullscreenflags & FULLSCREEN_ACTIVE)
2013-03-12 23:04:11 +00:00
// x11.pXMoveWindow(vid_dpy, vid_window, 0, 0);
2004-12-05 08:25:01 +00:00
break ;
case ConfigureNotify :
2013-03-12 22:47:42 +00:00
if ( event . xconfigurerequest . window = = vid_window )
{
2016-07-28 15:57:22 +00:00
# ifdef VKQUAKE
vk . neednewswapchain = true ;
# endif
2013-03-12 22:47:42 +00:00
vid . pixelwidth = event . xconfigurerequest . width ;
vid . pixelheight = event . xconfigurerequest . height ;
2014-03-30 08:55:06 +00:00
Cvar_ForceCallback ( & vid_conautoscale ) ;
2013-03-12 22:47:42 +00:00
}
else if ( event . xconfigurerequest . window = = vid_decoywindow )
{
if ( ! ( fullscreenflags & FULLSCREEN_ACTIVE ) )
2013-03-12 23:04:11 +00:00
x11 . pXResizeWindow ( vid_dpy , vid_window , event . xconfigurerequest . width , event . xconfigurerequest . height ) ;
2013-03-12 22:47:42 +00:00
}
// if (fullscreenflags & FULLSCREEN_ACTIVE)
2013-03-12 23:04:11 +00:00
// x11.pXMoveWindow(vid_dpy, vid_window, 0, 0);
2004-12-05 08:25:01 +00:00
break ;
2004-08-22 22:29:09 +00:00
case KeyPress :
2014-03-30 08:55:06 +00:00
X_KeyEvent ( & event . xkey , true , filtered ) ;
2009-07-07 21:32:54 +00:00
break ;
2004-08-22 22:29:09 +00:00
case KeyRelease :
2020-02-11 03:59:01 +00:00
if ( x11 . pXPending ( vid_dpy ) )
{ //autorepeat is messy - if the next event is a press event for the same key then ignore the release (we still get presses doing their autorepeat thing, just not the releases)
XEvent nextev ;
x11 . pXPeekEvent ( vid_dpy , & nextev ) ; //blocks, so needs XPending
if ( nextev . type = = KeyPress & & nextev . xkey . time = = event . xkey . time & & nextev . xkey . keycode = = event . xkey . keycode )
break ;
}
2014-03-30 08:55:06 +00:00
X_KeyEvent ( & event . xkey , false , filtered ) ;
2004-08-22 22:29:09 +00:00
break ;
case MotionNotify :
2017-10-25 08:10:35 +00:00
if ( x11_input_method = = XIM_DGA & & mouse_grabbed )
2004-08-22 22:29:09 +00:00
{
2017-10-25 08:10:35 +00:00
IN_MouseMove ( x11_mouseqdev , false , event . xmotion . x_root , event . xmotion . y_root , 0 , 0 ) ;
2004-08-22 22:29:09 +00:00
}
else
{
2017-10-25 08:10:35 +00:00
if ( mouse_grabbed )
2004-08-22 22:29:09 +00:00
{
2013-03-12 22:54:12 +00:00
if ( x11_input_method ! = XIM_XI2 )
{
int cx = vid . pixelwidth / 2 , cy = vid . pixelheight / 2 ;
2017-10-25 08:10:35 +00:00
IN_MouseMove ( x11_mouseqdev , false , event . xmotion . x - cx , event . xmotion . y - cy , 0 , 0 ) ;
2013-03-12 22:54:12 +00:00
/* move the mouse to the window center again (disabling warp first so we don't see it*/
2014-03-30 00:39:37 +00:00
x11 . pXSelectInput ( vid_dpy , vid_window , vid_x_eventmask & ~ PointerMotionMask ) ;
2013-03-12 23:04:11 +00:00
x11 . pXWarpPointer ( vid_dpy , None , vid_window , 0 , 0 , 0 , 0 ,
2013-03-12 22:54:12 +00:00
cx , cy ) ;
2014-03-30 00:39:37 +00:00
x11 . pXSelectInput ( vid_dpy , vid_window , vid_x_eventmask ) ;
2013-03-12 22:54:12 +00:00
}
2004-08-22 22:29:09 +00:00
}
2012-10-14 10:57:11 +00:00
else
{
2017-10-25 08:10:35 +00:00
IN_MouseMove ( x11_mouseqdev , true , event . xmotion . x , event . xmotion . y , 0 , 0 ) ;
2012-10-14 10:57:11 +00:00
}
2004-08-22 22:29:09 +00:00
}
break ;
case ButtonPress :
2017-10-25 08:10:35 +00:00
if ( x11_input_method = = XIM_XI2 & & mouse_grabbed )
2013-03-12 22:54:12 +00:00
break ; //no dupes!
2004-08-22 22:29:09 +00:00
b = - 1 ;
if ( event . xbutton . button = = 1 )
2008-02-05 00:38:41 +00:00
b = K_MOUSE1 ;
2004-08-22 22:29:09 +00:00
else if ( event . xbutton . button = = 2 )
2008-02-05 00:38:41 +00:00
b = K_MOUSE3 ;
2004-08-22 22:29:09 +00:00
else if ( event . xbutton . button = = 3 )
2008-02-05 00:38:41 +00:00
b = K_MOUSE2 ;
//note, the x11 protocol does not support a mousewheel
//we only support it because we follow convention. the actual protocol specifies 4+5 as regular buttons
2005-11-21 21:07:45 +00:00
else if ( event . xbutton . button = = 4 )
2008-02-05 00:38:41 +00:00
b = x11violations ? K_MWHEELUP : K_MOUSE4 ;
2005-11-21 21:07:45 +00:00
else if ( event . xbutton . button = = 5 )
2008-02-05 00:38:41 +00:00
b = x11violations ? K_MWHEELDOWN : K_MOUSE5 ;
//note, the x11 protocol does not support more than 5 mouse buttons
//which is a bit of a shame, but hey.
else if ( event . xbutton . button = = 6 )
b = x11violations ? K_MOUSE4 : - 1 ;
else if ( event . xbutton . button = = 7 )
b = x11violations ? K_MOUSE5 : - 1 ;
else if ( event . xbutton . button = = 8 )
b = x11violations ? K_MOUSE6 : - 1 ;
else if ( event . xbutton . button = = 9 )
b = x11violations ? K_MOUSE7 : - 1 ;
else if ( event . xbutton . button = = 10 )
b = x11violations ? K_MOUSE8 : - 1 ;
else if ( event . xbutton . button = = 11 )
b = x11violations ? K_MOUSE9 : - 1 ;
else if ( event . xbutton . button = = 12 )
b = x11violations ? K_MOUSE10 : - 1 ;
2004-08-22 22:29:09 +00:00
if ( b > = 0 )
2017-10-25 08:10:35 +00:00
IN_KeyEvent ( x11_mouseqdev , true , b , 0 ) ;
2013-03-12 22:47:42 +00:00
/*
if ( fullscreenflags & FULLSCREEN_LEGACY )
if ( fullscreenflags & FULLSCREEN_VMODE )
2016-02-10 23:23:43 +00:00
if ( ! vid . activeapp )
2005-11-21 21:07:45 +00:00
{ //KDE doesn't seem to like us, in that you can't alt-tab back or click to activate.
//This allows us to steal input focus back from the window manager
2013-03-12 23:04:11 +00:00
x11 . pXSetInputFocus ( vid_dpy , vid_window , RevertToParent , CurrentTime ) ;
2005-11-21 21:07:45 +00:00
}
2013-03-12 22:47:42 +00:00
*/
2004-08-22 22:29:09 +00:00
break ;
case ButtonRelease :
b = - 1 ;
if ( event . xbutton . button = = 1 )
2008-02-05 00:38:41 +00:00
b = K_MOUSE1 ;
2004-08-22 22:29:09 +00:00
else if ( event . xbutton . button = = 2 )
2008-02-05 00:38:41 +00:00
b = K_MOUSE3 ;
2004-08-22 22:29:09 +00:00
else if ( event . xbutton . button = = 3 )
2008-02-05 00:38:41 +00:00
b = K_MOUSE2 ;
//note, the x11 protocol does not support a mousewheel
//we only support it because we follow convention. the actual protocol specifies 4+5 as regular buttons
2005-11-21 21:07:45 +00:00
else if ( event . xbutton . button = = 4 )
2008-02-05 00:38:41 +00:00
b = x11violations ? K_MWHEELUP : K_MOUSE4 ;
2005-11-21 21:07:45 +00:00
else if ( event . xbutton . button = = 5 )
2008-02-05 00:38:41 +00:00
b = x11violations ? K_MWHEELDOWN : K_MOUSE5 ;
//note, the x11 protocol does not support more than 5 mouse buttons
//which is a bit of a shame, but hey.
else if ( event . xbutton . button = = 6 )
b = x11violations ? K_MOUSE4 : - 1 ;
else if ( event . xbutton . button = = 7 )
b = x11violations ? K_MOUSE5 : - 1 ;
else if ( event . xbutton . button = = 8 )
b = x11violations ? K_MOUSE6 : - 1 ;
else if ( event . xbutton . button = = 9 )
b = x11violations ? K_MOUSE7 : - 1 ;
else if ( event . xbutton . button = = 10 )
b = x11violations ? K_MOUSE8 : - 1 ;
else if ( event . xbutton . button = = 11 )
b = x11violations ? K_MOUSE9 : - 1 ;
else if ( event . xbutton . button = = 12 )
b = x11violations ? K_MOUSE10 : - 1 ;
2004-08-22 22:29:09 +00:00
if ( b > = 0 )
2017-10-25 08:10:35 +00:00
IN_KeyEvent ( x11_mouseqdev , false , b , 0 ) ;
2004-08-22 22:29:09 +00:00
break ;
case FocusIn :
2019-03-12 05:04:27 +00:00
//don't care about it if its just someone wiggling the mouse
if ( event . xfocus . detail = = NotifyPointer )
break ;
2013-03-12 22:47:42 +00:00
//activeapp is if the game window is focused
2016-02-10 23:23:43 +00:00
vid . activeapp = true ;
2018-10-11 10:31:23 +00:00
ClearAllStates ( ) ; //just in case.
2013-03-12 22:47:42 +00:00
//but change modes to track the desktop window
// if (!(fullscreenflags & FULLSCREEN_ACTIVE) || event.xfocus.window != vid_decoywindow)
2005-11-21 21:07:45 +00:00
{
2013-03-12 22:47:42 +00:00
modeswitchpending = 1 ;
modeswitchtime = Sys_Milliseconds ( ) + 1500 ; /*fairly slow, to make sure*/
2019-03-01 22:39:30 +00:00
UpdateGrabs ( ) ;
2005-11-21 21:07:45 +00:00
}
2013-03-12 22:47:42 +00:00
2018-11-27 16:48:19 +00:00
if ( event . xfocus . window = = vid_window )
x11 . ime_shown = - 1 ;
2017-01-15 13:13:09 +00:00
2013-03-12 22:47:42 +00:00
//we we're focusing onto the game window and we're currently fullscreen, hide the other one so alt-tab won't select that instead of a real alternate app.
// if ((fullscreenflags & FULLSCREEN_ACTIVE) && (fullscreenflags & FULLSCREEN_LEGACY) && event.xfocus.window == vid_window)
2013-03-12 23:04:11 +00:00
// x11.pXUnmapWindow(vid_dpy, vid_decoywindow);
2004-08-22 22:29:09 +00:00
break ;
case FocusOut :
2019-03-12 05:04:27 +00:00
//don't care about it if its just someone wiggling the mouse
if ( event . xfocus . detail = = NotifyPointer )
break ;
2013-03-12 22:47:42 +00:00
//if we're already active, the decoy window shouldn't be focused anyway.
2018-11-27 16:48:19 +00:00
if ( event . xfocus . window = = vid_window )
x11 . ime_shown = - 1 ;
2017-01-15 13:13:09 +00:00
2013-03-12 22:47:42 +00:00
if ( ( fullscreenflags & FULLSCREEN_ACTIVE ) & & event . xfocus . window = = vid_decoywindow )
{
break ;
}
2019-03-01 22:39:30 +00:00
# ifdef USE_XRANDR
if ( xrandr . origgamma )
xrandr . pSetCrtcGamma ( vid_dpy , xrandr . crtc , xrandr . origgamma ) ;
# endif
2017-09-02 05:13:33 +00:00
# ifdef USE_VMODE
2013-03-12 22:54:12 +00:00
if ( vm . originalapplied )
2016-07-28 15:57:22 +00:00
vm . pXF86VidModeSetGammaRamp ( vid_dpy , scrnum , vm . originalrampsize , vm . originalramps [ 0 ] , vm . originalramps [ 1 ] , vm . originalramps [ 2 ] ) ;
2017-09-02 05:13:33 +00:00
# endif
2005-11-21 21:07:45 +00:00
2013-03-12 22:47:42 +00:00
mw = vid_window ;
if ( ( fullscreenflags & FULLSCREEN_LEGACY ) & & ( fullscreenflags & FULLSCREEN_ACTIVE ) )
mw = vid_decoywindow ;
2014-09-21 03:35:38 +00:00
if ( event . xfocus . window = = mw | | event . xfocus . window = = vid_window )
2013-03-12 22:47:42 +00:00
{
2016-02-10 23:23:43 +00:00
vid . activeapp = false ;
2017-10-25 08:10:35 +00:00
UpdateGrabs ( ) ;
2013-03-12 22:47:42 +00:00
ClearAllStates ( ) ;
2005-11-21 21:07:45 +00:00
}
2013-03-12 22:47:42 +00:00
modeswitchpending = - 1 ;
modeswitchtime = Sys_Milliseconds ( ) + 100 ; /*fairly fast, so we don't unapply stuff when switching to other progs with delays*/
2011-01-29 19:53:38 +00:00
break ;
case ClientMessage :
{
2013-03-12 23:04:11 +00:00
char * name = x11 . pXGetAtomName ( vid_dpy , event . xclient . message_type ) ;
2011-01-29 19:53:38 +00:00
if ( ! strcmp ( name , " WM_PROTOCOLS " ) & & event . xclient . format = = 32 )
{
2013-03-12 23:04:11 +00:00
char * protname = x11 . pXGetAtomName ( vid_dpy , event . xclient . data . l [ 0 ] ) ;
2011-01-29 19:53:38 +00:00
if ( ! strcmp ( protname , " WM_DELETE_WINDOW " ) )
2013-03-12 22:47:42 +00:00
{
2019-06-17 04:21:41 +00:00
Key_Dest_Remove ( kdm_console ) ;
2018-09-23 19:35:24 +00:00
if ( Cmd_Exists ( " menu_quit " ) | | Cmd_AliasExist ( " menu_quit " , RESTRICT_LOCAL ) )
Cmd_ExecuteString ( " menu_quit prompt " , RESTRICT_LOCAL ) ;
else if ( Cmd_Exists ( " m_quit " ) | | Cmd_AliasExist ( " m_quit " , RESTRICT_LOCAL ) )
Cmd_ExecuteString ( " m_quit " , RESTRICT_LOCAL ) ;
else
Cmd_ExecuteString ( " quit " , RESTRICT_LOCAL ) ;
2013-03-12 23:04:11 +00:00
x11 . pXSetInputFocus ( vid_dpy , vid_window , RevertToParent , CurrentTime ) ;
2013-03-12 22:47:42 +00:00
}
2020-11-04 10:19:30 +00:00
else if ( ! strcmp ( protname , " _NET_WM_PING " ) )
{
event . xclient . window = vid_root ;
x11 . pXSendEvent ( vid_dpy , vid_root , false , SubstructureNotifyMask | SubstructureRedirectMask , & event ) ;
}
2011-01-29 19:53:38 +00:00
else
2017-10-25 08:10:35 +00:00
Con_DPrintf ( " Got unknown x11wm message %s \n " , protname ) ;
2013-03-12 23:04:11 +00:00
x11 . pXFree ( protname ) ;
2011-01-29 19:53:38 +00:00
}
2018-08-23 06:03:31 +00:00
# if 1
else if ( ! strcmp ( name , " XdndEnter " ) & & event . xclient . format = = 32 )
{
//check for text/uri-list
int i ;
2018-10-11 10:31:23 +00:00
x11 . dnd . type = None ;
2018-08-23 06:03:31 +00:00
for ( i = 2 ; i < 2 + 3 ; i + + )
{
if ( event . xclient . data . l [ i ] )
{
char * t = x11 . pXGetAtomName ( vid_dpy , event . xclient . data . l [ i ] ) ;
2018-09-23 19:35:24 +00:00
# ifdef XDS
//direct-save has no way to deal with multiple files, other than lying about it.
//which is unfortunately what other programs do. we have no real way to tell which file(s) actually got dragged/written.
//we would need to report an empty directory, then scan for new files, then wipe the lot recursively.
if ( ! strcmp ( t , " XdndDirectSave0 " ) & & ! x11 . dnd . type ) //single file
x11 . dnd . type = event . xclient . data . l [ i ] ;
# endif
2018-08-23 06:03:31 +00:00
if ( ! strcmp ( t , " text/uri-list " ) ) //file list
x11 . dnd . type = event . xclient . data . l [ i ] ;
2018-09-23 19:35:24 +00:00
// else if (!strcmp(t, "application/octet-stream")) //raw file data without a name.
// x11.dnd.type = event.xclient.data.l[i];
2018-08-23 06:03:31 +00:00
x11 . pXFree ( t ) ;
}
}
}
else if ( ! strcmp ( name , " XdndPosition " ) & & event . xclient . format = = 32 )
{
//Send XdndStatus
XEvent xev ;
memset ( & xev , 0 , sizeof ( xev ) ) ;
xev . type = ClientMessage ;
xev . xclient . window = event . xclient . data . l [ 0 ] ;
xev . xclient . message_type = x11 . pXInternAtom ( vid_dpy , " XdndStatus " , False ) ;
xev . xclient . format = 32 ;
xev . xclient . data . l [ 0 ] = vid_window ; //so source can ignore it if stale
2018-09-23 19:35:24 +00:00
xev . xclient . data . l [ 1 ] = x11 . dnd . type ? 1 : 0 ;
2018-08-23 06:03:31 +00:00
xev . xclient . data . l [ 2 ] = 0 ; //(x<<16)|y (should be in root coords)
xev . xclient . data . l [ 3 ] = 0 ; //(w<<16)|h
xev . xclient . data . l [ 4 ] = x11 . pXInternAtom ( vid_dpy , " XdndActionCopy " , False ) ;
x11 . pXSendEvent ( vid_dpy , xev . xclient . window , False , 0 , & xev ) ;
}
else if ( ! strcmp ( name , " XdndLeave " ) & & event . xclient . format = = 32 )
{
if ( x11 . dnd . source = = event . xclient . data . l [ 0 ] )
{
x11 . dnd . source = None ;
x11 . dnd . type = None ;
}
}
else if ( ! strcmp ( name , " XdndDrop " ) & & event . xclient . format = = 32 )
{
Atom xa_XdndSelection = x11 . pXInternAtom ( vid_dpy , " XdndSelection " , False ) ;
2018-09-23 19:35:24 +00:00
Window source = event . xclient . data . l [ 0 ] ;
2018-08-23 06:03:31 +00:00
Time t = CurrentTime ; //event.xclient.data.l[2];
2018-09-23 19:35:24 +00:00
# ifdef XDS
char * droptype = x11 . dnd . type ? x11 . pXGetAtomName ( vid_dpy , x11 . dnd . type ) : NULL ;
if ( droptype & & ! strcmp ( droptype , " XdndDirectSave0 " ) ) //single file
{
unsigned char * data = NULL ;
Atom type ;
int fmt ;
unsigned long nitems ;
unsigned long bytesleft ;
if ( x11 . pXGetWindowProperty ( vid_dpy , source , x11 . dnd . type , 0 , 65536 , False , AnyPropertyType , & type , & fmt , & nitems , & bytesleft , & data ) = = Success & & data )
{
char hostname [ 1024 ] ;
if ( gethostname ( hostname , sizeof ( hostname ) ) < 0 )
* hostname = 0 ; //failed? o.O
2018-10-11 10:31:23 +00:00
hostname [ sizeof ( hostname ) - 1 ] = 0 ;
2018-09-23 19:35:24 +00:00
char * path = va ( " file://%s/tmp/%s " , hostname , data ) ;
Atom proptype = x11 . pXInternAtom ( vid_dpy , " text/plain " , false ) ;
x11 . pXChangeProperty ( vid_dpy , source , x11 . dnd . type , proptype , 8 , PropModeReplace , ( void * ) path , strlen ( path ) ) ;
Con_Printf ( " Dropping file %s \n " , data ) ;
x11 . pXFree ( data ) ;
}
}
x11 . pXFree ( droptype ) ;
# endif
2018-08-23 06:03:31 +00:00
x11 . dnd . myprop = x11 . pXInternAtom ( vid_dpy , " _FTE_dnd " , False ) ;
2018-09-23 19:35:24 +00:00
if ( x11 . pXGetSelectionOwner ( vid_dpy , xa_XdndSelection ) = = source )
2018-08-23 06:03:31 +00:00
{
x11 . pXDeleteProperty ( vid_dpy , vid_window , x11 . dnd . myprop ) ;
x11 . pXConvertSelection ( vid_dpy , xa_XdndSelection , x11 . dnd . type , x11 . dnd . myprop , vid_window , t ) ;
}
}
# endif
2011-01-29 19:53:38 +00:00
else
2017-10-25 08:10:35 +00:00
Con_DPrintf ( " Got unknown x11 message %s \n " , name ) ;
2013-03-12 23:04:11 +00:00
x11 . pXFree ( name ) ;
2011-01-29 19:53:38 +00:00
}
break ;
2013-03-12 22:47:42 +00:00
# if 1
2018-08-23 06:03:31 +00:00
case SelectionNotify :
2018-10-11 10:31:23 +00:00
//for paste
if ( X11_Clipboard_Notify ( & event . xselection ) )
;
2018-08-23 06:03:31 +00:00
//for drag-n-drop
2018-10-11 10:31:23 +00:00
else if ( event . xselection . selection = = x11 . pXInternAtom ( vid_dpy , " XdndSelection " , False ) & & x11 . dnd . myprop ! = None )
2018-08-23 06:03:31 +00:00
{
qboolean okay = false ;
unsigned char * data ;
Atom type ;
int fmt ;
unsigned long nitems ;
unsigned long bytesleft ;
if ( x11 . pXGetWindowProperty ( vid_dpy , vid_window , x11 . dnd . myprop , 0 , 65536 , False , AnyPropertyType , & type , & fmt , & nitems , & bytesleft , & data ) = = Success & & data )
{
2018-09-23 19:35:24 +00:00
char * tname = x11 . pXGetAtomName ( vid_dpy , x11 . dnd . type ) ;
if ( type = = x11 . dnd . type & & ! strcmp ( tname , " text/uri-list " ) )
2018-08-23 06:03:31 +00:00
{
char * start , * end ;
for ( start = data ; * start ; )
{
for ( end = start ; * end & & * end ! = ' \r ' ; end + + )
;
if ( end ! = start )
Host_RunFile ( start , end - start , NULL ) ;
start = end ;
while ( * start = = ' \r ' | | * start = = ' \n ' )
start + + ;
}
okay = true ;
}
2018-09-23 19:35:24 +00:00
# ifdef XDS
else if ( type = = x11 . dnd . type & & ! strcmp ( tname , " XdndDirectSave0 " ) & & nitems = = 1 )
{
switch ( data [ 0 ] )
{
case ' S ' : //sender wrote the file
case ' E ' : //sender failed to generate the data or something
case ' F ' : //sender failed to write the file. we should use application/octet-stream and write it ourself.
}
}
# endif
x11 . pXFree ( tname ) ;
x11 . pXFree ( data ) ;
2018-08-23 06:03:31 +00:00
}
x11 . pXDeleteProperty ( vid_dpy , vid_window , x11 . dnd . myprop ) ; //might be large, so don't force it to hang around.
//Send XdndFinished now
2018-10-11 10:31:23 +00:00
{
XEvent xev ;
memset ( & xev , 0 , sizeof ( xev ) ) ;
xev . type = ClientMessage ;
xev . xclient . window = x11 . dnd . source ;
xev . xclient . message_type = x11 . pXInternAtom ( vid_dpy , " XdndFinished " , False ) ;
xev . xclient . format = 32 ;
xev . xclient . data . l [ 0 ] = vid_window ; //so source can ignore it if stale
xev . xclient . data . l [ 1 ] = ( okay ? 1 : 0 ) ;
xev . xclient . data . l [ 2 ] = x11 . pXInternAtom ( vid_dpy , " XdndActionCopy " , False ) ;
x11 . pXSendEvent ( vid_dpy , xev . xclient . window , False , 0 , & xev ) ;
}
2018-08-23 06:03:31 +00:00
}
break ;
case SelectionRequest : //needed for when another program tries pasting.
2004-08-22 22:29:09 +00:00
{
2018-08-23 06:03:31 +00:00
Atom xa_u8string = x11 . pXInternAtom ( vid_dpy , " UTF8_STRING " , false ) ; //explicitly UTF-8
Atom xa_l1string = x11 . pXInternAtom ( vid_dpy , " STRING " , false ) ; //explicitly 8859-1
Atom xa_text = x11 . pXInternAtom ( vid_dpy , " TEXT " , false ) ; //selection owner decides encoding (and we pick UTF-8)
Atom xa_targets = x11 . pXInternAtom ( vid_dpy , " TARGETS " , false ) ;
Atom xa_supportedtargets [ ] = { xa_u8string , xa_l1string , xa_text , xa_targets /*, xa_multiple, xa_timestamp*/ } ;
2018-10-14 16:16:34 +00:00
char * cliptext = NULL ;
2013-03-12 22:47:42 +00:00
memset ( & rep , 0 , sizeof ( rep ) ) ;
2018-08-23 06:03:31 +00:00
2018-10-14 16:16:34 +00:00
if ( event . xselectionrequest . selection = = x11 . pXInternAtom ( vid_dpy , " PRIMARY " , false ) )
cliptext = clipboard_buffer [ CBT_SELECTION ] ;
else if ( event . xselectionrequest . selection = = x11 . pXInternAtom ( vid_dpy , " CLIPBOARD " , false ) )
cliptext = clipboard_buffer [ CBT_CLIPBOARD ] ;
if ( ! cliptext ) //err, nothing in the clipboard buffer... that's not meant to happen.
cliptext = " " ;
if ( event . xselectionrequest . property = = None ) //no property sets a property matching the target atom, as a fallback.
event . xselectionrequest . property = event . xselectionrequest . target ;
2013-03-12 22:47:42 +00:00
if ( event . xselectionrequest . property = = None )
2013-03-12 23:04:11 +00:00
event . xselectionrequest . property = x11 . pXInternAtom ( vid_dpy , " foobar2000 " , false ) ;
2018-08-23 06:03:31 +00:00
if ( event . xselectionrequest . property ! = None & & event . xselectionrequest . target = = xa_targets )
{ //TARGETS results in a list of accepted target types (atoms)
x11 . pXChangeProperty ( vid_dpy , event . xselectionrequest . requestor , event . xselectionrequest . property , event . xselectionrequest . target , 32 , PropModeReplace , ( void * ) xa_supportedtargets , countof ( xa_supportedtargets ) ) ;
rep . xselection . property = event . xselectionrequest . property ;
}
else if ( event . xselectionrequest . property ! = None & & ( event . xselectionrequest . target = = xa_u8string | | event . xselectionrequest . target = = xa_text ) )
{ //UTF8_STRING or TEXT (which we choose to use utf-8 as our charset)
2018-10-14 16:16:34 +00:00
x11 . pXChangeProperty ( vid_dpy , event . xselectionrequest . requestor , event . xselectionrequest . property , event . xselectionrequest . target , 8 , PropModeReplace , ( void * ) cliptext , strlen ( cliptext ) ) ;
2013-03-12 22:47:42 +00:00
rep . xselection . property = event . xselectionrequest . property ;
}
2018-08-23 06:03:31 +00:00
else if ( event . xselectionrequest . property ! = None & & event . xselectionrequest . target = = xa_l1string )
{ //STRING == latin1. convert as needed.
2018-10-14 16:16:34 +00:00
char * latin1 = alloca ( strlen ( cliptext ) + 1 ) ; //may shorten
2018-11-27 16:48:19 +00:00
const char * in = cliptext ;
2018-08-23 06:03:31 +00:00
int c = 0 ;
int err ;
while ( * in & & c < sizeof ( latin1 ) )
{
2018-10-14 16:16:34 +00:00
int uc = utf8_decode ( & err , in , & in ) ;
2018-08-23 06:03:31 +00:00
if ( ( uc > = 0xe000 & & uc < = 0xe100 ) & & ( uc & 0x7f ) > = 32 )
uc = uc & 0x7f ; //don't do c0/c1 glyphs. otherwise treat as ascii.
else if ( uc > 255 | | err )
uc = ' ? ' ; //unsupported char
latin1 [ c + + ] = uc ;
}
x11 . pXChangeProperty ( vid_dpy , event . xselectionrequest . requestor , event . xselectionrequest . property , event . xselectionrequest . target , 8 , PropModeReplace , ( void * ) latin1 , c ) ;
rep . xselection . property = event . xselectionrequest . property ;
}
2013-03-12 22:47:42 +00:00
else
2018-08-23 06:03:31 +00:00
{ //unsupported target. we need to let them know that we don't know what they're asking for.
2013-03-12 22:47:42 +00:00
rep . xselection . property = None ;
}
rep . xselection . type = SelectionNotify ;
rep . xselection . serial = 0 ;
rep . xselection . send_event = true ;
rep . xselection . display = rep . xselection . display ;
rep . xselection . requestor = event . xselectionrequest . requestor ;
rep . xselection . selection = event . xselectionrequest . selection ;
rep . xselection . target = event . xselectionrequest . target ;
rep . xselection . time = event . xselectionrequest . time ;
2013-03-12 23:04:11 +00:00
x11 . pXSendEvent ( vid_dpy , event . xselectionrequest . requestor , 0 , 0 , & rep ) ;
2004-08-22 22:29:09 +00:00
}
2013-03-12 22:47:42 +00:00
break ;
# endif
default :
// Con_Printf("%x\n", event.type);
break ;
2004-08-22 22:29:09 +00:00
}
}
2018-10-11 10:31:23 +00:00
static void GLVID_Shutdown ( void )
2004-08-22 22:29:09 +00:00
{
2011-09-05 01:48:23 +00:00
if ( ! vid_dpy )
2004-08-22 22:29:09 +00:00
return ;
2017-10-25 08:10:35 +00:00
vid_activecursor = None ;
vid_newcursor = None ;
2013-03-12 23:04:11 +00:00
x11 . pXUngrabKeyboard ( vid_dpy , CurrentTime ) ;
2017-10-25 08:10:35 +00:00
uninstall_grabs ( ) ;
2004-08-22 22:29:09 +00:00
2017-09-02 05:13:33 +00:00
# ifdef USE_VMODE
2013-03-12 22:54:12 +00:00
if ( vm . originalapplied )
2016-07-28 15:57:22 +00:00
vm . pXF86VidModeSetGammaRamp ( vid_dpy , scrnum , vm . originalrampsize , vm . originalramps [ 0 ] , vm . originalramps [ 1 ] , vm . originalramps [ 2 ] ) ;
2017-09-02 05:13:33 +00:00
# endif
2013-03-12 22:49:04 +00:00
2014-03-30 00:39:37 +00:00
X_ShutdownUnicode ( ) ;
2013-03-12 22:49:04 +00:00
switch ( currentpsl )
{
2016-07-12 00:40:13 +00:00
# ifdef GLQUAKE
2013-03-12 22:49:04 +00:00
# ifdef USE_EGL
case PSL_EGL :
EGL_Shutdown ( ) ;
2018-04-27 16:40:50 +00:00
GL_ForgetPointers ( ) ;
2013-03-12 22:49:04 +00:00
break ;
# endif
case PSL_GLX :
if ( ctx )
{
2018-03-04 14:41:16 +00:00
glx . DestroyContext ( vid_dpy , ctx ) ;
2013-03-12 22:49:04 +00:00
ctx = NULL ;
}
2018-04-27 16:40:50 +00:00
GL_ForgetPointers ( ) ;
2013-03-12 22:49:04 +00:00
break ;
2016-07-12 00:40:13 +00:00
# endif
# ifdef VKQUAKE
case PSL_VULKAN :
VK_Shutdown ( ) ;
break ;
# endif
2013-03-12 22:49:04 +00:00
case PSL_NONE :
break ;
}
2017-09-02 05:13:33 +00:00
# ifdef USE_XRANDR
XRandR_Shutdown ( ) ;
# endif
2004-08-22 22:29:09 +00:00
if ( vid_window )
2013-03-12 23:04:11 +00:00
x11 . pXDestroyWindow ( vid_dpy , vid_window ) ;
2017-09-02 05:13:33 +00:00
if ( vid_decoywindow )
x11 . pXDestroyWindow ( vid_dpy , vid_decoywindow ) ;
2012-10-14 10:57:11 +00:00
if ( vid_nullcursor )
2013-03-12 23:04:11 +00:00
x11 . pXFreeCursor ( vid_dpy , vid_nullcursor ) ;
2013-03-12 22:47:42 +00:00
if ( vid_dpy )
{
2017-09-02 05:13:33 +00:00
# ifdef USE_VMODE
2013-03-12 22:47:42 +00:00
if ( fullscreenflags & FULLSCREEN_VMODEACTIVE )
2013-03-12 22:54:12 +00:00
vm . pXF86VidModeSwitchToMode ( vid_dpy , scrnum , vm . modes [ 0 ] ) ;
2013-03-12 22:47:42 +00:00
fullscreenflags & = ~ FULLSCREEN_VMODEACTIVE ;
2011-01-30 01:32:30 +00:00
2013-03-12 22:54:12 +00:00
if ( vm . modes )
2013-03-12 23:04:11 +00:00
x11 . pXFree ( vm . modes ) ;
2013-03-12 22:54:12 +00:00
vm . modes = NULL ;
vm . num_modes = 0 ;
2017-09-02 05:13:33 +00:00
# endif
2020-08-13 08:39:48 +00:00
x11 . pXCloseDisplay ( vid_dpy ) ;
2004-08-22 22:29:09 +00:00
}
2005-12-05 21:22:36 +00:00
vid_dpy = NULL ;
2004-08-22 22:29:09 +00:00
vid_window = ( Window ) NULL ;
2020-08-13 08:39:48 +00:00
switch ( currentpsl )
{
# ifdef GLQUAKE
# ifdef USE_EGL
case PSL_EGL :
EGL_UnloadLibrary ( ) ;
break ;
# endif
# endif
default :
break ;
}
2013-03-12 22:49:04 +00:00
currentpsl = PSL_NONE ;
2004-08-22 22:29:09 +00:00
}
void GLVID_DeInit ( void ) //FIXME:....
{
GLVID_Shutdown ( ) ;
}
static Cursor CreateNullCursor ( Display * display , Window root )
{
2014-03-30 08:55:06 +00:00
Pixmap cursormask ;
XGCValues xgc ;
GC gc ;
2019-07-29 05:28:20 +00:00
XColor dummycolour = { 0 } ;
2014-03-30 08:55:06 +00:00
Cursor cursor ;
cursormask = x11 . pXCreatePixmap ( display , root , 1 , 1 , 1 /*depth*/ ) ;
xgc . function = GXclear ;
gc = x11 . pXCreateGC ( display , cursormask , GCFunction , & xgc ) ;
x11 . pXFillRectangle ( display , cursormask , gc , 0 , 0 , 1 , 1 ) ;
dummycolour . flags = 04 ;
cursor = x11 . pXCreatePixmapCursor ( display , cursormask , cursormask ,
& dummycolour , & dummycolour , 0 , 0 ) ;
x11 . pXFreePixmap ( display , cursormask ) ;
x11 . pXFreeGC ( display , gc ) ;
return cursor ;
2004-08-22 22:29:09 +00:00
}
2018-08-23 07:04:55 +00:00
# ifndef NO_X11_CURSOR
2017-10-25 08:10:35 +00:00
# include <X11/Xcursor/Xcursor.h>
static struct
{
void * lib ;
XcursorBool ( * SupportsARGB ) ( Display * dpy ) ;
XcursorImage * ( * ImageCreate ) ( int width , int height ) ;
Cursor ( * ImageLoadCursor ) ( Display * dpy , const XcursorImage * image ) ;
void ( * ImageDestroy ) ( XcursorImage * image ) ;
} xcursor ;
2019-07-16 02:59:12 +00:00
static void * X11VID_CreateCursorRGBA ( const qbyte * rgbacursor , uploadfmt_t format , size_t w , size_t h , float hotx , float hoty )
2017-10-25 08:10:35 +00:00
{
Cursor * cursor ;
size_t x , y ;
XcursorImage * img ;
XcursorPixel * dest ;
img = xcursor . ImageCreate ( w , h ) ;
img - > xhot = hotx ;
img - > yhot = hoty ;
dest = img - > pixels ;
2019-07-16 02:59:12 +00:00
switch ( format )
{
case PTI_BGRA8 :
case PTI_BGRX8 :
for ( y = 0 ; y < h ; y + + )
for ( x = 0 ; x < w ; x + + , rgbacursor + = 4 )
* dest + + = ( rgbacursor [ 3 ] < < 24 ) | ( rgbacursor [ 2 ] < < 16 ) | ( rgbacursor [ 1 ] < < 8 ) | ( rgbacursor [ 0 ] < < 0 ) ; //0xARGB
break ; //supported...
case PTI_RGBA8 :
case PTI_RGBX8 :
case PTI_LLLA8 :
case PTI_LLLX8 :
for ( y = 0 ; y < h ; y + + )
for ( x = 0 ; x < w ; x + + , rgbacursor + = 4 )
* dest + + = ( rgbacursor [ 3 ] < < 24 ) | ( rgbacursor [ 0 ] < < 16 ) | ( rgbacursor [ 1 ] < < 8 ) | ( rgbacursor [ 2 ] < < 0 ) ; //0xARGB
break ;
default :
//panic... format wasn't supported. I hope we didn't spend ages resampling it...
xcursor . ImageDestroy ( img ) ;
return NULL ;
}
2017-10-25 08:10:35 +00:00
cursor = Z_Malloc ( sizeof ( * cursor ) ) ;
* cursor = xcursor . ImageLoadCursor ( vid_dpy , img ) ;
xcursor . ImageDestroy ( img ) ;
if ( * cursor )
return ( void * ) cursor ;
Z_Free ( cursor ) ;
return NULL ;
}
2018-10-23 07:09:06 +00:00
static void * X11VID_CreateCursor ( const qbyte * imagedata , int width , int height , uploadfmt_t format , float hotx , float hoty , float scale )
2017-10-25 08:10:35 +00:00
{
void * r ;
2018-10-23 07:09:06 +00:00
if ( ! imagedata )
2017-10-25 08:10:35 +00:00
return NULL ;
if ( scale ! = 1 )
{
int nw , nh ;
qbyte * nd ;
2021-08-23 06:37:21 +00:00
for ( ; ; )
{
nw = width * scale ;
nh = height * scale ;
if ( nw < = 0 | | nh < = 0 | | nw > 128 | | nh > 128 ) //don't go crazy.
return NULL ;
if ( nw < 8 )
scale = 8 / width ;
else if ( nh < 8 )
scale = 8 / height ;
else
break ;
}
2019-07-16 02:59:12 +00:00
nd = Image_ResampleTexture ( format , imagedata , width , height , NULL , nw , nh ) ;
if ( ! nd )
return NULL ; //resampling of that format didn't work for some reason...
2017-10-25 08:10:35 +00:00
width = nw ;
height = nh ;
2019-07-16 02:59:12 +00:00
r = X11VID_CreateCursorRGBA ( nd , format , width , height , hotx , hoty ) ;
2018-10-23 07:09:06 +00:00
BZ_Free ( nd ) ;
2017-10-25 08:10:35 +00:00
}
2018-10-23 07:09:06 +00:00
else
2019-07-16 02:59:12 +00:00
r = X11VID_CreateCursorRGBA ( imagedata , format , width , height , hotx , hoty ) ;
2017-10-25 08:10:35 +00:00
return r ;
}
static void X11VID_DestroyCursor ( void * qcursor )
{
Cursor c = * ( Cursor * ) qcursor ;
if ( vid_newcursor = = c )
vid_newcursor = None ;
if ( vid_dpy )
x11 . pXFreeCursor ( vid_dpy , c ) ;
Z_Free ( qcursor ) ;
}
static qboolean X11VID_SetCursor ( void * qcursor )
{
2018-09-29 17:31:58 +00:00
if ( qcursor )
vid_newcursor = * ( Cursor * ) qcursor ;
else
vid_newcursor = None ;
2017-10-25 08:10:35 +00:00
if ( vid_dpy )
UpdateGrabs ( ) ;
return true ;
}
static qboolean XCursor_Init ( void )
{
static dllfunction_t xcursor_functable [ ] =
{
{ ( void * * ) & xcursor . SupportsARGB , " XcursorSupportsARGB " } ,
{ ( void * * ) & xcursor . ImageCreate , " XcursorImageCreate " } ,
{ ( void * * ) & xcursor . ImageLoadCursor , " XcursorImageLoadCursor " } ,
{ ( void * * ) & xcursor . ImageDestroy , " XcursorImageDestroy " } ,
{ NULL , NULL }
} ;
qboolean defaulthwcursor = true ;
2017-10-31 22:52:58 +00:00
# ifdef GLQUAKE
if ( qrenderer = = QR_OPENGL & & ! strcmp ( gl_vendor , " Humper " ) & & ! strcmp ( gl_renderer , " Chromium " ) )
2017-10-25 08:10:35 +00:00
{ //I don't really understand the significance of these two values, but we get them when running inside VirtualBox
//in such cases, the opengl window has a nasty habit of appearing top-most, even above mouse cursors...
//so we NEED to disable hardware cursors by default in this case, because otherwise we won't see any
//(the cursor should be visible with mouse integration enabled, but then XWarpPointer fails without error. unplayable both ways to some extent)
Con_Printf ( " VirtualBox Detected: OpenGL obscures hardware cursors. seta x11_allow_xcursor 1 to ignore. \n " ) ;
defaulthwcursor = false ;
}
2017-10-31 22:52:58 +00:00
# endif
2017-10-25 08:10:35 +00:00
//in case they were previously set...
rf - > VID_CreateCursor = NULL ;
rf - > VID_DestroyCursor = NULL ;
rf - > VID_SetCursor = NULL ;
if ( ! X11_CheckFeature ( " xcursor " , defaulthwcursor ) )
{
Con_Printf ( " Hardware cursors disabled. \n " ) ;
return false ;
}
if ( ! xcursor . lib )
{
# ifdef __CYGWIN__
if ( ! xcursor . lib )
xcursor . lib = Sys_LoadLibrary ( " cygXcursor.dll " , xcursor_functable ) ;
# endif
if ( ! xcursor . lib )
xcursor . lib = Sys_LoadLibrary ( " libXcursor.so.1 " , xcursor_functable ) ;
if ( ! xcursor . lib )
xcursor . lib = Sys_LoadLibrary ( " libXcursor.so " , xcursor_functable ) ;
if ( ! xcursor . lib )
Con_Printf ( " Xcursor library not available or too old. \n " ) ;
}
if ( xcursor . lib )
{
if ( xcursor . SupportsARGB ( vid_dpy ) )
{ //okay, we should be able to use argb hardware cursors, so set up our public function pointers
rf - > VID_CreateCursor = X11VID_CreateCursor ;
rf - > VID_DestroyCursor = X11VID_DestroyCursor ;
rf - > VID_SetCursor = X11VID_SetCursor ;
return true ;
}
}
Con_Printf ( " Hardware cursors unsupported. \n " ) ;
return false ;
}
2018-08-23 07:04:55 +00:00
# else
static qboolean XCursor_Init ( void )
{
2020-09-08 05:11:09 +00:00
return false ;
2018-08-23 07:04:55 +00:00
}
# endif
2017-10-25 08:10:35 +00:00
2016-07-28 15:57:22 +00:00
qboolean GLVID_ApplyGammaRamps ( unsigned int rampcount , unsigned short * ramps )
2004-08-22 22:29:09 +00:00
{
2005-01-24 03:07:16 +00:00
extern qboolean gammaworks ;
2017-09-02 05:13:33 +00:00
if ( ramps )
2005-01-24 03:07:16 +00:00
{
2017-08-29 02:29:06 +00:00
switch ( vid_hardwaregamma . ival )
{
case 0 : //never use hardware/glsl gamma
case 2 : //ALWAYS use glsl gamma
return false ;
default :
case 1 : //no hardware gamma when windowed
if ( ! ( fullscreenflags & FULLSCREEN_ACTIVE ) )
return false ;
break ;
case 3 : //ALWAYS try to use hardware gamma, even when it fails...
break ;
}
2017-09-02 05:13:33 +00:00
}
2019-03-01 22:39:30 +00:00
# ifdef USE_XRANDR
if ( xrandr . origgamma )
{ //we favour xrandr - xf86 gamma seems to cache old values which screws up gamma after having previously quit ezquake.
if ( ramps & & rampcount = = xrandr . origgamma - > size )
{
XRRCrtcGamma g ;
g . size = rampcount ;
g . red = & ramps [ 0 ] ;
g . green = & ramps [ rampcount ] ;
g . blue = & ramps [ rampcount * 2 ] ;
if ( vid . activeapp )
{
if ( gammaworks )
xrandr . pSetCrtcGamma ( vid_dpy , xrandr . crtc , & g ) ;
gammaworks = true ;
return gammaworks ;
}
return false ;
}
else if ( gammaworks )
{
xrandr . pSetCrtcGamma ( vid_dpy , xrandr . crtc , xrandr . origgamma ) ;
return true ;
}
}
# endif
2017-09-02 05:13:33 +00:00
# ifdef USE_VMODE
//if we don't know the original ramps yet, don't allow changing them, because we're probably invalid anyway, and even if it worked, it'll break something later.
if ( vm . originalapplied )
{
2013-05-13 13:43:18 +00:00
2017-09-02 05:13:33 +00:00
if ( ramps & & rampcount = = vm . originalrampsize )
2017-08-29 02:29:06 +00:00
{
2017-09-02 05:13:33 +00:00
if ( vid . activeapp )
{
if ( gammaworks )
vm . pXF86VidModeSetGammaRamp ( vid_dpy , scrnum , rampcount , & ramps [ 0 ] , & ramps [ rampcount ] , & ramps [ rampcount * 2 ] ) ;
else
gammaworks = ! ! vm . pXF86VidModeSetGammaRamp ( vid_dpy , scrnum , rampcount , & ramps [ 0 ] , & ramps [ rampcount ] , & ramps [ rampcount * 2 ] ) ;
return gammaworks ;
}
return false ;
}
else if ( gammaworks )
{
vm . pXF86VidModeSetGammaRamp ( vid_dpy , scrnum , vm . originalrampsize , vm . originalramps [ 0 ] , vm . originalramps [ 1 ] , vm . originalramps [ 2 ] ) ;
return true ;
2017-08-29 02:29:06 +00:00
}
2004-08-22 22:29:09 +00:00
}
2017-09-02 05:13:33 +00:00
# endif
2017-08-29 02:29:06 +00:00
return false ;
2004-08-22 22:29:09 +00:00
}
2014-03-30 00:39:37 +00:00
void GLVID_SwapBuffers ( void )
2004-08-22 22:29:09 +00:00
{
2013-03-12 22:49:04 +00:00
switch ( currentpsl )
{
2016-07-12 00:40:13 +00:00
# ifdef GLQUAKE
2011-02-06 20:56:39 +00:00
# ifdef USE_EGL
2013-03-12 22:49:04 +00:00
case PSL_EGL :
2018-03-24 04:02:09 +00:00
EGL_SwapBuffers ( ) ;
2013-03-12 22:49:04 +00:00
break ;
2011-02-06 20:56:39 +00:00
# endif
2013-03-12 22:49:04 +00:00
case PSL_GLX :
2018-03-24 04:02:09 +00:00
{
int n = vid_vsync . ival ;
if ( cls . timedemo & & cls . demoplayback )
n = 0 ;
2019-01-13 16:51:50 +00:00
if ( ! glx . swaptear )
n = abs ( n ) ;
2018-03-24 04:02:09 +00:00
if ( glx . swapint ! = n )
{
glx . swapint = n ;
2019-01-13 16:51:50 +00:00
if ( glx . SwapIntervalEXT )
{
glx . SwapIntervalEXT ( vid_dpy , vid_window , glx . swapint ) ;
Con_DPrintf ( " Swap interval changed to %i \n " , glx . swapint ) ;
}
else if ( glx . SwapIntervalMESA & & glx . swapint > = 0 )
{
glx . SwapIntervalMESA ( glx . swapint ) ;
Con_DPrintf ( " Swap interval changed to %i \n " , glx . swapint ) ;
}
else if ( glx . SwapIntervalSGI & & glx . swapint > 0 )
2018-03-24 04:02:09 +00:00
{
2019-01-13 16:51:50 +00:00
glx . SwapIntervalSGI ( glx . swapint ) ;
Con_DPrintf ( " Swap interval changed to %i \n " , glx . swapint ) ;
2018-03-24 04:02:09 +00:00
}
2019-01-13 16:51:50 +00:00
else
Con_Printf ( " Unable to change swap interval to %i \n " , glx . swapint ) ;
2018-03-24 04:02:09 +00:00
}
}
2013-03-12 22:49:04 +00:00
//we don't need to flush, XSawpBuffers does it for us.
//chances are, it's version is more suitable anyway. At least there's the chance that it might be.
2018-03-04 14:41:16 +00:00
glx . SwapBuffers ( vid_dpy , vid_window ) ;
2013-03-12 22:49:04 +00:00
break ;
2016-07-12 00:40:13 +00:00
# endif
# ifdef VKQUAKE
case PSL_VULKAN :
break ;
# endif
2014-03-30 08:55:06 +00:00
default :
case PSL_NONE :
break ;
2013-03-12 22:49:04 +00:00
}
2004-08-22 22:29:09 +00:00
}
2018-05-28 10:12:10 +00:00
# include "fte_eukara64.h"
//#include "bymorphed.h"
2018-10-11 10:31:23 +00:00
static void X_StoreIcon ( Window wnd )
2013-03-12 22:47:42 +00:00
{
int i ;
2013-03-12 23:04:11 +00:00
Atom propname = x11 . pXInternAtom ( vid_dpy , " _NET_WM_ICON " , false ) ;
Atom proptype = x11 . pXInternAtom ( vid_dpy , " CARDINAL " , false ) ;
2013-03-12 22:47:42 +00:00
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
size_t filesize = 0 ;
2018-03-04 14:41:16 +00:00
qbyte * filedata = NULL ;
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
# ifdef IMAGEFMT_PNG
2018-03-04 14:41:16 +00:00
if ( ! filedata )
filedata = FS_LoadMallocFile ( " icon.png " , & filesize ) ;
# endif
if ( ! filedata )
filedata = FS_LoadMallocFile ( " icon.tga " , & filesize ) ;
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
# ifdef IMAGEFMT_JPG
2016-12-13 11:50:15 +00:00
if ( ! filedata )
2018-03-04 14:41:16 +00:00
filedata = FS_LoadMallocFile ( " icon.jpg " , & filesize ) ;
# endif
2019-01-29 07:18:07 +00:00
# ifdef IMAGEFMT_BMP
2016-12-13 11:50:15 +00:00
if ( ! filedata )
2018-03-04 14:41:16 +00:00
filedata = FS_LoadMallocFile ( " icon.ico " , & filesize ) ;
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
# endif
# ifdef HAVE_LEGACY
if ( ! filedata )
filedata = FS_LoadMallocFile ( " darkplaces-icon.tga " , & filesize ) ;
2019-01-29 07:18:07 +00:00
# endif
2016-12-13 11:50:15 +00:00
if ( filedata )
{
int imagewidth , imageheight ;
2019-01-29 07:18:07 +00:00
unsigned long * iconblob ; //yes, long, even on 64bit machines. and even when we claim it to be 32bit. xlib legacy cruft that'll get stripped...
2018-09-29 17:31:58 +00:00
uploadfmt_t format ;
qbyte * imagedata = ReadRawImageFile ( filedata , filesize , & imagewidth , & imageheight , & format , true , " icon.png " ) ;
2016-12-13 11:50:15 +00:00
Z_Free ( filedata ) ;
2019-01-29 07:18:07 +00:00
if ( imagedata )
{
iconblob = BZ_Malloc ( sizeof ( * iconblob ) * ( 2 + imagewidth * imageheight ) ) ;
iconblob [ 0 ] = imagewidth ;
iconblob [ 1 ] = imageheight ;
//needs to be 0xARGB, rather than RGBA bytes
for ( i = 0 ; i < imagewidth * imageheight ; i + + )
iconblob [ i + 2 ] = ( imagedata [ i * 4 + 3 ] < < 24 ) | ( imagedata [ i * 4 + 0 ] < < 16 ) | ( imagedata [ i * 4 + 1 ] < < 8 ) | ( imagedata [ i * 4 + 2 ] < < 0 ) ;
Z_Free ( imagedata ) ;
2016-12-13 11:50:15 +00:00
2019-01-29 07:18:07 +00:00
x11 . pXChangeProperty ( vid_dpy , wnd , propname , proptype , 32 , PropModeReplace , ( void * ) iconblob , 2 + imagewidth * imageheight ) ;
BZ_Free ( iconblob ) ;
return ;
}
2016-12-13 11:50:15 +00:00
}
2019-01-29 07:18:07 +00:00
2016-12-13 11:50:15 +00:00
{
//fall back to the embedded icon.
unsigned long data [ 64 * 64 + 2 ] ;
data [ 0 ] = icon . width ;
data [ 1 ] = icon . height ;
2019-01-27 03:52:14 +00:00
/* GIMP exports dumps as RGBA only, so we have to convert them too - eukara */
2016-12-13 11:50:15 +00:00
for ( i = 0 ; i < data [ 0 ] * data [ 1 ] ; i + + )
2019-01-27 03:52:14 +00:00
data [ i + 2 ] = ( icon . pixel_data [ i * 4 + 3 ] < < 24 ) | ( icon . pixel_data [ i * 4 + 0 ] < < 16 ) | ( icon . pixel_data [ i * 4 + 1 ] < < 8 ) | ( icon . pixel_data [ i * 4 + 2 ] < < 0 ) ;
2016-12-13 11:50:15 +00:00
x11 . pXChangeProperty ( vid_dpy , wnd , propname , proptype , 32 , PropModeReplace , ( void * ) data , data [ 0 ] * data [ 1 ] + 2 ) ;
}
2013-03-12 22:47:42 +00:00
}
2020-11-04 10:19:30 +00:00
static void X_StorePID ( Window wnd )
{
Atom net_wm_pid = x11 . pXInternAtom ( vid_dpy , " _NET_WM_PID " , false ) ;
Atom wm_client_machine = x11 . pXInternAtom ( vid_dpy , " WM_CLIENT_MACHINE " , false ) ;
Atom cardinal = x11 . pXInternAtom ( vid_dpy , " CARDINAL " , false ) ;
Atom string = x11 . pXInternAtom ( vid_dpy , " STRING " , false ) ;
long pid = getpid ( ) ;
# ifndef HOST_NAME_MAX
# define HOST_NAME_MAX 255
# endif
char hostname [ HOST_NAME_MAX + 1 ] ;
* hostname = 0 ;
if ( gethostname ( hostname , sizeof ( hostname ) ) < 0 )
return ; //just give up. if the hostname isn't valid then the pid won't be useful anyway.
hostname [ countof ( hostname ) - 1 ] = 0 ; //make sure its null terminated... *sigh*
x11 . pXChangeProperty ( vid_dpy , wnd , wm_client_machine , string , 8 , PropModeReplace , hostname , strlen ( hostname ) ) ;
x11 . pXChangeProperty ( vid_dpy , wnd , net_wm_pid , cardinal , 32 , PropModeReplace , ( void * ) & pid , 1 ) ;
}
2013-03-12 22:47:42 +00:00
void X_GoFullscreen ( void )
{
XEvent xev ;
//for NETWM window managers
memset ( & xev , 0 , sizeof ( xev ) ) ;
xev . type = ClientMessage ;
xev . xclient . window = vid_window ;
2013-03-12 23:04:11 +00:00
xev . xclient . message_type = x11 . pXInternAtom ( vid_dpy , " _NET_WM_STATE " , False ) ;
2013-03-12 22:47:42 +00:00
xev . xclient . format = 32 ;
xev . xclient . data . l [ 0 ] = 1 ; //add
2013-03-12 23:04:11 +00:00
xev . xclient . data . l [ 1 ] = x11 . pXInternAtom ( vid_dpy , " _NET_WM_STATE_FULLSCREEN " , False ) ;
2013-03-12 22:47:42 +00:00
xev . xclient . data . l [ 2 ] = 0 ;
2014-09-21 03:35:38 +00:00
//for any other window managers, and broken NETWM
2017-09-02 05:13:33 +00:00
//Note that certain window managers ignore this entirely, and instead fullscreen us on whichever monitor has the mouse cursor at the time. Which is awkward.
x11 . pXMoveResizeWindow ( vid_dpy , vid_window , fullscreenx , fullscreeny , fullscreenwidth , fullscreenheight ) ;
// x11.pXMoveResizeWindow(vid_dpy, vid_window, fullscreenx+fullscreenwidth/2, fullscreeny+fullscreenheight/2, 1, 1);
2013-03-12 23:04:11 +00:00
x11 . pXSync ( vid_dpy , False ) ;
x11 . pXSendEvent ( vid_dpy , DefaultRootWindow ( vid_dpy ) , False , SubstructureNotifyMask , & xev ) ;
x11 . pXSync ( vid_dpy , False ) ;
2017-09-02 05:13:33 +00:00
x11 . pXMoveResizeWindow ( vid_dpy , vid_window , fullscreenx , fullscreeny , fullscreenwidth , fullscreenheight ) ;
2013-03-12 23:04:11 +00:00
x11 . pXSync ( vid_dpy , False ) ;
2014-09-21 03:35:38 +00:00
2017-09-02 05:13:33 +00:00
//Con_Printf("Gone fullscreen\n");
2013-03-12 22:47:42 +00:00
}
void X_GoWindowed ( void )
{
XEvent xev ;
2013-03-12 23:04:11 +00:00
x11 . pXFlush ( vid_dpy ) ;
x11 . pXSync ( vid_dpy , False ) ;
2013-03-12 22:47:42 +00:00
memset ( & xev , 0 , sizeof ( xev ) ) ;
xev . type = ClientMessage ;
xev . xclient . window = vid_window ;
2013-03-12 23:04:11 +00:00
xev . xclient . message_type = x11 . pXInternAtom ( vid_dpy , " _NET_WM_STATE " , False ) ;
2013-03-12 22:47:42 +00:00
xev . xclient . format = 32 ;
xev . xclient . data . l [ 0 ] = 0 ; //remove
2013-03-12 23:04:11 +00:00
xev . xclient . data . l [ 1 ] = x11 . pXInternAtom ( vid_dpy , " _NET_WM_STATE_FULLSCREEN " , False ) ;
2013-03-12 22:47:42 +00:00
xev . xclient . data . l [ 2 ] = 0 ;
2013-03-12 23:04:11 +00:00
x11 . pXSendEvent ( vid_dpy , DefaultRootWindow ( vid_dpy ) , False , SubstructureNotifyMask , & xev ) ;
x11 . pXSync ( vid_dpy , False ) ;
2013-03-12 22:47:42 +00:00
2014-09-21 03:35:38 +00:00
x11 . pXMoveResizeWindow ( vid_dpy , vid_window , 0 , 0 , 640 , 480 ) ;
2017-09-02 05:13:33 +00:00
//Con_Printf("Gone windowed\n");
2013-03-12 22:47:42 +00:00
}
2018-10-11 10:31:23 +00:00
static qboolean X_CheckWMFullscreenAvailable ( void )
2013-03-12 22:47:42 +00:00
{
//root window must have _NET_SUPPORTING_WM_CHECK which is a Window created by the WM
//the WM's window must have _NET_WM_NAME set, which is the name of the window manager
//if we can find those, then the window manager has not crashed.
//if we can then find _NET_WM_STATE_FULLSCREEN in the _NET_SUPPORTED atom list on the root, then we can get fullscreen mode from the WM
//and we'll have no alt-tab issues whatsoever.
2013-03-12 23:04:11 +00:00
Atom xa_net_supporting_wm_check = x11 . pXInternAtom ( vid_dpy , " _NET_SUPPORTING_WM_CHECK " , False ) ;
Atom xa_net_wm_name = x11 . pXInternAtom ( vid_dpy , " _NET_WM_NAME " , False ) ;
Atom xa_net_supported = x11 . pXInternAtom ( vid_dpy , " _NET_SUPPORTED " , False ) ;
Atom xa_net_wm_state_fullscreen = x11 . pXInternAtom ( vid_dpy , " _NET_WM_STATE_FULLSCREEN " , False ) ;
2013-03-12 22:47:42 +00:00
Window wmwindow ;
unsigned char * prop ;
unsigned long bytes_after , nitems ;
Atom type ;
int format ;
qboolean success = false ;
unsigned char * wmname ;
int i ;
2014-09-08 23:26:22 +00:00
2017-09-02 05:13:33 +00:00
if ( ! X11_CheckFeature ( " wmfullscreen " , true ) )
2014-09-08 23:26:22 +00:00
{
Con_Printf ( " Window manager fullscreen support disabled. Will attempt to hide from it instead. \n " ) ;
return success ;
}
2013-03-12 22:47:42 +00:00
2013-03-12 23:04:11 +00:00
if ( x11 . pXGetWindowProperty ( vid_dpy , vid_root , xa_net_supporting_wm_check , 0 , 16384 , False , AnyPropertyType , & type , & format , & nitems , & bytes_after , & prop ) ! = Success | | prop = = NULL )
2013-03-12 22:47:42 +00:00
{
Con_Printf ( " Window manager not identified \n " ) ;
return success ;
}
wmwindow = * ( Window * ) prop ;
2013-03-12 23:04:11 +00:00
x11 . pXFree ( prop ) ;
2013-03-12 22:47:42 +00:00
2013-03-12 23:04:11 +00:00
if ( x11 . pXGetWindowProperty ( vid_dpy , wmwindow , xa_net_wm_name , 0 , 16384 , False , AnyPropertyType , & type , & format , & nitems , & bytes_after , & wmname ) ! = Success | | wmname = = NULL )
2013-03-12 22:47:42 +00:00
{
Con_Printf ( " Window manager crashed or something \n " ) ;
return success ;
}
else
{
2013-03-12 23:04:11 +00:00
if ( x11 . pXGetWindowProperty ( vid_dpy , vid_root , xa_net_supported , 0 , 16384 , False , AnyPropertyType , & type , & format , & nitems , & bytes_after , & prop ) ! = Success | | prop = = NULL )
2013-03-12 22:47:42 +00:00
{
2017-09-02 05:13:33 +00:00
Con_Printf ( " Window manager \" %s \" supports nothing \n " , wmname ) ;
2013-03-12 22:47:42 +00:00
}
else
{
for ( i = 0 ; i < nitems ; i + + )
{
2013-03-12 23:04:11 +00:00
// Con_Printf("supported: %s\n", x11.pXGetAtomName(vid_dpy, ((Atom*)prop)[i]));
2013-03-12 22:47:42 +00:00
if ( ( ( Atom * ) prop ) [ i ] = = xa_net_wm_state_fullscreen )
{
success = true ;
break ;
}
}
if ( ! success )
Con_Printf ( " Window manager \" %s \" does not appear to support fullscreen \n " , wmname ) ;
2014-09-21 03:35:38 +00:00
else if ( ! strcmp ( wmname , " Fluxbox " ) )
{
2017-09-02 05:13:33 +00:00
Con_Printf ( " Window manager \" %s \" claims to support fullscreen, but is known to be buggy \n " , wmname ) ;
2014-09-21 03:35:38 +00:00
success = false ;
}
2013-03-12 22:47:42 +00:00
else
2017-09-02 05:13:33 +00:00
Con_DPrintf ( " Window manager \" %s \" supports fullscreen. Set x11_allow_wmfullscreen 0 if it is buggy. \n " , wmname ) ;
2013-03-12 23:04:11 +00:00
x11 . pXFree ( prop ) ;
2013-03-12 22:47:42 +00:00
}
2013-03-12 23:04:11 +00:00
x11 . pXFree ( wmname ) ;
2013-03-12 22:47:42 +00:00
}
return success ;
}
2019-02-16 19:09:07 +00:00
static Window X_CreateWindow ( rendererstate_t * info , qboolean override , XVisualInfo * visinfo , int x , int y , unsigned int width , unsigned int height , qboolean fullscreen )
2004-08-22 22:29:09 +00:00
{
2013-03-12 23:03:46 +00:00
Window wnd , parent ;
2013-03-12 22:47:42 +00:00
XSetWindowAttributes attr ;
XSizeHints szhints ;
unsigned int mask ;
2020-11-04 10:19:30 +00:00
Atom prots [ 2 ] ;
2013-03-12 22:47:42 +00:00
/* window attributes */
attr . background_pixel = 0 ;
attr . border_pixel = 0 ;
2013-03-12 23:04:11 +00:00
attr . colormap = x11 . pXCreateColormap ( vid_dpy , vid_root , visinfo - > visual , AllocNone ) ;
2014-03-30 00:39:37 +00:00
attr . event_mask = vid_x_eventmask = X_MASK ;
2013-03-12 22:47:42 +00:00
attr . backing_store = NotUseful ;
attr . save_under = False ;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWBackingStore | CWSaveUnder ;
// override redirect prevents the windowmanager from finding out about us, and thus will not apply borders to our window.
if ( override )
{
mask | = CWOverrideRedirect ;
attr . override_redirect = True ;
}
memset ( & szhints , 0 , sizeof ( szhints ) ) ;
2019-02-16 19:09:07 +00:00
szhints . flags = PMinSize | PPosition | PSize ;
2013-03-12 22:47:42 +00:00
szhints . min_width = 320 ;
szhints . min_height = 200 ;
2019-02-16 19:09:07 +00:00
if ( ! fullscreen )
{
# ifdef USE_XRANDR
int dx , dy , dw , dh ;
if ( * info - > devicename & & XRandr_PickScreen ( info - > devicename , & dx , & dy , & dw , & dh ) )
{
x + = dx + ( dw - width ) / 2 ;
y + = dy + ( dh - height ) / 2 ;
}
else
# endif
szhints . flags & = ~ PPosition ;
}
2013-03-12 23:03:46 +00:00
if ( sys_parentwindow & & ! fullscreen )
{
x = ( sys_parentwidth - width ) / 2 ;
y = ( sys_parentheight - height ) / 2 ;
parent = sys_parentwindow ;
}
else
parent = vid_root ;
2019-02-16 19:09:07 +00:00
szhints . x = x ;
szhints . y = y ;
szhints . width = width ;
szhints . height = height ;
2013-03-12 23:04:11 +00:00
wnd = x11 . pXCreateWindow ( vid_dpy , parent , x , y , width , height ,
2013-03-12 22:47:42 +00:00
0 , visinfo - > depth , InputOutput ,
visinfo - > visual , mask , & attr ) ;
/*ask the window manager to stop triggering bugs in Xlib*/
2013-03-12 23:04:11 +00:00
prots [ 0 ] = x11 . pXInternAtom ( vid_dpy , " WM_DELETE_WINDOW " , False ) ;
2020-11-04 10:19:30 +00:00
prots [ 1 ] = x11 . pXInternAtom ( vid_dpy , " _NET_WM_PING " , False ) ;
x11 . pXSetWMProtocols ( vid_dpy , wnd , prots , countof ( prots ) ) ;
2013-03-12 23:04:11 +00:00
x11 . pXSetWMNormalHints ( vid_dpy , wnd , & szhints ) ;
2013-03-12 22:47:42 +00:00
/*set caption*/
2013-03-12 23:04:11 +00:00
x11 . pXStoreName ( vid_dpy , wnd , " FTE QuakeWorld " ) ;
x11 . pXSetIconName ( vid_dpy , wnd , " FTEQW " ) ;
2013-03-12 22:47:42 +00:00
X_StoreIcon ( wnd ) ;
2020-11-04 10:19:30 +00:00
X_StorePID ( wnd ) ;
2013-03-12 22:47:42 +00:00
/*make it visible*/
2013-03-12 23:04:11 +00:00
x11 . pXMapWindow ( vid_dpy , wnd ) ;
2013-03-12 22:47:42 +00:00
2018-08-23 06:03:31 +00:00
//advertise support as a drag+drop target
prots [ 0 ] = 5 ; //version 5 is the most recent.
x11 . pXChangeProperty ( vid_dpy , wnd , x11 . pXInternAtom ( vid_dpy , " XdndAware " , False ) , XA_ATOM , 32 , PropModeReplace , ( void * ) prots , 1 ) ;
2013-03-12 22:47:42 +00:00
return wnd ;
2004-08-22 22:29:09 +00:00
}
2018-10-11 10:31:23 +00:00
static qboolean X11VID_Init ( rendererstate_t * info , unsigned char * palette , int psl )
2004-08-22 22:29:09 +00:00
{
2017-09-02 05:13:33 +00:00
int x = 0 ;
int y = 0 ;
2013-03-12 22:47:42 +00:00
int width = info - > width ; //can override these if vmode isn't available
int height = info - > height ;
2014-10-07 13:50:58 +00:00
int rate = info - > rate ;
2019-07-16 02:59:12 +00:00
# if defined(USE_EGL)
EGLConfig eglcfg = 0 ;
# endif
2016-07-12 00:40:13 +00:00
# if defined(USE_EGL) || defined(VKQUAKE)
2011-02-06 20:56:39 +00:00
XVisualInfo vinfodef ;
# endif
2004-08-22 22:29:09 +00:00
XVisualInfo * visinfo ;
2018-03-04 14:41:16 +00:00
# ifdef GLQUAKE
GLXFBConfig fbconfig = NULL ;
# endif
2009-11-04 21:16:50 +00:00
qboolean fullscreen = false ;
2004-08-22 22:29:09 +00:00
2013-03-12 23:04:11 +00:00
if ( ! x11_initlib ( ) )
return false ;
2004-08-22 22:29:09 +00:00
if ( info - > fullscreen )
fullscreen = true ;
2013-03-12 22:49:04 +00:00
currentpsl = psl ;
switch ( currentpsl )
2004-12-22 13:47:57 +00:00
{
2016-07-12 00:40:13 +00:00
# ifdef GLQUAKE
2013-03-12 22:49:04 +00:00
# ifdef USE_EGL
case PSL_EGL :
2013-11-21 23:02:28 +00:00
if ( ! EGL_LoadLibrary ( info - > subrenderer ) )
2013-03-12 22:49:04 +00:00
{
Con_Printf ( " couldn't load EGL library \n " ) ;
return false ;
}
break ;
# endif
case PSL_GLX :
2013-11-21 23:02:28 +00:00
if ( ! GLX_InitLibrary ( info - > subrenderer ) )
2013-03-12 22:49:04 +00:00
{
Con_Printf ( " Couldn't intialise GLX \n Either your drivers are not installed or you need to specify the library name with the gl_driver cvar \n " ) ;
return false ;
}
break ;
2016-07-12 00:40:13 +00:00
# endif
# ifdef VKQUAKE
case PSL_VULKAN :
{
dllfunction_t func [ ] =
{
{ ( void * ) & vkGetInstanceProcAddr , " vkGetInstanceProcAddr " } ,
{ NULL , NULL }
} ;
if ( ! Sys_LoadLibrary ( " libvulkan.so.1 " , func ) )
{
if ( ! Sys_LoadLibrary ( " libvulkan.so " , func ) )
{
2018-08-23 07:04:55 +00:00
Con_Printf ( CON_ERROR " Couldn't load libvulkan.so \n vulkan loader is not installed \n " ) ;
2016-07-12 00:40:13 +00:00
return false ;
}
}
2020-06-27 19:31:55 +00:00
//"Some implementations may require threads to implement some presentation modes so applications must call XInitThreads() before calling any other Xlib functions."
x11 . pXInitThreads ( ) ;
2016-07-12 00:40:13 +00:00
}
break ;
# endif
2013-03-12 22:49:04 +00:00
case PSL_NONE :
2004-12-22 13:47:57 +00:00
return false ;
}
2005-06-15 04:36:20 +00:00
2004-08-22 22:29:09 +00:00
if ( ! vid_dpy )
2013-03-12 23:04:11 +00:00
vid_dpy = x11 . pXOpenDisplay ( NULL ) ;
2004-08-22 22:29:09 +00:00
if ( ! vid_dpy )
{
2007-09-23 15:28:06 +00:00
Con_Printf ( CON_ERROR " Error: couldn't open the X display \n " ) ;
2006-04-15 03:31:23 +00:00
return false ;
2004-08-22 22:29:09 +00:00
}
scrnum = DefaultScreen ( vid_dpy ) ;
2013-03-12 22:47:42 +00:00
vid_root = RootWindow ( vid_dpy , scrnum ) ;
2004-08-22 22:29:09 +00:00
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
# define MILLIMETRESPERINCH 25.4 //sigh, why did we go for dpi?
vid . dpi_x = DisplayWidth ( vid_dpy , scrnum ) * ( MILLIMETRESPERINCH / DisplayWidthMM ( vid_dpy , scrnum ) ) ;
vid . dpi_y = DisplayHeight ( vid_dpy , scrnum ) * ( MILLIMETRESPERINCH / DisplayHeightMM ( vid_dpy , scrnum ) ) ;
2013-03-12 22:47:42 +00:00
fullscreenflags = 0 ;
2017-09-02 05:13:33 +00:00
if ( info - > fullscreen = = 2 )
fullscreenflags | = FULLSCREEN_DESKTOP ;
# ifdef USE_XRANDR
XRandR_Init ( ) ;
2019-05-10 09:31:21 +00:00
XRandR_FindOutput ( info - > devicename ) ;
2017-09-02 05:13:33 +00:00
if ( fullscreen & & ! ( fullscreenflags & FULLSCREEN_ANYMODE ) )
XRandR_SelectMode ( info - > devicename , & x , & y , & width , & height , rate ) ;
# endif
2004-08-22 22:29:09 +00:00
2017-09-02 05:13:33 +00:00
# ifdef USE_VMODE
VMODE_Init ( ) ;
if ( fullscreen & & ! ( fullscreenflags & FULLSCREEN_ANYMODE ) )
VMODE_SelectMode ( & width , & height , rate ) ;
# endif
2004-08-22 22:29:09 +00:00
2013-03-12 22:47:42 +00:00
if ( fullscreen )
{
2017-09-02 05:13:33 +00:00
if ( ! ( fullscreenflags & ( FULLSCREEN_ANYMODE & ~ FULLSCREEN_DESKTOP ) ) )
2013-03-12 22:47:42 +00:00
{
2017-09-02 05:13:33 +00:00
//if we arn't using any mode switching extension then our fullscreen has to be the size of the root window
//FIXME: with xrandr (even when not fullscreen), we should pick an arbitrary display to size the game appropriately.
2013-03-12 22:47:42 +00:00
XWindowAttributes xwa ;
2013-03-12 23:04:11 +00:00
x11 . pXGetWindowAttributes ( vid_dpy , DefaultRootWindow ( vid_dpy ) , & xwa ) ;
2013-03-12 22:47:42 +00:00
width = xwa . width ;
height = xwa . height ;
2017-09-02 05:13:33 +00:00
x = 0 ;
y = 0 ;
# ifdef USE_XRANDR
XRandr_PickScreen ( info - > devicename , & x , & y , & width , & height ) ;
# endif
2013-03-12 22:47:42 +00:00
}
2013-03-12 22:54:12 +00:00
//window managers fuck up too much if we change the video mode and request the windowmanager make us fullscreen.
2017-09-02 05:13:33 +00:00
//we assume that window manages will understand xrandr, as that actually provides notifications that things have changed.
2019-05-10 09:31:21 +00:00
if ( ! ( fullscreenflags & ( FULLSCREEN_VMODE | FULLSCREEN_XRANDR ) ) & & X_CheckWMFullscreenAvailable ( ) )
2013-03-12 22:47:42 +00:00
fullscreenflags | = FULLSCREEN_WM ;
else
2013-11-21 23:02:28 +00:00
fullscreenflags | = FULLSCREEN_LEGACY ;
2013-03-12 22:47:42 +00:00
}
2013-03-12 23:03:46 +00:00
else if ( sys_parentwindow )
{
if ( width < 64 | | width > sys_parentwidth )
width = sys_parentwidth ;
if ( height < 64 | | height > sys_parentheight )
height = sys_parentheight ;
}
2009-07-12 18:57:40 +00:00
2013-03-12 22:49:04 +00:00
switch ( currentpsl )
2011-02-06 20:56:39 +00:00
{
2016-07-12 00:40:13 +00:00
# ifdef GLQUAKE
2013-03-12 22:49:04 +00:00
# ifdef USE_EGL
case PSL_EGL :
2019-07-16 02:59:12 +00:00
if ( ! EGL_InitDisplay ( info , EGL_PLATFORM_X11_KHR , vid_dpy , ( EGLNativeDisplayType ) vid_dpy , & eglcfg ) )
{
Con_Printf ( " X11VID_Init: Unable to find suitable EGL config \n " ) ;
GLVID_Shutdown ( ) ;
return false ;
}
2013-03-12 22:49:04 +00:00
{
2019-07-16 02:59:12 +00:00
int num_visuals ;
EGLint id ;
if ( ! qeglGetConfigAttrib ( egldpy , eglcfg , EGL_NATIVE_VISUAL_ID , & id ) )
Sys_Error ( " Couldn't choose visual for EGL \n " ) ;
vinfodef . visualid = id ;
visinfo = x11 . pXGetVisualInfo ( vid_dpy , VisualIDMask , & vinfodef , & num_visuals ) ;
if ( ! visinfo )
Sys_Error ( " Couldn't get visual info for EGL \n " ) ;
2013-03-12 22:49:04 +00:00
}
break ;
2011-02-06 20:56:39 +00:00
# endif
2013-03-12 22:49:04 +00:00
case PSL_GLX :
2019-01-13 16:51:50 +00:00
if ( glx . QueryExtensionsString )
glx . glxextensions = glx . QueryExtensionsString ( vid_dpy , scrnum ) ;
2018-03-04 14:41:16 +00:00
fbconfig = GLX_GetFBConfig ( info ) ;
if ( fbconfig )
visinfo = glx . GetVisualFromFBConfig ( vid_dpy , fbconfig ) ;
else
visinfo = GLX_GetVisual ( info ) ;
2013-03-12 22:49:04 +00:00
if ( ! visinfo )
{
2018-03-04 14:41:16 +00:00
Con_Printf ( " X11VID_Init: Error couldn't get an RGB, Double-buffered, Depth visual \n " ) ;
GLVID_Shutdown ( ) ;
return false ;
2013-03-12 22:49:04 +00:00
}
break ;
2016-07-12 00:40:13 +00:00
# endif
# ifdef VKQUAKE
case PSL_VULKAN :
visinfo = & vinfodef ;
2018-06-18 16:44:29 +00:00
if ( ! x11 . pXMatchVisualInfo ( vid_dpy , scrnum , min ( 24 , info - > bpp ? info - > bpp : DefaultDepth ( vid_dpy , scrnum ) ) , TrueColor , visinfo ) )
2016-07-12 00:40:13 +00:00
{
Sys_Error ( " Couldn't choose visual for vulkan \n " ) ;
}
break ;
# endif
2013-03-12 22:49:48 +00:00
default :
2013-03-12 22:49:04 +00:00
case PSL_NONE :
2013-03-12 22:49:48 +00:00
visinfo = NULL ;
2013-03-12 22:49:04 +00:00
break ; //erm
}
2011-02-06 20:56:39 +00:00
2016-02-10 23:23:43 +00:00
vid . activeapp = false ;
2013-03-12 22:47:42 +00:00
if ( fullscreenflags & FULLSCREEN_LEGACY )
{
2019-02-16 19:09:07 +00:00
vid_decoywindow = X_CreateWindow ( info , false , visinfo , x , y , 320 , 200 , false ) ;
vid_window = X_CreateWindow ( info , true , visinfo , x , y , width , height , fullscreen ) ;
2013-03-12 22:47:42 +00:00
}
else
2019-02-16 19:09:07 +00:00
vid_window = X_CreateWindow ( info , false , visinfo , x , y , width , height , fullscreen ) ;
2011-02-06 20:56:39 +00:00
2014-03-30 00:39:37 +00:00
vid_x_eventmask | = X_InitUnicode ( ) ;
x11 . pXSelectInput ( vid_dpy , vid_window , vid_x_eventmask ) ;
2013-03-12 22:47:42 +00:00
CL_UpdateWindowTitle ( ) ;
/*make it visible*/
2011-01-29 19:53:38 +00:00
2017-09-02 05:13:33 +00:00
# ifdef USE_VMODE
2013-11-21 23:02:28 +00:00
if ( fullscreenflags & FULLSCREEN_VMODE )
2013-03-12 22:47:42 +00:00
{
2013-03-12 23:04:11 +00:00
x11 . pXRaiseWindow ( vid_dpy , vid_window ) ;
x11 . pXWarpPointer ( vid_dpy , None , vid_window , 0 , 0 , 0 , 0 , 0 , 0 ) ;
x11 . pXFlush ( vid_dpy ) ;
2017-09-02 05:13:33 +00:00
// Move the viewport to top left, in case its not already.
2013-03-12 22:54:12 +00:00
vm . pXF86VidModeSetViewPort ( vid_dpy , scrnum , 0 , 0 ) ;
2004-08-22 22:29:09 +00:00
}
2017-09-02 05:13:33 +00:00
# endif
2004-08-22 22:29:09 +00:00
2012-10-14 10:57:11 +00:00
vid_nullcursor = CreateNullCursor ( vid_dpy , vid_window ) ;
2017-10-25 08:10:35 +00:00
vid_newcursor = vid_activecursor = None ; //at this point, the cursor is undefined (aka: inherited from parent)
2004-08-22 22:29:09 +00:00
2013-03-12 23:04:11 +00:00
x11 . pXFlush ( vid_dpy ) ;
2005-06-15 04:36:20 +00:00
2019-03-01 22:39:30 +00:00
# ifdef USE_XRANDR
if ( xrandr . origgamma )
vid . gammarampsize = xrandr . origgamma - > size ;
else
# endif
2017-09-02 05:13:33 +00:00
# ifdef USE_VMODE
2020-01-09 15:35:40 +00:00
if ( vm . pXF86VidModeGetGammaRampSize )
2005-04-18 05:41:39 +00:00
{
int rampsize = 256 ;
2013-03-12 22:54:12 +00:00
vm . pXF86VidModeGetGammaRampSize ( vid_dpy , scrnum , & rampsize ) ;
2016-07-28 15:57:22 +00:00
if ( rampsize > countof ( vm . originalramps [ 0 ] ) )
2005-04-18 05:41:39 +00:00
{
2013-03-12 22:54:12 +00:00
vm . originalapplied = false ;
2018-03-04 14:41:16 +00:00
Con_Printf ( " Gamma ramps have more than %zi entries (%i). \n " , countof ( vm . originalramps [ 0 ] ) , rampsize ) ;
2005-04-18 05:41:39 +00:00
}
else
2016-07-28 15:57:22 +00:00
{
vm . originalrampsize = vid . gammarampsize = rampsize ;
vm . originalapplied = vm . pXF86VidModeGetGammaRamp ( vid_dpy , scrnum , vm . originalrampsize , vm . originalramps [ 0 ] , vm . originalramps [ 1 ] , vm . originalramps [ 2 ] ) ;
}
2005-04-18 05:41:39 +00:00
}
2019-03-01 22:39:30 +00:00
else
2017-09-02 05:13:33 +00:00
# endif
2019-03-01 22:39:30 +00:00
vid . gammarampsize = 256 ;
2004-08-22 22:29:09 +00:00
2013-03-12 22:49:04 +00:00
switch ( currentpsl )
2005-04-18 05:35:23 +00:00
{
2016-07-12 00:40:13 +00:00
# ifdef GLQUAKE
2013-03-12 22:49:04 +00:00
case PSL_GLX :
2018-03-04 14:41:16 +00:00
if ( ! GLX_Init ( info , fbconfig , visinfo ) )
2013-03-12 22:49:04 +00:00
{
2018-03-06 16:51:18 +00:00
# if defined(USE_EGL) || defined(VKQUAKE)
2018-03-06 16:46:57 +00:00
if ( visinfo ! = & vinfodef )
2018-03-06 16:51:18 +00:00
# endif
2018-03-06 16:46:57 +00:00
x11 . pXFree ( visinfo ) ;
2013-03-12 22:49:04 +00:00
GLVID_Shutdown ( ) ;
return false ;
}
2018-03-06 17:01:53 +00:00
# if defined(USE_EGL) || defined(VKQUAKE)
2018-03-06 16:46:57 +00:00
if ( visinfo ! = & vinfodef )
2018-03-06 17:01:53 +00:00
# endif
2018-03-06 16:46:57 +00:00
x11 . pXFree ( visinfo ) ;
2019-01-13 16:51:50 +00:00
glx . SwapIntervalEXT = GLX_CheckExtension ( " GLX_EXT_swap_control " ) ? GLX_GetSymbol ( " glXSwapIntervalEXT " ) : NULL ;
glx . swaptear = glx . SwapIntervalEXT & & GLX_CheckExtension ( " GLX_EXT_swap_control_tear " ) ;
// if (glx.swaptear)
// glx.QueryDrawable(vid_dpy, vid_window, 0x20F3, &glx.swaptear);
if ( ! glx . SwapIntervalEXT )
glx . SwapIntervalMESA = GLX_CheckExtension ( " GLX_MESA_swap_control " ) ? GLX_GetSymbol ( " glXSwapIntervalMESA " ) : NULL ;
if ( ! glx . SwapIntervalEXT & & ! glx . SwapIntervalMESA )
glx . SwapIntervalSGI = GLX_CheckExtension ( " GLX_SGI_swap_control " ) ? GLX_GetSymbol ( " glXSwapIntervalSGI " ) : NULL ;
2018-03-24 04:02:09 +00:00
glx . swapint = vid_vsync . ival ;
2019-01-13 16:51:50 +00:00
if ( ! glx . swaptear )
glx . swapint = abs ( glx . swapint ) ;
if ( * vid_vsync . string )
{
if ( glx . SwapIntervalEXT /*&& (glx.swapint>=0 || swap_tear)*/ )
{
glx . SwapIntervalEXT ( vid_dpy , vid_window , glx . swapint ) ;
Con_DPrintf ( " Swap interval %i \n " , glx . swapint ) ;
}
else if ( glx . SwapIntervalMESA & & glx . swapint > = 0 )
{
glx . SwapIntervalMESA ( abs ( glx . swapint ) ) ;
Con_DPrintf ( " Swap interval %i \n " , glx . swapint ) ;
}
else if ( glx . SwapIntervalSGI & & glx . swapint > 0 )
{
glx . SwapIntervalSGI ( glx . swapint ) ;
Con_DPrintf ( " Swap interval %i \n " , glx . swapint ) ;
}
else
Con_Printf ( " Unable to explicitly %s vsync \n " , glx . swapint ? " configure " : " disable " ) ;
}
2013-03-12 22:49:04 +00:00
break ;
# ifdef USE_EGL
case PSL_EGL :
2019-07-16 02:59:12 +00:00
if ( ! EGL_InitWindow ( info , EGL_PLATFORM_X11_KHR , & vid_window , ( EGLNativeWindowType ) vid_window , eglcfg ) )
2013-03-12 23:00:29 +00:00
{
Con_Printf ( " Failed to create EGL context. \n " ) ;
GLVID_Shutdown ( ) ;
return false ;
}
2017-09-20 11:27:13 +00:00
if ( ! GL_Init ( info , & EGL_Proc ) )
return false ;
2013-03-12 22:49:04 +00:00
break ;
2016-07-12 00:40:13 +00:00
# endif
# endif
# ifdef VKQUAKE
case PSL_VULKAN :
2016-07-30 17:59:55 +00:00
# ifdef VK_USE_PLATFORM_XLIB_KHR
2017-09-20 11:27:13 +00:00
{
const char * extnames [ ] = { VK_KHR_XLIB_SURFACE_EXTENSION_NAME , NULL } ;
if ( VK_Init ( info , extnames , XVK_SetupSurface_XLib , NULL ) )
break ;
2021-04-14 05:21:04 +00:00
VK_Shutdown ( ) ;
2017-09-20 11:27:13 +00:00
}
2016-07-30 17:59:55 +00:00
# endif
# ifdef VK_USE_PLATFORM_XCB_KHR
2017-09-20 11:27:13 +00:00
{
const char * extnames [ ] = { VK_KHR_XCB_SURFACE_EXTENSION_NAME , NULL } ;
if ( x11xcb_initlib ( ) & & VK_Init ( info , extnames , XVK_SetupSurface_XCB , NULL ) )
break ;
2021-04-14 05:21:04 +00:00
VK_Shutdown ( ) ;
2017-09-20 11:27:13 +00:00
}
2016-07-30 17:59:55 +00:00
# endif
2020-05-14 15:50:26 +00:00
//Con_Printf(CON_ERROR "Failed to create a vulkan context.\n");
2016-07-30 17:59:55 +00:00
GLVID_Shutdown ( ) ;
return false ;
2011-02-06 20:56:39 +00:00
# endif
2013-03-12 22:49:04 +00:00
case PSL_NONE :
break ;
}
2011-02-06 20:56:39 +00:00
2013-03-12 22:47:42 +00:00
//probably going to be resized in the event handler
vid . pixelwidth = fullscreenwidth = width ;
vid . pixelheight = fullscreenheight = height ;
2017-09-02 05:13:33 +00:00
fullscreenx = x ;
fullscreeny = y ;
2004-08-22 22:29:09 +00:00
vid . numpages = 2 ;
2017-09-02 05:13:33 +00:00
// Con_SafePrintf ("Video mode %dx%d+%d,%d initialized.\n", width, height, x, y);
x11 . pXRaiseWindow ( vid_dpy , vid_window ) ;
2013-03-12 22:47:42 +00:00
if ( fullscreenflags & FULLSCREEN_WM )
X_GoFullscreen ( ) ;
if ( fullscreenflags & FULLSCREEN_LEGACY )
2017-09-02 05:13:33 +00:00
x11 . pXMoveResizeWindow ( vid_dpy , vid_window , fullscreenx , fullscreeny , fullscreenwidth , fullscreenheight ) ;
2013-03-12 22:47:42 +00:00
if ( fullscreenflags )
fullscreenflags | = FULLSCREEN_ACTIVE ;
2021-07-01 01:16:11 +00:00
vid_isfullscreen = ! ! ( fullscreenflags & FULLSCREEN_ACTIVE ) ;
2004-08-22 22:29:09 +00:00
2017-09-02 05:13:33 +00:00
if ( X11_CheckFeature ( " xi2 " , true ) & & XI2_Init ( ) )
2013-03-12 22:54:12 +00:00
{
x11_input_method = XIM_XI2 ;
2014-03-30 00:39:37 +00:00
Con_DPrintf ( " Using XInput2 \n " ) ;
2013-03-12 22:54:12 +00:00
}
2017-09-02 05:13:33 +00:00
else if ( X11_CheckFeature ( " dga " , true ) & & DGAM_Init ( ) )
2013-03-12 22:54:12 +00:00
{
x11_input_method = XIM_DGA ;
2014-03-30 00:39:37 +00:00
Con_DPrintf ( " Using DGA mouse \n " ) ;
2013-03-12 22:54:12 +00:00
}
else
{
x11_input_method = XIM_ORIG ;
2014-03-30 00:39:37 +00:00
Con_DPrintf ( " Using X11 mouse \n " ) ;
2013-03-12 22:54:12 +00:00
}
2017-10-25 08:10:35 +00:00
XCursor_Init ( ) ;
2013-03-12 22:54:12 +00:00
2014-09-21 03:35:38 +00:00
if ( fullscreenflags & FULLSCREEN_LEGACY )
2017-09-02 05:13:33 +00:00
x11 . pXMoveResizeWindow ( vid_dpy , vid_window , fullscreenx , fullscreeny , fullscreenwidth , fullscreenheight ) ;
2004-08-22 22:29:09 +00:00
if ( Cvar_Get ( " vidx_grabkeyboard " , " 0 " , 0 , " Additional video options " ) - > value )
2013-03-12 23:04:11 +00:00
x11 . pXGrabKeyboard ( vid_dpy , vid_window ,
2004-08-22 22:29:09 +00:00
False ,
GrabModeAsync , GrabModeAsync ,
CurrentTime ) ;
2014-09-21 03:35:38 +00:00
else if ( fullscreenflags & FULLSCREEN_LEGACY )
x11 . pXSetInputFocus ( vid_dpy , vid_window , RevertToNone , CurrentTime ) ;
2004-08-22 22:29:09 +00:00
return true ;
}
2016-07-12 00:40:13 +00:00
# ifdef GLQUAKE
2013-03-12 22:49:04 +00:00
qboolean GLVID_Init ( rendererstate_t * info , unsigned char * palette )
{
return X11VID_Init ( info , palette , PSL_GLX ) ;
}
2013-03-12 22:49:26 +00:00
# ifdef USE_EGL
2018-10-11 10:31:23 +00:00
static qboolean EGLVID_Init ( rendererstate_t * info , unsigned char * palette )
2013-03-12 22:49:04 +00:00
{
return X11VID_Init ( info , palette , PSL_EGL ) ;
}
2013-03-12 22:49:26 +00:00
# endif
2016-07-12 00:40:13 +00:00
# endif
# ifdef VKQUAKE
static qboolean VKVID_Init ( rendererstate_t * info , unsigned char * palette )
{
return X11VID_Init ( info , palette , PSL_VULKAN ) ;
}
# endif
2004-08-22 22:29:09 +00:00
2016-07-12 00:40:13 +00:00
void GLVID_SetCaption ( const char * text )
2007-03-28 12:57:05 +00:00
{
2016-07-12 00:40:13 +00:00
x11 . pXStoreName ( vid_dpy , vid_window , ( char * ) text ) ;
2007-03-28 12:57:05 +00:00
}
2013-03-12 22:49:04 +00:00
# ifdef USE_EGL
# include "shader.h"
# include "gl_draw.h"
rendererinfo_t eglrendererinfo =
{
2018-03-24 04:02:09 +00:00
" OpenGL (X11 EGL) " ,
2013-03-12 22:49:04 +00:00
{
" egl "
} ,
QR_OPENGL ,
GLDraw_Init ,
GLDraw_DeInit ,
2014-10-05 20:04:11 +00:00
GL_UpdateFiltering ,
GL_LoadTextureMips ,
2013-03-12 22:49:04 +00:00
GL_DestroyTexture ,
GLR_Init ,
GLR_DeInit ,
GLR_RenderView ,
EGLVID_Init ,
GLVID_DeInit ,
2014-03-30 00:39:37 +00:00
GLVID_SwapBuffers ,
GLVID_ApplyGammaRamps ,
2013-03-12 22:49:04 +00:00
2014-09-02 02:44:43 +00:00
NULL ,
NULL ,
NULL ,
2013-03-12 22:49:04 +00:00
GLVID_SetCaption , //setcaption
2014-03-30 00:39:37 +00:00
GLVID_GetRGBInfo ,
2013-03-12 22:49:04 +00:00
GLSCR_UpdateScreen ,
GLBE_SelectMode ,
GLBE_DrawMesh_List ,
GLBE_DrawMesh_Single ,
GLBE_SubmitBatch ,
GLBE_GetTempBatch ,
GLBE_DrawWorld ,
GLBE_Init ,
GLBE_GenBrushModelVBO ,
GLBE_ClearVBO ,
2020-04-19 01:23:32 +00:00
GLBE_UpdateLightmaps ,
2013-03-12 22:49:04 +00:00
GLBE_SelectEntity ,
GLBE_SelectDLight ,
2014-03-30 00:39:37 +00:00
GLBE_Scissor ,
2013-03-12 22:49:04 +00:00
GLBE_LightCullModel ,
2014-03-30 00:39:37 +00:00
GLBE_VBO_Begin ,
2014-03-30 08:55:06 +00:00
GLBE_VBO_Data ,
GLBE_VBO_Finish ,
GLBE_VBO_Destroy ,
2014-03-30 00:39:37 +00:00
2014-03-30 08:55:06 +00:00
GLBE_RenderToTextureUpdate2d ,
2014-03-30 00:39:37 +00:00
2013-03-12 22:49:04 +00:00
" "
} ;
# endif
2013-03-12 22:47:42 +00:00
2016-07-12 00:40:13 +00:00
# ifdef VKQUAKE
2016-07-30 17:59:55 +00:00
# ifdef VK_USE_PLATFORM_XLIB_KHR
static qboolean XVK_SetupSurface_XLib ( void )
2016-07-12 00:40:13 +00:00
{
VkXlibSurfaceCreateInfoKHR inf = { VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR } ;
inf . flags = 0 ;
inf . dpy = vid_dpy ;
inf . window = vid_window ;
if ( VK_SUCCESS = = vkCreateXlibSurfaceKHR ( vk . instance , & inf , vkallocationcb , & vk . surface ) )
return true ;
return false ;
}
2016-07-30 17:59:55 +00:00
# endif
# ifdef VK_USE_PLATFORM_XCB_KHR
static qboolean XVK_SetupSurface_XCB ( void )
{
VkXcbSurfaceCreateInfoKHR inf = { VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR } ;
inf . flags = 0 ;
inf . connection = x11xcb . pXGetXCBConnection ( vid_dpy ) ;
inf . window = vid_window ;
if ( VK_SUCCESS = = vkCreateXcbSurfaceKHR ( vk . instance , & inf , vkallocationcb , & vk . surface ) )
return true ;
return false ;
}
# endif
2021-04-14 05:21:04 +00:00
static qboolean XVK_EnumerateDevices ( void * usercontext , void ( * callback ) ( void * context , const char * devicename , const char * outputname , const char * desc ) )
{
qboolean ret = false ;
# ifdef VK_NO_PROTOTYPES
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr ;
void * lib = NULL ;
dllfunction_t func [ ] =
{
{ ( void * ) & vkGetInstanceProcAddr , " vkGetInstanceProcAddr " } ,
{ NULL , NULL }
} ;
if ( ! lib )
lib = Sys_LoadLibrary ( " libvulkan.so.1 " , func ) ;
if ( ! lib )
lib = Sys_LoadLibrary ( " libvulkan.so " , func ) ;
if ( ! lib )
return false ;
# endif
ret = VK_EnumerateDevices ( usercontext , callback , " Vulkan-X11- " , vkGetInstanceProcAddr ) ;
# ifdef VK_NO_PROTOTYPES
Sys_CloseLibrary ( lib ) ;
# endif
return ret ;
}
2016-07-12 00:40:13 +00:00
rendererinfo_t vkrendererinfo =
{
2018-03-24 04:02:09 +00:00
" Vulkan (X11) " ,
2016-07-12 00:40:13 +00:00
{
" xvk " ,
2018-03-24 04:02:09 +00:00
" vk " ,
2016-07-12 00:40:13 +00:00
" vulkan "
} ,
QR_VULKAN ,
VK_Draw_Init ,
VK_Draw_Shutdown ,
VK_UpdateFiltering ,
VK_LoadTextureMips ,
VK_DestroyTexture ,
VK_R_Init ,
VK_R_DeInit ,
VK_R_RenderView ,
VKVID_Init ,
GLVID_DeInit ,
GLVID_SwapBuffers ,
GLVID_ApplyGammaRamps ,
NULL ,
NULL ,
NULL ,
GLVID_SetCaption , //setcaption
VKVID_GetRGBInfo ,
VK_SCR_UpdateScreen ,
VKBE_SelectMode ,
VKBE_DrawMesh_List ,
VKBE_DrawMesh_Single ,
VKBE_SubmitBatch ,
VKBE_GetTempBatch ,
VKBE_DrawWorld ,
VKBE_Init ,
VKBE_GenBrushModelVBO ,
VKBE_ClearVBO ,
VKBE_UploadAllLightmaps ,
VKBE_SelectEntity ,
VKBE_SelectDLight ,
VKBE_Scissor ,
VKBE_LightCullModel ,
VKBE_VBO_Begin ,
VKBE_VBO_Data ,
VKBE_VBO_Finish ,
VKBE_VBO_Destroy ,
VKBE_RenderToTextureUpdate2d ,
2021-04-14 05:21:04 +00:00
" " ,
NULL , //int (*VID_GetPriority) (void); //so that eg x11 or wayland can be prioritised depending on environment settings. assumed to be 1.
NULL , //void (*VID_EnumerateVideoModes) (const char *driver, const char *output, void (*cb) (int w, int h));
XVK_EnumerateDevices , //qboolean (*VID_EnumerateDevices) (void *usercontext, void(*callback)(void *context, const char *devicename, const char *outputname, const char *desc));
2016-07-12 00:40:13 +00:00
} ;
# endif
2013-03-12 22:47:42 +00:00
# if 1
2020-07-14 00:48:56 +00:00
static void ( * paste_callback ) ( void * cb , const char * utf8 ) ;
2018-10-11 10:31:23 +00:00
static void * pastectx ;
static struct {
Atom clipboard ;
Atom prop ;
Atom owner ;
} x11paste ;
2020-07-14 00:48:56 +00:00
void Sys_Clipboard_PasteText ( clipboardtype_t clipboardtype , void ( * callback ) ( void * ctx , const char * utf8 ) , void * ctx )
2018-10-11 10:31:23 +00:00
{
//if there's a paste already pending, cancel the callback to ensure it always gets called.
if ( paste_callback )
paste_callback ( pastectx , NULL ) ;
paste_callback = NULL ;
pastectx = NULL ;
if ( vid_dpy )
{
Window clipboardowner ;
Atom xa_string = x11 . pXInternAtom ( vid_dpy , " UTF8_STRING " , false ) ;
//FIXME: we should query it using TARGETS first to see if UTF8_STRING etc is actually valid.
if ( clipboardtype = = CBT_SELECTION )
x11paste . clipboard = x11 . pXInternAtom ( vid_dpy , " PRIMARY " , false ) ;
else
x11paste . clipboard = x11 . pXInternAtom ( vid_dpy , " CLIPBOARD " , false ) ;
x11paste . prop = x11 . pXInternAtom ( vid_dpy , " _FTE_PASTE " , false ) ;
clipboardowner = x11 . pXGetSelectionOwner ( vid_dpy , x11paste . clipboard ) ;
if ( clipboardowner = = vid_window )
2018-10-14 16:16:34 +00:00
callback ( ctx , clipboard_buffer [ clipboardtype ] ) ; //we own it? no point doing round-robin stuff.
2018-10-11 10:31:23 +00:00
else if ( clipboardowner ! = None & & clipboardowner ! = vid_window )
{
x11 . pXConvertSelection ( vid_dpy , x11paste . clipboard , xa_string , x11paste . prop , vid_window , CurrentTime ) ;
paste_callback = callback ;
pastectx = ctx ;
}
else
callback ( ctx , NULL ) ; //nothing to paste (the window that owned it sucks
}
else
2018-10-14 16:16:34 +00:00
callback ( ctx , clipboard_buffer [ clipboardtype ] ) ; //if we're not using x11 then just instantly call the callback
2018-10-11 10:31:23 +00:00
}
static qboolean X11_Clipboard_Notify ( XSelectionEvent * xselection )
{ //called once XConvertSelection completes
if ( xselection - > display = = vid_dpy & & xselection - > selection = = x11paste . clipboard & & xselection - > requestor = = vid_window & & xselection - > property = = x11paste . prop )
{
int fmt ;
Atom type ;
unsigned long nitems , bytesleft ;
unsigned char * data = NULL ;
x11 . pXGetWindowProperty ( vid_dpy , vid_window , x11paste . prop , 0 , 65536 , False , AnyPropertyType , & type , & fmt , & nitems , & bytesleft , & data ) ;
if ( paste_callback )
paste_callback ( pastectx , data ) ;
x11 . pXFree ( data ) ;
paste_callback = NULL ;
pastectx = NULL ;
return true ;
}
return false ;
}
/*char *Sys_GetClipboard(void)
2013-03-12 22:47:42 +00:00
{
2018-03-24 04:02:09 +00:00
if ( vid_dpy )
2013-03-12 22:47:42 +00:00
{
2018-08-23 06:03:31 +00:00
//FIXME: we should query it using TARGETS first to see if UTF8_STRING etc is actually valid.
2018-03-24 04:02:09 +00:00
Atom xa_clipboard = x11 . pXInternAtom ( vid_dpy , " PRIMARY " , false ) ;
Atom xa_string = x11 . pXInternAtom ( vid_dpy , " UTF8_STRING " , false ) ;
Window clipboardowner = x11 . pXGetSelectionOwner ( vid_dpy , xa_clipboard ) ;
if ( clipboardowner ! = None & & clipboardowner ! = vid_window )
{
int fmt ;
Atom type ;
unsigned long nitems , bytesleft ;
unsigned char * data ;
x11 . pXConvertSelection ( vid_dpy , xa_clipboard , xa_string , None , vid_window , CurrentTime ) ;
2018-08-23 06:03:31 +00:00
//FIXME: we should rewrite the clipboard pasting to invoke a callback once its available.
2018-03-24 04:02:09 +00:00
x11 . pXFlush ( vid_dpy ) ;
2018-08-23 06:03:31 +00:00
x11 . pXSync ( vid_dpy , False ) ;
Sys_Sleep ( 0.3 ) ;
x11 . pXSync ( vid_dpy , False ) ;
//and now we can actually read the data.
x11 . pXGetWindowProperty ( vid_dpy , vid_window , xa_string , 0 , 65536 , False , AnyPropertyType , & type , & fmt , & nitems , & bytesleft , & data ) ;
2018-03-24 04:02:09 +00:00
return data ;
}
2013-03-12 22:47:42 +00:00
}
2014-03-30 08:55:06 +00:00
return clipboard_buffer ;
2013-03-12 22:47:42 +00:00
}
2018-10-11 10:31:23 +00:00
*/
2013-03-12 22:47:42 +00:00
2018-11-28 01:40:47 +00:00
void Sys_SaveClipboard ( clipboardtype_t clipboardtype , const char * text )
2013-03-12 22:47:42 +00:00
{
2018-10-14 16:16:34 +00:00
free ( clipboard_buffer [ clipboardtype ] ) ;
clipboard_buffer [ clipboardtype ] = strdup ( text ) ;
2018-03-24 04:02:09 +00:00
if ( vid_dpy )
{
2018-10-14 16:16:34 +00:00
Atom xa_clipboard ;
switch ( clipboardtype )
{
case CBT_SELECTION :
xa_clipboard = x11 . pXInternAtom ( vid_dpy , " PRIMARY " , false ) ;
break ;
case CBT_CLIPBOARD :
xa_clipboard = x11 . pXInternAtom ( vid_dpy , " CLIPBOARD " , false ) ;
break ;
default :
return ;
}
2018-08-23 06:03:31 +00:00
x11 . pXSetSelectionOwner ( vid_dpy , xa_clipboard , vid_window , CurrentTime ) ;
2018-03-24 04:02:09 +00:00
}
2013-03-12 22:47:42 +00:00
}
# endif
2013-03-12 23:04:11 +00:00
qboolean X11_GetDesktopParameters ( int * width , int * height , int * bpp , int * refreshrate )
{
2014-03-30 08:55:06 +00:00
Display * xtemp ;
int scr ;
2013-03-12 23:04:11 +00:00
if ( ! x11_initlib ( ) )
return false ;
2014-03-30 08:55:06 +00:00
xtemp = x11 . pXOpenDisplay ( NULL ) ;
2013-03-12 23:04:11 +00:00
2014-03-30 08:55:06 +00:00
if ( ! xtemp )
return false ;
2013-03-12 23:04:11 +00:00
2014-03-30 08:55:06 +00:00
scr = DefaultScreen ( xtemp ) ;
2013-03-12 23:04:11 +00:00
2017-09-02 05:13:33 +00:00
* width = 0 ; //DisplayWidth(xtemp, scr);
* height = 0 ; //DisplayHeight(xtemp, scr);
2014-03-30 08:55:06 +00:00
* bpp = DefaultDepth ( xtemp , scr ) ;
* refreshrate = 0 ;
2013-03-12 23:04:11 +00:00
2014-03-30 08:55:06 +00:00
x11 . pXCloseDisplay ( xtemp ) ;
2013-03-12 23:04:11 +00:00
2014-03-30 08:55:06 +00:00
return true ;
2013-03-12 23:04:11 +00:00
}
2018-08-23 07:04:55 +00:00
# endif
void Sys_SendKeyEvents ( void )
{
# ifndef CLIENTONLY
//this is stupid
SV_GetConsoleCommands ( ) ;
# endif
# ifndef NO_X11
if ( sys_gracefulexit )
{
Cbuf_AddText ( " \n quit \n " , RESTRICT_LOCAL ) ;
sys_gracefulexit = false ;
}
if ( vid_dpy & & vid_window )
{
2018-11-27 16:48:19 +00:00
if ( x11 . unicodecontext )
{
qboolean want = vid . ime_allow & & vid . activeapp ;
XPoint pos ;
if ( want ! = x11 . ime_shown )
{
x11 . ime_shown = want ;
if ( x11 . ime_shown )
x11 . pXSetICFocus ( x11 . unicodecontext ) ;
else
x11 . pXUnsetICFocus ( x11 . unicodecontext ) ;
}
pos . x = ( vid . ime_position [ 0 ] * vid . pixelwidth ) / vid . width ;
pos . y = ( vid . ime_position [ 1 ] * vid . pixelheight ) / vid . height ;
if ( /*x11.ime_shown &&*/ ( x11 . ime_pos . x ! = pos . x | | x11 . ime_pos . y ! = pos . y ) )
{
void * attr [ ] = { XNSpotLocation , & x11 . ime_pos , NULL } ;
x11 . ime_pos = pos ;
x11 . pXSetICValues ( x11 . unicodecontext , XNPreeditAttributes , attr , NULL ) ;
}
}
2018-08-23 07:04:55 +00:00
while ( x11 . pXPending ( vid_dpy ) )
GetEvent ( ) ;
if ( modeswitchpending & & modeswitchtime < Sys_Milliseconds ( ) )
{
UpdateGrabs ( ) ;
if ( modeswitchpending > 0 & & ! ( fullscreenflags & FULLSCREEN_ACTIVE ) )
{
//entering fullscreen mode
# ifdef USE_VMODE
if ( fullscreenflags & FULLSCREEN_VMODE )
{
if ( ! ( fullscreenflags & FULLSCREEN_VMODEACTIVE ) )
{
// change to the mode
vm . pXF86VidModeSwitchToMode ( vid_dpy , scrnum , vm . modes [ vm . usemode ] ) ;
fullscreenflags | = FULLSCREEN_VMODEACTIVE ;
// Move the viewport to top left
}
vm . pXF86VidModeSetViewPort ( vid_dpy , scrnum , 0 , 0 ) ;
}
# endif
# ifdef USE_XRANDR
if ( fullscreenflags & FULLSCREEN_XRANDR )
XRandR_ApplyMode ( ) ;
# endif
Cvar_ForceCallback ( & v_gamma ) ;
/*release the mouse now, because we're paranoid about clip regions*/
if ( fullscreenflags & FULLSCREEN_WM )
X_GoFullscreen ( ) ;
if ( fullscreenflags & FULLSCREEN_LEGACY )
{
x11 . pXReparentWindow ( vid_dpy , vid_window , vid_root , fullscreenx , fullscreeny ) ;
// if (vid_decoywindow)
// x11.pXMoveWindow(vid_dpy, vid_decoywindow, fullscreenx, fullscreeny);
//x11.pXUnmapWindow(vid_dpy, vid_decoywindow);
//make sure we have it
x11 . pXSetInputFocus ( vid_dpy , vid_window , RevertToParent , CurrentTime ) ;
x11 . pXRaiseWindow ( vid_dpy , vid_window ) ;
x11 . pXMoveResizeWindow ( vid_dpy , vid_window , fullscreenx , fullscreeny , fullscreenwidth , fullscreenheight ) ;
}
if ( fullscreenflags )
fullscreenflags | = FULLSCREEN_ACTIVE ;
2021-07-01 01:16:11 +00:00
vid_isfullscreen = ! ! ( fullscreenflags & FULLSCREEN_ACTIVE ) ;
2018-08-23 07:04:55 +00:00
}
if ( modeswitchpending < 0 )
{
//leave fullscreen mode
if ( ! COM_CheckParm ( " -stayactive " ) )
{ //a parameter that leaves the program fullscreen if you taskswitch.
//sounds pointless, works great with two moniters. :D
# ifdef USE_VMODE
if ( fullscreenflags & FULLSCREEN_VMODE )
{
if ( vm . originalapplied )
vm . pXF86VidModeSetGammaRamp ( vid_dpy , scrnum , vm . originalrampsize , vm . originalramps [ 0 ] , vm . originalramps [ 1 ] , vm . originalramps [ 2 ] ) ;
if ( fullscreenflags & FULLSCREEN_VMODEACTIVE )
{
vm . pXF86VidModeSwitchToMode ( vid_dpy , scrnum , vm . modes [ 0 ] ) ;
fullscreenflags & = ~ FULLSCREEN_VMODEACTIVE ;
}
}
# endif
# ifdef USE_XRANDR
if ( fullscreenflags & FULLSCREEN_XRANDR )
XRandR_RevertMode ( ) ;
# endif
if ( fullscreenflags & FULLSCREEN_WM )
X_GoWindowed ( ) ;
if ( fullscreenflags & FULLSCREEN_LEGACY )
{
x11 . pXReparentWindow ( vid_dpy , vid_window , vid_decoywindow , 0 , 0 ) ;
// x11.pXMoveResizeWindow(vid_dpy, vid_decoywindow, fullscreenx + (fullscreenwidth-640)/2, fullscreeny + (fullscreenheight-480)/2, 640, 480);
x11 . pXMapWindow ( vid_dpy , vid_decoywindow ) ;
}
fullscreenflags & = ~ FULLSCREEN_ACTIVE ;
2021-07-01 01:16:11 +00:00
vid_isfullscreen = ! ! ( fullscreenflags & FULLSCREEN_ACTIVE ) ;
2018-08-23 07:04:55 +00:00
}
}
modeswitchpending = 0 ;
}
if ( modeswitchpending )
return ;
UpdateGrabs ( ) ;
}
# endif
}
2018-10-11 10:31:23 +00:00
/*static void Force_CenterView_f (void)
2018-08-23 07:04:55 +00:00
{
cl . playerview [ 0 ] . viewangles [ PITCH ] = 0 ;
2018-10-11 10:31:23 +00:00
} */
2018-08-23 07:04:55 +00:00
//these are done from the x11 event handler. we don't support evdev.
void INS_Move ( void )
{
}
void INS_Commands ( void )
{
}
void INS_Init ( void )
{
}
void INS_ReInit ( void )
{
}
void INS_Shutdown ( void )
{
}
void INS_EnumerateDevices ( void * ctx , void ( * callback ) ( void * ctx , const char * type , const char * devicename , unsigned int * qdevid ) )
{
# ifndef NO_X11
callback ( ctx , " keyboard " , " x11 " , NULL ) ;
switch ( x11_input_method )
{
case XIM_ORIG :
callback ( ctx , " mouse " , " x11 " , & x11_mouseqdev ) ;
break ;
case XIM_DGA :
callback ( ctx , " mouse " , " dga " , & x11_mouseqdev ) ;
break ;
case XIM_XI2 :
{
int i , devs ;
XIDeviceInfo * dev = xi2 . pXIQueryDevice ( vid_dpy , xi2 . devicegroup , & devs ) ;
2019-03-01 22:39:30 +00:00
if ( dev )
2018-08-23 07:04:55 +00:00
{
2019-03-01 22:39:30 +00:00
for ( i = 0 ; i < devs ; i + + )
2018-08-23 07:04:55 +00:00
{
2019-03-01 22:39:30 +00:00
if ( ! dev [ i ] . enabled )
continue ;
if ( /*dev[i].use == XIMasterPointer ||*/ dev [ i ] . use = = XISlavePointer )
{
struct xidevinfo * devi = XI2_GetDeviceInfo ( dev [ i ] . deviceid ) ;
callback ( ctx , devi - > abs ? " tablet " : " mouse " , dev [ i ] . name , & devi - > qdev ) ;
}
// else if (dev[i].use == XIMasterKeyboard || dev[i].use == XISlaveKeyboard)
// {
// int qdev = dev[i].deviceid;
// callback(ctx, "xi2kb", dev[i].name, &qdev);
// }
2018-08-23 07:04:55 +00:00
}
2019-03-01 22:39:30 +00:00
xi2 . pXIFreeDeviceInfo ( dev ) ;
2018-08-23 07:04:55 +00:00
}
}
break ;
}
# endif
}
2016-07-30 17:59:55 +00:00
2021-07-25 16:12:24 +00:00
/* doubt this will ever happen to begin with */
2021-08-04 21:18:04 +00:00
void INS_Rumble ( int id , quint16_t amp_low , quint16_t amp_high , quint32_t duration )
2021-07-25 16:12:24 +00:00
{
//Con_DPrintf(CON_WARNING "Rumble is unavailable on this platform\n");
}
2021-08-04 21:18:04 +00:00
void INS_RumbleTriggers ( int id , quint16_t left , quint16_t right , quint32_t duration )
2021-07-25 16:12:24 +00:00
{
//Con_DPrintf(CON_WARNING "Trigger rumble is unavailable on this platform\n");
}
2021-08-04 21:18:04 +00:00
void INS_SetLEDColor ( int id , vec3_t color )
2021-07-25 16:12:24 +00:00
{
//Con_DPrintf(CON_WARNING "Game-Pad LED colors are unavailable on this platform\n");
}
2021-08-04 21:18:04 +00:00
void INS_SetTriggerFX ( int id , const void * data , size_t size )
2021-07-25 16:12:24 +00:00
{
//Con_DPrintf(CON_WARNING "Trigger FX are unavailable on this platform\n");
}