summaryrefslogtreecommitdiffstats
path: root/options
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-07-12 00:12:55 +0200
committerwm4 <wm4@nowhere>2020-07-12 00:12:55 +0200
commit4a93b046e954892edf3356bcd5745c612232fe15 (patch)
tree235153a1bf0393d7a576124994a7a48f71f00574 /options
parent06033df715b433d41b1a0855cf7805ff8f66d664 (diff)
downloadmpv-4a93b046e954892edf3356bcd5745c612232fe15.tar.bz2
mpv-4a93b046e954892edf3356bcd5745c612232fe15.tar.xz
x11: add option to make window appear on a specific workspace
Mess this into the --geometry option, because I like to be irresponsible. I considered adding a separate option, but at least this allows me to defer the question how the hell this should work as property (geometry simply and inherently does not). Tested on IceWM only. Option equality test and string output not tested.
Diffstat (limited to 'options')
-rw-r--r--options/m_option.c15
-rw-r--r--options/m_option.h1
2 files changed, 14 insertions, 2 deletions
diff --git a/options/m_option.c b/options/m_option.c
index 51e3c38801..9b0fd82779 100644
--- a/options/m_option.c
+++ b/options/m_option.c
@@ -2145,7 +2145,7 @@ static bool parse_geometry_str(struct m_geometry *gm, bstr s)
if (s.len == 0)
return true;
// Approximate grammar:
- // [[W][xH]][{+-}X{+-}Y] | [X:Y]
+ // [[W][xH]][{+-}X{+-}Y][/WS] | [X:Y]
// (meaning: [optional] {one character of} one|alternative)
// Every number can be followed by '%'
int num;
@@ -2181,6 +2181,14 @@ static bool parse_geometry_str(struct m_geometry *gm, bstr s)
READ_SIGN(y_sign);
READ_NUM(y, y_per);
}
+ if (bstr_eatstart0(&s, "/")) {
+ bstr rest;
+ long long v = bstrtoll(s, &rest, 10);
+ if (s.len == rest.len || v < 1 || v > INT_MAX)
+ goto error;
+ s = rest;
+ gm->ws = v;
+ }
} else {
gm->xy_valid = true;
READ_NUM(x, x_per);
@@ -2217,6 +2225,8 @@ static char *print_geometry(const m_option_t *opt, const void *val)
res = talloc_asprintf_append(res, gm->y_sign ? "-" : "+");
APPEND_PER(y, y_per);
}
+ if (gm->ws > 0)
+ res = talloc_asprintf_append(res, "/%d", gm->ws);
}
return res;
}
@@ -2301,7 +2311,8 @@ static bool geometry_equal(const m_option_t *opt, void *a, void *b)
ga->xy_valid == gb->xy_valid && ga->wh_valid == gb->wh_valid &&
ga->w_per == gb->w_per && ga->h_per == gb->h_per &&
ga->x_per == gb->x_per && ga->y_per == gb->y_per &&
- ga->x_sign == gb->x_sign && ga->y_sign == gb->y_sign;
+ ga->x_sign == gb->x_sign && ga->y_sign == gb->y_sign &&
+ ga->ws == gb->ws;
}
const m_option_type_t m_option_type_geometry = {
diff --git a/options/m_option.h b/options/m_option.h
index f51ca95fa8..25dc212482 100644
--- a/options/m_option.h
+++ b/options/m_option.h
@@ -98,6 +98,7 @@ struct m_geometry {
bool xy_valid : 1, wh_valid : 1;
bool w_per : 1, h_per : 1;
bool x_sign : 1, y_sign : 1, x_per : 1, y_per : 1;
+ int ws; // workspace; valid if !=0
};
void m_geometry_apply(int *xpos, int *ypos, int *widw, int *widh,