Fix first Wayland window wrong cell count with fractional scale (issue 10146)

This commit is contained in:
copilot-swe-agent[bot] 2026-06-19 02:43:17 +00:00 committed by GitHub
parent ec2cc29de7
commit 946867bf57
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View file

@ -181,6 +181,8 @@ Detailed list of changes
0.47.4 [2026-06-15]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Wayland: Fix first OS window being a few cells too small when :opt:`initial_window_width`/:opt:`initial_window_height` are set in cells and a fractional display scale is in use (:iss:`10146`)
- Linux: Fix a regression in the previous release that broke rendering of bitmap color fonts (:pull:`10145`)
- Linux: Allow fake italics defined via a matrix in fontconfig settings to work for fonts like Fira Code that do not ship with an italic face (:pull:`10120`)

View file

@ -1850,8 +1850,21 @@ create_os_window(PyObject UNUSED *self, PyObject *args, PyObject *kw) {
// this can happen if the window is moved by the OS to a different monitor when shown or with fractional scales on Wayland
// it can also happen with layer shell windows if the callback is
// called before the window is fully created
xdpi = n_xdpi; ydpi = n_ydpi;
xdpi = n_xdpi; ydpi = n_ydpi; xscale = n_xscale; yscale = n_yscale;
fonts_data = load_fonts_data(OPT(font_size), xdpi, ydpi);
// Re-compute the window size with the updated scale/font metrics. This matters when
// the initial size is specified in cells: the first window on Wayland is created with
// scale=1 because fractional scale is only sent by the compositor after the surface
// exists, so the cell dimensions used for the initial size calculation were wrong.
PyObject *new_size = PyObject_CallFunction(get_window_size, "IIddff", fonts_data->fcm.cell_width, fonts_data->fcm.cell_height, fonts_data->logical_dpi_x, fonts_data->logical_dpi_y, xscale, yscale);
if (new_size != NULL) {
int new_width = PyLong_AsLong(PyTuple_GET_ITEM(new_size, 0)), new_height = PyLong_AsLong(PyTuple_GET_ITEM(new_size, 1));
Py_DECREF(new_size);
if (!PyErr_Occurred() && (new_width != width || new_height != height)) {
glfwSetWindowSize(glfw_window, new_width, new_height);
width = new_width; height = new_height;
} else PyErr_Clear();
} else PyErr_Clear();
}
}
if (is_first_window) {