Qball's Weblog
Rofi 1.4.0: Sneak Preview (4): Sizing
This blog post will discussed how the different widgets in the rofi window (re)size.
Resizing of the window
New in this version of rofi is that the whole interface sizes automatically. So if one widget gets bigger (because padding is changed) the parent widget size will adjust to make space.
Some widgets are allows to expand/shrink to fill the remaining size, others will always occupy the size they require. The entry box is one of those widgets.
This behaviour is modelled after GTK.
The figure below shows how the different widgets are packed together.
The widgets marked with +
will grow/shrink to fit the remaining space.
Note when fullscreen is enabled, this behaviour is changed.
How the size of the listview is determined
The listview widget is the most interesting widget if it comes to sizing, as it shows dynamic content. It is one of the widgets that determines the height of the window. However, in contrary to the rest of the widgets, every element in the listview is sized by the listview, and not the content in the element. While it is possible to set different margins, font-sizes for different elements in the listview this is discouraged. The reason for this is speed, by keeping the size of each element fixed, a lot of sizing calculations can be avoided. In the future this behaviour might change.
There are two options that affect how the listview in rofi resizes based on filtering.
fixed-height
: Force rofi to always show all configured rows (line
setting), even when empty.dynamic
: Resize when the list gets filtered.
The fixed-height
setting override the dynamic
setting. This results in
three possible situations:
Note when fullscreen is enabled, this behaviour is changed. The listview will then always fill up the remaining space.
Fixed-Height enabled
If fixed-height: true
is set, the listview will always show the number of configured lines.
This is the most static view. The listview widget will not resize.
Try yourself:
seq 0 20 | rofi -dmenu -theme-str '#window mainbox listview { fixed-height: true; lines: 10;}' -show run
Fixed-Height disabled, dynamic disabled
This corresponds to the initial behaviour of rofi. The number of rows in
the list view is determined by the number of items to show, with a maximum of
the lines
setting. If you filter the list, it will not shrink.
So if you configure lines to be 10, then show 5 items, the listview will be 5 rows high. Filtering will not affect the size.
Try yourself:
seq 0 20 | rofi -dmenu -theme-str '#window mainbox listview { fixed-height: false; dynamic: false; lines: 10;}'
Fixed-Height disabled, dynamic enabled
If you enable both, the listview will always resize to show the available number
of rows with a maximum of the lines
setting.
This means that filtering the list, will automatically resize the view.
Try yourself:
seq 0 20 | rofi -dmenu -theme-str '#window mainbox listview { fixed-height: false; dynamic: true; lines: 10;}'
Font sizing and dpi.
One of the settings that is often is the biggest determining factor in sizing is the font. The font size is scaled based on DPI. This is all handled by pango.
How a font-size translates to on-screen pixels depends on the dpi
setting. We
currently support 3 options:
User specified
If you pass a number bigger then 2 to the dpi
setting, it interprets this as
the dpi value and passes this to pango.
Detect based on X11 screen size
This is the behaviour toolkits like gtk and windows managers like i3 determine the dpi size. The dpi is based on what X11 reports as the pixel and real-size of the default screen. This will give one dpi value for all monitors.
Detect base on monitor size
This is a more experimental option, that is also implemented in the latest Qt. It, if available, requests via xrandr the actual size of the monitor and number of pixels. Based on this the dpi is calculated for the monitor rofi is visible on.
This, in theory, would make fonts in rofi appear the same size on each connected monitor, even if they have different sizes and resolutions.
To see what DPI rofi detected, run rofi -h
it contains a section showing what has been detected:
ID: 0 (primary) ID: 1 ID: 2
name: eDP1 name: DVI-I-2 name: DVI-I-3
position: 0,0 position: 0,0 position: 1920,0
size: 2160,1440 size: 1920,1080 size: 1600,1200
size: 250mm,170mm dpi: 219,215 size: 480mm,268mm dpi: 102,102 size: 367mm,275mm dpi: 111,111
comments powered by DisqusNote that not every monitor reports it size correctly.