X-Git-Url: http://git.openbox.org/?p=dana%2Fopenbox.git;a=blobdiff_plain;f=openbox%2Fframe.c;h=571ddc041234d21658348cc3a0ae43f7b8b35cca;hp=6c3ee6f948c6ce0ca95a3a6b7c8f8a510e7046d6;hb=f307a3feabedd9bcadeaafd0fa8e1b1a60736eb2;hpb=09d1d0434ba5597fff7bea3ec4c5da88c94447e0 diff --git a/openbox/frame.c b/openbox/frame.c index 6c3ee6f..571ddc0 100644 --- a/openbox/frame.c +++ b/openbox/frame.c @@ -1281,6 +1281,50 @@ static void layout_title(ObFrame *self) XUnmapWindow(obt_display, self->label); } +gboolean frame_next_context_from_string(gchar *names, ObFrameContext *cx) +{ + gchar *p, *n; + + if (!*names) /* empty string */ + return FALSE; + + /* find the first space */ + for (p = names; *p; p = g_utf8_next_char(p)) { + const gunichar c = g_utf8_get_char(p); + if (g_unichar_isspace(c)) break; + } + + if (p == names) { + /* leading spaces in the string */ + n = g_utf8_next_char(names); + if (!frame_next_context_from_string(n, cx)) + return FALSE; + } else { + n = p; + if (*p) { + /* delete the space with null zero(s) */ + while (n < g_utf8_next_char(p)) + *(n++) = '\0'; + } + + *cx = frame_context_from_string(names); + + /* find the next non-space */ + for (; *n; n = g_utf8_next_char(n)) { + const gunichar c = g_utf8_get_char(n); + if (!g_unichar_isspace(c)) break; + } + } + + /* delete everything we just read (copy everything at n to the start of + the string */ + for (p = names; *n; ++p, ++n) + *p = *n; + *p = *n; + + return TRUE; +} + ObFrameContext frame_context_from_string(const gchar *name) { if (!g_ascii_strcasecmp("Desktop", name))