mirror of
https://github.com/mpv-player/mpv
synced 2025-02-06 07:01:45 +00:00
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.
This commit is contained in:
parent
06033df715
commit
4a93b046e9
@ -2936,7 +2936,7 @@ Window
|
||||
(X11 only)
|
||||
Show the video window on all virtual desktops.
|
||||
|
||||
``--geometry=<[W[xH]][+-x+-y]>``, ``--geometry=<x:y>``
|
||||
``--geometry=<[W[xH]][+-x+-y][/WS]>``, ``--geometry=<x:y>``
|
||||
Adjust the initial window position or size. ``W`` and ``H`` set the window
|
||||
size in pixels. ``x`` and ``y`` set the window position, measured in pixels
|
||||
from the top-left corner of the screen to the top-left corner of the image
|
||||
@ -2945,7 +2945,9 @@ Window
|
||||
Positions are specified similar to the standard X11 ``--geometry`` option
|
||||
format, in which e.g. +10-50 means "place 10 pixels from the left border and
|
||||
50 pixels from the lower border" and "--20+-10" means "place 20 pixels
|
||||
beyond the right and 10 pixels beyond the top border".
|
||||
beyond the right and 10 pixels beyond the top border". A trailing ``/``
|
||||
followed by an integer denotes on which workspace (virtual desktop) the
|
||||
window should appear (X11 only).
|
||||
|
||||
If an external window is specified using the ``--wid`` option, this
|
||||
option is ignored.
|
||||
@ -2982,9 +2984,10 @@ Window
|
||||
Forces the window width and height to half the screen width and
|
||||
height. Will show black borders to compensate for the video aspect
|
||||
ratio (with most VOs and without ``--no-keepaspect``).
|
||||
``50%+10+10``
|
||||
``50%+10+10/2``
|
||||
Sets the window to half the screen widths, and positions it 10
|
||||
pixels below/left of the top left corner of the screen.
|
||||
pixels below/left of the top left corner of the screen, on the
|
||||
second workspace.
|
||||
|
||||
See also ``--autofit`` and ``--autofit-larger`` for fitting the window into
|
||||
a given size without changing aspect ratio.
|
||||
|
@ -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 = {
|
||||
|
@ -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,
|
||||
|
@ -1498,8 +1498,9 @@ static void vo_x11_map_window(struct vo *vo, struct mp_rect rc)
|
||||
x11_send_ewmh_msg(x11, "_NET_WM_FULLSCREEN_MONITORS", params);
|
||||
}
|
||||
|
||||
if (x11->opts->all_workspaces) {
|
||||
long v = 0xFFFFFFFF;
|
||||
if (x11->opts->all_workspaces || x11->opts->geometry.ws > 0) {
|
||||
long v = x11->opts->all_workspaces
|
||||
? 0xFFFFFFFF : x11->opts->geometry.ws - 1;
|
||||
XChangeProperty(x11->display, x11->window, XA(x11, _NET_WM_DESKTOP),
|
||||
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&v, 1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user