Commit Graph

37 Commits

Author SHA1 Message Date
Stefano Pigozzi cc6ca112e0 cocoa_common: avoid situational nil dereferencing 2012-10-19 23:47:03 +02:00
Stefano Pigozzi e3fe5b8735 cocoa_common: use the same window level when windowed and fullscreen
This greatly simplifies the code and makes alt tab behave like it is supposed
to: it doesn't put the mplayer window behind the other ones when losing focus.

If you have other programs that are displaying themselves above the normal
window level, avoid them or use --ontop.
2012-10-16 07:19:33 +02:00
Stefano Pigozzi dd7607756d cocoa_common: split window creation in helper functions
This commit hopefully makes it easier to follow the flow of the program.
2012-10-16 07:19:33 +02:00
Stefano Pigozzi b3cc274c57 cocoa_common: cosmetics / reformat
Use 80columns almost exclusively and reformat Objective-C messages declarations
to follow Apple's style (i.e.: - (int)name; instead of - (int) name;).
2012-10-16 07:19:33 +02:00
Stefano Pigozzi 539021c779 cocoa_common: remove useless import
QuartzCore was probably forgot after extracting the code from `vo_corevideo`.
The OpenGL.h include can be avoided with no warnings/errors.
2012-10-16 07:19:32 +02:00
Stefano Pigozzi 5931e53dcc cocoa_common: replace TickCount() with NSProcessInfo#systemUptime
TickCount is depracted in OS X 10.8. Substitute it with a public Cocoa API
call available since OS X 10.6.
2012-10-16 07:19:32 +02:00
Stefano Pigozzi f5de0aac96 cocoa_common: use IOKit to perform power management
This allows to remove the call to the deprecated `UpdateSystemActivity`. The
additional benefit is power management is disabled only if the video is really
playing. A paused video will not stop the system from idling.
2012-10-16 07:19:32 +02:00
Stefano Pigozzi b946197243 cocoa_common: save state in the vo struct
Save the cocoa state in an instance variable for the Objective-C part of the
code and use a field in the vo struct for the raw C part of the code.
2012-10-16 07:19:32 +02:00
Stefano Pigozzi 09c5324314 cocoa_common: make fullscreen menubar/dock hiding conditional
cocoa_common was hiding the dock and menubar unconditionally when
going fullscreen. This means they were hidden even if they weren't on
the screen mplayer2 was going fullscreen on, resulting in poor user
experience.

Change the fullscreen function in the cocoa backend to check that
mplayer2 is on the same screen as the menubar/dock before hiding them.
2012-09-18 21:08:20 +02:00
Stefano Pigozzi da374c40de cocoa_common: improve conditional dock hiding from 3259e4a7a
Make the conditional hiding logic introduced in commit 3259e4a7a2a938
("cocoa_common: make fullscreen menubar/dock hiding conditional") work
when mplayer is started with the `fs` and `xineramascreen` options.
2012-08-28 23:21:07 +02:00
Stefano Pigozzi e70b5ee2fd cocoa_common: add HiDPI/retina support
With a HiDPI screen, for performance and backwards compatibility
reasons, AppKit requests an OpenGL surface with a pixel number that
equals the user points number. After the image is rendered to this
smaller surface, it is upscaled so that its dimensions are comparable
across screens of different DPIs. The applied scaling is not that good
and makes the video/subtitles blurry; this is not acceptable for a
video player.

Request AppKit to use a high resolution OpenGL surface to back the
mplayer2 OpenGL view. Also set the window pixel size information
correctly in the VO object by converting user points to actual pixels.

All the system version checks are done at runtime so that the feature
is available on OSX 10.7 even with a binary compiled with older SDKs.

Also replace is_lion_or_better() with is_osx_version_at_least(10, 7, 0)
which is defined in osx_common.
2012-08-16 22:41:09 +02:00
Stefano Pigozzi 87c375e6f2 cocoa_common.m: add missing config.h include
This is needed for the check on CONFIG_SDL in this file.
2012-08-16 22:30:06 +02:00
Stefano Pigozzi dcb90fde25 cocoa_common: refactor menu generation
This commit is supposed to make the menu generation a little more
readable. It also fixes menu generation for the `cmd+q` entry.
2012-08-16 22:28:27 +02:00
wm4 16145ff43f libvo, libao: remove useless video and audio output drivers
Some of these have only limited use, and some of these have no use at
all. Remove them. They make maintainance harder and nobody needs them.
It's possible that many of the removed drivers were very useful a dozen
of years ago, but now it's 2012.

Note that some of these could be added back, in case they were more
useful than I thought. But right now, they are just a burden.

Reason for removal for each module:
    vo_3dfx, vo_dfbmga, vo_dxr3, vo_ivtv, vo_mga, vo_s3fb,
    vo_tdfxfb, vo_xmga, vo_tdfx_vid:
        All of these are for very specific and outdated hardware. Some
        of them require non-standard kernel drivers or do direct HW
        access.
    vo_dga: the most crappy and ancient way to get fast output on X.
    vo_aa: there's vo_caca for the same purpose.
    vo_ggi: this never lived, and is entirely useless.
    vo_mpegpes: for DVB cards, I can't test this and it's crappy.
    vo_fbdev, vo_fbdev2: there's vo_directfb2
    vo_bl: what is this even? But it's neither important, nor alive.
    vo_svga, vo_vesa: you want to use this? You can't be serious.
    vo_wii: I can't test this, and who the hell uses this?
    vo_xvr100: some Sun thing.
    vo_xover: only useful in connection with xvr100.
    ao_nas: still alive, but I doubt it has any meaning today.
    ao_sun: Sun.
    ao_win32: use ao_dsound or ao_portaudio instead.
    ao_ivtv: removed along vo_ivtv.

Also get rid of anything SDL related. SDL 1.x is total crap for video
output, and will be replaced with SDL 2.x soon (perhaps), so if you
want to use SDL, write output drivers for SDL 2.x.

Additionally, I accidentally damaged Sun support, which made me
completely remove Sun/Solaris support. Nobody cares about this anyway.

Some left overs from previous commits removing modules were cleaned up.
2012-07-28 20:44:59 +02:00
Stefano Pigozzi dd77d9e912 cocoa: return the real CGLPixelFormatObj
vo_cocoa_cgl_pixel_format is returning a cached CGLPixelFormatObj.
Return the current one by querying the OpenGL context.
2012-05-15 10:37:58 +02:00
Stefano Pigozzi f47f741c5e cocoa: don't request a depth buffer size 2012-05-15 10:37:58 +02:00
Stefano Pigozzi 77be8b1240 cocoa: gl3: make window creation fail on <10.7
Versions of OSX prior to 10.7 do not support OpenGL 3. Fail the window
creation when that is the case.
2012-05-15 10:37:58 +02:00
Stefano Pigozzi 43337db0a4 cocoa: gl3: support querying of colors bit depth
Add support for querying the bit depth of the colors from the OpenGL
context. This allows to perform dithering correctly.
2012-05-15 10:37:58 +02:00
Stefano Pigozzi 4a2bd440dd cocoa: handle failure on pixel format creation
This didn't make any difference on with OpenGL 2.1, but with the
introduction of OpenGL3.2 it's possible for the pixel format creation to
fail (if OpenGL3.2 is not supported).

This code handles the failure case accordingly.
2012-05-14 16:28:43 +02:00
wm4 97ac824124 Merge remote-tracking branch 'origin/master'
Conflicts:
	bstr.c
	bstr.h
	libvo/cocoa_common.m
	libvo/gl_common.c
	libvo/video_out.c
	mplayer.c
	screenshot.c
	sub/subassconvert.c

Merge of cocoa_common.m done by pigoz.

Picking my version of screenshot.c. The fix in commit aadf1002f8 will
be redone in a follow-up commit, as the original commit causes too many
conflicts with the work done locally in this branch, and other work in
progress.
2012-04-29 10:01:28 +02:00
Stefano Pigozzi 4251af8d5d cocoa_common: fix problems with alt-tab window changes
Fix alt tabbing to another window in the same workspace. The player
window stayed on top because of a missing call to orderBack:.

Fix alt tabbing to the player window from a different workspace. The
window didn't get activated. Turns out that you must call
makeKeyAndOrderFront: before setLevel: or setPresentationOptions: or
the window will not properly ask for focus.
2012-04-26 21:03:10 +03:00
Stefano Pigozzi d3da92aea4 cocoa_common, gl_common: add OSX specific getProcAddress
Run dlopen on the OpenGL dynamic library instead of on the binary.
This should prevent crashes due to function conflicts when X11/lGL is
linked.

Remove mutual exclusion of the X11 and Cocoa backends.
2012-04-26 21:03:10 +03:00
Stefano Pigozzi 86790494d3 OSX, input: implement wakeup in response to Cocoa events
Add code to wake up the select() call in input.c when an OSX event is
available and a Cocoa OpenGL backend is initialized.

Fixes the slow response to input or other events in Cocoa-based VOs
during long select() sleeps (e.g., when mplayer2 is paused) introduced
by commit 7040968.
2012-04-26 21:03:10 +03:00
Stefano Pigozzi 768e06b0ac vo_corevideo: restructure this video output
Restructure this video output to be similar to vo_gl, even if simpler
and less feature complete (for example it's still missing EOSD
support). Ideally, it should act as a decent fallback in the case
where something breaks in the OSX support of vo_gl.

Here's a summary of what changed:

 * Remove the shared buffer code since it wasn't using any function
   from the CoreVideo API. Moreover, its presence in vo_corevideo was
   forcing the non-GUI related code to perform more image copies than
   necessary. Equivalent shared-buffer functionality will be added in
   a separate new VO in the next commit (this means OSX GUIs will need
   to specify a different VO).

 * Clean up the code to conform a bit more to the mplayer2
   conventions. Enforce 80 column wrapping, use a private struct for
   file variables, use the new libvo api.

 * Add OSD rendering using OpenGL instead of writing directly on the
   video image data.

 * Simplify the logic for the rendering function when dealing with
   panscan.

 * Add VOCTRL_REDRAW_FRAME support.

 * Add colormatrix support by using the built-in API provided by
   CoreVideo.
2012-04-26 21:03:10 +03:00
Stefano Pigozzi d12b9b611a vo_corevideo: use cocoa_common to display the window
Change vo_corevideo to use cocoa_common to create and manage the
window. This doesn't affect external OSX GUIs, since they don't use
vo_corevideo window management, but only read the image data from the
shared buffer.
2012-04-26 21:03:10 +03:00
wm4 1aa2e36122 Merge remote-tracking branch 'origin/master'
Conflicts:
	bstr.c
	bstr.h
	etc/input.conf
	input/input.c
	input/input.h
	libao2/ao_pulse.c
	libmpcodecs/vf_ass.c
	libmpcodecs/vf_vo.c
	libvo/gl_common.c
	libvo/x11_common.c
	mixer.c
	mixer.h
	mplayer.c
2012-04-01 22:52:33 +02:00
Stefano Pigozzi b00c1335c8 gl_common: cocoa: add OpenGL 3.2 context creation code
Add a new option to the cocoa window creation code in order to decide
which OpenGL context to create.
2012-03-31 02:58:52 +02:00
Stefano Pigozzi 9badc1d786 cocoa_common: update screen info before entering fullscreen
If the user moved the window to another screen, fullscreen mode would
still use the original screen. Fix to use the screen the window is
currently on (unless overridden by --xineramascreen).
2012-03-25 22:30:38 +03:00
Stefano Pigozzi e89ea0c371 cocoa_common: add license information 2012-03-25 22:30:37 +03:00
Stefano Pigozzi 98d399e2f3 cocoa_common: fix double click handling
The Cocoa framework generates only a NS*MouseDown event when handling
the second click of a double click (no NS*MouseUp). If that's the case
put mouse up key in mplayer2's fifo when dealing with the MouseDown
Cocoa event.
2012-03-25 22:30:37 +03:00
Stefano Pigozzi 09beba6e9e cocoa_common: accept window drag event from the whole window surface
Change the window to accept mouse drag events not only on the title
bar, but also on the rest of the window surface; this includes the
video area.

It looks like the changing of the window mask resets the behaviour
specified in the delegate method, probably due to some strange
interaction with NSBorderlessWindow. For this reason call
-setPresentationOptions in the -fullscreen method to remind cocoa the
behaviour we want.
2012-03-25 22:30:37 +03:00
Stefano Pigozzi 495dde4018 options, x11+cocoa: add option --cursor-autohide-delay
Add option --cursor-autohide-delay to control the number of milliseconds
with no user interaction before the mouse cursor is hidden.

There are two negative values with useful special meanings:
* A value of -1 prevents the cursor from hiding (useful for users
  with multiple displays).
* A value of -2 prevents the cursor from showing upon activity.

The default is 1 second to keep the behaviour consistent with the
past X11 backend implementation.

Remove the vo_mouse_autohide field as it was always true.
2012-03-25 22:30:37 +03:00
Stefano Pigozzi 506d9beb66 vo_gl: cocoa: add support for --ontop
Make the cocoa backend change the non-fullscreen window level
according to the value of the ontop property.
2012-03-25 22:30:37 +03:00
Stefano Pigozzi b2a41e20be vo_gl: cocoa: point swapinterval to cocoa_common function
Currently there is no way to set the swap interval with a function
that has a signature compatible with other platforms' gl extensions.

Make a wrapper function around the gui toolkit method of setting the
swap interval property, and point gl->SwapInterval to it.
2011-12-06 23:11:50 +01:00
Stefano Pigozzi bd8ba89cca vo_gl: cocoa: decouple cocoa_common from gl_common
Remove the useless dependency on MPGLContext from cocoa_common, since
it was used just to access the vo struct. Change gl_common to pass the
vo struct directly to all the cocoa_common functions.
2011-12-06 23:10:54 +01:00
wm4 d4de92e808 libvo: remove title argument from struct vo_driver.config
This affects only the "new" VO API. The config() title argument was barely
used, and it's hardcoded to "MPlayer" in vf_vo.c. The X11 and the Cocoa
GUI backends, which are the only ones properly supporting window titles,
ignored this argument. Remove the title argument.

Add the vo_get_window_title function. All GUI VOs are supposed to use it
for the window title.
2011-12-06 20:32:33 +01:00
Stefano Pigozzi 421c840b3c vo_gl: add native mac osx Cocoa backend for vo_gl
Add native Cocoa code to display an OpenGL window. Some of the code is
based on the OpenGL parts of vo_corevideo but I took the time to remove
old code based on Carbon.

There is autodetection in the configure script but you can use
--enable[disable]-cocoa to enable[disable] this.
2011-11-26 20:04:16 +02:00