i3 - improved tiling WM


Give layout enum a name: layout_t

Patch status: merged

Patch by Diego Ongaro

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

b/include/con.h

18
@@ -275,7 +275,7 @@ void con_set_border_style(Con *con, int border_style, int border_width);
19
  * new split container before).
20
  *
21
  */
22
-void con_set_layout(Con *con, int layout);
23
+void con_set_layout(Con *con, layout_t layout);
24
 
25
 /**
26
  * This function toggles the layout of a given container. toggle_mode can be

b/include/config.h

31
@@ -95,7 +95,7 @@ struct Config {
32
     char *ipc_socket_path;
33
     const char *restart_state_path;
34
 
35
-    int default_layout;
36
+    layout_t default_layout;
37
     int container_stack_limit;
38
     int container_stack_limit_value;
39
     int default_border_width;

b/include/data.h

44
@@ -80,6 +80,19 @@ enum {
45
 };
46
 
47
 /**
48
+ * Container layouts. See Con::layout.
49
+ */
50
+typedef enum {
51
+    L_DEFAULT = 0,
52
+    L_STACKED = 1,
53
+    L_TABBED = 2,
54
+    L_DOCKAREA = 3,
55
+    L_OUTPUT = 4,
56
+    L_SPLITV = 5,
57
+    L_SPLITH = 6
58
+} layout_t;
59
+
60
+/**
61
  * Stores a rectangle, for example the size of a window, the child window etc.
62
  * It needs to be packed so that the compiler will not add any padding bytes.
63
  * (it is used in src/ewmh.c for example)
64
@@ -531,15 +544,7 @@ struct Con {
65
      * parent and opening new containers). Instead, it stores the requested
66
      * layout in workspace_layout and creates a new split container with that
67
      * layout whenever a new container is attached to the workspace. */
68
-    enum {
69
-        L_DEFAULT = 0,
70
-        L_STACKED = 1,
71
-        L_TABBED = 2,
72
-        L_DOCKAREA = 3,
73
-        L_OUTPUT = 4,
74
-        L_SPLITV = 5,
75
-        L_SPLITH = 6
76
-    } layout, last_split_layout, workspace_layout;
77
+    layout_t layout, last_split_layout, workspace_layout;
78
     border_style_t border_style;
79
     /** floating? (= not in tiling layout) This cannot be simply a bool
80
      * because we want to keep track of whether the status was set by the

b/src/commands.c

85
@@ -1547,7 +1547,7 @@ void cmd_layout(I3_CMD, char *layout_str) {
86
     if (strcmp(layout_str, "stacking") == 0)
87
         layout_str = "stacked";
88
     owindow *current;
89
-    int layout;
90
+    layout_t layout;
91
     /* default is a special case which will be handled in con_set_layout(). */
92
     if (strcmp(layout_str, "default") == 0)
93
         layout = L_DEFAULT;

b/src/con.c

98
@@ -1209,7 +1209,7 @@ void con_set_border_style(Con *con, int border_style, int border_width) {
99
  * new split container before).
100
  *
101
  */
102
-void con_set_layout(Con *con, int layout) {
103
+void con_set_layout(Con *con, layout_t layout) {
104
     DLOG("con_set_layout(%p, %d), con->type = %d\n",
105
          con, layout, con->type);
106
 

b/src/handlers.c

111
@@ -158,7 +158,7 @@ static void handle_enter_notify(xcb_enter_notify_event_t *event) {
112
     }
113
 
114
     /* see if the user entered the window on a certain window decoration */
115
-    int layout = (enter_child ? con->parent->layout : con->layout);
116
+    layout_t layout = (enter_child ? con->parent->layout : con->layout);
117
     if (layout == L_DEFAULT) {
118
         Con *child;
119
         TAILQ_FOREACH(child, &(con->nodes_head), nodes)