Bring back support for SDL_VIDEO_WINDOW_POS envvar
SDL1.2 supported "SDL_VIDEO_WINDOW_POS" environment variable, but SDL2 does not; so reimplemented it ourselves. (See ENVARS docs.)
This commit is contained in:
parent
d87497e168
commit
949438e2fb
2 changed files with 37 additions and 40 deletions
|
|
@ -7,7 +7,7 @@ Various contributors (see below, and AUTHORS.txt)
|
||||||
https://tuxpaint.org/
|
https://tuxpaint.org/
|
||||||
|
|
||||||
|
|
||||||
2022.January.16 (0.9.29)
|
2022.January.19 (0.9.29)
|
||||||
* Improvements to "Stamp" tool:
|
* Improvements to "Stamp" tool:
|
||||||
-----------------------------
|
-----------------------------
|
||||||
* Stamps may now be rotated.
|
* Stamps may now be rotated.
|
||||||
|
|
@ -67,6 +67,10 @@ https://tuxpaint.org/
|
||||||
Closes https://sourceforge.net/p/tuxpaint/bugs/259/
|
Closes https://sourceforge.net/p/tuxpaint/bugs/259/
|
||||||
Bill Kendrick <bill@newbreedsoftware.com>
|
Bill Kendrick <bill@newbreedsoftware.com>
|
||||||
|
|
||||||
|
* SDL1.2 supported "SDL_VIDEO_WINDOW_POS" environment variable,
|
||||||
|
but SDL2 does not; so reimplemented it ourselves. (See ENVARS docs.)
|
||||||
|
Bill Kendrick <bill@newbreedsoftware.com>
|
||||||
|
|
||||||
* Mended issue that prevented pop-up prompt's drop-shadows
|
* Mended issue that prevented pop-up prompt's drop-shadows
|
||||||
from rendering (under SDL2).
|
from rendering (under SDL2).
|
||||||
Bill Kendrick <bill@newbreedsoftware.com>
|
Bill Kendrick <bill@newbreedsoftware.com>
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
(See COPYING.txt)
|
(See COPYING.txt)
|
||||||
|
|
||||||
June 14, 2002 - January 11, 2023
|
June 14, 2002 - January 19, 2023
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
@ -29895,29 +29895,20 @@ static void setup(void)
|
||||||
if (fullscreen)
|
if (fullscreen)
|
||||||
{
|
{
|
||||||
#ifdef USE_HWSURFACE
|
#ifdef USE_HWSURFACE
|
||||||
/* screen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT,
|
|
||||||
VIDEO_BPP, SDL_FULLSCREEN | SDL_HWSURFACE); */
|
|
||||||
window_screen =
|
window_screen =
|
||||||
SDL_CreateWindow("Tux Paint", SDL_WINDOWPOS_UNDEFINED,
|
SDL_CreateWindow("Tux Paint", SDL_WINDOWPOS_UNDEFINED,
|
||||||
SDL_WINDOWPOS_UNDEFINED,
|
SDL_WINDOWPOS_UNDEFINED,
|
||||||
//0,0,
|
|
||||||
WINDOW_WIDTH, WINDOW_HEIGHT,
|
WINDOW_WIDTH, WINDOW_HEIGHT,
|
||||||
SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_HWSURFACE);
|
SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_HWSURFACE);
|
||||||
printf("1\n");
|
|
||||||
if (window_screen == NULL)
|
if (window_screen == NULL)
|
||||||
printf("window_screen = NULL 1\n");
|
printf("window_screen = NULL 1\n");
|
||||||
|
|
||||||
#else
|
#else
|
||||||
/* screen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT,
|
|
||||||
VIDEO_BPP, SDL_FULLSCREEN | SDL_SWSURFACE);*/
|
|
||||||
window_screen = SDL_CreateWindow(NULL,
|
window_screen = SDL_CreateWindow(NULL,
|
||||||
//"Tux Paint",
|
|
||||||
SDL_WINDOWPOS_UNDEFINED,
|
SDL_WINDOWPOS_UNDEFINED,
|
||||||
SDL_WINDOWPOS_UNDEFINED,
|
SDL_WINDOWPOS_UNDEFINED,
|
||||||
//0, 0,
|
|
||||||
WINDOW_WIDTH, WINDOW_HEIGHT,
|
WINDOW_WIDTH, WINDOW_HEIGHT,
|
||||||
SDL_WINDOW_FULLSCREEN_DESKTOP);
|
SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||||
printf("2\n");
|
|
||||||
if (window_screen == NULL)
|
if (window_screen == NULL)
|
||||||
printf("window_screen = NULL 2\n");
|
printf("window_screen = NULL 2\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -30019,43 +30010,51 @@ static void setup(void)
|
||||||
|
|
||||||
if (!fullscreen)
|
if (!fullscreen)
|
||||||
{
|
{
|
||||||
int set_window_pos = 0;
|
int win_x = SDL_WINDOWPOS_UNDEFINED, win_y = SDL_WINDOWPOS_UNDEFINED;
|
||||||
|
|
||||||
if (getenv((char *) "SDL_VIDEO_WINDOW_POS") == NULL)
|
/* SDL1.2 supported "SDL_VIDEO_WINDOW_POS", but SDL2 does not,
|
||||||
{
|
so we implement it ourselves */
|
||||||
set_window_pos = 1;
|
|
||||||
putenv((char *) "SDL_VIDEO_WINDOW_POS=center");
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef USE_HWSURFACE
|
#ifdef USE_HWSURFACE
|
||||||
/* screen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT,
|
/* screen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT,
|
||||||
VIDEO_BPP, SDL_HWSURFACE); */
|
VIDEO_BPP, SDL_HWSURFACE); */
|
||||||
window_screen = SDL_CreateWindow("Tux Paint",
|
window_screen = SDL_CreateWindow("Tux Paint", win_x, win_y,
|
||||||
SDL_WINDOWPOS_UNDEFINED,
|
WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_HWSURFACE);
|
||||||
SDL_WINDOWPOS_UNDEFINED, WINDOW_WIDTH,
|
|
||||||
WINDOW_HEIGHT, SDL_WINDOW_HWSURFACE);
|
|
||||||
printf("3\n");
|
|
||||||
if (window_screen == NULL)
|
if (window_screen == NULL)
|
||||||
printf("window_screen = NULL 3\n");
|
printf("window_screen = NULL 3\n");
|
||||||
#else
|
#else
|
||||||
window_screen = SDL_CreateWindow("Tux Paint",
|
window_screen = SDL_CreateWindow("Tux Paint", win_x, win_y,
|
||||||
SDL_WINDOWPOS_UNDEFINED,
|
WINDOW_WIDTH,
|
||||||
SDL_WINDOWPOS_UNDEFINED, WINDOW_WIDTH,
|
|
||||||
WINDOW_HEIGHT, 0 /* no flags */ );
|
WINDOW_HEIGHT, 0 /* no flags */ );
|
||||||
/* screen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT,
|
|
||||||
s
|
|
||||||
VIDEO_BPP, SDL_SWSURFACE); */
|
|
||||||
printf("4\n");
|
|
||||||
if (window_screen == NULL)
|
if (window_screen == NULL)
|
||||||
printf("window_screen = NULL 4\n");
|
printf("window_screen = NULL 4\n");
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (set_window_pos)
|
|
||||||
putenv((char *) "SDL_VIDEO_WINDOW_POS=nopref");
|
|
||||||
|
|
||||||
/* Note: Seems that this depends on the compliance by the window manager
|
/* Note: Seems that this depends on the compliance by the window manager.
|
||||||
currently this doesn't works under Fvwm */
|
Currently this doesn't work under Fvwm */
|
||||||
SDL_SetWindowMinimumSize(window_screen, WINDOW_WIDTH, WINDOW_HEIGHT);
|
SDL_SetWindowMinimumSize(window_screen, WINDOW_WIDTH, WINDOW_HEIGHT);
|
||||||
SDL_SetWindowMaximumSize(window_screen, WINDOW_WIDTH, WINDOW_HEIGHT);
|
SDL_SetWindowMaximumSize(window_screen, WINDOW_WIDTH, WINDOW_HEIGHT);
|
||||||
|
|
||||||
|
|
@ -30070,12 +30069,6 @@ static void setup(void)
|
||||||
SDL_CreateRGBSurface(0, ww, hh, 32, 0x00FF0000, 0x0000FF00, 0x000000FF,
|
SDL_CreateRGBSurface(0, ww, hh, 32, 0x00FF0000, 0x0000FF00, 0x000000FF,
|
||||||
0xFF000000);
|
0xFF000000);
|
||||||
|
|
||||||
|
|
||||||
//screen = SDL_GetWindowSurface(window_screen);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (screen == NULL)
|
if (screen == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue