i3 - improved tiling WM


Allow i3-input to be set a name with -n option.

Patch status: rejected

Patch by Harri Montonen

Long description:

i3-input prompt has hardcoded geometrical position. It may be inconvenient
for some multimonitor systems. On the other hand, prompt window can't be
easily moved, as it doesn't have a name, nor does it have any option for
one. This patch is an effort to somewhat fix that issue.

Potential problems, as I'm not qualified C programmer nor have sufficient
knowledge of X11 internals:

- WM_NAME has been used as name, although I'm not sure if it should be
  WM_CLASS or _NET_WM_NAME.
- I'm not sure about validation practises regarding kind as the argument of
  option -n.
- I'm not sure whether xcb_change_property -call should have some kind of
  assurance of succesful call (well, probably should), nor how it should be
  done.

This commit message has way more characters than actual patch, though, so
may be this is not a problem. :)

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

b/i3-input/main.c

31
@@ -316,6 +316,7 @@ int main(int argc, char *argv[]) {
32
     socket_path = getenv("I3SOCK");
33
     char *pattern = sstrdup("-misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1");
34
     int o, option_index = 0;
35
+    char *name = NULL;
36
 
37
     static struct option long_options[] = {
38
         {"socket", required_argument, 0, 's'},
39
@@ -325,11 +326,12 @@ int main(int argc, char *argv[]) {
40
         {"prefix", required_argument, 0, 'p'},
41
         {"format", required_argument, 0, 'F'},
42
         {"font", required_argument, 0, 'f'},
43
+        {"name", required_argument, 0, 'n'},
44
         {"help", no_argument, 0, 'h'},
45
         {0, 0, 0, 0}
46
     };
47
 
48
-    char *options_string = "s:p:P:f:l:F:vh";
49
+    char *options_string = "s:p:P:f:l:F:n:vh";
50
 
51
     while ((o = getopt_long(argc, argv, options_string, long_options, &option_index)) != -1) {
52
         switch (o) {
53
@@ -361,9 +363,13 @@ int main(int argc, char *argv[]) {
54
                 FREE(format);
55
                 format = strdup(optarg);
56
                 break;
57
+            case 'n':
58
+                FREE(name);
59
+                name = strdup(optarg);
60
+                break;
61
             case 'h':
62
                 printf("i3-input " I3_VERSION "\n");
63
-                printf("i3-input [-s <socket>] [-F <format>] [-l <limit>] [-P <prompt>] [-f <font>] [-v]\n");
64
+                printf("i3-input [-s <socket>] [-F <format>] [-l <limit>] [-P <prompt>] [-f <font>] [-n <name>] [-v]\n");
65
                 printf("\n");
66
                 printf("Example:\n");
67
                 printf("    i3-input -F 'workspace \"%%s\"' -P 'Switch to workspace: '\n");
68
@@ -417,7 +423,17 @@ int main(int argc, char *argv[]) {
69
             1, /* override redirect: don’t manage this window */
70
             XCB_EVENT_MASK_EXPOSURE
71
         });
72
-
73
+    /* Set window name property (if given) */
74
+    if (name != NULL)
75
+        xcb_change_property(
76
+            conn,
77
+            XCB_PROP_MODE_REPLACE,
78
+            win,
79
+            XCB_ATOM_WM_NAME,
80
+            XCB_ATOM_STRING,
81
+            8,
82
+            strlen(name),
83
+            name);
84
     /* Map the window (make it visible) */
85
     xcb_map_window(conn, win);
86