call: autohide controls ui
This commit adds a hide timeout on call controls when mouse is not moving.
This leaves a clean view to display the call.
Issue: #78354
Change-Id: I58e7cb14beec89fd9be68ce144057d8f476a8d98
diff --git a/src/views/CallView.h b/src/views/CallView.h
index b15d525..eac0984 100644
--- a/src/views/CallView.h
+++ b/src/views/CallView.h
@@ -29,12 +29,13 @@
*/
#import <Cocoa/Cocoa.h>
-@protocol FullScreenDelegate;
-@protocol FullScreenDelegate
+@protocol CallDelegate;
+@protocol CallDelegate
@optional
-(void) callShouldToggleFullScreen;
+-(void) mouseIsMoving:(BOOL) move;
@end
@@ -54,6 +55,6 @@
/**
* Delegate to inform about desire to move
*/
-@property (nonatomic) id <FullScreenDelegate> fullScreenDelegate;
+@property (nonatomic) id <CallDelegate> callDelegate;
@end
diff --git a/src/views/CallView.mm b/src/views/CallView.mm
index 8fe60c6..e75ef3a 100644
--- a/src/views/CallView.mm
+++ b/src/views/CallView.mm
@@ -59,6 +59,17 @@
{
[self registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, nil]];
}
+
+ [self.window setAcceptsMouseMovedEvents:YES];
+
+ NSTrackingAreaOptions options = (NSTrackingActiveAlways | NSTrackingInVisibleRect | NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved);
+
+ NSTrackingArea *area = [[NSTrackingArea alloc] initWithRect:frame
+ options:options
+ owner:self
+ userInfo:nil];
+
+ [self addTrackingArea:area];
return self;
}
@@ -178,6 +189,21 @@
[NSMenu popUpContextMenu:contextualMenu withEvent:theEvent forView:self];
}
+- (void)mouseMoved:(NSEvent *)theEvent
+{
+ [NSObject cancelPreviousPerformRequestsWithTarget:self]; // cancel showContextualMenu
+ [self performSelector:@selector(mouseIdle:) withObject:theEvent afterDelay:3];
+ if (self.callDelegate)
+ [self.callDelegate mouseIsMoving:YES];
+}
+
+- (void) mouseIdle:(NSEvent *)theEvent
+{
+ if (self.callDelegate && shouldAcceptInteractions)
+ [self.callDelegate mouseIsMoving:NO];
+}
+
+
- (void)mouseUp:(NSEvent *)theEvent
{
if([theEvent clickCount] == 1 && shouldAcceptInteractions) {
@@ -189,8 +215,8 @@
else if([theEvent clickCount] == 2)
{
[NSObject cancelPreviousPerformRequestsWithTarget:self]; // cancel showContextualMenu
- if(self.fullScreenDelegate)
- [self.fullScreenDelegate callShouldToggleFullScreen];
+ if(self.callDelegate)
+ [self.callDelegate callShouldToggleFullScreen];
}
}