static void WindowRealized(MainWindow *win);
+static int blank_cursor_init = 0;
+static Pixmap blank_cursor_pixmap;
+static Cursor blank_cursor;
+
+static void init_blank_cursor(Widget w) {
+ char data = 0;
+
+ XColor c;
+
+ blank_cursor_pixmap = XCreateBitmapFromData(XtDisplay(w), XtWindow(w), &data, 1, 1);
+ if(!blank_cursor_pixmap) return;
+
+ blank_cursor = XCreatePixmapCursor(XtDisplay(w), blank_cursor_pixmap, blank_cursor_pixmap, &c, &c, 0, 0);
+
+ XFreePixmap(XtDisplay(w), blank_cursor_pixmap);
+ blank_cursor_init = 1;
+}
+
static void window_close_handler(Widget window, void *udata, void *cdata) {
WindowClosePlayer(main_window);
ApplicationExit();
static int main_window_is_realized = 0;
-static void resizeEH(Widget widget, XtPointer data, XEvent *event, Boolean *dispatch) {
+static void resizeEH(Widget widget, XtPointer data, XEvent *event, Boolean *dispatch) {
if(!main_window_is_realized) {
if(XtIsRealized(widget)) {
main_window_is_realized = 1;
PlayerOpenFile(win);
CleanOpenFileArg();
}
+
+ if(!blank_cursor_init) {
+ init_blank_cursor(win->player_widget);
+ }
}
static void playerWidgetInputCB(Widget widget, XtPointer u, XtPointer c) {
}
}
-static void playerEH(Widget widget, XtPointer data, XEvent *event, Boolean *dispatch) {
- MainWindow *win = data;
- if(!win->player || win->player->window == 0) return;
-
- /*
- if(event->type == EnterNotify) {
- printf("enter: grab pointer\n");
-
- XtGrabPointer(
+static void windowGrabButton(MainWindow *win) {
+ //printf("grab\n");
+ XtGrabButton(
win->player_widget,
+ AnyButton,
+ AnyModifier,
True,
ButtonPressMask | ButtonReleaseMask | PointerMotionMask | FocusChangeMask | EnterWindowMask | LeaveWindowMask,
GrabModeAsync,
GrabModeAsync,
None,
- None,
- CurrentTime);
-
+ None);
+ win->buttongrab = True;
+}
+
+static void playerEH(Widget widget, XtPointer data, XEvent *event, Boolean *dispatch) {
+ MainWindow *win = data;
+ int etype = event->type;
+
+ ///*
+ if(etype == EnterNotify) {
+ //printf("enter\n");
+ windowGrabButton(win);
return;
}
- if(event->type == LeaveNotify) {
- printf("leave\n");
- XtUngrabPointer(win->player_widget, CurrentTime);
+ if(etype == LeaveNotify) {
+ //printf("leave\n");
+ //XtUngrabButton(win->player_widget, AnyButton, AnyModifier);
+ //win->buttongrab = False;
return;
}
- if(event->type == MotionNotify) {
- static int testv = 0;
- printf("test %d\n", testv++);
+ int pass = 0;
+ if(etype == ButtonPress || etype == ButtonRelease || etype == KeyPress || etype == KeyRelease) {
+ //printf("button press\n");
+ pass = 1;
}
- */
- if(event->type == KeyPress || event->type == KeyRelease) {
+ if(!win->player || win->player->window == 0) return;
+
+ WindowPlayerWidgetEvent(win, event);
+
+ if(pass) {
// redirect key events to the player window
+ //printf("redirect\n");
event->xkey.window = win->player->window;
XSendEvent(
XtDisplay(win->player_widget),
}
}
+void WindowPlayerWidgetEvent(MainWindow *win, XEvent *event) {
+ int etype = event->type;
+
+ if(etype == MotionNotify) {
+
+ } else if(etype == ButtonPress) {
+
+ } else if(etype == ButtonRelease) {
+
+ }
+}
+
MainWindow* WindowCreate(Display *display) {
Arg args[32];
int n;
-
+
MainWindow *window = malloc(sizeof(MainWindow));
memset(window, 0, sizeof(MainWindow));
main_window = window;
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)
}
win->player = NULL;
}
+
+void WindowHidePlayerCursor(MainWindow *win) {
+ if(!win->cursorhidden && win->player && win->player->window != 0) {
+ //XDefineCursor(XtDisplay(win->player_widget), XtWindow(win->player_widget), blank_cursor);
+ win->cursorhidden = True;
+ XFlush(XtDisplay(win->player_widget));
+ }
+}
+
+void WindowShowPlayerCursor(MainWindow *win) {
+ if(win->cursorhidden && win->player && win->player->window != 0) {
+ XDefineCursor(XtDisplay(win->player_widget), XtWindow(win->player_widget), None);
+ win->cursorhidden = False;
+ XFlush(XtDisplay(win->player_widget));
+ }
+}