]> Dogcows Code - chaz/openbox/commitdiff
better string matching for duplicate title numbering. this will check against the...
authorDana Jansens <danakj@orodu.net>
Sun, 4 Mar 2007 07:54:21 +0000 (07:54 +0000)
committerDana Jansens <danakj@orodu.net>
Sun, 4 Mar 2007 07:54:21 +0000 (07:54 +0000)
openbox/client.c

index bb0772d722fd24a22987094448557325ccb77496..797d5b85198faaa1727925cf148efa6b9a0e37cc 100644 (file)
@@ -1577,8 +1577,21 @@ void client_update_title(ObClient *self)
         for (it = client_list; it; it = g_list_next(it))
             if (it->data != self) {
                 ObClient *c = it->data;
-                if (0 == strncmp(c->title, data, strlen(data)))
-                    nums |= 1 << c->title_count;
+
+                if (c->title_count == 1) {
+                    if (!strcmp(c->title, data))
+                        nums |= 1 << c->title_count;
+                } else {
+                    size_t len;
+                    gchar *end;
+
+                    /* find the beginning of our " - [%u]", this relies on
+                     that syntax being used */
+                    end = strrchr(c->title, '-') - 1; 
+                    len = end - c->title;
+                    if (!strncmp(c->title, data, len))
+                        nums |= 1 << c->title_count;
+                }
             }
         /* find first free number */
         for (i = 1; i <= 32; ++i)
@@ -1624,12 +1637,10 @@ no_number:
      * We don't need to check for config_title_number here since title_count
      * is not set above 1 then. */
     if (read_title && self->title_count > 1) {
-        gchar *vdata, *ndata;
-        ndata = g_strdup_printf(" - [%u]", self->title_count);
-        vdata = g_strconcat(data, ndata, NULL);
-        g_free(ndata);
+        gchar *newdata;
+        newdata = g_strdup_printf("%s - [%u]", data, self->title_count);
         g_free(data);
-        data = vdata;
+        data = newdata;
     }
 
     PROP_SETS(self->window, net_wm_visible_icon_name, data);
This page took 0.024729 seconds and 4 git commands to generate.