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:
parent
34dee2a3eb
commit
77e5541ba5
8 changed files with 62 additions and 6 deletions
|
@ -130,5 +130,7 @@ Settings config = {
|
|||
.combi_modi = "window,run",
|
||||
/** Fuzzy matching. */
|
||||
.fuzzy = FALSE,
|
||||
/** Monitor */
|
||||
.monitor = -1,
|
||||
};
|
||||
|
||||
|
|
|
@ -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`
|
||||
|
|
15
doc/rofi.1
15
doc/rofi.1
|
@ -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
|
||||
.
|
||||
|
|
|
@ -228,6 +228,8 @@ typedef struct _Settings
|
|||
char *combi_modi;
|
||||
/** Fuzzy match */
|
||||
unsigned int fuzzy;
|
||||
/** Monitors */
|
||||
int monitor;
|
||||
} Settings;
|
||||
|
||||
/** Global Settings structure. */
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue