set window size after a video is opened
[uwplayer.git] / application / player.c
index dbaca58..5c481fa 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 #include "player.h"
+#include "main.h"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -106,7 +107,7 @@ static void* wait_for_process(void *data) {
     int status = 0;
     waitpid(player->process, &status, 0);
 
-    //player->isactive = FALSE;
+    player->isactive = FALSE;
     player->status = status;
     
     return NULL;
@@ -326,6 +327,24 @@ static void handle_json_rpc_msg(Player *player, JSONValue *v) {
     fflush(stdout);
 }
 
+static void player_widget_set_size(XtPointer data, XtIntervalId *id) {
+    Player *player = data;
+    MainWindow *win = GetMainWindow();
+        
+    Dimension win_width, win_height;
+    XtVaGetValues(win->window, XmNwidth, &win_width, XmNheight, &win_height, NULL);
+    Dimension player_width, player_height;
+    XtVaGetValues(win->player_widget, XmNwidth, &player_width, XmNheight, &player_height, NULL);
+
+    Dimension new_width = player->width + win_width - player_width;
+    Dimension new_height = player->height + win_height - player_height;
+    
+    XtVaSetValues(win->window, XmNwidth, new_width, XmNheight, new_height, NULL);
+    
+}
+
+
+
 static void player_set_size(Player *player, int width, int height) {
     if(width >= 0) {
         player->width = width;
@@ -334,7 +353,7 @@ static void player_set_size(Player *player, int width, int height) {
         player->height = height;
     }
     if(player->width > 0 && player->height > 0) {
-        printf("TODO: set player size\n");
+        AppAddTimeOut(0, player_widget_set_size, player);
     }
 }