+
+void WindowAdjustAspectRatio(MainWindow *win) {
+ if(!win->player) return;
+ if(!win->player->isactive || win->player->width <= 0 || win->player->height <= 0) return;
+
+ // we have a running player width video
+ // adjust window aspect ratio (the window aspect ratio is different from
+ // the video, because of window decoration, menubar and other extra controls)
+
+ 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);
+
+ double r = (double)win->player->width / (double)win->player->height;
+ double p_width = player_width;
+ double p_height = p_width / r;
+
+ Dimension new_width = p_width + win_width - player_width;
+ Dimension new_height = p_height + win_height - player_height;
+
+ 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);
+}