summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
Diffstat (limited to 'libvo')
-rw-r--r--libvo/vo_vdpau.c52
-rw-r--r--libvo/wskeys.h85
-rw-r--r--libvo/x11_common.c143
-rw-r--r--libvo/x11_common.h3
4 files changed, 102 insertions, 181 deletions
diff --git a/libvo/vo_vdpau.c b/libvo/vo_vdpau.c
index 101291a558..7b2f974ac2 100644
--- a/libvo/vo_vdpau.c
+++ b/libvo/vo_vdpau.c
@@ -460,8 +460,12 @@ static int win_x11_init_vdpau_procs(struct vo *vo)
vdp_st = vdp_device_create_x11(x11->display, x11->screen, &vc->vdp_device,
&vc->vdp_get_proc_address);
if (vdp_st != VDP_STATUS_OK) {
- mp_msg(MSGT_VO, MSGL_ERR, "[vdpau] Error when calling "
- "vdp_device_create_x11: %i\n", vdp_st);
+ if (vc->is_preempted)
+ mp_msg(MSGT_VO, MSGL_DBG2, "[vdpau] Error calling "
+ "vdp_device_create_x11 while preempted: %d\n", vdp_st);
+ else
+ mp_msg(MSGT_VO, MSGL_ERR, "[vdpau] Error when calling "
+ "vdp_device_create_x11: %d\n", vdp_st);
return -1;
}
@@ -1011,9 +1015,6 @@ static void draw_eosd(struct vo *vo)
VdpOutputSurface output_surface = vc->output_surfaces[vc->surface_num];
int i;
- if (handle_preemption(vo) < 0)
- return;
-
VdpOutputSurfaceRenderBlendState blend_state = {
.struct_version = VDP_OUTPUT_SURFACE_RENDER_BLEND_STATE_VERSION,
.blend_factor_source_color =
@@ -1291,28 +1292,23 @@ static void draw_image(struct vo *vo, mp_image_t *mpi, double pts)
struct mp_image *reserved_mpi = NULL;
struct vdpau_render_state *rndr;
- if (vc->is_preempted) {
- vo->frame_loaded = true;
- return;
- }
-
if (IMGFMT_IS_VDPAU(vc->image_format)) {
rndr = mpi->priv;
reserved_mpi = mpi;
} else if (!(mpi->flags & MP_IMGFLAG_DRAW_CALLBACK)) {
- VdpStatus vdp_st;
- void *destdata[3] = {mpi->planes[0], mpi->planes[2], mpi->planes[1]};
rndr = get_surface(vo, vc->deint_counter);
vc->deint_counter = WRAP_ADD(vc->deint_counter, 1, NUM_BUFFERED_VIDEO);
- if (vc->image_format == IMGFMT_NV12)
- destdata[1] = destdata[2];
- vdp_st =
- vdp->video_surface_put_bits_y_cb_cr(rndr->surface,
- vc->vdp_pixel_format,
- (const void *const*)destdata,
- mpi->stride); // pitch
- CHECK_ST_WARNING("Error when calling "
- "vdp_video_surface_put_bits_y_cb_cr");
+ if (handle_preemption(vo) >= 0) {
+ VdpStatus vdp_st;
+ const void *destdata[3] = {mpi->planes[0], mpi->planes[2],
+ mpi->planes[1]};
+ if (vc->image_format == IMGFMT_NV12)
+ destdata[1] = destdata[2];
+ vdp_st = vdp->video_surface_put_bits_y_cb_cr(rndr->surface,
+ vc->vdp_pixel_format, destdata, mpi->stride);
+ CHECK_ST_WARNING("Error when calling "
+ "vdp_video_surface_put_bits_y_cb_cr");
+ }
} else
// We don't support slice callbacks so this shouldn't occur -
// I think the flags test above in pointless, but I'm adding
@@ -1683,8 +1679,10 @@ static int control(struct vo *vo, uint32_t request, void *data)
case VOCTRL_DRAW_EOSD:
if (!data)
return VO_FALSE;
- generate_eosd(vo, data);
- draw_eosd(vo);
+ if (status_ok(vo)) {
+ generate_eosd(vo, data);
+ draw_eosd(vo);
+ }
return VO_TRUE;
case VOCTRL_GET_EOSD_RES: {
struct mp_eosd_res *r = data;
@@ -1696,18 +1694,22 @@ static int control(struct vo *vo, uint32_t request, void *data)
}
case VOCTRL_NEWFRAME:
vc->deint_queue_pos = next_deint_queue_pos(vo, true);
- video_to_output_surface(vo);
+ if (status_ok(vo))
+ video_to_output_surface(vo);
return true;
case VOCTRL_SKIPFRAME:
vc->deint_queue_pos = next_deint_queue_pos(vo, true);
return true;
case VOCTRL_REDRAW_FRAME:
- video_to_output_surface(vo);
+ if (status_ok(vo))
+ video_to_output_surface(vo);
return true;
case VOCTRL_RESET:
forget_frames(vo);
return true;
case VOCTRL_SCREENSHOT: {
+ if (!status_ok(vo))
+ return false;
struct voctrl_screenshot_args *args = data;
if (args->full_window)
args->out_image = get_window_screenshot(vo);
diff --git a/libvo/wskeys.h b/libvo/wskeys.h
deleted file mode 100644
index a236a9fd55..0000000000
--- a/libvo/wskeys.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * This file is part of MPlayer.
- *
- * MPlayer is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * MPlayer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef MPLAYER_WSKEYS_H
-#define MPLAYER_WSKEYS_H
-
-#define wsPause 0xff13
-#define wsUp 0xff52
-#define wsDown 0xff54
-#define wsLeft 0xff51
-#define wsRight 0xff53
-#define wsLeftCtrl 0xffe3
-#define wsRightCtrl 0xffe4
-#define wsLeftAlt 0xffe9
-#define wsRightAlt 0xff7e
-#define wsLeftShift 0xffe1
-#define wsRightShift 0xffe2
-#define wsEnter 0xff0d
-#define wsBackSpace 0xff08
-#define wsCapsLock 0xffe5
-#define wsTab 0xff09
-#define wsF1 0xffbe
-#define wsF2 0xffbf
-#define wsF3 0xffc0
-#define wsF4 0xffc1
-#define wsF5 0xffc2
-#define wsF6 0xffc3
-#define wsF7 0xffc4
-#define wsF8 0xffc5
-#define wsF9 0xffc6
-#define wsF10 0xffc7
-#define wsF11 0xffc8
-#define wsF12 0xffc9
-#define wsInsert 0xff63
-#define wsDelete 0xffff
-#define wsHome 0xff50
-#define wsEnd 0xff57
-#define wsPageUp 0xff55
-#define wsPageDown 0xff56
-#define wsNumLock 0xff7f
-#define wsEscape 0xff1b
-#define wsGrayEnter 0xff8d
-#define wsGrayPlus 0xffab
-#define wsGrayMinus 0xffad
-#define wsGrayMul 0xffaa
-#define wsGrayDiv 0xffaf
-#define wsGrayDecimal 0xffae
-#define wsGray0 0xffb0
-#define wsGray1 0xffb1
-#define wsGray2 0xffb2
-#define wsGray3 0xffb3
-#define wsGray4 0xffb4
-#define wsGray5 0xffb5
-#define wsGray6 0xffb6
-#define wsGray7 0xffb7
-#define wsGray8 0xffb8
-#define wsGray9 0xffb9
-#define wsGrayHome 0xff95
-#define wsGrayLeft 0xff96
-#define wsGrayUp 0xff97
-#define wsGrayRight 0xff98
-#define wsGrayDown 0xff99
-#define wsGrayPgUp 0xff9a
-#define wsGrayPgDn 0xff9b
-#define wsGrayEnd 0xff9c
-#define wsGray5Dup 0xff9d
-#define wsGrayInsert 0xff9e
-#define wsGrayDelete 0xff9f
-
-#endif /* MPLAYER_WSKEYS_H */
diff --git a/libvo/x11_common.c b/libvo/x11_common.c
index cdbbc213b5..a233b7f8e2 100644
--- a/libvo/x11_common.c
+++ b/libvo/x11_common.c
@@ -23,6 +23,7 @@
#include <limits.h>
#include "config.h"
+#include "bstr.h"
#include "options.h"
#include "mp_msg.h"
#include "mp_fifo.h"
@@ -45,6 +46,7 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
+#include <X11/keysymdef.h>
#ifdef CONFIG_XSS
#include <X11/extensions/scrnsaver.h>
@@ -422,6 +424,8 @@ int vo_init(struct vo *vo)
x11->screen = DefaultScreen(x11->display); // screen ID
x11->rootwin = RootWindow(x11->display, x11->screen); // root window ID
+ x11->xim = XOpenIM(x11->display, NULL, NULL, NULL);
+
init_atoms(vo->x11);
#ifdef CONFIG_XF86VM
@@ -523,6 +527,8 @@ void vo_uninit(struct vo_x11_state *x11)
"vo: x11 uninit called but X11 not initialized..\n");
} else {
mp_msg(MSGT_VO, MSGL_V, "vo: uninit ...\n");
+ if (x11->xim)
+ XCloseIM(x11->xim);
XSetErrorHandler(NULL);
XCloseDisplay(x11->display);
x11->depthonscreen = 0;
@@ -531,63 +537,52 @@ void vo_uninit(struct vo_x11_state *x11)
talloc_free(x11);
}
-#include "wskeys.h"
-
-#ifdef XF86XK_AudioPause
-static const struct mp_keymap keysym_map[] = {
- {XF86XK_MenuKB, KEY_MENU},
- {XF86XK_AudioPlay, KEY_PLAY}, {XF86XK_AudioPause, KEY_PAUSE}, {XF86XK_AudioStop, KEY_STOP},
- {XF86XK_AudioPrev, KEY_PREV}, {XF86XK_AudioNext, KEY_NEXT},
- {XF86XK_AudioMute, KEY_MUTE}, {XF86XK_AudioLowerVolume, KEY_VOLUME_DOWN}, {XF86XK_AudioRaiseVolume, KEY_VOLUME_UP},
- {0, 0}
-};
-
-static void vo_x11_putkey_ext(struct vo *vo, int keysym, int modifiers)
-{
- struct mp_fifo *f = vo->key_fifo;
- int mpkey = lookup_keymap_table(keysym_map, keysym);
- if (mpkey)
- mplayer_put_key(f, mpkey + modifiers);
-}
-#endif
-
static const struct mp_keymap keymap[] = {
// special keys
- {wsPause, KEY_PAUSE}, {wsEscape, KEY_ESC}, {wsBackSpace, KEY_BS},
- {wsTab, KEY_TAB}, {wsEnter, KEY_ENTER},
+ {XK_Pause, KEY_PAUSE}, {XK_Escape, KEY_ESC}, {XK_BackSpace, KEY_BS},
+ {XK_Tab, KEY_TAB}, {XK_Return, KEY_ENTER},
+ {XK_Menu, KEY_MENU}, {XK_Print, KEY_PRINT},
// cursor keys
- {wsLeft, KEY_LEFT}, {wsRight, KEY_RIGHT}, {wsUp, KEY_UP}, {wsDown, KEY_DOWN},
+ {XK_Left, KEY_LEFT}, {XK_Right, KEY_RIGHT}, {XK_Up, KEY_UP}, {XK_Down, KEY_DOWN},
// navigation block
- {wsInsert, KEY_INSERT}, {wsDelete, KEY_DELETE}, {wsHome, KEY_HOME}, {wsEnd, KEY_END},
- {wsPageUp, KEY_PAGE_UP}, {wsPageDown, KEY_PAGE_DOWN},
+ {XK_Insert, KEY_INSERT}, {XK_Delete, KEY_DELETE}, {XK_Home, KEY_HOME}, {XK_End, KEY_END},
+ {XK_Page_Up, KEY_PAGE_UP}, {XK_Page_Down, KEY_PAGE_DOWN},
// F-keys
- {wsF1, KEY_F+1}, {wsF2, KEY_F+2}, {wsF3, KEY_F+3}, {wsF4, KEY_F+4},
- {wsF5, KEY_F+5}, {wsF6, KEY_F+6}, {wsF7, KEY_F+7}, {wsF8, KEY_F+8},
- {wsF9, KEY_F+9}, {wsF10, KEY_F+10}, {wsF11, KEY_F+11}, {wsF12, KEY_F+12},
+ {XK_F1, KEY_F+1}, {XK_F2, KEY_F+2}, {XK_F3, KEY_F+3}, {XK_F4, KEY_F+4},
+ {XK_F5, KEY_F+5}, {XK_F6, KEY_F+6}, {XK_F7, KEY_F+7}, {XK_F8, KEY_F+8},
+ {XK_F9, KEY_F+9}, {XK_F10, KEY_F+10}, {XK_F11, KEY_F+11}, {XK_F12, KEY_F+12},
// numpad independent of numlock
- {wsGrayMinus, '-'}, {wsGrayPlus, '+'}, {wsGrayMul, '*'}, {wsGrayDiv, '/'},
- {wsGrayEnter, KEY_KPENTER},
+ {XK_KP_Subtract, '-'}, {XK_KP_Add, '+'}, {XK_KP_Multiply, '*'}, {XK_KP_Divide, '/'},
+ {XK_KP_Enter, KEY_KPENTER},
// numpad with numlock
- {wsGray0, KEY_KP0}, {wsGray1, KEY_KP1}, {wsGray2, KEY_KP2},
- {wsGray3, KEY_KP3}, {wsGray4, KEY_KP4}, {wsGray5, KEY_KP5},
- {wsGray6, KEY_KP6}, {wsGray7, KEY_KP7}, {wsGray8, KEY_KP8},
- {wsGray9, KEY_KP9}, {wsGrayDecimal, KEY_KPDEC},
+ {XK_KP_0, KEY_KP0}, {XK_KP_1, KEY_KP1}, {XK_KP_2, KEY_KP2},
+ {XK_KP_3, KEY_KP3}, {XK_KP_4, KEY_KP4}, {XK_KP_5, KEY_KP5},
+ {XK_KP_6, KEY_KP6}, {XK_KP_7, KEY_KP7}, {XK_KP_8, KEY_KP8},
+ {XK_KP_9, KEY_KP9}, {XK_KP_Decimal, KEY_KPDEC},
+ {XK_KP_Separator, KEY_KPDEC},
// numpad without numlock
- {wsGrayInsert, KEY_KPINS}, {wsGrayEnd, KEY_KP1}, {wsGrayDown, KEY_KP2},
- {wsGrayPgDn, KEY_KP3}, {wsGrayLeft, KEY_KP4}, {wsGray5Dup, KEY_KP5},
- {wsGrayRight, KEY_KP6}, {wsGrayHome, KEY_KP7}, {wsGrayUp, KEY_KP8},
- {wsGrayPgUp, KEY_KP9}, {wsGrayDelete, KEY_KPDEL},
+ {XK_KP_Insert, KEY_KPINS}, {XK_KP_End, KEY_KP1}, {XK_KP_Down, KEY_KP2},
+ {XK_KP_Page_Down, KEY_KP3}, {XK_KP_Left, KEY_KP4}, {XK_KP_Begin, KEY_KP5},
+ {XK_KP_Right, KEY_KP6}, {XK_KP_Home, KEY_KP7}, {XK_KP_Up, KEY_KP8},
+ {XK_KP_Page_Up, KEY_KP9}, {XK_KP_Delete, KEY_KPDEL},
+
+#ifdef XF86XK_AudioPause
+ {XF86XK_MenuKB, KEY_MENU},
+ {XF86XK_AudioPlay, KEY_PLAY}, {XF86XK_AudioPause, KEY_PAUSE}, {XF86XK_AudioStop, KEY_STOP},
+ {XF86XK_AudioPrev, KEY_PREV}, {XF86XK_AudioNext, KEY_NEXT},
+ {XF86XK_AudioMute, KEY_MUTE}, {XF86XK_AudioLowerVolume, KEY_VOLUME_DOWN}, {XF86XK_AudioRaiseVolume, KEY_VOLUME_UP},
+#endif
{0, 0}
};
-static void vo_x11_putkey(struct vo *vo, int key, int modifiers)
+static int vo_x11_lookupkey(int key)
{
static const char *passthrough_keys = " -+*/<>`~!@#$%^&()_{}:;\"\',.?\\|=[]";
int mpkey = 0;
@@ -600,8 +595,7 @@ static void vo_x11_putkey(struct vo *vo, int key, int modifiers)
if (!mpkey)
mpkey = lookup_keymap_table(keymap, key);
- if (mpkey)
- mplayer_put_key(vo->key_fifo, mpkey + modifiers);
+ return mpkey;
}
@@ -746,6 +740,9 @@ void vo_x11_uninit(struct vo *vo)
{
XEvent xev;
+ if (x11->xic)
+ XDestroyIC(x11->xic);
+
XUnmapWindow(x11->display, x11->window);
XSelectInput(x11->display, x11->window, StructureNotifyMask);
XDestroyWindow(x11->display, x11->window);
@@ -785,8 +782,6 @@ int vo_x11_check_events(struct vo *vo)
Display *display = vo->x11->display;
int ret = 0;
XEvent Event;
- char buf[100];
- KeySym keySym;
if (x11->vo_mouse_autohide && x11->mouse_waiting_hide &&
(GetTimerMS() - x11->mouse_timer >= 1000)) {
@@ -812,8 +807,8 @@ int vo_x11_check_events(struct vo *vo)
break;
case KeyPress:
{
- XLookupString(&Event.xkey, buf, sizeof(buf), &keySym,
- &x11->compose_status);
+ char buf[100];
+ KeySym keySym = 0;
int modifiers = 0;
if (Event.xkey.state & ShiftMask)
modifiers |= KEY_MODIFIER_SHIFT;
@@ -823,10 +818,27 @@ int vo_x11_check_events(struct vo *vo)
modifiers |= KEY_MODIFIER_ALT;
if (Event.xkey.state & Mod4Mask)
modifiers |= KEY_MODIFIER_META;
-#ifdef XF86XK_AudioPause
- vo_x11_putkey_ext(vo, keySym, modifiers);
-#endif
- vo_x11_putkey(vo, keySym, modifiers);
+ if (x11->xic) {
+ Status status;
+ int len = Xutf8LookupString(x11->xic, &Event.xkey, buf,
+ sizeof(buf), &keySym,
+ &status);
+ int mpkey = vo_x11_lookupkey(keySym);
+ if (mpkey) {
+ mplayer_put_key(vo->key_fifo, mpkey | modifiers);
+ } else if (status == XLookupChars
+ || status == XLookupBoth)
+ {
+ struct bstr t = { buf, len };
+ mplayer_put_key_utf8(vo->key_fifo, modifiers, t);
+ }
+ } else {
+ XLookupString(&Event.xkey, buf, sizeof(buf), &keySym,
+ &x11->compose_status);
+ int mpkey = vo_x11_lookupkey(keySym);
+ if (mpkey)
+ mplayer_put_key(vo->key_fifo, mpkey | modifiers);
+ }
ret |= VO_EVENT_KEYPRESS;
}
break;
@@ -993,34 +1005,18 @@ static int vo_x11_get_gnome_layer(struct vo_x11_state *x11, Window win)
return WIN_LAYER_NORMAL;
}
-// set a X text property that expects a STRING type
+// set a X text property that expects a STRING or COMPOUND_TEXT type
static void vo_x11_set_property_string(struct vo *vo, Atom name, const char *t)
{
struct vo_x11_state *x11 = vo->x11;
XTextProperty prop = {0};
- int success;
-
- success = Xutf8TextListToTextProperty(x11->display, (char **)&t, 1,
- XStringStyle, &prop);
-
- // The call can fail if the string uses characters not in the STRING
- // encoding (which is latin-1 as far as I can tell). Try COMPOUND_TEXT
- // instead. (It is possible that COMPOUND_TEXT always works, but since the
- // difference in the type used for the property is visible to the Window
- // manager and the ICCCM seems to specify STRING, we're trying to be careful
- // and try STRING first.)
- // GTK seems to follow about the same fallback mechanism.
- if (success != Success) {
- XFree(prop.value);
- prop.value = NULL;
- success = Xutf8TextListToTextProperty(x11->display, (char **)&t, 1,
- XCompoundTextStyle, &prop);
- }
- if (success == Success)
+ if (Xutf8TextListToTextProperty(x11->display, (char **)&t, 1,
+ XStdICCTextStyle, &prop) == Success)
+ {
XSetTextProperty(x11->display, x11->window, &prop, name);
-
- XFree(prop.value);
+ XFree(prop.value);
+ }
}
// set a X text property that expects a UTF8_STRING type
@@ -1144,6 +1140,11 @@ void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y,
XSetWMNormalHints(mDisplay, x11->window, &hint);
if (!vo_border) vo_x11_decoration(vo, 0);
// map window
+ x11->xic = XCreateIC(x11->xim,
+ XNInputStyle, XIMPreeditNone | XIMStatusNone,
+ XNClientWindow, x11->window,
+ XNFocusWindow, x11->window,
+ NULL);
XSelectInput(mDisplay, x11->window, NoEventMask);
vo_x11_selectinput_witherr(mDisplay, x11->window,
StructureNotifyMask | KeyPressMask | PointerMotionMask |
diff --git a/libvo/x11_common.h b/libvo/x11_common.h
index a8b13cc690..6ba2780747 100644
--- a/libvo/x11_common.h
+++ b/libvo/x11_common.h
@@ -36,6 +36,9 @@ struct vo_x11_state {
int display_is_local;
int depthonscreen;
+ XIM xim;
+ XIC xic;
+
GC vo_gc;
struct xv_ck_info_s {