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) ...@@ -554,7 +554,7 @@ void x_setscaling(double newval)
double x_getscaling(void) double x_getscaling(void)
{ {
int ret; double ret;
pthread_mutex_lock(&vstatlock); pthread_mutex_lock(&vstatlock);
ret = vstat.scaling; ret = vstat.scaling;
......
...@@ -481,14 +481,16 @@ static void resize_window() ...@@ -481,14 +481,16 @@ static void resize_window()
pthread_mutex_lock(&vstatlock); pthread_mutex_lock(&vstatlock);
bitmap_get_scaled_win_size(x_cvstat.scaling, &width, &height, 0, 0); bitmap_get_scaled_win_size(x_cvstat.scaling, &width, &height, 0, 0);
if (width == vstat.winwidth && height == vstat.winheight) { 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); pthread_mutex_unlock(&vstatlock);
resize_xim(); resize_xim();
return; return;
} }
x_cvstat.winwidth = vstat.winwidth; x_cvstat.winwidth = vstat.winwidth;
x_cvstat.winheight = vstat.winheight; 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); pthread_mutex_unlock(&vstatlock);
x11.XResizeWindow(dpy, win, width, height); x11.XResizeWindow(dpy, win, width, height);
resize_xim(); resize_xim();
...@@ -859,16 +861,21 @@ static int x11_event(XEvent *ev) ...@@ -859,16 +861,21 @@ static int x11_event(XEvent *ev)
case ConfigureNotify: { case ConfigureNotify: {
bool resize = false; bool resize = false;
if (ev->xconfigure.window == win) {
if (x11_window_xpos != ev->xconfigure.x || x11_window_ypos != ev->xconfigure.y) { if (x11_window_xpos != ev->xconfigure.x || x11_window_ypos != ev->xconfigure.y) {
x11_window_xpos=ev->xconfigure.x; x11_window_xpos=ev->xconfigure.x;
x11_window_ypos=ev->xconfigure.y; x11_window_ypos=ev->xconfigure.y;
} }
pthread_mutex_lock(&vstatlock); pthread_mutex_lock(&vstatlock);
if (ev->xconfigure.width != vstat.winwidth || ev->xconfigure.height != vstat.winheight) 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; resize = true;
}
pthread_mutex_unlock(&vstatlock); pthread_mutex_unlock(&vstatlock);
if (resize) if (resize)
handle_resize_event(ev->xconfigure.width, ev->xconfigure.height); handle_resize_event(ev->xconfigure.width, ev->xconfigure.height);
}
break; break;
} }
case NoExpose: case NoExpose:
......
...@@ -1938,7 +1938,7 @@ main(int argc, char **argv) ...@@ -1938,7 +1938,7 @@ main(int argc, char **argv)
if ((txtinfo.currmode == screen_to_ciolib(settings.startup_mode)) if ((txtinfo.currmode == screen_to_ciolib(settings.startup_mode))
|| ((settings.startup_mode == SCREEN_MODE_CURRENT) && (txtinfo.currmode == C80))) { || ((settings.startup_mode == SCREEN_MODE_CURRENT) && (txtinfo.currmode == C80))) {
sf = getscaling(); sf = getscaling();
if (((sf > 0) && (sf != settings.scaling_factor))) { if (((sf > 0.0) && (sf != settings.scaling_factor))) {
char inipath[MAX_PATH + 1]; char inipath[MAX_PATH + 1];
FILE *inifile; FILE *inifile;
str_list_t inicontents; str_list_t inicontents;
...@@ -1951,8 +1951,9 @@ main(int argc, char **argv) ...@@ -1951,8 +1951,9 @@ main(int argc, char **argv)
else { else {
inicontents = strListInit(); inicontents = strListInit();
} }
if ((sf > 0) && (sf != settings.scaling_factor)) if ((sf > 0.0) && (sf != settings.scaling_factor)) {
iniSetFloat(&inicontents, "SyncTERM", "ScalingFactor", sf, &ini_style); iniSetFloat(&inicontents, "SyncTERM", "ScalingFactor", sf, &ini_style);
}
if ((inifile = fopen(inipath, "w")) != NULL) { if ((inifile = fopen(inipath, "w")) != NULL) {
iniWriteFile(inifile, inicontents); iniWriteFile(inifile, inicontents);
fclose(inifile); fclose(inifile);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment