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

A few scaling fixes for X11 mode...

- getscaling() incorrectly used an int intermediate variable
  This would force scaling to an integer value when read.
- Only parse ConfigureNotify events describing a change to the SyncTERM window
  It appears that XWayland on ChromeOS was occasionally sending a
  ConfigureNotify event describing some other window to SyncTERM,
  and that window had a 1x1 size, which would cause SyncTERM to
  assert minimum size again (usually 640x480), which would set
  scaling to 1.0.
parent 1c63f4d2
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #4324 passed
......@@ -554,7 +554,7 @@ void x_setscaling(double newval)
double x_getscaling(void)
{
int ret;
double ret;
pthread_mutex_lock(&vstatlock);
ret = vstat.scaling;
......
......@@ -481,14 +481,16 @@ static void resize_window()
pthread_mutex_lock(&vstatlock);
bitmap_get_scaled_win_size(x_cvstat.scaling, &width, &height, 0, 0);
if (width == vstat.winwidth && height == vstat.winheight) {
vstat.scaling = x_cvstat.scaling = bitmap_double_mult_inside(width, height);
x_cvstat.scaling = bitmap_double_mult_inside(width, height);
vstat.scaling = x_cvstat.scaling;
pthread_mutex_unlock(&vstatlock);
resize_xim();
return;
}
x_cvstat.winwidth = vstat.winwidth;
x_cvstat.winheight = vstat.winheight;
vstat.scaling = x_cvstat.scaling = bitmap_double_mult_inside(width, height);
x_cvstat.scaling = bitmap_double_mult_inside(width, height);
vstat.scaling = x_cvstat.scaling;
pthread_mutex_unlock(&vstatlock);
x11.XResizeWindow(dpy, win, width, height);
resize_xim();
......@@ -859,16 +861,21 @@ static int x11_event(XEvent *ev)
case ConfigureNotify: {
bool resize = false;
if (x11_window_xpos != ev->xconfigure.x || x11_window_ypos != ev->xconfigure.y) {
x11_window_xpos=ev->xconfigure.x;
x11_window_ypos=ev->xconfigure.y;
if (ev->xconfigure.window == win) {
if (x11_window_xpos != ev->xconfigure.x || x11_window_ypos != ev->xconfigure.y) {
x11_window_xpos=ev->xconfigure.x;
x11_window_ypos=ev->xconfigure.y;
}
pthread_mutex_lock(&vstatlock);
if (ev->xconfigure.width != vstat.winwidth || ev->xconfigure.height != vstat.winheight) {
// XWayland on ChromeOS appears to send a 1x1 resize event early on for unknown reasons... inore it.
if (ev->xconfigure.width != 1 && ev->xconfigure.height != 1)
resize = true;
}
pthread_mutex_unlock(&vstatlock);
if (resize)
handle_resize_event(ev->xconfigure.width, ev->xconfigure.height);
}
pthread_mutex_lock(&vstatlock);
if (ev->xconfigure.width != vstat.winwidth || ev->xconfigure.height != vstat.winheight)
resize = true;
pthread_mutex_unlock(&vstatlock);
if (resize)
handle_resize_event(ev->xconfigure.width, ev->xconfigure.height);
break;
}
case NoExpose:
......
......@@ -1938,7 +1938,7 @@ main(int argc, char **argv)
if ((txtinfo.currmode == screen_to_ciolib(settings.startup_mode))
|| ((settings.startup_mode == SCREEN_MODE_CURRENT) && (txtinfo.currmode == C80))) {
sf = getscaling();
if (((sf > 0) && (sf != settings.scaling_factor))) {
if (((sf > 0.0) && (sf != settings.scaling_factor))) {
char inipath[MAX_PATH + 1];
FILE *inifile;
str_list_t inicontents;
......@@ -1951,8 +1951,9 @@ main(int argc, char **argv)
else {
inicontents = strListInit();
}
if ((sf > 0) && (sf != settings.scaling_factor))
if ((sf > 0.0) && (sf != settings.scaling_factor)) {
iniSetFloat(&inicontents, "SyncTERM", "ScalingFactor", sf, &ini_style);
}
if ((inifile = fopen(inipath, "w")) != NULL) {
iniWriteFile(inifile, inicontents);
fclose(inifile);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment