SDL2 also for Windows, by TOYAMA Shin-ichi

This commit is contained in:
Pere Pujal i Carabantes 2021-09-29 20:25:56 +02:00
parent 6891266eee
commit 16f56ae9cd
4 changed files with 11 additions and 20 deletions

View file

@ -1357,11 +1357,11 @@ obj:
MAGIC_SDL_CPPFLAGS:=$(shell $(PKG_CONFIG) $(SDL_PCNAME) --cflags) MAGIC_SDL_CPPFLAGS:=$(shell $(PKG_CONFIG) $(SDL_PCNAME) --cflags)
# FIXME: Expose SDL_rotozoom to Magic API? -bjk 2021.09.06 # FIXME: Expose SDL_rotozoom to Magic API? -bjk 2021.09.06
windows_MAGIC_SDL_LIBS:=-L/usr/local/lib $(LIBMINGW) $(shell $(PKG_CONFIG) $(SDL_PCNAME) --libs) -lSDL_image -lSDL_ttf $(SDL_MIXER_LIB) windows_MAGIC_SDL_LIBS:=-L/usr/local/lib $(LIBMINGW) $(shell $(PKG_CONFIG) $(SDL_PCNAME) --libs) -lSDL2_image -lSDL2_ttf $(SDL_MIXER_LIB)
macos_MAGIC_SDL_LIBS:=-L/usr/local/lib $(shell $(PKG_CONFIG) $(SDL_PCNAME) --libs) -lSDL_image -lSDL_ttf $(SDL_MIXER_LIB) macos_MAGIC_SDL_LIBS:=-L/usr/local/lib $(shell $(PKG_CONFIG) $(SDL_PCNAME) --libs) -lSDL2_image -lSDL2_ttf $(SDL_MIXER_LIB)
ios_MAGIC_SDL_LIBS:=$(shell $(PKG_CONFIG) $(SDL_PCNAME) --libs) -lSDL_image -lSDL_ttf $(SDL_MIXER_LIB) ios_MAGIC_SDL_LIBS:=$(shell $(PKG_CONFIG) $(SDL_PCNAME) --libs) -lSDL2_image -lSDL2_ttf $(SDL_MIXER_LIB)
beos_MAGIC_SDL_LIBS:=-L/usr/local/lib $(shell $(PKG_CONFIG) $(SDL_PCNAME) --libs) -lSDL_image -lSDL_ttf $(SDL_MIXER_LIB) beos_MAGIC_SDL_LIBS:=-L/usr/local/lib $(shell $(PKG_CONFIG) $(SDL_PCNAME) --libs) -lSDL2_image -lSDL2_ttf $(SDL_MIXER_LIB)
linux_MAGIC_SDL_LIBS:=-L/usr/local/lib $(shell $(PKG_CONFIG) $(SDL_PCNAME) --libs) -lSDL_image -lSDL_ttf $(SDL_MIXER_LIB) linux_MAGIC_SDL_LIBS:=-L/usr/local/lib $(shell $(PKG_CONFIG) $(SDL_PCNAME) --libs) -lSDL2_image -lSDL2_ttf $(SDL_MIXER_LIB)
MAGIC_SDL_LIBS:=$($(OS)_MAGIC_SDL_LIBS) MAGIC_SDL_LIBS:=$($(OS)_MAGIC_SDL_LIBS)
windows_MAGIC_ARCH_LINKS=-lintl $(PNG) windows_MAGIC_ARCH_LINKS=-lintl $(PNG)

View file

@ -8725,10 +8725,8 @@ static void create_button_labels(void)
*/ */
static void seticon(void) static void seticon(void)
{ {
#ifndef WIN32
int masklen; int masklen;
Uint8 *mask; Uint8 *mask;
#endif
SDL_Surface *icon; SDL_Surface *icon;
/* Load icon into a surface: */ /* Load icon into a surface: */
@ -8749,7 +8747,6 @@ static void seticon(void)
} }
#ifndef WIN32
/* Create mask: */ /* Create mask: */
masklen = (((icon->w) + 7) / 8) * (icon->h); masklen = (((icon->w) + 7) / 8) * (icon->h);
mask = malloc(masklen * sizeof(Uint8)); mask = malloc(masklen * sizeof(Uint8));
@ -8760,10 +8757,6 @@ static void seticon(void)
SDL_SetWindowIcon(window_screen, icon); SDL_SetWindowIcon(window_screen, icon);
/* Free icon surface & mask: */ /* Free icon surface & mask: */
free(mask); free(mask);
#else
/* Set icon: */
SDL_WM_SetIcon(icon, NULL);
#endif
SDL_FreeSurface(icon); SDL_FreeSurface(icon);
@ -18020,7 +18013,7 @@ void do_print(void)
safe_snprintf(f, sizeof(f), "%s/%s", savedir, "print.cfg"); /* FIXME */ safe_snprintf(f, sizeof(f), "%s/%s", savedir, "print.cfg"); /* FIXME */
{ {
const char *error = SurfacePrint(save_canvas, use_print_config ? f : NULL, show); const char *error = SurfacePrint(window_screen, save_canvas, use_print_config ? f : NULL, show);
if (error) if (error)
fprintf(stderr, "%s\n", error); fprintf(stderr, "%s\n", error);
@ -18879,7 +18872,7 @@ static void handle_active(SDL_Event * event)
} }
#ifdef _WIN32 #ifdef _WIN32
SetActivationState(event->active.gain); SetActivationState(1);
#endif #endif
} }
} }

View file

@ -65,8 +65,6 @@ static SDL_Surface *make24bitDIB(SDL_Surface * surf)
pixfmt.Gloss = 0; pixfmt.Gloss = 0;
pixfmt.Bloss = 0; pixfmt.Bloss = 0;
pixfmt.Aloss = 0; pixfmt.Aloss = 0;
pixfmt.colorkey = 0;
pixfmt.alpha = 0;
surf24 = SDL_ConvertSurface(surf, &pixfmt, SDL_SWSURFACE); surf24 = SDL_ConvertSurface(surf, &pixfmt, SDL_SWSURFACE);
surfDIB = SDL_CreateRGBSurface(SDL_SWSURFACE, surf24->w, surf24->h, 24, surfDIB = SDL_CreateRGBSurface(SDL_SWSURFACE, surf24->w, surf24->h, 24,
@ -320,7 +318,7 @@ int IsPrinterAvailable(void)
/** /**
* FIXME * FIXME
*/ */
const char *SurfacePrint(SDL_Surface * surf, const char *printcfg, int showdialog) const char *SurfacePrint(SDL_Window * window, SDL_Surface * surf, const char *printcfg, int showdialog)
{ {
const char *res = NULL; const char *res = NULL;
HWND hWnd; HWND hWnd;
@ -338,10 +336,10 @@ const char *SurfacePrint(SDL_Surface * surf, const char *printcfg, int showdialo
int scaling = SCALE_TO_FIT; int scaling = SCALE_TO_FIT;
SDL_VERSION(&wminfo.version); SDL_VERSION(&wminfo.version);
if (!SDL_GetWMInfo(&wminfo)) if (!SDL_GetWindowWMInfo(window, &wminfo))
return "win32_print: SDL_GetWMInfo() failed."; return "win32_print: SDL_GetWMInfo() failed.";
hWnd = wminfo.window; hWnd = wminfo.info.win.window;
if (!GetPrinterDC(hWnd, printcfg, showdialog)) if (!GetPrinterDC(hWnd, printcfg, showdialog))
{ {
ShowWindow(hWnd, SW_SHOWNORMAL); ShowWindow(hWnd, SW_SHOWNORMAL);

View file

@ -15,7 +15,7 @@
#endif #endif
/* if printcfg is NULL, uses the default printer */ /* if printcfg is NULL, uses the default printer */
extern const char *SurfacePrint(SDL_Surface * surf, const char *printcfg, int showdialog); extern const char *SurfacePrint(SDL_Window * window, SDL_Surface * surf, const char *printcfg, int showdialog);
extern int IsPrinterAvailable(void); extern int IsPrinterAvailable(void);
/* additional windows functions requiring <windows.h> */ /* additional windows functions requiring <windows.h> */