Get the layer sizing function working
This commit is contained in:
parent
85a980ea3e
commit
46db1f7b76
3 changed files with 15 additions and 9 deletions
21
kitty/glfw.c
21
kitty/glfw.c
|
|
@ -1075,27 +1075,34 @@ edge_spacing(GLFWEdge which) {
|
|||
|
||||
static void
|
||||
calculate_layer_shell_window_size(
|
||||
GLFWwindow *window UNUSED, const GLFWLayerShellConfig *config, unsigned monitor_width, unsigned monitor_height, uint32_t *width, uint32_t *height) {
|
||||
GLFWwindow *window, const GLFWLayerShellConfig *config, unsigned monitor_width, unsigned monitor_height, uint32_t *width, uint32_t *height) {
|
||||
if (config->type == GLFW_LAYER_SHELL_BACKGROUND) {
|
||||
if (!*width) *width = monitor_width;
|
||||
if (!*height) *height = monitor_height;
|
||||
return;
|
||||
}
|
||||
OSWindow *os_window = os_window_for_glfw_window(window);
|
||||
if (!os_window) return;
|
||||
float xscale, yscale;
|
||||
glfwGetWindowContentScale(window, &xscale, &yscale);
|
||||
FONTS_DATA_HANDLE fonts_data;
|
||||
OSWindow *os_window = os_window_for_glfw_window(window);
|
||||
if (os_window) {
|
||||
fonts_data = os_window->fonts_data;
|
||||
} else {
|
||||
double xdpi, ydpi;
|
||||
dpi_from_scale(xscale, yscale, &xdpi, &ydpi);
|
||||
fonts_data = load_fonts_data(OPT(font_size), xdpi, ydpi);
|
||||
}
|
||||
if (config->edge == GLFW_EDGE_LEFT || config->edge == GLFW_EDGE_RIGHT) {
|
||||
if (!*height) *height = monitor_height;
|
||||
double spacing = edge_spacing(GLFW_EDGE_LEFT) + edge_spacing(GLFW_EDGE_RIGHT);
|
||||
spacing *= os_window->logical_dpi_x / 72.;
|
||||
spacing += (os_window->fonts_data->cell_width * config->size_in_cells) / xscale;
|
||||
spacing *= fonts_data->logical_dpi_x / 72.;
|
||||
spacing += (fonts_data->cell_width * config->size_in_cells) / xscale;
|
||||
*width = (uint32_t)(1. + spacing);
|
||||
} else {
|
||||
if (!*width) *width = monitor_width;
|
||||
double spacing = edge_spacing(GLFW_EDGE_TOP) + edge_spacing(GLFW_EDGE_BOTTOM);
|
||||
spacing *= os_window->logical_dpi_y / 72.;
|
||||
spacing += 1. + (os_window->fonts_data->cell_height * config->size_in_cells) / yscale;
|
||||
spacing *= fonts_data->logical_dpi_y / 72.;
|
||||
spacing += 1. + (fonts_data->cell_height * config->size_in_cells) / yscale;
|
||||
*height = (uint32_t)(1. + spacing);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ def edge_spacing(which: EdgeLiteral, opts:Optional[Union[WindowSizeData, Options
|
|||
padding: float = getattr(opts.single_window_padding_width, which)
|
||||
if padding < 0:
|
||||
padding = getattr(opts.window_padding_width, which)
|
||||
return padding + margin
|
||||
return float(padding + margin)
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1022,7 +1022,6 @@ PYWRAP1(os_window_font_size) {
|
|||
WITH_OS_WINDOW(os_window_id)
|
||||
if (new_sz > 0 && (force || new_sz != os_window->font_sz_in_pts)) {
|
||||
os_window->font_sz_in_pts = new_sz;
|
||||
os_window->fonts_data = NULL;
|
||||
os_window->fonts_data = load_fonts_data(os_window->font_sz_in_pts, os_window->logical_dpi_x, os_window->logical_dpi_y);
|
||||
send_prerendered_sprites_for_window(os_window);
|
||||
resize_screen(os_window, os_window->tab_bar_render_data.screen, false);
|
||||
|
|
|
|||
Loading…
Reference in a new issue