X-Git-Url: https://develop.uap-core.de/gitweb/uwplayer.git/blobdiff_plain/547b5816f07b91c51ecc65a4fdd87b8378c7be95..f2c881b827db459ee641c90bcfe4ef9e1ed25c0e:/application/player.c diff --git a/application/player.c b/application/player.c index 381132e..9e65410 100644 --- a/application/player.c +++ b/application/player.c @@ -39,6 +39,7 @@ #include #include "json.h" +#include "settings.h" extern char **environ; @@ -121,7 +122,11 @@ static int start_player_process(Player *player, MainWindow *win) { return 1; } - char *player_bin = "/usr/local/bin/mpv"; // TODO: get bin from settings + char *player_bin = SettingsGetPlayerBin(); + if(!player_bin) { + fprintf(stderr, "No mpv binary available\n"); + return 1; + } // -wid parameter value for embedding the player in the player_widget Window wid = XtWindow(win->player_widget); @@ -394,6 +399,23 @@ static void handle_json_rpc_reqid(Player *player, JSONValue *v, int reqid) { } } +static Boolean get_player_window(XtPointer data) { + Player *p = data; + MainWindow *win = GetMainWindow(); + + Widget player_wid = win->player_widget; + Window root, parent; + Window *child; + unsigned int nchild; + XQueryTree(XtDisplay(player_wid), XtWindow(player_wid), &root, &parent, &child, &nchild); + if(nchild > 0) { + p->window = child[0]; + XFree(child); + } + + return 0; +} + static void handle_json_rpc_event(Player *p, JSONValue *v, JSONValue *event) { if(!json_strcmp(event, "property-change")) { JSONValue *name = json_obj_get(&v->value.object, "name"); @@ -411,6 +433,8 @@ static void handle_json_rpc_event(Player *p, JSONValue *v, JSONValue *event) { "{ \"command\": [\"set_property\", \"keep-open\", true] }\n"; write(p->ipc, cmd, strlen(cmd)); p->isstarted = TRUE; + + AppExecProc(get_player_window, p); } } @@ -510,34 +534,5 @@ void PlayerEOF(Player *p) { } void PlayerHandleInput(MainWindow *win, Player *p, XmDrawingAreaCallbackStruct *cb) { - if(cb->event->type == KeyPress) { - XKeyEvent *xkey = &cb->event->xkey; - - static XComposeStatus compose = {NULL, 0}; - char chars[8]; - KeySym keysym; - int nchars; - - char keystr[64]; - keystr[0] = 0; - - nchars = XLookupString(xkey, chars, 8, &keysym, &compose); - if(nchars == 1) { - if(chars[0] >= 'a' && chars[0] <= 'z') { - keystr[0] = chars[0]; - keystr[1] = 0; - } else if(chars[0] == ' ') { - memcpy(keystr, "space", 6); - } - } - - if(keystr[0] != 0) { - char cmdbuf[STR_BUFSIZE]; - if(snprintf(cmdbuf, STR_BUFSIZE, "{ \"command\": [\"keypress\", \"%s\"] }\n", keystr) >= STR_BUFSIZE) { - // error: buffer to small - return; - } - write(p->ipc, cmdbuf, strlen(cmdbuf)); - } - } + }