0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00
Commit Graph

223 Commits

Author SHA1 Message Date
wm4
927afa311d build: make various x11 protocol extension libs mandatory
Reduces the ifdeffery, which is good and will avoid silent breakages, or
weird behavior if a lib is omitted.

Also reorder the x11_common.c include statements.
2017-04-21 07:30:03 +02:00
wm4
a35a5bb5f3 x11: pseudo HiDPI scaling
Scale the window by the assumed DPI scaling factor, using 96 DPI as
base. For example, a screen that reports 192 DPI is assumed to have a
DPI scale factor 2. The window will then be created with twice the size.

For robustness reasons, we accept only integer DPI scales between 1 and
9. We also error out if the X and Y scales are very different, as this
most likely indicates a multiscreen system with botched size reporting.

I'm not sure if reading the X server's DPI is such a good idea - maybe
the Xrdb "Xft.dpi" value should be used instead. The current method
follows what xdpyinfo does.

This can be disabled with --hidpi-window-scale=no.
2017-01-19 16:31:54 +01:00
wm4
58a0c43cf4 vo_opengl: x11: move RGBA visual test to x11_common.c
So that the EGL code can use it too.

Also print the actual FB config ID, instead of nonsense. (I _think_ once
in the past a certain GLX implementation just used numeric config IDs
casted to EGLConfig - or at least that would explain this nonsense.)
2016-12-30 20:04:32 +01:00
wm4
caa14e3d45 x11: fix external fullscreen update
On x11, you can change the fullscreen via the window manager and without
mpv's involvement. In these cases, the internal fullscreen flag has to
be updated.

The hack used for this didn't really work properly. Change it
accordingly. The important thing is that the shadow copy of the option
is updated. This is still not really ideal.

Fixes #3570.
2016-09-23 12:09:48 +02:00
wm4
591e21a2eb osdep: rename atomics.h to atomic.h
The standard header is stdatomic.h, so the extra "s" freaks me out every
time I look at it.
2016-09-07 11:26:25 +02:00
wm4
2c917219cf vo: use new option update mechanism
This is still rather basic.

run_reconfig() and run_control() update the options because it's needed
for panscan (and other video scaling options), and fullscreen, border,
ontop updates. In the old model, these options could be accessed only
while both playback thread and VO threads were locked  (i.e. during
synchronous calls like vo_control()), so this should be sufficient in
order not to miss any updates. In the future, a more fine-grained update
mechanism could be added to handle these updates "exactly".

x11_common.c contains an evil hack, as I see no reasonable way to handle
this properly. The VO thread can't "lock" the main thread, so this is
not simple.
2016-09-02 15:50:54 +02:00
wm4
4d75514321 vo: change messy handling of fullscreen and other flags
Before this commit, all VOs had to toggle the option flag themselves,
now command.c does it.

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

This change will be useful for cleaning up VO option handling.
2016-08-30 23:52:16 +02:00
wm4
37d6604d70 x11, wayland: always round up wait times
If wait_us is >0 and <500, the wait time gets rounded down 0,
effectively turning this into busy waiting. Round it up instead.
2016-08-26 20:22:33 +02:00
wm4
2a5b61244f x11: work around mutter fullscreen issue
If the video has the same size as the screen, starting with --fs and
then leaving fullscreen doesn't actually leave fullscreen.

The reason is that mpv tries to restore the previous window size if
necessary (otherwise, you'd end up with a Window of nearly the same size
as the screen with some WMs). It will typically restore with the
rectangle set exactly to the screen if no other position or size is
forced. This triggers pre-EWMH fullscreen mode, which WMs detect using
various heuristics.

Apparently we triggered this with mutter (but strangely no other WMs).
It's possible that pre-EWMH fullscreen mode actually requires removing
decorations, and mutter either ignores this. But this is speculation and
I haven't checked.

Work this around by reducing the requested size by 1 pixel if it
happens.

This was observed with mutter 3.18.2.

Fixes #2072.
2016-08-25 14:16:10 +02:00
Rostislav Pehlivanov
c3e11f7b7c osdep/io: introduce mp_flush_wakeup_pipe()
Makes a fairly common occurence with wakeup_pipes easier to handle.
2016-07-30 00:02:39 +02:00
wm4
cb4342dda4 x11: do not accidentally discard event flags
It seems vo_x11_check_events() was supposed to return the currently
flagged events and reset them. But there are many places where
vo_x11_check_events() is called without checking its return value. This
could lead to forgotten events.

Change the code such that they can't get lost.
2016-07-25 11:28:06 +02:00
wm4
16d276308a x11, wayland: do not accidentally close FD 0
Both backends have code to close each FD of their wakeup_pipe array.
This array is default-initialized with 0, which means if the backends
exit before the wakeup pipe is created (e.g. when probing), they would
close FD 0.

Initialize the FDs with -1. Then we call close(-1) in these situations,
which is perfectly allowed and has no bad consequences.
2016-07-21 15:18:32 +02:00
wm4
fde784129f x11: stop using vo.event_fd
Instead let it do its own event loop wakeup handling.
2016-07-20 20:52:08 +02:00
wm4
64cd0f4292 x11: skip ICC update on every window move
Don't just cause vo_opengl to update the ICC profile every time the
window is moved. Instead, explicitly check if the screen was changed.

Mostly untested.
2016-07-18 13:06:38 +02:00
wm4
35be389031 x11: add missing FocusChangeMask
So we actually get FocusOut events. Disables key repeat when losing
focus while a key is down.
2016-07-08 16:36:53 +02:00
Ben Boeckel
4f4eea6b44 x11_common: silence xdg-screensaver
Some screen lockers have a habit of dumping output to the terminal when
their output is reset. Ignore its output to keep the TTY output clean.
2016-07-05 19:16:01 +02:00
Mantas Mikulėnas
00c9bdf3f7 x11: tell GNOME to use dark window decorations 2016-05-09 20:39:59 +02:00
wm4
8fe33a11e2 x11: slightly safer X11 error handler behavior
The X11 error handler is global, and not per-display. If another Xlib
user exists in the process, they can conflict. In theory, it might
happen that e.g. another library sets an error handler (overwriting the
mpv one), and some time after mpv closes its display, restores the error
handler to mpv's one. To mitigate this, check if the error log instance
is actually set, instead of possibly crashing.

The change in vo_x11_uninit() is mostly cosmetic.
2016-05-08 11:04:44 +02:00
wm4
55846641ea x11: add --x11-bypass-compositor=always
Also add missing documentation for fs-only, and correct the default.
2016-05-06 19:57:17 +02:00
wm4
8a26e139af x11: extend --x11-bypass-compositor with fs-only option
The "fs-only" choice sets the _NET_WM_BYPASS_COMPOSITOR to 1 if the
window is fullscreened, and 0 otherwise. (0 is specified to be the
implicit default - i.e. no change is requested in windowed mode.)

In particular, change the default to "fs-only".

Fixes #2582.
2016-05-02 21:21:53 +02:00
wm4
7e75e2a5dc x11, input: move mime type drag&drop negotiation to common code
Drag&drop mechanisms typically support multiple types for the drop data.
Move most of the logic which types are accepted and preferred to
event.c, where the data is also interpreted.

(Maybe sorting the types by assigning scores is over-engineered, since
they're already sorted by preference, but it's actually not much more
code.)

Not very interesting/meaningful yet, but preparation for the next
commit.
2016-03-15 22:42:06 +01:00
wm4
718cc27f34 x11: move vo->input_ctx accesses to x11->input_ctx
Reduces VO access and makes the code more self-contained. (One day the
windowing backend code should not access the VO anymore. We're just not
quite there yet.)
2016-03-15 22:11:31 +01:00
Tracerneo
ca9124cd07 x11: stop waiting for MapNotify when WM_STATE changes
Signed-off-by: wm4 <wm4@nowhere>
2016-01-31 00:10:20 +01:00
Nils Schneider
c406f83d37 x11: get *current* XRandR screen configuration
Only request the current screen configuration instead of polling for new
screens, too. We're not interested in detecting any new screens as we're
merely enumerating what is currently connected and configured.

On some hardware (like mine) calling XRRGetScreenResources will stall
X11 for about 10 to 20 seconds. This has annoyed me for a few months
now and almost made me switch to VLC ;)

Signed-off-by: wm4 <wm4@nowhere>
2016-01-20 20:28:16 +01:00
Dmitrij D. Czarkoff
ea442fa047 mpv_talloc.h: rename from talloc.h
This change helps avoiding conflict with talloc.h from libtalloc.
2016-01-11 21:05:55 +01:00
wm4
fa315705be x11: silence xdg-screensaver failure message 2016-01-03 15:50:00 +01:00
wm4
9db50c6760 vo: get rid of vo_get_window_title()
It always was a weird artifact - VOCTRLs are meant _not_ to require
special handling in the code that passes them through (like in vo.c).
Removing it is also interesting to further reduce the dependency of
backends on struct vo. Just get rid of it.

Removing it is somewhat inconvenient, because in many situations the UI
window is created after the first VOCTRL_UPDATE_WINDOW_TITLE. This means
these backends have to store it in a new field in their own context.
2015-12-06 18:41:31 +01:00
wm4
516e7d19da x11: request bypassing compositor
Maybe this is a good idea. Also add an option to disable it again, for
the sake of testing.

Fixes #2502.
2015-11-18 21:48:29 +01:00
wm4
6bbb1e4cf9 x11: print Xlib errors in verbose mode if Xlib messages are silenced
Follow up to commit b984ec52.
2015-11-07 17:43:10 +01:00
wm4
b984ec52aa vo_opengl: x11: silence error messages when using legacy GL context
glXCreateContextAttribsARB() by design can throw some X11 errors. We
ignore these, but we generally still print error messages to the
terminal. This was confusing/annoying users, so silence it. The stupid
part is that the Xlib error handler is global, so we have to be slightly
careful here.
2015-11-06 21:20:23 +01:00
wm4
7c5f41ff5f x11: separate window creation and configuration
This gets rid of an old hack, VOFLAG_HIDDEN. Although handling of it has
been sane for a while, it used to cause much pain, and is still
unintuitive and weird even today.

The main reason for this hack is that OpenGL selects a X11 Visual for
you, and you're supposed to use this Visual when creating the X window
for the OpenGL context. Which means the X window can't be created early
in the common X11 init code, but the OpenGL code needs to do something
before that. API-wise you need separate functions for X11 init and X11
window creation. The VOFLAG_HIDDEN hack conflated window creation and
the entrypoint for resizing on video resolution change into one
function, vo_x11_config_vo_window(). This required all platform backends
to handle this flag, even if they didn't need this mechanism.

Wayland still uses this for minor reasons (alpha support?), so the
wayland backend must be changed before the flag can be entirely removed.
2015-09-30 23:31:34 +02:00
Kevin Mitchell
638322f77e x11: drag and drop append with modifier
If the drag and drop action is anything other than
XdndActionCopy, append the dropped files rather than
replacing the existing playlist. With most file managers,
this will mean at least pressing shift while dropping.
2015-08-30 05:28:30 -07:00
Kevin Mitchell
c80b7eed53 input: add append argument to file drop event
This puts in place the machinery to merely append dropped file to the playlist
instead of replacing the existing playlist. In this commit, all front-ends
set this to false preserving the existing behaviour.
2015-08-30 05:28:24 -07:00
wm4
6afef5839f x11: move GCs and background clearing to vo_xv
vo_xv.c is the only place where these things are used.
2015-07-01 23:55:10 +02:00
wm4
8dff03560a x11: remove clear on map
Less code, and avoids a black flash on start.

In theory it could happen that we map the window, and then don't have a
frame to draw - but mapping the window is done in the exact moment we
have a new frame to display.
2015-07-01 23:46:34 +02:00
wm4
d98cd6609d x11: remove trailing spaces 2015-06-29 15:09:28 +02:00
Eduardo Sánchez Muñoz
db3d36927d x11: Handle external fullscreen toggles
Some window managers let you change the fullscreen state of any window
using a key combination. For example, on XFWM you can use Alt+F11 and
on Compiz you can configure a key combination with the
"Extra WM actions" plugin.

With this change mpv will handle these fullscreen state changes. So, if
you enter into fullscreen mode using the WM's shortcut and then you use
mpv's fullscreen toggle, you will get back into window mode.

Merges PR #2081.

Signed-off-by: wm4 <wm4@nowhere>
2015-06-28 20:13:57 +02:00
wm4
b17b8ff7fe x11: make screensaver failure message slightly more friendly 2015-06-20 21:55:15 +02:00
wm4
be9bf4cc7c x11: never forcefully terminate xdg-screensaver process
It sometimes happens on exit, and it's probably a bad idea. If the
process hangs on exit (possibly due to stupid hardcoded timeouts it's
doing), mpv will also hang now, unfortunately.
2015-05-18 22:25:59 +02:00
wm4
a4f3df5970 x11: attempt to make initial fullscreening more reliable
It appears some WMs have a problem with out method of setting initial
fullscreen mode. We assume that if the window's _NET_WM_STATE includes
_NET_WM_STATE_FULLSCREEN before mapping the window, the WM will show it
as fullscreen at mapped. EWMH doesn't say anything that this should
work, although one could argue that it's implied.

In any case, since it's not standard behavior without at least some
doubt, it's probably a good idea to try the "old" method as well.
Fortunately, it should be idempotent.

See #1937, #1920.
2015-05-15 13:50:44 +02:00
Niklas Haas
daf4334697
x11: query ICC profile based on center of window
Right now, the default behavior is to pick the numerically lowest screen
ID that overlaps the window in any way - but this means that mpv will
decide to pick an ICC profile in a pretty arbitrary way even if the
window only overlaps another screen by a single pixel.

The new behavior is to query it based on the center of the window
instead.
2015-04-29 14:01:27 +02:00
wm4
dd12040ebe x11: actually disable screensaver
We already use 2 screensaver APIs when attempting to disable the
screensaver: XResetScreenSaver() (from xlib) and XScreenSaverSuspend
(from the X11 Screen Saver extension). None of these actually work.

On modern desktop Linux, we are expected to make dbus calls using some
freedesktop-defined protocol (and possibly we'd have to fallback to a
Gnome specific one). At least xscreensaver doesn't respect the "old"
APIs either.

Solve this by running the xdg-screensaver script. It's a terrible, ugly
piece of shit (just read the script if you disagree), but at least it
appears to work everywhere. It's also simpler than involving various
dbus client libraries.

I hope this can replace the --heartbeat-cmd option, and maybe we could
remove our own DPMS/XSS code too.
2015-04-15 22:40:19 +02:00
Marcin Kurczewski
f43017bfe9 Update license headers
Signed-off-by: wm4 <wm4@nowhere>
2015-04-13 12:10:01 +02:00
wm4
30860f7b10 x11: ignore mouse enter/leave events due to pointer grab
If you click on a window that doesn't have a focus, a LeaveNotify
followed by a EnterNotify event can be generated. The former will have
mode set to NotifyGrab, the latter to NotifyUngrab. This will make the
player think the mouse left the window, even though this is not the
case. Ignore these and only react to those with mode set to
NotifyNormal.

Probably fixes #1672, and some other strange issues on some WMs.
2015-03-11 11:52:33 +01:00
wm4
b7f242dfcf x11: fix VOCTRL_GET_WIN_STATE
Do not rely on the pointed-to argument to be initialized; VOCTRLs are
supposed to completely overwrite them on success (or not to touch them
on failure).

The currently only caller of VOCTRL_GET_WIN_STATE initializes the value
before calling this, so this is merely about correctness and didn't lead
to any actual bugs.
2015-03-09 11:46:16 +01:00
Martin Herkt
1bab7f69ae vo_opengl/x11: fix automatic ICC profile loading
mpv would attempt to load ICC profiles several times during VO init
even if no window is displayed. This potentially causes it to load
a profile for a different screen than it is going to be displayed
on, thereby invalidating the profile cache and rebuilding the LUT
every single time.
It would not unload a previously loaded profile when the video
window is moved to a display without an installed profile.

Fix these issues and tweak the log messages a little.
2015-03-07 13:00:06 +01:00
torque
3b269ac0a0 input: add MOUSE_ENTER keybinding.
Signed-off-by: wm4 <wm4@nowhere>
2015-02-18 00:03:16 +01:00
wm4
f247294d73 x11: fix uninitialized variable reads
This line of code ended up in the wrong block in commit cd6dfcbe.
2015-02-14 16:45:38 +01:00
Martin Herkt
9aaec7cffb x11: add XK_Cancel to the list of special keys
Some IR receivers emit this key by default for remote control
buttons. Make it mappable.
2015-02-14 03:50:26 +01:00
wm4
cd6dfcbef4 x11: return a framerate even if no window is mapped
Falls back to the first display in the list returned by xrandr. Not
entirely correct, but makes some people happy (see #1575).
2015-02-13 22:34:26 +01:00