2 * Copyright 2022 Olaf Wintermann
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
36 static MainWindow *main_window;
38 static void WindowCreateMenu(MainWindow *win, Widget parent, Arg *args, int nargs);
40 static void FileOpenCB(Widget w, void *udata, void *cdata);
41 static void FileQuitCB(Widget w, void *udata, void *cdata);
42 static void PlayRepeatCB(Widget w, void *udata, void *cdata);
43 static void PlayRepeatListCB(Widget w, void *udata, void *cdata);
44 static void PlayAutoPlayCB(Widget w, void *udata, void *cdata);
45 static void PlayRandomCB(Widget w, void *udata, void *cdata);
46 static void ViewFullscreenCB(Widget w, void *udata, void *cdata);
47 static void ViewSidebarCB(Widget w, void *udata, void *cdata);
48 static void ViewAdjustWindowSizeCB(Widget w, void *udata, void *cdata);
50 static void WindowRealized(MainWindow *win);
52 static int blank_cursor_init = 0;
53 static Pixmap blank_cursor_pixmap;
54 static Cursor blank_cursor;
56 static void init_blank_cursor(Widget w) {
61 blank_cursor_pixmap = XCreateBitmapFromData(XtDisplay(w), XtWindow(w), &data, 1, 1);
62 if(!blank_cursor_pixmap) return;
64 blank_cursor = XCreatePixmapCursor(XtDisplay(w), blank_cursor_pixmap, blank_cursor_pixmap, &c, &c, 0, 0);
66 XFreePixmap(XtDisplay(w), blank_cursor_pixmap);
67 blank_cursor_init = 1;
70 static void window_close_handler(Widget window, void *udata, void *cdata) {
71 FileQuitCB(window, NULL, NULL);
74 static unsigned int keycodeF;
76 static void windowKeyEH(Widget widget, XtPointer data, XEvent *event, Boolean *dispatch) {
77 MainWindow *win = data;
78 if(win->fullscreen && event->xkey.keycode == keycodeF) {
79 WindowFullscreen(main_window, FALSE);
84 static int main_window_is_realized = 0;
86 static void resizeEH(Widget widget, XtPointer data, XEvent *event, Boolean *dispatch) {
87 if(!main_window_is_realized) {
88 if(XtIsRealized(widget)) {
89 main_window_is_realized = 1;
93 WindowAdjustAspectRatio(data);
96 static void WindowRealized(MainWindow *win) {
97 char *open_file = GetOpenFileArg();
99 PlayListAddFile(win, open_file);
100 PlayListPlayNext(win, true);
104 if(!blank_cursor_init) {
105 init_blank_cursor(win->player_widget);
108 XdndEnable(win->window);
111 static void playerWidgetInputCB(Widget widget, XtPointer u, XtPointer c) {
113 XmDrawingAreaCallbackStruct *cb = c;
115 if(win->player && win->player->isactive) {
116 PlayerHandleInput(win, win->player, cb);
120 static void windowGrabButton(MainWindow *win) {
127 ButtonPressMask | ButtonReleaseMask | PointerMotionMask | FocusChangeMask | EnterWindowMask | LeaveWindowMask,
132 win->buttongrab = True;
135 static void playerEH(Widget widget, XtPointer data, XEvent *event, Boolean *dispatch) {
136 MainWindow *win = data;
137 int etype = event->type;
140 if(etype == EnterNotify) {
142 windowGrabButton(win);
145 if(etype == LeaveNotify) {
147 //XtUngrabButton(win->player_widget, AnyButton, AnyModifier);
148 //win->buttongrab = False;
153 if(etype == ButtonPress || etype == ButtonRelease || etype == KeyPress || etype == KeyRelease) {
154 //printf("button press\n");
158 if(!win->player || win->player->window == 0) return;
160 WindowHandlePlayerEvent(win, event);
163 // redirect key events to the player window
164 //printf("redirect\n");
165 event->xkey.window = win->player->window;
167 XtDisplay(win->player_widget),
175 #define IGNORE_MOTION_THRESHOLD_MS 1000
176 #define MOTION_POS_THRESHOLD_PIX 5
177 #define OSD_BOTTOM_THRESHOLD 0.09
179 #define DOUBLE_CLICK_TIME_MS 500
181 void WindowHandlePlayerEvent(MainWindow *win, XEvent *event) {
182 // event handler for intercepted player mouse events
183 // win->player is not NULL
185 int etype = event->type;
187 if(etype == MotionNotify) {
188 Time cur_motion_time = event->xmotion.time;
190 win->motion_playback_time = win->player->playback_time;
193 int x = event->xmotion.x_root;
194 int y = event->xmotion.y_root;
195 if(win->cursorhidden && cur_motion_time - win->player_event_time < IGNORE_MOTION_THRESHOLD_MS) {
196 int diff_x = abs(x - win->mouse_x);
197 int diff_y = abs(y - win->mouse_y);
198 if(diff_x > MOTION_POS_THRESHOLD_PIX || diff_y > MOTION_POS_THRESHOLD_PIX) {
199 WindowShowPlayerCursor(win);
205 win->player_event_time = cur_motion_time;
206 win->motion_playback_time = win->player->playback_time;
210 if(win->pwbuttonpressed) {
211 Display *dp = XtDisplay(win->window);
213 XtUngrabPointer(win->player_widget, CurrentTime);
216 memset(&xev, 0, sizeof(xev));
217 xev.type = ClientMessage;
218 xev.xclient.message_type = XInternAtom(dp, "_NET_WM_MOVERESIZE", False);
219 xev.xclient.window = XtWindow(win->window);
220 xev.xclient.format = 32;
221 xev.xclient.data.l[0] = x;
222 xev.xclient.data.l[1] = y;
223 xev.xclient.data.l[2] = 8; // _NET_WM_MOVERESIZE_MOVE
224 xev.xclient.data.l[3] = 1; // button1
225 xev.xclient.data.l[4] = 1; // source indication
227 XSendEvent(dp, DefaultRootWindow(dp), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
229 win->pwbuttonpressed = FALSE;
231 } else if(etype == ButtonPress) {
232 Time t = event->xbutton.time;
234 int yi = win->player_widget->core.height - event->xbutton.y;
235 if((float)yi/(float)win->player_widget->core.height < OSD_BOTTOM_THRESHOLD) {
236 win->button_press_time = 0;
238 if(t - win->button_press_time < DOUBLE_CLICK_TIME_MS) {
240 WindowFullscreen(main_window, !win->fullscreen);
241 win->button_press_time = 0;
243 win->button_press_time = t;
245 win->pwbuttonpressed = 1;
247 } else if(etype == ButtonRelease) {
248 win->player_event_time = event->xbutton.time;
249 win->pwbuttonpressed = FALSE;
255 MainWindow* WindowCreate(Display *display) {
259 MainWindow *window = malloc(sizeof(MainWindow));
260 memset(window, 0, sizeof(MainWindow));
261 main_window = window;
265 XtSetArg(args[n], XmNtitle, APP_NAME); n++;
266 window->window = XtAppCreateShell(
269 applicationShellWidgetClass,
270 //vendorShellWidgetClass,
276 Atom wm_delete_window;
277 wm_delete_window = XmInternAtom(
281 XmAddWMProtocolCallback(
284 window_close_handler,
288 XtAddEventHandler(window->window, StructureNotifyMask, False, resizeEH, window);
291 XtSetArg(args[n], XmNwidth, 360); n++;
292 XtSetArg(args[n], XmNheight, 220); n++;
293 XtSetArg(args[n], XmNshadowThickness, 0); n++;
294 Widget container = XmCreateForm(window->window, "form", args, n);
295 XtManageChild(container);
296 XtAddEventHandler(container, KeyPressMask, FALSE, windowKeyEH, window);
299 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
300 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
301 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
302 WindowCreateMenu(window, container, args, n);
305 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
306 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
307 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
308 XtSetArg(args[n], XmNtopWidget, window->menubar); n++;
309 XtSetArg(args[n], XmNwidth, 300); n++;
310 window->sidebar = CreateSidebar(container, "sidebar", args, n);
311 SidebarSetWindow(window->sidebar, window);
312 //XtManageChild(window->sidebar);
315 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
316 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
317 XtSetArg(args[n], XmNrightWidget, window->sidebar); n++;
318 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
319 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
320 XtSetArg(args[n], XmNtopWidget, window->menubar); n++;
321 XtSetArg(args[n], XmNbackground, BlackPixelOfScreen(XtScreen(window->window))); n++;
322 window->player_widget = XmCreateDrawingArea(container, "player", args, n);
323 XtManageChild(window->player_widget);
324 XtAddCallback(window->player_widget, XmNinputCallback, playerWidgetInputCB, window);
325 XmProcessTraversal(window->player_widget, XmTRAVERSE_CURRENT);
326 XtAddEventHandler(window->player_widget, PointerMotionMask | ButtonPressMask | ButtonReleaseMask | FocusChangeMask |
327 EnterWindowMask | KeyPressMask | KeyReleaseMask |
328 LeaveWindowMask, FALSE, playerEH, window);
332 keycodeF = XKeysymToKeycode(XtDisplay(window->window), XStringToKeysym("F"));
335 PlayListInit(window);
337 window->adjustWindowSize = true; // auto adjust window size by default
342 MainWindow* GetMainWindow(void) {
346 void WindowShow(MainWindow *win) {
347 XtRealizeWidget(win->window);
351 * Creates a XmPushButton menu item
353 static Widget createMenuItem(
358 const char *accelerator,
359 char *accelerator_text,
360 XtCallbackProc callback,
366 XmString s1 = XmStringCreateSimple(label);
367 XtSetArg(args[n], XmNlabelString, s1); n++;
368 XtSetArg(args[n], XmNmnemonic, mnemonic); n++;
370 if(accelerator && accelerator_text) {
371 at = XmStringCreateSimple(accelerator_text);
372 XtSetArg(args[n], XmNaccelerator, accelerator); n++;
373 XtSetArg(args[n], XmNacceleratorText, at); n++;
376 Widget menuItem = XmCreatePushButtonGadget(menu, name, args, n);
377 XtManageChild(menuItem);
379 if(at) XmStringFree(at);
382 XtAddCallback(menuItem, XmNactivateCallback, (XtCallbackProc)callback, cbData);
389 * Creates a XmToggleButton menu item
391 static Widget createToggleMenuItem(
396 Boolean defaultValue,
397 const char *accelerator,
398 char *accelerator_text,
399 XtCallbackProc callback,
405 XmString s1 = XmStringCreateSimple(label);
406 XtSetArg(args[n], XmNlabelString, s1); n++;
407 XtSetArg(args[n], XmNmnemonic, mnemonic); n++;
408 XtSetArg(args[n], XmNset, defaultValue); n++;
410 if(accelerator && accelerator_text) {
411 at = XmStringCreateSimple(accelerator_text);
412 XtSetArg(args[n], XmNaccelerator, accelerator); n++;
413 XtSetArg(args[n], XmNacceleratorText, at); n++;
416 Widget menuItem = XmCreateToggleButtonGadget(menu, name, args, n);
417 XtManageChild(menuItem);
419 if(at) XmStringFree(at);
422 XtAddCallback(menuItem, XmNvalueChangedCallback, (XtCallbackProc)callback, cbData);
429 * Creates a menu separator
431 static Widget createMenuSeparator(Widget menu) {
432 Widget w = XmCreateSeparator(menu, "separator", NULL, 0);
437 static void WindowCreateMenu(MainWindow *win, Widget parent, Arg *mbargs, int nmbargs) {
438 Widget menubar = XmCreateMenuBar(parent, "menubar", mbargs, nmbargs);
439 XtManageChild(menubar);
440 win->menubar = menubar;
446 XmString s = XmStringCreateSimple("File");
447 XtVaCreateManagedWidget(
449 xmCascadeButtonWidgetClass,
454 Widget fileMenu = XmVaCreateSimplePulldownMenu(menubar, "menu", 0, NULL, NULL);
456 s = XmStringCreateSimple("Playback");
457 XtVaCreateManagedWidget(
459 xmCascadeButtonWidgetClass,
464 Widget playMenu = XmVaCreateSimplePulldownMenu(menubar, "menu", 1, NULL, NULL);
466 s = XmStringCreateSimple("View");
467 Widget viewMenuItem = XtVaCreateManagedWidget(
469 xmCascadeButtonWidgetClass,
474 Widget viewMenu = XmVaCreateSimplePulldownMenu(menubar, "menu", 2, NULL, NULL);
477 createMenuItem(fileMenu, "fileOpen", "Open...", 'O', "Ctrl<Key>O", "Ctrl+O", FileOpenCB, NULL);
478 createMenuItem(fileMenu, "fileQuit", "Exit", 'E', "Ctrl<Key>Q", "Ctrl+Q", FileQuitCB, NULL);
481 win->playRepeatTrackButton = createToggleMenuItem(playMenu, "playRepeatTrack", "Repeat", 'R', False, NULL, NULL, PlayRepeatCB, win);
482 win->playRepeatListButton = createToggleMenuItem(playMenu, "playRepeatList", "Repeat List", 'L', False, NULL, NULL, PlayRepeatListCB, win);
483 win->playAutoPlayButton = createToggleMenuItem(playMenu, "playAutoNext", "Autoplay Folder", 'A', False, NULL, NULL, PlayAutoPlayCB, win);
484 XtVaSetValues(win->playRepeatTrackButton, XmNindicatorType, XmONE_OF_MANY, NULL);
485 XtVaSetValues(win->playRepeatListButton, XmNindicatorType, XmONE_OF_MANY, NULL);
486 XtVaSetValues(win->playAutoPlayButton, XmNindicatorType, XmONE_OF_MANY, NULL);
488 createMenuSeparator(playMenu);
490 win->playRandom = createToggleMenuItem(playMenu, "playRandom", "Random Playback", 'P', False, NULL, NULL, PlayRandomCB, win);
494 createMenuItem(viewMenu, "viewFullscreen", "Fullscreen", 'F', "<Key>F", "F", ViewFullscreenCB, NULL);
495 win->viewSidebarButton = createToggleMenuItem(viewMenu, "viewSidebar", "View Sidebar", 'S', False, NULL, NULL, ViewSidebarCB, win);
497 createMenuSeparator(viewMenu);
499 win->viewAdjustWindowSize = createToggleMenuItem(viewMenu, "viewAdjustWindowSize", "Adjust Window Size", 'W', TRUE, NULL, NULL, ViewAdjustWindowSizeCB, win);
502 void go_fullscreen(Display *dsp, Window win)
505 Atom wm_state = XInternAtom(dsp, "_NET_WM_STATE", False);
506 Atom fullscreen = XInternAtom(dsp, "_NET_WM_STATE_FULLSCREEN", False);
507 memset(&xev, 0, sizeof(xev));
508 xev.type = ClientMessage;
509 xev.xclient.window = win;
510 xev.xclient.message_type = wm_state;
511 xev.xclient.format = 32;
512 xev.xclient.data.l[0] = 1; // _NET_WM_STATE_ADD
513 xev.xclient.data.l[1] = fullscreen;
514 xev.xclient.data.l[2] = 0;
515 XSendEvent(dsp, DefaultRootWindow(dsp), False,
516 SubstructureNotifyMask, &xev);
519 static Atom net_wm_state;
520 static Atom net_wm_state_fullscreen;
521 static int net_wm_atoms_initialized = 0;
523 void WindowFullscreen(MainWindow *win, bool enableFullscreen) {
524 Display *dpy = XtDisplay(win->window);
526 // init net_wm_state atoms
527 if(!net_wm_atoms_initialized) {
528 net_wm_state = XInternAtom(dpy, "_NET_WM_STATE", False);
529 net_wm_state_fullscreen = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False);
530 net_wm_atoms_initialized = 1;
533 WindowMenubarSetVisible(win, !enableFullscreen);
534 if(enableFullscreen && !win->fullscreen) {
535 XtUnmanageChild(main_window->menubar);
536 main_window->fullscreen = TRUE;
537 } else if(!enableFullscreen && win->fullscreen) {
538 XtManageChild(main_window->menubar);
539 main_window->fullscreen = FALSE;
542 WindowShowSidebar(win, enableFullscreen ? false : win->sidebarvisible);
545 memset(&ev, 0, sizeof(XEvent));
546 ev.type = ClientMessage;
547 ev.xclient.window = XtWindow(win->window);
548 ev.xclient.message_type = net_wm_state;
549 ev.xclient.format = 32;
550 ev.xclient.data.l[0] = enableFullscreen ? 1 : 0;
551 ev.xclient.data.l[1] = net_wm_state_fullscreen;
552 ev.xclient.data.l[2] = 0;
553 XSendEvent(dpy, DefaultRootWindow(dpy), False, SubstructureNotifyMask | SubstructureRedirectMask, &ev);
556 void WindowMenubarSetVisible(MainWindow *win, bool visible) {
558 XtManageChild(main_window->menubar);
559 XtVaSetValues(main_window->player_widget, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, main_window->menubar, NULL);
561 XtUnmanageChild(main_window->menubar);
562 XtVaSetValues(main_window->player_widget, XmNtopAttachment, XmATTACH_FORM, NULL);
566 static void filedialog_end(
569 XmFileSelectionBoxCallbackStruct *selection)
571 XtUnmanageChild(widget);
572 XtDestroyWidget(widget);
575 static void filedialog_select(
578 XmFileSelectionBoxCallbackStruct *selection)
581 if(selection->value) {
582 XmStringGetLtoR(selection->value, XmSTRING_DEFAULT_CHARSET, &value);
584 PlayListAddFile(data, value);
585 PlayListPlayNext(data, true);
589 filedialog_end(widget, data, NULL);
595 static void FileOpenCB(Widget w, void *udata, void *cdata) {
596 MainWindow *win = main_window;
601 XtSetArg(args[n], XnNshowViewMenu, 1); n++;
602 Widget dialog = XnCreateFileSelectionDialog(win->window, "dialog", args, n);
603 XtAddCallback(dialog, XmNokCallback, (XtCallbackProc)filedialog_select, win);
604 XtAddCallback(dialog, XmNcancelCallback, (XtCallbackProc)filedialog_end, win);
606 Widget dirUp = XnFileSelectionBoxGetChild(dialog, XnFSB_DIR_UP_BUTTON);
607 XtUnmanageChild(dirUp);
609 XtManageChild(dialog);
612 static void FileQuitCB(Widget w, void *udata, void *cdata) {
613 WindowClosePlayer(main_window);
617 static void PlayRepeatCB(Widget w, void *udata, void *cdata) {
618 MainWindow *win = udata;
619 win->playlist.repeatTrack = XmToggleButtonGadgetGetState(w);
620 win->playlist.repeatList = 0;
621 win->playlist.autoplayFolder = 0;
622 XtVaSetValues(win->playRepeatListButton, XmNset, 0, NULL);
623 XtVaSetValues(win->playAutoPlayButton, XmNset, 0, NULL);
626 static void PlayRepeatListCB(Widget w, void *udata, void *cdata) {
627 MainWindow *win = udata;
628 win->playlist.repeatList = XmToggleButtonGadgetGetState(w);
629 win->playlist.repeatTrack = 0;
630 win->playlist.autoplayFolder = 0;
631 XtVaSetValues(win->playRepeatTrackButton, XmNset, 0, NULL);
632 XtVaSetValues(win->playAutoPlayButton, XmNset, 0, NULL);
635 static void PlayAutoPlayCB(Widget w, void *udata, void *cdata) {
636 MainWindow *win = udata;
637 win->playlist.autoplayFolder = XmToggleButtonGadgetGetState(w);
638 win->playlist.repeatTrack = 0;
639 win->playlist.repeatList = 0;
640 XtVaSetValues(win->playRepeatTrackButton, XmNset, 0, NULL);
641 XtVaSetValues(win->playRepeatListButton, XmNset, 0, NULL);
644 static void PlayRandomCB(Widget w, void *udata, void *cdata) {
645 MainWindow *win = udata;
646 win->playlist.random = XmToggleButtonGadgetGetState(w);
649 static void ViewFullscreenCB(Widget w, void *udata, void *cdata) {
650 if(main_window->fullscreen) {
651 WindowFullscreen(main_window, FALSE);
653 WindowFullscreen(main_window, TRUE);
657 static void ViewSidebarCB(Widget w, void *udata, void *cdata) {
658 MainWindow *win = udata;
659 XmToggleButtonCallbackStruct *cb = cdata;
660 win->sidebarvisible = cb->set;
661 WindowShowSidebar(win, cb->set);
664 static void ViewAdjustWindowSizeCB(Widget w, void *udata, void *cdata) {
665 MainWindow *win = udata;
666 win->adjustWindowSize = XmToggleButtonGadgetGetState(w);
669 void WindowAdjustAspectRatio(MainWindow *win) {
670 if(!win->player) return;
671 if(!win->player->isactive || win->player->width <= 0 || win->player->height <= 0) return;
673 // we have a running player width video
674 // adjust window aspect ratio (the window aspect ratio is different from
675 // the video, because of window decoration, menubar and other extra controls)
677 Dimension win_width, win_height;
678 XtVaGetValues(win->window, XmNwidth, &win_width, XmNheight, &win_height, NULL);
679 Dimension player_width, player_height;
680 XtVaGetValues(win->player_widget, XmNwidth, &player_width, XmNheight, &player_height, NULL);
682 double r = (double)win->player->width / (double)win->player->height;
683 double p_width = player_width;
684 double p_height = p_width / r;
686 Dimension new_width = p_width + win_width - player_width;
687 Dimension new_height = p_height + win_height - player_height;
690 hints.flags = PAspect;
691 hints.min_aspect.x = new_width;
692 hints.min_aspect.y = new_height;
693 hints.max_aspect.x = new_width;
694 hints.max_aspect.y = new_height;
695 XSetWMNormalHints(XtDisplay(win->window), XtWindow(win->window), &hints);
698 void WindowClosePlayer(MainWindow *win) {
700 PlayerDestroy(win->player);
703 WindowShowPlayerCursor(win);
706 void WindowHidePlayerCursor(MainWindow *win) {
707 if(!win->cursorhidden && win->player && win->player->window != 0) {
708 XDefineCursor(XtDisplay(win->player_widget), XtWindow(win->player_widget), blank_cursor);
709 win->cursorhidden = True;
710 XFlush(XtDisplay(win->player_widget));
714 void WindowShowPlayerCursor(MainWindow *win) {
715 if(win->cursorhidden && win->player && win->player->window != 0) {
716 XDefineCursor(XtDisplay(win->player_widget), XtWindow(win->player_widget), None);
717 XFlush(XtDisplay(win->player_widget));
719 win->cursorhidden = False;
722 void WindowShowSidebar(MainWindow *win, bool visible) {
724 XtManageChild(win->sidebar);
725 XtVaSetValues(win->player_widget, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, win->sidebar, NULL);
727 XtUnmanageChild(win->sidebar);
728 XtVaSetValues(win->player_widget, XmNrightAttachment, XmATTACH_FORM, NULL);
732 void WindowUpdate(MainWindow *win) {
733 SidebarRepaint(win->sidebar);