1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-25 13:55:34 -05:00

Update DPI detection method.

This commit is contained in:
Dave Davenport 2017-01-22 14:58:59 +01:00
parent 2306e58a25
commit 46db427735
3 changed files with 7 additions and 6 deletions

View file

@ -414,7 +414,8 @@ This option can be specified multiple times.
`-dpi` *number*
Override the default DPI setting.
If set to `0` it tries to auto-detect based on monitor.
If set to `0` it tries to auto-detect based on X11 screen size. (Similar to i3 and GTK)
If set to `1` it tries to auto-detect based on monitor (rofi is displayed on) size. (Similar to latest QT5)
### PATTERN setting

View file

@ -672,7 +672,7 @@ This option can be specified multiple times\.
\fB\-dpi\fR \fInumber\fR
.
.P
Override the default DPI setting\. If set to \fB0\fR it tries to auto\-detect based on monitor\.
Override the default DPI setting\. If set to \fB0\fR it tries to auto\-detect based on X11 screen size\. (Similar to i3 and GTK) If set to \fB1\fR it tries to auto\-detect based on monitor (rofi is displayed on) size\. (Similar to latest QT5)
.
.SS "PATTERN setting"
\fB\-terminal\fR

View file

@ -209,7 +209,7 @@ static void menu_capture_screenshot ( void )
fprintf ( stderr, color_green "Storing screenshot %s\n"color_reset, fpath );
cairo_status_t status = cairo_surface_write_to_png ( CacheState.edit_surf, fpath );
if ( status != CAIRO_STATUS_SUCCESS ) {
fprintf ( stderr, "Failed to produce screenshot '%s', got error: '%s'\n", filename,
fprintf ( stderr, "Failed to produce screenshot '%s', got error: '%s'\n", fpath,
cairo_status_to_string ( status ) );
}
g_free ( fpath );
@ -671,14 +671,14 @@ void __create_window ( MenuFlags menu_flags )
CacheState.flags = menu_flags;
monitor_active ( &( CacheState.mon ) );
// Setup dpi
if ( config.dpi > 0 ) {
if ( config.dpi > 1 ) {
PangoFontMap *font_map = pango_cairo_font_map_get_default ();
pango_cairo_font_map_set_resolution ( (PangoCairoFontMap *) font_map, (double) config.dpi );
}
else if ( config.dpi == 0 ) {
else if ( config.dpi == 0 || config.dpi == 1 ) {
// Auto-detect mode.
double dpi = 96;
if ( CacheState.mon.mh > 0 ) {
if ( CacheState.mon.mh > 0 && config.dpi == 1 ) {
dpi = ( CacheState.mon.h * 25.4 ) / (double) ( CacheState.mon.mh );
}
else {