Decoration plugin: Add title_align option
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.1k
- Forks
- 237
- Avg merge
- 1h 43m
- Merged PRs (30d)
- 1
Description
Summary
This FR adds customizable text alignment for window titles in the decor (pixman/cairo decoration) plugin, along with the corresponding XML metadata.
Feature added:
title_align: Allows aligning the title bar text (left, center, right).
Current behavior: Title text always aligned left
Benefits
Title text alignment can be changed as required
Configuration Example (wayfire.ini)
[decoration]
title_height = 30
font = JetBrains Mono 10
font_scale = 0.85
title_align = center
How it was tested
- Verified
left,center, andrightalignments on various window widths.
--- a/plugins/decor/deco-theme.hpp 2026-07-27 10:26:17.000000000 +0200
+++ b/plugins/decor/deco-theme.hpp 2026-08-06 17:28:50.638747400 +0200
@@ -72,6 +72,7 @@
wf::option_wrapper_t<std::string> font{"decoration/font"};
wf::option_wrapper_t<wf::color_t> font_color{"decoration/font_color"};
wf::option_wrapper_t<int> title_height{"decoration/title_height"};
+ wf::option_wrapper_t<std::string> title_align{"decoration/title_align"};
wf::option_wrapper_t<int> border_size{"decoration/border_size"};
wf::option_wrapper_t<double> font_scale{"decoration/font_scale"};
wf::option_wrapper_t<double> button_scale{"decoration/button_scale"};
--- a/plugins/decor/deco-theme.cppg 2026-07-27 10:26:17.000000000 +0200
+++ b/plugins/decor/deco-theme.cpp 2026-08-06 17:30:20.329837617 +0200
@@ -86,6 +86,31 @@
layout = pango_cairo_create_layout(cr);
pango_layout_set_font_description(layout, font_desc);
pango_layout_set_text(layout, text.c_str(), text.size());
+ // --- ALIGNMENT LOGIC ---
+ int pango_text_width, pango_text_height;
+ pango_layout_get_pixel_size(layout, &pango_text_width, &pango_text_height);
+ // config settings
+ std::string align = (std::string)title_align;
+ double x_offset = 10.0; // "left" alignment default offset
+
+ if (align == "center")
+ {
+ x_offset = (width - pango_text_width) / 2.0;
+ }
+ else if (align == "right")
+ {
+ x_offset = width - pango_text_width - 10.0; // 10px right offset
+ }
+ if (x_offset < 10.0)
+ {
+ x_offset = 10.0;
+ }
+ cairo_move_to(cr, x_offset, 0);
+ // ---------------------------
cairo_set_source_rgba(cr, color.r, color.g, color.b, color.a);
pango_cairo_show_layout(cr, layout);
pango_font_description_free(font_desc);
--- a/metadata/decoration.xml 2026-07-27 10:26:17.000000000 +0200
+++ b/metadata/decoration.xml 2026-08-06 17:26:43.752761331 +0200
@@ -28,6 +28,11 @@
<max>100</max>
<min>0</min>
</option>
+ <option name="title_align" type="string">
+ <_short>Title bar text align</_short>
+ <_long>Sets the alignment of the title bars text</_long>
+ <default>left</default>
+ </option>
<option name="border_size" type="int">
<_short>Border size</_short>
<_long>Sets the border size in pixels.</_long>
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with plugins/decor/deco-theme.hpp and plugins/decor/deco-theme.cpp, then review metadata/decoration.xml for the decoration options and current title rendering. Check how the proposed title_align values are read and how the title is positioned, then verify left, center, and right alignment across window widths using the provided wayfire.ini configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- desktop
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100