summaryrefslogtreecommitdiffstats
path: root/libvo/x11_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'libvo/x11_common.c')
-rw-r--r--libvo/x11_common.c1011
1 files changed, 502 insertions, 509 deletions
diff --git a/libvo/x11_common.c b/libvo/x11_common.c
index 5c21fee975..a7ac744af8 100644
--- a/libvo/x11_common.c
+++ b/libvo/x11_common.c
@@ -23,10 +23,12 @@
#include <limits.h>
#include "config.h"
+#include "options.h"
#include "mp_msg.h"
#include "mp_fifo.h"
#include "libavutil/common.h"
#include "x11_common.h"
+#include "talloc.h"
#ifdef X11_FULLSCREEN
@@ -75,11 +77,6 @@
#include "input/input.h"
#include "input/mouse.h"
-#ifdef CONFIG_GUI
-#include "gui/interface.h"
-#include "mplayer.h"
-#endif
-
#define WIN_LAYER_ONBOTTOM 2
#define WIN_LAYER_NORMAL 4
#define WIN_LAYER_ONTOP 6
@@ -87,57 +84,26 @@
extern int enable_mouse_movements;
int fs_layer = WIN_LAYER_ABOVE_DOCK;
-static int orig_layer = 0;
-static int old_gravity = NorthWestGravity;
int stop_xscreensaver = 0;
static int dpms_disabled = 0;
char *mDisplayName = NULL;
-Display *mDisplay = NULL;
-Window mRootWin;
-int mScreen;
-int mLocalDisplay;
-
-/* output window id */
-int vo_mouse_autohide = 0;
-int vo_wm_type = 0;
-int vo_fs_type = 0; // needs to be accessible for GUI X11 code
-static int window_state;
-static int vo_fs_flip = 0;
+
char **vo_fstype_list;
/* 1 means that the WM is metacity (broken as hell) */
int metacity_hack = 0;
-static Atom XA_NET_SUPPORTED;
-static Atom XA_NET_WM_STATE;
-static Atom XA_NET_WM_STATE_FULLSCREEN;
-static Atom XA_NET_WM_STATE_ABOVE;
-static Atom XA_NET_WM_STATE_STAYS_ON_TOP;
-static Atom XA_NET_WM_STATE_BELOW;
-static Atom XA_NET_WM_PID;
-static Atom XA_WIN_PROTOCOLS;
-static Atom XA_WIN_LAYER;
-static Atom XA_WIN_HINTS;
-static Atom XAWM_PROTOCOLS;
-static Atom XAWM_DELETE_WINDOW;
-
-#define XA_INIT(x) XA##x = XInternAtom(mDisplay, #x, False)
-
-static int vo_old_x = 0;
-static int vo_old_y = 0;
-static int vo_old_width = 0;
-static int vo_old_height = 0;
-
#ifdef CONFIG_XF86VM
XF86VidModeModeInfo **vidmodes = NULL;
XF86VidModeModeLine modeline;
#endif
static int vo_x11_get_fs_type(int supported);
-
+static void saver_off(Display *);
+static void saver_on(Display *);
/*
* Sends the EWMH fullscreen state event.
@@ -146,12 +112,12 @@ static int vo_x11_get_fs_type(int supported);
* _NET_WM_STATE_ADD -- add state
* _NET_WM_STATE_TOGGLE -- toggle
*/
-void vo_x11_ewmh_fullscreen(int action)
+void vo_x11_ewmh_fullscreen(struct vo_x11_state *x11, int action)
{
assert(action == _NET_WM_STATE_REMOVE ||
action == _NET_WM_STATE_ADD || action == _NET_WM_STATE_TOGGLE);
- if (vo_fs_type & vo_wm_FULLSCREEN)
+ if (x11->fs_type & vo_wm_FULLSCREEN)
{
XEvent xev;
@@ -159,32 +125,32 @@ void vo_x11_ewmh_fullscreen(int action)
xev.xclient.type = ClientMessage;
xev.xclient.serial = 0;
xev.xclient.send_event = True;
- xev.xclient.message_type = XA_NET_WM_STATE;
- xev.xclient.window = vo_window;
+ xev.xclient.message_type = x11->XA_NET_WM_STATE;
+ xev.xclient.window = x11->window;
xev.xclient.format = 32;
xev.xclient.data.l[0] = action;
- xev.xclient.data.l[1] = XA_NET_WM_STATE_FULLSCREEN;
+ xev.xclient.data.l[1] = x11->XA_NET_WM_STATE_FULLSCREEN;
xev.xclient.data.l[2] = 0;
xev.xclient.data.l[3] = 0;
xev.xclient.data.l[4] = 0;
/* finally send that damn thing */
- if (!XSendEvent(mDisplay, DefaultRootWindow(mDisplay), False,
+ if (!XSendEvent(x11->display, DefaultRootWindow(x11->display), False,
SubstructureRedirectMask | SubstructureNotifyMask,
&xev))
{
- mp_msg(MSGT_VO, MSGL_ERR, MSGTR_EwmhFullscreenStateFailed);
+ mp_tmsg(MSGT_VO, MSGL_ERR, "\nX11: Couldn't send EWMH fullscreen event!\n");
}
}
}
-void vo_hidecursor(Display * disp, Window win)
+static void vo_hidecursor(Display * disp, Window win)
{
Cursor no_ptr;
Pixmap bm_no;
XColor black, dummy;
Colormap colormap;
- static char bm_no_data[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+ const char bm_no_data[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
if (WinID == 0)
return; // do not hide if playing on the root window
@@ -203,7 +169,7 @@ void vo_hidecursor(Display * disp, Window win)
XFreeColors(disp,colormap,&black.pixel,1,0);
}
-void vo_showcursor(Display * disp, Window win)
+static void vo_showcursor(Display * disp, Window win)
{
if (WinID == 0)
return;
@@ -227,13 +193,14 @@ static int x11_errorhandler(Display * display, XErrorEvent * event)
event->error_code, event->request_code, event->minor_code);
// abort();
+ //exit_player("X11 error");
return 0;
#undef MSGLEN
}
void fstype_help(void)
{
- mp_msg(MSGT_VO, MSGL_INFO, MSGTR_AvailableFsType);
+ mp_tmsg(MSGT_VO, MSGL_INFO, "Available fullscreen layer change modes:\n");
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_FULL_SCREEN_TYPES\n");
mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "none",
@@ -278,9 +245,9 @@ static void fstype_dump(int fstype)
"[x11] Current fstype setting doesn't honour any X atoms\n");
}
-static int net_wm_support_state_test(Atom atom)
+static int net_wm_support_state_test(struct vo_x11_state *x11, Atom atom)
{
-#define NET_WM_STATE_TEST(x) { if (atom == XA_NET_WM_STATE_##x) { mp_msg( MSGT_VO,MSGL_V, "[x11] Detected wm supports " #x " state.\n" ); return vo_wm_##x; } }
+#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; } }
NET_WM_STATE_TEST(FULLSCREEN);
NET_WM_STATE_TEST(ABOVE);
@@ -289,20 +256,22 @@ static int net_wm_support_state_test(Atom atom)
return 0;
}
-static int x11_get_property(Atom type, Atom ** args, unsigned long *nitems)
+static int x11_get_property(struct vo_x11_state *x11, Atom type, Atom ** args,
+ unsigned long *nitems)
{
int format;
unsigned long bytesafter;
return Success ==
- XGetWindowProperty(mDisplay, mRootWin, type, 0, 16384, False,
+ XGetWindowProperty(x11->display, x11->rootwin, type, 0, 16384, False,
AnyPropertyType, &type, &format, nitems,
&bytesafter, (unsigned char **) args)
&& *nitems > 0;
}
-static int vo_wm_detect(void)
+static int vo_wm_detect(struct vo *vo)
{
+ struct vo_x11_state *x11 = vo->x11;
int i;
int wm = 0;
unsigned long nitems;
@@ -312,12 +281,12 @@ static int vo_wm_detect(void)
return 0;
// -- supports layers
- if (x11_get_property(XA_WIN_PROTOCOLS, &args, &nitems))
+ if (x11_get_property(x11, x11->XA_WIN_PROTOCOLS, &args, &nitems))
{
mp_msg(MSGT_VO, MSGL_V, "[x11] Detected wm supports layers.\n");
for (i = 0; i < nitems; i++)
{
- if (args[i] == XA_WIN_LAYER)
+ if (args[i] == x11->XA_WIN_LAYER)
{
wm |= vo_wm_LAYER;
metacity_hack |= 1;
@@ -337,11 +306,11 @@ static int vo_wm_detect(void)
}
}
// --- netwm
- if (x11_get_property(XA_NET_SUPPORTED, &args, &nitems))
+ if (x11_get_property(x11, x11->XA_NET_SUPPORTED, &args, &nitems))
{
mp_msg(MSGT_VO, MSGL_V, "[x11] Detected wm supports NetWM.\n");
for (i = 0; i < nitems; i++)
- wm |= net_wm_support_state_test(args[i]);
+ wm |= net_wm_support_state_test(vo->x11, args[i]);
XFree(args);
}
@@ -350,7 +319,8 @@ static int vo_wm_detect(void)
return wm;
}
-static void init_atoms(void)
+#define XA_INIT(x) x11->XA##x = XInternAtom(x11->display, #x, False)
+static void init_atoms(struct vo_x11_state *x11)
{
XA_INIT(_NET_SUPPORTED);
XA_INIT(_NET_WM_STATE);
@@ -366,21 +336,22 @@ static void init_atoms(void)
XA_INIT(WM_DELETE_WINDOW);
}
-void update_xinerama_info(void) {
+void update_xinerama_info(struct vo *vo) {
+ struct MPOpts *opts = vo->opts;
int screen = xinerama_screen;
xinerama_x = xinerama_y = 0;
#ifdef CONFIG_XINERAMA
- if (screen >= -1 && XineramaIsActive(mDisplay))
+ if (screen >= -1 && XineramaIsActive(vo->x11->display))
{
XineramaScreenInfo *screens;
int num_screens;
- screens = XineramaQueryScreens(mDisplay, &num_screens);
+ screens = XineramaQueryScreens(vo->x11->display, &num_screens);
if (screen >= num_screens)
screen = num_screens - 1;
if (screen == -1) {
- int x = vo_dx + vo_dwidth / 2;
- int y = vo_dy + vo_dheight / 2;
+ int x = vo->dx + vo->dwidth / 2;
+ int y = vo->dy + vo->dheight / 2;
for (screen = num_screens - 1; screen > 0; screen--) {
int left = screens[screen].x_org;
int right = left + screens[screen].width;
@@ -392,19 +363,21 @@ void update_xinerama_info(void) {
}
if (screen < 0)
screen = 0;
- vo_screenwidth = screens[screen].width;
- vo_screenheight = screens[screen].height;
+ opts->vo_screenwidth = screens[screen].width;
+ opts->vo_screenheight = screens[screen].height;
xinerama_x = screens[screen].x_org;
xinerama_y = screens[screen].y_org;
XFree(screens);
}
#endif
- aspect_save_screenres(vo_screenwidth, vo_screenheight);
+ aspect_save_screenres(vo, opts->vo_screenwidth, opts->vo_screenheight);
}
-int vo_init(void)
+int vo_init(struct vo *vo)
{
+ struct MPOpts *opts = vo->opts;
+ struct vo_x11_state *x11 = vo->x11;
// int mScreen;
int depth, bpp;
unsigned int mask;
@@ -420,9 +393,9 @@ int vo_init(void)
if (vo_rootwin)
WinID = 0; // use root window
- if (vo_depthonscreen)
+ if (x11->depthonscreen)
{
- saver_off(mDisplay);
+ saver_off(x11->display);
return 1; // already called
}
@@ -438,52 +411,52 @@ int vo_init(void)
mp_msg(MSGT_VO, MSGL_V, "X11 opening display: %s\n", dispName);
- mDisplay = XOpenDisplay(dispName);
- if (!mDisplay)
+ x11->display = XOpenDisplay(dispName);
+ if (!x11->display)
{
mp_msg(MSGT_VO, MSGL_ERR,
"vo: couldn't open the X11 display (%s)!\n", dispName);
return 0;
}
- mScreen = DefaultScreen(mDisplay); // screen ID
- mRootWin = RootWindow(mDisplay, mScreen); // root window ID
+ x11->screen = DefaultScreen(x11->display); // screen ID
+ x11->rootwin = RootWindow(x11->display, x11->screen); // root window ID
- init_atoms();
+ init_atoms(vo->x11);
#ifdef CONFIG_XF86VM
{
int clock;
- XF86VidModeGetModeLine(mDisplay, mScreen, &clock, &modeline);
- if (!vo_screenwidth)
- vo_screenwidth = modeline.hdisplay;
- if (!vo_screenheight)
- vo_screenheight = modeline.vdisplay;
+ XF86VidModeGetModeLine(x11->display, x11->screen, &clock, &modeline);
+ if (!opts->vo_screenwidth)
+ opts->vo_screenwidth = modeline.hdisplay;
+ if (!opts->vo_screenheight)
+ opts->vo_screenheight = modeline.vdisplay;
}
#endif
{
- if (!vo_screenwidth)
- vo_screenwidth = DisplayWidth(mDisplay, mScreen);
- if (!vo_screenheight)
- vo_screenheight = DisplayHeight(mDisplay, mScreen);
+ if (!opts->vo_screenwidth)
+ opts->vo_screenwidth = DisplayWidth(x11->display, x11->screen);
+ if (!opts->vo_screenheight)
+ opts->vo_screenheight = DisplayHeight(x11->display, x11->screen);
}
// get color depth (from root window, or the best visual):
- XGetWindowAttributes(mDisplay, mRootWin, &attribs);
+ XGetWindowAttributes(x11->display, x11->rootwin, &attribs);
depth = attribs.depth;
if (depth != 15 && depth != 16 && depth != 24 && depth != 32)
{
Visual *visual;
- depth = vo_find_depth_from_visuals(mDisplay, mScreen, &visual);
+ depth = vo_find_depth_from_visuals(x11->display, x11->screen, &visual);
if (depth != -1)
- mXImage = XCreateImage(mDisplay, visual, depth, ZPixmap,
+ mXImage = XCreateImage(x11->display, visual, depth, ZPixmap,
0, NULL, 1, 1, 8, 1);
} else
mXImage =
- XGetImage(mDisplay, mRootWin, 0, 0, 1, 1, AllPlanes, ZPixmap);
+ XGetImage(x11->display, x11->rootwin, 0, 0, 1, 1, AllPlanes, ZPixmap);
- vo_depthonscreen = depth; // display depth on screen
+ x11->depthonscreen = depth; // display depth on screen
// get bits/pixel from XImage structure:
if (mXImage == NULL)
@@ -493,15 +466,15 @@ int vo_init(void)
{
/*
* for the depth==24 case, the XImage structures might use
- * 24 or 32 bits of data per pixel. The global variable
- * vo_depthonscreen stores the amount of data per pixel in the
+ * 24 or 32 bits of data per pixel. The x11->depthonscreen
+ * field stores the amount of data per pixel in the
* XImage structure!
*
* Maybe we should rename vo_depthonscreen to (or add) vo_bpp?
*/
bpp = mXImage->bits_per_pixel;
- if ((vo_depthonscreen + 7) / 8 != (bpp + 7) / 8)
- vo_depthonscreen = bpp; // by A'rpi
+ if ((x11->depthonscreen + 7) / 8 != (bpp + 7) / 8)
+ x11->depthonscreen = bpp; // by A'rpi
mask =
mXImage->red_mask | mXImage->green_mask | mXImage->blue_mask;
mp_msg(MSGT_VO, MSGL_V,
@@ -509,12 +482,12 @@ int vo_init(void)
mXImage->red_mask, mXImage->green_mask, mXImage->blue_mask);
XDestroyImage(mXImage);
}
- if (((vo_depthonscreen + 7) / 8) == 2)
+ if (((x11->depthonscreen + 7) / 8) == 2)
{
if (mask == 0x7FFF)
- vo_depthonscreen = 15;
+ x11->depthonscreen = 15;
else if (mask == 0xFFFF)
- vo_depthonscreen = 16;
+ x11->depthonscreen = 16;
}
// XCloseDisplay( mDisplay );
/* slightly improved local display detection AST */
@@ -523,38 +496,38 @@ int vo_init(void)
else if (strncmp(dispName, "localhost:", 10) == 0)
dispName += 9;
if (*dispName == ':' && atoi(dispName + 1) < 10)
- mLocalDisplay = 1;
+ x11->display_is_local = 1;
else
- mLocalDisplay = 0;
+ x11->display_is_local = 0;
mp_msg(MSGT_VO, MSGL_V,
"vo: X11 running at %dx%d with depth %d and %d bpp (\"%s\" => %s display)\n",
- vo_screenwidth, vo_screenheight, depth, vo_depthonscreen,
- dispName, mLocalDisplay ? "local" : "remote");
+ opts->vo_screenwidth, opts->vo_screenheight, depth, x11->depthonscreen,
+ dispName, x11->display_is_local ? "local" : "remote");
- vo_wm_type = vo_wm_detect();
+ x11->wm_type = vo_wm_detect(vo);
- vo_fs_type = vo_x11_get_fs_type(vo_wm_type);
+ x11->fs_type = vo_x11_get_fs_type(x11->wm_type);
- fstype_dump(vo_fs_type);
+ fstype_dump(x11->fs_type);
- saver_off(mDisplay);
+ saver_off(x11->display);
return 1;
}
-void vo_uninit(void)
+void vo_uninit(struct vo_x11_state *x11)
{
- if (!mDisplay)
+ if (!x11->display)
{
mp_msg(MSGT_VO, MSGL_V,
"vo: x11 uninit called but X11 not initialized..\n");
- return;
+ } else {
+ mp_msg(MSGT_VO, MSGL_V, "vo: uninit ...\n");
+ XSetErrorHandler(NULL);
+ XCloseDisplay(x11->display);
+ x11->depthonscreen = 0;
+ x11->display = NULL;
}
-// if( !vo_depthonscreen ) return;
- mp_msg(MSGT_VO, MSGL_V, "vo: uninit ...\n");
- XSetErrorHandler(NULL);
- XCloseDisplay(mDisplay);
- vo_depthonscreen = 0;
- mDisplay = NULL;
+ talloc_free(x11);
}
#include "osdep/keycodes.h"
@@ -569,11 +542,12 @@ static const struct keymap keysym_map[] = {
{0, 0}
};
-static void vo_x11_putkey_ext(int keysym)
+static void vo_x11_putkey_ext(struct vo *vo, int keysym)
{
+ struct mp_fifo *f = vo->key_fifo;
int mpkey = lookup_keymap_table(keysym_map, keysym);
if (mpkey)
- mplayer_put_key(mpkey);
+ mplayer_put_key(f, mpkey);
}
#endif
@@ -612,7 +586,7 @@ static const struct keymap keymap[] = {
{0, 0}
};
-void vo_x11_putkey(int key)
+void vo_x11_putkey(struct vo *vo, int key)
{
static const char *passthrough_keys = " -+*/<>`~!@#$%^&()_{}:;\"\',.?\\|=[]";
int mpkey = 0;
@@ -626,7 +600,7 @@ void vo_x11_putkey(int key)
mpkey = lookup_keymap_table(keymap, key);
if (mpkey)
- mplayer_put_key(mpkey);
+ mplayer_put_key(vo->key_fifo, mpkey);
}
@@ -672,12 +646,9 @@ typedef struct
static MotifWmHints vo_MotifWmHints;
static Atom vo_MotifHints = None;
-void vo_x11_decoration(Display * vo_Display, Window w, int d)
+void vo_x11_decoration(struct vo *vo, int d)
{
- static unsigned int olddecor = MWM_DECOR_ALL;
- static unsigned int oldfuncs =
- MWM_FUNC_MOVE | MWM_FUNC_CLOSE | MWM_FUNC_MINIMIZE |
- MWM_FUNC_MAXIMIZE | MWM_FUNC_RESIZE;
+ struct vo_x11_state *x11 = vo->x11;
Atom mtype;
int mformat;
unsigned long mn, mb;
@@ -687,26 +658,27 @@ void vo_x11_decoration(Display * vo_Display, Window w, int d)
if (vo_fsmode & 8)
{
- XSetTransientForHint(vo_Display, w,
- RootWindow(vo_Display, mScreen));
+ XSetTransientForHint(x11->display, x11->window,
+ RootWindow(x11->display, x11->screen));
}
- vo_MotifHints = XInternAtom(vo_Display, "_MOTIF_WM_HINTS", 0);
+ vo_MotifHints = XInternAtom(x11->display, "_MOTIF_WM_HINTS", 0);
if (vo_MotifHints != None)
{
if (!d)
{
MotifWmHints *mhints = NULL;
- XGetWindowProperty(vo_Display, w, vo_MotifHints, 0, 20, False,
+ XGetWindowProperty(x11->display, x11->window,
+ vo_MotifHints, 0, 20, False,
vo_MotifHints, &mtype, &mformat, &mn,
&mb, (unsigned char **) &mhints);
if (mhints)
{
if (mhints->flags & MWM_HINTS_DECORATIONS)
- olddecor = mhints->decorations;
+ x11->olddecor = mhints->decorations;
if (mhints->flags & MWM_HINTS_FUNCTIONS)
- oldfuncs = mhints->functions;
+ x11->oldfuncs = mhints->functions;
XFree(mhints);
}
}
@@ -716,8 +688,8 @@ void vo_x11_decoration(Display * vo_Display, Window w, int d)
MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
if (d)
{
- vo_MotifWmHints.functions = oldfuncs;
- d = olddecor;
+ vo_MotifWmHints.functions = x11->oldfuncs;
+ d = x11->olddecor;
}
#if 0
vo_MotifWmHints.decorations =
@@ -726,114 +698,90 @@ void vo_x11_decoration(Display * vo_Display, Window w, int d)
vo_MotifWmHints.decorations =
d | ((vo_fsmode & 2) ? MWM_DECOR_MENU : 0);
#endif
- XChangeProperty(vo_Display, w, vo_MotifHints, vo_MotifHints, 32,
+ XChangeProperty(x11->display, x11->window, vo_MotifHints,
+ vo_MotifHints, 32,
PropModeReplace,
(unsigned char *) &vo_MotifWmHints,
(vo_fsmode & 4) ? 4 : 5);
}
}
-void vo_x11_classhint(Display * display, Window window, const char *name)
+void vo_x11_classhint(struct vo *vo, Window window, const char *name)
{
+ struct vo_x11_state *x11 = vo->x11;
XClassHint wmClass;
pid_t pid = getpid();
wmClass.res_name = vo_winname ? vo_winname : name;
wmClass.res_class = "MPlayer";
- XSetClassHint(display, window, &wmClass);
- XChangeProperty(display, window, XA_NET_WM_PID, XA_CARDINAL, 32,
- PropModeReplace, (unsigned char *) &pid, 1);
+ XSetClassHint(x11->display, window, &wmClass);
+ XChangeProperty(x11->display, window, x11->XA_NET_WM_PID, XA_CARDINAL,
+ 32, PropModeReplace, (unsigned char *) &pid, 1);
}
-Window vo_window = None;
-GC vo_gc = NULL;
-GC f_gc = NULL;
-XSizeHints vo_hint;
-
-#ifdef CONFIG_GUI
-void vo_setwindow(Window w, GC g)
+void vo_x11_uninit(struct vo *vo)
{
- vo_window = w;
- vo_gc = g;
-}
-#endif
+ struct vo_x11_state *x11 = vo->x11;
+ saver_on(x11->display);
+ if (x11->window != None)
+ vo_showcursor(x11->display, x11->window);
-void vo_x11_uninit(void)
-{
- saver_on(mDisplay);
- if (vo_window != None)
- vo_showcursor(mDisplay, vo_window);
-
- if (f_gc)
+ if (x11->f_gc)
{
- XFreeGC(mDisplay, f_gc);
- f_gc = NULL;
+ XFreeGC(vo->x11->display, x11->f_gc);
+ x11->f_gc = NULL;
}
-#ifdef CONFIG_GUI
- /* destroy window only if it's not controlled by the GUI */
- if (!use_gui)
-#endif
{
- if (vo_gc)
+ if (x11->vo_gc)
{
- XSetBackground(mDisplay, vo_gc, 0);
- XFreeGC(mDisplay, vo_gc);
- vo_gc = NULL;
+ XSetBackground(vo->x11->display, x11->vo_gc, 0);
+ XFreeGC(vo->x11->display, x11->vo_gc);
+ x11->vo_gc = NULL;
}
- if (vo_window != None)
+ if (x11->window != None)
{
- XClearWindow(mDisplay, vo_window);
+ XClearWindow(x11->display, x11->window);
if (WinID < 0)
{
XEvent xev;
- XUnmapWindow(mDisplay, vo_window);
- XSelectInput(mDisplay, vo_window, StructureNotifyMask);
- XDestroyWindow(mDisplay, vo_window);
+ XUnmapWindow(x11->display, x11->window);
+ XSelectInput(x11->display, x11->window, StructureNotifyMask);
+ XDestroyWindow(x11->display, x11->window);
do
{
- XNextEvent(mDisplay, &xev);
+ XNextEvent(x11->display, &xev);
}
while (xev.type != DestroyNotify
- || xev.xdestroywindow.event != vo_window);
+ || xev.xdestroywindow.event != x11->window);
}
- vo_window = None;
+ x11->window = None;
}
vo_fs = 0;
- vo_old_width = vo_old_height = 0;
+ x11->vo_old_width = x11->vo_old_height = 0;
}
}
-static unsigned int mouse_timer;
-static int mouse_waiting_hide;
-
-int vo_x11_check_events(Display * mydisplay)
+int vo_x11_check_events(struct vo *vo)
{
+ struct vo_x11_state *x11 = vo->x11;
+ Display *display = vo->x11->display;
int ret = 0;
XEvent Event;
char buf[100];
KeySym keySym;
- static XComposeStatus stat;
// unsigned long vo_KeyTable[512];
- if ((vo_mouse_autohide) && mouse_waiting_hide &&
- (GetTimerMS() - mouse_timer >= 1000)) {
- vo_hidecursor(mydisplay, vo_window);
- mouse_waiting_hide = 0;
+ if ((x11->vo_mouse_autohide) && x11->mouse_waiting_hide &&
+ (GetTimerMS() - x11->mouse_timer >= 1000)) {
+ vo_hidecursor(display, x11->window);
+ x11->mouse_waiting_hide = 0;
}
- while (XPending(mydisplay))
+ while (XPending(display))
{
- XNextEvent(mydisplay, &Event);
-#ifdef CONFIG_GUI
- if (use_gui)
- {
- guiGetEvent(0, (char *) &Event);
- if (vo_window != Event.xany.window)
- continue;
- }
-#endif
+ XNextEvent(display, &Event);
// printf("\rEvent.type=%X \n",Event.type);
switch (Event.type)
{
@@ -841,15 +789,12 @@ int vo_x11_check_events(Display * mydisplay)
ret |= VO_EVENT_EXPOSE;
break;
case ConfigureNotify:
-// if (!vo_fs && (Event.xconfigure.width == vo_screenwidth || Event.xconfigure.height == vo_screenheight)) break;
-// if (vo_fs && Event.xconfigure.width != vo_screenwidth && Event.xconfigure.height != vo_screenheight) break;
- if (vo_window == None)
+ if (x11->window == None)
break;
{
- int old_w = vo_dwidth, old_h = vo_dheight;
- int old_x = vo_dx, old_y = vo_dy;
- vo_x11_update_geometry();
- if (vo_dwidth != old_w || vo_dheight != old_h || vo_dx != old_x || vo_dy != old_y)
+ int old_w = vo->dwidth, old_h = vo->dheight;
+ vo_x11_update_geometry(vo);
+ if (vo->dwidth != old_w || vo->dheight != old_h)
ret |= VO_EVENT_RESIZE;
}
break;
@@ -857,19 +802,15 @@ int vo_x11_check_events(Display * mydisplay)
{
int key;
-#ifdef CONFIG_GUI
- if ( use_gui ) { break; }
-#endif
-
XLookupString(&Event.xkey, buf, sizeof(buf), &keySym,
- &stat);
+ &x11->compose_status);
#ifdef XF86XK_AudioPause
- vo_x11_putkey_ext(keySym);
+ vo_x11_putkey_ext(vo, keySym);
#endif
key =
((keySym & 0xff00) !=
0 ? ((keySym & 0x00ff) + 256) : (keySym));
- vo_x11_putkey(key);
+ vo_x11_putkey(vo, key);
ret |= VO_EVENT_KEYPRESS;
}
break;
@@ -878,51 +819,42 @@ int vo_x11_check_events(Display * mydisplay)
{
char cmd_str[40];
sprintf(cmd_str,"set_mouse_pos %i %i",Event.xmotion.x, Event.xmotion.y);
- mp_input_queue_cmd(mp_input_parse_cmd(cmd_str));
+ mp_input_queue_cmd(vo->input_ctx,
+ mp_input_parse_cmd(cmd_str));
}
- if (vo_mouse_autohide)
+ if (x11->vo_mouse_autohide)
{
- vo_showcursor(mydisplay, vo_window);
- mouse_waiting_hide = 1;
- mouse_timer = GetTimerMS();
+ vo_showcursor(display, x11->window);
+ x11->mouse_waiting_hide = 1;
+ x11->mouse_timer = GetTimerMS();
}
break;
case ButtonPress:
- if (vo_mouse_autohide)
+ if (x11->vo_mouse_autohide)
{
- vo_showcursor(mydisplay, vo_window);
- mouse_waiting_hide = 1;
- mouse_timer = GetTimerMS();
+ vo_showcursor(display, x11->window);
+ x11->mouse_waiting_hide = 1;
+ x11->mouse_timer = GetTimerMS();
}
-#ifdef CONFIG_GUI
- // Ignore mouse button 1-3 under GUI.
- if (use_gui && (Event.xbutton.button >= 1)
- && (Event.xbutton.button <= 3))
- break;
-#endif
- mplayer_put_key((MOUSE_BTN0 + Event.xbutton.button -
- 1) | MP_KEY_DOWN);
+ mplayer_put_key(vo->key_fifo,
+ (MOUSE_BTN0 + Event.xbutton.button - 1)
+ | MP_KEY_DOWN);
break;
case ButtonRelease:
- if (vo_mouse_autohide)
+ if (x11->vo_mouse_autohide)
{
- vo_showcursor(mydisplay, vo_window);
- mouse_waiting_hide = 1;
- mouse_timer = GetTimerMS();
+ vo_showcursor(display, x11->window);
+ x11->mouse_waiting_hide = 1;
+ x11->mouse_timer = GetTimerMS();
}
-#ifdef CONFIG_GUI
- // Ignore mouse button 1-3 under GUI.
- if (use_gui && (Event.xbutton.button >= 1)
- && (Event.xbutton.button <= 3))
- break;
-#endif
- mplayer_put_key(MOUSE_BTN0 + Event.xbutton.button - 1);
+ mplayer_put_key(vo->key_fifo,
+ MOUSE_BTN0 + Event.xbutton.button - 1);
break;
case PropertyNotify:
{
char *name =
- XGetAtomName(mydisplay, Event.xproperty.atom);
+ XGetAtomName(display, Event.xproperty.atom);
if (!name)
break;
@@ -933,14 +865,14 @@ int vo_x11_check_events(Display * mydisplay)
}
break;
case MapNotify:
- vo_hint.win_gravity = old_gravity;
- XSetWMNormalHints(mDisplay, vo_window, &vo_hint);
- vo_fs_flip = 0;
+ x11->vo_hint.win_gravity = x11->old_gravity;
+ XSetWMNormalHints(display, x11->window, &x11->vo_hint);
+ x11->fs_flip = 0;
break;
case ClientMessage:
- if (Event.xclient.message_type == XAWM_PROTOCOLS &&
- Event.xclient.data.l[0] == XAWM_DELETE_WINDOW)
- mplayer_put_key(KEY_CLOSE_WIN);
+ if (Event.xclient.message_type == x11->XAWM_PROTOCOLS &&
+ Event.xclient.data.l[0] == x11->XAWM_DELETE_WINDOW)
+ mplayer_put_key(vo->key_fifo, KEY_CLOSE_WIN);
break;
}
}
@@ -950,69 +882,76 @@ int vo_x11_check_events(Display * mydisplay)
/**
* \brief sets the size and position of the non-fullscreen window.
*/
-void vo_x11_nofs_sizepos(int x, int y, int width, int height)
+static void vo_x11_nofs_sizepos(struct vo *vo, int x, int y,
+ int width, int height)
{
- vo_x11_sizehint(x, y, width, height, 0);
+ struct vo_x11_state *x11 = vo->x11;
+ vo_x11_sizehint(vo, x, y, width, height, 0);
if (vo_fs) {
- vo_old_x = x;
- vo_old_y = y;
- vo_old_width = width;
- vo_old_height = height;
+ x11->vo_old_x = x;
+ x11->vo_old_y = y;
+ x11->vo_old_width = width;
+ x11->vo_old_height = height;
}
else
{
- vo_dwidth = width;
- vo_dheight = height;
- XMoveResizeWindow(mDisplay, vo_window, x, y, width, height);
+ vo->dwidth = width;
+ vo->dheight = height;
+ if (vo->opts->force_window_position)
+ XMoveResizeWindow(vo->x11->display, vo->x11->window, x, y, width,
+ height);
+ else
+ XResizeWindow(vo->x11->display, vo->x11->window, width, height);
}
}
-void vo_x11_sizehint(int x, int y, int width, int height, int max)
+void vo_x11_sizehint(struct vo *vo, int x, int y, int width, int height, int max)
{
- vo_hint.flags = 0;
+ struct vo_x11_state *x11 = vo->x11;
+ x11->vo_hint.flags = 0;
if (vo_keepaspect)
{
- vo_hint.flags |= PAspect;
- vo_hint.min_aspect.x = width;
- vo_hint.min_aspect.y = height;
- vo_hint.max_aspect.x = width;
- vo_hint.max_aspect.y = height;
+ 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;
}
- vo_hint.flags |= PPosition | PSize;
- vo_hint.x = x;
- vo_hint.y = y;
- vo_hint.width = width;
- vo_hint.height = height;
+ x11->vo_hint.flags |= PPosition | PSize;
+ x11->vo_hint.x = x;
+ x11->vo_hint.y = y;
+ x11->vo_hint.width = width;
+ x11->vo_hint.height = height;
if (max)
{
- vo_hint.flags |= PMaxSize;
- vo_hint.max_width = width;
- vo_hint.max_height = height;
+ x11->vo_hint.flags |= PMaxSize;
+ x11->vo_hint.max_width = width;
+ x11->vo_hint.max_height = height;
} else
{
- vo_hint.max_width = 0;
- vo_hint.max_height = 0;
+ x11->vo_hint.max_width = 0;
+ x11->vo_hint.max_height = 0;
}
// Set minimum height/width to 4 to avoid off-by-one errors
// and because mga_vid requires a minimal size of 4 pixels.
- vo_hint.flags |= PMinSize;
- vo_hint.min_width = vo_hint.min_height = 4;
+ x11->vo_hint.flags |= PMinSize;
+ x11->vo_hint.min_width = x11->vo_hint.min_height = 4;
// 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.
- vo_hint.flags |= PBaseSize;
- vo_hint.base_width = 0 /*width*/;
- vo_hint.base_height = 0 /*height*/;
+ x11->vo_hint.flags |= PBaseSize;
+ x11->vo_hint.base_width = 0 /*width*/;
+ x11->vo_hint.base_height = 0 /*height*/;
- vo_hint.flags |= PWinGravity;
- vo_hint.win_gravity = StaticGravity;
- XSetWMNormalHints(mDisplay, vo_window, &vo_hint);
+ x11->vo_hint.flags |= PWinGravity;
+ x11->vo_hint.win_gravity = StaticGravity;
+ XSetWMNormalHints(x11->display, x11->window, &x11->vo_hint);
}
-static int vo_x11_get_gnome_layer(Display * mDisplay, Window win)
+static int vo_x11_get_gnome_layer(struct vo_x11_state *x11, Window win)
{
Atom type;
int format;
@@ -1020,7 +959,7 @@ static int vo_x11_get_gnome_layer(Display * mDisplay, Window win)
unsigned long bytesafter;
unsigned short *args = NULL;
- if (XGetWindowProperty(mDisplay, win, XA_WIN_LAYER, 0, 16384,
+ if (XGetWindowProperty(x11->display, win, x11->XA_WIN_LAYER, 0, 16384,
False, AnyPropertyType, &type, &format, &nitems,
&bytesafter,
(unsigned char **) &args) == Success
@@ -1034,7 +973,7 @@ static int vo_x11_get_gnome_layer(Display * mDisplay, Window win)
}
//
-Window vo_x11_create_smooth_window(Display * mDisplay, Window mRoot,
+static Window vo_x11_create_smooth_window(struct vo_x11_state *x11, Window mRoot,
Visual * vis, int x, int y,
unsigned int width, unsigned int he