diff options
| author | Dana Jansens <danakj@orodu.net> | 2010-05-13 22:16:44 -0400 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2010-05-17 19:31:51 -0400 |
| commit | f307a3feabedd9bcadeaafd0fa8e1b1a60736eb2 (patch) | |
| tree | a00dea6e23e4561f2bd3cfe713c41dce14628d51 /openbox/frame.c | |
| parent | 09d1d0434ba5597fff7bea3ec4c5da88c94447e0 (diff) | |
allow multiple contexts separated by space in a mouse binding
example: context="Top Left Right Bottom"
Diffstat (limited to 'openbox/frame.c')
| -rw-r--r-- | openbox/frame.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/openbox/frame.c b/openbox/frame.c index 6c3ee6f9..571ddc04 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)) |
