From 6225b29d9484b8a6e0822e7b55f96051c6d03cb9 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Fri, 19 Aug 2016 18:01:26 +0200 Subject: [PATCH] Issue 448, Take another default that should not fail, better error mesg --- config/config.c | 2 +- doc/rofi-manpage.markdown | 2 +- source/helper.c | 16 +++++++++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/config/config.c b/config/config.c index e3b8f83f..1a9da3b0 100644 --- a/config/config.c +++ b/config/config.c @@ -112,7 +112,7 @@ Settings config = { .tokenize = TRUE, .regex = FALSE, /** Monitor */ - .monitor = "-1", + .monitor = "-5", /** set line margin */ .line_margin = 2, /** Set filter */ diff --git a/doc/rofi-manpage.markdown b/doc/rofi-manpage.markdown index 2b9b0b2c..14014343 100644 --- a/doc/rofi-manpage.markdown +++ b/doc/rofi-manpage.markdown @@ -388,7 +388,7 @@ detection). Negative numbers are handled differently: * **-4**: the monitor with the focused window. * **-5**: the monitor that shows the mouse pointer. - Default: *-1* + Default: *-5* See `rofi -h` output for the detected monitors, their position and size. diff --git a/source/helper.c b/source/helper.c index 905babfd..f74203d1 100644 --- a/source/helper.c +++ b/source/helper.c @@ -49,6 +49,13 @@ #include "rofi.h" #include "view.h" +const char *const monitor_position_entries[] = { + "on focused monitor", + "on focused window", + "at mouse pointer", + "on monitor with focused window", + "on monitor that has mouse pointer" +}; extern xcb_connection_t *xcb_connection; extern xcb_screen_t *xcb_screen; static int stored_argc = 0; @@ -482,7 +489,14 @@ int config_sanity_check ( void ) ssize = MIN ( mon.w, mon.h ); } else{ - g_string_append_printf ( msg, "\tconfig.monitor=%s Could not find monitor.\n", config.monitor ); + const char *name = config.monitor; + if ( name && name[0] == '-' ) { + int index = name[1] - '0'; + if ( index < 5 && index > 0 ) { + name = monitor_position_entries[index - 1]; + } + } + g_string_append_printf ( msg, "\tconfig.monitor=%s Could not find monitor.\n", name ); ssize = 0; } // Have todo an estimate here.