summaryrefslogtreecommitdiffstats
path: root/video/out/x11_common.h
Commit message (Collapse)AuthorAgeFilesLines
* vo_opengl, x11: implement icc-profile-autowm42015-01-261-0/+3
| | | | | | | | | | | | | | | | | This queries the _ICC_PROFILE property on the root window. It also tries to reload the ICC when it changes, or if the mpv window changes the monitor. (If multiple monitors are covered, mpv will randomly select one of them.) The official spec is a dead link on freedesktop.org, so don't blame me for any bugs. Note that this assumes that Xinerama screen numbers match the way mpv enumerates the xrandr monitors. Although there is some chance that this matches, it most likely doesn't, and we actually have to do complicated things to map the screen numbers. If it turns out that this is required, I will fix it as soon as someone with a suitable setup for testing the fix reports it.
* x11: copy WinID optionwm42014-12-091-0/+1
| | | | For the purpose of making "--wid" setable at any time.
* vo/x11: implement VOCTRL_GET_DISPLAY_NAMES with xrandr names (e.g., "LVDS1")Kevin Mitchell2014-11-071-0/+1
| | | | | | | | 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.
* x11: rely on the Atom cachewm42014-11-031-4/+0
| | | | | XInternAtom() has a 64 entry hash table to avoid network accesses. Rely on this cache, instead of caching these manually.
* command: add window-minimized property (X11 only)wm42014-11-021-0/+1
| | | | | | More or less requested by #1237. Should be simple to extend this to other backends.
* x11: if the WM supports _NET_FRAME_EXTENTS, don't wait for mapwm42014-09-151-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* x11: remove unused functionwm42014-09-141-2/+0
|
* x11: listen to xrandr eventswm42014-08-171-0/+2
| | | | | | | | | | | 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.
* x11: use xrandr to retrieve display refresh ratewm42014-08-161-0/+11
| | | | | | | | | | | | | | | | | 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.
* x11: cleanup motif hints handlingwm42014-06-061-4/+0
| | | | | | | | 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.
* x11: un-inline GNOME layer stuffwm42014-05-231-1/+1
| | | | | | Having it as separate function is not useful. Also remove the useless vo_window parameter.
* x11: never enable DPMS if we didn't disable itwm42014-05-181-0/+1
| | | | | | | | | 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.
* x11: make screensaver code more compact, change DPMS handlingwm42014-05-171-2/+1
| | | | | | | | 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.
* x11: replace x/y/w/h with mp_rectwm42014-05-171-10/+3
|
* x11: remove some unused fieldswm42014-05-171-3/+0
|
* x11: remove vo_hint memberwm42014-05-171-1/+0
| | | | | Now it's always recreated in vo_x11_sizehint(). Also, the Xlib manual says you must use XAllocSizeHints() (for ABI reasons), so do that.
* x11: remove gravity restore codewm42014-05-171-1/+0
| | | | | | | | | | 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
* x11: don't cache X Atoms manuallywm42014-05-161-31/+0
| | | | | XInternAtom() already caches lookups. Even if calling XInternAtom would be always inefficient, it wouldn't matter much during normal playback.
* x11: replace--[x11-]fstype option with --x11-netwmwm42014-05-161-1/+0
| | | | | Simplifies the code a lot. You can still use --x11-netwm=no to disable NetWM for whatever reasons.
* x11: don't use VOCTRL_UPDATE_SCREENINFOwm42014-05-061-3/+4
| | | | See previous commit.
* x11: implement window dragging by grabbingwm42014-03-181-0/+4
| | | | | | | | | | | | | | | | | | 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.
* video/out: remove pointless x/y parameter from vo_x11_config_vo_windowwm42014-01-111-2/+1
| | | | | This never made any real sense; the "backend" has to access vo->dx/dy anyway.
* x11: implement dropping files on the VO windowwm42014-01-041-0/+17
| | | | | | | | | | | | | | | | | | | | 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
* x11: mp_msg conversion for fstype help outputwm42013-12-211-1/+2
|
* Reduce recursive config.h inclusions in headerswm42013-12-181-2/+0
| | | | | | In my opinion, config.h inclusions should be kept to a minimum. MPlayer code really liked including config.h everywhere, though, even in often used header files. Try to reduce this.
* x11: fix border togglingwm42013-10-271-0/+2
| | | | | | | | | | | | | 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.
* x11: remove colormap code, always request TrueColor visualswm42013-09-301-10/+0
| | | | | | | | | | | | | | | | | | | | 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.
* x11_common: mp_msg conversionwm42013-09-121-0/+1
| | | | | Doesn't touch some parts, like the X11 error handler (which doesn't allow setting a context pointer).
* x11: add window iconwm42013-09-011-0/+1
| | | | | | | | | | | | | | | | | | | | | 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).
* video: remove fullscreen flags chaoswm42013-07-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Replace all calls to GetTimer()/GetTimerMS()wm42013-05-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | 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.
* x11: remove cursor hiding logic, use VOCTRL_SET_CURSOR_VISIBILITYwm42013-05-261-2/+1
|
* x11: use vo_x11_control() for all VOswm42013-05-261-4/+0
|
* video/out: introduce vo_control for gl_common based VOswm42013-05-261-0/+1
| | | | | | | | | | | | | | | | 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.
* x11: use mpv internal key auto-repeat handling if possiblewm42013-04-241-0/+1
| | | | | | | | | | | | | | | | | 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.
* x11_common: remove assumption that video is always centeredwm42013-03-171-2/+2
| | | | | | | | | | 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).
* x11_common: fix window mapping, refactor window creation/resize handlingwm42013-03-031-9/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* x11_common: use private variables for window statewm42013-03-031-0/+8
| | | | | | | | | | | | | | | | 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.
* core: move X11 specific code to x11_common.cwm42013-03-011-2/+0
| | | | | Nothing changes, because vo_check_events() is called at the same place anyway.
* video/out: remove video mode switching (--vm)wm42013-02-261-2/+0
| | | | | | | | | | | | | | | | | | | | 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.
* video/out: rename create_window to config_windowwm42013-02-261-1/+1
| | | | | | 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.
* core: add fs-screen option for fullscreen display selectionStefano Pigozzi2013-02-211-0/+2
| | | | | | | | | | | | `--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.
* x11_common: uncrustifywm42013-02-211-3/+4
| | | | | | | | 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.
* x11: simplify handling of X Visuals and Colormaps in VOswm42013-01-271-2/+2
| | | | | | | | | | | | | | | | | Don't force VOs to pick an arbitrary default Visual and Colormap. They still can override them if needed. This simplifies the X11 VO interface. Always create a Colormap for simplicity. Using CopyFromParent fails if the selected visual is not the same of that of the parent window, which happens for me with vo_opengl. vo_vdpau and vo_xv explicitly set CWBorderPixel, do that in x11_common instead (it was already done for native windows, but not for slave mode windows). What gl_common did was incorrect in theory: freeing a colormap while a window uses it will change the colormap of the window to "None", and the color mapping for such windows is "undefined".
* x11: fix some obvious video mode switching bugswm42013-01-271-0/+1
| | | | | | | | | | | | | | | The original video mode wasn't reliably restored, so just store the mode separately. For some reason, window decorations got into the picture, possibly due to an incorrect initial window position or something like this. Normally, the window is positioned and sized such that it covers the screen entirely, even though the window still has decorations and is not in fullscreen mode (fullscreen wouldn't be correct, because the virtual desktop size is not screen size). Hack-fix by forcing window decorations off when VM-switching. All in all, VM switching is still buggy and useless.
* x11: reduce VO mode switching code duplicationwm42013-01-271-5/+1
| | | | | | | | | | | | | | Some parts for initiating mode switches were duplicated in every VO supporting X11 (except vo_opengl/gl_common, which didn't support mode switching). Move this to x11_common.c. Note that this might be slightly risky: is it really guaranteed that no VO needed to do "special" setup that depends on X parameters changing after a mode switch, such as bit depth, visuals etc.? From what I can see, this shouldn't be the case (X probably can't even change depth on the fly). Even if this should be a one-way road, VM switching is in general very useless, and its implementation buggy, so it can just be removed should unfixable problems arise.
* x11: cleanup, refactorwm42013-01-271-66/+18
| | | | | | | | | | | | | | | | Move things that are used by vo_xv only into vo_xv, same for vo_x11. Rename some functions exported by x11_common, like vo_init to vo_x11_common. Make functions not used outsode of x11_common.c private to that file. Eliminate all global variables defined b