From: Olaf Wintermann Date: Sun, 4 Sep 2022 17:38:14 +0000 (+0200) Subject: add menu item for toggling window size adjustment X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=92835e632a2570c851ecd45af5c3b97af2037322;p=uwplayer.git add menu item for toggling window size adjustment --- diff --git a/application/player.c b/application/player.c index be4d77f..2d63135 100644 --- a/application/player.c +++ b/application/player.c @@ -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); diff --git a/application/window.c b/application/window.c index 1b351a8..2ce5c34 100644 --- a/application/window.c +++ b/application/window.c @@ -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', "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; diff --git a/application/window.h b/application/window.h index c00f29e..55bdd1f 100644 --- a/application/window.h +++ b/application/window.h @@ -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;