From f986f933f2e77d895932cf074febabed6e4190da Mon Sep 17 00:00:00 2001
From: Rudolf Polzer <divverent@xonotic.org>
Date: Tue, 20 Aug 2013 10:41:12 +0200
Subject: [PATCH] rename netwmfullscreen to desktopfullscreen

---
 vid.h        |  1 +
 vid_glx.c    | 35 +++++++++++++++++------------------
 vid_shared.c |  2 ++
 3 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/vid.h b/vid.h
index 650d3223..901c8f71 100644
--- a/vid.h
+++ b/vid.h
@@ -199,6 +199,7 @@ extern cvar_t vid_touchscreen_showkeyboard;
 extern cvar_t vid_touchscreen_supportshowkeyboard;
 extern cvar_t vid_stick_mouse;
 extern cvar_t vid_resizable;
+extern cvar_t vid_desktopfullscreen;
 extern cvar_t vid_minwidth;
 extern cvar_t vid_minheight;
 extern cvar_t vid_sRGB;
diff --git a/vid_glx.c b/vid_glx.c
index c066555c..b9c72d46 100644
--- a/vid_glx.c
+++ b/vid_glx.c
@@ -129,7 +129,6 @@ static int vid_x11_gammarampsize = 0;
 cvar_t vid_dgamouse = {CVAR_SAVE, "vid_dgamouse", "0", "make use of DGA mouse input"};
 static qboolean vid_usingdgamouse = false;
 #endif
-cvar_t vid_netwmfullscreen = {CVAR_SAVE, "vid_netwmfullscreen", "0", "make use _NET_WM_STATE_FULLSCREEN; turn this off if fullscreen does not work for you"};
 
 qboolean vidmode_ext = false;
 
@@ -138,7 +137,7 @@ static int win_x, win_y;
 static XF86VidModeModeInfo init_vidmode, game_vidmode;
 static qboolean vid_isfullscreen = false;
 static qboolean vid_isvidmodefullscreen = false;
-static qboolean vid_isnetwmfullscreen = false;
+static qboolean vid_isdesktopfullscreen = false;
 static qboolean vid_isoverrideredirect = false;
 
 static Visual *vidx11_visual;
@@ -654,11 +653,11 @@ static void HandleEvents(void)
 			// window changed size/location
 			win_x = event.xconfigure.x;
 			win_y = event.xconfigure.y;
-			if((vid_resizable.integer < 2 || vid_isnetwmfullscreen) && (vid.width != event.xconfigure.width || vid.height != event.xconfigure.height))
+			if((vid_resizable.integer < 2 || vid_isdesktopfullscreen) && (vid.width != event.xconfigure.width || vid.height != event.xconfigure.height))
 			{
 				vid.width = event.xconfigure.width;
 				vid.height = event.xconfigure.height;
-				if(vid_isnetwmfullscreen)
+				if(vid_isdesktopfullscreen)
 					Con_Printf("NetWM fullscreen: actually using resolution %dx%d\n", vid.width, vid.height);
 				else
 					Con_DPrintf("Updating to ConfigureNotify resolution %dx%d\n", vid.width, vid.height);
@@ -703,7 +702,7 @@ static void HandleEvents(void)
 				XF86VidModeSetViewPort(vidx11_display, vidx11_screen, 0, 0);
 			}
 
-			if(vid_isnetwmfullscreen)
+			if(vid_isdesktopfullscreen)
 			{
 				// make sure it's fullscreen
 				XEvent event;
@@ -745,7 +744,7 @@ static void HandleEvents(void)
 			if (vid_isoverrideredirect)
 				break;
 
-			if(vid_isnetwmfullscreen && event.xfocus.mode == NotifyNormal)
+			if(vid_isdesktopfullscreen && event.xfocus.mode == NotifyNormal)
 			{
 				// iconify netwm fullscreen window when it loses focus
 				// when the user selects it in the taskbar, the window manager will map it again and send MapNotify
@@ -866,7 +865,7 @@ void VID_Shutdown(void)
 
 	vid_hidden = true;
 	vid_isfullscreen = false;
-	vid_isnetwmfullscreen = false;
+	vid_isdesktopfullscreen = false;
 	vid_isvidmodefullscreen = false;
 	vid_isoverrideredirect = false;
 	vidx11_display = NULL;
@@ -974,7 +973,7 @@ void VID_Init(void)
 #ifdef USEDGA
 	Cvar_RegisterVariable (&vid_dgamouse);
 #endif
-	Cvar_RegisterVariable (&vid_netwmfullscreen);
+	Cvar_RegisterVariable (&vid_desktopfullscreen);
 	InitSig(); // trap evil signals
 // COMMANDLINEOPTION: Input: -nomouse disables mouse support (see also vid_mouse cvar)
 	if (COM_CheckParm ("-nomouse"))
@@ -1026,7 +1025,7 @@ static qboolean VID_InitModeSoft(viddef_mode_t *mode)
 	char vabuf[1024];
 
 	vid_isfullscreen = false;
-	vid_isnetwmfullscreen = false;
+	vid_isdesktopfullscreen = false;
 	vid_isvidmodefullscreen = false;
 	vid_isoverrideredirect = false;
 
@@ -1064,10 +1063,10 @@ static qboolean VID_InitModeSoft(viddef_mode_t *mode)
 
 	if (mode->fullscreen)
 	{
-		if(vid_netwmfullscreen.integer)
+		if(vid_desktopfullscreen.integer)
 		{
 			// TODO detect WM support
-			vid_isnetwmfullscreen = true;
+			vid_isdesktopfullscreen = true;
 			vid_isfullscreen = true;
 			// width and height will be filled in later
 			Con_DPrintf("Using NetWM fullscreen mode\n");
@@ -1151,7 +1150,7 @@ static qboolean VID_InitModeSoft(viddef_mode_t *mode)
 
 	if (mode->fullscreen)
 	{
-		if(vid_isnetwmfullscreen)
+		if(vid_isdesktopfullscreen)
 		{
 			mask = CWBackPixel | CWColormap | CWSaveUnder | CWBackingStore | CWEventMask;
 			attr.backing_store = NotUseful;
@@ -1224,7 +1223,7 @@ static qboolean VID_InitModeSoft(viddef_mode_t *mode)
 	clshints->res_class = strdup("DarkPlaces");
 
 	szhints = XAllocSizeHints();
-	if(vid_resizable.integer == 0 && !vid_isnetwmfullscreen)
+	if(vid_resizable.integer == 0 && !vid_isdesktopfullscreen)
 	{
 		szhints->min_width = szhints->max_width = mode->width;
 		szhints->min_height = szhints->max_height = mode->height;
@@ -1326,7 +1325,7 @@ static qboolean VID_InitModeGL(viddef_mode_t *mode)
 	char vabuf[1024];
 
 	vid_isfullscreen = false;
-	vid_isnetwmfullscreen = false;
+	vid_isdesktopfullscreen = false;
 	vid_isvidmodefullscreen = false;
 	vid_isoverrideredirect = false;
 
@@ -1399,10 +1398,10 @@ static qboolean VID_InitModeGL(viddef_mode_t *mode)
 
 	if (mode->fullscreen)
 	{
-		if(vid_netwmfullscreen.integer)
+		if(vid_desktopfullscreen.integer)
 		{
 			// TODO detect WM support
-			vid_isnetwmfullscreen = true;
+			vid_isdesktopfullscreen = true;
 			vid_isfullscreen = true;
 			// width and height will be filled in later
 			Con_DPrintf("Using NetWM fullscreen mode\n");
@@ -1486,7 +1485,7 @@ static qboolean VID_InitModeGL(viddef_mode_t *mode)
 
 	if (mode->fullscreen)
 	{
-		if(vid_isnetwmfullscreen)
+		if(vid_isdesktopfullscreen)
 		{
 			mask = CWBackPixel | CWColormap | CWSaveUnder | CWBackingStore | CWEventMask;
 			attr.backing_store = NotUseful;
@@ -1559,7 +1558,7 @@ static qboolean VID_InitModeGL(viddef_mode_t *mode)
 	clshints->res_class = strdup("DarkPlaces");
 
 	szhints = XAllocSizeHints();
-	if(vid_resizable.integer == 0 && !vid_isnetwmfullscreen)
+	if(vid_resizable.integer == 0 && !vid_isdesktopfullscreen)
 	{
 		szhints->min_width = szhints->max_width = mode->width;
 		szhints->min_height = szhints->max_height = mode->height;
diff --git a/vid_shared.c b/vid_shared.c
index 175c7512..2d6497e5 100644
--- a/vid_shared.c
+++ b/vid_shared.c
@@ -189,6 +189,7 @@ cvar_t vid_touchscreen_showkeyboard = {0, "vid_touchscreen_showkeyboard", "0", "
 cvar_t vid_touchscreen_supportshowkeyboard = {CVAR_READONLY, "vid_touchscreen_supportshowkeyboard", "0", "indicates if the platform supports a virtual keyboard"};
 cvar_t vid_stick_mouse = {CVAR_SAVE, "vid_stick_mouse", "0", "have the mouse stuck in the center of the screen" };
 cvar_t vid_resizable = {CVAR_SAVE, "vid_resizable", "0", "0: window not resizable, 1: resizable, 2: window can be resized but the framebuffer isn't adjusted" };
+cvar_t vid_desktopfullscreen = {CVAR_SAVE, "vid_desktopfullscreen", "0", "force desktop resolution for fullscreen; also use some OS dependent tricks for better fullscreen integration"};
 
 cvar_t v_gamma = {CVAR_SAVE, "v_gamma", "1", "inverse gamma correction value, a brightness effect that does not affect white or black, and tends to make the image grey and dull"};
 cvar_t v_contrast = {CVAR_SAVE, "v_contrast", "1", "brightness of white (values above 1 give a brighter image with increased color saturation, unlike v_gamma)"};
@@ -1770,6 +1771,7 @@ void VID_Shared_Init(void)
 	Cvar_RegisterVariable(&vid_touchscreen_supportshowkeyboard);
 	Cvar_RegisterVariable(&vid_stick_mouse);
 	Cvar_RegisterVariable(&vid_resizable);
+	Cvar_RegisterVariable(&vid_desktopfullscreen);
 	Cvar_RegisterVariable(&vid_minwidth);
 	Cvar_RegisterVariable(&vid_minheight);
 	Cvar_RegisterVariable(&vid_gl13);
-- 
2.39.5