summaryrefslogtreecommitdiffstats
path: root/osdep/macosx_events.m
Commit message (Collapse)AuthorAgeFilesLines
* mac: replace old event tap for media key support with MediaPlayerder richter2019-12-151-121/+6
| | | | | | | | | | | | | | | the old event tap has several problems, like no proper priority support or having to set accessibility permissions for mpv or the terminal. it is now replaced by the new MediaPlayer which has proper priority support and isn't as greedy as previously. this only includes Media Key support and not any of the other features included in the MediaPlayer framework, like proper Now Playing data (only set dummy data for now). this is only available on macOS 10.12.2 and higher. also removes some unnecessary redefines. Fixes #6389
* mac: remove Apple Remote supportder richter2019-12-151-65/+0
| | | | | | the Apple Remote has long been deprecated and abandoned by Apple. current macs don't come with support for it anymore. support might be re-added with the next commit.
* macosx_events: fix crash when shutting down during window animationsRodger Combs2019-03-131-1/+3
|
* mac: fix crash if we can't get an event tapRodger Combs2018-10-021-9/+12
| | | | | | | | without assistive-device permissions the event tap can't be create on 10.14 any more which lead to an assertion. System Preferences > Security & Privacy > Privacy > Accessibility and add mpv or your terminal App to the list.
* all: replace mpv_detach_destroy() with mpv_destroy()wm42018-03-151-2/+2
|
* cocoa-cb: initial implementation via opengl-cb APIAkemi2018-02-121-5/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | this is meant to replace the old and not properly working vo_gpu/opengl cocoa backend in the future. the problems are various shortcomings of Apple's opengl implementation and buggy behaviour in certain circumstances that couldn't be properly worked around. there are also certain regressions on newer macOS versions from 10.11 onwards. - awful opengl performance with a none layer backed context - huge amount of dropped frames with an early context flush - flickering of system elements like the dock or volume indicator - double buffering not properly working with a none layer backed context - bad performance in fullscreen because of system optimisations all the problems were caused by using a normal opengl context, that seems somewhat abandoned by apple, and are fixed by using a layer backed opengl context instead. problems that couldn't be fixed could be properly worked around. this has all features our old backend has sans the wid embedding, the possibility to disable the automatic GPU switching and taking screenshots of the window content. the first was deemed unnecessary by me for now, since i just use the libmpv API that others can use anyway. second is technically not possible atm because we have to pre-allocate our opengl context at a time the config isn't read yet, so we can't get the needed property. third one is a bit tricky because of deadlocking and it needed to be in sync, hopefully i can work around that in the future. this also has at least one additional feature or eye-candy. a properly working fullscreen animation with the native fs. also since this is a direct port of the old backend of the parts that could be used, though with adaptions and improvements, this looks a lot cleaner and easier to understand. some credit goes to @pigoz for the initial swift build support which i could improve upon. Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739, #2392, #2217
* osx: code cleanups and cosmetic fixesAkemi2018-01-201-5/+0
|
* osx: fix media keys input when other Apps steal the priorityAkemi2017-09-071-0/+20
| | | | | | | | | | | other Apps do the same as mpv and tap into the global event chain. events that are handled are not being propagated down the event chain. that can lead to mpv not getting any media key events anymore when they are held back by other Apps. we will just move mpv back to the top of the event list when mpv is refocused and is not at the top of the list any more. Fixes #4834
* osx: code cleanups and cosmetic fixesAkemi2017-08-181-4/+6
| | | | silence build warnings, clean up code style and remove unused code.
* osx: change license of OSX and cocoa files to LGPLwm42017-06-241-7/+7
| | | | All authors of the current code have agreed.
* osx: fix deadlock on exit with libmpv on OSXwm42017-04-191-8/+11
| | | | | | | | | | | There is explicit code to handle the libmpv case, but it expects that a dispatch queue is running. This is not necessarily the case. E.g. edit the simple.c mpv example not to do any playback and to destroy the mpv handle immediately. It will freeze on exit, because nothing will release the mpv_handle. I'm not sure how this should be fixed, so disable it for now in library mode.
* osx: fix event propagation of menu bar item key shortcutsAkemi2017-03-271-4/+3
| | | | | | a small logic error in 063ca8f broke the filtering of the menu bar item key shortcuts. they where called several times per event because the propagation wasn't stopped properly.
* osx: fix key input in certain circumstancesAkemi2017-03-261-19/+11
| | | | | | | | | | | | | 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.
* osx: initial Touch Bar supportAkemi2017-03-261-0/+61
|
* osx: add key mappings for previous and next Media KeysAkemi2017-03-091-3/+5
| | | | Fixes #4204
* cocoa: cosmetic fixesAkemi2016-12-161-5/+9
|
* cocoa: support append file to paylist on dropAkemi2016-12-141-1/+4
| | | | | | | | | When dropping a file on mpv, either on the window or the App bundle icon, while holding the shift key the dropped files will be appended to the playlist. Fixes #2166
* cocoa: fix macOS 10.12 deprecation warningsAkemi2016-09-221-9/+9
|
* cocoa: fix charcode retrieving for accented charactersAlexis Nootens2016-02-151-1/+2
| | | | | The handler was retrieving an invalid charcode for accented characters, thus ignoring them.
* mpv_talloc.h: rename from talloc.hDmitrij D. Czarkoff2016-01-111-1/+1
| | | | This change helps avoiding conflict with talloc.h from libtalloc.
* input: add append argument to file drop eventKevin Mitchell2015-08-301-1/+1
| | | | | | This puts in place the machinery to merely append dropped file to the playlist instead of replacing the existing playlist. In this commit, all front-ends set this to false preserving the existing behaviour.
* osx: add NULL check for input context in a missing casewm42015-06-011-1/+2
| | | | Fixes a crash on exit under certain circumstances.
* osx: synchronize access to the input_ctxwm42015-05-261-18/+30
| | | | | | | | | | While all functions of input_ctx are inherently thread-safe, access to the _inputContext field itself is not. It could be unset any time by cocoa_set_input_context(). So even trivial input_ctx calls must be under a lock, so that the input_ctx can not be destroyed while the function call is "starting". (Even a function call in progress wouldn't be fine, because mp_input_uninit() requires the caller to "own" the object, i.e. no other threads can access it at this point.)
* osx: never expose input_ctx from EventsResponderwm42015-05-261-9/+23
| | | | Keep it internal, so we can synchronize access to it properly.
* cocoa: silence -Wlogical-op-parenthesesStefano Pigozzi2015-03-041-1/+1
|
* cocoa: use --idle when running inside bundleStefano Pigozzi2014-12-061-5/+5
| | | | | Previously when using the bundle we used a custom bizarro thing to wait for events. Just use `--idle` and greatly simplify the code.
* cocoa: fix opening reference URLs (.file/id=)Stefano Pigozzi2014-12-011-2/+4
| | | | | | Fixes #1202 /cc @mpv-player/stable
* cocoa: allow to disable apple remote at compile timeStefano Pigozzi2014-10-171-0/+9
| | | | | Actually doesn't remove the related flags so that one can still pass the option with the option doing nothing.
* cocoa: post keydown and keyup events without event monitorStefano Pigozzi2014-10-091-0/+5
| | | | | 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.
* libmpv/cocoa: don't start the event monitorStefano Pigozzi2014-10-091-10/+19
| | | | | | The event monitor is used to get keyboard events when there is no window, but since it is a global monitor to the current process, we don't want it in a library setting.
* cocoa: move handleFilesArray: to macosx_eventsFRAU KOUJIRO2014-08-061-0/+15
|
* cocoa: move set_input_context to macosx_eventsFRAU KOUJIRO2014-08-061-0/+5
|
* cocoa: sync inputContext inside EventsResponderFRAU KOUJIRO2014-08-061-3/+23
|
* cocoa: decouple events from application somewhatFRAU KOUJIRO2014-08-061-16/+62
|
* cocoa: fix key equivalent dispatchingStefano Pigozzi2014-07-301-21/+1
| | | | | | | | | | Prior to this commit we had a list of key modifiers and checked against that. Actually, the Cocoa framework has a built in way to do it and it involves calling performKeyEquivalent: on the menu instance. Fixes #946 cc @mpv-player/stable: this should apply with no conflicts
* Fix OSX build; remove all remaining mpvcore references11rcombs2013-12-171-1/+1
|
* macosx_events: fix null dereference on uninitStefano Pigozzi2013-12-071-1/+4
| | | | | | | Bug introduced by commit 6fb020f5. It doesn't always happen, since it is caused by the playloop and cocoa UI code running in separate threads. Fixes #398.
* options: add option to disable using right Alt key as Alt GrVivek Jain2013-12-021-2/+8
| | | | | | | | | mpv was hardcoded to always consider the right Alt key as Alt Gr, but there are parituclar combinations of platforms and keyboard layouts where it's more convenient to treat the right Alt as a keyboard modifier just like the left one. Fixes #388
* osx: fix -Wshadow warnings on platform specific codeStefano Pigozzi2013-11-041-4/+4
|
* macosx_events: fix modifiers handling with media keysStefano Pigozzi2013-09-051-1/+1
| | | | | | This was caused by a typo. Regression from add7c2955df. Fixes #213
* macosx_events: send a `release all` after key up eventsStefano Pigozzi2013-09-021-0/+2
| | | | | | | | This prevents keys to become stuck due to changing keyboard modifiers during the key down. Not the prettiest approach but event `x11_common` does it like this. Fixes #210
* macosx_events: remove duplicationStefano Pigozzi2013-09-021-29/+33
| | | | refactoring: extract method `handleMPKey:withMask:`
* cocoa: enqueue events only if input context is presentStefano Pigozzi2013-09-011-1/+2
|
* osx: use MP_KEY_* instead of MK_* for media keysStefano Pigozzi2013-09-011-3/+3
| | | | | In 213ad5d6c I added `MK_*` key bindings overlooking the fact that mpv already has `MP_KEY_*` for media keys.
* cocoa: let the core handle key repeatsStefano Pigozzi2013-08-301-2/+14
| | | | | Report key down and key up modifiers to the core so that it can issue it's own key repeats (instead of relying on Cocoa's ones).
* macosx: remove platform specific input queueStefano Pigozzi2013-08-131-13/+3
| | | | | Since last commit the input queue in the core is thread safe, so there is no need for all this platform specific stuff anymore.
* core: move contents to mpvcore (2/2)Stefano Pigozzi2013-08-061-1/+1
| | | | Followup commit. Fixes all the files references.
* cocoa_common: handle keyboard modifiers for mouse eventsStefano Pigozzi2013-07-211-13/+21
|
* cocoa: remove usage of mp_fifoStefano Pigozzi2013-07-031-2/+2
| | | | | | Update Cocoa parts to remove usage of the mp_fifo internal API to send events to the core and use the input context directly. This is to follow commits the work in commits 70a8079c and d603e73c.
* OSX: fix compilation with 10.7 SDKStefano Pigozzi2013-06-191-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | Recent work in the OS X parts of the code started using clang's support for Obj-C's support for Literals and Subscripting. These particular language features remove a lot of boilerplate code and allow to interact with collections as consicely as one would do in scripting languages like Ruby or Python. Even if these are compiler features, Subscripting needs some runtime support. This is provided with libarclite (coming with the compiler), but we need to add the proper method definitions since the 10.7 SDK headers do not include them. That is because 10.7 shipped before this language features. This will cause some warnings when compiling with the 10.7 SDK because the commit also redefines BOOL to make autoboxing/unboxing of BOOL literals to work. If you need to test this for whatever reason on 10.8, just pass in the correct SDK to configure's extra cflags: ./configure --extra-cflags='-mmacosx-version-min=10.7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk' Fixes #117
* macosx_events: handle key modifiers with media keysStefano Pigozzi2013-06-061-26/+55
| | | | | | This was overlooked in the previous inplementation. Adding it required some refactoring of the `handleKeyDown:` method in order to extract common parts with `handleMediaKey:`.
* macosx_events: DRY up key lookup over dictionaryStefano Pigozzi2013-06-051-10/+12
| | | | | Two methods duplicated very similar behaviour. Extract method with the common behaviour.
* macosx_events: make remote property an instance variableStefano Pigozzi2013-06-051-5/+7
| | | | There was no reason for it to be public.
* osx: improve Media Keys supportStefano Pigozzi2013-06-041-15/+98
| | | | | | | | | | | | | | | | | | | | | | | This commit addresses some issues with the users had with the previous implementation in commit c39efb9. Here's the changes: * Use Quartz Event Taps to remove Media Key events mpv handles from the global OS X queue. This prevents conflicts with iTunes. I did this on the main thread since it is mostly idling. It's the playloop thread that actually does all the work so there is no danger of blocking the event tap callback. * Introduce `--no-media-keys` switch so that users can disable all of mpv's media key handling at runtime (some prefer iTunes for example). * Use mpv's bindings so that users can customize what the media keys do via input.conf. Current bindings are: MK_PLAY cycle pause MK_PREV playlist_prev MK_NEXT playlist_next An additional benefit of this implementation is that it is completly handled by the `macosx_events` file instead of `macosx_application` making the project organization more straightforward.
* osx: add Apple Remote supportStefano Pigozzi2013-06-031-2/+59
| | | | | | | | | | | | | | | | | After killing the non functional AR support in c8fd9e5 I got much complaints so this adds AR support back in (and it works). I am using the HIDRemote class by Felix Schwarz and that part of the code is under the BSD license. I slightly modified it replacing [NSApplication sharedApplication] with NSApp. The code of the class is quite complex (probably because it had to deal with all the edge cases with IOKit) but it works nicely as a black box. In a later commit I'll remove the deprecation warnings caused by HIDRemote's usage of Gestalt. Check out `etc/input.conf` for the default bindings. Apple Remote functionality is automatically compiled in when cocoa is enabled. It can be disabled at runtime with the `--no-ar` option.
* osx: implement media keysStefano Pigozzi2013-06-031-0/+19
| | | | | | | | | | | | | | | Media keys are pretty handy if you use mpv as a music player (yes I'm one of those people that do). These are the bindings (which lead to the same behaviour as iTunes): * NX_KEYTYPE_PLAY -> MP_KEY_PLAY * NX_KEYTYPE_FAST -> MP_KEY_NEXT * NX_KEYTYPE_REWIND -> MP_KEY_PREV I just handled these ones as the volume one would be pretty invasive. I could maybe change it to increase the application's volume instead of system volume only when mpv is frontmost (iTunes does this), but some users would probably hate it.
* macosx_events: send all queued eventsStefano Pigozzi2013-06-031-2/+3
| | | | | Seeking feels a little faster or it may be self suggestion. There's really no reason to just send only one event at a time.
* osx: create macosx_events to deal with keyDown eventsStefano Pigozzi2013-06-031-0/+141
On OSX with Cocoa enabled keyDown events are now handled with addLocalMonitorForEventsMatchingMask:handler:. This allows to respond to events even when there is no VO initialized but the GUI is focused.