summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-03-15 22:11:31 +0100
committerwm4 <wm4@nowhere>2016-03-15 22:11:31 +0100
commit718cc27f34bd0bbaa155cb61e11179dba31cbd33 (patch)
tree47ed7bf8228e1399087acfd09ca8550826dd1c27 /video/out
parent3375d65bc5c1755a9ab0ebee137520d11261a712 (diff)
downloadmpv-718cc27f34bd0bbaa155cb61e11179dba31cbd33.tar.bz2
mpv-718cc27f34bd0bbaa155cb61e11179dba31cbd33.tar.xz
x11: move vo->input_ctx accesses to x11->input_ctx
Reduces VO access and makes the code more self-contained. (One day the windowing backend code should not access the VO anymore. We're just not quite there yet.)
Diffstat (limited to 'video/out')
-rw-r--r--video/out/x11_common.c39
-rw-r--r--video/out/x11_common.h1
2 files changed, 21 insertions, 19 deletions
diff --git a/video/out/x11_common.c b/video/out/x11_common.c
index 5033a0f691..cad53701dd 100644
--- a/video/out/x11_common.c
+++ b/video/out/x11_common.c
@@ -518,6 +518,7 @@ int vo_x11_init(struct vo *vo)
struct vo_x11_state *x11 = talloc_ptrtype(NULL, x11);
*x11 = (struct vo_x11_state){
.log = mp_log_new(x11, vo->log, "x11"),
+ .input_ctx = vo->input_ctx,
.screensaver_enabled = true,
.xrandr_event = -1,
};
@@ -709,7 +710,7 @@ void vo_x11_uninit(struct vo *vo)
if (!x11)
return;
- mp_input_put_key(vo->input_ctx, MP_INPUT_RELEASE_ALL);
+ mp_input_put_key(x11->input_ctx, MP_INPUT_RELEASE_ALL);
set_screensaver(x11, true);
@@ -849,7 +850,7 @@ static void vo_x11_dnd_handle_selection(struct vo *vo, XSelectionEvent *se)
DND_REPLACE : DND_APPEND;
// No idea if this is guaranteed to be \0-padded, so use bstr.
- success = mp_event_drop_mime_data(vo->input_ctx, "text/uri-list",
+ success = mp_event_drop_mime_data(x11->input_ctx, "text/uri-list",
(bstr){prop, nitems}, action) > 0;
XFree(prop);
}
@@ -976,17 +977,17 @@ int vo_x11_check_events(struct vo *vo)
sizeof(buf), &keySym, &status);
int mpkey = vo_x11_lookupkey(keySym);
if (mpkey) {
- mp_input_put_key(vo->input_ctx, mpkey | modifiers);
+ mp_input_put_key(x11->input_ctx, mpkey | modifiers);
} else if (status == XLookupChars || status == XLookupBoth) {
struct bstr t = { buf, len };
- mp_input_put_key_utf8(vo->input_ctx, modifiers, t);
+ mp_input_put_key_utf8(x11->input_ctx, modifiers, t);
}
} else {
XLookupString(&Event.xkey, buf, sizeof(buf), &keySym,
&x11->compose_status);
int mpkey = vo_x11_lookupkey(keySym);
if (mpkey)
- mp_input_put_key(vo->input_ctx, mpkey | modifiers);
+ mp_input_put_key(x11->input_ctx, mpkey | modifiers);
}
break;
}
@@ -996,16 +997,16 @@ int vo_x11_check_events(struct vo *vo)
case KeyRelease:
{
if (x11->no_autorepeat)
- mp_input_put_key(vo->input_ctx, MP_INPUT_RELEASE_ALL);
+ mp_input_put_key(x11->input_ctx, MP_INPUT_RELEASE_ALL);
x11->win_drag_button1_down = false;
break;
}
case MotionNotify:
if (x11->win_drag_button1_down && !x11->fs &&
- !mp_input_test_dragging(vo->input_ctx, Event.xmotion.x,
- Event.xmotion.y))
+ !mp_input_test_dragging(x11->input_ctx, Event.xmotion.x,
+ Event.xmotion.y))
{
- mp_input_put_key(vo->input_ctx, MP_INPUT_RELEASE_ALL);
+ mp_input_put_key(x11->input_ctx, MP_INPUT_RELEASE_ALL);
XUngrabPointer(x11->display, CurrentTime);
long params[5] = {
@@ -1016,8 +1017,8 @@ int vo_x11_check_events(struct vo *vo)
};
x11_send_ewmh_msg(x11, "_NET_WM_MOVERESIZE", params);
} else {
- mp_input_set_mouse_pos(vo->input_ctx, Event.xmotion.x,
- Event.xmotion.y);
+ mp_input_set_mouse_pos(x11->input_ctx, Event.xmotion.x,
+ Event.xmotion.y);
}
x11->win_drag_button1_down = false;
break;
@@ -1025,17 +1026,17 @@ int vo_x11_check_events(struct vo *vo)
if (Event.xcrossing.mode != NotifyNormal)
break;
x11->win_drag_button1_down = false;
- mp_input_put_key(vo->input_ctx, MP_KEY_MOUSE_LEAVE);
+ mp_input_put_key(x11->input_ctx, MP_KEY_MOUSE_LEAVE);
break;
case EnterNotify:
if (Event.xcrossing.mode != NotifyNormal)
break;
- mp_input_put_key(vo->input_ctx, MP_KEY_MOUSE_ENTER);
+ mp_input_put_key(x11->input_ctx, MP_KEY_MOUSE_ENTER);
break;
case ButtonPress:
if (Event.xbutton.button == 1)
x11->win_drag_button1_down = true;
- mp_input_put_key(vo->input_ctx,
+ mp_input_put_key(x11->input_ctx,
(MP_MOUSE_BTN0 + Event.xbutton.button - 1) |
get_mods(Event.xbutton.state) | MP_KEY_STATE_DOWN);
long msg[4] = {XEMBED_REQUEST_FOCUS};
@@ -1044,7 +1045,7 @@ int vo_x11_check_events(struct vo *vo)
case ButtonRelease:
if (Event.xbutton.button == 1)
x11->win_drag_button1_down = false;
- mp_input_put_key(vo->input_ctx,
+ mp_input_put_key(x11->input_ctx,
(MP_MOUSE_BTN0 + Event.xbutton.button - 1) |
get_mods(Event.xbutton.state) | MP_KEY_STATE_UP);
break;
@@ -1055,13 +1056,13 @@ int vo_x11_check_events(struct vo *vo)
break;
case DestroyNotify:
MP_WARN(x11, "Our window was destroyed, exiting\n");
- mp_input_put_key(vo->input_ctx, MP_KEY_CLOSE_WIN);
+ mp_input_put_key(x11->input_ctx, MP_KEY_CLOSE_WIN);
x11->window = 0;
break;
case ClientMessage:
if (Event.xclient.message_type == XA(x11, WM_PROTOCOLS) &&
Event.xclient.data.l[0] == XA(x11, WM_DELETE_WINDOW))
- mp_input_put_key(vo->input_ctx, MP_KEY_CLOSE_WIN);
+ mp_input_put_key(x11->input_ctx, MP_KEY_CLOSE_WIN);
vo_x11_dnd_handle_message(vo, &Event.xclient);
vo_x11_xembed_handle_message(vo, &Event.xclient);
break;
@@ -1437,9 +1438,9 @@ static void vo_x11_map_window(struct vo *vo, struct mp_rect rc)
// map window
int events = StructureNotifyMask | ExposureMask | PropertyChangeMask |
LeaveWindowMask | EnterWindowMask;
- if (mp_input_mouse_enabled(vo->input_ctx))
+ if (mp_input_mouse_enabled(x11->input_ctx))
events |= PointerMotionMask | ButtonPressMask | ButtonReleaseMask;
- if (mp_input_vo_keyboard_enabled(vo->input_ctx))
+ if (mp_input_vo_keyboard_enabled(x11->input_ctx))
events |= KeyPressMask | KeyReleaseMask;
vo_x11_selectinput_witherr(vo, x11->display, x11->window, events);
XMapWindow(x11->display, x11->window);
diff --git a/video/out/x11_common.h b/video/out/x11_common.h
index 4b122e8535..812c309afe 100644
--- a/video/out/x11_common.h
+++ b/video/out/x11_common.h
@@ -43,6 +43,7 @@ struct xrandr_display {
struct vo_x11_state {
struct mp_log *log;
+ struct input_ctx *input_ctx;
Display *display;
Window window;
Window rootwin;