Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit e2f5762b authored by Deucе's avatar Deucе 👌🏾

Don't allow ALT-Direction to work when maximized

With maximized windows, unexpected behaviour occured when the program
resized itself, then the window manager minimized/restored the window
Should address SF bugs #18 and #13
parent f4d43d13
Pipeline #1525 passed with stage
in 11 minutes and 55 seconds
......@@ -824,53 +824,57 @@ void sdl_video_event_thread(void *data)
ev.key.keysym.sym == SDLK_UP ||
ev.key.keysym.sym == SDLK_DOWN)) {
int w, h;
pthread_mutex_lock(&vstatlock);
w = cvstat.winwidth;
h = cvstat.winheight;
switch(ev.key.keysym.sym) {
case SDLK_LEFT:
if (w % (cvstat.scrnwidth)) {
w = w - w % cvstat.scrnwidth;
}
else {
w -= cvstat.scrnwidth;
if (w < cvstat.scrnwidth)
w = cvstat.scrnwidth;
}
break;
case SDLK_RIGHT:
w = (w - w % cvstat.scrnwidth) + cvstat.scrnwidth;
break;
case SDLK_UP:
if (h % (cvstat.scrnheight * cvstat.vmultiplier)) {
h = h - h % (cvstat.scrnheight * cvstat.vmultiplier);
}
else {
h -= (cvstat.scrnheight * cvstat.vmultiplier);
if (h < (cvstat.scrnheight * cvstat.vmultiplier))
h = cvstat.scrnheight * cvstat.vmultiplier;
}
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;
// Don't allow ALT-DIR to change size when maximized...
if ((sdl.GetWindowFlags(win) & SDL_WINDOW_MAXIMIZED) == 0) {
pthread_mutex_lock(&vstatlock);
w = cvstat.winwidth;
h = cvstat.winheight;
switch(ev.key.keysym.sym) {
case SDLK_LEFT:
if (w % (cvstat.scrnwidth)) {
w = w - w % cvstat.scrnwidth;
}
else {
h = (h - h % (cvstat.scrnheight * cvstat.vmultiplier)) + (cvstat.scrnheight * cvstat.vmultiplier);
w -= cvstat.scrnwidth;
if (w < cvstat.scrnwidth)
w = cvstat.scrnwidth;
}
}
else
h = (h - h % (cvstat.scrnheight * cvstat.vmultiplier)) + (cvstat.scrnheight * cvstat.vmultiplier);
break;
}
if (w > 16384 || h > 16384)
beep();
else {
cvstat.winwidth = w;
cvstat.winheight = h;
break;
case SDLK_RIGHT:
w = (w - w % cvstat.scrnwidth) + cvstat.scrnwidth;
break;
case SDLK_UP:
if (h % (cvstat.scrnheight * cvstat.vmultiplier)) {
h = h - h % (cvstat.scrnheight * cvstat.vmultiplier);
}
else {
h -= (cvstat.scrnheight * cvstat.vmultiplier);
if (h < (cvstat.scrnheight * cvstat.vmultiplier))
h = cvstat.scrnheight * cvstat.vmultiplier;
}
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;
}
if (w > 16384 || h > 16384)
beep();
else {
cvstat.winwidth = w;
cvstat.winheight = h;
}
pthread_mutex_unlock(&vstatlock);
}
pthread_mutex_unlock(&vstatlock);
break;
}
}
......
......@@ -198,6 +198,10 @@ int load_sdl_funcs(struct sdlfuncs *sdlf)
xp_dlclose(sdl_dll);
return(-1);
}
if((sdlf->GetWindowFlags=xp_dlsym(sdl_dll, SDL_GetWindowFlags))==NULL) {
xp_dlclose(sdl_dll);
return(-1);
}
#ifndef STATIC_SDL
{
int (HACK_HACK_HACK *ra)(char *name, Uint32 style, void *hInst);
......
......@@ -55,6 +55,7 @@ struct sdlfuncs {
void (HACK_HACK_HACK *SetCursor) (SDL_Cursor *curs);
void (HACK_HACK_HACK *FreeCursor) (SDL_Cursor *curs);
void(HACK_HACK_HACK *free) (void *);
Uint32(HACK_HACK_HACK *GetWindowFlags) (SDL_Window * window);
int gotfuncs;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment