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.
|
|
|
|
*/
|
|
|
|
|
2008-02-22 09:09:46 +00:00
|
|
|
#ifndef MPLAYER_X11_COMMON_H
|
|
|
|
#define MPLAYER_X11_COMMON_H
|
2002-03-07 17:50:25 +00:00
|
|
|
|
2010-01-04 19:04:33 +00:00
|
|
|
#include <stdint.h>
|
2010-07-23 00:30:44 +00:00
|
|
|
#include <stdbool.h>
|
2002-03-08 20:14:08 +00:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
|
2008-10-16 18:19:36 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2008-04-19 04:45:16 +00:00
|
|
|
struct vo;
|
2013-03-17 22:01:33 +00:00
|
|
|
struct mp_rect;
|
2008-04-19 04:45:16 +00:00
|
|
|
|
2008-04-20 04:36:34 +00:00
|
|
|
struct vo_x11_state {
|
2013-09-11 22:56:41 +00:00
|
|
|
struct mp_log *log;
|
2008-04-20 06:34:27 +00:00
|
|
|
Display *display;
|
2008-04-21 00:14:37 +00:00
|
|
|
Window window;
|
2008-04-21 01:59:00 +00:00
|
|
|
Window rootwin;
|
|
|
|
int screen;
|
|
|
|
int display_is_local;
|
2013-02-17 15:35:44 +00:00
|
|
|
int ws_width;
|
|
|
|
int ws_height;
|
2013-01-26 21:37:47 +00:00
|
|
|
|
|
|
|
int screensaver_off;
|
|
|
|
int dpms_disabled;
|
2013-05-25 16:31:06 +00:00
|
|
|
double screensaver_time_last;
|
2008-04-21 00:43:03 +00:00
|
|
|
|
2012-01-14 13:09:44 +00:00
|
|
|
XIM xim;
|
|
|
|
XIC xic;
|
2013-04-03 23:13:56 +00:00
|
|
|
bool no_autorepeat;
|
2012-01-14 13:09: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
|
|
|
GC f_gc; // used to paint background
|
|
|
|
GC vo_gc; // used to paint video
|
2013-01-27 11:01:08 +00:00
|
|
|
Colormap colormap;
|
2008-04-21 01:19:43 +00:00
|
|
|
|
2008-04-21 01:50:29 +00:00
|
|
|
int wm_type;
|
|
|
|
int fs_type;
|
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 window_hidden;
|
2008-04-21 01:50:29 +00:00
|
|
|
int fs_flip;
|
2013-01-26 21:37:47 +00:00
|
|
|
int fs_layer;
|
2013-07-18 12:05:39 +00:00
|
|
|
int fs; // whether we assume the window is in fullscreen mode
|
2008-04-21 01:50:29 +00:00
|
|
|
|
2008-04-21 01:19:43 +00:00
|
|
|
XSizeHints vo_hint;
|
2013-05-16 21:24:56 +00:00
|
|
|
bool mouse_cursor_hidden;
|
2008-04-21 01:37:46 +00:00
|
|
|
int orig_layer;
|
|
|
|
int old_gravity;
|
2008-04-21 01:41:52 +00:00
|
|
|
|
2013-02-15 18:47:34 +00:00
|
|
|
// Current actual window position (updated on window move/resize events).
|
|
|
|
int win_x;
|
|
|
|
int win_y;
|
|
|
|
unsigned int win_width;
|
|
|
|
unsigned int win_height;
|
|
|
|
|
|
|
|
int pending_vo_events;
|
|
|
|
|
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
|
|
|
// last non-fullscreen extends (updated on fullscreen or reinitialization)
|
|
|
|
int nofs_width;
|
|
|
|
int nofs_height;
|
|
|
|
int nofs_x;
|
|
|
|
int nofs_y;
|
|
|
|
|
2010-07-23 00:30:44 +00:00
|
|
|
/* Keep track of original video width/height to determine when to
|
|
|
|
* resize window when reconfiguring. Resize window when video size
|
|
|
|
* changes, but don't force window size changes as long as video size
|
|
|
|
* stays the same (even if that size is different from the current
|
|
|
|
* window size after the user modified the latter). */
|
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
|
|
|
int old_dwidth;
|
|
|
|
int old_dheight;
|
2010-07-23 00:30:44 +00:00
|
|
|
/* Video size changed during fullscreen when we couldn't tell the new
|
|
|
|
* size to the window manager. Must set window size when turning
|
|
|
|
* fullscreen off. */
|
|
|
|
bool size_changed_during_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
|
|
|
bool pos_changed_during_fs;
|
2008-04-21 01:19:43 +00:00
|
|
|
|
2013-10-27 22:22:46 +00:00
|
|
|
bool got_motif_hints;
|
2008-04-21 01:09:26 +00:00
|
|
|
unsigned int olddecor;
|
|
|
|
unsigned int oldfuncs;
|
2013-10-27 22:22:46 +00:00
|
|
|
|
2008-04-21 01:09:26 +00:00
|
|
|
XComposeStatus compose_status;
|
|
|
|
|
2013-01-02 11:55:52 +00:00
|
|
|
/* XShm stuff */
|
|
|
|
int ShmCompletionEvent;
|
|
|
|
/* Number of outstanding XShmPutImage requests */
|
|
|
|
/* Decremented when ShmCompletionEvent is received */
|
|
|
|
/* Increment it before XShmPutImage */
|
|
|
|
int ShmCompletionWaitCount;
|
|
|
|
|
2008-04-20 23:50:40 +00:00
|
|
|
Atom XA_NET_SUPPORTED;
|
|
|
|
Atom XA_NET_WM_STATE;
|
|
|
|
Atom XA_NET_WM_STATE_FULLSCREEN;
|
|
|
|
Atom XA_NET_WM_STATE_ABOVE;
|
|
|
|
Atom XA_NET_WM_STATE_STAYS_ON_TOP;
|
|
|
|
Atom XA_NET_WM_STATE_BELOW;
|
|
|
|
Atom XA_NET_WM_PID;
|
2011-12-06 17:48:31 +00:00
|
|
|
Atom XA_NET_WM_NAME;
|
|
|
|
Atom XA_NET_WM_ICON_NAME;
|
x11: add window icon
The png file added to etc/ are taken from the link mentioned in commit
303096b, except that they have been converted to 16 bit, sRGB (with
color profile info dropped, if there was one), and transparent pixels
reset for better compression.
The file x11_icon.bin is generated by gen-x11-icon.sh. I'm adding it to
the git repo directly, because the script requires ImageMagick, and we
don't want to make building even more complicated.
The way how this is done is basically a compromise between effort
required in x11_common.c and in gen-x11-icon.sh. Ideally, x11_icon.bin
would be directly in the format as required by _NET_WM_ICON, but trying
to write the binary width/height values from shell would probably be a
nightmare, so here we go.
The zlib code in x11_common.c is lifted from demux_mkv.c, with some
modifications (like accepting a gzip header, because I don't know how to
make gzip write raw compressed data).
2013-09-01 21:26:44 +00:00
|
|
|
Atom XA_NET_WM_ICON;
|
2008-04-20 23:50:40 +00:00
|
|
|
Atom XA_WIN_PROTOCOLS;
|
|
|
|
Atom XA_WIN_LAYER;
|
|
|
|
Atom XA_WIN_HINTS;
|
|
|
|
Atom XAWM_PROTOCOLS;
|
|
|
|
Atom XAWM_DELETE_WINDOW;
|
2011-12-06 17:48:31 +00:00
|
|
|
Atom XAUTF8_STRING;
|
2012-07-27 00:40:38 +00:00
|
|
|
Atom XA_NET_WM_CM;
|
2008-04-20 04:36:34 +00:00
|
|
|
};
|
|
|
|
|
2013-01-26 21:37:47 +00:00
|
|
|
int vo_x11_init(struct vo *vo);
|
|
|
|
void vo_x11_uninit(struct vo *vo);
|
2008-04-20 06:34:27 +00:00
|
|
|
int vo_x11_check_events(struct vo *vo);
|
2012-07-27 00:40:38 +00:00
|
|
|
bool vo_x11_screen_is_composited(struct vo *vo);
|
2008-11-15 17:48:27 +00:00
|
|
|
void fstype_help(void);
|
2013-02-24 22:32:51 +00:00
|
|
|
void vo_x11_config_vo_window(struct vo *vo, XVisualInfo *vis,
|
2013-02-13 15:33:01 +00:00
|
|
|
int x, int y, unsigned int width,
|
|
|
|
unsigned int height, int flags,
|
|
|
|
const char *classname);
|
2013-03-17 22:01:33 +00:00
|
|
|
void vo_x11_clear_background(struct vo *vo, const struct mp_rect *rc);
|
2008-04-20 23:18:28 +00:00
|
|
|
void vo_x11_clearwindow(struct vo *vo, Window vo_window);
|
2013-05-15 16:17:18 +00:00
|
|
|
int vo_x11_control(struct vo *vo, int *events, int request, void *arg);
|
2003-07-01 21:37:20 +00:00
|
|
|
|
2013-01-27 06:21:10 +00:00
|
|
|
double vo_x11_vm_get_fps(struct vo *vo);
|
2002-03-07 17:50:25 +00:00
|
|
|
|
2008-02-22 09:09:46 +00:00
|
|
|
#endif /* MPLAYER_X11_COMMON_H */
|