summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
Diffstat (limited to 'libvo')
-rw-r--r--libvo/cocoa_common.m49
-rw-r--r--libvo/x11_common.c15
-rw-r--r--libvo/x11_common.h1
3 files changed, 49 insertions, 16 deletions
diff --git a/libvo/cocoa_common.m b/libvo/cocoa_common.m
index ba7d0ebc7c..aa8480bec5 100644
--- a/libvo/cocoa_common.m
+++ b/libvo/cocoa_common.m
@@ -55,6 +55,10 @@ struct vo_cocoa_state {
int last_screensaver_update;
+ int display_cursor;
+ int cursor_timer;
+ int cursor_autohide_delay;
+
bool did_resize;
bool out_fs_resize;
};
@@ -68,6 +72,7 @@ struct vo_cocoa_state *vo_cocoa_init_state(void);
void vo_set_level(int ontop);
void update_screen_info(void);
void resize_window(struct vo *vo);
+void vo_cocoa_display_cursor(int requested_state);
void create_menu(void);
struct vo_cocoa_state *vo_cocoa_init_state(void)
@@ -82,6 +87,7 @@ struct vo_cocoa_state *vo_cocoa_init_state(void)
.fullscreen_window_level = NSNormalWindowLevel + 1,
.windowed_frame = {{0,0},{0,0}},
.out_fs_resize = NO,
+ .display_cursor = 1,
};
return s;
}
@@ -90,6 +96,7 @@ int vo_cocoa_init(struct vo *vo)
{
s = vo_cocoa_init_state();
s->pool = [[NSAutoreleasePool alloc] init];
+ s->cursor_autohide_delay = vo->opts->cursor_autohide_delay;
NSApplicationLoad();
NSApp = [NSApplication sharedApplication];
[NSApp setActivationPolicy: NSApplicationActivationPolicyRegular];
@@ -245,18 +252,42 @@ void vo_cocoa_swap_buffers()
[s->glContext flushBuffer];
}
+void vo_cocoa_display_cursor(int requested_state)
+{
+ if (requested_state) {
+ if (!vo_fs || s->cursor_autohide_delay > -2) {
+ s->display_cursor = requested_state;
+ CGDisplayShowCursor(kCGDirectMainDisplay);
+ }
+ } else {
+ if (s->cursor_autohide_delay != -1) {
+ s->display_cursor = requested_state;
+ CGDisplayHideCursor(kCGDirectMainDisplay);
+ }
+ }
+}
+
int vo_cocoa_check_events(struct vo *vo)
{
+ NSEvent *event;
+ float curTime = TickCount()/60;
+ int msCurTime = (int) (curTime * 1000);
+
+ // automatically hide mouse cursor
+ if (vo_fs && s->display_cursor &&
+ (msCurTime - s->cursor_timer >= s->cursor_autohide_delay)) {
+ vo_cocoa_display_cursor(0);
+ s->cursor_timer = msCurTime;
+ }
+
//update activity every 30 seconds to prevent
//screensaver from starting up.
- int curTime = TickCount()/60;
- if (curTime - s->last_screensaver_update >= 30 || s->last_screensaver_update == 0)
+ if ((int)curTime - s->last_screensaver_update >= 30 || s->last_screensaver_update == 0)
{
UpdateSystemActivity(UsrActivity);
- s->last_screensaver_update = curTime;
+ s->last_screensaver_update = (int)curTime;
}
- NSEvent *event;
event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:nil
inMode:NSEventTrackingRunLoopMode dequeue:YES];
if (event == nil)
@@ -335,8 +366,8 @@ void create_menu()
[self setStyleMask:s->fullscreen_mask];
[self setFrame:s->screen_frame display:YES animate:NO];
[self setLevel:s->fullscreen_window_level];
- CGDisplayHideCursor(kCGDirectMainDisplay);
vo_fs = VO_TRUE;
+ vo_cocoa_display_cursor(0);
} else {
[NSApp setPresentationOptions:NSApplicationPresentationDefault];
[self setHasShadow:YES];
@@ -349,8 +380,8 @@ void create_menu()
}
[self setContentAspectRatio:s->current_video_size];
[self setLevel:s->windowed_window_level];
- CGDisplayShowCursor(kCGDirectMainDisplay);
vo_fs = VO_FALSE;
+ vo_cocoa_display_cursor(1);
}
}
@@ -396,6 +427,12 @@ void create_menu()
}
}
+- (void) mouseMoved: (NSEvent *) theEvent
+{
+ if (vo_fs)
+ vo_cocoa_display_cursor(1);
+}
+
- (void) mouseDragged:(NSEvent *)theEvent
{
[self mouseEvent: theEvent];
diff --git a/libvo/x11_common.c b/libvo/x11_common.c
index d5af7a41ab..ee50ba5575 100644
--- a/libvo/x11_common.c
+++ b/libvo/x11_common.c
@@ -780,12 +780,13 @@ static int check_resize(struct vo *vo)
int vo_x11_check_events(struct vo *vo)
{
struct vo_x11_state *x11 = vo->x11;
+ struct MPOpts *opts = vo->opts;
Display *display = vo->x11->display;
int ret = 0;
XEvent Event;
- if (x11->vo_mouse_autohide && x11->mouse_waiting_hide &&
- (GetTimerMS() - x11->mouse_timer >= 1000)) {
+ if (x11->mouse_waiting_hide && opts->cursor_autohide_delay != -1 &&
+ (GetTimerMS() - x11->mouse_timer >= opts->cursor_autohide_delay)) {
vo_hidecursor(display, x11->window);
x11->mouse_waiting_hide = 0;
}
@@ -846,16 +847,14 @@ int vo_x11_check_events(struct vo *vo)
case MotionNotify:
vo_mouse_movement(vo, Event.xmotion.x, Event.xmotion.y);
- if (x11->vo_mouse_autohide)
- {
+ if (opts->cursor_autohide_delay > -2) {
vo_showcursor(display, x11->window);
x11->mouse_waiting_hide = 1;
x11->mouse_timer = GetTimerMS();
}
break;
case ButtonPress:
- if (x11->vo_mouse_autohide)
- {
+ if (opts->cursor_autohide_delay > -2) {
vo_showcursor(display, x11->window);
x11->mouse_waiting_hide = 1;
x11->mouse_timer = GetTimerMS();
@@ -865,8 +864,7 @@ int vo_x11_check_events(struct vo *vo)
| MP_KEY_DOWN);
break;
case ButtonRelease:
- if (x11->vo_mouse_autohide)
- {
+ if (opts->cursor_autohide_delay > -2) {
vo_showcursor(display, x11->window);
x11->mouse_waiting_hide = 1;
x11->mouse_timer = GetTimerMS();
@@ -1176,7 +1174,6 @@ final:
x11->vo_gc = XCreateGC(mDisplay, x11->window, 0, NULL);
XSync(mDisplay, False);
- x11->vo_mouse_autohide = 1;
vo->event_fd = ConnectionNumber(x11->display);
}
diff --git a/libvo/x11_common.h b/libvo/x11_common.h
index 6ba2780747..14c7e44549 100644
--- a/libvo/x11_common.h
+++ b/libvo/x11_common.h
@@ -48,7 +48,6 @@ struct vo_x11_state {
unsigned long xv_colorkey;
unsigned int xv_port;
- int vo_mouse_autohide;
int wm_type;
int fs_type;
int window_state;