Skip to content
Snippets Groups Projects
Commit 53cfb81a authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

More changes around fullscreen/maximized/etc for SDL

On macOS, fullscreen and maximized are very slightly different, so
don't force one to mean the other.  However, when entering or
leaving fullscreen mode, we need to explicitly make the window
resizable or not.

Also, update the uifc screen title when the mode changes and we're
at one of the main menus... still a bit icky, but likely the best
that can be done (won't update if you toggle fullscreen from a
sub-menu for example).
parent a5438fc8
No related branches found
No related tags found
No related merge requests found
...@@ -699,6 +699,8 @@ static void setup_surfaces(struct video_stats *vs) ...@@ -699,6 +699,8 @@ static void setup_surfaces(struct video_stats *vs)
/* Called from event thread only */ /* Called from event thread only */
static void sdl_add_key(unsigned int keyval, struct video_stats *vs) static void sdl_add_key(unsigned int keyval, struct video_stats *vs)
{ {
int w, h;
if (keyval == 0xe0) if (keyval == 0xe0)
keyval = CIO_KEY_LITERAL_E0; keyval = CIO_KEY_LITERAL_E0;
if(keyval==0xa600 && vs != NULL) { if(keyval==0xa600 && vs != NULL) {
...@@ -706,12 +708,12 @@ static void sdl_add_key(unsigned int keyval, struct video_stats *vs) ...@@ -706,12 +708,12 @@ static void sdl_add_key(unsigned int keyval, struct video_stats *vs)
cio_api.mode=fullscreen?CIOLIB_MODE_SDL_FULLSCREEN:CIOLIB_MODE_SDL; cio_api.mode=fullscreen?CIOLIB_MODE_SDL_FULLSCREEN:CIOLIB_MODE_SDL;
update_cvstat(vs); update_cvstat(vs);
sdl.SetWindowFullscreen(win, fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0); sdl.SetWindowFullscreen(win, fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
if (!fullscreen) { sdl.SetWindowResizable(win, fullscreen ? SDL_FALSE : SDL_TRUE);
int w, h;
// Get current window size // Get current window size
sdl.GetWindowSizeInPixels(win, &w, &h); sdl.GetWindowSizeInPixels(win, &w, &h);
// Limit to max window size if available // Limit to max window size if available
if (!fullscreen) {
SDL_Rect r; SDL_Rect r;
if (sdl.GetDisplayUsableBounds(0, &r) == 0) { if (sdl.GetDisplayUsableBounds(0, &r) == 0) {
if (w > r.w) if (w > r.w)
...@@ -719,10 +721,10 @@ static void sdl_add_key(unsigned int keyval, struct video_stats *vs) ...@@ -719,10 +721,10 @@ static void sdl_add_key(unsigned int keyval, struct video_stats *vs)
if (h > r.h) if (h > r.h)
h = r.h; h = r.h;
} }
}
// Set size based on current max // Set size based on current max
vs->scaling = bitmap_double_mult_inside(w, h); vs->scaling = bitmap_double_mult_inside(w, h);
bitmap_get_scaled_win_size(vs->scaling, &vs->winwidth, &vs->winheight, w, h); bitmap_get_scaled_win_size(vs->scaling, &vs->winwidth, &vs->winheight, w, h);
}
setup_surfaces(vs); setup_surfaces(vs);
return; return;
} }
...@@ -1049,7 +1051,11 @@ void sdl_video_event_thread(void *data) ...@@ -1049,7 +1051,11 @@ void sdl_video_event_thread(void *data)
// Fall-through // Fall-through
case SDL_WINDOWEVENT_SIZE_CHANGED: case SDL_WINDOWEVENT_SIZE_CHANGED:
// SDL2: User resized window // SDL2: User resized window
case SDL_WINDOWEVENT_RESIZED: case SDL_WINDOWEVENT_RESIZED: {
int flags = sdl.GetWindowFlags(win);
fullscreen = (flags & (SDL_WINDOW_FULLSCREEN)) != 0;
sdl.SetWindowResizable(win, (flags & SDL_WINDOW_FULLSCREEN) ? SDL_FALSE : SDL_TRUE);
cio_api.mode=fullscreen?CIOLIB_MODE_SDL_FULLSCREEN:CIOLIB_MODE_SDL;
pthread_mutex_lock(&sdl_mode_mutex); pthread_mutex_lock(&sdl_mode_mutex);
if (sdl_mode) { if (sdl_mode) {
pthread_mutex_unlock(&sdl_mode_mutex); pthread_mutex_unlock(&sdl_mode_mutex);
...@@ -1058,6 +1064,7 @@ void sdl_video_event_thread(void *data) ...@@ -1058,6 +1064,7 @@ void sdl_video_event_thread(void *data)
pthread_mutex_unlock(&sdl_mode_mutex); pthread_mutex_unlock(&sdl_mode_mutex);
internal_setwinsize(&cvstat, false); internal_setwinsize(&cvstat, false);
break; break;
}
case SDL_WINDOWEVENT_EXPOSED: case SDL_WINDOWEVENT_EXPOSED:
bitmap_drv_request_pixels(); bitmap_drv_request_pixels();
break; break;
......
...@@ -150,6 +150,10 @@ int load_sdl_funcs(struct sdlfuncs *sdlf) ...@@ -150,6 +150,10 @@ int load_sdl_funcs(struct sdlfuncs *sdlf)
xp_dlclose(sdl_dll); xp_dlclose(sdl_dll);
return(-1); return(-1);
} }
if((sdlf->SetWindowResizable=xp_dlsym(sdl_dll, SDL_SetWindowResizable))==NULL) {
xp_dlclose(sdl_dll);
return(-1);
}
if((sdlf->LockTexture=xp_dlsym(sdl_dll, SDL_LockTexture))==NULL) { if((sdlf->LockTexture=xp_dlsym(sdl_dll, SDL_LockTexture))==NULL) {
xp_dlclose(sdl_dll); xp_dlclose(sdl_dll);
return(-1); return(-1);
......
...@@ -43,6 +43,7 @@ struct sdlfuncs { ...@@ -43,6 +43,7 @@ struct sdlfuncs {
void (HACK_HACK_HACK *SetWindowSize) (SDL_Window *window, int w, int h); void (HACK_HACK_HACK *SetWindowSize) (SDL_Window *window, int w, int h);
void (HACK_HACK_HACK *DestroyTexture) (SDL_Texture *texture); void (HACK_HACK_HACK *DestroyTexture) (SDL_Texture *texture);
int (HACK_HACK_HACK *SetWindowFullscreen) (SDL_Window *window, Uint32 flags); int (HACK_HACK_HACK *SetWindowFullscreen) (SDL_Window *window, Uint32 flags);
int (HACK_HACK_HACK *SetWindowResizable) (SDL_Window *window, SDL_bool resizable);
int (HACK_HACK_HACK *LockTexture) (SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch); int (HACK_HACK_HACK *LockTexture) (SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch);
void (HACK_HACK_HACK *UnlockTexture) (SDL_Texture *texture); void (HACK_HACK_HACK *UnlockTexture) (SDL_Texture *texture);
int (HACK_HACK_HACK *QueryTexture) (SDL_Texture *texture, Uint32 *format, int *access, int *w, int *h); int (HACK_HACK_HACK *QueryTexture) (SDL_Texture *texture, Uint32 *format, int *access, int *w, int *h);
......
...@@ -5,6 +5,7 @@ Properly quit video subsystem from video thread - fixes Haiku crash ...@@ -5,6 +5,7 @@ Properly quit video subsystem from video thread - fixes Haiku crash
Create dirs on macOS when needed - fixes adding first BBS Create dirs on macOS when needed - fixes adding first BBS
Fix cache subdirectories on Windows Fix cache subdirectories on Windows
Make File Locations window wider Make File Locations window wider
Ensure window can be resized if started in fullscreen mode
Version 1.2rc2 Version 1.2rc2
-------------- --------------
......
...@@ -2655,6 +2655,7 @@ show_bbslist(char *current, int connected) ...@@ -2655,6 +2655,7 @@ show_bbslist(char *current, int connected)
char list_title[30]; char list_title[30];
int redraw = 0; int redraw = 0;
bool nowait = true; bool nowait = true;
int last_mode;
glob_sbar = &sbar; glob_sbar = &sbar;
glob_sopt = &sopt; glob_sopt = &sopt;
...@@ -2678,6 +2679,7 @@ show_bbslist(char *current, int connected) ...@@ -2678,6 +2679,7 @@ show_bbslist(char *current, int connected)
uifc.helpbuf = "Help Button Hack"; uifc.helpbuf = "Help Button Hack";
uifc.list(WIN_T2B | WIN_RHT | WIN_EXTKEYS | WIN_DYN | WIN_ACT | WIN_INACT, uifc.list(WIN_T2B | WIN_RHT | WIN_EXTKEYS | WIN_DYN | WIN_ACT | WIN_INACT,
0, 0, 0, &sopt, &sbar, "SyncTERM Settings", connected ? connected_settings_menu : settings_menu); 0, 0, 0, &sopt, &sbar, "SyncTERM Settings", connected ? connected_settings_menu : settings_menu);
last_mode = cio_api.mode;
for (;;) { for (;;) {
if (quitting) { if (quitting) {
free(list); free(list);
...@@ -2690,6 +2692,10 @@ show_bbslist(char *current, int connected) ...@@ -2690,6 +2692,10 @@ show_bbslist(char *current, int connected)
free(list); free(list);
return NULL; return NULL;
} }
if (last_mode != cio_api.mode) {
set_uifc_title();
last_mode = cio_api.mode;
}
if (connected) { if (connected) {
uifc.helpbuf = "`SyncTERM Directory`\n\n" uifc.helpbuf = "`SyncTERM Directory`\n\n"
"Commands:\n\n" "Commands:\n\n"
...@@ -3166,6 +3172,10 @@ show_bbslist(char *current, int connected) ...@@ -3166,6 +3172,10 @@ show_bbslist(char *current, int connected)
} }
else { else {
for (; at_settings && !quitting;) { for (; at_settings && !quitting;) {
if (last_mode != cio_api.mode) {
set_uifc_title();
last_mode = cio_api.mode;
}
uifc.helpbuf = "`SyncTERM Settings Menu`\n\n" uifc.helpbuf = "`SyncTERM Settings Menu`\n\n"
"~ Default Connection Settings ~\n" "~ Default Connection Settings ~\n"
" Modify the settings that are used by default for new entries\n\n" " Modify the settings that are used by default for new entries\n\n"
......
...@@ -24,6 +24,26 @@ int orig_x; ...@@ -24,6 +24,26 @@ int orig_x;
int orig_y; int orig_y;
uint32_t orig_palette[16]; uint32_t orig_palette[16];
static void
get_title(char *str, size_t sz)
{
snprintf(str, sz, "%.40s - %.30s", syncterm_version, output_descrs[cio_api.mode]);
}
void
set_uifc_title(void)
{
char top[80];
textattr(uifc.bclr | (uifc.cclr<<4));
get_title(top, sizeof(top));
gotoxy(1,1);
clreol();
gotoxy(3,1);
cputs(top);
uifc.timedisplay(true);
}
int int
init_uifc(bool scrn, bool bottom) init_uifc(bool scrn, bool bottom)
{ {
...@@ -59,7 +79,7 @@ init_uifc(bool scrn, bool bottom) ...@@ -59,7 +79,7 @@ init_uifc(bool scrn, bool bottom)
} }
if (scrn) { if (scrn) {
sprintf(top, "%.40s - %.30s", syncterm_version, output_descrs[cio_api.mode]); get_title(top, sizeof(top));
if (uifc.scrn(top)) { if (uifc.scrn(top)) {
printf(" USCRN (len=%d) failed!\n", uifc.scrn_len + 1); printf(" USCRN (len=%d) failed!\n", uifc.scrn_len + 1);
uifc.bail(); uifc.bail();
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <uifc.h> #include <uifc.h>
extern uifcapi_t uifc; /* User Interface (UIFC) Library API */ extern uifcapi_t uifc; /* User Interface (UIFC) Library API */
void set_uifc_title(void);
int init_uifc(bool scrn, bool bottom); int init_uifc(bool scrn, bool bottom);
void uifcbail(void); void uifcbail(void);
void uifcmsg(char *msg, char *helpbuf); void uifcmsg(char *msg, char *helpbuf);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment