i3 - improved tiling WM


Implemented configurable scratchpad size.

Patch status: rejected

Patch by Matthias Fulz

To apply this patch, use:
curl http://cr.i3wm.org/patch/639/raw.patch | git am

b/include/config.h

17
@@ -183,6 +183,10 @@ struct Config {
18
     int32_t floating_minimum_width;
19
     int32_t floating_minimum_height;
20
 
21
+    /** Scratchpad size in percent of the size of the output screen */
22
+    float scratchpad_width_percent;
23
+    float scratchpad_height_percent;
24
+
25
     /* Color codes are stored here */
26
     struct config_client {
27
         uint32_t background;

b/parser-specs/config.spec

32
@@ -47,6 +47,8 @@ state INITIAL:
33
       -> COLOR_SINGLE
34
   colorclass = 'client.focused_inactive', 'client.focused', 'client.unfocused', 'client.urgent'
35
       -> COLOR_BORDER
36
+  'scratchpad_width_percent'               -> SCRATCHPAD_WIDTH_PERCENT
37
+  'scratchpad_height_percent'              -> SCRATCHPAD_HEIGHT_PERCENT
38
 
39
 # We ignore comments and 'set' lines (variables).
40
 state IGNORE_LINE:
41
@@ -474,3 +476,13 @@ state BAR_COLORS_TEXT:
42
       -> call cfg_bar_color($colorclass, $border, $background, NULL); BAR_COLORS
43
   text = word
44
       -> call cfg_bar_color($colorclass, $border, $background, $text); BAR_COLORS
45
+
46
+# scratchpad width in percent of output screen
47
+state SCRATCHPAD_WIDTH_PERCENT:
48
+  width = number
49
+      -> call cfg_scratchpad_width_percent(&width)
50
+
51
+state SCRATCHPAD_HEIGHT_PERCENT:
52
+  height = number
53
+      -> call cfg_scratchpad_height_percent(&height)
54
+

b/src/config.c

59
@@ -258,6 +258,10 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath,
60
     /* Set default_orientation to NO_ORIENTATION for auto orientation. */
61
     config.default_orientation = NO_ORIENTATION;
62
 
63
+    /* Set defualt scratchpad size */
64
+    config.scratchpad_width_percent = 0.5;
65
+    config.scratchpad_height_percent = 0.75;
66
+
67
     /* Set default urgency reset delay to 500ms */
68
     if (config.workspace_urgency_timer == 0)
69
         config.workspace_urgency_timer = 0.5;

b/src/config_directives.c

74
@@ -394,6 +394,24 @@ CFGFUN(color, const char *colorclass, const char *border, const char *background
75
 #undef APPLY_COLORS
76
 }
77
 
78
+CFGFUN(scratchpad_width_percent, const long width) {
79
+    config.scratchpad_width_percent = width * 0.01;
80
+    // not sure, shall we check the size?
81
+    if(config.scratchpad_width_percent > 1.0)
82
+        config.scratchpad_width_percent = 1.0;
83
+    else if(config.scratchpad_width_percent < 0.05)
84
+        config.scratchpad_width_percent = 0.05;
85
+}
86
+
87
+CFGFUN(scratchpad_height_percent, const long height) {
88
+    config.scratchpad_height_percent = height * 0.01;
89
+    // not sure, shall we check the size?
90
+    if(config.scratchpad_height_percent > 1.0)
91
+        config.scratchpad_height_percent = 1.0;
92
+    else if(config.scratchpad_height_percent < 0.05)
93
+        config.scratchpad_height_percent = 0.05;
94
+}
95
+
96
 CFGFUN(assign, const char *workspace) {
97
     if (match_is_empty(current_match)) {
98
         ELOG("Match is empty, ignoring this assignment\n");

b/src/scratchpad.c

103
@@ -195,8 +195,8 @@ void scratchpad_show(Con *con) {
104
     if (con->scratchpad_state == SCRATCHPAD_FRESH) {
105
         DLOG("Adjusting size of this window.\n");
106
         Con *output = con_get_output(con);
107
-        con->rect.width = output->rect.width * 0.5;
108
-        con->rect.height = output->rect.height * 0.75;
109
+        con->rect.width = output->rect.width * config.scratchpad_width_percent;
110
+        con->rect.height = output->rect.height * config.scratchpad_height_percent;
111
         floating_check_size(con);
112
         con->rect.x = output->rect.x +
113
                       ((output->rect.width / 2.0) - (con->rect.width / 2.0));