summaryrefslogtreecommitdiffstats
path: root/video/out/x11_common.c
Commit message (Collapse)AuthorAgeFilesLines
* x11: fix border togglingwm42013-11-021-2/+3
| | | | | | | | | | | | | 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_common: reduce screensaver heartbeat from 30 to 10 secondswm42013-11-021-1/+1
| | | | | Apparently this fixes issues with Gnome, which has a smaller timeout. See github issue #315.
* x11_common: don't handle mouse enter eventswm42013-10-151-5/+1
| | | | | | | | | | | | | | | | | | | | 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.)
* x11: remove colormap code, always request TrueColor visualswm42013-09-301-145/+5
| | | | | | | | | | | | | | | | | | | | 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.
* vo/x11_common: don't require a working input methodwm42013-09-201-14/+9
| | | | | | | 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).
* vo/x11_common: remove superfluous msg prefixesMartin Herkt2013-09-201-2/+2
|
* vo/x11_common: Fail init with no valid XIMMartin Herkt2013-09-191-0/+9
| | | | | | 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.
* gl_common: signal to GL backend whether we are probingwm42013-09-161-1/+3
| | | | | | | | | | | 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>
* x11_common: mp_msg conversionwm42013-09-121-40/+37
| | | | | Doesn't touch some parts, like the X11 error handler (which doesn't allow setting a context pointer).
* options: remove --(no-)mouseinput optionwm42013-09-081-1/+1
| | | | I have no idea why it exists, as it's redundant to --(no-)mouse-movements.
* x11_common: don't allocate more than needed for iconwm42013-09-041-3/+4
| | | | | | | | | 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.
* x11: add window iconwm42013-09-011-0/+104
| | | | | | | | | | | | | | | | | | | | | 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).
* input: deal with spurious X11 LeaveNotify eventswm42013-09-011-1/+5
| | | | | | | | | | | | | | | | | | | | | 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.)
* input: add some more X11 multimedia/internet keyswm42013-09-011-0/+3
| | | | | | | | 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.
* x11: fix --ontopwm42013-08-141-3/+3
| | | | Apply it after mapping.
* x11_common: get hack for Motif Window Manager out of the waywm42013-08-111-1/+11
| | | | | | | | 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.
* core: move contents to mpvcore (2/2)Stefano Pigozzi2013-08-061-6/+6
| | | | Followup commit. Fixes all the files references.
* x11: add key modifiers to mouse button eventswm42013-07-211-13/+19
|
* video: remove fullscreen flags chaoswm42013-07-181-16/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* core: cleanup more mp_fifo leftoverswm42013-07-021-15/+15
| | | | Now only the OSX and Wayland parts are using this.
* input: require VOs to send key up events, redo input key lookupwm42013-07-021-1/+2
| | | | | | | | | | | | | | Making key up events implicit was sort-of a nice idea, but it's too tricky and unreliable and makes the key lookup code (interpret_keys()) hard to reason about. See e.g. previous commit for subtle bugs and issues this caused. Make key-up events explicit instead. Add key up events to all VOs. Any time MP_KEY_STATE_DOWN is used, the matching key up event must use MP_KEY_STATE_UP. Rewrite the key lookup code. It should be simpler and more robust now. (Even though the LOC increases, because the new code is less "compact".)
* input: trigger mouse_leave key bindings if mouse leaves mouse areawm42013-06-291-2/+5
| | | | | | 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.
* video/out: introduce VOCTRL_UPDATE_WINDOW_TITLEwm42013-06-151-1/+8
| | | | | | | | | | | 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.
* x11: enable screensaver when paused, rename/change --stop-xscreensaverwm42013-06-141-3/+7
| | | | | | | | | | | 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.
* Replace all calls to GetTimer()/GetTimerMS()wm42013-05-261-2/+2
| | | | | | | | | | | | | | | | | | | | | | 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-46/+32
|
* x11: use vo_x11_control() for all VOswm42013-05-261-4/+5
|
* video/out: introduce vo_control for gl_common based VOswm42013-05-261-0/+24
| | | | | | | | | | | | | | | | 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.
* Silence some compiler warningswm42013-05-211-1/+1
| | | | None of these were actual issues.
* x11: use mpv internal key auto-repeat handling if possiblewm42013-04-241-2/+23
| | | | | | | | | | | | | | | | | 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: minor simplificationwm42013-04-211-13/+6
|
* x11_common: remove assumption that video is always centeredwm42013-03-171-22/+20
| | | | | | | | | | 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).
* vo: Separate vo options from MPOptsAlexander Preisinger2013-03-041-77/+77
| | | | | | | 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
* vo: remove and cleanup globalsAlexander Preisinger2013-03-041-83/+85
| | | | | | | | 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.
* x11_common: fix --cursor-autohide when pausedwm42013-03-031-20/+22
| | | | | | | | 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.
* x11_common: fix window mapping, refactor window creation/resize handlingwm42013-03-031-127/+136
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-46/+48
| | | | | | | | | | | | | | | | 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-1/+4
| | | | | Nothing changes, because vo_check_events() is called at the same place anyway.
* video/out: remove video mode switching (--vm)wm42013-02-261-128/+2
| | | | | | | | | | | | | | | | | | | | 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.
* x11_common: always create a window, even with --widwm42013-02-261-37/+31
| | | | | | | | | | | | | | | | | 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.
* 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.
* Remove --rootwin option and rootwin propertywm42013-02-241-3/+0
| | | | | | | | 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.
* core: add fs-screen option for fullscreen display selectionStefano Pigozzi2013-02-211-26/+39
| | | | | | | | | | | | `--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.
* core: move `xineramascreen` to `MPOpts` as `vo_screen_id`Stefano Pigozzi2013-02-211-3/+3
| | | | This is a small cleanup in preparation for the next commit.
* x11_common: uncrustifywm42013-02-211-387/+324
| | | | | | | | 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.
* Prefix keycode defines with MP_wm42013-02-121-33/+39
| | | | | | | | | | Do this to reduce conflicts with <linux/input.h>, which contains some conflicting defines. This changes the meaning of MP_KEY_DOWN: KEY_DOWN is renamed to MP_KEY_DOWN (cursor down key) MP_KEY_DOWN is renamed to MP_KEY_STATE_DOWN (modifier for key down state)
* x11: simplify handling of X Visuals and Colormaps in VOswm42013-01-271-45/+59
| | | | | | | | | | | | | | | | | 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-20/+30
| | | | | | | | | | | | | | | 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-3/+33
| | | | | | <