Accept SDL_VIDEO_WINDOW_POS in --fullscreen too

This seems to allow me to specify which display (monitor) to make
Tux Paint appear on my two-monitor set-up (laptop + external monitor)!

Closes https://sourceforge.net/p/tuxpaint/bugs/277/
This commit is contained in:
Bill Kendrick 2023-04-28 00:13:32 -07:00
parent 3d1efe8661
commit 378b2acca6
12 changed files with 86 additions and 69 deletions

View file

@ -6,7 +6,7 @@ Copyright (c) 2002-2023
Various contributors (see below, and AUTHORS.txt)
https://tuxpaint.org/
2023.April.27 (0.9.30)
2023.April.28 (0.9.30)
* Improvements to Stamp tool:
---------------------------
* Avoid playing English descriptive sound for a stamp
@ -104,6 +104,12 @@ https://tuxpaint.org/
(shows when certain features are enabled; not just disabled)
Bill Kendrick <bill@newbreedsoftware.com>
* SDL_VIDEO_WINDOW_POS environment variable is now recognized
when running Tux Paint in fullscreen mode (useful for positioning
Tux Paint on a particular monitor).
Closes https://sourceforge.net/p/tuxpaint/bugs/277/
Bill Kendrick <bill@newbreedsoftware.com>
* Starter and Template Improvements
---------------------------------
* More starters have smearing disabled (world maps & "skyline-sf-dusk")

View file

@ -76,7 +76,7 @@ Language-related environment variables
Display-related environment variables
The following are a few of the environment variables supported by Simple
DirectMedia Layer (libSD) — which Tux Paint utilizes for displaying
DirectMedia Layer (libSDL) — which Tux Paint utilizes for displaying
graphics, playing sounds, and receiving mouse, keyboard, and joystick
input — and which may be useful to users of Tux Paint.
@ -89,6 +89,9 @@ Display-related environment variables
SDL_VIDEO_WINDOW_POS
Requests where to position Tux Paint's window. Normally set to
"center" by Tux Paint itself, unless the environment variable is
already set (e.g., to "nopref", meaning "no preference").
Requests where to position Tux Paint's window, and can be used to
specify what display to place a fullscreen Tux Paint in a
multi-monitor configuration. If not set, or set to "nopref"
(meaning "no preference"), Simple DirectMedia Layer (libSDL)
decides. Can be set to an X,Y coordinate (e.g. 200,100), or
"center" (meaning "center").

View file

@ -110,7 +110,7 @@
Display-related environment variables </h2>
<p>
The following are a few of the environment variables supported by Simple DirectMedia Layer (libSD) &mdash; which Tux Paint utilizes for displaying graphics, playing sounds, and receiving mouse, keyboard, and joystick input &mdash; and which may be useful to users of Tux Paint.
The following are a few of the environment variables supported by Simple DirectMedia Layer (libSDL) &mdash; which Tux Paint utilizes for displaying graphics, playing sounds, and receiving mouse, keyboard, and joystick input &mdash; and which may be useful to users of Tux Paint.
<dl>
<dt>
<code>SDL_VIDEO_ALLOW_SCREENSAVER</code>
@ -124,7 +124,7 @@
</dt>
<dd>
<p>
Requests where to position Tux Paint's window. Normally set to "<code>center</code>" by Tux Paint itself, unless the environment variable is already set (e.g., to "<code>nopref</code>", meaning "no preference"). </p>
Requests where to position Tux Paint's window, and can be used to specify what display to place a fullscreen Tux Paint in a multi-monitor configuration. If not set, or set to "<code>nopref</code>" (meaning "no preference"), Simple DirectMedia Layer (libSDL) decides. Can be set to an <code>X,Y</code> coordinate (e.g. <code>200,100</code>), or "<code>center</code>" (meaning "center"). </p>
</dd>
</dl>

View file

@ -76,7 +76,7 @@ Language-related environment variables
Display-related environment variables
The following are a few of the environment variables supported by Simple
DirectMedia Layer (libSD) — which Tux Paint utilizes for displaying
DirectMedia Layer (libSDL) — which Tux Paint utilizes for displaying
graphics, playing sounds, and receiving mouse, keyboard, and joystick
input — and which may be useful to users of Tux Paint.
@ -89,6 +89,9 @@ Display-related environment variables
SDL_VIDEO_WINDOW_POS
Requests where to position Tux Paint's window. Normally set to
"center" by Tux Paint itself, unless the environment variable is
already set (e.g., to "nopref", meaning "no preference").
Requests where to position Tux Paint's window, and can be used to
specify what display to place a fullscreen Tux Paint in a
multi-monitor configuration. If not set, or set to "nopref"
(meaning "no preference"), Simple DirectMedia Layer (libSDL)
decides. Can be set to an X,Y coordinate (e.g. 200,100), or
"center" (meaning "center").

View file

@ -110,7 +110,7 @@
Display-related environment variables </h2>
<p>
The following are a few of the environment variables supported by Simple DirectMedia Layer (libSD) &mdash; which Tux Paint utilizes for displaying graphics, playing sounds, and receiving mouse, keyboard, and joystick input &mdash; and which may be useful to users of Tux Paint.
The following are a few of the environment variables supported by Simple DirectMedia Layer (libSDL) &mdash; which Tux Paint utilizes for displaying graphics, playing sounds, and receiving mouse, keyboard, and joystick input &mdash; and which may be useful to users of Tux Paint.
<dl>
<dt>
<code>SDL_VIDEO_ALLOW_SCREENSAVER</code>
@ -124,7 +124,7 @@
</dt>
<dd>
<p>
Requests where to position Tux Paint's window. Normally set to "<code>center</code>" by Tux Paint itself, unless the environment variable is already set (e.g., to "<code>nopref</code>", meaning "no preference"). </p>
Requests where to position Tux Paint's window, and can be used to specify what display to place a fullscreen Tux Paint in a multi-monitor configuration. If not set, or set to "<code>nopref</code>" (meaning "no preference"), Simple DirectMedia Layer (libSDL) decides. Can be set to an <code>X,Y</code> coordinate (e.g. <code>200,100</code>), or "<code>center</code>" (meaning "center"). </p>
</dd>
</dl>

View file

@ -85,7 +85,7 @@ Variables d'environnement relatives aux langues
Variables d'environnement en rapport avec l'affichage
Ce qui suit donne quelques variables d'environnement supportées par Simple
DirectMedia Layer (libSD) — que Tux Paint utilise pour l'affichage des
DirectMedia Layer (libSDL) — que Tux Paint utilise pour l'affichage des
dessins, pour jouer des sons et traiter les saisies de la souris, du
clavier et du joystick — et qui peuvent être utiles aux utilisateurs de
Tux Paint.
@ -99,7 +99,9 @@ Variables d'environnement en rapport avec l'affichage
SDL_VIDEO_WINDOW_POS
Indique où positionner la fenêtre de Tux Paint. Normalement
positionnée à "center" par Tux Paint lui-même, à moins que la
variable d'environnement n'ait déjà une valeur (par ex. "nopref"
signifie pas de préférence).
Requests where to position Tux Paint's window, and can be used to
specify what display to place a fullscreen Tux Paint in a
multi-monitor configuration. If not set, or set to "nopref"
(meaning "no preference"), Simple DirectMedia Layer (libSDL)
decides. Can be set to an X,Y coordinate (e.g. 200,100), or
"center" (meaning "center").

View file

@ -110,7 +110,7 @@
Variables d'environnement en rapport avec l'affichage </h2>
<p>
Ce qui suit donne quelques variables d'environnement supportées par Simple DirectMedia Layer (libSD) &mdash; que Tux Paint utilise pour l'affichage des dessins, pour jouer des sons et traiter les saisies de la souris, du clavier et du joystick &mdash; et qui peuvent être utiles aux utilisateurs de Tux Paint.
Ce qui suit donne quelques variables d'environnement supportées par Simple DirectMedia Layer (libSDL) &mdash; que Tux Paint utilise pour l'affichage des dessins, pour jouer des sons et traiter les saisies de la souris, du clavier et du joystick &mdash; et qui peuvent être utiles aux utilisateurs de Tux Paint.
<dl>
<dt>
<code>SDL_VIDEO_ALLOW_SCREENSAVER</code>
@ -124,7 +124,7 @@
</dt>
<dd>
<p>
Indique où positionner la fenêtre de Tux Paint. Normalement positionnée à "<code>center</code>" par Tux Paint lui-même, à moins que la variable d'environnement n'ait déjà une valeur (par ex. "<code>nopref</code>" signifie pas de préférence). </p>
Requests where to position Tux Paint's window, and can be used to specify what display to place a fullscreen Tux Paint in a multi-monitor configuration. If not set, or set to "<code>nopref</code>" (meaning "no preference"), Simple DirectMedia Layer (libSDL) decides. Can be set to an <code>X,Y</code> coordinate (e.g. <code>200,100</code>), or "<code>center</code>" (meaning "center"). </p>
</dd>
</dl>

View file

@ -79,7 +79,7 @@ Variábeis de contorno relacionadas co idioma
Variábeisbles de contorno relacionadas co que se amosa
A seguir amósanse algunhas das variábeis de contorno compatíbeis con
Simple DirectMedia Layer (libSD) — que Tux Paint utiliza para amosar
Simple DirectMedia Layer (libSDL) — que Tux Paint utiliza para amosar
gráficos, reproducir sons e recibir entrada do rato, teclado e joystick —
e que poden ser útiles para os usuarios de Tux Paint.
@ -92,6 +92,9 @@ Variábeisbles de contorno relacionadas co que se amosa
SDL_VIDEO_WINDOW_POS
Requests where to position Tux Paint's window. Normally set to
"center" by Tux Paint itself, unless the environment variable is
already set (e.g., to "nopref", meaning "no preference").
Requests where to position Tux Paint's window, and can be used to
specify what display to place a fullscreen Tux Paint in a
multi-monitor configuration. If not set, or set to "nopref"
(meaning "no preference"), Simple DirectMedia Layer (libSDL)
decides. Can be set to an X,Y coordinate (e.g. 200,100), or
"center" (meaning "center").

View file

@ -110,7 +110,7 @@
Variábeisbles de contorno relacionadas co que se amosa </h2>
<p>
A seguir amósanse algunhas das variábeis de contorno compatíbeis con Simple DirectMedia Layer (libSD) &mdash; que Tux Paint utiliza para amosar gráficos, reproducir sons e recibir entrada do rato, teclado e joystick &mdash; e que poden ser útiles para os usuarios de Tux Paint.
A seguir amósanse algunhas das variábeis de contorno compatíbeis con Simple DirectMedia Layer (libSDL) &mdash; que Tux Paint utiliza para amosar gráficos, reproducir sons e recibir entrada do rato, teclado e joystick &mdash; e que poden ser útiles para os usuarios de Tux Paint.
<dl>
<dt>
<code>SDL_VIDEO_ALLOW_SCREENSAVER</code>
@ -124,7 +124,7 @@
</dt>
<dd>
<p>
Requests where to position Tux Paint's window. Normally set to "<code>center</code>" by Tux Paint itself, unless the environment variable is already set (e.g., to "<code>nopref</code>", meaning "no preference"). </p>
Requests where to position Tux Paint's window, and can be used to specify what display to place a fullscreen Tux Paint in a multi-monitor configuration. If not set, or set to "<code>nopref</code>" (meaning "no preference"), Simple DirectMedia Layer (libSDL) decides. Can be set to an <code>X,Y</code> coordinate (e.g. <code>200,100</code>), or "<code>center</code>" (meaning "center"). </p>
</dd>
</dl>

View file

@ -76,7 +76,7 @@ Language-related environment variables
Display-related environment variables
The following are a few of the environment variables supported by Simple
DirectMedia Layer (libSD) — which Tux Paint utilizes for displaying
DirectMedia Layer (libSDL) — which Tux Paint utilizes for displaying
graphics, playing sounds, and receiving mouse, keyboard, and joystick
input — and which may be useful to users of Tux Paint.
@ -89,6 +89,9 @@ Display-related environment variables
SDL_VIDEO_WINDOW_POS
Requests where to position Tux Paint's window. Normally set to
"center" by Tux Paint itself, unless the environment variable is
already set (e.g., to "nopref", meaning "no preference").
Requests where to position Tux Paint's window, and can be used to
specify what display to place a fullscreen Tux Paint in a
multi-monitor configuration. If not set, or set to "nopref"
(meaning "no preference"), Simple DirectMedia Layer (libSDL)
decides. Can be set to an X,Y coordinate (e.g. 200,100), or
"center" (meaning "center").

View file

@ -110,7 +110,7 @@
Display-related environment variables </h2>
<p>
The following are a few of the environment variables supported by Simple DirectMedia Layer (libSD) &mdash; which Tux Paint utilizes for displaying graphics, playing sounds, and receiving mouse, keyboard, and joystick input &mdash; and which may be useful to users of Tux Paint.
The following are a few of the environment variables supported by Simple DirectMedia Layer (libSDL) &mdash; which Tux Paint utilizes for displaying graphics, playing sounds, and receiving mouse, keyboard, and joystick input &mdash; and which may be useful to users of Tux Paint.
<dl>
<dt>
<code>SDL_VIDEO_ALLOW_SCREENSAVER</code>
@ -124,7 +124,7 @@
</dt>
<dd>
<p>
Requests where to position Tux Paint's window. Normally set to "<code>center</code>" by Tux Paint itself, unless the environment variable is already set (e.g., to "<code>nopref</code>", meaning "no preference"). </p>
Requests where to position Tux Paint's window, and can be used to specify what display to place a fullscreen Tux Paint in a multi-monitor configuration. If not set, or set to "<code>nopref</code>" (meaning "no preference"), Simple DirectMedia Layer (libSDL) decides. Can be set to an <code>X,Y</code> coordinate (e.g. <code>200,100</code>), or "<code>center</code>" (meaning "center"). </p>
</dd>
</dl>

View file

@ -22,7 +22,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
June 14, 2002 - April 27, 2023
June 14, 2002 - April 28, 2023
*/
#include "platform.h"
@ -28954,6 +28954,7 @@ static void setup(void)
SDL_Rect dest;
int scale;
int canvas_width, canvas_height;
int win_x = SDL_WINDOWPOS_UNDEFINED, win_y = SDL_WINDOWPOS_UNDEFINED;
#ifndef LOW_QUALITY_COLOR_SELECTOR
int x, y;
@ -29176,22 +29177,49 @@ static void setup(void)
}
/* SDL1.2 supported "SDL_VIDEO_WINDOW_POS", but SDL2 does not,
so we implement it ourselves */
if (getenv((char *)"SDL_VIDEO_WINDOW_POS") != NULL)
{
char *winpos;
winpos = getenv((char *)"SDL_VIDEO_WINDOW_POS");
if (strcmp(winpos, "nopref") != 0)
{
if (strcmp(winpos, "center") == 0)
{
win_x = SDL_WINDOWPOS_CENTERED;
win_y = SDL_WINDOWPOS_CENTERED;
}
else
{
int success;
success = sscanf(winpos, "%d,%d", &win_x, &win_y);
if (success != 2)
{
fprintf(stderr, "Warning: Cannot parse SDL_VIDEO_WINDOW_POS value of \"%s\"; ignoring\n", winpos);
win_x = SDL_WINDOWPOS_UNDEFINED;
win_y = SDL_WINDOWPOS_UNDEFINED;
}
}
}
}
/* Open Window: */
if (fullscreen)
{
#ifdef USE_HWSURFACE
window_screen =
SDL_CreateWindow("Tux Paint", SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
SDL_CreateWindow("Tux Paint", win_x, win_y,
WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_HWSURFACE);
if (window_screen == NULL)
printf("window_screen = NULL 1\n");
#else
window_screen = SDL_CreateWindow(NULL,
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
window_screen = SDL_CreateWindow(NULL, win_x, win_y,
WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_FULLSCREEN_DESKTOP);
if (window_screen == NULL)
printf("window_screen = NULL 2\n");
@ -29291,7 +29319,6 @@ static void setup(void)
if (!fullscreen)
{
int win_x = SDL_WINDOWPOS_UNDEFINED, win_y = SDL_WINDOWPOS_UNDEFINED;
int max_scrn_w, max_scrn_h;
int num_displays, i, res;
SDL_DisplayMode mode;
@ -29357,36 +29384,6 @@ static void setup(void)
}
/* SDL1.2 supported "SDL_VIDEO_WINDOW_POS", but SDL2 does not,
so we implement it ourselves */
if (getenv((char *)"SDL_VIDEO_WINDOW_POS") != NULL)
{
char *winpos;
winpos = getenv((char *)"SDL_VIDEO_WINDOW_POS");
if (strcmp(winpos, "nopref") != 0)
{
if (strcmp(winpos, "center") == 0)
{
win_x = SDL_WINDOWPOS_CENTERED;
win_y = SDL_WINDOWPOS_CENTERED;
}
else
{
int success;
success = sscanf(winpos, "%d,%d", &win_x, &win_y);
if (success != 2)
{
fprintf(stderr, "Warning: Cannot parse SDL_VIDEO_WINDOW_POS value of \"%s\"; ignoring\n", winpos);
win_x = SDL_WINDOWPOS_UNDEFINED;
win_y = SDL_WINDOWPOS_UNDEFINED;
}
}
}
}
/* Finally, ready to create a window! */
#ifdef USE_HWSURFACE
window_screen = SDL_CreateWindow("Tux Paint", win_x, win_y, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_HWSURFACE);