summaryrefslogtreecommitdiffstats
path: root/video/out/cocoa
Commit message (Collapse)AuthorAgeFilesLines
* osx: code cleanups and cosmetic fixesAkemi2018-01-201-1/+2
|
* cocoa: always return the target NSRect when in fullscreenAkemi2017-11-111-1/+4
| | | | | | there is no need to calculate a new rectangle when in fullscreen since we always want to cover the whole screen. so just return the target rectangle.
* input: merge mouse wheel and axis keycodesJames Ross-Gowan2017-09-032-4/+4
| | | | | | | | | | | | | | | | | | | | | | Mouse wheel bindings have always been a cause of user confusion. Previously, on Wayland and macOS, precise touchpads would generate AXIS keycodes and notched mouse wheels would generate mouse button keycodes. On Windows, both types of device would generate AXIS keycodes and on X11, both types of device would generate mouse button keycodes. This made it pretty difficult for users to modify their mouse-wheel bindings, since it differed between platforms and in some cases, between devices. To make it more confusing, the keycodes used on Windows were changed in 18a45a42d524 without a deprecation period or adequate communication to users. This change aims to make mouse wheel binds less confusing. Both the mouse button and AXIS keycodes are now deprecated aliases of the new WHEEL keycodes. This will technically break input configs on Wayland and macOS that assign different commands to precise and non-precise scroll events, but this is probably uncommon (if anyone does it at all) and I think it's a fair tradeoff for finally fixing mouse wheel-related confusion on other platforms.
* cocoa: fix button numbering for back/forwardJames Ross-Gowan2017-09-031-4/+7
| | | | | | It seems like the Cocoa backend used to return the same mpv keycodes for mouse back/forward as it did for scrolling up and down. Fix this by explicitly mapping all Cocoa button numbers to the right mpv keycodes.
* input: use mnemonic names for mouse buttonsJames Ross-Gowan2017-09-031-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | mpv's mouse button numbering is based on X11 button numbering, which allows for an arbitrary number of buttons and includes mouse wheel input as buttons 3-6. This button numbering was used throughout the codebase and exposed in input.conf, and it was difficult to remember which physical button each number actually referred to and which referred to the scroll wheel. In practice, PC mice only have between two and five buttons and one or two scroll wheel axes, which are more or less in the same location and have more or less the same function. This allows us to use names to refer to the buttons instead of numbers, which makes input.conf syntax a lot easier to remember. It also makes the syntax robust to changes in mpv's underlying numbering. The old MOUSE_BTNx names are still understood as deprecated aliases of the named buttons. This changes both the input.conf syntax and the MP_MOUSE_BTNx symbols in the codebase, since I think both would benefit from using names over numbers, especially since some platforms don't use X11 button numbering and handle different mouse buttons in different windowing system events. This also makes the names shorter, since otherwise they would be pretty long, and it removes the high-numbered MOUSE_BTNx_DBL names, since they weren't used. Names are the same as used in Qt: https://doc.qt.io/qt-5/qt.html#MouseButton-enum
* osx: code cleanups and cosmetic fixesAkemi2017-08-182-11/+5
| | | | silence build warnings, clean up code style and remove unused code.
* cocoa: add an option to disable the native macOS fullscreenAkemi2017-08-062-8/+32
| | | | Fixes #4014
* cocoa: remove usage of FFABS and the dependency on libavutil/common.hAkemi2017-07-311-4/+2
|
* cocoa: distinguish between horizontal and vertical scrollAkemi2017-07-311-2/+12
| | | | | | | | | | we need to switch the x and y deltas when Shift is being held because macOS switches them around. otherwise we would get a horizontal scroll on a vertical one and vice versa. additional we switch from deltaX/Y to scrollingDeltaX/Y since the Apple docs suggest it's the preferred way now. in my tests both reported the same values on imprecise scrolls though.
* osx: change license header on some more cocoa fileswm42017-06-247-49/+49
| | | | Changing the headers was actually forgotten in the previous commit.
* cocoa: properly unhide Dock when quitting during System fs animationAkemi2017-05-191-0/+12
| | | | | | | | when quitting mpv during the System fullscreen animation cocoa can't reset some flags properly and won't reset the Dock hiding behaviour to it's previous state. Fixes #4400
* cocoa: fix first responder when borderless window is usedAkemi2017-03-261-0/+7
| | | | | | | | | | | | | this fixes a weird behaviour when a borderless window's style mask is set to a none-borderless style mask. this can happen when cycling the border or just toggling fullscreen. what happens is that the first responder is reset to the NSWindow instead of being kept, the events view in our case. this happens without the usual resignFirstResponder, becomeFirstResponder routine. this is a small workaround that overrides the setStyleMask method. it keeps the first responder from before the style mask change and resets this first responder after the new style mask was applied.
* osx: fix key input in certain circumstancesAkemi2017-03-262-11/+0
| | | | | | | | | | | | | for a reason i can just assume some key events can vanish from the event chain and mpv seems unresponsive. after quite some testing i could confirm that the events are present at the first entry point of the event chain, the sendEvent method of the Application, and that they vanish at a point afterwards. now we use that entry point to grab keyDown and keyUp events. we also stop propagating those key events to prevent the no key input' error sound. if we ever need the key events somewhere down the event chain we need to start propagating them again. though this is not necessary currently.
* cocoa: set background of the title bar from black to whiteAkemi2017-03-092-1/+3
| | | | | | | | | | | | due to the see-through nature of the title bar and our standard black window background, the title bar appears dark grey opposed to the expected light grey. we change the window background to white but at the same time set the background of the enclosed view to black. that way the title bar has a white background and the background of our video stays black in all cases. this prevents white flashing in some cases when the video is resized with too heavy render settings.
* cocoa: improve calculation of new window position on a different screenAkemi2017-02-281-13/+44
| | | | | | | | | | | forcibly moving a window from one screen to another is supposed to put it in a position that looks relative the same as on the old screen, as in bottom, top, left and right margin look the same, without changing the window size. in some situations the old code moved the window off screen or on top of the menu bar so it ended up at a somewhat random position. the new code fixes some edge cases but is probably not completely correct since the priority is to make sure that the window ends up on the right screen.
* cocoa: only move window into screen bounds when changing screensAkemi2017-02-271-3/+9
| | | | | | | | | | | when forcibly moving windows to a different screen with --screen or --fs-screen we need to move the window into the screen bounds if the window is out of bounds, otherwise it can end up on the wrong screen. previously it always recalculated the bounds and moved the window when toggling fullscreen, now it only does the bound calculation when changing screens. Fixes #4178
* cocoa: fix segfault in certain circumstancesAkemi2017-02-272-3/+5
| | | | | | | | | | | | | | i falsely assumed that the windowDidChangeScreen was meant to report ‘physical’ screen changes but was wondering why it triggers on other events too. it actually is a event that informs us when anything referenced by our current NSScreen is changed. even when something referenced in the NSScreen changed the old and new NSScreen are still equal if the physical screen didn’t change. with that my previous optimisation broke some cases where the physical screen didn’t change but things it referenced did, leading to a segfault when theses were accessed. to keep the optimisation we will always update our internal NSScreen reference but the rest only when the physical screen was changed.
* cocoa: fix dragging out of focus windowAkemi2017-02-211-1/+0
| | | | | | | | | | fffab30 introduced a small regression where the cursor couldn't be unhidden after refocusing. the problem is that no mouseUp event was reported in our events_view. work around this with a separate event monitor. this also fixes another regression when the window is being dragged from the title bar. #4174
* cocoa: only report mouse movements when window is not being draggedAkemi2017-02-202-0/+6
| | | | | | even though the mouse doesn’t move relative to the window itself, when the window is being dragged, some outliers are still reported and trigger the OSC.
* cocoa: fix cursor hiding at the top of the screen in fullscreenAkemi2017-02-191-0/+12
| | | | | | | | | | | | | | | | | | | even before the recent refactor the cursor was hidden when moving it to the top of the screen in fullscreen and placing it on top of the now visible menu bar. we need to know when the menu bar is hidden so we don’t create a ‘dead zone’ at the top of the screen where the cursor can’t be hidden. to determine when the menu bar is visible, and with that the title bar, we get the height of the menu bar. the height is always 0 when hidden. furthermore there is no way to get the title bar directly and with that its height. so we calculate the frame rect of a NSWindowStyleMaskTitled window from a CGRectZero content frame. the resulting height is the height of a title bar. with that we can exclude the top area for the cursor hiding and can be certain when the menu bar is not hidden.
* cocoa: fix cursor hiding in the Dock area of the screenAkemi2017-02-191-1/+1
| | | | | | | | | | | | | | | | the cursor couldn’t be hidden when the cursor was at the same position as the Dock, even if the cursor was next to it. this is especially annoying in fullscreen since the Dock isn’t actually hidden but is still reported as being visible. this basically made the part of the screen, where the Dock resides, a ‘dead zone’. so instead of using the visibleFrame we will just use the normal frame. there is no problem at the top area of the screen, since a window can’t be placed above the menu bar and in fullscreen the menu bar is always reported as not being on screen. i suspect this was done so the cursor wasn’t hidden when the it was placed above the Dock when windowed. with the recent refactor this is not needed any more.
* cocoa: fix scroll wheel input with Shift modifierAkemi2017-02-191-1/+2
| | | | | | | holding shift swaps the scroll wheel axes and deltaY returned zero. summing up deltaX and deltaY will always give us the right button. Fixes #3506
* cocoa: refactor mouse events and cursor visibilityAkemi2017-02-163-12/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | we reported some unnecessary mouse movements and not all mouse enter and leave events. that lead to wrongly reported activity on hover areas like on the OSC or comparable lua scripts. sometimes menu items were shown that shouldn't be shown or they didn't vanish because of the missing mouse leave event. this incorporates @torque's fix for mouse leave events that weren't triggered during a transition, like going to fullscreen. the tracking area was updated but the mouse never left that area because it was never over it. besides some known cursor visibility bugs the aforementioned changes also revealed some other bugs that weren't reproducible before because of the missbehavior. known issues, in some cases the cursor doesn't show or hide properly. for example when switching spaces, switching Apps via CMD+Tab or a system notification. former two could be fixed while keeping our current blank cursor approach. though the notification case couldn't. there is no event or similar to detect a notification and the cursor visibility couldn't be recovered in any way. new issues, i noticed that our event view isn't initialised yet when the first VOCTRL_SET_CURSOR_VISIBILITY event gets dispatched, which depends on the event view to be initialised. so the mouse cursor couldn't be hidden when mpv was opened and the cursor was within the window bounds. this wasn't noticeable before because of various bugs and unwanted behavior that have been fixed with this. now, in case the event view isn't ready yet, we set the visibility at a later point when the event view is ready and a helper flag is set. Fixes #1817 #3856 #4147
* cocoa: fix dropping of files and URLsAkemi2017-02-021-14/+5
| | | | | | | | | | | | | | | | | | | the problem here is that dropped files can also be treated as NSURLPboardType instead of just NSFilenamesPboardType. the 'else if' could never be reached and was dead code. this basically reverts ed695ce which tried to fix multiple dropped URLs, or rather files, and moves the filename check infront of the URL check. the filename path can handle multiple dropped files, whereas the URL path can only handle one dropped URL. this assumes that only one URL can be dropped at a time. it also reverts a603543 because it's not needed any more. this also fixes a problem where dropped URLs from Chrome don't conform to the NSURL class and the readObjectsForClasses method always returned an empty URL. Fixes #4036
* cocoa: optimise screen event handlingAkemi2017-02-021-5/+9
| | | | | | | | | | | | | | | | this optimises two things and fix a minor bug. 1. we always updated the display refresh rate on any mode change whether it was the current screen or not. now we only update the refresh rate when the mode changed happened on the current screen. 2. the windowDidChangeScreen event doesn't exclusively trigger on screen changes so we updated the display refresh rate in cases where it wasn't needed at all. since we manually keep track of the current screen, we can easily test if the screen really changed. 3. weirdly on initWithContentRect accessing the screen of the window always returned the main screen instead of the screen the window is created on. since we already use the window init method with the screen as argument, overwrite that method instead and use the screen argument.
* cocoa: don't constrain window frame for fullscreenAkemi2017-01-191-3/+4
| | | | | | | | | | | | | our constrainFrameRect prevents our window from positioning itself ontop of the menubar, which is unwanted for a fullscreen window. this always positioned our window vertically at -22/-23pt when going into fullscreen because of the menubar. this bug doesn't show on newer versions of OS X since the various flags we set force the window position. on OS X 10.9 though the fullscreen window was shifted 22pt downwards. even though this bug doesn't show on newer OS X versions, it should still be fixed for a possible behaviour changes in future version. Fixes #4044
* cocoa: move updateBorder method to the protocolAkemi2017-01-191-3/+3
| | | | | | we are calling the method on a NSWindow object that may not respond to that call, since its a method of MpvVideoWindow. add the method to our protocol and rename that protocol to reflect the change.
* cocoa: properly recover from toggleFullscreen failAkemi2017-01-191-8/+20
| | | | | | | | | | | in some circumstances cocoa isn't able to enter or exit fullscreen but we still set window sizes and flags accordingly. this leaves us in a hanging state between fullscreen and window. it also prevents the toggleFullscreen method and its events to work properly afterwards. in that state it's impossible to enter or exit this 'semi-fullscreen'. add a proper fallback to recover from this state. Fixes #4035
* cocoa: fix window size in certain circumstancesAkemi2017-01-191-8/+2
| | | | | | a combination of starting from bundle and fullscreen used the standard window size (960x480) from the pseudo GUI instead of the wanted video size.
* cocoa: add border cyclingAkemi2017-01-112-0/+29
| | | | Fixes #2430
* cocoa: fix build on OS X 10.9Akemi2016-12-261-1/+1
| | | | fixes #3946
* cocoa: cosmetic fixesAkemi2016-12-163-12/+20
|
* cocoa: fullscreen refactoringAkemi2016-12-154-89/+163
| | | | | | | | | | this replaces the old fullscreen with the native macOS fullscreen. additional the --fs-black-out-screens was removed since the new API doesn't support it in a way the old one did. it can possibly be re-added if done manually. Fixes #2857 #3272 #1352 #2062 #3864
* cocoa: fix dropping of certain urls on the windowAkemi2016-12-141-1/+6
| | | | | | the 'path' of an youtube url (youtube.com/watch?v=x) would just be '/watch'. obviously this fails to load.
* cocoa: fix display refresh rate retrieval on multi monitor setupsAkemi2016-06-181-0/+5
| | | | | | | | | | | | | | | | | | 1. this basically reverts commit de4c74e5a4a996e8ff431c8f33a32c4b580be203. even with CVDisplayLinkCreateWithActiveCGDisplays and CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext we still have to explicitly set the current display ID, otherwise it will just always choose the display with the lowest refresh rate. another weird thing is, we still have to set the display ID another time with CVDisplayLinkSetCurrentCGDisplay after the link was started. otherwise the display period is 0 and the fallback will be used. if we ever use the callback method for something useful it's probably better to use CVDisplayLinkCreateWithActiveCGDisplays since we will need to keep the display link around instead of releasing it at the end. in that case we have to call CVDisplayLinkSetCurrentCGDisplay two times, once before and once after LinkStart. 2. add windowDidChangeScreen delegate to update the display refresh rate when mpv is moved to a different screen.
* os x: handle multiple dropped files on the windowNyx0uf2016-04-301-2/+7
| | | | | | Should fix #3076 (partially). Signed-off-by: wm4 <wm4@nowhere>
* cocoa: support the "window-minimized" propertyJaime Marquínez Ferrándiz2015-03-081-0/+10
| | | | Signed-off-by: Stefano Pigozzi <stefano.pigozzi@gmail.com>
* cocoa: fix autohide in fullscreenStefano Pigozzi2015-03-083-4/+5
|
* cocoa: fix mouse hiding with launchpad and dock foldersStefano Pigozzi2015-03-082-0/+11
| | | | | | | | | | | | Some UI elements in OS X – like Launchpad and Dock folders – are implemented using borderless windows in background demonized applications. When we use these elements, mpv doesn't stop to be the active application, but the mpv window leaves keyWindow state while we use the OS controls. This commit just keeps track of window state to update the cursor visibility accordingly. Fixes #513
* cocoa: clamp mouse position to window.torque2015-03-071-0/+2
| | | | | Prevents out-of-window coordinates being reported for mouse coordinates. Previously they could be out-of-window coordinates on init or on resize.
* cocoa: update mouse coordinates when window is initialized.torque2015-03-072-1/+1
| | | | | | Make MpvEventsView -signalMousePosition a public method so it can be called without a compiler warning. Previously, the mouse position would be reported as (0,0) until the cursor was moved.
* input: add MOUSE_ENTER keybinding.torque2015-02-181-0/+3
| | | | Signed-off-by: wm4 <wm4@nowhere>
* cocoa: fix build on 10.9Stefano Pigozzi2015-01-021-1/+1
| | | | Use -isInFullScreenMode instead of the property introduced with the 10.10 SDK.
* cocoa: fix NSMapGet errorStefano Pigozzi2015-01-021-2/+4
| | | | regression from 64b6b2ea45
* cocoa: fix uninitialization while in fullscreenStefano Pigozzi2015-01-012-0/+13
| | | | | | | | This is only needed for switching video track with `_`, since Cocoa automatically handles cleaning up the application's presentation options when quitting the process. Fixes #1399
* cocoa: allow to black out other display when going fsStefano Pigozzi2014-12-012-1/+2
| | | fixes #1302
* cocoa: reintroduce async resizeStefano Pigozzi2014-10-182-2/+7
| | | | | | | After removing synchronous libdispatch calls, this looks like it doesn't deadlock anymore. I also experimented with pthread_mutex_trylock liek wm4 suggested, but it leads to some annoying black flickering. I will fallback to that only if some new deadlocks are discovered.
* cocoa: allow mouse events to bubble up with no-input-cursorStefano Pigozzi2014-10-172-14/+101
| | | | | Previously we didn't report events to the core, but still prevented the events to travel on the responder chain.
* libmpv/cocoa: allow clients to use mpv event systemStefano Pigozzi2014-10-121-0/+1
| | | | | | | | | | This allows mpv's view to take key and send events to mpv's core. To set key status correctly, clients must call -[NSWindow selectNextKeyView:] during reconfig on the main thread. All is 'documented' in the cocoabasic example. If someone knows a better way to handle giving key to the embedded view, let me know!
* cocoa: remove usage of Objective-C categoriesStefano Pigozzi2014-10-124-88/+37
| | | | | Objective-C categories need special linker flags from the user when statically linking (-ObjC LDFLAG), so make everyone's life simpler and remove them.
* cocoa: post keydown and keyup events without event monitorStefano Pigozzi2014-10-092-0/+9
| | | | | Our code worked under the assumption that the event monitor is always active and we did remove the keydown and keyup overrides from our cocoa view.
* cocoa: allow to embed into an arbitrary NSViewStefano Pigozzi2014-10-084-6/+6
| | | | | Basically add if guards on all the problematic features. I'm still thinking about a better way to handle this, but for the time being, this will do.
* cocoa: fix mouse autohideStefano Pigozzi2014-10-051-1/+1
| | | | broken in 547b62f
* cocoa: remove a debug commentoStefano Pigozzi2014-10-051-1/+1
| | | | fixup previous commit
* cocoa: separate video view and events viewStefano Pigozzi2014-10-055-11/+74
|
* cocoa: remove --fs-missioncontrolStefano Pigozzi2014-10-052-44/+2
| | | | | | | This is