diff --git a/README.md b/README.md index 0867132..24f04f0 100644 --- a/README.md +++ b/README.md @@ -201,6 +201,9 @@ plugin { # render the window title on the bar render_text = # default: true + # center the window title + text_center = # default: false + # font to render the window title with text_font = # default: Sans diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp index 217b88e..7888984 100644 --- a/src/TabGroup.cpp +++ b/src/TabGroup.cpp @@ -128,6 +128,7 @@ void Hy3TabBarEntry::prepareTexture(float scale, CBox& box) { // clang-format off static const auto* s_rounding = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:rounding")->intValue; static const auto* render_text = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:render_text")->intValue; + static const auto* text_center = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:text_center")->intValue; static const auto* text_font = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:text_font")->strValue; static const auto* text_height = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:text_height")->intValue; static const auto* text_padding = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:text_padding")->intValue; @@ -224,6 +225,9 @@ void Hy3TabBarEntry::prepareTexture(float scale, CBox& box) { PangoLayout* layout = pango_cairo_create_layout(cairo); pango_layout_set_text(layout, this->window_title.c_str(), -1); + if (*text_center) + pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); + PangoFontDescription* font_desc = pango_font_description_from_string(text_font->c_str()); pango_font_description_set_size(font_desc, *text_height * scale * PANGO_SCALE); pango_layout_set_font_description(layout, font_desc); diff --git a/src/main.cpp b/src/main.cpp index b0820f4..aebe592 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -44,6 +44,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { CONF("tabs:from_top", int, 0); CONF("tabs:rounding", int, 3); CONF("tabs:render_text", int, 1); + CONF("tabs:text_center", int, 0); CONF("tabs:text_font", str, "Sans"); CONF("tabs:text_height", int, 8); CONF("tabs:text_padding", int, 3);