2009-02-08 03:27:30 +00:00
|
|
|
/*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2001-04-15 20:31:58 +00:00
|
|
|
|
2001-03-03 21:47:37 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2002-10-29 20:27:47 +00:00
|
|
|
#include <math.h>
|
2002-06-12 22:57:58 +00:00
|
|
|
#include <inttypes.h>
|
2008-11-15 19:06:25 +00:00
|
|
|
#include <limits.h>
|
2001-04-15 18:35:17 +00:00
|
|
|
|
2001-04-15 20:31:58 +00:00
|
|
|
#include "config.h"
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "core/bstr.h"
|
|
|
|
#include "core/options.h"
|
|
|
|
#include "core/mp_msg.h"
|
|
|
|
#include "core/mp_fifo.h"
|
2009-01-09 15:25:24 +00:00
|
|
|
#include "libavutil/common.h"
|
2002-06-12 22:57:58 +00:00
|
|
|
#include "x11_common.h"
|
2008-04-29 13:22:33 +00:00
|
|
|
#include "talloc.h"
|
2001-04-15 20:31:58 +00:00
|
|
|
|
|
|
|
#include <string.h>
|
2001-03-03 21:47:37 +00:00
|
|
|
#include <unistd.h>
|
2004-06-02 02:34:39 +00:00
|
|
|
#include <assert.h>
|
2001-03-03 21:47:37 +00:00
|
|
|
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "vo.h"
|
2003-09-20 10:24:10 +00:00
|
|
|
#include "aspect.h"
|
2004-10-28 01:15:53 +00:00
|
|
|
#include "osdep/timer.h"
|
2001-03-03 21:47:37 +00:00
|
|
|
|
2001-04-10 00:00:04 +00:00
|
|
|
#include <X11/Xmd.h>
|
2001-03-03 21:47:37 +00:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <X11/Xatom.h>
|
2012-01-13 08:25:12 +00:00
|
|
|
#include <X11/keysym.h>
|
2013-04-03 23:13:56 +00:00
|
|
|
#include <X11/XKBlib.h>
|
2001-03-03 21:47:37 +00:00
|
|
|
|
2008-08-04 06:16:23 +00:00
|
|
|
#ifdef CONFIG_XSS
|
2007-12-22 18:51:05 +00:00
|
|
|
#include <X11/extensions/scrnsaver.h>
|
|
|
|
#endif
|
|
|
|
|
2008-08-04 06:16:23 +00:00
|
|
|
#ifdef CONFIG_XDPMS
|
2001-04-15 20:31:58 +00:00
|
|
|
#include <X11/extensions/dpms.h>
|
2001-07-19 18:47:22 +00:00
|
|
|
#endif
|
2001-04-15 20:31:58 +00:00
|
|
|
|
2008-08-04 06:16:23 +00:00
|
|
|
#ifdef CONFIG_XINERAMA
|
2001-10-10 01:48:54 +00:00
|
|
|
#include <X11/extensions/Xinerama.h>
|
|
|
|
#endif
|
2001-08-28 17:52:20 +00:00
|
|
|
|
2008-08-04 06:16:23 +00:00
|
|
|
#ifdef CONFIG_XF86VM
|
2002-01-31 00:37:27 +00:00
|
|
|
#include <X11/extensions/xf86vmode.h>
|
2005-02-02 14:07:13 +00:00
|
|
|
#endif
|
|
|
|
|
2008-08-04 06:16:23 +00:00
|
|
|
#ifdef CONFIG_XF86XK
|
2003-04-04 15:04:26 +00:00
|
|
|
#include <X11/XF86keysym.h>
|
2002-01-31 00:37:27 +00:00
|
|
|
#endif
|
|
|
|
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "core/input/input.h"
|
|
|
|
#include "core/input/keycodes.h"
|
2002-02-11 11:44:50 +00:00
|
|
|
|
2013-01-26 21:37:47 +00:00
|
|
|
#define vo_wm_LAYER 1
|
|
|
|
#define vo_wm_FULLSCREEN 2
|
|
|
|
#define vo_wm_STAYS_ON_TOP 4
|
|
|
|
#define vo_wm_ABOVE 8
|
|
|
|
#define vo_wm_BELOW 16
|
2013-02-13 15:33:01 +00:00
|
|
|
#define vo_wm_NETWM (vo_wm_FULLSCREEN | vo_wm_STAYS_ON_TOP | vo_wm_ABOVE | \
|
|
|
|
vo_wm_BELOW)
|
2013-01-26 21:37:47 +00:00
|
|
|
|
|
|
|
/* EWMH state actions, see
|
|
|
|
http://freedesktop.org/Standards/wm-spec/index.html#id2768769 */
|
|
|
|
#define _NET_WM_STATE_REMOVE 0 /* remove/unset property */
|
|
|
|
#define _NET_WM_STATE_ADD 1 /* add/set property */
|
|
|
|
#define _NET_WM_STATE_TOGGLE 2 /* toggle property */
|
|
|
|
|
2002-12-30 18:50:15 +00:00
|
|
|
#define WIN_LAYER_ONBOTTOM 2
|
|
|
|
#define WIN_LAYER_NORMAL 4
|
|
|
|
#define WIN_LAYER_ONTOP 6
|
This time the patch is fixing much more that breaking :-)
It includes ugly hack for OpenBox, swaps checking for netwm
with layers (and makes fvwm work -> they have also broken
_NET_WM_STATE_FULLSCREEN but also supports layers) and changes
back fullscreen layer to 10, afterstep doesn't like 12 :-)
Tested with: sawfish, metacity, kwin, blackbox, openbox, waimea,
windowmaker, afterstep, icewm, mwm, fvwm
Filip Kalinski <filon@pld.org.pl>
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@8670 b3059339-0415-0410-9bf9-f77b7e298cf2
2002-12-30 23:59:53 +00:00
|
|
|
#define WIN_LAYER_ABOVE_DOCK 10
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2013-01-26 21:37:47 +00:00
|
|
|
// ----- Motif header: -------
|
|
|
|
|
|
|
|
#define MWM_HINTS_FUNCTIONS (1L << 0)
|
|
|
|
#define MWM_HINTS_DECORATIONS (1L << 1)
|
|
|
|
#define MWM_HINTS_INPUT_MODE (1L << 2)
|
|
|
|
#define MWM_HINTS_STATUS (1L << 3)
|
|
|
|
|
|
|
|
#define MWM_FUNC_ALL (1L << 0)
|
|
|
|
#define MWM_FUNC_RESIZE (1L << 1)
|
|
|
|
#define MWM_FUNC_MOVE (1L << 2)
|
|
|
|
#define MWM_FUNC_MINIMIZE (1L << 3)
|
|
|
|
#define MWM_FUNC_MAXIMIZE (1L << 4)
|
|
|
|
#define MWM_FUNC_CLOSE (1L << 5)
|
2003-01-09 21:23:54 +00:00
|
|
|
|
2013-01-26 21:37:47 +00:00
|
|
|
#define MWM_DECOR_ALL (1L << 0)
|
|
|
|
#define MWM_DECOR_BORDER (1L << 1)
|
|
|
|
#define MWM_DECOR_RESIZEH (1L << 2)
|
|
|
|
#define MWM_DECOR_TITLE (1L << 3)
|
|
|
|
#define MWM_DECOR_MENU (1L << 4)
|
|
|
|
#define MWM_DECOR_MINIMIZE (1L << 5)
|
|
|
|
#define MWM_DECOR_MAXIMIZE (1L << 6)
|
2002-05-27 11:19:56 +00:00
|
|
|
|
2013-01-26 21:37:47 +00:00
|
|
|
#define MWM_INPUT_MODELESS 0
|
|
|
|
#define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1
|
|
|
|
#define MWM_INPUT_SYSTEM_MODAL 2
|
|
|
|
#define MWM_INPUT_FULL_APPLICATION_MODAL 3
|
|
|
|
#define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL
|
2001-04-10 00:00:04 +00:00
|
|
|
|
2013-02-13 15:33:01 +00:00
|
|
|
#define MWM_TEAROFF_WINDOW (1L << 0)
|
2001-04-13 00:54:05 +00:00
|
|
|
|
2013-01-26 21:37:47 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
long flags;
|
|
|
|
long functions;
|
|
|
|
long decorations;
|
|
|
|
long input_mode;
|
|
|
|
long state;
|
|
|
|
} MotifWmHints;
|
2003-01-07 20:58:25 +00:00
|
|
|
|
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-02 16:08:37 +00:00
|
|
|
static void vo_x11_update_geometry(struct vo *vo);
|
2013-05-16 12:02:28 +00:00
|
|
|
static void vo_x11_fullscreen(struct vo *vo);
|
2013-01-26 21:37:47 +00:00
|
|
|
static int vo_x11_get_fs_type(struct vo *vo);
|
2013-03-01 10:17:56 +00:00
|
|
|
static void xscreensaver_heartbeat(struct vo_x11_state *x11);
|
2013-01-26 21:37:47 +00:00
|
|
|
static void saver_on(struct vo_x11_state *x11);
|
|
|
|
static void saver_off(struct vo_x11_state *x11);
|
2013-03-04 16:40:21 +00:00
|
|
|
static void vo_x11_selectinput_witherr(struct vo *vo, Display *display,
|
|
|
|
Window w, long event_mask);
|
2013-01-26 21:37:47 +00:00
|
|
|
static void vo_x11_setlayer(struct vo *vo, Window vo_window, int layer);
|
2013-01-27 11:01:08 +00:00
|
|
|
static void vo_x11_create_colormap(struct vo_x11_state *x11,
|
|
|
|
XVisualInfo *vinfo);
|
2003-05-30 18:05:49 +00:00
|
|
|
|
2004-06-02 02:34:39 +00:00
|
|
|
/*
|
|
|
|
* Sends the EWMH fullscreen state event.
|
2007-01-18 09:03:42 +00:00
|
|
|
*
|
|
|
|
* action: could be one of _NET_WM_STATE_REMOVE -- remove state
|
|
|
|
* _NET_WM_STATE_ADD -- add state
|
|
|
|
* _NET_WM_STATE_TOGGLE -- toggle
|
2004-06-02 02:34:39 +00:00
|
|
|
*/
|
2013-01-26 21:37:47 +00:00
|
|
|
static void vo_x11_ewmh_fullscreen(struct vo_x11_state *x11, int action)
|
2004-06-02 02:34:39 +00:00
|
|
|
{
|
2013-02-13 15:33:01 +00:00
|
|
|
assert(action == _NET_WM_STATE_REMOVE || action == _NET_WM_STATE_ADD ||
|
|
|
|
action == _NET_WM_STATE_TOGGLE);
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2013-02-13 15:33:01 +00:00
|
|
|
if (x11->fs_type & vo_wm_FULLSCREEN) {
|
2004-06-14 04:53:03 +00:00
|
|
|
XEvent xev;
|
|
|
|
|
2007-01-18 09:03:42 +00:00
|
|
|
/* init X event structure for _NET_WM_FULLSCREEN client message */
|
2004-06-14 04:53:03 +00:00
|
|
|
xev.xclient.type = ClientMessage;
|
|
|
|
xev.xclient.serial = 0;
|
|
|
|
xev.xclient.send_event = True;
|
2008-09-20 13:13:33 +00:00
|
|
|
xev.xclient.message_type = x11->XA_NET_WM_STATE;
|
2008-04-21 00:14:37 +00:00
|
|
|
xev.xclient.window = x11->window;
|
2004-06-14 04:53:03 +00:00
|
|
|
xev.xclient.format = 32;
|
|
|
|
xev.xclient.data.l[0] = action;
|
2008-09-20 13:13:33 +00:00
|
|
|
xev.xclient.data.l[1] = x11->XA_NET_WM_STATE_FULLSCREEN;
|
2004-06-14 04:53:03 +00:00
|
|
|
xev.xclient.data.l[2] = 0;
|
|
|
|
xev.xclient.data.l[3] = 0;
|
|
|
|
xev.xclient.data.l[4] = 0;
|
|
|
|
|
|
|
|
/* finally send that damn thing */
|
2008-04-21 00:14:37 +00:00
|
|
|
if (!XSendEvent(x11->display, DefaultRootWindow(x11->display), False,
|
2004-06-14 04:53:03 +00:00
|
|
|
SubstructureRedirectMask | SubstructureNotifyMask,
|
|
|
|
&xev))
|
|
|
|
{
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO, MSGL_ERR, "\nX11: Couldn't send EWMH fullscreen event!\n");
|
2004-06-14 04:53:03 +00:00
|
|
|
}
|
2004-06-02 02:34:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-16 21:24:56 +00:00
|
|
|
static void vo_set_cursor_hidden(struct vo *vo, bool cursor_hidden)
|
2001-04-13 00:54:05 +00:00
|
|
|
{
|
2004-06-14 04:53:03 +00:00
|
|
|
Cursor no_ptr;
|
|
|
|
Pixmap bm_no;
|
|
|
|
XColor black, dummy;
|
|
|
|
Colormap colormap;
|
2013-02-13 15:33:01 +00:00
|
|
|
const char bm_no_data[] = {0, 0, 0, 0, 0, 0, 0, 0};
|
2013-05-16 21:24:56 +00:00
|
|
|
struct vo_x11_state *x11 = vo->x11;
|
|
|
|
Display *disp = x11->display;
|
|
|
|
Window win = x11->window;
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2013-05-16 21:24:56 +00:00
|
|
|
if (cursor_hidden == x11->mouse_cursor_hidden)
|
|
|
|
return;
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2013-05-16 21:24:56 +00:00
|
|
|
x11->mouse_cursor_hidden = cursor_hidden;
|
2001-04-13 00:54:05 +00:00
|
|
|
|
2013-05-16 21:24:56 +00:00
|
|
|
if (vo->opts->WinID == 0 || win == 0)
|
|
|
|
return; // do not hide if playing on the root window
|
|
|
|
|
|
|
|
if (x11->mouse_cursor_hidden) {
|
|
|
|
colormap = DefaultColormap(disp, DefaultScreen(disp));
|
|
|
|
if (!XAllocNamedColor(disp, colormap, "black", &black, &dummy))
|
|
|
|
return; // color alloc failed, give up
|
|
|
|
bm_no = XCreateBitmapFromData(disp, win, bm_no_data, 8, 8);
|
|
|
|
no_ptr = XCreatePixmapCursor(disp, bm_no, bm_no, &black, &black, 0, 0);
|
|
|
|
XDefineCursor(disp, win, no_ptr);
|
|
|
|
XFreeCursor(disp, no_ptr);
|
|
|
|
if (bm_no != None)
|
|
|
|
XFreePixmap(disp, bm_no);
|
|
|
|
XFreeColors(disp, colormap, &black.pixel, 1, 0);
|
|
|
|
} else {
|
|
|
|
XDefineCursor(x11->display, x11->window, 0);
|
|
|
|
}
|
2002-05-03 20:57:13 +00:00
|
|
|
}
|
2001-04-13 00:54:05 +00:00
|
|
|
|
2013-02-13 15:33:01 +00:00
|
|
|
static int x11_errorhandler(Display *display, XErrorEvent *event)
|
2002-02-17 12:34:29 +00:00
|
|
|
{
|
2013-02-13 15:33:01 +00:00
|
|
|
char msg[60];
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2013-02-13 15:33:01 +00:00
|
|
|
XGetErrorText(display, event->error_code, (char *) &msg, sizeof(msg));
|
2004-06-14 04:53:03 +00:00
|
|
|
|
|
|
|
mp_msg(MSGT_VO, MSGL_ERR, "X11 error: %s\n", msg);
|
|
|
|
|
|
|
|
mp_msg(MSGT_VO, MSGL_V,
|
2006-01-12 20:04:36 +00:00
|
|
|
"Type: %x, display: %p, resourceid: %lx, serial: %lx\n",
|
2004-06-14 04:53:03 +00:00
|
|
|
event->type, event->display, event->resourceid, event->serial);
|
|
|
|
mp_msg(MSGT_VO, MSGL_V,
|
|
|
|
"Error code: %x, request code: %x, minor code: %x\n",
|
|
|
|
event->error_code, event->request_code, event->minor_code);
|
|
|
|
|
2007-01-05 11:57:06 +00:00
|
|
|
// abort();
|
2007-06-24 10:46:40 +00:00
|
|
|
return 0;
|
2002-02-17 12:34:29 +00:00
|
|
|
}
|
2001-08-28 17:52:20 +00:00
|
|
|
|
2003-02-07 19:38:39 +00:00
|
|
|
void fstype_help(void)
|
|
|
|
{
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_VO, MSGL_INFO, "Available fullscreen layer change modes:\n");
|
2006-04-24 07:20:34 +00:00
|
|
|
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_FULL_SCREEN_TYPES\n");
|
2004-06-14 04:53:03 +00:00
|
|
|
|
|
|
|
mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "none",
|
|
|
|
"don't set fullscreen window layer");
|
|
|
|
mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "layer",
|
|
|
|
"use _WIN_LAYER hint with default layer");
|
|
|
|
mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "layer=<0..15>",
|
|
|
|
"use _WIN_LAYER hint with a given layer number");
|
|
|
|
mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "netwm",
|
|
|
|
"force NETWM style");
|
|
|
|
mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "above",
|
|
|
|
"use _NETWM_STATE_ABOVE hint if available");
|
|
|
|
mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "below",
|
|
|
|
"use _NETWM_STATE_BELOW hint if available");
|
|
|
|
mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "fullscreen",
|
2010-08-03 15:55:17 +00:00
|
|
|
"use _NETWM_STATE_FULLSCREEN hint if available");
|
2004-06-14 04:53:03 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "stays_on_top",
|
|
|
|
"use _NETWM_STATE_STAYS_ON_TOP hint if available");
|
|
|
|
mp_msg(MSGT_VO, MSGL_INFO,
|
|
|
|
"You can also negate the settings with simply putting '-' in the beginning");
|
2006-03-04 17:33:56 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_INFO, "\n");
|
2003-08-25 18:13:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void fstype_dump(int fstype)
|
|
|
|
{
|
2013-02-13 15:33:01 +00:00
|
|
|
if (fstype) {
|
2004-06-14 04:53:03 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_V, "[x11] Current fstype setting honours");
|
|
|
|
if (fstype & vo_wm_LAYER)
|
|
|
|
mp_msg(MSGT_VO, MSGL_V, " LAYER");
|
|
|
|
if (fstype & vo_wm_FULLSCREEN)
|
|
|
|
mp_msg(MSGT_VO, MSGL_V, " FULLSCREEN");
|
|
|
|
if (fstype & vo_wm_STAYS_ON_TOP)
|
|
|
|
mp_msg(MSGT_VO, MSGL_V, " STAYS_ON_TOP");
|
|
|
|
if (fstype & vo_wm_ABOVE)
|
|
|
|
mp_msg(MSGT_VO, MSGL_V, " ABOVE");
|
|
|
|
if (fstype & vo_wm_BELOW)
|
|
|
|
mp_msg(MSGT_VO, MSGL_V, " BELOW");
|
|
|
|
mp_msg(MSGT_VO, MSGL_V, " X atoms\n");
|
2013-02-13 15:33:01 +00:00
|
|
|
} else {
|
2004-06-14 04:53:03 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_V,
|
|
|
|
"[x11] Current fstype setting doesn't honour any X atoms\n");
|
2013-02-13 15:33:01 +00:00
|
|
|
}
|
2003-02-07 19:38:39 +00:00
|
|
|
}
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2008-04-20 23:50:40 +00:00
|
|
|
static int net_wm_support_state_test(struct vo_x11_state *x11, Atom atom)
|
2002-12-30 00:47:43 +00:00
|
|
|
{
|
2013-02-13 15:33:01 +00:00
|
|
|
#define NET_WM_STATE_TEST(x) { \
|
|
|
|
if (atom == x11->XA_NET_WM_STATE_##x) { \
|
|
|
|
mp_msg( MSGT_VO,MSGL_V, "[x11] Detected wm supports " #x " state.\n" ); \
|
|
|
|
return vo_wm_##x; \
|
|
|
|
} \
|
|
|
|
}
|
2004-06-14 04:53:03 +00:00
|
|
|
|
|
|
|
NET_WM_STATE_TEST(FULLSCREEN);
|
|
|
|
NET_WM_STATE_TEST(ABOVE);
|
|
|
|
NET_WM_STATE_TEST(STAYS_ON_TOP);
|
|
|
|
NET_WM_STATE_TEST(BELOW);
|
|
|
|
return 0;
|
2002-12-30 00:47:43 +00:00
|
|
|
}
|
|
|
|
|
2013-02-13 15:33:01 +00:00
|
|
|
static int x11_get_property(struct vo_x11_state *x11, Atom type, Atom **args,
|
2008-04-20 06:34:27 +00:00
|
|
|
unsigned long *nitems)
|
2003-01-03 15:30:57 +00:00
|
|
|
{
|
2004-06-14 04:53:03 +00:00
|
|
|
int format;
|
|
|
|
unsigned long bytesafter;
|
|
|
|
|
2013-02-13 15:33:01 +00:00
|
|
|
return Success ==
|
|
|
|
XGetWindowProperty(x11->display, x11->rootwin, type, 0, 16384, False,
|
|
|
|
AnyPropertyType, &type, &format, nitems,
|
|
|
|
&bytesafter, (unsigned char **) args)
|
|
|
|
&& *nitems > 0;
|
2003-01-03 15:30:57 +00:00
|
|
|
}
|
|
|
|
|
2008-04-20 06:34:27 +00:00
|
|
|
static int vo_wm_detect(struct vo *vo)
|
2002-05-07 13:31:29 +00:00
|
|
|
{
|
2008-04-20 23:50:40 +00:00
|
|
|
struct vo_x11_state *x11 = vo->x11;
|
2004-06-14 04:53:03 +00:00
|
|
|
int i;
|
|
|
|
int wm = 0;
|
|
|
|
unsigned long nitems;
|
|
|
|
Atom *args = NULL;
|
|
|
|
|
2013-03-04 21:41:27 +00:00
|
|
|
if (vo->opts->WinID >= 0)
|
2004-06-14 04:53:03 +00:00
|
|
|
return 0;
|
This time the patch is fixing much more that breaking :-)
It includes ugly hack for OpenBox, swaps checking for netwm
with layers (and makes fvwm work -> they have also broken
_NET_WM_STATE_FULLSCREEN but also supports layers) and changes
back fullscreen layer to 10, afterstep doesn't like 12 :-)
Tested with: sawfish, metacity, kwin, blackbox, openbox, waimea,
windowmaker, afterstep, icewm, mwm, fvwm
Filip Kalinski <filon@pld.org.pl>
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@8670 b3059339-0415-0410-9bf9-f77b7e298cf2
2002-12-30 23:59:53 +00:00
|
|
|
|
2004-06-14 04:53:03 +00:00
|
|
|
// -- supports layers
|
2013-02-13 15:33:01 +00:00
|
|
|
if (x11_get_property(x11, x11->XA_WIN_PROTOCOLS, &args, &nitems)) {
|
2004-06-14 04:53:03 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_V, "[x11] Detected wm supports layers.\n");
|
2013-01-26 21:37:47 +00:00
|
|
|
int metacity_hack = 0;
|
2013-02-13 15:33:01 +00:00
|
|
|
for (i = 0; i < nitems; i++) {
|
2013-01-26 21:37:47 +00:00
|
|
|
if (args[i] == x11->XA_WIN_LAYER) {
|
2004-06-14 04:53:03 +00:00
|
|
|
wm |= vo_wm_LAYER;
|
|
|
|
metacity_hack |= 1;
|
2013-01-26 21:37:47 +00:00
|
|
|
} else {
|
2007-01-18 09:03:42 +00:00
|
|
|
/* metacity is the only window manager I know which reports
|
|
|
|
* supporting only the _WIN_LAYER hint in _WIN_PROTOCOLS.
|
|
|
|
* (what's more support for it is broken) */
|
2004-06-14 04:53:03 +00:00
|
|
|
metacity_hack |= 2;
|
2013-01-26 21:37:47 +00:00
|
|
|
}
|
2004-06-14 04:53:03 +00:00
|
|
|
}
|
|
|
|
XFree(args);
|
2013-02-13 15:33:01 +00:00
|
|
|
if (wm && (metacity_hack == 1)) {
|
2007-01-18 09:03:42 +00:00
|
|
|
// metacity claims to support layers, but it is not the truth :-)
|
2004-06-14 04:53:03 +00:00
|
|
|
wm ^= vo_wm_LAYER;
|
|
|
|
mp_msg(MSGT_VO, MSGL_V,
|
|
|
|
"[x11] Using workaround for Metacity bugs.\n");
|
|
|
|
}
|
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
// --- netwm
|
2013-02-13 15:33:01 +00:00
|
|
|
if (x11_get_property(x11, x11->XA_NET_SUPPORTED, &args, &nitems)) {
|
2004-06-14 04:53:03 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_V, "[x11] Detected wm supports NetWM.\n");
|
|
|
|
for (i = 0; i < nitems; i++)
|
2008-04-20 23:50:40 +00:00
|
|
|
wm |= net_wm_support_state_test(vo->x11, args[i]);
|
2004-06-14 04:53:03 +00:00
|
|
|
XFree(args);
|
|
|
|
}
|
2003-02-07 19:38:39 +00:00
|
|
|
|
2004-06-14 04:53:03 +00:00
|
|
|
if (wm == 0)
|
|
|
|
mp_msg(MSGT_VO, MSGL_V, "[x11] Unknown wm type...\n");
|
|
|
|
return wm;
|
|
|
|
}
|
2002-05-07 13:31:29 +00:00
|
|
|
|
2013-02-13 15:33:01 +00:00
|
|
|
#define XA_INIT(x) x11->XA ## x = XInternAtom(x11->display, # x, False)
|
2008-04-20 23:50:40 +00:00
|
|
|
static void init_atoms(struct vo_x11_state *x11)
|
2003-01-03 15:30:57 +00:00
|
|
|
{
|
2004-06-14 04:53:03 +00:00
|
|
|
XA_INIT(_NET_SUPPORTED);
|
|
|
|
XA_INIT(_NET_WM_STATE);
|
|
|
|
XA_INIT(_NET_WM_STATE_FULLSCREEN);
|
|
|
|
XA_INIT(_NET_WM_STATE_ABOVE);
|
|
|
|
XA_INIT(_NET_WM_STATE_STAYS_ON_TOP);
|
|
|
|
XA_INIT(_NET_WM_STATE_BELOW);
|
|
|
|
XA_INIT(_NET_WM_PID);
|
2011-12-06 17:48:31 +00:00
|
|
|
XA_INIT(_NET_WM_NAME);
|
|
|
|
XA_INIT(_NET_WM_ICON_NAME);
|
2004-06-14 04:53:03 +00:00
|
|
|
XA_INIT(_WIN_PROTOCOLS);
|
|
|
|
XA_INIT(_WIN_LAYER);
|
|
|
|
XA_INIT(_WIN_HINTS);
|
2006-04-19 15:58:10 +00:00
|
|
|
XA_INIT(WM_PROTOCOLS);
|
|
|
|
XA_INIT(WM_DELETE_WINDOW);
|
2011-12-06 17:48:31 +00:00
|
|
|
XA_INIT(UTF8_STRING);
|
2012-07-27 00:40:38 +00:00
|
|
|
char buf[50];
|
|
|
|
sprintf(buf, "_NET_WM_CM_S%d", x11->screen);
|
|
|
|
x11->XA_NET_WM_CM = XInternAtom(x11->display, buf, False);
|
2003-01-03 15:30:57 +00:00
|
|
|
}
|
|
|
|
|
2013-05-16 12:02:28 +00:00
|
|
|
static void vo_x11_update_screeninfo(struct vo *vo)
|
2013-02-13 15:33:01 +00:00
|
|
|
{
|
2013-03-04 21:41:27 +00:00
|
|
|
struct mp_vo_opts *opts = vo->opts;
|
2013-02-15 18:47:34 +00:00
|
|
|
struct vo_x11_state *x11 = vo->x11;
|
2013-03-04 21:41:27 +00:00
|
|
|
bool all_screens = opts->fs && opts->fsscreen_id == -2;
|
2013-03-04 16:40:21 +00:00
|
|
|
vo->xinerama_x = vo->xinerama_y = 0;
|
2013-02-17 15:35:44 +00:00
|
|
|
if (all_screens) {
|
2013-03-04 21:41:27 +00:00
|
|
|
opts->screenwidth = x11->ws_width;
|
|
|
|
opts->screenheight = x11->ws_height;
|
2013-02-17 15:35:44 +00:00
|
|
|
}
|
2008-08-04 06:16:23 +00:00
|
|
|
#ifdef CONFIG_XINERAMA
|
2013-03-04 21:41:27 +00:00
|
|
|
if (opts->screen_id >= -1 && XineramaIsActive(x11->display) &&
|
2013-02-17 15:35:44 +00:00
|
|
|
!all_screens)
|
|
|
|
{
|
2013-03-04 21:41:27 +00:00
|
|
|
int screen = opts->fs ? opts->fsscreen_id : opts->screen_id;
|
2006-04-16 13:38:28 +00:00
|
|
|
XineramaScreenInfo *screens;
|
|
|
|
int num_screens;
|
|
|
|
|
2013-02-15 18:47:34 +00:00
|
|
|
screens = XineramaQueryScreens(x11->display, &num_screens);
|
2008-04-19 09:58:01 +00:00
|
|
|
if (screen >= num_screens)
|
|
|
|
screen = num_screens - 1;
|
|
|
|
if (screen == -1) {
|
2013-02-15 18:47:34 +00:00
|
|
|
int x = x11->win_x + x11->win_width / 2;
|
|
|
|
int y = x11->win_y + x11->win_height / 2;
|
2008-04-19 09:58:01 +00:00
|
|
|
for (screen = num_screens - 1; screen > 0; screen--) {
|
2013-02-13 15:33:01 +00:00
|
|
|
int left = screens[screen].x_org;
|
|
|
|
int right = left + screens[screen].width;
|
|
|
|
int top = screens[screen].y_org;
|
|
|
|
int bottom = top + screens[screen].height;
|
|
|
|
if (left <= x && x <= right && top <= y && y <= bottom)
|
|
|
|
break;
|
2008-04-19 09:58:01 +00:00
|
|
|
}
|
2008-04-13 11:15:08 +00:00
|
|
|
}
|
2006-04-16 13:38:28 +00:00
|
|
|
if (screen < 0)
|
|
|
|
screen = 0;
|
2013-03-04 21:41:27 +00:00
|
|
|
opts->screenwidth = screens[screen].width;
|
|
|
|
opts->screenheight = screens[screen].height;
|
2013-03-04 16:40:21 +00:00
|
|
|
vo->xinerama_x = screens[screen].x_org;
|
|
|
|
vo->xinerama_y = screens[screen].y_org;
|
2006-04-16 13:38:28 +00:00
|
|
|
|
|
|
|
XFree(screens);
|
|
|
|
}
|
|
|
|
#endif
|
2013-03-04 21:41:27 +00:00
|
|
|
aspect_save_screenres(vo, opts->screenwidth, opts->screenheight);
|
2006-04-16 13:38:28 +00:00
|
|
|
}
|
|
|
|
|
2013-01-26 21:37:47 +00:00
|
|
|
int vo_x11_init(struct vo *vo)
|
2001-03-03 21:47:37 +00:00
|
|
|
{
|
2013-03-04 21:41:27 +00:00
|
|
|
struct mp_vo_opts *opts = vo->opts;
|
2004-06-14 04:53:03 +00:00
|
|
|
char *dispName;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2013-01-26 21:37:47 +00:00
|
|
|
assert(!vo->x11);
|
2012-08-03 03:55:02 +00:00
|
|
|
|
2013-01-26 21:37:47 +00:00
|
|
|
struct vo_x11_state *x11 = talloc_ptrtype(NULL, x11);
|
|
|
|
*x11 = (struct vo_x11_state){
|
|
|
|
.olddecor = MWM_DECOR_ALL,
|
|
|
|
.oldfuncs = MWM_FUNC_MOVE | MWM_FUNC_CLOSE | MWM_FUNC_MINIMIZE |
|
|
|
|
MWM_FUNC_MAXIMIZE | MWM_FUNC_RESIZE,
|
|
|
|
.old_gravity = NorthWestGravity,
|
|
|
|
.fs_layer = WIN_LAYER_ABOVE_DOCK,
|
|
|
|
};
|
|
|
|
vo->x11 = x11;
|
2012-08-03 03:55:02 +00:00
|
|
|
|
2004-06-14 04:53:03 +00:00
|
|
|
XSetErrorHandler(x11_errorhandler);
|
2002-02-22 19:36:21 +00:00
|
|
|
|
2012-11-15 14:38:02 +00:00
|
|
|
dispName = XDisplayName(NULL);
|
2002-02-22 19:36:21 +00:00
|
|
|
|
2004-06-14 04:53:03 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_V, "X11 opening display: %s\n", dispName);
|
|
|
|
|
2008-04-20 06:34:27 +00:00
|
|
|
x11->display = XOpenDisplay(dispName);
|
2013-02-13 15:33:01 +00:00
|
|
|
if (!x11->display) {
|
2004-06-14 04:53:03 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_ERR,
|
|
|
|
"vo: couldn't open the X11 display (%s)!\n", dispName);
|
2012-08-03 03:55:02 +00:00
|
|
|
talloc_free(x11);
|
|
|
|
vo->x11 = NULL;
|
2004-06-14 04:53:03 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2008-04-21 01:59:00 +00:00
|
|
|
x11->screen = DefaultScreen(x11->display); // screen ID
|
|
|
|
x11->rootwin = RootWindow(x11->display, x11->screen); // root window ID
|
2001-05-31 22:32:58 +00:00
|
|
|
|
2013-04-03 23:13:56 +00:00
|
|
|
if (!opts->native_keyrepeat) {
|
|
|
|
Bool ok = False;
|
|
|
|
XkbSetDetectableAutoRepeat(x11->display, True, &ok);
|
|
|
|
x11->no_autorepeat = ok;
|
|
|
|
}
|
|
|
|
|
2012-01-14 13:09:44 +00:00
|
|
|
x11->xim = XOpenIM(x11->display, NULL, NULL, NULL);
|
|
|
|
|
2008-04-20 23:50:40 +00:00
|
|
|
init_atoms(vo->x11);
|
2001-10-10 01:48:54 +00:00
|
|
|
|
2013-03-04 21:41:27 +00:00
|
|
|
x11->ws_width = opts->screenwidth;
|
|
|
|
x11->ws_height = opts->screenheight;
|
2013-02-17 15:35:44 +00:00
|
|
|
|
|
|
|
if (!x11->ws_width)
|
|
|
|
x11->ws_width = DisplayWidth(x11->display, x11->screen);
|
|
|
|
if (!x11->ws_height)
|
|
|
|
x11->ws_height = DisplayHeight(x11->display, x11->screen);
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2013-03-04 21:41:27 +00:00
|
|
|
opts->screenwidth = x11->ws_width;
|
|
|
|
opts->screenheight = x11->ws_height;
|
2013-02-13 15:33:01 +00:00
|
|
|
|
2004-06-14 04:53:03 +00:00
|
|
|
if (strncmp(dispName, "unix:", 5) == 0)
|
|
|
|
dispName += 4;
|
|
|
|
else if (strncmp(dispName, "localhost:", 10) == 0)
|
|
|
|
dispName += 9;
|
|
|
|
if (*dispName == ':' && atoi(dispName + 1) < 10)
|
2008-04-21 01:59:00 +00:00
|
|
|
x11->display_is_local = 1;
|
2004-06-14 04:53:03 +00:00
|
|
|
else
|
2008-04-21 01:59:00 +00:00
|
|
|
x11->display_is_local = 0;
|
2013-01-26 21:37:47 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_V, "vo: X11 running at %dx%d (\"%s\" => %s display)\n",
|
2013-03-04 21:41:27 +00:00
|
|
|
opts->screenwidth, opts->screenheight, dispName,
|
2013-01-26 21:37:47 +00:00
|
|
|
x11->display_is_local ? "local" : "remote");
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2008-04-21 01:50:29 +00:00
|
|
|
x11->wm_type = vo_wm_detect(vo);
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2013-01-26 21:37:47 +00:00
|
|
|
x11->fs_type = vo_x11_get_fs_type(vo);
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2008-04-21 01:50:29 +00:00
|
|
|
fstype_dump(x11->fs_type);
|
2004-06-14 04:53:03 +00:00
|
|
|
|
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-02 16:08:37 +00:00
|
|
|
vo->event_fd = ConnectionNumber(x11->display);
|
|
|
|
|
2013-01-26 21:37:47 +00:00
|
|
|
return 1;
|
2002-05-08 16:41:44 +00:00
|
|
|
}
|
2002-01-31 11:04:41 +00:00
|
|
|
|
2010-04-23 10:22:44 +00:00
|
|
|
static const struct mp_keymap keymap[] = {
|
2008-12-20 11:12:45 +00:00
|
|
|
// special keys
|
2013-02-12 00:34:04 +00:00
|
|
|
{XK_Pause, MP_KEY_PAUSE}, {XK_Escape, MP_KEY_ESC},
|
|
|
|
{XK_BackSpace, MP_KEY_BS}, {XK_Tab, MP_KEY_TAB}, {XK_Return, MP_KEY_ENTER},
|
|
|
|
{XK_Menu, MP_KEY_MENU}, {XK_Print, MP_KEY_PRINT},
|
2008-12-20 11:12:45 +00:00
|
|
|
|
|
|
|
// cursor keys
|
2013-02-12 00:34:04 +00:00
|
|
|
{XK_Left, MP_KEY_LEFT}, {XK_Right, MP_KEY_RIGHT}, {XK_Up, MP_KEY_UP},
|
|
|
|
{XK_Down, MP_KEY_DOWN},
|
2008-12-20 11:12:45 +00:00
|
|
|
|
|
|
|
// navigation block
|
2013-02-12 00:34:04 +00:00
|
|
|
{XK_Insert, MP_KEY_INSERT}, {XK_Delete, MP_KEY_DELETE},
|
|
|
|
{XK_Home, MP_KEY_HOME}, {XK_End, MP_KEY_END}, {XK_Page_Up, MP_KEY_PAGE_UP},
|
|
|
|
{XK_Page_Down, MP_KEY_PAGE_DOWN},
|
2008-12-20 11:12:45 +00:00
|
|
|
|
|
|
|
// F-keys
|
2013-02-12 00:34:04 +00:00
|
|
|
{XK_F1, MP_KEY_F+1}, {XK_F2, MP_KEY_F+2}, {XK_F3, MP_KEY_F+3},
|
|
|
|
{XK_F4, MP_KEY_F+4}, {XK_F5, MP_KEY_F+5}, {XK_F6, MP_KEY_F+6},
|
|
|
|
{XK_F7, MP_KEY_F+7}, {XK_F8, MP_KEY_F+8}, {XK_F9, MP_KEY_F+9},
|
|
|
|
{XK_F10, MP_KEY_F+10}, {XK_F11, MP_KEY_F+11}, {XK_F12, MP_KEY_F+12},
|
2008-12-20 11:12:45 +00:00
|
|
|
|
|
|
|
// numpad independent of numlock
|
2013-02-12 00:34:04 +00:00
|
|
|
{XK_KP_Subtract, '-'}, {XK_KP_Add, '+'}, {XK_KP_Multiply, '*'},
|
|
|
|
{XK_KP_Divide, '/'}, {XK_KP_Enter, MP_KEY_KPENTER},
|
2008-12-20 11:12:45 +00:00
|
|
|
|
|
|
|
// numpad with numlock
|
2013-02-12 00:34:04 +00:00
|
|
|
{XK_KP_0, MP_KEY_KP0}, {XK_KP_1, MP_KEY_KP1}, {XK_KP_2, MP_KEY_KP2},
|
|
|
|
{XK_KP_3, MP_KEY_KP3}, {XK_KP_4, MP_KEY_KP4}, {XK_KP_5, MP_KEY_KP5},
|
|
|
|
{XK_KP_6, MP_KEY_KP6}, {XK_KP_7, MP_KEY_KP7}, {XK_KP_8, MP_KEY_KP8},
|
|
|
|
{XK_KP_9, MP_KEY_KP9}, {XK_KP_Decimal, MP_KEY_KPDEC},
|
|
|
|
{XK_KP_Separator, MP_KEY_KPDEC},
|
2008-12-20 11:12:45 +00:00
|
|
|
|
|
|
|
// numpad without numlock
|
2013-02-12 00:34:04 +00:00
|
|
|
{XK_KP_Insert, MP_KEY_KPINS}, {XK_KP_End, MP_KEY_KP1},
|
|
|
|
{XK_KP_Down, MP_KEY_KP2}, {XK_KP_Page_Down, MP_KEY_KP3},
|
|
|
|
{XK_KP_Left, MP_KEY_KP4}, {XK_KP_Begin, MP_KEY_KP5},
|
|
|
|
{XK_KP_Right, MP_KEY_KP6}, {XK_KP_Home, MP_KEY_KP7}, {XK_KP_Up, MP_KEY_KP8},
|
|
|
|
{XK_KP_Page_Up, MP_KEY_KP9}, {XK_KP_Delete, MP_KEY_KPDEL},
|
2008-12-20 11:12:45 +00:00
|
|
|
|
2012-01-14 13:09:44 +00:00
|
|
|
#ifdef XF86XK_AudioPause
|
2013-02-12 00:34:04 +00:00
|
|
|
{XF86XK_MenuKB, MP_KEY_MENU},
|
|
|
|
{XF86XK_AudioPlay, MP_KEY_PLAY}, {XF86XK_AudioPause, MP_KEY_PAUSE},
|
|
|
|
{XF86XK_AudioStop, MP_KEY_STOP}, {XF86XK_AudioPrev, MP_KEY_PREV},
|
|
|
|
{XF86XK_AudioNext, MP_KEY_NEXT}, {XF86XK_AudioMute, MP_KEY_MUTE},
|
|
|
|
{XF86XK_AudioLowerVolume, MP_KEY_VOLUME_DOWN},
|
|
|
|
{XF86XK_AudioRaiseVolume, MP_KEY_VOLUME_UP},
|
2012-01-14 13:09:44 +00:00
|
|
|
#endif
|
2008-12-20 11:12:45 +00:00
|
|
|
|
2009-07-06 23:26:13 +00:00
|
|
|
{0, 0}
|
2008-12-20 11:12:45 +00:00
|
|
|
};
|
|
|
|
|
2012-01-14 13:09:44 +00:00
|
|
|
static int vo_x11_lookupkey(int key)
|
2004-06-14 04:53:03 +00:00
|
|
|
{
|
2008-12-20 10:25:13 +00:00
|
|
|
static const char *passthrough_keys = " -+*/<>`~!@#$%^&()_{}:;\"\',.?\\|=[]";
|
2008-12-20 11:12:45 +00:00
|
|
|
int mpkey = 0;
|
2008-12-20 10:25:13 +00:00
|
|
|
if ((key >= 'a' && key <= 'z') ||
|
|
|
|
(key >= 'A' && key <= 'Z') ||
|
|
|
|
(key >= '0' && key <= '9') ||
|
2013-02-13 15:33:01 +00:00
|
|
|
(key > 0 && key < 256 && strchr(passthrough_keys, key)))
|
2008-12-20 11:12:45 +00:00
|
|
|
mpkey = key;
|
2008-12-20 10:25:13 +00:00
|
|
|
|
2008-12-20 11:52:11 +00:00
|
|
|
if (!mpkey)
|
2008-12-21 04:11:51 +00:00
|
|
|
mpkey = lookup_keymap_table(keymap, key);
|
2001-04-12 00:05:41 +00:00
|
|
|
|
2012-01-14 13:09:44 +00:00
|
|
|
return mpkey;
|
2001-03-03 21:47:37 +00:00
|
|
|
}
|
|
|
|
|
2013-01-26 21:37:47 +00:00
|
|
|
static void vo_x11_decoration(struct vo *vo, int d)
|
2001-03-03 21:47:37 +00:00
|
|
|
{
|
2008-04-21 01:09:26 +00:00
|
|
|
struct vo_x11_state *x11 = vo->x11;
|
2004-06-14 04:53:03 +00:00
|
|
|
Atom mtype;
|
|
|
|
int mformat;
|
|
|
|
unsigned long mn, mb;
|
2013-01-26 21:37:47 +00:00
|
|
|
Atom vo_MotifHints;
|
|
|
|
MotifWmHints vo_MotifWmHints;
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2013-03-04 21:41:27 +00:00
|
|
|
if (!vo->opts->WinID)
|
2004-06-14 04:53:03 +00:00
|
|
|
return;
|
|
|
|
|
2013-03-04 21:41:27 +00:00
|
|
|
if (vo->opts->fsmode & 8) {
|
2008-04-21 01:09:26 +00:00
|
|
|
XSetTransientForHint(x11->display, x11->window,
|
2008-04-21 01:59:00 +00:00
|
|
|
RootWindow(x11->display, x11->screen));
|
2002-03-08 20:14:08 +00:00
|
|
|
}
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2008-04-21 01:09:26 +00:00
|
|
|
vo_MotifHints = XInternAtom(x11->display, "_MOTIF_WM_HINTS", 0);
|
2013-02-13 15:33:01 +00:00
|
|
|
if (vo_MotifHints != None) {
|
|
|
|
if (!d) {
|
2004-06-14 04:53:03 +00:00
|
|
|
MotifWmHints *mhints = NULL;
|
|
|
|
|
2008-04-21 01:09:26 +00:00
|
|
|
XGetWindowProperty(x11->display, x11->window,
|
|
|
|
vo_MotifHints, 0, 20, False,
|
2004-06-14 04:53:03 +00:00
|
|
|
vo_MotifHints, &mtype, &mformat, &mn,
|
|
|
|
&mb, (unsigned char **) &mhints);
|
2013-02-13 15:33:01 +00:00
|
|
|
if (mhints) {
|
2004-06-14 04:53:03 +00:00
|
|
|
if (mhints->flags & MWM_HINTS_DECORATIONS)
|
2008-04-21 01:09:26 +00:00
|
|
|
x11->olddecor = mhints->decorations;
|
2004-06-14 04:53:03 +00:00
|
|
|
if (mhints->flags & MWM_HINTS_FUNCTIONS)
|
2008-04-21 01:09:26 +00:00
|
|
|
x11->oldfuncs = mhints->functions;
|
2004-06-14 04:53:03 +00:00
|
|
|
XFree(mhints);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&vo_MotifWmHints, 0, sizeof(MotifWmHints));
|
|
|
|
vo_MotifWmHints.flags =
|
|
|
|
MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
|
2013-02-13 15:33:01 +00:00
|
|
|
if (d) {
|
2008-04-21 01:09:26 +00:00
|
|
|
vo_MotifWmHints.functions = x11->oldfuncs;
|
|
|
|
d = x11->olddecor;
|
2004-06-14 04:53:03 +00:00
|
|
|
}
|
|
|
|
vo_MotifWmHints.decorations =
|
2013-03-04 21:41:27 +00:00
|
|
|
d | ((vo->opts->fsmode & 2) ? MWM_DECOR_MENU : 0);
|
2008-04-21 01:09:26 +00:00
|
|
|
XChangeProperty(x11->display, x11->window, vo_MotifHints,
|
|
|
|
vo_MotifHints, 32,
|
2004-06-14 04:53:03 +00:00
|
|
|
PropModeReplace,
|
|
|
|
(unsigned char *) &vo_MotifWmHints,
|
2013-03-04 21:41:27 +00:00
|
|
|
(vo->opts->fsmode & 4) ? 4 : 5);
|
2004-06-14 04:53:03 +00:00
|
|
|
}
|
2001-03-03 21:47:37 +00:00
|
|
|
}
|
|
|
|
|
2013-01-26 21:37:47 +00:00
|
|
|
static void vo_x11_classhint(struct vo *vo, Window window, const char *name)
|
2004-06-14 04:53:03 +00:00
|
|
|
{
|
2013-03-04 21:41:27 +00:00
|
|
|
struct mp_vo_opts *opts = vo->opts;
|
2008-04-20 23:50:40 +00:00
|
|
|
struct vo_x11_state *x11 = vo->x11;
|
2004-06-14 04:53:03 +00:00
|
|
|
XClassHint wmClass;
|
|
|
|
pid_t pid = getpid();
|
|
|
|
|
2013-03-04 21:41:27 +00:00
|
|
|
wmClass.res_name = opts->winname ? opts->winname : (char *)name;
|
2012-10-11 00:04:08 +00:00
|
|
|
wmClass.res_class = "mpv";
|
2008-04-20 23:50:40 +00:00
|
|
|
XSetClassHint(x11->display, window, &wmClass);
|
|
|
|
XChangeProperty(x11->display, window, x11->XA_NET_WM_PID, XA_CARDINAL,
|
|
|
|
32, PropModeReplace, (unsigned char *) &pid, 1);
|
2001-06-17 01:22:09 +00:00
|
|
|
}
|
|
|
|
|
2008-04-20 06:34:27 +00:00
|
|
|
void vo_x11_uninit(struct vo *vo)
|
2002-01-31 11:15:54 +00:00
|
|
|
{
|
2008-04-21 00:14:37 +00:00
|
|
|
struct vo_x11_state *x11 = vo->x11;
|
2013-01-26 21:37:47 +00:00
|
|
|
assert(x11);
|
|
|
|
|
2013-04-03 23:13:56 +00:00
|
|
|
mplayer_put_key(vo->key_fifo, MP_INPUT_RELEASE_ALL);
|
|
|
|
|
2013-01-26 21:37:47 +00:00
|
|
|
saver_on(x11);
|
2008-04-21 00:14:37 +00:00
|
|
|
if (x11->window != None)
|
2013-05-16 21:24:56 +00:00
|
|
|
vo_set_cursor_hidden(vo, false);
|
2002-02-17 12:34:29 +00:00
|
|
|
|
2010-06-14 19:17:38 +00:00
|
|
|
if (x11->f_gc != None)
|
2008-04-21 01:19:43 +00:00
|
|
|
XFreeGC(vo->x11->display, x11->f_gc);
|
2013-01-26 21:37:47 +00:00
|
|
|
if (x11->vo_gc != None)
|
|
|
|
XFreeGC(vo->x11->display, x11->vo_gc);
|
|
|
|
if (x11->window != None) {
|
|
|
|
XClearWindow(x11->display, x11->window);
|
2013-02-24 22:35:13 +00:00
|
|
|
XUnmapWindow(x11->display, x11->window);
|
|
|
|
|
|
|
|
XSelectInput(x11->display, x11->window, StructureNotifyMask);
|
|
|
|
XDestroyWindow(x11->display, x11->window);
|
|
|
|
XEvent xev;
|
|
|
|
do {
|
|
|
|
XNextEvent(x11->display, &xev);
|
|
|
|
} while (xev.type != DestroyNotify ||
|
|
|
|
xev.xdestroywindow.event != x11->window);
|
2013-01-26 21:37:47 +00:00
|
|
|
}
|
|
|
|
if (x11->xic)
|
|
|
|
XDestroyIC(x11->xic);
|
2013-01-27 11:01:08 +00:00
|
|
|
if (x11->colormap != None)
|
|
|
|
XFreeColormap(vo->x11->display, x11->colormap);
|
2013-03-04 21:41:27 +00:00
|
|
|
vo->opts->fs = false;
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2013-01-26 21:37:47 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_V, "vo: uninit ...\n");
|
|
|
|
if (x11->xim)
|
|
|
|
XCloseIM(x11->xim);
|
|
|
|
XSetErrorHandler(NULL);
|
|
|
|
XCloseDisplay(x11->display);
|
2012-01-14 13:09:44 +00:00
|
|
|
|
2013-01-26 21:37:47 +00:00
|
|
|
talloc_free(x11);
|
2012-08-03 03:55:02 +00:00
|
|
|
vo->x11 = NULL;
|
2002-01-31 11:15:54 +00:00
|
|
|
}
|
|
|
|
|
2013-02-15 18:47:34 +00:00
|
|
|
static void update_vo_size(struct vo *vo)
|
2010-07-01 19:48:00 +00:00
|
|
|
{
|
2013-02-15 18:47:34 +00:00
|
|
|
struct vo_x11_state *x11 = vo->x11;
|
|
|
|
|
|
|
|
if (x11->win_width != vo->dwidth || x11->win_height != vo->dheight) {
|
|
|
|
vo->dwidth = x11->win_width;
|
|
|
|
vo->dheight = x11->win_height;
|
|
|
|
x11->pending_vo_events |= VO_EVENT_RESIZE;
|
|
|
|
}
|
2010-07-01 19:48:00 +00:00
|
|
|
}
|
|
|
|
|
2008-04-20 06:34:27 +00:00
|
|
|
int vo_x11_check_events(struct vo *vo)
|
2004-06-14 04:53:03 +00:00
|
|
|
{
|
2008-04-20 23:50:40 +00:00
|
|
|
struct vo_x11_state *x11 = vo->x11;
|
2008-04-20 06:34:27 +00:00
|
|
|
Display *display = vo->x11->display;
|
2004-06-14 04:53:03 +00:00
|
|
|
XEvent Event;
|
2002-04-16 17:41:29 +00:00
|
|
|
|
2013-03-01 10:17:56 +00:00
|
|
|
xscreensaver_heartbeat(vo->x11);
|
|
|
|
|
2013-03-04 21:41:27 +00:00
|
|
|
if (vo->opts->WinID > 0)
|
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-02 16:08:37 +00:00
|
|
|
vo_x11_update_geometry(vo);
|
2013-02-13 15:33:01 +00:00
|
|
|
while (XPending(display)) {
|
2008-04-20 06:34:27 +00:00
|
|
|
XNextEvent(display, &Event);
|
2002-05-14 23:44:35 +00:00
|
|
|
// printf("\rEvent.type=%X \n",Event.type);
|
2013-02-13 15:33:01 +00:00
|
|
|
switch (Event.type) {
|
|
|
|
case Expose:
|
2013-02-15 18:47:34 +00:00
|
|
|
x11->pending_vo_events |= VO_EVENT_EXPOSE;
|
2013-02-13 15:33:01 +00:00
|
|
|
break;
|
|
|
|
case ConfigureNotify:
|
|
|
|
if (x11->window == None)
|
2004-06-14 04:53:03 +00:00
|
|
|
break;
|
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-02 16:08:37 +00:00
|
|
|
vo_x11_update_geometry(vo);
|
2013-02-13 15:33:01 +00:00
|
|
|
break;
|
|
|
|
case KeyPress: {
|
|
|
|
char buf[100];
|
|
|
|
KeySym keySym = 0;
|
|
|
|
int modifiers = 0;
|
2013-04-03 23:13:56 +00:00
|
|
|
if (x11->no_autorepeat)
|
|
|
|
modifiers |= MP_KEY_STATE_DOWN;
|
2013-02-13 15:33:01 +00:00
|
|
|
if (Event.xkey.state & ShiftMask)
|
|
|
|
modifiers |= MP_KEY_MODIFIER_SHIFT;
|
|
|
|
if (Event.xkey.state & ControlMask)
|
|
|
|
modifiers |= MP_KEY_MODIFIER_CTRL;
|
|
|
|
if (Event.xkey.state & Mod1Mask)
|
|
|
|
modifiers |= MP_KEY_MODIFIER_ALT;
|
|
|
|
if (Event.xkey.state & Mod4Mask)
|
|
|
|
modifiers |= MP_KEY_MODIFIER_META;
|
|
|
|
if (x11->xic) {
|
|
|
|
Status status;
|
|
|
|
int len = Xutf8LookupString(x11->xic, &Event.xkey, buf,
|
|
|
|
sizeof(buf), &keySym, &status);
|
|
|
|
int mpkey = vo_x11_lookupkey(keySym);
|
|
|
|
if (mpkey) {
|
|
|
|
mplayer_put_key(vo->key_fifo, mpkey | modifiers);
|
|
|
|
} else if (status == XLookupChars || status == XLookupBoth) {
|
|
|
|
struct bstr t = { buf, len };
|
|
|
|
mplayer_put_key_utf8(vo->key_fifo, modifiers, t);
|
2004-06-14 04:53:03 +00:00
|
|
|
}
|
2013-02-13 15:33:01 +00:00
|
|
|
} else {
|
|
|
|
XLookupString(&Event.xkey, buf, sizeof(buf), &keySym,
|
|
|
|
&x11->compose_status);
|
|
|
|
int mpkey = vo_x11_lookupkey(keySym);
|
|
|
|
if (mpkey)
|
|
|
|
mplayer_put_key(vo->key_fifo, mpkey | modifiers);
|
|
|
|
}
|
2013-04-03 23:13:56 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
// Releasing all keys in these situations is simpler and ensures no
|
|
|
|
// keys can be get "stuck".
|
|
|
|
case FocusOut:
|
|
|
|
case KeyRelease:
|
|
|
|
{
|
|
|
|
if (x11->no_autorepeat)
|
|
|
|
mplayer_put_key(vo->key_fifo, MP_INPUT_RELEASE_ALL);
|
|
|
|
break;
|
2013-02-13 15:33:01 +00:00
|
|
|
}
|
|
|
|
case MotionNotify:
|
|
|
|
vo_mouse_movement(vo, Event.xmotion.x, Event.xmotion.y);
|
|
|
|
break;
|
2013-06-19 16:19:45 +00:00
|
|
|
case LeaveNotify:
|
|
|
|
mplayer_put_key(vo->key_fifo, MP_KEY_MOUSE_LEAVE);
|
|
|
|
break;
|
2013-02-13 15:33:01 +00:00
|
|
|
case ButtonPress:
|
|
|
|
mplayer_put_key(vo->key_fifo,
|
|
|
|
(MP_MOUSE_BTN0 + Event.xbutton.button - 1)
|
|
|
|
| MP_KEY_STATE_DOWN);
|
|
|
|
break;
|
|
|
|
case ButtonRelease:
|
|
|
|
mplayer_put_key(vo->key_fifo,
|
|
|
|
MP_MOUSE_BTN0 + Event.xbutton.button - 1);
|
|
|
|
break;
|
|
|
|
case PropertyNotify: {
|
|
|
|
char *name = XGetAtomName(display, Event.xproperty.atom);
|
|
|
|
if (!name)
|
2004-06-14 04:53:03 +00:00
|
|
|
break;
|
2013-02-13 15:33:01 +00:00
|
|
|
XFree(name);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MapNotify:
|
|
|
|
x11->vo_hint.win_gravity = x11->old_gravity;
|
|
|
|
XSetWMNormalHints(display, x11->window, &x11->vo_hint);
|
|
|
|
x11->fs_flip = 0;
|
|
|
|
break;
|
|
|
|
case DestroyNotify:
|
|
|
|
mp_msg(MSGT_VO, MSGL_WARN, "Our window was destroyed, exiting\n");
|
|
|
|
mplayer_put_key(vo->key_fifo, MP_KEY_CLOSE_WIN);
|
|
|
|
break;
|
|
|
|
case ClientMessage:
|
|
|
|
if (Event.xclient.message_type == x11->XAWM_PROTOCOLS &&
|
|
|
|
Event.xclient.data.l[0] == x11->XAWM_DELETE_WINDOW)
|
2013-02-12 00:34:04 +00:00
|
|
|
mplayer_put_key(vo->key_fifo, MP_KEY_CLOSE_WIN);
|
2013-02-13 15:33:01 +00:00
|
|
|
break;
|
2013-01-02 11:55:52 +00:00
|
|
|
default:
|
2013-02-13 15:33:01 +00:00
|
|
|
if (Event.type == x11->ShmCompletionEvent) {
|
|
|
|
if (x11->ShmCompletionWaitCount > 0)
|
|
|
|
x11->ShmCompletionWaitCount--;
|
|
|
|
}
|
|
|
|
break;
|
2004-06-14 04:53:03 +00:00
|
|
|
}
|
|
|
|
}
|
2013-03-02 21:50:09 +00:00
|
|
|
|
2013-02-15 18:47:34 +00:00
|
|
|
update_vo_size(vo);
|
2013-03-04 21:41:27 +00:00
|
|
|
if (vo->opts->WinID >= 0 && (x11->pending_vo_events & VO_EVENT_RESIZE)) {
|
2013-02-15 18:47:34 +00:00
|
|
|
int x = x11->win_x, y = x11->win_y;
|
|
|
|
unsigned int w = x11->win_width, h = x11->win_height;
|
2013-02-24 22:35:13 +00:00
|
|
|
XMoveResizeWindow(x11->display, x11->window, x, y, w, h);
|
|
|
|
}
|
2013-02-15 18:47:34 +00:00
|
|
|
int ret = x11->pending_vo_events;
|
|
|
|
x11->pending_vo_events = 0;
|
2004-06-14 04:53:03 +00:00
|
|
|
return ret;
|
2001-03-03 21:47:37 +00:00
|
|
|
}
|
|
|
|
|
2013-01-26 21:37:47 +00:00
|
|
|
static void vo_x11_sizehint(struct vo *vo, int x, int y, int width, int height,
|
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-02 16:08:37 +00:00
|
|
|
bool override_pos)
|
2002-03-08 20:14:08 +00:00
|
|
|
{
|
2013-03-04 21:41:27 +00:00
|
|
|
struct mp_vo_opts *opts = vo->opts;
|
2008-04-21 00:14:37 +00:00
|
|
|
struct vo_x11_state *x11 = vo->x11;
|
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-02 16:08:37 +00:00
|
|
|
|
2013-03-04 21:41:27 +00:00
|
|
|
bool force_pos = opts->geometry.xy_valid || // explicitly forced by user
|
|
|
|
opts->force_window_position || // resize -> reset position
|
|
|
|
opts->screen_id >= 0 || // force onto screen area
|
|
|
|
opts->WinID >= 0 || // force to fill parent
|
|
|
|
override_pos; // for fullscreen and such
|
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-02 16:08:37 +00:00
|
|
|
|
2008-04-21 01:19:43 +00:00
|
|
|
x11->vo_hint.flags = 0;
|
2013-03-04 21:41:27 +00:00
|
|
|
if (opts->keepaspect) {
|
2008-04-21 01:19:43 +00:00
|
|
|
x11->vo_hint.flags |= PAspect;
|
|
|
|
x11->vo_hint.min_aspect.x = width;
|
|
|
|
x11->vo_hint.min_aspect.y = height;
|
|
|
|
x11->vo_hint.max_aspect.x = width;
|
|
|
|
x11->vo_hint.max_aspect.y = height;
|
2004-06-14 04:53:03 +00:00
|
|
|
}
|
|
|
|
|
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-02 16:08:37 +00:00
|
|
|
x11->vo_hint.flags |= PSize | (force_pos ? PPosition : 0);
|
2008-04-21 01:19:43 +00:00
|
|
|
x11->vo_hint.x = x;
|
|
|
|
x11->vo_hint.y = y;
|
|
|
|
x11->vo_hint.width = width;
|
|
|
|
x11->vo_hint.height = height;
|
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-02 16:08:37 +00:00
|
|
|
x11->vo_hint.max_width = 0;
|
|
|
|
x11->vo_hint.max_height = 0;
|
2004-06-14 04:53:03 +00:00
|
|
|
|
libvo, libao: remove useless video and audio output drivers
Some of these have only limited use, and some of these have no use at
all. Remove them. They make maintainance harder and nobody needs them.
It's possible that many of the removed drivers were very useful a dozen
of years ago, but now it's 2012.
Note that some of these could be added back, in case they were more
useful than I thought. But right now, they are just a burden.
Reason for removal for each module:
vo_3dfx, vo_dfbmga, vo_dxr3, vo_ivtv, vo_mga, vo_s3fb,
vo_tdfxfb, vo_xmga, vo_tdfx_vid:
All of these are for very specific and outdated hardware. Some
of them require non-standard kernel drivers or do direct HW
access.
vo_dga: the most crappy and ancient way to get fast output on X.
vo_aa: there's vo_caca for the same purpose.
vo_ggi: this never lived, and is entirely useless.
vo_mpegpes: for DVB cards, I can't test this and it's crappy.
vo_fbdev, vo_fbdev2: there's vo_directfb2
vo_bl: what is this even? But it's neither important, nor alive.
vo_svga, vo_vesa: you want to use this? You can't be serious.
vo_wii: I can't test this, and who the hell uses this?
vo_xvr100: some Sun thing.
vo_xover: only useful in connection with xvr100.
ao_nas: still alive, but I doubt it has any meaning today.
ao_sun: Sun.
ao_win32: use ao_dsound or ao_portaudio instead.
ao_ivtv: removed along vo_ivtv.
Also get rid of anything SDL related. SDL 1.x is total crap for video
output, and will be replaced with SDL 2.x soon (perhaps), so if you
want to use SDL, write output drivers for SDL 2.x.
Additionally, I accidentally damaged Sun support, which made me
completely remove Sun/Solaris support. Nobody cares about this anyway.
Some left overs from previous commits removing modules were cleaned up.
2012-07-28 18:20:17 +00:00
|
|
|
// Set minimum height/width to 4 to avoid off-by-one errors.
|
2008-04-21 01:19:43 +00:00
|
|
|
x11->vo_hint.flags |= PMinSize;
|
|
|
|
x11->vo_hint.min_width = x11->vo_hint.min_height = 4;
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2008-12-05 19:01:49 +00:00
|
|
|
// Set the base size. A window manager might display the window
|
|
|
|
// size to the user relative to this.
|
|
|
|
// Setting these to width/height might be nice, but e.g. fluxbox can't handle it.
|
2008-12-06 00:16:51 +00:00
|
|
|
x11->vo_hint.flags |= PBaseSize;
|
|
|
|
x11->vo_hint.base_width = 0 /*width*/;
|
|
|
|
x11->vo_hint.base_height = 0 /*height*/;
|
2008-12-05 19:01:49 +00:00
|
|
|
|
2008-04-21 01:19:43 +00:00
|
|
|
x11->vo_hint.flags |= PWinGravity;
|
|
|
|
x11->vo_hint.win_gravity = StaticGravity;
|
|
|
|
XSetWMNormalHints(x11->display, x11->window, &x11->vo_hint);
|
2002-03-08 20:14:08 +00:00
|
|
|
}
|
|
|
|
|
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-02 16:08:37 +00:00
|
|
|
static void vo_x11_move_resize(struct vo *vo, bool move, bool resize,
|
|
|
|
int x, int y, int w, int h)
|
2013-01-26 21:37:47 +00:00
|
|
|
{
|
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-02 16:08:37 +00:00
|
|
|
XWindowChanges req = {.x = x, .y = y, .width = w, .height = h};
|
|
|
|
unsigned mask = (move ? CWX | CWY : 0) | (resize ? CWWidth | CWHeight : 0);
|
|
|
|
if (mask)
|
|
|
|
XConfigureWindow(vo->x11->display, vo->x11->window, mask, &req);
|
|
|
|
vo_x11_sizehint(vo, x, y, w, h, false);
|
2013-01-26 21:37:47 +00:00
|
|
|
}
|
|
|
|
|
2008-04-20 23:50:40 +00:00
|
|
|
static int vo_x11_get_gnome_layer(struct vo_x11_state *x11, Window win)
|
2003-01-09 21:23:54 +00:00
|
|
|
{
|
2004-06-14 04:53:03 +00:00
|
|
|
Atom type;
|
|
|
|
int format;
|
|
|
|
unsigned long nitems;
|
|
|
|
unsigned long bytesafter;
|
|
|
|
unsigned short *args = NULL;
|
|
|
|
|
2008-04-20 23:50:40 +00:00
|
|
|
if (XGetWindowProperty(x11->display, win, x11->XA_WIN_LAYER, 0, 16384,
|
2004-06-14 04:53:03 +00:00
|
|
|
False, AnyPropertyType, &type, &format, &nitems,
|
|
|
|
&bytesafter,
|
|
|
|
(unsigned char **) &args) == Success
|
|
|
|
&& nitems > 0 && args)
|
|
|
|
{
|
|
|
|
mp_msg(MSGT_VO, MSGL_V, "[x11] original window layer is %d.\n",
|
|
|
|
*args);
|
|
|
|
return *args;
|
|
|
|
}
|
|
|
|
return WIN_LAYER_NORMAL;
|
2003-01-09 21:23:54 +00:00
|
|
|
}
|
|
|
|
|
2012-01-25 01:01:22 +00:00
|
|
|
// set a X text property that expects a UTF8_STRING type
|
|
|
|
static void vo_x11_set_property_utf8(struct vo *vo, Atom name, const char *t)
|
|
|
|
{
|
|
|
|
struct vo_x11_state *x11 = vo->x11;
|
|
|
|
|
|
|
|
XChangeProperty(x11->display, x11->window, name, x11->XAUTF8_STRING, 8,
|
|
|
|
PropModeReplace, t, strlen(t));
|
|
|
|
}
|
|
|
|
|
2011-12-26 16:15:11 +00:00
|
|
|
// set a X text property that expects a STRING or COMPOUND_TEXT type
|
2011-12-06 17:48:31 +00:00
|
|
|
static void vo_x11_set_property_string(struct vo *vo, Atom name, const char *t)
|
|
|
|
{
|
|
|
|
struct vo_x11_state *x11 = vo->x11;
|
|
|
|
XTextProperty prop = {0};
|
|
|
|
|
2011-12-26 16:15:11 +00:00
|
|
|
if (Xutf8TextListToTextProperty(x11->display, (char **)&t, 1,
|
|
|
|
XStdICCTextStyle, &prop) == Success)
|
|
|
|
{
|
2011-12-06 17:48:31 +00:00
|
|
|
XSetTextProperty(x11->display, x11->window, &prop, name);
|
2012-01-25 01:01:22 +00:00
|
|
|
} else {
|
|
|
|
// Strictly speaking this violates the ICCCM, but there's no way we
|
|
|
|
// can do this correctly.
|
|
|
|
vo_x11_set_property_utf8(vo, name, t);
|
2011-12-26 16:15:11 +00:00
|
|
|
}
|
2011-12-06 17:48:31 +00:00
|
|
|
|
2012-01-25 01:01:22 +00:00
|
|
|
if (prop.value)
|
|
|
|
XFree(prop.value);
|
2011-12-06 17:48:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void vo_x11_update_window_title(struct vo *vo)
|
|
|
|
{
|
|
|
|
struct vo_x11_state *x11 = vo->x11;
|
|
|
|
|
2013-06-15 17:04:20 +00:00
|
|
|
if (!x11->window)
|
|
|
|
return;
|
|
|
|
|
2011-12-06 17:48:31 +00:00
|
|
|
const char *title = vo_get_window_title(vo);
|
|
|
|
vo_x11_set_property_string(vo, XA_WM_NAME, title);
|
|
|
|
vo_x11_set_property_string(vo, XA_WM_ICON_NAME, title);
|
|
|
|
vo_x11_set_property_utf8(vo, x11->XA_NET_WM_NAME, title);
|
|
|
|
vo_x11_set_property_utf8(vo, x11->XA_NET_WM_ICON_NAME, title);
|
|
|
|
}
|
|
|
|
|
2013-01-27 11:01:08 +00:00
|
|
|
static void find_default_visual(struct vo_x11_state *x11, XVisualInfo *vis)
|
|
|
|
{
|
|
|
|
Display *display = x11->display;
|
|
|
|
XWindowAttributes attribs;
|
|
|
|
XGetWindowAttributes(display, DefaultRootWindow(display), &attribs);
|
|
|
|
XMatchVisualInfo(display, x11->screen, attribs.depth, TrueColor, vis);
|
|
|
|
}
|
|
|
|
|
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-02 16:08:37 +00:00
|
|
|
static void vo_x11_create_window(struct vo *vo, XVisualInfo *vis, int x, int y,
|
|
|
|
unsigned int w, unsigned int h)
|
2013-01-27 11:01:08 +00:00
|
|
|
{
|
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-02 16:08:37 +00:00
|
|
|
struct vo_x11_state *x11 = vo->x11;
|
|
|
|
|
|
|
|
assert(x11->window == None);
|
|
|
|
assert(!x11->xic);
|
|
|
|
|
|
|
|
XVisualInfo vinfo_storage;
|
|
|
|
if (!vis) {
|
|
|
|
vis = &vinfo_storage;
|
|
|
|
find_default_visual(x11, vis);
|
|
|
|
}
|
|
|
|
|
2013-04-15 19:18:46 +00:00
|
|
|
vo_x11_create_colormap(x11, vis);
|
|
|
|
unsigned long xswamask = CWBorderPixel | CWColormap;
|
|
|
|
XSetWindowAttributes xswa = {
|
|
|
|
.border_pixel = 0,
|
|
|
|
.colormap = x11->colormap,
|
|
|
|
};
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2013-03-04 21:41:27 +00:00
|
|
|
Window parent = vo->opts->WinID >= 0 ? vo->opts->WinID : x11->rootwin;
|
2013-02-24 22:35:13 +00:00
|
|
|
|
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-02 16:08:37 +00:00
|
|
|
x11->window =
|
|
|
|
XCreateWindow(x11->display, parent, x, y, w, h, 0, vis->depth,
|
2013-02-24 22:35:13 +00:00
|
|
|
CopyFromParent, vis->visual, xswamask, &xswa);
|
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-02 16:08:37 +00:00
|
|
|
XSetWMProtocols(x11->display, x11->window, &x11->XAWM_DELETE_WINDOW, 1);
|
|
|
|
x11->f_gc = XCreateGC(x11->display, x11->window, 0, 0);
|
|
|
|
x11->vo_gc = XCreateGC(x11->display, x11->window, 0, NULL);
|
2008-04-21 01:19:43 +00:00
|
|
|
XSetForeground(x11->display, x11->f_gc, 0);
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2013-05-16 21:24:56 +00:00
|
|
|
if (x11->mouse_cursor_hidden) {
|
|
|
|
x11->mouse_cursor_hidden = false;
|
|
|
|
vo_set_cursor_hidden(vo, true);
|
|
|
|
}
|
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-02 16:08:37 +00:00
|
|
|
x11->xic = XCreateIC(x11->xim,
|
|
|
|
XNInputStyle, XIMPreeditNone | XIMStatusNone,
|
|
|
|
XNClientWindow, x11->window,
|
|
|
|
XNFocusWindow, x11->window,
|
|
|
|
NULL);
|
2013-06-15 17:04:20 +00:00
|
|
|
|
|
|
|
vo_x11_update_window_title(vo);
|
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-02 16:08:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void vo_x11_map_window(struct vo *vo, int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
struct vo_x11_state *x11 = vo->x11;
|
|
|
|
|
|
|
|
x11->window_hidden = false;
|
|
|
|
vo_x11_move_resize(vo, true, true, x, y, w, h);
|
2013-03-04 21:41:27 +00:00
|
|
|
if (!vo->opts->border)
|
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-02 16:08:37 +00:00
|
|
|
vo_x11_decoration(vo, 0);
|
|
|
|
// map window
|
2013-03-04 16:40:21 +00:00
|
|
|
vo_x11_selectinput_witherr(vo, x11->display, x11->window,
|
2013-06-19 16:19:45 +00:00
|
|
|
StructureNotifyMask | ExposureMask |
|
2013-04-03 23:13:56 +00:00
|
|
|
KeyPressMask | KeyReleaseMask |
|
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-02 16:08:37 +00:00
|
|
|
ButtonPressMask | ButtonReleaseMask |
|
2013-06-19 16:19:45 +00:00
|
|
|
PointerMotionMask | LeaveWindowMask);
|
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-02 16:08:37 +00:00
|
|
|
XMapWindow(x11->display, x11->window);
|
|
|
|
vo_x11_clearwindow(vo, x11->window);
|
2003-08-31 22:27:10 +00:00
|
|
|
}
|
|
|
|
|
2013-02-13 15:33:01 +00:00
|
|
|
/* Create and setup a window suitable for display
|
|
|
|
* vis: Visual to use for creating the window (NULL for default)
|
|
|
|
* x, y: position of window (might be ignored)
|
|
|
|
* width, height: size of window
|
|
|
|
* flags: flags for window creation (VOFLAG_*)
|
|
|
|
* classname: name to use for the X11 classhint
|
2007-06-27 10:26:13 +00:00
|
|
|
*
|
2013-02-13 15:33:01 +00:00
|
|
|
* If the window already exists, it just moves and resizes it.
|
2007-06-27 10:26:13 +00:00
|
|
|
*/
|
2013-02-24 22:32:51 +00:00
|
|
|
void vo_x11_config_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y,
|
2007-06-27 10:26:13 +00:00
|
|
|
unsigned int width, unsigned int height, int flags,
|
2013-01-27 11:01:08 +00:00
|
|
|
const char *classname)
|
2007-06-27 10:26:13 +00:00
|
|
|
{
|
2013-03-04 21:41:27 +00:00
|
|
|
struct mp_vo_opts *opts = vo->opts;
|
2013-02-13 15:33:01 +00:00
|
|
|
struct vo_x11_state *x11 = vo->x11;
|
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-02 16:08:37 +00:00
|
|
|
|
2013-03-04 21:41:27 +00:00
|
|
|
if (opts->WinID >= 0) {
|
|
|
|
XSelectInput(x11->display, opts->WinID, StructureNotifyMask);
|
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-02 16:08:37 +00:00
|
|
|
vo_x11_update_geometry(vo);
|
2013-02-15 18:47:34 +00:00
|
|
|
x = x11->win_x; y = x11->win_y;
|
|
|
|
width = x11->win_width; height = x11->win_height;
|
2013-02-13 15:33:01 +00:00
|
|
|
}
|
|
|
|
if (x11->window == None) {
|
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-02 16:08:37 +00:00
|
|
|
vo_x11_create_window(vo, vis, x, y, width, height);
|
|
|
|
vo_x11_classhint(vo, x11->window, classname);
|
2013-03-04 21:41:27 +00:00
|
|
|
opts->fs = 0;
|
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-02 16:08:37 +00:00
|
|
|
x11->window_hidden = true;
|
2013-02-13 15:33:01 +00:00
|
|
|
}
|
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-02 16:08:37 +00:00
|
|
|
|
2013-02-13 15:33:01 +00:00
|
|
|
if (flags & VOFLAG_HIDDEN)
|
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-02 16:08:37 +00:00
|
|
|
return;
|
|
|
|
|
2013-03-04 21:41:27 +00:00
|
|
|
if (opts->ontop)
|
|
|
|
vo_x11_setlayer(vo, x11->window, opts->ontop);
|
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-02 16:08:37 +00:00
|
|
|
|
|
|
|
bool reset_size = !(x11->old_dwidth == width && x11->old_dheight == height);
|
|
|
|
if (x11->window_hidden) {
|
|
|
|
x11->nofs_x = x;
|
|
|
|
x11->nofs_y = y;
|
|
|
|
reset_size = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
x11->old_dwidth = width;
|
|
|
|
x11->old_dheight = height;
|
|
|
|
|
|
|
|
if (reset_size) {
|
|
|
|
x11->nofs_width = width;
|
|
|
|
x11->nofs_height = height;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x11->window_hidden) {
|
|
|
|
vo_x11_map_window(vo, x, y, width, height);
|
|
|
|
} else if (reset_size) {
|
2013-03-04 21:41:27 +00:00
|
|
|
bool reset_pos = opts->force_window_position;
|
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-02 16:08:37 +00:00
|
|
|
if (reset_pos) {
|
|
|
|
x11->nofs_x = x;
|
|
|
|
x11->nofs_y = y;
|
|
|
|
}
|
2013-03-04 21:41:27 +00:00
|
|
|
if (opts->fs) {
|
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-02 16:08:37 +00:00
|
|
|
x11->size_changed_during_fs = true;
|
|
|
|
x11->pos_changed_during_fs = reset_pos;
|
|
|
|
vo_x11_sizehint(vo, x, y, width, height, false);
|
|
|
|
} else {
|
|
|
|
vo_x11_move_resize(vo, reset_pos, true, x, y, width, height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-04 21:41:27 +00:00
|
|
|
if (!!opts->fs != !!(flags & VOFLAG_FULLSCREEN)) {
|
2013-02-13 15:33:01 +00:00
|
|
|
vo_x11_fullscreen(vo);
|
|
|
|
}
|
2011-05-29 23:05:57 +00:00
|
|
|
|
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-02 16:08:37 +00:00
|
|
|
XSync(x11->display, False);
|
2013-02-15 18:47:34 +00:00
|
|
|
|
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-02 16:08:37 +00:00
|
|
|
vo_x11_update_geometry(vo);
|
2013-02-15 18:47:34 +00:00
|
|
|
update_vo_size(vo);
|
|
|
|
x11->pending_vo_events &= ~VO_EVENT_RESIZE; // implicitly done by the VO
|
2007-06-27 10:26:13 +00:00
|
|
|
}
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2013-03-17 22:01:33 +00:00
|
|
|
static void fill_rect(struct vo *vo, GC gc, int x0, int y0, int x1, int y1)
|
2003-08-31 22:27:10 +00:00
|
|
|
{
|
2008-04-21 01:19:43 +00:00
|
|
|
struct vo_x11_state *x11 = vo->x11;
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2013-03-17 22:01:33 +00:00
|
|
|
x0 = FFMAX(x0, 0);
|
|
|
|
y0 = FFMAX(y0, 0);
|
|
|
|
x1 = FFMIN(x1, x11->win_width);
|
|
|
|
y1 = FFMIN(y1, x11->win_height);
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2013-03-17 22:01:33 +00:00
|
|
|
if (x11->window && x1 > x0 && y1 > y0)
|
|
|
|
XFillRectangle(x11->display, x11->window, gc, x0, y0, x1 - x0, y1 - y0);
|
|
|
|
}
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2013-03-17 22:01:33 +00:00
|
|
|
// Clear everything outside of rc with the background color
|
|
|
|
void vo_x11_clear_background(struct vo *vo, const struct mp_rect *rc)
|
|
|
|
{
|
|
|
|
struct vo_x11_state *x11 = vo->x11;
|
|
|
|
GC gc = x11->f_gc;
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2013-03-17 22:01:33 +00:00
|
|
|
int w = x11->win_width;
|
|
|
|
int h = x11->win_height;
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2013-03-17 22:01:33 +00:00
|
|
|
fill_rect(vo, gc, 0, 0, w, rc->y0); // top
|
|
|
|
fill_rect(vo, gc, 0, rc->y1, w, h); // bottom
|
|
|
|
fill_rect(vo, gc, 0, rc->y0, rc->x0, rc->y1); // left
|
|
|
|
fill_rect(vo, gc, rc->x1, rc->y0, w, rc->y1); // right
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2013-03-17 22:01:33 +00:00
|
|
|
XFlush(x11->display);
|
2003-08-31 22:27:10 +00:00
|
|
|
}
|
|
|
|
|
2008-04-20 23:18:28 +00:00
|
|
|
void vo_x11_clearwindow(struct vo *vo, Window vo_window)
|
2003-08-31 22:27:10 +00:00
|
|
|
{
|
2008-04-21 01:19:43 +00:00
|
|
|
struct vo_x11_state *x11 = vo->x11;
|
2013-03-04 21:41:27 +00:00
|
|
|
struct mp_vo_opts *opts = vo->opts;
|
2010-06-14 19:17:38 +00:00
|
|
|
if (x11->f_gc == None)
|
2004-06-14 04:53:03 +00:00
|
|
|
return;
|
2008-04-21 01:19:43 +00:00
|
|
|
XFillRectangle(x11->display, vo_window, x11->f_gc, 0, 0,
|
2013-03-04 21:41:27 +00:00
|
|
|
opts->screenwidth, opts->screenheight);
|
2008-04-21 01:19:43 +00:00
|
|
|
XFlush(x11->display);
|
2003-08-31 22:27:10 +00:00
|
|
|
}
|
|
|
|
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2013-01-26 21:37:47 +00:00
|
|
|
static void vo_x11_setlayer(struct vo *vo, Window vo_window, int layer)
|
2002-05-06 15:05:07 +00:00
|
|
|
{
|
2008-04-20 23:50:40 +00:00
|
|
|
struct vo_x11_state *x11 = vo->x11;
|
2013-03-04 21:41:27 +00:00
|
|
|
if (vo->opts->WinID >= 0)
|
2004-06-14 04:53:03 +00:00
|
|
|
return;
|
|
|
|
|
2013-02-13 15:33:01 +00:00
|
|
|
if (x11->fs_type & vo_wm_LAYER) {
|
2004-06-14 04:53:03 +00:00
|
|
|
XClientMessageEvent xev;
|
|
|
|
|
2008-04-21 01:37:46 +00:00
|
|
|
if (!x11->orig_layer)
|
|
|
|
x11->orig_layer = vo_x11_get_gnome_layer(x11, vo_window);
|
2004-06-14 04:53:03 +00:00
|
|
|
|
|
|
|
memset(&xev, 0, sizeof(xev));
|
|
|
|
xev.type = ClientMessage;
|
2008-04-20 23:50:40 +00:00
|
|
|
xev.display = x11->display;
|
2004-06-14 04:53:03 +00:00
|
|
|
xev.window = vo_window;
|
2008-04-20 23:50:40 +00:00
|
|
|
xev.message_type = x11->XA_WIN_LAYER;
|
2004-06-14 04:53:03 +00:00
|
|
|
xev.format = 32;
|
2013-01-26 21:37:47 +00:00
|
|
|
// if not fullscreen, stay on default layer
|
|
|
|
xev.data.l[0] = layer ? x11->fs_layer : x11->orig_layer;
|
2004-06-14 04:53:03 +00:00
|
|
|
xev.data.l[1] = CurrentTime;
|
2013-02-13 15:33:01 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_V, "[x11] Layered style stay on top (layer %ld).\n",
|
2004-06-14 04:53:03 +00:00
|
|
|
xev.data.l[0]);
|
2008-04-21 01:59:00 +00:00
|
|
|
XSendEvent(x11->display, x11->rootwin, False, SubstructureNotifyMask,
|
2013-02-13 15:33:01 +00:00
|
|
|
(XEvent *) &xev);
|
|
|
|
} else if (x11->fs_type & vo_wm_NETWM) {
|
2004-06-14 04:53:03 +00:00
|
|
|
XClientMessageEvent xev;
|
|
|
|
char *state;
|
|
|
|
|
|
|
|
memset(&xev, 0, sizeof(xev));
|
|
|
|
xev.type = ClientMessage;
|
2008-04-20 23:50:40 +00:00
|
|
|
xev.message_type = x11->XA_NET_WM_STATE;
|
|
|
|
xev.display = x11->display;
|
2004-06-14 04:53:03 +00:00
|
|
|
xev.window = vo_window;
|
|
|
|
xev.format = 32;
|
|
|
|
xev.data.l[0] = layer;
|
|
|
|
|
2013-02-13 15:33:01 +00:00
|
|
|
if (x11->fs_type & vo_wm_STAYS_ON_TOP) {
|
2008-04-20 23:50:40 +00:00
|
|
|
xev.data.l[1] = x11->XA_NET_WM_STATE_STAYS_ON_TOP;
|
2013-02-13 15:33:01 +00:00
|
|
|
} else if (x11->fs_type & vo_wm_ABOVE) {
|
2008-04-20 23:50:40 +00:00
|
|
|
xev.data.l[1] = x11->XA_NET_WM_STATE_ABOVE;
|
2013-02-13 15:33:01 +00:00
|
|
|
} else if (x11->fs_type & vo_wm_FULLSCREEN) {
|
2008-04-20 23:50:40 +00:00
|
|
|
xev.data.l[1] = x11->XA_NET_WM_STATE_FULLSCREEN;
|
2013-02-13 15:33:01 +00:00
|
|
|
} else if (x11->fs_type & vo_wm_BELOW) {
|
2007-01-18 09:03:42 +00:00
|
|
|
// This is not fallback. We can safely assume that the situation
|
|
|
|
// where only NETWM_STATE_BELOW is supported doesn't exist.
|
2008-04-20 23:50:40 +00:00
|
|
|
xev.data.l[1] = x11->XA_NET_WM_STATE_BELOW;
|
2013-02-13 15:33:01 +00:00
|
|
|
}
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2008-04-21 01:59:00 +00:00
|
|
|
XSendEvent(x11->display, x11->rootwin, False, SubstructureRedirectMask,
|
2013-02-13 15:33:01 +00:00
|
|
|
(XEvent *) &xev);
|
2008-04-20 23:50:40 +00:00
|
|
|
state = XGetAtomName(x11->display, xev.data.l[1]);
|
2004-06-14 04:53:03 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_V,
|
|
|
|
"[x11] NET style stay on top (layer %d). Using state %s.\n",
|
|
|
|
layer, state);
|
|
|
|
XFree(state);
|
|
|
|
}
|
2002-05-06 15:05:07 +00:00
|
|
|
}
|
|
|
|
|
2013-01-26 21:37:47 +00:00
|
|
|
static int vo_x11_get_fs_type(struct vo *vo)
|
2003-02-07 19:38:39 +00:00
|
|
|
{
|
2013-01-26 21:37:47 +00:00
|
|
|
struct vo_x11_state *x11 = vo->x11;
|
|
|
|
int type = x11->wm_type;
|
2013-03-04 21:41:27 +00:00
|
|
|
char **fstype_list = vo->opts->fstype_list;
|
2004-06-14 04:53:03 +00:00
|
|
|
int i;
|
|
|
|
|
2013-02-13 15:33:01 +00:00
|
|
|
if (fstype_list) {
|
|
|
|
for (i = 0; fstype_list[i]; i++) {
|
2004-06-14 04:53:03 +00:00
|
|
|
int neg = 0;
|
2013-01-26 21:37:47 +00:00
|
|
|
char *arg = fstype_list[i];
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2013-02-13 15:33:01 +00:00
|
|
|
if (fstype_list[i][0] == '-') {
|
2004-06-14 04:53:03 +00:00
|
|
|
neg = 1;
|
2013-01-26 21:37:47 +00:00
|
|
|
arg = fstype_list[i] + 1;
|
2004-06-14 04:53:03 +00:00
|
|
|
}
|
|
|
|
|
2013-02-13 15:33:01 +00:00
|
|
|
if (!strncmp(arg, "layer", 5)) {
|
|
|
|
if (!neg && (arg[5] == '=')) {
|
2004-06-14 04:53:03 +00:00
|
|
|
char *endptr = NULL;
|
2013-01-26 21:37:47 +00:00
|
|
|
int layer = strtol(fstype_list[i] + 6, &endptr, 10);
|
2004-06-14 04:53:03 +00:00
|
|
|
|
|
|
|
if (endptr && *endptr == '\0' && layer >= 0
|
|
|
|
&& layer <= 15)
|
2013-01-26 21:37:47 +00:00
|
|
|
x11->fs_layer = layer;
|
2004-06-14 04:53:03 +00:00
|
|
|
}
|
|
|
|
if (neg)
|
|
|
|
type &= ~vo_wm_LAYER;
|
|
|
|
else
|
|
|
|
type |= vo_wm_LAYER;
|
2013-02-13 15:33:01 +00:00
|
|
|
} else if (!strcmp(arg, "above")) {
|
2004-06-14 04:53:03 +00:00
|
|
|
if (neg)
|
|
|
|
type &= ~vo_wm_ABOVE;
|
|
|
|
else
|
|
|
|
type |= vo_wm_ABOVE;
|
2013-02-13 15:33:01 +00:00
|
|
|
} else if (!strcmp(arg, "fullscreen")) {
|
2004-06-14 04:53:03 +00:00
|
|
|
if (neg)
|
|
|
|
type &= ~vo_wm_FULLSCREEN;
|
|
|
|
else
|
|
|
|
type |= vo_wm_FULLSCREEN;
|
2013-02-13 15:33:01 +00:00
|
|
|
} else if (!strcmp(arg, "stays_on_top")) {
|
2004-06-14 04:53:03 +00:00
|
|
|
if (neg)
|
|
|
|
type &= ~vo_wm_STAYS_ON_TOP;
|
|
|
|
else
|
|
|
|
type |= vo_wm_STAYS_ON_TOP;
|
2013-02-13 15:33:01 +00:00
|
|
|
} else if (!strcmp(arg, "below")) {
|
2004-06-14 04:53:03 +00:00
|
|
|
if (neg)
|
|
|
|
type &= ~vo_wm_BELOW;
|
|
|
|
else
|
|
|
|
type |= vo_wm_BELOW;
|
2013-02-13 15:33:01 +00:00
|
|
|
} else if (!strcmp(arg, "netwm")) {
|
2004-06-14 04:53:03 +00:00
|
|
|
if (neg)
|
|
|
|
type &= ~vo_wm_NETWM;
|
|
|
|
else
|
|
|
|
type |= vo_wm_NETWM;
|
|
|
|
} else if (!strcmp(arg, "none"))
|
2013-02-13 15:33:01 +00:00
|
|
|
type = 0; // clear; keep parsing
|
2003-02-07 19:38:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-14 04:53:03 +00:00
|
|
|
return type;
|
2003-02-07 19:38:39 +00:00
|
|
|
}
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2013-02-15 18:47:34 +00:00
|
|
|
// update x11->win_x, x11->win_y, x11->win_width and x11->win_height with current values of vo->x11->window
|
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-02 16:08:37 +00:00
|
|
|
static void vo_x11_update_geometry(struct vo *vo)
|
2008-11-17 18:50:23 +00:00
|
|
|
{
|
|
|
|
struct vo_x11_state *x11 = vo->x11;
|
2013-01-26 21:37:47 +00:00
|
|
|
unsigned w, h, dummy_uint;
|
2008-11-15 17:45:55 +00:00
|
|
|
int dummy_int;
|
|
|
|
Window dummy_win;
|
2013-03-04 21:41:27 +00:00
|
|
|
Window win = vo->opts->WinID >= 0 ? vo->opts->WinID : x11->window;
|
2013-02-24 22:35:13 +00:00
|
|
|
XGetGeometry(x11->display, win, &dummy_win, &dummy_int, &dummy_int,
|
2013-01-26 21:37:47 +00:00
|
|
|
&w, &h, &dummy_int, &dummy_uint);
|
2008-11-17 18:50:23 +00:00
|
|
|
if (w <= INT_MAX && h <= INT_MAX) {
|
2013-02-15 18:47:34 +00:00
|
|
|
x11->win_width = w;
|
|
|
|
x11->win_height = h;
|
2008-11-17 18:50:23 +00:00
|
|
|
}
|
2013-03-04 21:41:27 +00:00
|
|
|
if (vo->opts->WinID >= 0) {
|
2013-02-15 18:47:34 +00:00
|
|
|
x11->win_x = 0;
|
|
|
|
x11->win_y = 0;
|
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-02 16:08:37 +00:00
|
|
|
} else {
|
2011-02-03 19:49:12 +00:00
|
|
|
XTranslateCoordinates(x11->display, x11->window, x11->rootwin, 0, 0,
|
2013-02-15 18:47:34 +00:00
|
|
|
&x11->win_x, &x11->win_y, &dummy_win);
|
2013-02-13 15:33:01 +00:00
|
|
|
}
|
2008-11-15 17:45:55 +00:00
|
|
|
}
|
|
|
|
|
2013-05-16 12:02:28 +00:00
|
|
|
static void vo_x11_fullscreen(struct vo *vo)
|
2002-03-07 17:50:25 +00:00
|
|
|
{
|
2013-03-04 21:41:27 +00:00
|
|
|
struct mp_vo_opts *opts = vo->opts;
|
2008-04-20 06:34:27 +00:00
|
|
|
struct vo_x11_state *x11 = vo->x11;
|
2004-06-14 04:53:03 +00:00
|
|
|
int x, y, w, h;
|
|
|
|
|
2013-03-04 21:41:27 +00:00
|
|
|
if (opts->WinID >= 0) {
|
|
|
|
opts->fs = !opts->fs;
|
2009-08-27 12:03:02 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-09-04 16:49:35 +00:00
|
|
|
if (x11->fs_flip)
|
2004-06-14 04:53:03 +00:00
|
|
|
return;
|
|
|
|
|
2013-03-04 21:41:27 +00:00
|
|
|
if (opts->fs) {
|
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-02 16:08:37 +00:00
|
|
|
// fs->win
|
2013-03-04 21:41:27 +00:00
|
|
|
opts->fs = VO_FALSE;
|
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-02 16:08:37 +00:00
|
|
|
|
|
|
|
x = x11->nofs_x;
|
|
|
|
y = x11->nofs_y;
|
|
|
|
w = x11->nofs_width;
|
|
|
|
h = x11->nofs_height;
|
|
|
|
|
2008-04-21 00:14:37 +00:00
|
|
|
vo_x11_ewmh_fullscreen(x11, _NET_WM_STATE_REMOVE); // removes fullscreen state if wm supports EWMH
|
2013-03-04 21:41:27 +00:00
|
|
|
if ((x11->fs_type & vo_wm_FULLSCREEN) && opts->fsscreen_id != -1) {
|
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-02 16:08:37 +00:00
|
|
|
x11->size_changed_during_fs = true;
|
|
|
|
x11->pos_changed_during_fs = true;
|
2013-02-17 15:35:44 +00:00
|
|
|
}
|
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-02 16:08:37 +00:00
|
|
|
|
|
|
|
if (x11->fs_type & vo_wm_FULLSCREEN) {
|
|
|
|
vo_x11_move_resize(vo, x11->pos_changed_during_fs,
|
|
|
|
x11->size_changed_during_fs, x, y, w, h);
|
2013-02-13 15:33:01 +00:00
|
|
|
}
|
|
|
|
} else {
|
2004-06-14 04:53:03 +00:00
|
|
|
// win->fs
|
2013-03-04 21:41:27 +00:00
|
|
|
opts->fs = true;
|
2013-02-17 15:35:44 +00:00
|
|
|
|
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-02 16:08:37 +00:00
|
|
|
vo_x11_update_geometry(vo);
|
|
|
|
x11->nofs_x = x11->win_x;
|
|
|
|
x11->nofs_y = x11->win_y;
|
|
|
|
x11->nofs_width = x11->win_width;
|
|
|
|
x11->nofs_height = x11->win_height;
|
2013-02-17 15:35:44 +00:00
|
|
|
|
2013-02-13 15:33:01 +00:00
|
|
|
vo_x11_update_screeninfo(vo);
|
2013-02-17 15:35:44 +00:00
|
|
|
|
2013-03-04 16:40:21 +00:00
|
|
|
x = vo->xinerama_x;
|
|
|
|
y = vo->xinerama_y;
|
2013-03-04 21:41:27 +00:00
|
|
|
w = opts->screenwidth;
|
|
|
|
h = opts->screenheight;
|
2013-02-17 15:35:44 +00:00
|
|
|
|
2013-03-04 21:41:27 +00:00
|
|
|
if ((x11->fs_type & vo_wm_FULLSCREEN) && opts->fsscreen_id != -1) {
|
2013-02-17 15:35:44 +00:00
|
|
|
// The EWMH fullscreen hint always works on the current screen, so
|
|
|
|
// change the current screen forcibly.
|
|
|
|
// This was observed to work under IceWM, but not Unity/Compiz and
|
|
|
|
// awesome (but --screen etc. doesn't really work on these either).
|
|
|
|
XMoveResizeWindow(x11->display, x11->window, x, y, w, h);
|
|
|
|
}
|
|
|
|
|
|
|
|
vo_x11_ewmh_fullscreen(x11, _NET_WM_STATE_ADD); // sends fullscreen state to be added if wm supports EWMH
|
2004-06-14 04:53:03 +00:00
|
|
|
}
|
|
|
|
{
|
|
|
|
long dummy;
|
|
|
|
|
2008-04-21 01:19:43 +00:00
|
|
|
XGetWMNormalHints(x11->display, x11->window, &x11->vo_hint, &dummy);
|
|
|
|
if (!(x11->vo_hint.flags & PWinGravity))
|
2008-04-21 01:37:46 +00:00
|
|
|
x11->old_gravity = NorthWestGravity;
|
2004-06-14 04:53:03 +00:00
|
|
|
else
|
2008-04-21 01:37:46 +00:00
|
|
|
x11->old_gravity = x11->vo_hint.win_gravity;
|
2004-06-14 04:53:03 +00:00
|
|
|
}
|
2013-03-04 21:41:27 +00:00
|
|
|
if (x11->wm_type == 0 && !(vo->opts->fsmode & 16)) {
|
2008-04-21 00:14:37 +00:00
|
|
|
XUnmapWindow(x11->display, x11->window); // required for MWM
|
2008-04-21 01:59:00 +00:00
|
|
|
XWithdrawWindow(x11->display, x11->window, x11->screen);
|
2008-04-21 01:50:29 +00:00
|
|
|
x11->fs_flip = 1;
|
2004-06-14 04:53:03 +00:00
|
|
|
}
|
|
|
|
|
2013-02-13 15:33:01 +00:00
|
|
|
if (!(x11->fs_type & vo_wm_FULLSCREEN)) { // not needed with EWMH fs
|
2013-03-04 21:41:27 +00:00
|
|
|
vo_x11_decoration(vo, opts->border && !opts->fs);
|
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-02 16:08:37 +00:00
|
|
|
vo_x11_sizehint(vo, x, y, w, h, true);
|
2013-03-04 21:41:27 +00:00
|
|
|
vo_x11_setlayer(vo, x11->window, opts->fs);
|
2004-06-14 04:53:03 +00:00
|
|
|
|
|
|
|
|
2008-04-21 00:14:37 +00:00
|
|
|
XMoveResizeWindow(x11->display, x11->window, x, y, w, h);
|
2004-07-11 22:16:52 +00:00
|
|
|
}
|
2007-01-18 09:03:42 +00:00
|
|
|
/* some WMs lose ontop after fullscreen */
|
2013-03-04 21:41:27 +00:00
|
|
|
if ((!(opts->fs)) & opts->ontop)
|
|
|
|
vo_x11_setlayer(vo, x11->window, opts->ontop);
|
2004-12-27 11:09:49 +00:00
|
|
|
|
2008-04-21 00:14:37 +00:00
|
|
|
XMapRaised(x11->display, x11->window);
|
2013-02-13 15:33:01 +00:00
|
|
|
if (!(x11->fs_type & vo_wm_FULLSCREEN)) // some WMs change window pos on map
|
2008-04-21 00:14:37 +00:00
|
|
|
XMoveResizeWindow(x11->display, x11->window, x, y, w, h);
|
|
|
|
XRaiseWindow(x11->display, x11->window);
|
2008-04-20 06:34:27 +00:00
|
|
|
XFlush(x11->display);
|
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-02 16:08:37 +00:00
|
|
|
|
|
|
|
x11->size_changed_during_fs = false;
|
|
|
|
x11->pos_changed_during_fs = false;
|
2002-03-07 17:50:25 +00:00
|
|
|
}
|
|
|
|
|
2013-05-16 12:02:28 +00:00
|
|
|
static void vo_x11_ontop(struct vo *vo)
|
2003-11-30 16:36:10 +00:00
|
|
|
{
|
2013-03-04 21:41:27 +00:00
|
|
|
struct mp_vo_opts *opts = vo->opts;
|
|
|
|
opts->ontop = !opts->ontop;
|
2003-11-30 16:36:10 +00:00
|
|
|
|
2013-03-04 21:41:27 +00:00
|
|
|
vo_x11_setlayer(vo, vo->x11->window, opts->ontop);
|
2003-11-30 16:36:10 +00:00
|
|
|
}
|
|
|
|
|
2013-05-16 12:02:28 +00:00
|
|
|
static void vo_x11_border(struct vo *vo)
|
2008-07-22 18:46:07 +00:00
|
|
|
{
|
2013-03-04 21:41:27 +00:00
|
|
|
vo->opts->border = !vo->opts->border;
|
|
|
|
vo_x11_decoration(vo, vo->opts->border && !vo->opts->fs);
|
2008-07-22 18:46:07 +00:00
|
|
|
}
|
|
|
|
|
2013-05-15 16:17:18 +00:00
|
|
|
int vo_x11_control(struct vo *vo, int *events, int request, void *arg)
|
|
|
|
{
|
2013-06-13 22:24:41 +00:00
|
|
|
struct vo_x11_state *x11 = vo->x11;
|
2013-05-15 16:17:18 +00:00
|
|
|
switch (request) {
|
|
|
|
case VOCTRL_CHECK_EVENTS:
|
|
|
|
*events |= vo_x11_check_events(vo);
|
|
|
|
return VO_TRUE;
|
|
|
|
case VOCTRL_FULLSCREEN:
|
|
|
|
vo_x11_fullscreen(vo);
|
|
|
|
*events |= VO_EVENT_RESIZE;
|
|
|
|
return VO_TRUE;
|
|
|
|
case VOCTRL_ONTOP:
|
|
|
|
vo_x11_ontop(vo);
|
|
|
|
return VO_TRUE;
|
|
|
|
case VOCTRL_BORDER:
|
|
|
|
vo_x11_border(vo);
|
|
|
|
*events |= VO_EVENT_RESIZE;
|
|
|
|
return VO_TRUE;
|
|
|
|
case VOCTRL_UPDATE_SCREENINFO:
|
|
|
|
vo_x11_update_screeninfo(vo);
|
|
|
|
return VO_TRUE;
|
2013-05-16 21:24:56 +00:00
|
|
|
case VOCTRL_SET_CURSOR_VISIBILITY:
|
|
|
|
vo_set_cursor_hidden(vo, !(*(bool *)arg));
|
|
|
|
return VO_TRUE;
|
2013-06-13 22:24:41 +00:00
|
|
|
case VOCTRL_KILL_SCREENSAVER:
|
|
|
|
saver_off(x11);
|
|
|
|
return VO_TRUE;
|
|
|
|
case VOCTRL_RESTORE_SCREENSAVER:
|
|
|
|
saver_on(x11);
|
|
|
|
return VO_TRUE;
|
2013-06-15 17:04:20 +00:00
|
|
|
case VOCTRL_UPDATE_WINDOW_TITLE:
|
|
|
|
vo_x11_update_window_title(vo);
|
|
|
|
return VO_TRUE;
|
2013-05-15 16:17:18 +00:00
|
|
|
}
|
|
|
|
return VO_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-03-01 10:17:56 +00:00
|
|
|
static void xscreensaver_heartbeat(struct vo_x11_state *x11)
|
2003-03-26 17:02:28 +00:00
|
|
|
{
|
2013-05-25 16:31:06 +00:00
|
|
|
double time = mp_time_sec();
|
2003-03-26 17:02:28 +00:00
|
|
|
|
2013-01-26 21:37:47 +00:00
|
|
|
if (x11->display && x11->screensaver_off &&
|
2013-05-25 16:31:06 +00:00
|
|
|
(time - x11->screensaver_time_last) > 30)
|
2004-06-14 04:53:03 +00:00
|
|
|
{
|
2013-01-26 21:37:47 +00:00
|
|
|
x11->screensaver_time_last = time;
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2008-04-20 06:34:27 +00:00
|
|
|
XResetScreenSaver(x11->display);
|
2003-03-26 17:02:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-20 06:34:27 +00:00
|
|
|
static int xss_suspend(Display *mDisplay, Bool suspend)
|
2007-12-22 11:09:43 +00:00
|
|
|
{
|
2008-08-04 06:16:23 +00:00
|
|
|
#ifndef CONFIG_XSS
|
2007-12-22 11:09:43 +00:00
|
|
|
return 0;
|
|
|
|
#else
|
|
|
|
int event, error, major, minor;
|
|
|
|
if (XScreenSaverQueryExtension(mDisplay, &event, &error) != True ||
|
|
|
|
XScreenSaverQueryVersion(mDisplay, &major, &minor) != True)
|
|
|
|
return 0;
|
2008-06-15 11:11:39 +00:00
|
|
|
if (major < 1 || (major == 1 && minor < 1))
|
2007-12-22 11:09:43 +00:00
|
|
|
return 0;
|
|
|
|
XScreenSaverSuspend(mDisplay, suspend);
|
|
|
|
return 1;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-01-26 21:37:47 +00:00
|
|
|
static void saver_on(struct vo_x11_state *x11)
|
2004-06-14 04:53:03 +00:00
|
|
|
{
|
2013-01-26 21:37:47 +00:00
|
|
|
Display *mDisplay = x11->display;
|
|
|
|
if (!x11->screensaver_off)
|
2008-01-07 12:18:17 +00:00
|
|
|
return;
|
2013-01-26 21:37:47 +00:00
|
|
|
x11->screensaver_off = 0;
|
2008-04-20 06:34:27 +00:00
|
|
|
if (xss_suspend(mDisplay, False))
|
2007-12-22 11:09:43 +00:00
|
|
|
return;
|
2008-08-04 06:16:23 +00:00
|
|
|
#ifdef CONFIG_XDPMS
|
2013-01-26 21:37:47 +00:00
|
|
|
if (x11->dpms_disabled) {
|
2007-12-20 12:51:24 +00:00
|
|
|
int nothing;
|
2013-01-26 21:37:47 +00:00
|
|
|
if (DPMSQueryExtension(mDisplay, ¬hing, ¬hing)) {
|
|
|
|
if (!DPMSEnable(mDisplay)) { // restoring power saving settings
|
2004-06-14 04:53:03 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_WARN, "DPMS not available?\n");
|
2013-01-26 21:37:47 +00:00
|
|
|
} else {
|
2001-05-09 20:15:37 +00:00
|
|
|
// DPMS does not seem to be enabled unless we call DPMSInfo
|
2004-06-14 04:53:03 +00:00
|
|
|
BOOL onoff;
|
|
|
|
CARD16 state;
|
|
|
|
|
|
|
|
DPMSForceLevel(mDisplay, DPMSModeOn);
|
|
|
|
DPMSInfo(mDisplay, &state, &onoff);
|
2013-02-13 15:33:01 +00:00
|
|
|
if (onoff) {
|
|
|
|
mp_msg(MSGT_VO, MSGL_V, "Successfully enabled DPMS\n");
|
|
|
|
} else {
|
2004-06-14 04:53:03 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_WARN, "Could not enable DPMS\n");
|
2001-05-09 20:15:37 +00:00
|
|
|
}
|
|
|
|
}
|
2004-06-14 04:53:03 +00:00
|
|
|
}
|
2013-01-26 21:37:47 +00:00
|
|
|
x11->dpms_disabled = 0;
|
2001-04-10 00:00:04 +00:00
|
|
|
}
|
2001-07-19 18:47:22 +00:00
|
|
|
#endif
|
2001-04-10 00:00:04 +00:00
|
|
|
}
|
|
|
|
|
2013-01-26 21:37:47 +00:00
|
|
|
static void saver_off(struct vo_x11_state *x11)
|
2004-06-14 04:53:03 +00:00
|
|
|
{
|
2013-01-26 21:37:47 +00:00
|
|
|
Display *mDisplay = x11->display;
|
2001-07-19 18:47:22 +00:00
|
|
|
int nothing;
|
2001-04-10 00:00:04 +00:00
|
|
|
|
2013-01-26 21:37:47 +00:00
|
|
|
if (x11->screensaver_off)
|
2008-01-07 12:18:17 +00:00
|
|
|
return;
|
2013-01-26 21:37:47 +00:00
|
|
|
x11->screensaver_off = 1;
|
2008-04-20 06:34:27 +00:00
|
|
|
if (xss_suspend(mDisplay, True))
|
2007-12-22 11:09:43 +00:00
|
|
|
return;
|
2008-08-04 06:16:23 +00:00
|
|
|
#ifdef CONFIG_XDPMS
|
2013-02-13 15:33:01 +00:00
|
|
|
if (DPMSQueryExtension(mDisplay, ¬hing, ¬hing)) {
|
2004-06-14 04:53:03 +00:00
|
|
|
BOOL onoff;
|
|
|
|
CARD16 state;
|
|
|
|
|
|
|
|
DPMSInfo(mDisplay, &state, &onoff);
|
2013-02-13 15:33:01 +00:00
|
|
|
if (onoff) {
|
2004-06-14 04:53:03 +00:00
|
|
|
Status stat;
|
|
|
|
|
2004-11-15 09:09:29 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_V, "Disabling DPMS\n");
|
2013-01-26 21:37:47 +00:00
|
|
|
x11->dpms_disabled = 1;
|
2004-06-14 04:53:03 +00:00
|
|
|
stat = DPMSDisable(mDisplay); // monitor powersave off
|
|
|
|
mp_msg(MSGT_VO, MSGL_V, "DPMSDisable stat: %d\n", stat);
|
|
|
|
}
|
2001-04-10 00:00:04 +00:00
|
|
|
}
|
2001-07-19 18:47:22 +00:00
|
|
|
#endif
|
2001-04-10 02:29:38 +00:00
|
|
|
}
|
2001-04-15 20:31:58 +00:00
|
|
|
|
2013-03-04 16:40:21 +00:00
|
|
|
static void vo_x11_selectinput_witherr(struct vo *vo,
|
|
|
|
Display *display,
|
|
|
|
Window w,
|
2013-01-26 21:37:47 +00:00
|
|
|
long event_mask)
|
2002-08-09 17:43:49 +00:00
|
|
|
{
|
2013-03-04 21:41:27 +00:00
|
|
|
if (vo->opts->nomouse_input)
|
2013-01-27 05:33:58 +00:00
|
|
|
event_mask &= ~(ButtonPressMask | ButtonReleaseMask);
|
|
|
|
|
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-02 16:08:37 +00:00
|
|
|
XSelectInput(display, w, NoEventMask);
|
|
|
|
|
2013-01-27 05:33:58 +00:00
|
|
|
// NOTE: this can raise BadAccess, which should be ignored by the X error
|
|
|
|
// handler; also see below
|
|
|
|
XSelectInput(display, w, event_mask);
|
|
|
|
|
|
|
|
// Test whether setting the event mask failed (with a BadAccess X error,
|
|
|
|
// although we don't know whether this really happened).
|
|
|
|
// This is needed for obscure situations like using --rootwin with a window
|
|
|
|
// manager active.
|
|
|
|
XWindowAttributes a;
|
|
|
|
if (XGetWindowAttributes(display, w, &a)) {
|
|
|
|
long bad = ButtonPressMask | ButtonReleaseMask | PointerMotionMask;
|
|
|
|
if ((event_mask & bad) && (a.all_event_masks & bad) &&
|
|
|
|
((a.your_event_mask & bad) != (event_mask & bad)))
|
|
|
|
{
|
|
|
|
mp_msg(MSGT_VO, MSGL_ERR, "X11 error: error during XSelectInput "
|
|
|
|
"call, trying without mouse events\n");
|
|
|
|
XSelectInput(display, w, event_mask & ~bad);
|
|
|
|
}
|
2004-06-14 04:53:03 +00:00
|
|
|
}
|
2002-08-09 17:43:49 +00:00
|
|
|
}
|
2002-01-05 08:49:46 +00:00
|
|
|
|
2008-08-04 06:16:23 +00:00
|
|
|
#ifdef CONFIG_XF86VM
|
2013-01-27 06:21:10 +00:00
|
|
|
double vo_x11_vm_get_fps(struct vo *vo)
|
2009-11-15 02:39:22 +00:00
|
|
|
{
|
|
|
|
struct vo_x11_state *x11 = vo->x11;
|
|
|
|
int clock;
|
|
|
|
XF86VidModeModeLine modeline;
|
|
|
|
if (!XF86VidModeGetModeLine(x11->display, x11->screen, &clock, &modeline))
|
|
|
|
return 0;
|
|
|
|
if (modeline.privsize)
|
2009-11-15 13:21:40 +00:00
|
|
|
XFree(modeline.private);
|
2009-11-15 02:39:22 +00:00
|
|
|
return 1e3 * clock / modeline.htotal / modeline.vtotal;
|
|
|
|
}
|
2013-01-27 06:21:10 +00:00
|
|
|
#else /* CONFIG_XF86VM */
|
2013-05-19 13:47:34 +00:00
|
|
|
double vo_x11_vm_get_fps(struct vo *vo)
|
2013-01-27 06:21:10 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2002-01-31 00:37:27 +00:00
|
|
|
#endif
|
|
|
|
|
2002-09-03 18:10:42 +00:00
|
|
|
|
2013-01-27 11:01:08 +00:00
|
|
|
static void vo_x11_create_colormap(struct vo_x11_state *x11,
|
|
|
|
XVisualInfo *vinfo)
|
2002-10-29 20:27:47 +00:00
|
|
|
{
|
2004-06-14 04:53:03 +00:00
|
|
|
unsigned k, r, g, b, ru, gu, bu, m, rv, gv, bv, rvu, gvu, bvu;
|
|
|
|
|
2013-01-27 11:01:08 +00:00
|
|
|
if (x11->colormap != None)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (vinfo->class != DirectColor) {
|
|
|
|
x11->colormap = XCreateColormap(x11->display, x11->rootwin,
|
|
|
|
vinfo->visual, AllocNone);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// DirectColor is requested by vo_x11 by default, for the equalizer
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2013-01-26 21:37:47 +00:00
|
|
|
x11->cm_size = vinfo->colormap_size;
|
|
|
|
x11->red_mask = vinfo->red_mask;
|
|
|
|
x11->green_mask = vinfo->green_mask;
|
|
|
|
x11->blue_mask = vinfo->blue_mask;
|
|
|
|
ru = (x11->red_mask & (x11->red_mask - 1)) ^ x11->red_mask;
|
|
|
|
gu = (x11->green_mask & (x11->green_mask - 1)) ^ x11->green_mask;
|
|
|
|
bu = (x11->blue_mask & (x11->blue_mask - 1)) ^ x11->blue_mask;
|
|
|
|
rvu = 65536ull * ru / (x11->red_mask + ru);
|
|
|
|
gvu = 65536ull * gu / (x11->green_mask + gu);
|
|
|
|
bvu = 65536ull * bu / (x11->blue_mask + bu);
|
2004-06-14 04:53:03 +00:00
|
|
|
r = g = b = 0;
|
|
|
|
rv = gv = bv = 0;
|
|
|
|
m = DoRed | DoGreen | DoBlue;
|
2013-02-13 15:33:01 +00:00
|
|
|
for (k = 0; k < x11->cm_size; k++) {
|
2004-06-14 04:53:03 +00:00
|
|
|
int t;
|
|
|
|
|
2013-01-26 21:37:47 +00:00
|
|
|
x11->cols[k].pixel = r | g | b;
|
|
|
|
x11->cols[k].red = rv;
|
|
|
|
x11->cols[k].green = gv;
|
|
|
|
x11->cols[k].blue = bv;
|
|
|
|
x11->cols[k].flags = m;
|
|
|
|
t = (r + ru) & x11->red_mask;
|
2004-06-14 04:53:03 +00:00
|
|
|
if (t < r)
|
|
|
|
m &= ~DoRed;
|
|
|
|
r = t;
|
2013-01-26 21:37:47 +00:00
|
|
|
t = (g + gu) & x11->green_mask;
|
2004-06-14 04:53:03 +00:00
|
|
|
if (t < g)
|
|
|
|
m &= ~DoGreen;
|
|
|
|
g = t;
|
2013-01-26 21:37:47 +00:00
|
|
|
t = (b + bu) & x11->blue_mask;
|
2004-06-14 04:53:03 +00:00
|
|
|
if (t < b)
|
|
|
|
m &= ~DoBlue;
|
|
|
|
b = t;
|
|
|
|
rv += rvu;
|
|
|
|
gv += gvu;
|
|
|
|
bv += bvu;
|
|
|
|
}
|
2013-01-27 11:01:08 +00:00
|
|
|
x11->colormap = XCreateColormap(x11->display, x11->rootwin, vinfo->visual,
|
|
|
|
AllocAll);
|
|
|
|
XStoreColors(x11->display, x11->colormap, x11->cols, x11->cm_size);
|
2002-10-29 20:27:47 +00:00
|
|
|
}
|
|
|
|
|
2008-01-12 16:30:41 +00:00
|
|
|
static int transform_color(float val,
|
2013-02-13 15:33:01 +00:00
|
|
|
float brightness, float contrast, float gamma)
|
|
|
|
{
|
2008-01-12 16:30:41 +00:00
|
|
|
float s = pow(val, gamma);
|
|
|
|
s = (s - 0.5) * contrast + 0.5;
|
|
|
|
s += brightness;
|
|
|
|
if (s < 0)
|
|
|
|
s = 0;
|
|
|
|
if (s > 1)
|
|
|
|
s = 1;
|
|
|
|
return (unsigned short) (s * 65535);
|
|
|
|
}
|
2002-10-29 20:27:47 +00:00
|
|
|
|
2011-03-07 20:50:45 +00:00
|
|
|
uint32_t vo_x11_set_equalizer(struct vo *vo, const char *name, int value)
|
2002-10-29 20:27:47 +00:00
|
|
|
{
|
2013-01-26 21:37:47 +00:00
|
|
|
struct vo_x11_state *x11 = vo->x11;
|
2004-06-14 04:53:03 +00:00
|
|
|
float gamma, brightness, contrast;
|
|
|
|
float rf, gf, bf;
|
|
|
|
int k;
|
2013-01-26 21:37:47 +00:00
|
|
|
int red_mask = x11->red_mask;
|
|
|
|
int green_mask = x11->green_mask;
|
|
|
|
int blue_mask = x11->blue_mask;
|
2004-06-14 04:53:03 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* IMPLEMENTME: consider using XF86VidModeSetGammaRamp in the case
|
|
|
|
* of TrueColor-ed window but be careful:
|
2007-01-18 09:03:42 +00:00
|
|
|
* Unlike the colormaps, which are private for the X client
|
2004-06-14 04:53:03 +00:00
|
|
|
* who created them and thus automatically destroyed on client
|
|
|
|
* disconnect, this gamma ramp is a system-wide (X-server-wide)
|
2007-01-18 09:03:42 +00:00
|
|
|
* setting and _must_ be restored before the process exits.
|
|
|
|
* Unforunately when the process crashes (or gets killed
|
2004-06-14 04:53:03 +00:00
|
|
|
* for some reason) it is impossible to restore the setting,
|
|
|
|
* and such behaviour could be rather annoying for the users.
|
|
|
|
*/
|
2013-01-27 11:01:08 +00:00
|
|
|
if (x11->colormap == None)
|
2004-06-14 04:53:03 +00:00
|
|
|
return VO_NOTAVAIL;
|
|
|
|
|
|
|
|
if (!strcasecmp(name, "brightness"))
|
2013-01-26 21:37:47 +00:00
|
|
|
x11->vo_brightness = value;
|
2004-06-14 04:53:03 +00:00
|
|
|
else if (!strcasecmp(name, "contrast"))
|
2013-01-26 21:37:47 +00:00
|
|
|
x11->vo_contrast = value;
|
2004-06-14 04:53:03 +00:00
|
|
|
else if (!strcasecmp(name, "gamma"))
|
2013-01-26 21:37:47 +00:00
|
|
|
x11->vo_gamma = value;
|
2004-06-14 04:53:03 +00:00
|
|
|
else
|
|
|
|
return VO_NOTIMPL;
|
|
|
|
|
2013-01-26 21:37:47 +00:00
|
|
|
brightness = 0.01 * x11->vo_brightness;
|
|
|
|
contrast = tan(0.0095 * (x11->vo_contrast + 100) * M_PI / 4);
|
|
|
|
gamma = pow(2, -0.02 * x11->vo_gamma);
|
2004-06-14 04:53:03 +00:00
|
|
|
|
|
|
|
rf = (float) ((red_mask & (red_mask - 1)) ^ red_mask) / red_mask;
|
|
|
|
gf = (float) ((green_mask & (green_mask - 1)) ^ green_mask) /
|
2013-02-13 15:33:01 +00:00
|
|
|
green_mask;
|
2004-06-14 04:53:03 +00:00
|
|
|
bf = (float) ((blue_mask & (blue_mask - 1)) ^ blue_mask) / blue_mask;
|
|
|
|
|
|
|
|
/* now recalculate the colormap using the newly set value */
|
2013-02-13 15:33:01 +00:00
|
|
|
for (k = 0; k < x11->cm_size; k++) {
|
2013-01-26 21:37:47 +00:00
|
|
|
x11->cols[k].red = transform_color(rf * k, brightness, contrast, gamma);
|
|
|
|
x11->cols[k].green = transform_color(gf * k, brightness, contrast, gamma);
|
|
|
|
x11->cols[k].blue = transform_color(bf * k, brightness, contrast, gamma);
|
2004-06-14 04:53:03 +00:00
|
|
|
}
|
|
|
|
|
2013-01-27 11:01:08 +00:00
|
|
|
XStoreColors(vo->x11->display, x11->colormap, x11->cols, x11->cm_size);
|
2008-04-20 06:34:27 +00:00
|
|
|
XFlush(vo->x11->display);
|
2004-06-14 04:53:03 +00:00
|
|
|
return VO_TRUE;
|
2002-10-29 20:27:47 +00:00
|
|
|
}
|
|
|
|
|
2013-01-26 21:37:47 +00:00
|
|
|
uint32_t vo_x11_get_equalizer(struct vo *vo, const char *name, int *value)
|
2002-10-29 20:27:47 +00:00
|
|
|
{
|
2013-01-26 21:37:47 +00:00
|
|
|
struct vo_x11_state *x11 = vo->x11;
|
2013-01-27 11:01:08 +00:00
|
|
|
if (x11->colormap == None)
|
2004-06-14 04:53:03 +00:00
|
|
|
return VO_NOTAVAIL;
|
|
|
|
if (!strcasecmp(name, "brightness"))
|
2013-01-26 21:37:47 +00:00
|
|
|
*value = x11->vo_brightness;
|
2004-06-14 04:53:03 +00:00
|
|
|
else if (!strcasecmp(name, "contrast"))
|
2013-01-26 21:37:47 +00:00
|
|
|
*value = x11->vo_contrast;
|
2004-06-14 04:53:03 +00:00
|
|
|
else if (!strcasecmp(name, "gamma"))
|
2013-01-26 21:37:47 +00:00
|
|
|
*value = x11->vo_gamma;
|
2004-06-14 04:53:03 +00:00
|
|
|
else
|
|
|
|
return VO_NOTIMPL;
|
|
|
|
return VO_TRUE;
|
2002-10-29 20:27:47 +00:00
|
|
|
}
|
2004-06-14 04:53:03 +00:00
|
|
|
|
2012-07-27 00:40:38 +00:00
|
|
|
bool vo_x11_screen_is_composited(struct vo *vo)
|
|
|
|
{
|
|
|
|
struct vo_x11_state *x11 = vo->x11;
|
|
|
|
return XGetSelectionOwner(x11->display, x11->XA_NET_WM_CM) != None;
|
|
|
|
}
|