tuurep / openbox

Openbox with some fixes and tweaks that I'd like to have
http://openbox.org
GNU General Public License v2.0
0 stars 0 forks source link

Perfectly center window title #1

Open tuurep opened 1 week ago

tuurep commented 1 week ago

With

*.text.justify: center

in a theme, the title isn't centered on the whole width of the titlebar, but offset by buttons on the bar, like so:

image

I found a good lead about how this could maybe be changed:

https://github.com/helloSystem/ISO/issues/145#issuecomment-781527843

On modifying Openbox, a starting point can be changing in openbox/framerender.c framerender_label to call RrPaint with self->width instead of self->label_width.

Only changing self->label_width to self->width comes close, but is basically one character half a character width too far to the right:

image

Adding a sort of arbitrary self->width - 10 (px?) looks like it's very close:

image

So, looks like it's possible, but a couple issues:

(window title is downloads)

self->label_width:

image

self->width:

image

It does still truncate, as can be seen with a longer title:

image

tuurep commented 1 week ago

framerender_label:

https://github.com/tuurep/openbox/blob/adb85c538962c15b496b90e79781eb7254c798cf/openbox/framerender.c#L351

self is an ObFrame struct, see here:

https://github.com/tuurep/openbox/blob/adb85c538962c15b496b90e79781eb7254c798cf/openbox/frame.h#L82

tuurep commented 1 week ago

basically half a character width too far to the right

  • How to get the right width with no hardcoded pixel values?

Look into this:

https://github.com/tuurep/openbox/blob/adb85c538962c15b496b90e79781eb7254c798cf/obrender/render.h#L399

tuurep commented 1 week ago

Have to also consider there can be buttons or an app icon on the left side.

Probably best to approach this by first getting the title perfectly centered and then thinking about the truncation as a separate problem.