static void handle_json_rpc_msg(Player *player, JSONValue *v) {
if(v->type != JSON_OBJECT) return;
-
+
JSONValue *request_id_v = json_obj_get(&v->value.object, "request_id");
JSONValue *event = NULL;
if(request_id_v && request_id_v->type == JSON_STRING) {
handle_json_rpc_event(player, v, event);
}
- json_print(v, NULL, 0);
+ //json_print(v, NULL, 0);
fflush(stdout);
}
-static void player_widget_set_size(XtPointer data, XtIntervalId *id) {
+static Boolean player_widget_set_size(XtPointer data) {
Player *player = data;
MainWindow *win = GetMainWindow();
Dimension new_width = player->width + win_width - player_width;
Dimension new_height = player->height + win_height - player_height;
+ // set window size
XtVaSetValues(win->window, XmNwidth, new_width, XmNheight, new_height, NULL);
+ // set window aspect ratio
+ XSizeHints hints;
+ hints.flags = PAspect;
+ hints.min_aspect.x = new_width;
+ hints.min_aspect.y = new_height;
+ hints.max_aspect.x = new_width;
+ hints.max_aspect.y = new_height;
+ XSetWMNormalHints(XtDisplay(win->window), XtWindow(win->window), &hints);
+
+ return 0;
}
player->height = height;
}
if(player->width > 0 && player->height > 0) {
- AppAddTimeOut(0, player_widget_set_size, player);
+ AppExecProc(player_widget_set_size, player);
}
}
PlayerEOF(p);
}
}
- } else if(!json_strcmp(event, "playback-restart")) {
+ } else if(!p->isstarted && !json_strcmp(event, "playback-restart")) {
char *cmd = "{ \"command\": [\"observe_property\", 1, \"playback-time\"] }\n"
"{ \"command\": [\"observe_property\", 1, \"eof-reached\"] }\n"
"{ \"command\": [\"get_property\", \"width\"], request_id=\"" REQ_ID_WIDTH "\" }\n"
"{ \"command\": [\"get_property\", \"height\"], request_id=\"" REQ_ID_HEIGHT "\" }\n"
"{ \"command\": [\"set_property\", \"keep-open\", true] }\n";
write(p->ipc, cmd, strlen(cmd));
+ p->isstarted = TRUE;
}
}