#include "player.h"
#include "Fsb.h"
+#include "Sidebar.h"
static MainWindow *main_window;
static void FileOpenCB(Widget w, void *udata, void *cdata);
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 ViewFullscreenCB(Widget w, void *udata, void *cdata);
+static void ViewSidebarCB(Widget w, void *udata, void *cdata);
static void WindowRealized(MainWindow *win);
if(etype == MotionNotify) {
Time cur_motion_time = event->xmotion.time;
- int x = event->xmotion.x;
- int y = event->xmotion.y;
+ if(win->player) {
+ win->motion_playback_time = win->player->playback_time;
+ }
+
+ int x = event->xmotion.x_root;
+ int y = event->xmotion.y_root;
if(win->cursorhidden && cur_motion_time - win->player_event_time < IGNORE_MOTION_THRESHOLD_MS) {
- int diff_x = abs(x - win->mouse_x_orig);
- int diff_y = abs(y - win->mouse_y_orig);
+ int diff_x = abs(x - win->mouse_x);
+ int diff_y = abs(y - win->mouse_y);
if(diff_x > MOTION_POS_THRESHOLD_PIX || diff_y > MOTION_POS_THRESHOLD_PIX) {
WindowShowPlayerCursor(win);
}
} else {
- win->mouse_x_orig = x;
- win->mouse_y_orig = y;
+ win->mouse_x = x;
+ win->mouse_y = y;
}
win->player_event_time = cur_motion_time;
win->motion_playback_time = win->player->playback_time;
+
+
+
+ if(win->pwbuttonpressed) {
+ Display *dp = XtDisplay(win->window);
+
+ XtUngrabPointer(win->player_widget, CurrentTime);
+
+ XEvent xev;
+ memset(&xev, 0, sizeof(xev));
+ xev.type = ClientMessage;
+ xev.xclient.message_type = XInternAtom(dp, "_NET_WM_MOVERESIZE", False);
+ xev.xclient.window = XtWindow(win->window);
+ xev.xclient.format = 32;
+ xev.xclient.data.l[0] = x;
+ xev.xclient.data.l[1] = y;
+ xev.xclient.data.l[2] = 8; // _NET_WM_MOVERESIZE_MOVE
+ xev.xclient.data.l[3] = 1; // button1
+ xev.xclient.data.l[4] = 1; // source indication
+
+ XSendEvent(dp, DefaultRootWindow(dp), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
+
+ win->pwbuttonpressed = FALSE;
+ }
} else if(etype == ButtonPress) {
Time t = event->xbutton.time;
if(t - win->button_press_time < DOUBLE_CLICK_TIME_MS) {
} else {
win->button_press_time = t;
}
+ win->pwbuttonpressed = 1;
} else if(etype == ButtonRelease) {
win->player_event_time = event->xbutton.time;
+ win->pwbuttonpressed = FALSE;
}
}
WindowCreateMenu(window, container, args, n);
n = 0;
+ XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
+ XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
+ XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
+ XtSetArg(args[n], XmNtopWidget, window->menubar); n++;
+ XtSetArg(args[n], XmNwidth, 300); n++;
+ window->sidebar = CreateSidebar(container, "sidebar", args, n);
+ //XtManageChild(window->sidebar);
+
+ n = 0;
XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
+ XtSetArg(args[n], XmNrightWidget, window->sidebar); n++;
XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg(args[n], XmNtopWidget, window->menubar); n++;
EnterWindowMask | KeyPressMask | KeyReleaseMask |
LeaveWindowMask, FALSE, playerEH, window);
-
+
// get F keycode
keycodeF = XKeysymToKeycode(XtDisplay(window->window), XStringToKeysym("F"));
createMenuItem(fileMenu, "fileQuit", "Exit", 'E', "Ctrl<Key>Q", "Ctrl+Q", FileQuitCB, NULL);
// play menu
- createToggleMenuItem(playMenu, "playRepeatTrack", "Repeat", 'R', False, NULL, NULL, PlayRepeatCB, win);
+ win->playRepeatTrackButton = createToggleMenuItem(playMenu, "playRepeatTrack", "Repeat", 'R', False, NULL, NULL, PlayRepeatCB, win);
+ win->playRepeatListButton = createToggleMenuItem(playMenu, "playRepeatList", "Repeat List", 'L', False, NULL, NULL, PlayRepeatListCB, win);
+ win->playAutoPlayButton = createToggleMenuItem(playMenu, "playAutoNext", "Autoplay Folder", 'A', False, NULL, NULL, PlayAutoPlayCB, win);
+ XtVaSetValues(win->playRepeatTrackButton, XmNindicatorType, XmONE_OF_MANY, NULL);
+ XtVaSetValues(win->playRepeatListButton, XmNindicatorType, XmONE_OF_MANY, NULL);
+ XtVaSetValues(win->playAutoPlayButton, XmNindicatorType, XmONE_OF_MANY, NULL);
// 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);
}
void go_fullscreen(Display *dsp, Window win)
static void PlayRepeatCB(Widget w, void *udata, void *cdata) {
MainWindow *win = udata;
win->repeatTrack = XmToggleButtonGadgetGetState(w);
+ win->repeatList = 0;
+ win->autoplayFolder = 0;
+ XtVaSetValues(win->playRepeatListButton, XmNset, 0, NULL);
+ XtVaSetValues(win->playAutoPlayButton, XmNset, 0, NULL);
+}
+
+static void PlayRepeatListCB(Widget w, void *udata, void *cdata) {
+ MainWindow *win = udata;
+ win->repeatList = XmToggleButtonGadgetGetState(w);
+ win->repeatTrack = 0;
+ win->autoplayFolder = 0;
+ XtVaSetValues(win->playRepeatTrackButton, XmNset, 0, NULL);
+ XtVaSetValues(win->playAutoPlayButton, XmNset, 0, NULL);
+}
+
+static void PlayAutoPlayCB(Widget w, void *udata, void *cdata) {
+ MainWindow *win = udata;
+ win->autoplayFolder = XmToggleButtonGadgetGetState(w);
+ win->repeatTrack = 0;
+ win->repeatList = 0;
+ XtVaSetValues(win->playRepeatTrackButton, XmNset, 0, NULL);
+ XtVaSetValues(win->playRepeatListButton, XmNset, 0, NULL);
}
static void ViewFullscreenCB(Widget w, void *udata, void *cdata) {
WindowFullscreen(main_window, FALSE);
} else {
WindowFullscreen(main_window, TRUE);
+ }
+}
+
+static void ViewSidebarCB(Widget w, void *udata, void *cdata) {
+ MainWindow *win = udata;
+ XmToggleButtonCallbackStruct *cb = cdata;
+ if(cb->set) {
+ WindowShowSidebar(win);
+ } else {
+ WindowHideSidebar(win);
}
-
}
void WindowAdjustAspectRatio(MainWindow *win) {
}
win->cursorhidden = False;
}
+
+void WindowHideSidebar(MainWindow *win) {
+ XtUnmanageChild(win->sidebar);
+ XtVaSetValues(win->player_widget, XmNrightAttachment, XmATTACH_FORM, NULL);
+}
+
+void WindowShowSidebar(MainWindow *win) {
+ XtManageChild(win->sidebar);
+ XtVaSetValues(win->player_widget, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, win->sidebar, NULL);
+}
+