summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/rofi-manpage.markdown8
-rw-r--r--doc/rofi.110
-rw-r--r--include/helper.h2
-rw-r--r--include/widgets/textbox.h20
-rw-r--r--include/x11-helper.h1
-rw-r--r--source/dialogs/drun.c4
-rw-r--r--source/dialogs/ssh.c2
-rw-r--r--source/helper.c9
-rw-r--r--source/rofi.c2
-rw-r--r--source/theme.c4
-rw-r--r--source/view.c42
-rw-r--r--source/x11-helper.c21
-rw-r--r--source/xrmoptions.c2
13 files changed, 82 insertions, 45 deletions
diff --git a/doc/rofi-manpage.markdown b/doc/rofi-manpage.markdown
index 3be97936..a735f9a0 100644
--- a/doc/rofi-manpage.markdown
+++ b/doc/rofi-manpage.markdown
@@ -51,6 +51,7 @@
[ -no-show-match ]
[ -theme *filename* ]
[ -theme-str *string* ]
+[ -dpi *dpi* ]
## DESCRIPTION
@@ -408,6 +409,13 @@ For example
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.
+
### PATTERN setting
`-terminal`
diff --git a/doc/rofi.1 b/doc/rofi.1
index 9757516f..d7f40cd9 100644
--- a/doc/rofi.1
+++ b/doc/rofi.1
@@ -1,13 +1,13 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
-.TH "ROFI\-MANPAGE" "" "2017-01-18" "" ""
+.TH "ROFI\-MANPAGE" "" "January 2017" "" ""
.
.SH "NAME"
\fBrofi\fR \- A window switcher, run launcher, ssh dialog and dmenu replacement
.
.SH "SYNOPSIS"
-\fBrofi\fR [ \-width \fIpct_scr\fR ] [ \-lines \fIlines\fR ] [ \-columns \fIcolumns\fR ] [ \-font \fIpangofont\fR ] [ \-terminal \fIterminal\fR ] [ \-location \fIposition\fR ] [ \-fixed\-num\-lines ] [ \-padding \fIpadding\fR ] [ \-display \fIdisplay\fR ] [ \-bw \fIwidth\fR ] [ \-dmenu [ \-p \fIprompt\fR ] [ \-sep \fIseparator\fR ] [ \-l \fIselected line\fR ] [ \-mesg ] [ \-select ] [ \-input \fIinput\fR ] ] [ \-filter \fIfilter\fR ] [ \-ssh\-client \fIclient\fR ] [ \-ssh\-command \fIcommand\fR ] [ \-window\-command \fIcommand\fR ] [ \-disable\-history ] [ \-levenshtein\-sort ] [ \-case\-sensitive ] [ \-cycle ] [ \-show \fImode\fR ] [ \-modi \fImode1,mode2\fR ] [ \-eh \fIelement height\fR ] [ \-e \fImessage\fR] [ \-a \fIrow\fR ] [ \-u \fIrow\fR ] [ \-pid \fIpath\fR ] [ \-version ] [ \-help ] [ \-dump\-xresources ] [ \-dump\-xresources\-theme ] [ \-auto\-select ] [ \-parse\-hosts ] [ \-no\-parse\-known\-hosts ] [ \-combi\-modi \fImode1,mode2\fR ] [ \-normal\-window ] [ \-fake\-transparency ] [ \-matching \fImethod\fR ] [ \-tokenize ] [ \-no\-click\-to\-exit ] [ \-threads \fInum\fR ] [ \-config \fIfilename\fR ] [ \-no\-show\-match ] [ \-theme \fIfilename\fR ] [ \-theme\-str \fIstring\fR ]
+\fBrofi\fR [ \-width \fIpct_scr\fR ] [ \-lines \fIlines\fR ] [ \-columns \fIcolumns\fR ] [ \-font \fIpangofont\fR ] [ \-terminal \fIterminal\fR ] [ \-location \fIposition\fR ] [ \-fixed\-num\-lines ] [ \-padding \fIpadding\fR ] [ \-display \fIdisplay\fR ] [ \-bw \fIwidth\fR ] [ \-dmenu [ \-p \fIprompt\fR ] [ \-sep \fIseparator\fR ] [ \-l \fIselected line\fR ] [ \-mesg ] [ \-select ] [ \-input \fIinput\fR ] ] [ \-filter \fIfilter\fR ] [ \-ssh\-client \fIclient\fR ] [ \-ssh\-command \fIcommand\fR ] [ \-window\-command \fIcommand\fR ] [ \-disable\-history ] [ \-levenshtein\-sort ] [ \-case\-sensitive ] [ \-cycle ] [ \-show \fImode\fR ] [ \-modi \fImode1,mode2\fR ] [ \-eh \fIelement height\fR ] [ \-e \fImessage\fR] [ \-a \fIrow\fR ] [ \-u \fIrow\fR ] [ \-pid \fIpath\fR ] [ \-version ] [ \-help ] [ \-dump\-xresources ] [ \-dump\-xresources\-theme ] [ \-auto\-select ] [ \-parse\-hosts ] [ \-no\-parse\-known\-hosts ] [ \-combi\-modi \fImode1,mode2\fR ] [ \-normal\-window ] [ \-fake\-transparency ] [ \-matching \fImethod\fR ] [ \-tokenize ] [ \-no\-click\-to\-exit ] [ \-threads \fInum\fR ] [ \-config \fIfilename\fR ] [ \-no\-show\-match ] [ \-theme \fIfilename\fR ] [ \-theme\-str \fIstring\fR ] [ \-dpi \fIdpi\fR ]
.
.SH "DESCRIPTION"
\fBrofi\fR is an X11 popup window switcher, run dialog, dmenu replacement and more\. It focuses on being fast to use and have minimal distraction\. It supports keyboard and mouse navigation, type to filter, tokenized search and more\.
@@ -668,6 +668,12 @@ rofi \-theme\-str \'#window { fullscreen: true; }\'
.P
This option can be specified multiple times\.
.
+.P
+\fB\-dpi\fR \fInumber\fR
+.
+.P
+Override the default DPI setting\. If set to \fB0\fR it tries to auto\-detect based on monitor\.
+.
.SS "PATTERN setting"
\fB\-terminal\fR
.
diff --git a/include/helper.h b/include/helper.h
index 01799967..5f530dbf 100644
--- a/include/helper.h
+++ b/include/helper.h
@@ -209,8 +209,6 @@ char * rofi_latin_to_utf8_strdup ( const char *input, gssize length );
*/
PangoAttrList *token_match_get_pango_attr ( ThemeHighlight th, GRegex **tokens, const char *input, PangoAttrList *retv );
-
-
/**
* @param pattern The user input to match against.
* @param plen Pattern length.
diff --git a/include/widgets/textbox.h b/include/widgets/textbox.h
index f8469ead..d81d8806 100644
--- a/include/widgets/textbox.h
+++ b/include/widgets/textbox.h
@@ -48,16 +48,16 @@ typedef struct
*/
typedef enum
{
- TB_AUTOHEIGHT = 1 << 0,
- TB_AUTOWIDTH = 1 << 1,
- TB_LEFT = 1 << 16,
- TB_RIGHT = 1 << 17,
- TB_CENTER = 1 << 18,
- TB_EDITABLE = 1 << 19,
- TB_MARKUP = 1 << 20,
- TB_WRAP = 1 << 21,
- TB_PASSWORD = 1 << 22,
- TB_INDICATOR = 1 << 23,
+ TB_AUTOHEIGHT = 1 << 0,
+ TB_AUTOWIDTH = 1 << 1,
+ TB_LEFT = 1 << 16,
+ TB_RIGHT = 1 << 17,
+ TB_CENTER = 1 << 18,
+ TB_EDITABLE = 1 << 19,
+ TB_MARKUP = 1 << 20,
+ TB_WRAP = 1 << 21,
+ TB_PASSWORD = 1 << 22,
+ TB_INDICATOR = 1 << 23,
} TextboxFlags;
/**
* Flags indicating current state of the textbox.
diff --git a/include/x11-helper.h b/include/x11-helper.h
index ac833ce6..7f37899d 100644
--- a/include/x11-helper.h
+++ b/include/x11-helper.h
@@ -97,6 +97,7 @@ typedef struct _workarea
int w;
/** Height of the monitor */
int h;
+ int mw, mh;
/** Output name of the monitor, e.g. eDP1 or VGA-1 */
char *name;
/** Pointer to next monitor */
diff --git a/source/dialogs/drun.c b/source/dialogs/drun.c
index 1df1b88f..e881907f 100644
--- a/source/dialogs/drun.c
+++ b/source/dialogs/drun.c
@@ -194,9 +194,9 @@ static void exec_cmd_entry ( DRunModeEntry *e )
}
gchar *fp = rofi_expand_path ( g_strstrip ( str ) );
gchar *exec_path = g_key_file_get_string ( e->key_file, "Desktop Entry", "Path", NULL );
- if ( exec_path != NULL && strlen(exec_path) == 0){
+ if ( exec_path != NULL && strlen ( exec_path ) == 0 ) {
// If it is empty, ignore this property. (#529)
- g_free(exec_path);
+ g_free ( exec_path );
exec_path = NULL;
}
diff --git a/source/dialogs/ssh.c b/source/dialogs/ssh.c
index c0ba2f8c..8cfe68fd 100644
--- a/source/dialogs/ssh.c
+++ b/source/dialogs/ssh.c
@@ -198,7 +198,7 @@ static char **read_hosts_file ( char ** retv, unsigned int *length )
// Reading one line per time.
while ( getline ( &buffer, &buffer_length, fd ) > 0 ) {
// Evaluate one line.
- unsigned int index = 0, ti = 0;
+ unsigned int index = 0, ti = 0;
char *token = buffer;
// Tokenize it.
diff --git a/source/helper.c b/source/helper.c
index 696cf41e..ef4a8a49 100644
--- a/source/helper.c
+++ b/source/helper.c
@@ -249,7 +249,7 @@ GRegex **tokenize ( const char *input, int case_sensitive )
}
char *saveptr = NULL, *token;
- GRegex **retv = NULL;
+ GRegex **retv = NULL;
if ( !config.tokenize ) {
retv = g_malloc0 ( sizeof ( GRegex* ) * 2 );
retv[0] = (GRegex *) create_regex ( input, case_sensitive );
@@ -656,7 +656,7 @@ char *rofi_expand_path ( const char *input )
/** Return the minimum value of a,b,c */
#define MIN3( a, b, c ) ( ( a ) < ( b ) ? ( ( a ) < ( c ) ? ( a ) : ( c ) ) : ( ( b ) < ( c ) ? ( b ) : ( c ) ) )
-unsigned int levenshtein ( const char *needle, const glong needlelen, const char *haystack, const glong haystacklen )
+unsigned int levenshtein ( const char *needle, const glong needlelen, const char *haystack, const glong haystacklen )
{
unsigned int column[needlelen + 1];
for ( glong y = 0; y <= needlelen; y++ ) {
@@ -846,8 +846,8 @@ int rofi_scorer_fuzzy_evaluate ( const char *pattern, glong plen, const char *st
// uleft: value of the upper left cell; ulefts: maximum value of uleft and cells on the left. The arbitrary initial
// values suppress warnings.
int uleft = 0, ulefts = 0, left, lefts;
- const gchar *pit = pattern, *sit;
- enum CharClass prev = NON_WORD, cur;
+ const gchar *pit = pattern, *sit;
+ enum CharClass prev = NON_WORD, cur;
for ( si = 0, sit = str; si < slen; si++, sit = g_utf8_next_char ( sit ) ) {
cur = rofi_scorer_get_character_class ( g_utf8_get_char ( sit ) );
score[si] = rofi_scorer_get_score_for ( prev, cur );
@@ -889,4 +889,3 @@ int rofi_scorer_fuzzy_evaluate ( const char *pattern, glong plen, const char *st
g_free ( dp );
return -lefts;
}
-
diff --git a/source/rofi.c b/source/rofi.c
index 63b3edc8..ea155f2b 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -416,7 +416,7 @@ static int add_mode ( const char * token )
}
else
#endif // WINDOW_MODE
- // SSh dialog
+ // SSh dialog
if ( strcasecmp ( token, "ssh" ) == 0 ) {
modi[num_modi] = &ssh_mode;
num_modi++;
diff --git a/source/theme.c b/source/theme.c
index 27c9f508..47e7c4a0 100644
--- a/source/theme.c
+++ b/source/theme.c
@@ -861,9 +861,9 @@ gboolean rofi_theme_parse_file ( const char *file )
yyin = fopen ( filename, "rb" );
if ( yyin == NULL ) {
char *str = g_markup_printf_escaped ( "Failed to open theme: <i>%s</i>\nError: <b>%s</b>",
- filename, strerror ( errno ) );
+ filename, strerror ( errno ) );
rofi_add_error_message ( g_string_new ( str ) );
- g_free(str);
+ g_free ( str );
g_free ( filename );
return TRUE;
}
diff --git a/source/view.c b/source/view.c
index 9db61826..024c41e3 100644
--- a/source/view.c
+++ b/source/view.c
@@ -61,8 +61,7 @@
#include "theme.h"
/** The Rofi View log domain */
-#define LOG_DOMAIN "View"
-
+#define LOG_DOMAIN "View"
#include "xcb.h"
/**
@@ -343,10 +342,10 @@ static void rofi_view_calculate_window_position ( RofiViewState *state )
break;
}
// Apply offset.
- Distance x = rofi_theme_get_distance ( WIDGET ( state->main_window), "x-offset", config.x_offset );
- Distance y = rofi_theme_get_distance ( WIDGET ( state->main_window), "y-offset", config.y_offset );
- state->x += distance_get_pixel(x, ORIENTATION_HORIZONTAL);
- state->y += distance_get_pixel(y, ORIENTATION_VERTICAL);
+ Distance x = rofi_theme_get_distance ( WIDGET ( state->main_window ), "x-offset", config.x_offset );
+ Distance y = rofi_theme_get_distance ( WIDGET ( state->main_window ), "y-offset", config.y_offset );
+ state->x += distance_get_pixel ( x, ORIENTATION_HORIZONTAL );
+ state->y += distance_get_pixel ( y, ORIENTATION_VERTICAL );
}
static void rofi_view_window_update_size ( RofiViewState * state )
@@ -558,11 +557,12 @@ static void filter_elements ( thread_state *t, G_GNUC_UNUSED gpointer user_data
t->state->line_map[t->start + t->count] = i;
if ( config.sort ) {
// This is inefficient, need to fix it.
- char * str = mode_get_completion ( t->state->sw, i );
- glong slen = g_utf8_strlen ( str, -1 );
+ char * str = mode_get_completion ( t->state->sw, i );
+ glong slen = g_utf8_strlen ( str, -1 );
if ( config.levenshtein_sort || config.matching_method != MM_FUZZY ) {
t->state->distance[i] = levenshtein ( pattern, plen, str, slen );
- } else {
+ }
+ else {
t->state->distance[i] = rofi_scorer_fuzzy_evaluate ( pattern, plen, str, slen );
}
g_free ( str );
@@ -666,11 +666,27 @@ void __create_window ( MenuFlags menu_flags )
PangoContext *p = pango_cairo_create_context ( CacheState.edit_draw );
// Set the font options from the xlib surface
pango_cairo_context_set_font_options ( p, fo );
+
+ CacheState.main_window = box;
+ CacheState.flags = menu_flags;
+ monitor_active ( &( CacheState.mon ) );
// Setup dpi
if ( config.dpi > 0 ) {
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 ) {
+ // Auto-detect mode.
+ double dpi = 96;
+ if ( CacheState.mon.mh > 0 ) {
+ dpi = ( CacheState.mon.h * 25.4 ) / (double) ( CacheState.mon.mh );
+ }
+ else {
+ dpi = ( xcb->screen->height_in_pixels * 25.4 ) / (double) ( xcb->screen->height_in_millimeters );
+ }
+ PangoFontMap *font_map = pango_cairo_font_map_get_default ();
+ pango_cairo_font_map_set_resolution ( (PangoCairoFontMap *) font_map, dpi );
+ }
// Setup font.
// Dummy widget.
container *win = container_create ( "window.box" );
@@ -710,10 +726,6 @@ void __create_window ( MenuFlags menu_flags )
xcb_change_property ( xcb->connection, XCB_PROP_MODE_REPLACE, box, xcb->ewmh._NET_WM_NAME, xcb->ewmh.UTF8_STRING, 8, 4, "rofi" );
xcb_change_property ( xcb->connection, XCB_PROP_MODE_REPLACE, box, XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8, 4, "rofi" );
- CacheState.main_window = box;
- CacheState.flags = menu_flags;
- monitor_active ( &( CacheState.mon ) );
-
char *transparency = rofi_theme_get_string ( WIDGET ( win ), "transparency", NULL );
if ( transparency == NULL && config.fake_transparency ) {
transparency = config.fake_background;
@@ -1102,8 +1114,8 @@ gboolean rofi_view_trigger_action ( RofiViewState *state, KeyBindingAction actio
menu_capture_screenshot ( );
break;
case TOGGLE_SORT:
- config.sort = !config.sort;
- state->refilter = TRUE;
+ config.sort = !config.sort;
+ state->refilter = TRUE;
textbox_text ( state->case_indicator, get_matching_state () );
break;
case MODE_PREVIOUS:
diff --git a/source/x11-helper.c b/source/x11-helper.c
index 2411d3ec..93ec2842 100644
--- a/source/x11-helper.c
+++ b/source/x11-helper.c
@@ -210,6 +210,9 @@ static workarea * x11_get_monitor_from_output ( xcb_randr_output_t out )
retv->w = crtc_reply->width;
retv->h = crtc_reply->height;
+ retv->mw = op_reply->mm_width;
+ retv->mh = op_reply->mm_height;
+
char *tname = (char *) xcb_randr_get_output_info_name ( op_reply );
int tname_len = xcb_randr_get_output_info_name_length ( op_reply );
@@ -337,6 +340,16 @@ void x11_dump_monitor_layout ( void )
printf ( "%s name%s: %s\n", ( is_term ) ? color_bold : "", is_term ? color_reset : "", iter->name );
printf ( "%s position%s: %d,%d\n", ( is_term ) ? color_bold : "", is_term ? color_reset : "", iter->x, iter->y );
printf ( "%s size%s: %d,%d\n", ( is_term ) ? color_bold : "", is_term ? color_reset : "", iter->w, iter->h );
+ if ( iter->mw > 0 && iter->mh > 0 ) {
+ printf ( "%s size%s: %dmm,%dmm dpi: %.0f,%.0f\n",
+ ( is_term ) ? color_bold : "",
+ is_term ? color_reset : "",
+ iter->mw,
+ iter->mh,
+ iter->w * 25.4 / (double) iter->mw,
+ iter->h * 25.4 / (double) iter->mh
+ );
+ }
printf ( "\n" );
}
}
@@ -679,9 +692,9 @@ gboolean x11_parse_key ( const char *combo, unsigned int *mod, xkb_keysym_t *key
}
}
else if ( g_utf8_collate ( entry_lowered, "super" ) == 0 ||
- g_utf8_collate ( entry_lowered, "super_l" ) == 0 ||
- g_utf8_collate ( entry_lowered, "super_r" ) == 0
- ) {
+ g_utf8_collate ( entry_lowered, "super_l" ) == 0 ||
+ g_utf8_collate ( entry_lowered, "super_r" ) == 0
+ ) {
modmask |= x11_mod_masks[X11MOD_SUPER];
if ( x11_mod_masks[X11MOD_SUPER] == 0 ) {
error_msg = g_strdup ( "X11 configured keyboard has no <b>Super</b> key.\n" );
@@ -701,7 +714,7 @@ gboolean x11_parse_key ( const char *combo, unsigned int *mod, xkb_keysym_t *key
}
else {
if ( sym != XKB_KEY_NoSymbol ) {
- error_msg = g_markup_printf_escaped ( "Only one (non modifier) key can be bound per binding: <b>%s</b> is invalid.\n", entry);
+ error_msg = g_markup_printf_escaped ( "Only one (non modifier) key can be bound per binding: <b>%s</b> is invalid.\n", entry );
}
sym = xkb_keysym_from_name ( entry, XKB_KEYSYM_NO_FLAGS );
if ( sym == XKB_KEY_NoSymbol ) {
diff --git a/source/xrmoptions.c b/source/xrmoptions.c
index 85f829c7..79e379a1 100644
--- a/source/xrmoptions.c
+++ b/source/xrmoptions.c
@@ -138,7 +138,7 @@ static XrmOption xrmOptions[] = {
{ xrm_Boolean, "disable-history", { .num = &config.disable_history }, NULL,
"Disable history in run/ssh", CONFIG_DEFAULT },
{ xrm_Boolean, "sort", { .num = &config.sort }, NULL,
- "Use sorting", CONFIG_DEFAULT },
+ "Use sorting", CONFIG_DEFAULT },
{ xrm_Boolean, "levenshtein-sort", { .num = &config.levenshtein_sort }, NULL,
"Use levenshtein sorting also for fuzzy matching", CONFIG_DEFAULT },
{ xrm_Boolean, "case-sensitive", { .num = &config.case_sensitive }, NULL,