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

More fallout from non-square pixels...

This fixes all the window adjustment "stuff", but the new aspect
ratio enforcement means that ALT-UP and ALT-DOWN are useless for
resizing the window unless it's not already snapped... use ALT-LEFT
and ALT-RIGHT to decrease/increase the window size.
parent 5f027c49
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #2165 passed
......@@ -797,29 +797,13 @@ static int win_to_res_ypos(int winpos)
void sdl_video_event_thread(void *data)
{
SDL_Event ev;
int old_w, old_h;
int block_text = 0;
static SDL_Keycode last_sym = SDLK_UNKNOWN;
static Uint16 last_mod = 0;
pthread_mutex_lock(&vstatlock);
old_w = cvstat.winwidth;
old_h = cvstat.winheight;
pthread_mutex_unlock(&vstatlock);
while(1) {
if(sdl.WaitEventTimeout(&ev, 1)!=1) {
pthread_mutex_lock(&vstatlock);
if (cvstat.winwidth != old_w || cvstat.winheight != old_h) {
sdl_setwinsize_locked(cvstat.winwidth, cvstat.winheight);
setup_surfaces_locked();
old_w = cvstat.winwidth;
old_h = cvstat.winheight;
sdl_getwinsize_locked(&cvstat.winwidth, &cvstat.winheight);
}
pthread_mutex_unlock(&vstatlock);
}
else {
if(sdl.WaitEventTimeout(&ev, 1)!=1)
continue;
switch (ev.type) {
case SDL_KEYDOWN: /* Keypress */
last_mod = ev.key.keysym.mod;
......@@ -863,15 +847,6 @@ void sdl_video_event_thread(void *data)
}
break;
case SDLK_DOWN:
if (cvstat.scale_denominator != cvstat.scale_numerator) {
if (h % (cvstat.scrnheight * cvstat.vmultiplier) == 0) {
h = h * cvstat.scale_denominator / cvstat.scale_numerator;
}
else {
h = (h - h % (cvstat.scrnheight * cvstat.vmultiplier)) + (cvstat.scrnheight * cvstat.vmultiplier);
}
}
else
h = (h - h % (cvstat.scrnheight * cvstat.vmultiplier)) + (cvstat.scrnheight * cvstat.vmultiplier);
break;
}
......@@ -881,6 +856,7 @@ void sdl_video_event_thread(void *data)
cvstat.winwidth = w;
cvstat.winheight = h;
}
setup_surfaces_locked();
pthread_mutex_unlock(&vstatlock);
}
break;
......@@ -998,7 +974,6 @@ void sdl_video_event_thread(void *data)
else
newh = "0";
pthread_mutex_lock(&win_mutex);
if (ev.window.event == SDL_WINDOWEVENT_RESIZED)
sdl.GetWindowSize(win, &cvstat.winwidth, &cvstat.winheight);
if (strcmp(newh, sdl.GetHint(SDL_HINT_RENDER_SCALE_QUALITY))) {
SDL_Texture *newtexture;
......@@ -1008,8 +983,9 @@ void sdl_video_event_thread(void *data)
if (texture)
sdl.DestroyTexture(texture);
texture = newtexture;
bitmap_drv_request_pixels();
}
sdl.RenderClear(renderer);
bitmap_drv_request_pixels();
pthread_mutex_unlock(&win_mutex);
pthread_mutex_unlock(&vstatlock);
break;
......@@ -1080,11 +1056,11 @@ void sdl_video_event_thread(void *data)
idealw = roundl((long double)dst.h * cvstat.scale_numerator / cvstat.scale_denominator * cvstat.scrnwidth / cvstat.scrnheight);
idealh = roundl((long double)dst.w * cvstat.scale_denominator / cvstat.scale_numerator * cvstat.scrnheight / cvstat.scrnwidth);
if (idealw < cvstat.winwidth) {
dst.x += (cvstat.winwidth - idealw) / 2;
dst.x = (cvstat.winwidth - idealw) / 2;
dst.w = idealw;
}
else if(idealh < cvstat.winheight) {
dst.y += (cvstat.winheight - idealh) / 2;
dst.y = (cvstat.winheight - idealh) / 2;
dst.h = idealh;
}
sdl.RenderCopy(renderer, texture, &src, &dst);
......@@ -1128,8 +1104,6 @@ void sdl_video_event_thread(void *data)
case SDL_USEREVENT_SETVIDMODE:
pthread_mutex_lock(&vstatlock);
setup_surfaces_locked();
old_w = cvstat.winwidth;
old_h = cvstat.winheight;
pthread_mutex_unlock(&vstatlock);
sdl_ufunc_retval=0;
sem_post(&sdl_ufunc_ret);
......@@ -1197,7 +1171,6 @@ void sdl_video_event_thread(void *data)
break;
}
}
}
return;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment