From cf731b1504b66af6b6c0b0e8d99cd044cc046bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20Wi=C3=9Fmann?= Date: Mon, 17 Aug 2015 18:32:17 +0200 Subject: [PATCH] Monitor -2 stands for the focused window When setting rofi's monitor to -2, rofi is placed over the focused window. --- doc/rofi-manpage.markdown | 4 +++- doc/rofi.1 | 8 +++++--- source/x11-helper.c | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/doc/rofi-manpage.markdown b/doc/rofi-manpage.markdown index d5ab23a2..6cb948c0 100644 --- a/doc/rofi-manpage.markdown +++ b/doc/rofi-manpage.markdown @@ -406,7 +406,9 @@ The following options are further explained in the theming section: `-m` *num* `-monitor` *num* - Select (Xinerama) monitor to display **rofi** on. + Select (Xinerama) monitor to display **rofi** on. The special number -1 denotes the currently focused monitor, the number -2 denotes the currently focused window (i.e. rofi will be displayed on top of the focused window). + + Default: *-1* ### PATTERN setting diff --git a/doc/rofi.1 b/doc/rofi.1 index e53dddbe..0b7de0f9 100644 --- a/doc/rofi.1 +++ b/doc/rofi.1 @@ -741,9 +741,11 @@ When one entry is left, automatically select this\. . .IP "" 4 . -.nf - -Select (Xinerama) monitor to display **rofi** on\. +.P +Select (Xinerama) monitor to display **rofi** on\. The special number -1 denotes the currently focused monitor, the number -2 denotes the currently focused window (i.e. rofi will be displayed on top of the focused window). +. +.P +Default: \fI{cmd}\fR . .fi . diff --git a/source/x11-helper.c b/source/x11-helper.c index 907e0af4..5bd1c675 100644 --- a/source/x11-helper.c +++ b/source/x11-helper.c @@ -241,6 +241,20 @@ void monitor_active ( Display *display, workarea *mon ) -attr.border_width, -attr.border_width, &x, &y, &junkwin ) == True ) { + if ( config.monitor == -2 ) { + // place the menu above the window + // if some window is focused, place menu above window, else fall + // back to selected monitor. + mon->x = x; + mon->y = y; + mon->w = attr.width; + mon->h = attr.height; + mon->t = attr.border_width; + mon->b = attr.border_width; + mon->l = attr.border_width; + mon->r = attr.border_width; + return; + } monitor_dimensions ( display, screen, x, y, mon ); return; }