Commit Graph

261 Commits

Author SHA1 Message Date
wm4 eec4b86bbc x11: fix mysterious issue with window embedding on OpenBox
For some reason, when using window embedding, and the window manager is
OpenBox, calling XSetWMNormalHints() before the window is mapped, the
initial window position will be off. It leaves some vertical space,
instead of placing it on the top/left corner. Suspiciously, the vertical
space is as much as a the height of normal window decoration.

I don't know what kind of issue this is. Possibly an OpenBox bug, but
then this happens even if the override-redirect flag is set. (This flag
basically tells the X server to ignore the window manager. Normally we
don't set it.) On other window managers, it works fine. So I don't know
why this is happening.

But this is easy to workaround. XSetWMNormalHints() isn't needed at all
if embedding.

Should fix #1235.
2014-12-18 16:45:55 +01:00
wm4 7098f33077 x11: minor improvements
Always include the window position in winrc, even if the window
embedded. This should give the correct positions for things which still
interact with global coordinates, such as the xrandr code.
2014-12-18 16:30:13 +01:00
wm4 fbccddb48b x11: copy WinID option
For the purpose of making "--wid" setable at any time.
2014-12-09 21:55:18 +01:00
wm4 9d91776d0d x11: fix crash
Broken by previous commit. Oops.
2014-11-23 13:58:03 +01:00
wm4 c9fdf4308c x11: fix crash with --wid=0 and vo_xv/vo_x11
But seriously, don't use --wid=0, don't use vo_xv, and _especially_
don't use vo_x11.

Fixes #1284.
2014-11-23 10:54:34 +01:00
Kevin Mitchell 83aab1d4be vo/x11: implement VOCTRL_GET_DISPLAY_NAMES with xrandr names (e.g., "LVDS1")
XRRGetOutputInfo contains a "name" element which corresponds to to the
display names given to the user by the "xrandr" command line
utility. Copy it into the xrandr_display struct for each display.
On VOCTRL_GET_DISPLAY_NAMES, send a copy of the names
of the displays spanned by the mpv window on.
2014-11-07 01:14:03 -08:00
wm4 dc1d851c92 x11: rely on the Atom cache
XInternAtom() has a 64 entry hash table to avoid network accesses. Rely
on this cache, instead of caching these manually.
2014-11-03 23:01:27 +01:00
wm4 416c86f3cb command: add window-minimized property (X11 only)
More or less requested by #1237.

Should be simple to extend this to other backends.
2014-11-02 20:55:07 +01:00
wm4 fcc360ccad x11: fix display FPS detection for interlaced modes
In interlaced modes, we output fields, not complete frames, so the
framerate doubles.

The method to calculate this was borrowed from xrandr code.

Hopefully fixes #1224.
2014-10-27 16:17:55 +01:00
wm4 7266ceeb8e x11: don't wait for asynchronous X resizing with window-scale
Instead of letting the window-scale property return the old value until
X11 actually executed the resize, just set the new assumed internal
window size immediately. This avoids a "lag" between setting and reading
the window-scale property, like OSD controls typically do.

Remove the additional calls from vo_x11_highlevel_resize() - they're
pointless and slightly wrong, and resize events will take care of
updating these things correctly anyway.

Fixes #1176.

("window-scale" works via VOCTRL_[S|G]ET_UNFS_WINDOW_SIZE.)
2014-10-13 09:57:31 +02:00
wm4 cea7528b39 x11: don't wait until window is destroyed
This can hang if the window was destroyed externally (or that's what I
suspect happens), and we somehow didn't receive the DestroyNotify event.
I'm not sure why we wouldn't receive this event (since it should just be
in the xlib event queue), but on the other hand there's no real need to
wait for window destruction.

This essentially reverts 97fc74e2.
2014-10-11 16:30:58 +02:00
wm4 a13e01cc3e x11: fix inverted condition
Worryingly wrong. Fixes #1162.

Also fix another issue (window title was set anyway), which was why I
didn't notice this and testing it seemed to be fine.
2014-10-09 21:26:03 +02:00
wm4 e294656cb1 client API: rename --input-x11-keyboard to --input-vo-keyboard
Apparently we need this for Cocoa too. (The option was X11 specific in
the hope that only X11 would need this hack.)
2014-10-09 18:28:37 +02:00
wm4 f47269a074 x11: disable various features when embedding the window 2014-10-07 23:37:47 +02:00
wm4 bd169a313c options: add --no-keepaspect-window
Seems silly, but was requested.
2014-10-04 22:17:36 +02:00
wm4 54fd93856a x11: stupid workaround for XMonad
--x11-netwm=yes now forces NetWM fullscreen, while --x11-netwm=auto
(detect whether NetWM fullsctreen support is available) is the old
behavior and still the default.

See #888.
2014-10-04 15:03:02 +02:00
wm4 6dad7d6fe7 x11: fix --wid=0
Another fallout resulting from the changes whether or not to wait for
mapping the window. In this case, it obviously makes no sense to wait
for mapping, because the root window is always mapped. Mapping will
never happen, and it would wait forever.

Fixes #1139.
CC: @mpv-player/stable
2014-10-02 18:14:30 +02:00
wm4 64fb37c173 vo_vdpau: don't try to create surfaces of size 0
At least on kwin, we decide to proceed without waiting for the window
being mapped (due to the frame exts hack, see commit 8c002b79). But that
leaves us with a window size of 0x0, which causes VdpOutputSurfaceCreate
to fail. This prints some warnings, although vo_vdpau recovers later and
this has no other bad consequences.

Do the following things to deal with this:
- set the "known" window size to the suggested window size before the
  window is even created
- allow calling XGetGeometry on the window even if the window is not
  mapped yet (this should work just fine)
- make the output surface minimum size 1x1

Strictly speaking, only one of these would be required to make the
warning disappear, but they're all valid changes and increase robustness
and correctness. At no point we use a window size of 0x0 as magic value
for "unset" or unknown size, so keeping it unset has no purpose anyway.

CC: @mpv-player/stable
2014-10-01 17:29:24 +02:00
wm4 053196de84 x11: always wait for mapped when using --wid
Might help with embedding with mozplugger. I can't confirm whether it
fixes the issue.

See #1090.
2014-09-29 18:06:45 +02:00
wm4 3273db1ef7 client API, X11: change default keyboard input handling again
Commit 64b7811c tried to do the "right thing" with respect to whether
keyboard input should be enabled or not. It turns out that X11 does
something stupid by design. All modern toolkits work around this native
X11 behavior, but embedding breaks these workarounds.

The only way to handle this correctly is the XEmbed protocol. It needs
to be supported by the toolkit, and probably also some mpv support. But
Qt has inconsistent support for it. In Qt 4, a X11 specific embedding
widget was needed. Qt 5.0 doesn't support it at all. Qt 5.1 apparently
supports it via QWindow, but if it really does, I couldn't get it to
work.

So add a hack instead. The new --input-x11-keyboard option controls
whether mpv should enable keyboard input on the X11 window or not. In
the command line player, it's enabled by default, but in libmpv it's
disabled.

This hack has the same problem as all previous embedding had: move the
mouse outside of the window, and you don't get keyboard input anymore.
Likewise, mpv will steal all keyboard input from the parent application
as long as the mouse is inside of the mpv window.

Also see issue #1090.
2014-09-28 20:11:00 +02:00
wm4 8c002b79d3 x11: if the WM supports _NET_FRAME_EXTENTS, don't wait for map
Some window managers can prevent mapping of a window as a feature. i3
can put new windows on a certain workspace (with "assign"), so if mpv is
started on a different workspace, the window will never be mapped.

mpv currently waits until the window is mapped (blocking almost all of
the player), in order to avoid race conditions regarding the window
size. We don't want to remove this, but on the other hand we also don't
want to block the player forever in these situations.

So what we need is a way to know when the window manager is "done" with
processing the map request. Unfortunately, there doesn't seem to be a
standard way for this. So, instead we could do some arbitrary
communication with the WM, that may act as "barrier" after map request
and the "immediate" mapping of the window. If the window is not mapped
after this barrier, it means the window manager decided to delay the
mapping indefinitely. Use the _NET_REQUEST_FRAME_EXTENTS message as such
a barrier. WMs supporting this message must set the _NET_FRAME_EXTENTS
property on the mpv window, and we receive a PropertyNotify event. If
that happens, we always continue and cancel waiting for the MapNotify
event.

I don't know if this is sane or if there's a better mechanism. Also,
this works only for WMs which support this message, which are not many.
But at least it appears to work on i3. It may reintroduce flickering on
fullscreen with other WMs, though.
2014-09-15 19:19:01 +02:00
wm4 b44571abab x11: remove unused function 2014-09-14 15:59:10 +02:00
wm4 e267ff93f3 video: rename VOCTRL_GET_WINDOW_SIZE
Make it clear that this accesses the un-fullscreened window size.
2014-09-05 01:52:16 +02:00
Kenneth Zhou 98b9d47482 x11: add rewind and forward keys
Signed-off-by: wm4 <wm4@nowhere>
2014-09-03 21:08:54 +02:00
wm4 64b7811c28 x11: when using --wid, inherit event flags from parent window
When embedding a X window, it's hard to control whether it receives
mouse/keyboard input or not. It seems the X protocol itself makes this
hard (basically due to the outdated design mismatching with modern
toolkits), and we have to take care of these things explicitly.

Simply do this by manually querying and using the parent window event
flags.

This restores some MPlayer behavior (it doesn't add back exactly the
same code, but it's very similar).

This probably has some potential to interfere with libmpv embedding, so
bump the client API minor.

CC: @mpv-player/stable (if applied, client-api-changes.rst has to be
    adjusted to include the 0.5.2 release)
2014-08-31 14:48:26 +02:00
wm4 68ff8a0484 Move compat/ and bstr/ directory contents somewhere else
bstr.c doesn't really deserve its own directory, and compat had just
a few files, most of which may as well be in osdep. There isn't really
any justification for these extra directories, so get rid of them.

The compat/libav.h was empty - just delete it. We changed our approach
to API compatibility, and will likely not need it anymore.
2014-08-29 12:31:52 +02:00
wm4 1e04c474ab x11: listen to xrandr events
If the Xrandr configuration changes, re-read it. So if you change
display modes or screen configuration, it will update the framedrop
refresh rate accordingly.

This passes the rootwin to XRRSelectInput(), which may or may not be
allowed. But it works, and the documentation (which is worse than used
toilet paper, great job Xorg) doesn't forbid it, or in fact say anything
about what the window parameter is even used for.
2014-08-17 15:39:18 +02:00
wm4 3778e63330 x11: fix xrandr conditional compilation
Oops.

Fixes #1020.
2014-08-17 04:35:24 +02:00
wm4 4822056db7 x11: fix memory leaks
Oh, we have to free this stuff. OK.
2014-08-17 02:47:44 +02:00
wm4 f8f3a1b4a1 build: drop check for XF86keysym.h
This is always included in the Xorg development headers. Strictly
speaking it's not necessarily available with other X implementations,
but these are hopefully all dead.
2014-08-16 21:57:51 +02:00
wm4 fe782a6e95 x11: use xrandr to retrieve display refresh rate
Drop use of the ancient XF86VM, and use the slightly less ancient Xrandr
extension to retrieve the refresh rate. Xrandr has the advantage that it
supports multiple monitors (at least the modern version of it).

For now, we don't attempt any dynamic reconfiguration. We don't request
and listen to Xrandr events, and we don't notify the VO code of changes
in the refresh rate. (The later works by assuming that X coordinates map
directly to Xrandr coordinates, which probably is wrong with compositing
window manager, at least if these use complicated transformations. But I
know of no API to handle this.)

It would be nice to drop use of the Xinerama extension too, but
unfortunately, at least one EWMH feature uses Xinerama screen numbers,
and I don't know how that maps to Xrandr outputs.
2014-08-16 21:56:22 +02:00
wm4 543ba6c114 video: add VO framedropping mode
This mostly uses the same idea as with vo_vdpau.c, but much simplified.

On X11, it tries to get the display framerate with XF86VM, and limits
the frequency of new video frames against it. Note that this is an old
extension, and is confirmed not to work correctly with multi-monitor
setups. But we're using it because it was already around (it is also
used by vo_vdpau).

This attempts to predict the next vsync event by using the time of the
last frame and the display FPS. Even if that goes completely wrong,
the results are still relatively good.

On other systems, or if the X11 code doesn't return a display FPS, a
framerate of 1000 is assumed. This is infinite for all practical
purposes, and means that only frames which are definitely too late are
dropped. This probably has worse results, but is still useful.

"--framedrop=yes" is basically replaced with "--framedrop=decoder". The
old framedropping mode is kept around, and should perhaps be improved.
Dropping on the decoder level is still useful if decoding itself is too
slow.
2014-08-15 23:33:33 +02:00
wm4 f6f93b6336 x11: vdpau GLX interop needs X11 threads
Xlib is not thread-safe. Or actually it is, but it's an incomprehensible
hack that was added later, and which needs to be acitvated manually
(this makes no sense). And it appears that the vdpau accesses X from the
decoder thread if GLX interop is used (and not in any other situations -
this doesn't make too much sense either).

So, just call the magic function that enables Xlib thread-safety.
2014-08-13 00:26:13 +02:00
wm4 4c533fbb16 vo: remove vo_mouse_movement() wrapper
So that VO backends don't have to access the VO just for that.
2014-07-27 21:53:29 +02:00
wm4 4a5cfb4323 x11: avoid obscure behavior when --wid is partially garbage
Cast away the "extra" bits (since apparently Window/XID is always
32 bit unsigned). This is not striclty needed, because you're not
supposed to pass garbage to --wid, just because the upper bits are
possibly not interpreted. But if you do so, this change increases
consistency in behavior and removes a strange behavior that was
thought to be a bug.

Also see github issue #906.
2014-07-04 02:23:05 +02:00
wm4 6d38ad1410 x11: clear window only on initial map
Apparently clearing on every map can cause problems with vdpau when
switching virtual desktops and such. This was observed with at least
XMonad and nvidia-340.17. It's not observed on some other setups without
XMonad.

It's not clear why this happens. Normally, the window background is not
saved, so clearing should have no additional affect. It's a complete
mystery. Possible, the use of legacy X drawing commands (used to clear
the window) interferes with vdpau operation in non-trivial ways.

Work this around by clearing on initial map only. This probably only
hides the underlying issue, but good enough.

Closes #897.

CC: @mpv-player/stable
2014-07-02 02:07:06 +02:00
wm4 99f5fef0ea Add more const
While I'm not very fond of "const", it's important for declarations
(it decides whether a symbol is emitted in a read-only or read/write
section). Fix all these cases, so we have writeable global data only
when we really need.
2014-06-11 00:39:14 +02:00
wm4 79e76abb4d x11: cleanup motif hints handling
It seems we can't really get rid of this. There are no other hints to
remove decorations that work across all reasonable WMs, so we're stuck
with the ugly motif stuff.

But at least we can make the code for it less ugly.
2014-06-06 18:45:38 +02:00
wm4 8dfd93c6fb vo_vaapi: cleanup error handling on init
Close the X connection if initializing vaapi fails.
2014-05-28 02:08:45 +02:00
wm4 d04ce8a7c2 x11: fix restoring position when leaving fullscreen
Accidentally broken in commit 7163bf7d by inverting the condition.
2014-05-26 21:59:30 +02:00
wm4 44e8a4085e x11: fix datatype for _NET_WM_PID
Setting this property was added 12 years ago, and the code was always
incorrect. The underlying data type is "long", not "pid_t". It's well
possible that the data types are different, and the pointer to the pid
variable is directly passed to XChangeProperty, possibly invoking
undefined behavior.

It's funny, because in theory using pid_t for PIDs sounds more correct.
2014-05-26 21:59:30 +02:00
wm4 76bd701a7a x11: un-inline GNOME layer stuff
Having it as separate function is not useful.

Also remove the useless vo_window parameter.
2014-05-23 20:59:36 +02:00
wm4 e2e318a213 x11: prefer NetWM hints over _WIN_LAYER for --ontop
_WIN_LAYER is apparently an old GNOME thing (also explains why there is
a function vo_x11_get_gnome_layer() involved in this code). Prefer the
NetWM hints over this. This just moves the NetWM case if-body over the
_WIN_LAYER one.
2014-05-23 20:59:36 +02:00
wm4 8033b4b4ba x11: rename identifiers using reserved namespace
You can't use identifiers starting with "_" and an uppercase letter in
application programs. They are reserved by the C standard.

Unrelated change: drop unused/misleading vo_wm_NETWM define.
2014-05-23 20:59:06 +02:00
wm4 990888f968 x11: fix NetWM ontop setting
I can only assume the old code was wrong. EWMH does not document
anything with _WIN_LAYER. Instead, you have to toggle the state using a
client message. We also remove these weird non-sense fallbacks, like
using _NET_WM_STATE_BELOW - what the hell?
2014-05-23 20:57:26 +02:00
wm4 7163bf7db8 x11: add a generic function for NetWM state setting
And use it for fullscreening. It will also be used for fixing --ontop.
2014-05-23 20:57:21 +02:00
wm4 ac66bcc259 x11: unbreak build without xinerama 2014-05-19 22:09:26 +02:00
wm4 5f6406f450 x11: leaving fullscreen -> reset WM hints only if needed
This works around an issue in OpenBox: OpenBox apparently sizes the
normal window incorrectly if aspect ratio hints are set, and the window
size is off by 1 pixel. Then, when going fullscreen and leaving
fullscreen again, mpv sets the hints based on OpenBox' broken window
size, and as result, OpenBox sizes the window incorrectly and is off by
1 pixel again - so it's 2 pixels off in total. The error gets more
visible, the more often you toggle fullscreen mode.

Work this around by not setting the window hints if we don't need to.
Actually we only need to do this when the video is resized during
fullscreen, which happens rarely. Under normal circumstances, leaving
fullscreen mode requires that the WM restores the old state.

As such, this commit is not only a workaround, but actually a cleanup.

Note that we do need to set the hints when leaving fullscreen if the
window has resized: even though we set the hints in
vo_x11_highlevel_resize (called by vo_x11_config_vo_window), this
doesn't seem to have an effect (at least on IceWM), so we have to do it
after that.

Side note: ot seems commit 625ad57a strangely triggered the OpenBox
issue according to user reports; I'm not sure why.
2014-05-19 21:59:10 +02:00
wm4 a332a227f4 x11: always check whether a window exists
So any VOCTRL can be called at any time. Working towards removing all
these config_ok checks in vo.c.
2014-05-19 01:07:54 +02:00
wm4 821f37db62 x11: request and handle resize events of parent windows with --wid
Before this commit, this was somehow polled (i.e. not the right way).

Also, selects the correct window when doing --wid=0 (which is another
weird special-case).
2014-05-19 01:07:10 +02:00
wm4 2c012e9eb2 x11: remove a duplicated line 2014-05-18 23:47:28 +02:00
wm4 d9bd5bacc1 x11: never enable DPMS if we didn't disable it
Enabling DPMS even though you disabled it globally is pretty unfriendly,
so don't do it. Instead, we only disable DPMS if it was enabled, and
only enable it if we disabled it ourselves.

The other way should never happen (disabling DPMS permanently), unless
mpv crashes during playback.
2014-05-18 22:16:53 +02:00
wm4 c2039572b7 x11: make screensaver code more compact, change DPMS handling
Reduces some code-duplication.

Just call DPMSEnable/DPMSDisable, instead of DPMSForceLevel when
reenabling DPMS. "Force" sounds evil, and messing with DPMS is already
pretty evil. I'm not even sure that we should.
2014-05-17 21:36:34 +02:00
wm4 b4b68ebf5a x11: add wrapper for EWMH XSendEvent calls 2014-05-17 18:03:28 +02:00
wm4 347eaaa93c x11: fix Drag & Drop
Accidentally broken in commit 95462747.
2014-05-17 17:49:47 +02:00
wm4 8304478149 x11: add a wrapper for XGetWindowProperty
XGetWindowProperty is a really bad API, almost as if the NSA designed
it. The wrapper takes care of verifying the return values and handle
corner cases.
2014-05-17 17:49:47 +02:00
wm4 5a1bf25523 x11: comment about gravity
The window "gravity" influences how placement interacts with WM added
borders (i.e. from decorations). This is probably what the code removed
in commit c14721c8 was about.

In theory, we'd probably want to set the gravity depending on the
relative placement requested by the user (so that it's possible to line
up the top/left video pixel with the monitor corner, as well as the
bottom/right pixel - but that would be too complicated, and who cares
after all?).

I'm also not sure whether CenterGravity really uses the top/left corner
as reference point (instead of making coordinates relative to the window
center), but empirically it's correct.
2014-05-17 14:26:49 +02:00
wm4 0e579f8439 x11: replace x/y/w/h with mp_rect 2014-05-17 03:29:36 +02:00
wm4 625ad57add x11: don't set PBaseSize
There's apparently no reason why we should set a bogus size.
2014-05-17 02:53:57 +02:00
wm4 3afff3fe9b x11: remove vo_hint member
Now it's always recreated in vo_x11_sizehint(). Also, the Xlib manual
says you must use XAllocSizeHints() (for ABI reasons), so do that.
2014-05-17 02:27:46 +02:00
wm4 4807f8bdd2 x11: always raise layer in fullscreen mode without NetWM 2014-05-17 01:53:56 +02:00
wm4 faeaa6c358 x11: implement --fs-screen properly, separate old code path
Try to get the "new" code path (using NetWM/EWMH) free of hacks done for
the sake of old WMs or the no-WM case.

Implement --fs-screen using _NET_WM_FULLSCREEN_MONITORS.
2014-05-17 01:14:59 +02:00
wm4 444e583b6d x11: use CenterGravity by default
Keeps the window centered on resize. Seems nicer. (Although it's worse
if 1. the default placement of the WM puts it into a monitor corner,
and 2. you switch to a larger video.)
2014-05-17 00:53:54 +02:00
wm4 c14721c8b9 x11: remove gravity restore code
It was added with 3813c685 in 2004. I'm not really sure why this gravity
stuff would be needed; apparently it has to do with misplacements with
broken WMs and had to be changed on fullscreen. Just get rid of it; it
works perfectly fine without on modern WMs.

The thread discussing this is here:
http://mplayerhq.hu/pipermail/mplayer-dev-eng/2004-July/027674.html
2014-05-17 00:53:53 +02:00
wm4 9546274710 x11: don't cache X Atoms manually
XInternAtom() already caches lookups. Even if calling XInternAtom would
be always inefficient, it wouldn't matter much during normal playback.
2014-05-16 23:17:09 +02:00
wm4 7c2cf7cdf1 x11: inline a function
Keeping it separate seems less readable.
2014-05-16 23:17:02 +02:00
wm4 ebd5bbd241 x11: replace--[x11-]fstype option with --x11-netwm
Simplifies the code a lot. You can still use --x11-netwm=no to disable
NetWM for whatever reasons.
2014-05-16 00:47:13 +02:00
wm4 b6e675a9bc x11: remove a MWM hack
This was for Motif Window Manager. No, I don't care about Motif.
2014-05-16 00:08:18 +02:00
wm4 c4cbf6b540 x11: remove unused stuff
Unfortunately, it looks like some Motif functionality is still needed
to allow for --no-border.
2014-05-16 00:03:31 +02:00
wm4 7ad8c5ff33 x11: set the fullscreen state before mapping the window
This should get rid of some flickering. Since this actually skips all
the wacky fullscreening code on startup, this might lead to certain
wacky features to stop working. In this case, you'll have to use the
--x11-fstype option, and disable _NETWM_STATE_FULLSCREEN usage.
2014-05-15 23:56:14 +02:00
wm4 8f29f6fc61 x11: clear window on map
vo_x11_map_window() was attempting to clear the window on map. However,
it did so immediately after the map request. It probably assumed that
the drawing calls for clearing the window would be queued along with the
map request, and then executed in the right order. However, this
assumption was wrong - the map request first has to go to the window
manager (I guess?), so a lot of things happen before the window is even
mapped.

Fix this by moving the call to the MapNotify message handler, when the
window (apparently) becomes really visible.

I also tried to set CWBackPixel to black instead, but this seemed to
result in flickering on manual resizing.
2014-05-15 23:56:14 +02:00
wm4 9bfe3f394c x11: wait until the window is mapped
This blocks everything, until the window is actually reported as mapped.

This fixes the race condition between VO initialization and mapping the
window, which resulted in possibly different window sizes, leading to an
immediate redraw, visible as flashing.

Note that if the map event never comes for some reason, we're out of
luck and will block forever.
2014-05-15 23:56:14 +02:00
wm4 26b00ffe8a x11: fix potentially unaligned access in icon loader
Tried to load a 32 bit value by dereferencing a uint32_t pointer, but
the pointer is not guaranteed to be aligned, not even in practice.
2014-05-10 10:44:16 +02:00
wm4 5eaefaa98a x11: don't use VOCTRL_UPDATE_SCREENINFO
See previous commit.
2014-05-06 20:24:35 +02:00
Martin Herkt 81c076b2f8 options: remove obsolete --fsmode-dontuse 2014-05-04 02:46:11 +02:00
wm4 85998f6121 Fix some libav* include statements
Fix all include statements of the form:

   #include "libav.../..."

These come from MPlayer times, when FFmpeg was somehow part of the
MPlayer build tree, and this form was needed to prefer the local files
over system FFmpeg.

In some cases, the include statement wasn't needed or could be replaced
with mpv defined symbols.
2014-04-19 17:18:10 +02:00
wm4 ba62e01cd3 x11_common: fix some problems with window dragging
There were some bad interactions with the OSC.

For one, dragging the OSC bar, and then moving the mouse outside of the
OSC (while mouse button still held) would suddenly initiate window
dragging. This was because win_drag_button1_down was not reset when
sending a normal mouse event, which means the window dragging code can
become active even after we've basically decided that the preceding
click didn't initiate window dragging.

Second, dragging the window and clicking on the OSC bar after that did
nothing. This was because no mouse button up event was sent to the core,
even though a mouse down event was sent. So make sure the key state is
erased with MP_INPUT_RELEASE_ALL.
2014-03-22 02:12:20 +01:00
wm4 19f101db68 x11: implement window dragging by grabbing
We don't check whether the WM supports _NET_WM_MOVERESIZE_MOVE, but
if it doesn't, nothing bad happens. There might be a race condition
when pressing a button, and then moving the mouse and releasing the
button at the same time; then the WM might get the message to initiate
moving the window after the mouse button has been released, in which
case the result will probably be annoying. This could possibly be fixed
by sending _NET_WM_MOVERESIZE_CANCEL on button release, but on the
other hand, we probably won't receive a button release event in this
situation, so ignore this problem.

The dragging is initiated only when moving the mouse pointer after a
click in order to reduce annoying behavior when the user is e.g.
doubleclicking.

Closes #608.
2014-03-18 20:43:45 +01:00
wm4 c8b754e38f x11: fix initial VO size
This was done incorrectly in the previous commit: the fallback size used
the window size as requested with the first config call, which is the
size of the hidden window in the vo_opengl case. (That damn hidden
window again...)
2014-02-02 03:19:36 +01:00
wm4 b57a0a0bc6 x11: remove apparently useless code
This code essentially does nothing. As far as I could find out, this
actually used to do something. Then it was removed with commit efe7c39f,
leaving some leftover code that didn't do anything useful. This happened
12 years ago!

Also remove a commented debug printf.
2014-02-02 01:50:25 +01:00
wm4 fc04be708c x11: fix race condition when setting aspect when leaving fullscreen
vo_opengl creates a hidden X11 window to probe the OpenGL context. It
must do that before creating a visible window, because VO creation and
VO config are separate phases.

There's a race condition involving the hidden window: when starting with
--fs, and then leaving fullscreen, the unfullscreened window is
sometimes set to the aspect ratio of the hidden window. I'm not sure why
the window size itself uses the correct size (but corrupted by the wrong
aspect), but that's perhaps because the window manager is free to ignore
the size hint while honoring the aspect, or something equally messed up.

It turns out this happens because x11_common.c thinks the size of the
hidden window is the size of the unfullscreened window. This in turn
happens because vo_x11_update_geometry() reads the size of the hidden
window when called in vo_x11_fullscreen() (called from
vo_x11_config_vo_window()) when mapping the fullscreen window. At that
point, the window could be mapped, but not necessarily. If it's not
mapped, it will get the size of the unfullscreened window... I think.

One could fix this by actively waiting until the window is mapped. Try
to pick a less hacky approach instead, and never read the window size
until MapNotify is received.

vo_x11_create_window() needs a hack, because we'd possibly set the VO's
size to 0, resulting e.g. in vdpau to fail initialization. (It'll print
error messages until a proper resize is received.)
2014-02-02 01:35:46 +01:00
wm4 ad654f3803 options: remove --screenw and --screenh
Doesn't make any sense anymore. X11 (which was mentioned in the manpage)
autodetects it, and everything else ignored the option values.

Since for incomprehensible reasons the backends and vo.c still need to
exchange information about the screensize using the option fields,
they're not removed yet.
2014-01-11 18:58:07 +01:00
wm4 905029ec0c video/out: remove pointless x/y parameter from vo_x11_config_vo_window
This never made any real sense; the "backend" has to access vo->dx/dy
anyway.
2014-01-11 18:58: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
wm4 7c6bb321eb video/out: remove some code duplication between X11 and wayland
Both X11 and Wayland support the same format for drag & drop operations
(text/uri-list), and the code for that was copied from x11_common.c to
wayland_common.c. Factor it out.
2014-01-04 19:33:40 +01:00
Stefano Pigozzi 082c5c19a1 input: move files drag and drop to a new event.c file
event.c will be used to feed the input queue with 'global' events that don't
mesh well with the usual check_events path in mpv.
2014-01-04 17:28:55 +01:00
wm4 6a1b12158d x11: implement dropping files on the VO window
Drag and drop is pretty complicated (just note how the number of Atoms
in use almost doubles), so I'm not sure whether this works everywhere.

This has been written by looking at the specification [1] or what looks
like the specification, and some external example code [2]. (The latter
one has no code license, but we didn't copy any code.)

We completely ignore the "requirement" of the spec. that the filename
"must" include username and hostname, e.g. "file://user@host/path/file".
In theory, this is required because X is network transparent, but at
this point the so called network transparency is a complete joke, and
Konqueror for one didn't include hostnames in "file://" URIs.

Tested with konqueror as drop source.

[1] http://www.newplanetsoftware.com/xdnd/
[2] http://www.edwardrosten.com/code/dist/x_clipboard-1.1/paste.cc
2014-01-04 01:27:28 +01:00
ahodesuka 62be13b019 vo/x11_common: do not select motion events when --no-mouse-movements is set 2013-12-28 15:07:01 +01:00
wm4 f146e9b15a Revert "x11: don't set global error handler"
This reverts commit 877303aaa9.

The OpenGL 2.1 fallback for vo_opengl didn't work. Two things come
together: 1. trying to create an OpenGL 3.0 context will fail with
a GLXBadFBConfig error, and 2. X errors are fatal by default. Since
the reverted commit removed the X error handler, the mpv process was
killed, instead of continuing for the fallback.

(Note that this commit is not an exact inverse commit, since mp_msg
changed, but it does about the same thing.)
2013-12-27 23:22:46 +01:00
wm4 8cd1b33a22 x11: mp_msg conversion for fstype help output 2013-12-21 21:43:16 +01:00
wm4 877303aaa9 x11: don't set global error handler
This has similar problems as the ALSA message callback, though in theory
we could use the Display handle to find the right mpv instance from the
global callback. It still wouldn't work if another library happens to
set the error handler at the same time. There doesn't seem much of an
advantage overriding the error handler (though it used to be required),
so remove it.
2013-12-21 17:39:40 +01:00
wm4 0112143fda Split mpvcore/ into common/, misc/, bstr/ 2013-12-17 02:39:45 +01:00
wm4 eb15151705 Move options/config related files from mpvcore/ to options/
Since m_option.h and options.h are extremely often included, a lot of
files have to be changed.

Moving path.c/h to options/ is a bit questionable, but since this is
mainly about access to config files (which are also handled in
options/), it's probably ok.
2013-12-17 02:07:57 +01:00
wm4 8d5214de0a Move mpvcore/input/ to input/ 2013-12-17 01:23:09 +01:00
wm4 7dc7b900c6 Replace mp_tmsg, mp_dbg -> mp_msg, remove mp_gtext(), remove set_osd_tmsg
The tmsg stuff was for the internal gettext() based translation system,
which nobody ever attempted to use and thus was removed. mp_gtext() and
set_osd_tmsg() were also for this.

mp_dbg was once enabled in debug mode only, but since we have log level
for enabling debug messages, it seems utterly useless.
2013-12-16 20:41:08 +01:00
Stefano Pigozzi 7e2edad8ef switch the build system to waf
This commit adds a new build system based on waf. configure and Makefile
are deprecated effective immediately and someday in the future they will be
removed (they are still available by running ./old-configure).

You can find how the choice for waf came to be in `DOCS/waf-buildsystem.rst`.
TL;DR: we couldn't get the same level of abstraction and customization with
other build systems we tried (CMake and autotools).

For guidance on how to build the software now, take a look at README.md
and the cross compilation guide.

CREDITS:
This is a squash of ~250 commits. Some of them are not by me, so here is the
deserved attribution:

 - @wm4 contributed some Windows fixes, renamed configure to old-configure
   and contributed to the bootstrap script. Also, GNU/Linux testing.
 - @lachs0r contributed some Windows fixes and the bootstrap script.
 - @Nikoli contributed a lot of testing and discovered many bugs.
 - @CrimsonVoid contributed changes to the bootstrap script.
2013-11-21 21:22:36 +01:00
wm4 3813b13796 fix weird DPMS->EXT replacement 2013-11-04 00:43:27 +01:00
Stefano Pigozzi 37388ebb0e configure: uniform the defines to #define HAVE_xxx (0|1)
The configure followed 5 different convetions of defines because the next guy
always wanted to introduce a new better way to uniform it[1]. For an
hypothetic feature 'hurr' you could have had:

  * #define HAVE_HURR 1   / #undef HAVE_DURR
  * #define HAVE_HURR     / #undef HAVE_DURR
  * #define CONFIG_HURR 1 / #undef CONFIG_DURR
  * #define HAVE_HURR 1   / #define HAVE_DURR 0
  * #define CONFIG_HURR 1 / #define CONFIG_DURR 0

All is now uniform and uses:
  * #define HAVE_HURR 1
  * #define HAVE_DURR 0

We like definining to 0 as opposed to `undef` bcause it can help spot typos
and is very helpful when doing big reorganizations in the code.

[1]: http://xkcd.com/927/ related
2013-11-03 21:59:54 +01:00
wm4 9423a7e23e x11: make window-scale use windowed size in fullscreen mode
This is a bit more intuitive, since before, the window size was just set
to something random when setting the window-scale property during
fullscreen.
2013-11-02 17:32:03 +01:00
wm4 94542abf2e command: add property to scale window size 2013-10-31 23:30:14 +01:00
wm4 b55d557822 x11: factor out normal window resize code
As preparation for resizing the window with input commands in the
following commit.

Since there are already so many functions which somehow resize the
window, add the word "highlevel" to the name of this new function.
2013-10-31 19:51:46 +01:00
wm4 50e57c346f x11: restore support for --wid=0
This stopped working when the code was changed to create a window even
if --wid is used.

It appears we can't create our own window in this case, because in X11
there is no difference between a window with the root window as parent,
and a window that is managed by the WM. So make this (kind of worthless)
special case use the root window itself.
2013-10-30 22:19:32 +01:00
wm4 7743ed2dc6 x11: remove ancient metacity hack
Tested with recent metacity; this code is not triggered anymore. The
code was added in 2003 and probably has been unused for years.
2013-10-30 22:19:31 +01:00
wm4 4b2d93f103 x11: minor cosmetics 2013-10-30 22:19:31 +01:00
wm4 96a60e15ce x11_common: refactor of fstype code
This is completely pointless, but it still somehow bugged me.
2013-10-28 22:42:47 +01:00
wm4 f2d438a1fd x11: fix border toggling
Trying to toggle the border during fullscreen (with "cycle border")
would leave the window stuck without border, and it couldn't be
restored. This was because vo_x11_decoration() always excepted to be
called when toggling the state, and thus confusing the contents of the
olddecor variable. Add got_motif_hints to hopefully prevent this.

Also, when changing the border, don't take fs in account. May break on
older/broken WMs, but all in all is in fact more robust and simpler,
because you do not need to update the border state manually when
returning from fullscreen.
2013-10-27 23:22:46 +01:00
wm4 de303d8ba4 x11_common: reduce screensaver heartbeat from 30 to 10 seconds
Apparently this fixes issues with Gnome, which has a smaller timeout.
See github issue #315.
2013-10-25 20:30:01 +02:00
wm4 a0485221c7 x11_common: don't handle mouse enter events
This could cause the OSC to be displayed without mouse interaction: for
example, starting mpv with --fs, and putting the mouse to where the OSC
area is beforehand, would cause the OSC to appear and stay visible. We
don't want that. The simplest solution is not generating artificial
mouse move events from mouse enter events, because they make the OSC
think the mouse was actually moved.

Also see commit 0c7978c, where handling of mouse enter events was added.
This was supposed to fix certain corner cases, but they're not relevant
anymore due to changes in OSC behavior.

Commit 9777047 fixed this as well (by resetting the mouse state on
MOUSE_LEAVE), but all the behavior reverted with this commit as perhaps
a bad idea. It wasn't very robust, made it hard to distinguish real
events from artificial ones, and finally made the mouse cursor more
often visible than needed. (Now switching between workspaces doesn't
make the cursor visible again when switching to a fullscreened mpv.)
2013-10-15 21:53:33 +02:00
wm4 c000a08de2 x11: remove colormap code, always request TrueColor visuals
vo_x11 had a clever trick to implement a video equalizer: it requested a
DirectColor visual. This is a X11 mechanism which allows you to specify
a lookup table for each color channel. Effectively, this is a safe
override for the graphic card's gamma ramp. If X thinks the window
deserves priority over other windows in the system, X would temporarily
switch the gamma ramp so that DirectColor visuals can be displayed as
the application intends. (I'm not sure what the exact policy is, but in
practice, this meant the equalizer worked when the mouse button was
inside the window.)

But all in all, this is just lots of useless code for a feature that is
rarely ever useful. Remove it and use the libswscale equalizer instead.
(This comes without a cost, since vo_x11 already uses libswscale.)

One worry was that using DirectColor could have made it work better in
8-bit paletted mode. But this is not the case: there's no difference,
and in both cases, the video looks equally bad.
2013-09-30 00:47:24 +02:00
wm4 2694b5f378 vo/x11_common: don't require a working input method
Normally, we need this for Xutf8LookupString(). But we can just fall
back to XLookupString(). In fact, the code for this was already there,
the code was just never tested and was actually crashing when active
(see commit 2115c4a).
2013-09-20 14:45:49 +02:00
Martin Herkt ed2d67b6d7 vo/x11_common: remove superfluous msg prefixes 2013-09-20 00:04:39 +02:00
Martin Herkt 2115c4a3ad vo/x11_common: Fail init with no valid XIM
XOpenIM can fail to find a valid input method, in which case it
returns NULL. Passing a NULL pointer to XCreateIC would cause a
crash, so fail VO init before that happens.
2013-09-19 20:08:34 +02:00
wm4 2f165ee12b gl_common: signal to GL backend whether we are probing
This is supposed to reduce the amount of useless error messages shown
during initialization of vo_opengl. If multiple backends are compiled,
usually only one of them will work. For example, on Linux both X and
Wayland backends can be compiled, but usually either Wayland or X is
running. Then, if Wayland is not running, but X is, trying to initialize
the Wayland backend should not spam the terminal with error messages.

Signed-off-by: Andreas Sinz <andreas.sinz@aon.at>
2013-09-16 13:45:33 +02:00
wm4 057407a39f x11_common: mp_msg conversion
Doesn't touch some parts, like the X11 error handler (which doesn't
allow setting a context pointer).
2013-09-12 01:34:41 +02:00
wm4 68e331851a options: remove --(no-)mouseinput option
I have no idea why it exists, as it's redundant to --(no-)mouse-movements.
2013-09-08 03:03:58 +02:00
wm4 dbff29c81d x11_common: don't allocate more than needed for icon
icon_size is the number of array items of type long, not bytes. Change
the type of icon_size to int, because size_t makes you think of byte
quantities too quickly.

As an unrelated change, change the (char *) cast to (unsigned char *),
because it matches the common XChangeProperty idiom better.
2013-09-04 13:37:38 +02:00
wm4 a5183a761c x11: add window icon
The png file added to etc/ are taken from the link mentioned in commit
303096b, except that they have been converted to 16 bit, sRGB (with
color profile info dropped, if there was one), and transparent pixels
reset for better compression.

The file x11_icon.bin is generated by gen-x11-icon.sh. I'm adding it to
the git repo directly, because the script requires ImageMagick, and we
don't want to make building even more complicated.

The way how this is done is basically a compromise between effort
required in x11_common.c and in gen-x11-icon.sh. Ideally, x11_icon.bin
would be directly in the format as required by _NET_WM_ICON, but trying
to write the binary width/height values from shell would probably be a
nightmare, so here we go.

The zlib code in x11_common.c is lifted from demux_mkv.c, with some
modifications (like accepting a gzip header, because I don't know how to
make gzip write raw compressed data).
2013-09-01 23:27:33 +02:00
wm4 0c7978cf9c input: deal with spurious X11 LeaveNotify events
If the mpv window is unfocus, clicking on the OSC should focus the
window (done by the window manager) and allow interaction with the OSC.
But somehow X sends a spurious LeaveNotify event, immediately followed
by an EnterNotify event. This happens at least with IceWM. The result is
that the OSC will disappear (due to receiving MOUSE_LEAVE). The OSC will
stay invisible, because EnterNotify isn't handled, and there's nothing
that could make the OSC appear again.

Solve this by handling EnterNotify. We cause a redundant MOUSE_MOVE
event to be sent, which triggers the code to make the OSC visible. We
have to remove the code from input.c, which ignores redundant mouse move
events.

Since the code ignoring redundant mouse move events is still needed on
Windows, move that code to w32_common.c. The need for this is documented
in the code, also see commit 03fd2fe. (The original idea was to save
some code by having this code in the core, but now it turns out that
this didn't quite work out.)
2013-09-01 20:17:51 +02:00
wm4 61ba810752 input: add some more X11 multimedia/internet keys
These keys can be found on various "multimedia" and "internet" keyboard.
X defines many keycodes, so I'm not adding all, just what I found on my
own keyboard.

Other key codes can be added on request.
2013-09-01 20:17:51 +02:00
wm4 3ffabe26af x11: fix --ontop
Apply it after mapping.
2013-08-14 00:36:33 +02:00
wm4 cdf4b7d2ee x11_common: get hack for Motif Window Manager out of the way
Disable the hack by default, because it's interfering with some more
modern WMs. MWM (Motif Window Manager) is probably pretty dead, but
we still allow enabling the old hack with "--fstype=mwm_hack".

See github issue #179.
2013-08-11 23:59:18 +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
wm4 50a84eb32d x11: add key modifiers to mouse button events 2013-07-21 18:07:09 +02:00
wm4 c4b08a9a11 video: remove fullscreen flags chaos
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>
2013-07-18 14:07:21 +02:00
wm4 d603e73c24 core: cleanup more mp_fifo leftovers
Now only the OSX and Wayland parts are using this.
2013-07-02 14:11:31 +02:00
wm4 c4766dc3c6 input: require VOs to send key up events, redo input key lookup
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".)
2013-07-02 12:19:16 +02:00
wm4 831a7cf3ee input: trigger mouse_leave key bindings if mouse leaves mouse area
Also, implement mouse leave events for X11. But evne on other
platforms, these events will be generated if mouse crosses a section's
mouse area boundaries within the mpv window.
2013-06-29 22:58:13 +02:00
wm4 168a595bfe video/out: introduce VOCTRL_UPDATE_WINDOW_TITLE
Instead of implicitly changing the window title on config(), do it as
part of the new VOCTRL.

At first I wanted to make all VOs use the VOCTRL argument directly, but
on a second thought it appears vo_get_window_title() is much more useful
for some (namely, if the window is created lazily on first config()).

Not all VOs are changed. Wayland and OSX have to follow.
2013-06-15 19:07:21 +02:00
wm4 f1d3ba0e33 x11: enable screensaver when paused, rename/change --stop-xscreensaver
Use the recently introduced screensaver VOCTRLs to control the
screensaver in the X11 backend. This means the behavior when paused
changes: the old code always kept the screensaver disabled, but now the
screensaver is reenabled on pausing.

Rename the --stop-xscreensaver option to --stop-screensaver and make it
more generic. Now it affects all backends that respond to the
screensaver VOCTRLs.
2013-06-14 00:37:39 +02:00
wm4 e56d8a200d Replace all calls to GetTimer()/GetTimerMS()
GetTimer() is generally replaced with mp_time_us(). Both calls return
microseconds, but the latter uses int64_t, us defined to never wrap,
and never returns 0 or negative values.

GetTimerMS() has no direct replacement. Instead the other functions are
used.

For some code, switch to mp_time_sec(), which returns the time as double
float value in seconds. The returned time is offset to program start
time, so there is enough precision left to deliver microsecond
resolution for at least 100 years. Unless it's casted to a float
(or the CPU reduces precision), which is why we still use mp_time_us()
out of paranoia in places where precision is clearly needed.

Always switch to the correct time. The whole point of the new timer
calls is that they don't wrap, and storing microseconds in unsigned int
variables would negate this.

In some cases, remove wrap-around handling for time values.
2013-05-26 16:44:20 +02:00
wm4 c76c65441a x11: remove cursor hiding logic, use VOCTRL_SET_CURSOR_VISIBILITY 2013-05-26 16:44:19 +02:00
wm4 d5de75b340 x11: use vo_x11_control() for all VOs 2013-05-26 16:44:19 +02:00
wm4 bf10a4fdfa video/out: introduce vo_control for gl_common based VOs
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.
2013-05-26 16:44:18 +02:00
wm4 266230ad64 Silence some compiler warnings
None of these were actual issues.
2013-05-21 00:04:27 +02:00
wm4 d853abafc3 x11: use mpv internal key auto-repeat handling if possible
Block X11's native key repeat, and use mpv's key repeat handling in
input.c instead.

No configure check for XKB. Even though it's an extension, it has been
part of most (all?) xlibs since 1996. If XKB appears to be missing,
just refuse enabling x11.

This is a potentially controversial change. mpv will use its own key
repeat rate, instead of X11's. This should be better, because seeking
will have a standardized "speed" (seek events per seconds when keeping
a seek key held down). It will also allow disabling key repears for
certain commands, though this is not done anywhere yet.

The new behavior can be disabled with the --native-keyrepeat option.
2013-04-24 18:07:01 +02:00
wm4 465ccd2c93 x11_common: minor simplification 2013-04-21 00:39:54 +02:00
wm4 ea03cc6712 x11_common: remove assumption that video is always centered
The vo_x11_clearwindow_part() function assumed that the video is always
centered. Replace it with a new vo_x11_clear_background() function
instead, which essentially does the same as the old function. It takes
the video rectangle instead of just the video size, and doesn't have to
make the assumption that the video rectangle is centered.

Also make vo_x11 use it (seems advantageous).
2013-03-17 23:01:33 +01:00
Alexander Preisinger 1198c031e4 vo: Separate vo options from MPOpts
Separate the video output options from the big MPOpts structure and also only
pass the new mp_vo_opts structure to the vo backend.

Move video_driver_list into mp_vo_opts
2013-03-04 23:32:47 +01:00
Alexander Preisinger 7686cd7f04 vo: remove and cleanup globals
Removes almost every global variabel in vo.h and puts them in a special struct
in MPOpts for video output related options.

Also we completly remove the options/globals pts and refresh rate because
they were unused.
2013-03-04 17:40:21 +01:00
wm4 ca893689fe x11_common: fix --cursor-autohide when paused
When paused, --cursor-autohide worked with a precision of 500ms, which
is the main loop's default sleep time when paused. Cursor hiding is
polled in x11_common, and the main loop never called the X11 code at
the right time. Fix this by allowing the VO to set a time when it
should be called next.
2013-03-03 15:36:56 +01:00
wm4 ba35335939 x11_common: fix window mapping, refactor window creation/resize handling
vo_opengl creates an invisible window with VOFLAG_HIDDEN in order to
test whether the OpenGL context is useable. The visible window is
created at a later point. This has been broken forever (in vo_gl,
now called vo_opengl_old, it could be avoided by disabling auto-
detection explicitly using the "yuv" sub-option). Avoiding
VOFLAG_HIDDEN only mitigates the issue, and a related bug can still
happen with some window managers (see below).

As a hack, code was added to vo_gl to destroy the (hidden) window so
that all state was destroyed. Later, more hacks were added to deal with
some caveats that came with recreating the window, such as probing for
the context up to 4 times.

Attempt to fix the problem properly. There were two problems: first,
the window was not resized to video size before mapping. This was the
main cause for the placement issue, e.g. mapping the window as 320x200,
and then resizing it. Second, mpv tried to force the window position
with XSetWMNormalHints and PPosition with values it just read with
XGetGeometry. This messes up the window manager's default placement.
It seems to be a race condition, and behavior is different across
various WMs too: with IceWM, the window manager's placement is usually
preferred, and with Fluxbox, mpv's position is preferred. mpv's default
position is centering the window on the screen, which is much nicer for
video in general than typical WM default placement, so it's possible
that this bug was perceived as a feature. (Users who want this have to
use --geometry="50%:50%", doing this by default is probably not safe
with all WMs.)

Since the old code was hard to follow and full of issues, it's easier
to redo it. Move general window creation stuff out of the
vo_x11_config_vo_window function, and move the resize logic into it.

This has been tested on IcwWM, Fluxbox, awesome, Unity/Compiz.
2013-03-03 15:36:27 +01:00
wm4 1b09f46338 x11_common: use private variables for window state
Store the window state (position and size) in vo_x11_state, instead of
in vo->dx/dy/dwidth/dheight. The VO variables are overwritten by vo.c on
every vo_config() call, which is extremely not helpful.

Now vo->dx/dy are mostly unused (except for passing the position forced
by the --geometry option), and vo->dwidth/dheight are set for the VO,
and otherwise read for resize detection only.

In the long term, the way vo_config() handles the --geometry option
should be changed, and vo->dx/dy should be removed.

Remove some useless stuff: VO_EVENT_MOVE and VO_EVENT_KEYPRESS were
generated, but unused. Wayland changes by Alexander Preisinger.
2013-03-03 14:19:57 +01:00
wm4 fdc1560a0e core: move X11 specific code to x11_common.c
Nothing changes, because vo_check_events() is called at the same place
anyway.
2013-03-01 11:17:56 +01:00
wm4 70346d3be6 video/out: remove video mode switching (--vm)
This allowed making the player switch the monitor video mode when
creating the video window. This was a questionable feature, and with
today's LCD screens certainly not useful anymore. Switching to a random
video mode (going by video width/height) doesn't sound too useful
either.

I'm not sure about the win32 implementation, but the X part had several
bugs. Even in mplayer-svn (where x11_common.c hasn't been receiving any
larger changes for a long time), this code is buggy and doesn't do the
right thing anyway. (And what the hell _did_ it do when using multiple
physical monitors?)

If you really want this, write a shell script that calls xrandr before
and after calling mpv.

vo_sdl still can do mode switching, because SDL has native support for
it, and using it is trivial. Add a new sub-option for this.
2013-02-26 02:01:48 +01:00
wm4 b23dce6d7c x11_common: always create a window, even with --wid
The --wid switch (for embedding the player into other applications)
didn't create a new window, and instead tried to use the window that
was passed via --wid directly. This made the code more complex, caused
strange X errors (mpv and host application fighting for exclusive X
resources), and actually could cause issues if the --wid window wasn't
created with the X Visual needed for OpenGL.

Always create a window instead. This makes it always possible to embed
the player into foreign windows. --geometry doesn't work anymore - the
controlling application should always create a new window to place the
player inside it, and can control the video window by moving and
resizing this window.

w32_common.c actually did this right, and always creates a new window.
2013-02-26 02:01:48 +01:00
wm4 423c0b13c4 video/out: rename create_window to config_window
create_window is really bad naming, because this function can be called
multiple times, while the name implies that it always creates a new
window. At least the name config_window is not actively misleading.
2013-02-26 02:01:48 +01:00
wm4 af54ff826b Remove --rootwin option and rootwin property
You can just use --wid=0 if you really want this.

This only worked/works for X11, and even then it might interact badly
with most desktop environments. All the option did was setting --wid to
0, and the property did nothing.
2013-02-24 17:00:52 +01:00
Stefano Pigozzi e540e5d4da core: add fs-screen option for fullscreen display selection
`--fs-screen` allows to decide what display to go fullscreen into. The
semantics of `--screen` changed and now it is only used to select the windowed
display when starting the application.

This is useful for people using mpv with an external TV. They will start
windowed on their laptop's screen and switch to fullscreen on the TV.

@wm4 worked on the x11 and w32 parts of the code. All is squashed in one
commit for history clarity.
2013-02-21 22:23:08 +01:00
Stefano Pigozzi 41c1749f46 core: move `xineramascreen` to `MPOpts` as `vo_screen_id`
This is a small cleanup in preparation for the next commit.
2013-02-21 22:23:08 +01:00
wm4 08952f23dd x11_common: uncrustify
Also some other cosmetic changes. And reformat the two remaining doxygen
comments.

Removing MSGLEN in x11_errorhandler() is technically not just a cosmetic
change, but the result is the same anyway.
2013-02-21 22:23:08 +01:00