aboutsummaryrefslogtreecommitdiffstats
path: root/community/yeahconsole/restarthidden.patch
blob: 42c82d0487b44fa4b6fa77850fe35b1ecccdd60e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Based on https://github.com/rduplain/yeahconsole/commit/22488002357cda40ddcc67df695f64f5b06a44a6

--- a/yeahconsole.c
+++ b/yeahconsole.c
@@ -48,7 +48,7 @@ char *progname, command[256];
 int revert_to;
 int screen;
 int opt_x, opt_width, opt_height, opt_delay, opt_bw, opt_step,
-    height, opt_restart;
+  height, opt_restart, opt_restart_hidden;
 char *opt_color;
 char *opt_term;
 KeySym opt_key;
@@ -72,7 +72,8 @@ int main(int argc, char *argv[])
     XEvent event;
     int hidden = 1;
     int fullscreen = 0;
-    int i, old_height;
+    int i;
+    int old_height = 0;
     Window last_focused, current_focused;
 	
     /* strip the path from argv[0] if there is one */
@@ -190,10 +191,18 @@ int main(int argc, char *argv[])
 	case UnmapNotify:
 	    if (event.xunmap.window == termwin) {
 		if (opt_restart) {
+                    if (opt_restart_hidden) {
+                        roll(UP);
+                        hidden = 1;
+                    }
 		    init_xterm(0);
 		    XSync(dpy, False);
-		    XSetInputFocus(dpy, termwin, RevertToPointerRoot,
-				   CurrentTime);
+                    if (opt_restart_hidden && last_focused)
+                        XSetInputFocus(dpy, last_focused,
+                                       RevertToPointerRoot, CurrentTime);
+                    else
+                        XSetInputFocus(dpy, termwin, RevertToPointerRoot,
+                                       CurrentTime);
 		} else {
 		    if (last_focused)
 			XSetInputFocus(dpy, last_focused,
@@ -264,6 +273,8 @@ void get_defaults()
     opt_step = opt ? atoi(opt) : 1;
     opt = XGetDefault(dpy, progname, "restart");
     opt_restart = opt ? atoi(opt) : 0;
+    opt = XGetDefault(dpy, progname, "restartHidden");
+    opt_restart_hidden = opt ? atoi(opt) : 0;
     opt = XGetDefault(dpy, progname, "term");
     opt_term = opt ? opt : "xterm";
     opt = XGetDefault(dpy, progname, "toggleKey");