Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit 2248800

Browse files
committed
Added yeahconsole*restartHidden resource option.
* if yeahconsole*restartHidden is 0: no change to behavior * if yeahconsole*restartHidden is 1: console is hidden/rolled-up on restart yeahconsole restarts on exit when yeahconsole*restart is 1. Attention is given to avoid focus stealing on restartHidden.
1 parent e45188e commit 2248800

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

yeahconsole.c

+15-4
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ char *progname, command[256];
4848
int revert_to;
4949
int screen;
5050
int opt_x, opt_width, opt_height, opt_delay, opt_bw, opt_step,
51-
height, opt_restart;
51+
height, opt_restart, opt_restart_hidden;
5252
char *opt_color;
5353
char *opt_term;
5454
KeySym opt_key;
@@ -72,7 +72,8 @@ int main(int argc, char *argv[])
7272
XEvent event;
7373
int hidden = 1;
7474
int fullscreen = 0;
75-
int i, old_height;
75+
int i;
76+
int old_height = 0;
7677
Window last_focused, current_focused;
7778

7879
/* strip the path from argv[0] if there is one */
@@ -190,10 +191,18 @@ int main(int argc, char *argv[])
190191
case UnmapNotify:
191192
if (event.xunmap.window == termwin) {
192193
if (opt_restart) {
194+
if (opt_restart_hidden) {
195+
roll(UP);
196+
hidden = 1;
197+
}
193198
init_xterm(0);
194199
XSync(dpy, False);
195-
XSetInputFocus(dpy, termwin, RevertToPointerRoot,
196-
CurrentTime);
200+
if (opt_restart_hidden && last_focused)
201+
XSetInputFocus(dpy, last_focused,
202+
RevertToPointerRoot, CurrentTime);
203+
else
204+
XSetInputFocus(dpy, termwin, RevertToPointerRoot,
205+
CurrentTime);
197206
} else {
198207
if (last_focused)
199208
XSetInputFocus(dpy, last_focused,
@@ -264,6 +273,8 @@ void get_defaults()
264273
opt_step = opt ? atoi(opt) : 1;
265274
opt = XGetDefault(dpy, progname, "restart");
266275
opt_restart = opt ? atoi(opt) : 0;
276+
opt = XGetDefault(dpy, progname, "restartHidden");
277+
opt_restart_hidden = opt ? atoi(opt) : 0;
267278
opt = XGetDefault(dpy, progname, "term");
268279
opt_term = opt ? opt : "xterm";
269280
opt = XGetDefault(dpy, progname, "toggleKey");

0 commit comments

Comments
 (0)