Merge branch 'master' into smarter-auto-orientation

This commit is contained in:
Milad Alizadeh 2026-03-20 22:10:15 +00:00 committed by GitHub
commit 79007ce07f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 35 additions and 6 deletions

View file

@ -84,22 +84,41 @@ PangoLayout *get_pango_layout(cairo_t *cairo, const PangoFontDescription *desc,
void get_text_size(cairo_t *cairo, const PangoFontDescription *desc, int *width, int *height,
int *baseline, double scale, bool markup, const char *fmt, ...) {
if (width) {
*width = 0;
}
if (height) {
*height = 0;
}
if (baseline) {
*baseline = 0;
}
va_list args;
va_start(args, fmt);
char *buf = vformat_str(fmt, args);
va_end(args);
if (buf == NULL) {
sway_log(SWAY_ERROR, "Failed to format string");
return;
}
PangoLayout *layout = get_pango_layout(cairo, desc, buf, scale, markup);
pango_cairo_update_layout(cairo, layout);
cairo_status_t status = cairo_status(cairo);
if (status != CAIRO_STATUS_SUCCESS) {
sway_log(SWAY_ERROR, "pango_cairo_update_layout() failed: %s",
cairo_status_to_string(status));
goto out;
}
pango_layout_get_pixel_size(layout, width, height);
if (baseline) {
*baseline = pango_layout_get_baseline(layout) / PANGO_SCALE;
}
g_object_unref(layout);
out:
g_object_unref(layout);
free(buf);
}
@ -125,6 +144,7 @@ void render_text(cairo_t *cairo, const PangoFontDescription *desc,
char *buf = vformat_str(fmt, args);
va_end(args);
if (buf == NULL) {
sway_log(SWAY_ERROR, "Failed to format string");
return;
}
@ -133,9 +153,18 @@ void render_text(cairo_t *cairo, const PangoFontDescription *desc,
cairo_get_font_options(cairo, fo);
pango_cairo_context_set_font_options(pango_layout_get_context(layout), fo);
cairo_font_options_destroy(fo);
pango_cairo_update_layout(cairo, layout);
pango_cairo_show_layout(cairo, layout);
g_object_unref(layout);
pango_cairo_update_layout(cairo, layout);
cairo_status_t status = cairo_status(cairo);
if (status != CAIRO_STATUS_SUCCESS) {
sway_log(SWAY_ERROR, "pango_cairo_update_layout() failed: %s",
cairo_status_to_string(status));
goto out;
}
pango_cairo_show_layout(cairo, layout);
out:
g_object_unref(layout);
free(buf);
}

View file

@ -39,14 +39,14 @@ if is_freebsd
endif
# Execute the wlroots subproject, if any
wlroots_version = ['>=0.20.0', '<0.21.0']
wlroots_version = ['>=0.21.0', '<0.22.0']
subproject(
'wlroots',
default_options: ['examples=false'],
required: false,
version: wlroots_version,
)
wlroots = dependency('wlroots-0.20', version: wlroots_version, fallback: 'wlroots')
wlroots = dependency('wlroots-0.21', version: wlroots_version, fallback: 'wlroots')
wlroots_features = {
'xwayland': false,
'libinput_backend': false,