static void FileOpenCB(Widget w, void *udata, void *cdata);
static void ViewFullscreenCB(Widget w, void *udata, void *cdata);
+static void WindowRealized(MainWindow *win);
+
static void window_close_handler(Widget window, void *udata, void *cdata) {
WindowClosePlayer(main_window);
ApplicationExit();
}
}
+static int main_window_is_realized = 0;
+
static void resizeEH(Widget widget, XtPointer data, XEvent *event, Boolean *dispatch) {
+ if(!main_window_is_realized) {
+ if(XtIsRealized(widget)) {
+ main_window_is_realized = 1;
+ WindowRealized(data);
+ }
+ }
WindowAdjustAspectRatio(data);
}
+static void WindowRealized(MainWindow *win) {
+ char *open_file = GetOpenFileArg();
+ if(open_file) {
+ size_t len = strlen(open_file);
+ char *file = XtMalloc(len+1);
+ memcpy(file, open_file, len);
+ file[len] = 0;
+ WindowSetFile(win, file);
+ PlayerOpenFile(win);
+ CleanOpenFileArg();
+ }
+}
+
static void playerWidgetInputCB(Widget widget, XtPointer u, XtPointer c) {
MainWindow *win = u;
XmDrawingAreaCallbackStruct *cb = c;
// resize handler
XtAddEventHandler(window->window, StructureNotifyMask, False, resizeEH, window);
-
+
n = 0;
XtSetArg(args[n], XmNwidth, 360); n++;
XtSetArg(args[n], XmNheight, 220); n++;
}
}
-
+void WindowSetFile(MainWindow *win, char *file) {
+ if(win->file) {
+ XtFree(win->file);
+ }
+ win->file = file;
+}
static void filedialog_end(
Widget widget,
if(selection->value) {
XmStringGetLtoR(selection->value, XmSTRING_DEFAULT_CHARSET, &value);
if(value) {
- if(data->file) {
- XtFree(data->file);
- }
- data->file = value;
+ WindowSetFile(data, value);
// no need to free the value, because it is stored in MainWindow
PlayerOpenFile(data);