summaryrefslogtreecommitdiffstats
path: root/video/out/cocoa/events_view.m
Commit message (Collapse)AuthorAgeFilesLines
* input: merge mouse wheel and axis keycodesJames Ross-Gowan2017-09-031-3/+3
| | | | | | | | | | | | | | | | | | | | | | 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-181-10/+3
| | | | silence build warnings, clean up code style and remove unused code.
* 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-241-7/+7
| | | | Changing the headers was actually forgotten in the previous commit.
* osx: fix key input in certain circumstancesAkemi2017-03-261-10/+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: 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-201-0/+1
| | | | | | 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-161-10/+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: fix build on OS X 10.9Akemi2016-12-261-1/+1
| | | | fixes #3946
* cocoa: cosmetic fixesAkemi2016-12-161-9/+14
|
* cocoa: fullscreen refactoringAkemi2016-12-151-71/+0
| | | | | | | | | | 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.
* os x: handle multiple dropped files on the windowNyx0uf2016-04-301-2/+7
| | | | | | Should fix #3076 (partially). Signed-off-by: wm4 <wm4@nowhere>
* cocoa: fix autohide in fullscreenStefano Pigozzi2015-03-081-1/+2
|
* 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-071-1/+0
| | | | | | 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-011-0/+12
| | | | | | | | 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-011-1/+1
| | | fixes #1302
* cocoa: allow mouse events to bubble up with no-input-cursorStefano Pigozzi2014-10-171-14/+99
| | | | | 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-121-5/+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-091-0/+8
| | | | | 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-081-5/+0
| | | | | 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: separate video view and events viewStefano Pigozzi2014-10-051-0/+262