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

Make lazy-key-grab an option, add --release for i3 to manpage.

This commit is contained in:
Dave Davenport 2017-01-07 10:35:36 +01:00
parent ff88d3d6d7
commit c98b67ed0d
3 changed files with 43 additions and 5 deletions

View file

@ -209,6 +209,10 @@ Select the scrolling method. 0: Per page, 1: continuous.
Hide the indicator that shows what part of the string is matched.
`-lazy-grab`
When fail to grab keyboard, don't block but retry later in background.
### Theming
All colors are either hex #rrggbb, #aarrggbb or argb:aarrggbbvalues or X11 color names.
@ -886,6 +890,15 @@ Use `qalc` to get a simple calculator in **rofi**:
rofi -show calc -modi "calc:qalc +u8 -nocurrencies"
## I3
In [I3](http://i3wm.org/) you want to bind rofi to be launched on key-release. Otherwise it cannot grab the keyboard.
See also the I3 [manual](http://i3wm.org/docs/userguide.html):
Some tools (such as import or xdotool) might be unable to run upon a KeyPress event, because the keyboard/pointer is
still grabbed. For these situations, the --release flag can be used, which will execute the command after the keys have
been released.
## LICENSE
MIT/X11

View file

@ -300,6 +300,12 @@ Select the scrolling method\. 0: Per page, 1: continuous\.
.P
Hide the indicator that shows what part of the string is matched\.
.
.P
\fB\-lazy\-grab\fR
.
.P
When fail to grab keyboard, don\'t block but retry later in background\.
.
.SS "Theming"
All colors are either hex #rrggbb, #aarrggbb or argb:aarrggbbvalues or X11 color names\.
.
@ -1469,6 +1475,12 @@ Use \fBqalc\fR to get a simple calculator in \fBrofi\fR:
.
.IP "" 0
.
.SH "I3"
In I3 \fIhttp://i3wm\.org/\fR you want to bind rofi to be launched on key\-release\. Otherwise it cannot grab the keyboard\. See also the I3 manual \fIhttp://i3wm\.org/docs/userguide\.html\fR:
.
.P
Some tools (such as import or xdotool) might be unable to run upon a KeyPress event, because the keyboard/pointer is still grabbed\. For these situations, the \-\-release flag can be used, which will execute the command after the keys have been released\.
.
.SH "LICENSE"
.
.nf

View file

@ -252,6 +252,7 @@ static void print_main_application_options ( int is_term )
print_help_msg ( "-markup", "", "Enable pango markup where possible.", NULL, is_term );
print_help_msg ( "-normal-window", "", "In dmenu mode, behave as a normal window. (experimental)", NULL, is_term );
print_help_msg ( "-show", "[mode]", "Show the mode 'mode' and exit. The mode has to be enabled.", NULL, is_term );
print_help_msg ( "-lazy-grab", "", "When fail to grab keyboard, don't block but retry later.", NULL, is_term );
}
static void help ( G_GNUC_UNUSED int argc, char **argv )
{
@ -625,11 +626,23 @@ static gboolean startup ( G_GNUC_UNUSED gpointer data )
// We grab this using the rootwindow (as dmenu does it).
// this seems to result in the smallest delay for most people.
if ( ( window_flags & MENU_NORMAL_WINDOW ) == 0 ) {
if ( !take_keyboard ( xcb_stuff_get_root_window ( xcb), 0) ){
g_timeout_add ( 1,lazy_grab_keyboard, NULL);
}
if ( !take_pointer ( xcb_stuff_get_root_window ( xcb ), 0 )) {
g_timeout_add ( 1,lazy_grab_pointer, NULL);
if ( find_arg ( "-lazy-grab") >= 0 ){
if ( !take_keyboard ( xcb_stuff_get_root_window ( xcb), 0) ){
g_timeout_add ( 1,lazy_grab_keyboard, NULL);
}
if ( !take_pointer ( xcb_stuff_get_root_window ( xcb ), 0 )) {
g_timeout_add ( 1,lazy_grab_pointer, NULL);
}
} else {
if ( !take_keyboard ( xcb_stuff_get_root_window ( xcb), 500) ){
fprintf ( stderr, "Failed to grab keyboard, even after %d uS.", 500 * 1000 );
g_main_loop_quit ( main_loop );
return G_SOURCE_REMOVE;
}
if ( ! take_pointer ( xcb_stuff_get_root_window ( xcb ), 100 ) ) {
fprintf ( stderr, "Failed to grab mouse pointer, even after %d uS.", 100*1000);
}
}
}
TICK_N ( "Grab keyboard" );