1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

Bug #200 implement -m mode

This commit is contained in:
QC 2015-08-02 15:45:52 +02:00
parent 34dee2a3eb
commit 77e5541ba5
8 changed files with 62 additions and 6 deletions

View file

@ -130,5 +130,7 @@ Settings config = {
.combi_modi = "window,run",
/** Fuzzy matching. */
.fuzzy = FALSE,
/** Monitor */
.monitor = -1,
};

View file

@ -395,6 +395,11 @@ The following options are further explained in the theming section:
When one entry is left, automatically select this.
`-m` *num*
`-monitor` *num*
Select (Xinerama) monitor to display **rofi** on.
### PATTERN setting
`-terminal`

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "ROFI\-MANPAGE" "" "July 2015" "" ""
.TH "ROFI\-MANPAGE" "" "August 2015" "" ""
.
.SH "NAME"
\fBrofi\fR \- A window switcher, run launcher, ssh dialog and dmenu replacement
@ -719,6 +719,19 @@ When one entry is left, automatically select this\.
.
.IP "" 0
.
.P
\fB\-m\fR \fInum\fR \fB\-monitor\fR \fInum\fR
.
.IP "" 4
.
.nf
Select (Xinerama) monitor to display **rofi** on\.
.
.fi
.
.IP "" 0
.
.SS "PATTERN setting"
\fB\-terminal\fR
.

View file

@ -228,6 +228,8 @@ typedef struct _Settings
char *combi_modi;
/** Fuzzy match */
unsigned int fuzzy;
/** Monitors */
int monitor;
} Settings;
/** Global Settings structure. */

View file

@ -65,6 +65,8 @@ int window_send_message ( Display *display, Window target, Window subject,
// find the dimensions of the monitor displaying point x,y
void monitor_dimensions ( Display *display, Screen *screen, int x, int y, workarea *mon );
// Find the dimensions of the monitor specified by user.
int monitor_get_dimension ( Display *display, Screen *screen, int monitor, workarea *mon );
/**
* @param display The display.

View file

@ -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;

View file

@ -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.