summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorQC <qball@gmpclient.org>2015-08-02 15:45:52 +0200
committerQC <qball@gmpclient.org>2015-08-02 15:45:52 +0200
commit77e5541ba57e62089a931377def6cb2df5b2574e (patch)
tree5f63d2f342714f9062eb5c8af8b79d70c69433ec /source
parent34dee2a3eb946fa0be85f77d6995babefcc1842a (diff)
Bug #200 implement `-m` mode
Diffstat (limited to 'source')
-rw-r--r--source/rofi.c8
-rw-r--r--source/x11-helper.c29
-rw-r--r--source/xrmoptions.c5
3 files changed, 37 insertions, 5 deletions
diff --git a/source/rofi.c b/source/rofi.c
index 1815354d..e2aa0777 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -1870,7 +1870,7 @@ static void main_loop_x11_event_handler ( void )
*
* returns TRUE when mainloop should be stopped.
*/
-static int main_loop_signal_handler ( char command , int quiet )
+static int main_loop_signal_handler ( char command, int quiet )
{
if ( command == 'c' ) {
if ( !quiet ) {
@@ -2105,11 +2105,11 @@ int main ( int argc, char *argv[] )
FD_SET ( x11_fd, &in_fds );
FD_SET ( pfds[0], &in_fds );
- // Wait for X Event or a message on signal pipe
+ // Wait for X Event or a message on signal pipe
if ( select ( MAX ( x11_fd, pfds[0] ) + 1, &in_fds, 0, 0, NULL ) >= 0 ) {
// X11
if ( FD_ISSET ( x11_fd, &in_fds ) ) {
- main_loop_x11_event_handler();
+ main_loop_x11_event_handler ();
}
// Signal Pipe
if ( FD_ISSET ( pfds[0], &in_fds ) ) {
@@ -2117,7 +2117,7 @@ int main ( int argc, char *argv[] )
char c;
read ( pfds[0], &c, 1 );
// Process the signal in the main_loop.
- if(main_loop_signal_handler(c, quiet)) {
+ if ( main_loop_signal_handler ( c, quiet ) ) {
break;
}
}
diff --git a/source/x11-helper.c b/source/x11-helper.c
index 395b176a..907e0af4 100644
--- a/source/x11-helper.c
+++ b/source/x11-helper.c
@@ -139,6 +139,29 @@ int window_get_cardinal_prop ( Display *display, Window w, Atom atom, unsigned l
}
+int monitor_get_dimension ( Display *display, Screen *screen, int monitor, workarea *mon )
+{
+ memset ( mon, 0, sizeof ( workarea ) );
+ mon->w = WidthOfScreen ( screen );
+ mon->h = HeightOfScreen ( screen );
+ // locate the current monitor
+ if ( XineramaIsActive ( display ) ) {
+ int monitors;
+ XineramaScreenInfo *info = XineramaQueryScreens ( display, &monitors );
+
+ if ( info ) {
+ if ( monitor >= 0 && monitor < monitors ) {
+ mon->x = info[monitor].x_org;
+ mon->y = info[monitor].y_org;
+ mon->w = info[monitor].width;
+ mon->h = info[monitor].height;
+ return TRUE;
+ }
+ XFree ( info );
+ }
+ }
+ return FALSE;
+}
// find the dimensions of the monitor displaying point x,y
void monitor_dimensions ( Display *display, Screen *screen, int x, int y, workarea *mon )
{
@@ -203,6 +226,12 @@ void monitor_active ( Display *display, workarea *mon )
Window id;
Atom type;
int count;
+ if ( config.monitor >= 0 ) {
+ if ( monitor_get_dimension ( display, screen, config.monitor, mon ) ) {
+ return;
+ }
+ fprintf ( stderr, "Failed to find selected monitor.\n" );
+ }
if ( window_get_prop ( display, root, netatoms[_NET_ACTIVE_WINDOW], &type, &count, &id, sizeof ( Window ) )
&& type == XA_WINDOW && count > 0 ) {
XWindowAttributes attr;
diff --git a/source/xrmoptions.c b/source/xrmoptions.c
index 2cbb3573..67b3b43f 100644
--- a/source/xrmoptions.c
+++ b/source/xrmoptions.c
@@ -123,7 +123,10 @@ static XrmOption xrmOptions[] = {
{ xrm_Boolean, "auto-select", { .num = &config.auto_select }, NULL },
{ xrm_Boolean, "parse-hosts", { .num = &config.parse_hosts }, NULL },
{ xrm_String, "combi-modi", { .str = &config.combi_modi }, NULL },
- { xrm_Boolean, "fuzzy", { .num = &config.fuzzy }, NULL }
+ { xrm_Boolean, "fuzzy", { .num = &config.fuzzy }, NULL },
+ { xrm_Number, "monitor", { .snum = &config.monitor }, NULL },
+ /* Alias for dmenu compatibility. */
+ { xrm_Number, "m", { .snum = &config.monitor }, NULL }
};
// Dynamic options.