mirror of
https://github.com/mpv-player/mpv
synced 2024-11-14 22:48:35 +01:00
x11_common: don't use vo->opts directly
Use x11->opts instead of vo->opts. This doesn't matter currently, and x11->opts is actually set to vo->opts. However, there's a chance that either option access changes, or that the way backends integrate with struct vo changes. This is just a preemptive change to make this less of a mess, and it's generally a good idea to reduce accesses to struct vo anyway.
This commit is contained in:
parent
7c6570402b
commit
db3b5c9309
@ -353,7 +353,7 @@ static int vo_wm_detect(struct vo *vo)
|
||||
&nitems);
|
||||
if (args) {
|
||||
MP_DBG(x11, "Detected wm supports NetWM.\n");
|
||||
if (vo->opts->x11_netwm >= 0) {
|
||||
if (x11->opts->x11_netwm >= 0) {
|
||||
for (i = 0; i < nitems; i++)
|
||||
wm |= net_wm_support_state_test(vo->x11, args[i]);
|
||||
} else {
|
||||
@ -364,7 +364,7 @@ static int vo_wm_detect(struct vo *vo)
|
||||
|
||||
if (wm == 0)
|
||||
MP_DBG(x11, "Unknown wm type...\n");
|
||||
if (vo->opts->x11_netwm > 0 && !(wm & vo_wm_FULLSCREEN)) {
|
||||
if (x11->opts->x11_netwm > 0 && !(wm & vo_wm_FULLSCREEN)) {
|
||||
MP_WARN(x11, "Forcing NetWM FULLSCREEN support.\n");
|
||||
wm |= vo_wm_FULLSCREEN;
|
||||
}
|
||||
@ -459,8 +459,8 @@ static void xrandr_read(struct vo_x11_state *x11)
|
||||
|
||||
static void vo_x11_update_screeninfo(struct vo *vo)
|
||||
{
|
||||
struct mp_vo_opts *opts = vo->opts;
|
||||
struct vo_x11_state *x11 = vo->x11;
|
||||
struct mp_vo_opts *opts = x11->opts;
|
||||
bool all_screens = opts->fullscreen && opts->fsscreen_id == -2;
|
||||
x11->screenrc = (struct mp_rect){.x1 = x11->ws_width, .y1 = x11->ws_height};
|
||||
if (opts->screen_id >= -1 && XineramaIsActive(x11->display) && !all_screens)
|
||||
@ -546,7 +546,6 @@ static void *screensaver_thread(void *arg)
|
||||
|
||||
int vo_x11_init(struct vo *vo)
|
||||
{
|
||||
struct mp_vo_opts *opts = vo->opts;
|
||||
char *dispName;
|
||||
|
||||
assert(!vo->x11);
|
||||
@ -561,6 +560,7 @@ int vo_x11_init(struct vo *vo)
|
||||
.xrandr_event = -1,
|
||||
.wakeup_pipe = {-1, -1},
|
||||
.dpi_scale = 1,
|
||||
.opts = vo->opts,
|
||||
};
|
||||
vo->x11 = x11;
|
||||
|
||||
@ -587,10 +587,10 @@ int vo_x11_init(struct vo *vo)
|
||||
x11->screen = DefaultScreen(x11->display); // screen ID
|
||||
x11->rootwin = RootWindow(x11->display, x11->screen); // root window ID
|
||||
|
||||
if (vo->opts->WinID >= 0)
|
||||
x11->parent = vo->opts->WinID ? vo->opts->WinID : x11->rootwin;
|
||||
if (x11->opts->WinID >= 0)
|
||||
x11->parent = x11->opts->WinID ? x11->opts->WinID : x11->rootwin;
|
||||
|
||||
if (!opts->native_keyrepeat) {
|
||||
if (!x11->opts->native_keyrepeat) {
|
||||
Bool ok = False;
|
||||
XkbSetDetectableAutoRepeat(x11->display, True, &ok);
|
||||
x11->no_autorepeat = ok;
|
||||
@ -750,8 +750,8 @@ static void vo_x11_decoration(struct vo *vo, bool d)
|
||||
|
||||
static void vo_x11_classhint(struct vo *vo, Window window, const char *name)
|
||||
{
|
||||
struct mp_vo_opts *opts = vo->opts;
|
||||
struct vo_x11_state *x11 = vo->x11;
|
||||
struct mp_vo_opts *opts = x11->opts;
|
||||
XClassHint wmClass;
|
||||
long pid = getpid();
|
||||
|
||||
@ -999,7 +999,7 @@ static void vo_x11_update_composition_hint(struct vo *vo)
|
||||
struct vo_x11_state *x11 = vo->x11;
|
||||
|
||||
long hint = 0;
|
||||
switch (vo->opts->x11_bypass_compositor) {
|
||||
switch (x11->opts->x11_bypass_compositor) {
|
||||
case 0: hint = 0; break; // leave default
|
||||
case 1: hint = 1; break; // always bypass
|
||||
case 2: hint = x11->fs ? 1 : 0; break; // bypass in FS
|
||||
@ -1033,10 +1033,10 @@ static void vo_x11_check_net_wm_state_fullscreen_change(struct vo *vo)
|
||||
XFree(elems);
|
||||
}
|
||||
|
||||
if ((vo->opts->fullscreen && !is_fullscreen) ||
|
||||
(!vo->opts->fullscreen && is_fullscreen))
|
||||
if ((x11->opts->fullscreen && !is_fullscreen) ||
|
||||
(!x11->opts->fullscreen && is_fullscreen))
|
||||
{
|
||||
vo->opts->fullscreen = is_fullscreen;
|
||||
x11->opts->fullscreen = is_fullscreen;
|
||||
x11->fs = is_fullscreen;
|
||||
x11->pending_vo_events |= VO_EVENT_FULLSCREEN_STATE;
|
||||
|
||||
@ -1236,8 +1236,8 @@ void vo_x11_check_events(struct vo *vo)
|
||||
|
||||
static void vo_x11_sizehint(struct vo *vo, struct mp_rect rc, bool override_pos)
|
||||
{
|
||||
struct mp_vo_opts *opts = vo->opts;
|
||||
struct vo_x11_state *x11 = vo->x11;
|
||||
struct mp_vo_opts *opts = x11->opts;
|
||||
|
||||
if (!x11->window || x11->parent)
|
||||
return;
|
||||
@ -1469,9 +1469,9 @@ static void vo_x11_map_window(struct vo *vo, struct mp_rect rc)
|
||||
struct vo_x11_state *x11 = vo->x11;
|
||||
|
||||
vo_x11_move_resize(vo, true, true, rc);
|
||||
vo_x11_decoration(vo, vo->opts->border);
|
||||
vo_x11_decoration(vo, x11->opts->border);
|
||||
|
||||
if (vo->opts->fullscreen && (x11->wm_type & vo_wm_FULLSCREEN)) {
|
||||
if (x11->opts->fullscreen && (x11->wm_type & vo_wm_FULLSCREEN)) {
|
||||
Atom state = XA(x11, _NET_WM_STATE_FULLSCREEN);
|
||||
XChangeProperty(x11->display, x11->window, XA(x11, _NET_WM_STATE), XA_ATOM,
|
||||
32, PropModeAppend, (unsigned char *)&state, 1);
|
||||
@ -1481,11 +1481,11 @@ static void vo_x11_map_window(struct vo *vo, struct mp_rect rc)
|
||||
x11->pos_changed_during_fs = true;
|
||||
}
|
||||
|
||||
if (vo->opts->fsscreen_id != -1) {
|
||||
if (x11->opts->fsscreen_id != -1) {
|
||||
long params[5] = {0};
|
||||
if (vo->opts->fsscreen_id >= 0) {
|
||||
if (x11->opts->fsscreen_id >= 0) {
|
||||
for (int n = 0; n < 4; n++)
|
||||
params[n] = vo->opts->fsscreen_id;
|
||||
params[n] = x11->opts->fsscreen_id;
|
||||
} else {
|
||||
vo_x11_get_bounding_monitors(x11, ¶ms[0]);
|
||||
}
|
||||
@ -1493,7 +1493,7 @@ static void vo_x11_map_window(struct vo *vo, struct mp_rect rc)
|
||||
x11_send_ewmh_msg(x11, "_NET_WM_FULLSCREEN_MONITORS", params);
|
||||
}
|
||||
|
||||
if (vo->opts->all_workspaces) {
|
||||
if (x11->opts->all_workspaces) {
|
||||
long v = 0xFFFFFFFF;
|
||||
XChangeProperty(x11->display, x11->window, XA(x11, _NET_WM_DESKTOP),
|
||||
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&v, 1);
|
||||
@ -1511,7 +1511,7 @@ static void vo_x11_map_window(struct vo *vo, struct mp_rect rc)
|
||||
vo_x11_selectinput_witherr(vo, x11->display, x11->window, events);
|
||||
XMapWindow(x11->display, x11->window);
|
||||
|
||||
if (vo->opts->fullscreen && (x11->wm_type & vo_wm_FULLSCREEN))
|
||||
if (x11->opts->fullscreen && (x11->wm_type & vo_wm_FULLSCREEN))
|
||||
x11_set_ewmh_state(x11, "_NET_WM_STATE_FULLSCREEN", 1);
|
||||
|
||||
vo_x11_xembed_update(x11, XEMBED_MAPPED);
|
||||
@ -1519,8 +1519,8 @@ static void vo_x11_map_window(struct vo *vo, struct mp_rect rc)
|
||||
|
||||
static void vo_x11_highlevel_resize(struct vo *vo, struct mp_rect rc)
|
||||
{
|
||||
struct mp_vo_opts *opts = vo->opts;
|
||||
struct vo_x11_state *x11 = vo->x11;
|
||||
struct mp_vo_opts *opts = x11->opts;
|
||||
|
||||
bool reset_pos = opts->force_window_position;
|
||||
if (reset_pos) {
|
||||
@ -1586,8 +1586,8 @@ bool vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis,
|
||||
// Resize the window (e.g. new file, or video resolution change)
|
||||
void vo_x11_config_vo_window(struct vo *vo)
|
||||
{
|
||||
struct mp_vo_opts *opts = vo->opts;
|
||||
struct vo_x11_state *x11 = vo->x11;
|
||||
struct mp_vo_opts *opts = x11->opts;
|
||||
|
||||
assert(x11->window);
|
||||
|
||||
@ -1724,8 +1724,8 @@ static void vo_x11_update_geometry(struct vo *vo)
|
||||
|
||||
static void vo_x11_fullscreen(struct vo *vo)
|
||||
{
|
||||
struct mp_vo_opts *opts = vo->opts;
|
||||
struct vo_x11_state *x11 = vo->x11;
|
||||
struct mp_vo_opts *opts = x11->opts;
|
||||
|
||||
if (opts->fullscreen == x11->fs)
|
||||
return;
|
||||
@ -1783,8 +1783,8 @@ static void vo_x11_fullscreen(struct vo *vo)
|
||||
|
||||
int vo_x11_control(struct vo *vo, int *events, int request, void *arg)
|
||||
{
|
||||
struct mp_vo_opts *opts = vo->opts;
|
||||
struct vo_x11_state *x11 = vo->x11;
|
||||
struct mp_vo_opts *opts = x11->opts;
|
||||
switch (request) {
|
||||
case VOCTRL_CHECK_EVENTS:
|
||||
vo_x11_check_events(vo);
|
||||
@ -1801,7 +1801,7 @@ int vo_x11_control(struct vo *vo, int *events, int request, void *arg)
|
||||
vo_x11_setlayer(vo, opts->ontop);
|
||||
return VO_TRUE;
|
||||
case VOCTRL_BORDER:
|
||||
vo_x11_decoration(vo, vo->opts->border);
|
||||
vo_x11_decoration(vo, opts->border);
|
||||
return VO_TRUE;
|
||||
case VOCTRL_ALL_WORKSPACES: {
|
||||
long params[5] = {0xFFFFFFFF, 1};
|
||||
|
@ -50,6 +50,7 @@ struct xrandr_display {
|
||||
struct vo_x11_state {
|
||||
struct mp_log *log;
|
||||
struct input_ctx *input_ctx;
|
||||
struct mp_vo_opts *opts;
|
||||
Display *display;
|
||||
int event_fd;
|
||||
int wakeup_pipe[2];
|
||||
|
Loading…
Reference in New Issue
Block a user