add handler for motion/button events
[uwplayer.git] / application / main.c
index 18d534b..43d6c05 100644 (file)
@@ -133,7 +133,7 @@ int main(int argc, char** argv) {
     srand(time(NULL));
     
     WindowShow(window);
-    XtAppMainLoop(app);
+    AppMainLoop(app);
     
     return 0;
 }
@@ -160,3 +160,25 @@ char* GetOpenFileArg(void) {
 void CleanOpenFileArg(void) {
     open_file_arg = NULL;
 }
+
+static Window app_player_window = 0;
+
+void SetPlayerWindow(Window w) {
+    app_player_window = w;
+}
+
+/*
+ * Extended Xt main loop, that also handles external window events
+ */
+void AppMainLoop(XtAppContext app) {
+    while(!XtAppGetExitFlag(app)) {
+        XEvent event;
+        XtAppNextEvent(app, &event);
+        
+        if(app_player_window != 0 && event.xany.window == app_player_window) {
+            WindowPlayerWidgetEvent(GetMainWindow(), &event);
+        } else {
+            XtDispatchEvent(&event);
+        }
+    }
+}