]> uap-core.de Git - uwplayer.git/commitdiff
add menu item for toggling window size adjustment
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Sun, 4 Sep 2022 17:38:14 +0000 (19:38 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Sun, 4 Sep 2022 17:38:14 +0000 (19:38 +0200)
application/player.c
application/window.c
application/window.h

index be4d77f96ada34be88771d364e7efb41df792d09..2d631352423e21f5002270bfcd37791bb39cfc44 100644 (file)
@@ -245,6 +245,7 @@ static int connect_to_ipc(Player *player) {
 static Boolean update_player_window(XtPointer data) {
     MainWindow *win = data;
     WindowUpdate(win);
+    return 0;
 }
 
 static void* start_player(void *data) {
@@ -356,6 +357,10 @@ static void handle_json_rpc_msg(Player *player, JSONValue *v) {
 static Boolean player_widget_set_size(XtPointer data) {
     Player *player = data;
     MainWindow *win = GetMainWindow();
+    
+    if(!win->adjustWindowSize) {
+        return 0;
+    }
         
     Dimension win_width, win_height;
     XtVaGetValues(win->window, XmNwidth, &win_width, XmNheight, &win_height, NULL);
index 1b351a8b67c2d0d998c379d06954ae127f32bdf3..2ce5c34fdd0e385e9a083c67a33f0abb9172a377 100644 (file)
@@ -42,8 +42,10 @@ static void FileQuitCB(Widget w, void *udata, void *cdata);
 static void PlayRepeatCB(Widget w, void *udata, void *cdata);
 static void PlayRepeatListCB(Widget w, void *udata, void *cdata);
 static void PlayAutoPlayCB(Widget w, void *udata, void *cdata);
+static void PlayRandomCB(Widget w, void *udata, void *cdata);
 static void ViewFullscreenCB(Widget w, void *udata, void *cdata);
 static void ViewSidebarCB(Widget w, void *udata, void *cdata);
+static void ViewAdjustWindowSizeCB(Widget w, void *udata, void *cdata);
 
 static void WindowRealized(MainWindow *win);
 
@@ -332,6 +334,8 @@ MainWindow* WindowCreate(Display *display) {
     
     PlayListInit(window);
     
+    window->adjustWindowSize = true; // auto adjust window size by default
+    
     return window;
 }
 
@@ -421,6 +425,15 @@ static Widget createToggleMenuItem(
     return menuItem;
 }
 
+/*
+ * Creates a menu separator
+ */
+static Widget createMenuSeparator(Widget menu) {
+    Widget w = XmCreateSeparator(menu, "separator", NULL, 0);
+    XtManageChild(w);
+    return w;
+}
+
 static void WindowCreateMenu(MainWindow *win, Widget parent, Arg *mbargs, int nmbargs) {
     Widget menubar = XmCreateMenuBar(parent, "menubar", mbargs, nmbargs);
     XtManageChild(menubar);
@@ -472,9 +485,18 @@ static void WindowCreateMenu(MainWindow *win, Widget parent, Arg *mbargs, int nm
     XtVaSetValues(win->playRepeatListButton, XmNindicatorType, XmONE_OF_MANY, NULL);
     XtVaSetValues(win->playAutoPlayButton, XmNindicatorType, XmONE_OF_MANY, NULL);
     
+    createMenuSeparator(playMenu);
+    
+    win->playRandom = createToggleMenuItem(playMenu, "playRandom", "Random Playback", 'P', False, NULL, NULL, PlayRandomCB, win);
+    
+    
     // view menu
     createMenuItem(viewMenu, "viewFullscreen", "Fullscreen", 'F', "<Key>F", "F", ViewFullscreenCB, NULL);
     win->viewSidebarButton = createToggleMenuItem(viewMenu, "viewSidebar", "View Sidebar", 'S', False, NULL, NULL, ViewSidebarCB, win);
+    
+    createMenuSeparator(viewMenu);
+    
+    win->viewAdjustWindowSize = createToggleMenuItem(viewMenu, "viewAdjustWindowSize", "Adjust Window Size", 'W', TRUE, NULL, NULL, ViewAdjustWindowSizeCB, win);
 }
 
 void go_fullscreen(Display *dsp, Window win)
@@ -617,6 +639,11 @@ static void PlayAutoPlayCB(Widget w, void *udata, void *cdata) {
     XtVaSetValues(win->playRepeatListButton, XmNset, 0, NULL);
 }
 
+static void PlayRandomCB(Widget w, void *udata, void *cdata) {
+    MainWindow *win = udata;
+    win->playlist.random = XmToggleButtonGadgetGetState(w);
+}
+
 static void ViewFullscreenCB(Widget w, void *udata, void *cdata) {
     if(main_window->fullscreen) {
         WindowFullscreen(main_window, FALSE);
@@ -635,6 +662,11 @@ static void ViewSidebarCB(Widget w, void *udata, void *cdata) {
     }
 }
 
+static void ViewAdjustWindowSizeCB(Widget w, void *udata, void *cdata) {
+    MainWindow *win = udata;
+    win->adjustWindowSize = XmToggleButtonGadgetGetState(w);
+}
+
 void WindowAdjustAspectRatio(MainWindow *win) {
     if(!win->player) return;
     if(!win->player->isactive || win->player->width <= 0 || win->player->height <= 0) return;
index c00f29e19ca289ddc1d14951e3f9466209421733..55bdd1f741650368086904a9ee6253079b09052b 100644 (file)
@@ -55,6 +55,7 @@ typedef struct {
     Boolean repeatTrack;
     Boolean repeatList;
     Boolean autoplayFolder;
+    Boolean random;
 } PlayList;
 
 typedef struct MainWindow {
@@ -74,10 +75,14 @@ typedef struct MainWindow {
     Widget playRepeatTrackButton;
     Widget playRepeatListButton;
     Widget playAutoPlayButton;
+    Widget playRandom;
     Widget viewSidebarButton;
+    Widget viewAdjustWindowSize;
     
     PlayList playlist;
     
+    bool adjustWindowSize;
+    
     Time player_event_time;
     Time button_press_time;
     double motion_playback_time;