summaryrefslogtreecommitdiffstats
path: root/video/out/cocoa_common.m
Commit message (Collapse)AuthorAgeFilesLines
* cocoa: set and clear gl context inside of sync sectionsStefano Pigozzi2013-11-021-6/+6
| | | | | | | 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.
* cocoa: make --ontop also cover dock+menubarStefano Pigozzi2013-10-121-1/+3
| | | | | 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.
* cocoa_common: add OS X 10.7 compatibility hacks includesStefano Pigozzi2013-10-051-0/+1
| | | | | I forgot these when I split the code. They will hopefully fix compilation on 10.7.
* cocoa_common: call gl_clear indirectlyStefano Pigozzi2013-09-281-2/+11
| | | | | | | 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
* cocoa_common: fix deadlockStefano Pigozzi2013-09-281-5/+7
| | | | | | | 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`.
* cocoa_common: split the code, refactoring and cleanupsStefano Pigozzi2013-09-281-503/+162
| | | | | | | | | 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.
* cocoa_common: signal a mouse movement when changing window sizeStefano Pigozzi2013-09-181-0/+8
| | | | | | | | | 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.
* cocoa_common: override core's cursor visibility stateStefano Pigozzi2013-09-181-3/+5
| | | | | | | 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).
* cocoa_common: remove most of the special handling for cursor autohideStefano Pigozzi2013-09-101-17/+3
| | | | | | | | | | | | | | | 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)
* cocoa_common: remove unlocking from fullscreen functionStefano Pigozzi2013-09-021-12/+0
| | | | | This was added in the past to prevent a deadlock, but is not needed anymore.
* cocoa_common: avoid the opengl view to leak it's stateStefano Pigozzi2013-09-021-7/+13
| | | | | Just because everything is in a single file it doesn't excuse us to have high coupling between C and ObjC code.
* cocoa_common: enable click-through on the video viewStefano Pigozzi2013-09-011-0/+1
| | | | | | 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.
* cocoa_common: track mouse move events when not focusedStefano Pigozzi2013-09-011-1/+1
| | | | | This is really only important with the OSC and makes the tracking code behave more consistently with the X11 one.
* cocoa_common: autohide dock when autohiding menubarStefano Pigozzi2013-08-261-1/+5
| | | | A cocoa bug doesn't allow to do otherwise. Will open a radar later.
* cocoa_common: avoid locking calls when not neededStefano Pigozzi2013-08-231-2/+2
| | | | | | | | | | 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
* cocoa_common: fix window positioning with `--geometry`Stefano Pigozzi2013-08-221-10/+5
| | | | | | | | | | | 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
* cocoa_common: add precise scrolling supportStefano Pigozzi2013-08-131-16/+11
| | | | | | 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.
* core: move contents to mpvcore (2/2)Stefano Pigozzi2013-08-061-3/+3
| | | | Followup commit. Fixes all the files references.
* cocoa_common: use new log APIStefano Pigozzi2013-08-011-7/+11
|
* cocoa_common: simplify resize codeStefano Pigozzi2013-07-301-51/+16
| | | | | | | | | | 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.
* cocoa_common: fix regression in draggable state computationStefano Pigozzi2013-07-211-0/+1
| | | | Regression introduced in 8fb064de5. Prevented the OSC from working correctly.
* cocoa_common: fix styleStefano Pigozzi2013-07-211-2/+2
|
* cocoa_common: move tracking area setup to updateTrackingAreasStefano Pigozzi2013-07-211-14/+13
| | | | This makes the tracking area work when going in and out of fullscreen.
* cocoa_common: handle keyboard modifiers for mouse eventsStefano Pigozzi2013-07-211-47/+51
|
* cocoa_common: make the fullscreen transition only when necessaryStefano Pigozzi2013-07-201-5/+16
| | | | | This makes the cocoa backend follow more closely the new fullscreen semantics added in c4b08a9a.
* cocoa_common: use a tracking area to handle mouse eventsStefano Pigozzi2013-07-201-33/+52
| | | | | | | | | 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.
* cocoa_common: fix typo in commentStefano Pigozzi2013-07-201-1/+1
| | | | Surely it's copy pasta's fault.
* cocoa_common: implement MP_MOUSE_LEAVE notificationsStefano Pigozzi2013-07-201-0/+2
| | | | | 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.
* cocoa_common: implement conditional video draggingStefano Pigozzi2013-07-201-14/+30
| | | | | | 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.
* video: remove fullscreen flags chaoswm42013-07-181-15/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There was a MPOpts fullscreen field, a mp_vo_opts.fs field, and VOFLAG_FULLSCREEN. Remove all these and introduce a mp_vo_opts.fullscreen flag instead. When VOs receive VOCTRL_FULLSCREEN, they are supposed to set the current fullscreen mode to the state in mp_vo_opts.fullscreen. They also should do this implicitly on config(). VOs which are capable of doing so can update the mp_vo_opts.fullscreen if the actual fullscreen mode changes (e.g. if the user uses the window manager controls). If fullscreen mode switching fails, they can also set mp_vo_opts.fullscreen to the actual state. Note that the X11 backend does almost none of this, and it has a private fs flag to store the fullscreen flag, instead of getting it from the WM. (Possibly because it has to deal with broken WMs.) The fullscreen option has to be checked on config() to deal with the -fs option, especially with something like: mpv --fs file1.mkv --{ --no-fs file2.mkv --} (It should start in fullscreen mode, but go to windowed mode when playing file2.mkv.) Wayland changes by: Alexander Preisinger <alexander.preisinger@gmail.com> Cocoa changes by: Stefano Pigozzi <stefano.pigozzi@gmail.com>
* cocoa_common: change video size when changing screen DPIStefano Pigozzi2013-07-101-0/+8
| | | | | This improves the situation when moving a window from screens with different DPIs.
* core: remove mp_fifo leftoverswm42013-07-041-1/+0
|
* input: require VOs to send key up events, redo input key lookupwm42013-07-021-2/+2
| | | | | | | | | | | | | | Making key up events implicit was sort-of a nice idea, but it's too tricky and unreliable and makes the key lookup code (interpret_keys()) hard to reason about. See e.g. previous commit for subtle bugs and issues this caused. Make key-up events explicit instead. Add key up events to all VOs. Any time MP_KEY_STATE_DOWN is used, the matching key up event must use MP_KEY_STATE_UP. Rewrite the key lookup code. It should be simpler and more robust now. (Even though the LOC increases, because the new code is less "compact".)
* cocoa_common: uninit fs window properlyStefano Pigozzi2013-06-291-0/+3
| | | | | | | | In fullscreen `s->window` is the windowed window. So freeing that didn't get rid of the FS window and OpenGL view. Fixes #122 [ci skip]
* cocoa_common: schedule a redraw frame after a non live resizeStefano Pigozzi2013-06-251-3/+18
| | | | | | | | | | | A redraw forces recalculation of panscan and other stuff not accounted for in the resize_redraw codepath. This is actually a hack but works really well in my tests. Thanks @wm4 and @Cpuroast for the idea. Fixes #86 [ci skip]
* OSX: fix compilation with 10.7 SDKStefano Pigozzi2013-06-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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
* cocoa_common: implement VOCTRL_UPDATE_WINDOW_TITLEStefano Pigozzi2013-06-161-2/+11
| | | | | Unfortunately this backend creates the window lazily and a call to `cocoa_set_window_title` is needed inside config.
* cocoa_common: remove play/pause VOCTRL functionsStefano Pigozzi2013-06-141-12/+2
| | | | | Make VOCTRL_RESTORE_SCREENSAVER / VOCTRL_KILL_SCREENSAVER use the power management functions directly.
* core: introduce separate VOCTRLs for screensaver stop/resumewm42013-06-141-3/+2
| | | | | | | | | | | | | | | | | | | | | | This is slightly better because VOCTRL_RESUME/VOCTRL_PAUSE are usually needed by VOs to know whether video is actually being played (for whatever reason), and they wouldn't be passed to the backend's VOCTRL handler, like vo_x11_control(). Also try to make sure that these flags (both pause state and screensaver state) are set consistently in some corner cases. For example, it seems enabling video in the middle of playing a file while the player is paused would not set the paused flag. If codec initialization fails, destroy the VO instead of keeping it around to make sure the state is consistent. Framestepping is implemented by unpausing the player for the duration of a frame. Remove the special handling of VOCTRL_PAUSE/RESUME in these cases. It was most likely needed because these VOCTRLs used to be important for screen redrawing (blatant guess), which is now handled completely differently. The only potentially bad side-effect is that the screensaver will be disabled/reenabled for the duration of one frame.
* cocoa_common: fix ontop switching when fullscreenStefano Pigozzi2013-06-111-2/+2
| | | | | | | `enterFullScreenMode:withOptions:` creates another window so set the level on both the windowed window and current window. Also remove NSFullScreenModeWindowLevel as it seems to be superfluous.
* cocoa_common: fix window level when going fullscreenStefano Pigozzi2013-06-101-1/+1
| | | | | | | | | This is a regression introduced by 0057aa4769. Fix it so that the fullscreen window uses the correct window level. [ci skip] Fixes #106
* osx: cocoa_common: use default wakeup periodStefano Pigozzi2013-06-031-1/+0
| | | | | Now that Cocoa's input handling is done on a separate thread from the playloop it is ridicolously simple to have longer asynchronous sleeps when paused.
* osx: create macosx_events to deal with keyDown eventsStefano Pigozzi2013-06-031-106/+9
| | | | | | 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.
* cocoa_common: autohide dock/menubar on fs only if on same screenStefano Pigozzi2013-06-011-7/+37
| | | | | | | | | | | | | Autohide the menubar and/or dock only if they are present in the screen the player is going to go fullscreen into. I thought the GUI would handle this for me when I switched 0057aa476 but lack of hardware to test made me embarass myself yet again. I reimplemented this feature with nicer code and behaviour. The code checks separately wether to hide menubar and dock separatly, while the old code used a single check possibly hiding stuff without need. Added the key checks as a some category additions to NSScreen for readability.
* cocoa_common: don't autohide mouse on mousedownStefano Pigozzi2013-06-011-2/+10
| | | | | Previews code allowed to click the same spot for a long time and the cursor would autohide. No more!
* cocoa_common: avoid window creation with VOFLAG_HIDDENStefano Pigozzi2013-06-011-76/+92
| | | | | | | | This takes an approach similar to the wayland OpenGL backend. VOFLAG_HIDDEN flag semantics doesn't mean "hide the window" but is simply ever used only to do detection of available OpenGL extensions. On OSX it's possibile to accomplish this task just by creating the OpenGL context without attaching it to a drawable.
* cocoa_common: dehack mouse autohide by clipping view bounds to visible screenStefano Pigozzi2013-06-011-17/+19
| | | | | This prevents the mouse to autohide when hovering the dock/menubar without any particular hack and seems to finally cover all edge cases.
* cocoa_common: fix mouse autohide on MenuBar/Dock interactionStefano Pigozzi2013-05-311-1/+7
| | | | | This is needed after last commit. A bug within a bug (yo dawg)! Serious explaination in the source code comment so that it's not forgotten.
* cocoa_common: fix empty window when going fs on different screenStefano Pigozzi2013-05-311-0/+9
| | | | | | | | | Using `enterFullScreenMode:withOptions:` with a screen handle than the current screen doesn't hide the current window in the current screen. This is a bug in Cocoa (preparing an isolated test case and sending the rdar later). To work around this, manually hide/show the window that the toolkit should hide/show for us.
* cocoa_common: fix mouse hiding outside of player viewStefano Pigozzi2013-05-301-9/+21
| | | | | | | | | | | | This bug was the result of crappy position detection in the previous code combined with the commits moving autohide delay out of the cocoa backend and into the core. The hit detection was improved and now takes also account of interactions with the Dock and Menubar. Moreover VOCTRL_SET_CURSOR_VISIBILITY now has an effect only if the mouse position matches with this improved hit detection. This means that both interaction with the Dock and Menubar are considered as well as moving the mouse inside another screen.
* cocoa_common: refactor fullscreen code for readabilityStefano Pigozzi2013-05-301-31/+53
| | | | | Break up the code into several methods and reduce code duplication. Also add comments to make the intention of all this clearer.
* cocoa_common: fix native-fs state savingStefano Pigozzi2013-05-301-1/+2
| | | | `opts->fs = VO_FALSE` was forgotten
* cocoa_common: fix a bug in window initialization errorStefano Pigozzi2013-05-301-1/+3
| | | | We didn't bail out soon enough. Bug was introduced by 134f3e97.
* cocoa_common: use cocoa APIs to go fullscreenStefano Pigozzi2013-05-301-217/+165
| | | | | | | | | | | | This removes a bit of ugly code and bookeeping which is never bad. `drawRect` needs to guard against different window instances since in fullscreen the view is wrapped in a fullscreen window provided by the toolkit (a instance of NSFullScreenWindow to be precise). The event handling was moved to the view so that it can still get all the events when in the fullscreen window. Ideally these should be moved to some NSResponder subclass within macosx_application and made available even when no window is present. I refrained from this because "small steps".
* cocoa_common: use better power management activity descriptionStefano Pigozzi2013-05-301-1/+1
| | | | | Now one might actually undestand why this power management assertion is used in the first place.
* osx: remove compatibility conditionals for 10.6Stefano Pigozzi2013-05-301-61/+13
| | | | | | | | At this point 10.6 is pretty old and we don't want to supporting old platforms. I'm killing all the 10.6 compatibility code before doing more refactorings. Next commits will also use newer Objective-C syntax such as literals and @autoreleasepool.
* cocoa_common: send mouse moved events to core when draggingStefano Pigozzi2013-05-261-2/+7
| | | | This change fixes mouse autohide when dragging mouse.
* cocoa_common: implement VOCTRL_SET_CURSOR_VISIBILITYStefano Pigozzi2013-05-261-39/+20
| | | | Pass along cursor visibility hints to be more consistent with OSX's behaviour.
* cocoa_common: implement mouse movement notificationsStefano Pigozzi2013-05-261-0/+10
| | | | | | Notify the core of mouse movement events. The coordinates are converted to a coordinate system with the origin in upper left corner, since Cocoa has it in the lower left corner.
* video/out: introduce vo_control for gl_common based VOswm42013-05-261-0/+26
| | | | | | | | | | | | | | | | Instead of having separate callbacks for each backend-handled feature (like MPGLContext.fullscreen, MPGLContext.border, etc.), pass the VOCTRL responsible for this directly to the backend. This allows removing a bunch of callbacks, that currently must be set even for optional/lesser features (like VOCTRL_BORDER). This requires changes to all VOs using gl_common, as well as all backends that support gl_common. Also introduce VOCTRL_CHECK_EVENTS. vo.check_events is now optional. VO backends can use VOCTRL_CHECK_EVENTS instead to implementing check_events. This has the advantage that the event handling code in VOs doesn't have to be duplicated if vo_control() is used.
* cocoa_common: authohide menu/dock in fullscreenStefano Pigozzi2013-05-261-2/+3