set window size after a video is opened
[uwplayer.git] / application / main.c
index 8a43d19..55a9d4f 100644 (file)
@@ -36,6 +36,7 @@
 
 static XtAppContext app;
 static Display *display;
+static Widget toplevel_window;
 
 static String fallback[] = {
         "*renderTable: rt",
@@ -75,7 +76,7 @@ int main(int argc, char** argv) {
     XtSetLanguageProc(NULL, langProc, NULL);
     app = XtCreateApplicationContext();
     XtAppSetFallbackResources(app, fallback);
-    
+       
     display =  XtOpenDisplay(app, NULL, APP_NAME, APP_CLASS, NULL, 0, &argc, argv);
     
     // load settings
@@ -84,6 +85,7 @@ int main(int argc, char** argv) {
     }
     
     MainWindow *window = WindowCreate(display);
+    toplevel_window = window->window;
     
     // random numbers only used for creating tmp dirs
     srand(time(NULL));
@@ -104,4 +106,16 @@ void ApplicationExit(void) {
 
 void AppAddTimeOut(unsigned long interval, XtTimerCallbackProc proc, XtPointer data) {
     XtAppAddTimeOut(app, interval, proc, data);
+    
+    if(!toplevel_window) return;
+    
+    // send a dummy X11 event, because the event loop may be waiting
+    // and the timeout proc is only called when an event is processed
+    XClientMessageEvent event;
+    memset(&event, 0, sizeof(XClientMessageEvent));
+    event.type = ClientMessage;
+    event.window = XtWindow(toplevel_window);
+    event.format = 32;
+    XSendEvent(display, XtWindow(toplevel_window), 0, 0, (XEvent*)&event);
+    XFlush(display);
 }