Commit Graph

121 Commits

Author SHA1 Message Date
wm4 836893fed9 cocoa: don't use VOCTRL_UPDATE_SCREENINFO 2014-05-06 22:00:17 +02:00
Martin Herkt b54c963258 options: rename video-related options/properties
Renamed options:
--aspect    → --video-aspect
--fstype    → --x11-fstype
--native-fs → --fs-missioncontrol
--name      → --x11-name

Renamed properties:
aspect → video-aspect
2014-05-04 02:46:11 +02:00
Stefano Pigozzi 9d0c1d6913 cocoa: refactor sync scheduling to a function
This extracts the scheduling logic to a single function which is nicer to keep
it consistent.

Additionally make sure we don't schedule sync operations from a sync operation
itself since that could cause deadlocks (even if it should not be happening
with the current code).
2014-04-28 21:51:04 +02:00
Ryan Goulden 80ec0bac43 cocoa: move sync section assignments in vo_control 2014-04-28 21:32:58 +02:00
Ryan Goulden 4d8489efae cocoa: cosmetics: use NSMakeSize 2014-04-28 21:32:58 +02:00
Ryan Goulden 2878c2a914 cocoa: fix native fullscreen
This fixes a couple of issues with the Cocoa `--native-fs` mode, primarily:

 - A ghost titlebar at the top of the screen in full screen:

   This was caused by the window constraining code kicking in during
   fullscreen. Simply returning the unconstrained rect from the constraining
   method fixes the problem.

 - Incorrect behavior when using the titlebar buttons to enter/exit
   fullscreen, as opposed to the OSD button.

   This was caused by mpv's internal fullscreen state going out of sync with
   the NSWindow's one. This was the case because `toggleFullScreen:`
   completely bypassed the normal event flow that mpv expects.

Signed-off-by: Ryan Goulden <percontation@gmail.com>

Change style for mpv, simplify and refactor some of the constraining code.

Signed-off-by: Stefano Pigozzi <stefano.pigozzi@gmail.com>
2014-04-28 21:32:58 +02:00
Stefano Pigozzi b0ee9334e3 vo_opengl, cocoa: allow to autoselect a color profile
This commit adds support for automatic selection of color profiles based on
the display where mpv is initialized, and automatically changes the color
profile when display is changed or the profile itself is changed from
System Preferences.

@UliZappe was responsible with the testing and implementation of a lot of this
commit, including the original implementation of `cocoa_get_icc_profile_path`
(See #594).

Fixes #594
2014-03-31 22:07:33 +02:00
wm4 38d29c487c vo: merge get rid of vo.aspdat field
Rename vo_get_src_dst_rects() to mp_get_src_dst_rects() and make it
independent from the VO (it takes a comical amount of parameters now to
pass all required state). Add a convenience wrapper with the name
vo_get_src_dst_rects() to vo.c. Replace all aspdat and vo usages with
immediate parameters.

Functionally, nothing should change, except that the window size is
clamped to a minimum of size 1 much earlier, and some log messages
change the prefix (don't bother with vo.vo_log stuff).
2014-01-22 00:35:52 +01:00
Stefano Pigozzi 369e88c99b cocoa: remove dead code
This became dead code in commit 3f594c2e.
2014-01-21 23:32:07 +01:00
wm4 d956bbc065 video/out: simplify monitor aspect handling
For some reason, this made all VO backends both set the screen
resolution in opts->screenwidth/height, and call
aspect_save_screenres(). Remove the latter. Move the code to calculate
the PAR-corrected window size from aspect.c to vo.c, and make it so that
the monitor PAR is recalculated when it makes sense.
2014-01-11 18:58:06 +01:00
Stefano Pigozzi 6a3ab66427 cocoa: fix window placement on secondary screens
For a long time the cocoa backend set the xinerama_x/y and used dx/dy from the
VO instance. This somewhat worked with some workarounds but wasn't really
what was supposed to be happening. Moreover 27e4360, which touched this
workaround introduced a regression.

New code doesn't set the xinerama_x/y values so that dx/dy are offsets in the
current screen (not a virtual screen composed of all the screens). The screen
reference detected during VOCTRL_UPDATE_SCREENINFO is also passed down to the
window initialization code.

Fixes #472
2014-01-11 14:06:40 +01:00
Stefano Pigozzi 27e4360b0b cocoa: refactor init window positioning code 2014-01-10 20:39:25 +01:00
Stefano Pigozzi 48e3344f84 cocoa: don't reset window size when the video size doesn't change
Fixes #459
2014-01-06 14:19:04 +01:00
Stefano Pigozzi 1e988c595b cocoa: handle files drag and drop on the player video view 2014-01-04 17:29:53 +01:00
Stefano Pigozzi b205e63cdc Revert "cocoa: unlock on uninit"
Not sure why but this doesn't seem to be needed anymore.

This reverts commit 6ead6aa005.
2013-12-26 22:26:41 +01:00
Stefano Pigozzi a410a750c7 cocoa: sanitize window title string and guard against NULL
If the utf8 string used to create the NSString for title was invalid utf8,
-stringWithUTF8String returned nil and triggered an assertion in Cocoa's
framework code.

Sanitize the utf8 string and if the sanitation wasn't enough just avoid
crashing by not setting a title.

Fixes #406
2013-12-25 18:13:09 +01:00
11rcombs ad92c893a0 Fix OSX build; remove all remaining mpvcore references 2013-12-17 08:44:21 +01:00
agiz a066dae19e cocoa: make borderless window resizable
Fixes #399
2013-12-07 15:43:49 +01:00
Stefano Pigozzi 6ead6aa005 cocoa: unlock on uninit
NSLock should be unlocked before dealloc is called on it.
2013-11-26 20:50:35 +01:00
Stefano Pigozzi 3f594c2e84 cocoa: use window-scale to support video scaling functionality
In the cocoa backend you can use cmd+0/1/2 to scale the window. This commit
makes it use the new window-scale functionality.
2013-11-22 08:43:02 +01:00
Stefano Pigozzi ede608ed43 cocoa: implement window-scale 2013-11-22 08:41:34 +01:00
Stefano Pigozzi 3b156caf78 cocoa: set and clear gl context inside of sync sections
The code did not set and unset the current context inside sync sections. I am
not sure if this was an actual problem but this is better since the context is
linked to a single thread. In my brief tests this seems to avoid garbage to
show up in fullscreen.
2013-10-20 21:25:55 +02:00
Stefano Pigozzi 8d5f800567 cocoa: make --ontop also cover dock+menubar
This only shows any differences when mpv isn't frontmost and is in fullscreen.
Cmd+Tab overlay is still at a higher level as to avoid complete usability fail.
2013-10-12 21:02:46 +02:00
Stefano Pigozzi 89fced63b8 cocoa_common: add OS X 10.7 compatibility hacks includes
I forgot these when I split the code. They will hopefully fix compilation on
10.7.
2013-10-05 14:40:48 +02:00
Stefano Pigozzi 9d3943840c cocoa_common: call gl_clear indirectly
glClear needs GL headers and we don't want those in `cocoa_common`. Create
a callback in `gl_cocoa` and register it `cocoa_common`.

Fixes #264
2013-09-28 15:08:40 +02:00
Stefano Pigozzi 73808cd8f0 cocoa_common: fix deadlock
After rebasing my dev branch it turned out that  the code deadlocked on
recursive calls of `vo_control`. Make the locking code a little bit smarter
by making always skip locking/unlocking if we are executing a chunck of
code that is already synchronized with `dispatch_sync`.
2013-09-28 15:08:26 +02:00
Stefano Pigozzi 0ab9634eb3 cocoa_common: split the code, refactoring and cleanups
Split the code to several files. The GUI elements now each have they own files
and private state. The original code was a mess to respect the retarded mplayer
convention of having everything in a single file.

This commit also seems to fix the long running bug of artifacts showing
randomly when going fullscreen using nVidia GPUs.
2013-09-28 11:20:00 +02:00
Stefano Pigozzi bb4ea8bb3e cocoa_common: signal a mouse movement when changing window size
This is mainly to avoid spurious cursor states due to the mouse moving inside
or outside the window as a result of the window resize (with cmd-0/1/2).

This avoids complex logic and triggers a mouse move so that the player
recomputes the correct cursor state based on the autohide configuration of
the user.
2013-09-18 19:05:00 +02:00
Stefano Pigozzi a08802016d cocoa_common: override core's cursor visibility state
This keeps the state in sync with the current state in cocoa_common. Infact the
cocoa code in mpv can decide wether it really wants to hide the cursor based on
the result of the `canHideCursor` method (this is so that the cursor is only
hidden when hovering on the video window).
2013-09-18 19:05:00 +02:00
Stefano Pigozzi 49849190dd cocoa_common: remove most of the special handling for cursor autohide
This is mostly related to the fullscreen behaviour. cecbd8864 introduces an
option to make mpv behave like a OSX user would expect. This commit changes
the Cocoa parts of the code to be consistent with the behaviour on X11. Old
behaviour is still available through the option mentioned in cecbd8864.

There is still custom logic in the cocoa backend and it can probably be moved
to core:

  * Don't perform autohide if the mouse is down
  * Don't perform autohide outside of the video window

Fixes #218 (by accident)
2013-09-10 21:24:37 +02:00
Stefano Pigozzi 39a69aeb89 cocoa_common: remove unlocking from fullscreen function
This was added in the past to prevent a deadlock, but is not needed
anymore.
2013-09-02 08:35:21 +02:00
Stefano Pigozzi 694654e383 cocoa_common: avoid the opengl view to leak it's state
Just because everything is in a single file it doesn't excuse us to have high
coupling between C and ObjC code.
2013-09-02 08:21:03 +02:00
Stefano Pigozzi ddd873902a cocoa_common: enable click-through on the video view
Generate a mouse down event on the first click so that one can interact
with the OSC directly as opposed to wasting the first click in order to focus
the window.
2013-09-01 16:10:57 +02:00
Stefano Pigozzi c686e270a1 cocoa_common: track mouse move events when not focused
This is really only important with the OSC and makes the tracking code behave
more consistently with the X11 one.
2013-09-01 16:10:37 +02:00
Stefano Pigozzi d3c4ba3ab8 cocoa_common: autohide dock when autohiding menubar
A cocoa bug doesn't allow to do otherwise. Will open a radar later.
2013-08-26 20:01:20 +02:00
Stefano Pigozzi fcde6207a1 cocoa_common: avoid locking calls when not needed
cocoa_common contains some locking calls to support video outputs that support
live resizing (at this moment only vo=opengl).

These should not be used unless the VO declares it is multithreaded by
registering the resize_redraw callback used for live resizing.

Fixes #200
2013-08-23 13:58:38 +02:00
Stefano Pigozzi acbf5e826a cocoa_common: fix window positioning with `--geometry`
Regression since ff3b98d11c. The window positioning code relied on the
visibleFrame's height without taking into account the dock's presence.

Also moved the constraining code to the proper method that overrides the
original NSWindow behaviour. This avoids having to check for border since the
constraining is performed by Cocoa only for titled windows.

Fixes #190
2013-08-22 11:54:28 +02:00
Stefano Pigozzi 04cdc205bc cocoa_common: add precise scrolling support
This adds precise scrolling support. I ran some tests and it seems a little
bit smoother and well.. precise. The defaults are rebindable using: AXIS_UP,
AXIS_DOWN, AXIS_LEFT and AXIS_RIGHT.
2013-08-13 23:05:46 +02:00
Stefano Pigozzi 406241005e core: move contents to mpvcore (2/2)
Followup commit. Fixes all the files references.
2013-08-06 22:52:31 +02:00
Stefano Pigozzi 94df9ef797 cocoa_common: use new log API 2013-08-01 08:23:53 +02:00
Stefano Pigozzi ff3b98d11c cocoa_common: simplify resize code
This introduces some changes in resize behaviour. Most importantly the window
frame is not constrained to it's screen's `visibleFrame`. Anyone who still wants
that kind of behaviour when opening a video, can use `--autofit-larger`.

Even though the size of the window is not constrained, it's position is, so
that the titlebar will always be visible. When using `--no-border` even the
position will not be constrained in any way.
2013-07-30 20:02:48 +02:00
Stefano Pigozzi 644451f4d9 cocoa_common: fix regression in draggable state computation
Regression introduced in 8fb064de5. Prevented the OSC from working correctly.
2013-07-21 21:02:44 +02:00
Stefano Pigozzi 73cd78f8c5 cocoa_common: fix style 2013-07-21 21:02:43 +02:00
Stefano Pigozzi 7c1d707f45 cocoa_common: move tracking area setup to updateTrackingAreas
This makes the tracking area work when going in and out of fullscreen.
2013-07-21 21:02:43 +02:00
Stefano Pigozzi 5f265d5930 cocoa_common: handle keyboard modifiers for mouse events 2013-07-21 10:49:27 +02:00
Stefano Pigozzi 7088fe3fec cocoa_common: make the fullscreen transition only when necessary
This makes the cocoa backend follow more closely the new fullscreen semantics
added in c4b08a9a.
2013-07-20 12:08:14 +02:00
Stefano Pigozzi 8fb064de58 cocoa_common: use a tracking area to handle mouse events
This change which also flipse the coordinate system of the view, greatly
simplifies the mouse event handling code.

There are still some uglities mostly related to the cursor visibility
code. For instance the core doesn't show the cursor when it receives a mouse
leave event.
2013-07-20 11:45:32 +02:00
Stefano Pigozzi 2765153214 cocoa_common: fix typo in comment
Surely it's copy pasta's fault.
2013-07-20 11:44:06 +02:00
Stefano Pigozzi 20c0231f02 cocoa_common: implement MP_MOUSE_LEAVE notifications
This is needed for the OSC. At the moment I'm sending a notification for any
mouse movement outside of the video surface. This might be overkill.
2013-07-20 11:44:06 +02:00
Stefano Pigozzi 891e092669 cocoa_common: implement conditional video dragging
This was more roundabout than expected, since it looks like the framework
caches isMovabileByWindowBackground so in mpv's case it's needed to set it
with setMovableByWindowBackground.
2013-07-20 11:44:06 +02:00