Add support for selecting marks

This commit is contained in:
QC 2014-01-26 15:39:50 +01:00
parent bd33e93e16
commit 0529d21ffd
4 changed files with 63 additions and 9 deletions

View file

@ -48,6 +48,9 @@ Settings config = {
.window_key = "F12",
.run_key = "mod1+F2",
.ssh_key = "mod1+F3",
#ifdef I3
.mark_key = "mod1+F5",
#endif
.location = CENTER,
.wmode = VERTICAL,
.inner_margin = 5

View file

@ -21,9 +21,12 @@ simpleswitcher \- a simple EWMH window switcher
.IR combo ]
.RB [ \-dkey
.IR comdo ]
.RB [ \-mkey
.IR comdo ]
.RB [ \-now ]
.RB [ \-rnow ]
.RB [ \-snow ]
.RB [ \-mnow ]
.RB [ \-term
.IR terminal ]
.RB [ \-loc
@ -70,7 +73,7 @@ simpleswitcher -rkey mod1+grave (grave=backtick)
.RE
.TP
.B -skey
Change the key combination to display the ssh dialog (default: mod1-F3).
Change the key combination to display the ssh dialog (default: Alt-F3).
.P
.RS
simpleswitcher -skey F10
@ -80,6 +83,14 @@ simpleswitcher -skey control+shift+s
simpleswitcher -skey mod1+grave (grave=backtick)
.RE
.TP
.B -mkey
Change the key combination to display the mark dialog (default: Alt-F5)
(only if i3 support is enabled).
.P
.RS
simpleswitcher -mkey Alt-F2
.RE
.TP
.B -now
Run simpleswitcher in all-windows mode once then exit. Does not bind any keys.
.TP
@ -89,6 +100,10 @@ Run simpleswitcher in run-dialog mode once then exit. Does not bind any keys.
.B -snow
Run simpleswitcher in ssh mode once then exit. Does not bind any keys.
.TP
.B -mnow
Run simpleswitcher in mark mode once then exit. Does not bind any keys (only if i3 support is
enabled).
.TP
.B -bg
Set the background text color (X11 named color or hex #rrggbb) for the menu (default: #222222).
.P

View file

@ -10,11 +10,17 @@
#define INTERSECT(x,y,w,h,x1,y1,w1,h1) (OVERLAP((x),(w),(x1),(w1)) && OVERLAP((y),(h),(y1),(h1)))
extern const char *cache_dir;
#ifdef I3
extern char *i3_socket_path;
#endif
typedef enum {
WINDOW_SWITCHER,
RUN_DIALOG,
SSH_DIALOG,
#ifdef I3
MARK_DIALOG,
#endif
NUM_DIALOGS,
MODE_EXIT,
NEXT_DIALOG
@ -82,6 +88,9 @@ typedef struct _Settings {
WindowLocation location;
WindowMode wmode;
unsigned int inner_margin;
#ifdef I3
char * mark_key;
#endif
} Settings;
extern Settings config;

View file

@ -64,6 +64,7 @@
#include "simpleswitcher.h"
#include "run-dialog.h"
#include "ssh-dialog.h"
#include "mark-dialog.h"
#define LINE_MARGIN 4
@ -649,6 +650,12 @@ unsigned int rundialog_modmask;
KeySym rundialog_keysym;
unsigned int sshdialog_modmask;
KeySym sshdialog_keysym;
#ifdef I3
unsigned int markdialog_modmask;
KeySym markdialog_keysym;
#endif
Window main_window = None;
GC gc = NULL;
@ -1178,7 +1185,11 @@ void run_switcher( int fmode, SwitcherMode mode )
} else if ( mode == SSH_DIALOG ) {
retv = ssh_switcher_dialog( &input );
}
#ifdef I3
else if ( mode == MARK_DIALOG ) {
retv = mark_switcher_dialog ( &input );
}
#endif
if ( retv == NEXT_DIALOG ) {
mode = ( mode+1 )%NUM_DIALOGS;
} else {
@ -1214,6 +1225,12 @@ void handle_keypress( XEvent *ev )
key == sshdialog_keysym ) {
run_switcher( FORK , SSH_DIALOG );
}
#ifdef I3
if ( ( markdialog_modmask == AnyModifier || ev->xkey.state & markdialog_modmask ) &&
key == markdialog_keysym ) {
run_switcher( FORK , MARK_DIALOG );
}
#endif
}
// convert a Mod+key arg to mod mask and keysym
@ -1389,21 +1406,31 @@ int main( int argc, char *argv[] )
run_switcher( NOFORK, RUN_DIALOG );
} else if ( find_arg( argc, argv, "-snow" ) >= 0 ) {
run_switcher( NOFORK, SSH_DIALOG );
#ifdef I3
} else if ( find_arg( argc, argv, "-mnow" ) >= 0 ) {
run_switcher( NOFORK, MARK_DIALOG );
#endif
} else {
// Daemon mode, Listen to key presses..
find_arg_str( argc, argv, "-key", &( config.window_key ) );
find_arg_str( argc, argv, "-rkey",&( config.run_key ) );
find_arg_str( argc, argv, "-skey",&( config.ssh_key ) );
parse_key( config.window_key, &windows_modmask, &windows_keysym );
parse_key( config.run_key, &rundialog_modmask, &rundialog_keysym );
parse_key( config.ssh_key, &sshdialog_modmask, &sshdialog_keysym );
// bind key combos
grab_key( windows_modmask, windows_keysym );
find_arg_str( argc, argv, "-rkey",&( config.run_key ) );
parse_key( config.run_key, &rundialog_modmask, &rundialog_keysym );
grab_key( rundialog_modmask, rundialog_keysym );
find_arg_str( argc, argv, "-skey",&( config.ssh_key ) );
parse_key( config.ssh_key, &sshdialog_modmask, &sshdialog_keysym );
grab_key( sshdialog_modmask, sshdialog_keysym );
// bind key combos
#ifdef I3
find_arg_str( argc, argv, "-mkey",&( config.mark_key ) );
parse_key( config.mark_key, &markdialog_modmask, &markdialog_keysym );
grab_key( markdialog_modmask, markdialog_keysym );
#endif
XEvent ev;