Commit Graph

258 Commits

Author SHA1 Message Date
Dudemanguy 0bed2a2263 build: remove outdated generated directory
This only existed as essentially a workaround for meson's behavior and
to maintain compatibility with the waf build. Since waf put everything
in a generated subdirectory, we had to put make a subdirectory called
"generated" in the source for meson so stuff could go to the right
place. Well now we don't need to do that anymore. Move the meson.build
files around so they go in the appropriate place in the subdirectory of
the source tree and change the paths of the headers accordingly. A
couple of important things to note.

1. mpv.com now gets made in build/player/mpv.com (necessary because of
   a meson limitation)
2. The macos icon generation path is shortened to
   TOOLS/osxbundle/icon.icns.inc.
2023-07-31 19:00:06 +00:00
Thomas Weißschuh 9efce6d4ae various: drop unused #include "config.h"
Most sources don't need config.h.
The inclusion only leads to lots of unneeded recompilation if the
configuration is changed.
2023-02-20 14:21:18 +00:00
Cœur bb5b4b1ba6 various: fix typos 2022-04-25 09:07:18 -04:00
wm4 07b0c18bad build: change filenames of generated files
Force them into a more consistent naming schema.
2020-06-04 16:59:05 +02:00
der richter 327b092bfc mac, cocoa: fix UI updates on none main queue threads
injecting the Apple Main Thread Checker via
DYLD_INSERT_LIBRARIES=libMainThreadChecker.dylib identified several
problems that needed fixing.
2020-02-22 13:56:31 +01:00
wm4 19bd69e5e3 cocoa_common: remove deprecated VOCTRLs/VO_EVENTs
See commit 4e4252f916 and the following as an example how this would
have to be done if done properly.

Since I'm unable to test on OSX, and nobody is interested in fixing this
code (including myself, actually), just remove the deprecated
definitions to make sure the code still builds. This will break runtime
switching of fullscreen, ontop, border. (The way the minimized state is
reported was also deprecated, but commit 40c2f2eeb0 already broke it
anyway.)
2019-12-12 19:56:03 +01:00
Rodger Combs 1842a932d3 {mac,cocoa}: trim trailing null out of macosx_icon when loading it
This prevents crashes when loading the application icon image.

Suggested-by: Akemi <der.richter@gmx.de>
2018-10-02 00:20:43 +03:00
James Ross-Gowan fab0448c5e Revert "cocoa: re-enable double buffering"
Enabling double buffering fixed some graphical glitches when entering
fullscreen, but it also caused a fullscreen performance regression. We
decided that the glitches were preferable to the performance regression.

This reverts commit cee764849e.
2017-09-22 23:08:46 +10:00
James Ross-Gowan cee764849e cocoa: re-enable double buffering
This causes a performance regression on 10.11 and newer, but the single
buffered method was broken and could cause partially rendered frames to
be presented to the screen.

This reverts 9f30cd8292 and
e543853a7f.
2017-09-21 15:01:22 +02:00
James Ross-Gowan 7897f79217 input: merge mouse wheel and axis keycodes
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
18a45a42d5 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.
2017-09-03 20:31:44 +10:00
Akemi 344b75f52d osx: code cleanups and cosmetic fixes
silence build warnings, clean up code style and remove unused code.
2017-08-18 19:47:47 +02:00
Akemi f550fdaa91 cocoa: add an option to disable the native macOS fullscreen
Fixes #4014
2017-08-06 22:48:26 +02:00
wm4 6b303d5c3c osx: change license of OSX and cocoa files to LGPL
All authors of the current code have agreed.
2017-06-24 16:29:22 +02:00
Akemi 37f0571973 cocoa: properly unhide Dock when quitting during System fs animation
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
2017-05-19 19:19:29 +02:00
Akemi f7637db377 cocoa: fix retrieval of unfs window size while animating
due to the System inherent fullscreen animation the option and the
actual fullscreen state can be out of sync, leading to a wrongly
reported unfs window size in the time of the animation.

just always fall back to the window size, we keep track of, when we
either are in fullscreen or are currently switching to it.

Fixes #4323
2017-04-17 02:45:26 +02:00
Akemi c083a7f53e cocoa: fix retrieval of unfs window size
there are two minor bugs. mpv could try to retrieve the size when in
fullscreen and would get the fullscreen size. to fix that we keep track
of the window size before going into fullscreen.

the second small bug is when using HiDPI resolution and the
--hidpi-window-scale option. we actually want the OSD to show the proper
window scale depending on the hidpi settings. before when resizing the
window to double the size it could show "window-scale: 1.0" or
"window-scale: 0.5" when resizing to normal size. now it considers the
backing scale factor and the hidpi option to return a logical correct
window size.
2017-03-26 20:41:20 +02:00
Akemi 063ca8f0fe osx: fix key input in certain circumstances
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.
2017-03-26 20:38:26 +02:00
Akemi 7bddd3fb4c cocoa: fix autofit options on HiDPI resolutions without HiDPI scaling
Fixes #4194
2017-03-09 17:57:07 +01:00
Akemi 9bd819a0bc cocoa: fix segfault in certain circumstances
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.
2017-02-27 23:57:44 +01:00
Akemi c824a023c4 cocoa: fix dragging out of focus window
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
2017-02-21 19:26:33 +01:00
Akemi fffab30a3e cocoa: only report mouse movements when window is not being dragged
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.
2017-02-20 17:26:56 +01:00
Akemi bdd096db9a cocoa: make window draggable on init
fixes the case when mpv is opened and the cursor is within the window
bounds without moving the mouse. previously the window could only be
dragged around after the first mouse movement.
2017-02-20 17:25:42 +01:00
Akemi 72d90f911a cocoa: simplify the cursor hiding code
we can simplify the code because we don't need to change the bool
pointer we were given by the VOCTRL_SET_CURSOR_VISIBILITY event. i
assume this was done to work around some bugs previously to the recent
cursor refactor. i kept that because i thought it was necessary, which
wasn't in the end. after the refactor it only caused some weirdnesses i
tried to work around. without it we can get rid of some special cases
and simplify the code quite a bit.
2017-02-19 17:54:06 +01:00
Akemi 9ac05a575c cocoa: refactor mouse events and cursor visibility
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
2017-02-16 22:22:11 +01:00
Akemi 9a45932984 cocoa: fix black edges on live resize
this fixes a small bug with black edges on live resize, due to the
synchronisation with the DisplayLink. we just pause the DisplayLink for
the duration of the live resize. i also added some convenience functions
for reoccurring calls and simplified some DisplayLink related screen
info.
2017-02-13 22:52:47 +01:00
Akemi 64b0d81c32 cocoa: add --ontop-level option for modifying ontop window level
since there are different views on what ontop is, we make the ontop
window level modifiable. at the moment only support for macOS was added.
the default for macOS was changed from 'system' to 'window' since this
fixes an unwanted behaviour in fullscreen and in general causes less
issues with expected behaviour.

Fixes #2376 #3974
2017-02-13 22:49:11 +01:00
Akemi d11c03faee cocoa: fix color profile retrieval
when the color profile was changed it used the right NSScreen but with
the old colorSpace. this was optimised out by a previous commit because
of a wrong assumption. we need to update the screen so we can get the
new colorSpace. this adds a bit of redundancy since on screen change it
will update screen pointer twice.
2017-02-02 16:31:28 +01:00
Akemi 6da224b1dd cocoa: optimise screen event handling
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.
2017-02-02 16:22:27 +01:00
Akemi f39a1cb1b0 cocoa: fix displaylink refresh rate retrieval
we are dealing with several problems here, which weren't apparent
because we always initialised a new displaylink for the display refresh
rate retrieval, previously to commit 449eb20 and bug 9490b62.

just changing the display with CVDisplayLinkSetCurrentCGDisplay
can cause inconsistent refresh rates and discontinuity in timestamps.
this can either lead to bogus values for the Actual display refresh rate
or retrieving the refresh rate of the previous display if we immediately
try to get a new value. since the Actual refresh rate is computed i
assume that it at least needs one refresh period to actual return
something useful.

furthermore when changing the screen and updating the displaylink, it
seems that the retrieved refresh rates for the screen mpv wasn't opened
on are being estimated in a sub-optimal way. as an example, when moving
my window to my second screen the Actual refresh rate was always a
constant 60Hz, even though it is supposed to fluctuate a little bit.
though if mpv was started on the secondary screen the Actual refresh
rate fluctuated around 59.94Hz like expected. in that case my primary
screen always reported a constant 60Hz instead.

for the first problem we moved the actual retrieval of the refresh rate
to the very last moment when mpv actual requests a new value and not
when the refresh rate changed. we only update the displaylink itself
when a possible refresh rate change is detected. this gives the
displaylink some time to calculate the new refresh rate. for the second
problem, instead of setting the new display we completely uninitialise
the old dislaylink and create a new one for the new screen. this gives
us properly estimated refresh rates.

additionally we also optimised the display refresh rate fallback
heuristic. it will never be 0 anymore and we prevent it from returning
bogus values with a simple threshold for the difference of the Actual
and Nominal refresh rate.
2017-02-02 16:22:27 +01:00
Akemi 954625c165 cocoa: fix unwanted behavior with window level other than the default
setting a window level other than NSNormalWindowLevel always sets
NSWindowCollectionBehaviorTransient, which prevents certain things to
work properly. examples are automatic switching to the active Space when
mpv is made active and (de-)miniaturizing. latter always lead to a
vanishing window.

Fixes #1757 #1884
2017-01-29 19:46:53 +01:00
Akemi 9490b628c5 cocoa: don't init displaylink on reconfig
everytime we switched to a new video file a new displaylink was
initialised and started, but the old one was not stopped and released
beforehand. this lead to several displaylink callback calls per swap,
depending on how many files were switched beforehand. moving the
displaylink init call to the cocoa init functions will ever only init
one displaylink.

Fixes #4031
2017-01-19 14:58:15 +01:00
Akemi fe02e5023c cocoa: move updateBorder method to the protocol
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.
2017-01-19 14:54:22 +01:00
Akemi fee5ceccad cocoa: don't change Space on quit in fullscreen
circumvent undefined behavior when quitting in
fullscreen.

Fixes #3957
2017-01-11 15:00:47 +01:00
Akemi 449eb208f4 cocoa: rate limit video output
the display refresh rate can't be estimated
correctly in some cases and just increases till it
turns off display-resample. cases are
off-screen rendering (different space), mpv
being completely hidden behind another window or
the mission control view.
this utilise the unused displaylink callback to
limit the refresh rate to the actual display
refresh rate.
2017-01-11 14:20:32 +01:00
Akemi 46b74a38f1 cocoa: add border cycling
Fixes #2430
2017-01-11 14:17:33 +01:00
Akemi a05c5b4ec6 cocoa: fix handling of geometry option
This flips the y-coordinate to be consistent with
other platforms and the manual. furthermore it
fixes an unwanted behaviour of the cocoa
convertRectFromBacking method, where the x- and
y-coordinate was divided by the same factor as the
width and height instead of placing the new scaled
rectangle at the same relative position as the
original unscaled rectangle, by manually
calculating the new position.

Fixes #3867
2017-01-11 14:15:10 +01:00
Akemi 2b8b17402e cocoa: cosmetic fixes 2016-12-16 16:32:26 +01:00
Akemi a8347eb9ba cocoa: fullscreen refactoring
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
2016-12-15 20:55:16 +01:00
Akemi aceeeaf9bb cocoa: option to scale window by HiDPI scale factor
Deactivating this options makes it possible to
circumvent the default OS X behavior of using
points. Windows on HiDPI resolutions won't open
in double the size anymore and videos are display
in their native resolution when windowed.

Fixes #3716
2016-11-11 21:37:04 +01:00
Akemi e543853a7f cocoa: add glFlush() to cocoa backend
The glFlush() call was made optional recently
since it's not needed in most cases. On OSX though
this is needed since we removed kCGLPFADoubleBuffer
from the context creation, so the glFlush() call
was added to the cocoa backend only.
The CGLFlushDrawable() call can be safely removed
since it only does something when a double
buffered context is used. Also fixes a small typo.
Fixes #3627.
2016-10-06 19:50:25 +02:00
Akemi 9df797575f cocoa: fix macOS 10.12 deprecation warnings 2016-09-22 13:46:27 +02:00
wm4 591e21a2eb osdep: rename atomics.h to atomic.h
The standard header is stdatomic.h, so the extra "s" freaks me out every
time I look at it.
2016-09-07 11:26:25 +02:00
wm4 4d75514321 vo: change messy handling of fullscreen and other flags
Before this commit, all VOs had to toggle the option flag themselves,
now command.c does it.

I can't really comprehend why it required every VO to do this manually.
Maybe it was for rejecting the property/option change if the VO didn't
support a specific capability. But then it could have checked the VOCTRL
result. In any case, I don't care, and successfully changing the
property without doing anything (With some VOs) is fine too. Many things
work this way now, and it's simpler overall.

This change will be useful for cleaning up VO option handling.
2016-08-30 23:52:16 +02:00
Akemi f53c7f1a78 cocoa: remove unused icc profile variables 2016-07-21 08:48:45 +02:00
Akemi 7531275f62 cocoa: update screen fps only if necessary
we don't need to update the display refresh rate
when going fullscreen or updating the colour profile
2016-07-21 08:48:37 +02:00
Akemi 47d9fbd133 cocoa: fix display refresh rate retrieval on multi monitor setups
1. this basically reverts commit de4c74e5a4.
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.
2016-06-18 19:15:36 +02:00
Akemi fb7c5804bb cocoa: fix actual display refresh rate retrieval
We have two problems here.
1. CVDisplayLinkGetActualOutputVideoRefreshPeriod, like the name suggests,
returns a frame period and not a refresh rate. using this as screen_fps
just leads to a slideshow. why didn't this break video playback on OS X
completely? the answer to this leads us to the second problem.
2. it seems that CVDisplayLinkGetActualOutputVideoRefreshPeriod always
returns 0 if used without CVDisplayLinkSetOutputCallback and hence always
fell back to CVDisplayLinkGetNominalOutputVideoRefreshPeriod. adding a
callback to CVDisplayLink solves this problem. the callback function at
this moment doesn't do anything but could possibly used in the future.
2016-06-18 19:15:34 +02:00
Stefano Pigozzi de4c74e5a4 cocoa: use displaylink without manually tracking the display id
Maybe it partially helps with #2392 (on dual display setups). Either way, it
makes the code simpler.
2016-06-11 11:58:07 +02:00
Stefano Pigozzi bc1dce5d5b cocoa: get fps only from dislaylink
In my tests, CGDisplayModeGetRefreshRate returns 24.0 even though the nominal
one is set to 24000/1001. This is obviously not good for video.
2016-01-14 11:11:43 +01:00
Stefano Pigozzi 0fad73862c cocoa: add an observer for screenmode change 2016-01-14 11:11:43 +01:00