Commit Graph

11 Commits

Author SHA1 Message Date
Stefano Pigozzi a31422bbfe macosx_application: refactor psn matching code
Objective-C is shorter / more readable than snprintf.
2013-05-30 23:03:20 +02:00
Stefano Pigozzi 8b40494e93 macosx_application: refactor filename escape
Use Objective-C's new literal syntax to make the code simpler.
2013-05-30 23:03:20 +02:00
Stefano Pigozzi 1d11db6596 macosx_application: use @autoreleasepool
I don't even want to know how this worked. It scares me a lot.
2013-05-30 23:01:12 +02:00
Stefano Pigozzi 3396e0565b macosx_application: move escape_loadfile_name in this file
This allows to move back osx_common to raw C.
2013-05-30 23:01:12 +02:00
Stefano Pigozzi 41e6c922a5 macosx_application: fix menu 'ghosting'
This fixes a bug that caused the application to never leave it's frontmost
position.

The idea is stolen from @donmelton who used it in MPlayerShell. Thanks!
2013-05-26 23:46:50 +02:00
Stefano Pigozzi 29f5429223 macosx_application: implement "Quit & remember position"
Add a menu item to quit and save the current playback position using the code
added with commit ce9a854.

Fixes #85
2013-05-23 20:07:14 +02:00
wm4 58cc0f637f input: do property expansion for all input command string arguments
Also add a "raw" prefix for commands, which prevents property expansion.
The idea is that if the commands are generated by a program, it doesn't
have to know whether the command expands properties or not.
2013-05-18 17:45:55 +02:00
Stefano Pigozzi 6a83ef1552 macosx_application: fix crash when quitting player
mpv crashed on quit when it was run using the bundle functionality and started
without any files thus waiting for file open events. In that case, since there
is no key_fifo initialized yet, short circuit to `terminate_cocoa_application()`
which is generally called from `exit_player()` during normal lifecycle.

Fixes bug report from user `eng` on IRC.
2013-05-12 20:29:23 +02:00
Stefano Pigozzi 6a14dd593f macosx_application: add menu item for hide operation
Fixes #35
2013-05-12 15:27:54 +02:00
Stefano Pigozzi 134f3e97bf OSX: run native event loop in a separate thread
This commit is a followup on the previous one and uses a solution I like more
since it totally decouples the Cocoa code from mpv's core and tries to emulate
a generic Cocoa application's lifecycle as much as possible without fighting
the framework.

mpv's main is executed in a pthread while the main thread runs the native cocoa
event loop.

All of the thread safety is mainly accomplished with additional logic in
cocoa_common as to not increase complexity on the crossplatform parts of the
code.
2013-05-12 15:27:54 +02:00
Stefano Pigozzi afdc9c4ae2 OSX: use native Cocoa's event loop
Schedule mpv's playloop as a high frequency timer inside the main Cocoa event
loop. This has the benefit to allow accessing menus as well as resizing the
window without the playback being blocked and allows to remove countless hacks
from the code that involved manually pumping the event loop as well simulating
manually some of the Cocoa default behaviours.

A huge improvement consists in removing NSApplicationLoad. This is a C function
defined in the Cocoa header and implements a minimal OSX application under ther
hood so that you can use the Cocoa GUI toolkit from C/C++ without having to
respect the Cocoa standards in terms of application initialization. This was
bad because the behaviour implemented by NSApplicationLoad was hard to customize
and had several gotchas especially in the menu department.

mpv was changed to be just a nib-less application. All the Cocoa part is still
generated in code but the event handling is now not dissimilar to what is
present in a stock Mac application.

As a part of reviewing the initialization process, I also removed all of
`osdep/macosx_finder_args`. The useful parts of the code were moved to
`osdep/macosx_appication` which has the broaded responsibility of managing the
full lifecycle of the Cocoa application. By consequence the
`--enable-macosx-finder` configure switch was killed as well, as this feature
is always enabled.

Another change the users will notice is that when using a bundle the `--quiet`
option will be inserted much earlier in the initializaion process. This results
in mpv not spamming mpv.log anymore with all the initialization outputs.
2013-05-12 15:27:54 +02:00