summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUoti Urpala <uau@symbol.nonexistent.invalid>2008-04-20 09:34:27 +0300
committerUoti Urpala <uau@symbol.nonexistent.invalid>2008-04-23 13:46:34 +0300
commit26039a38e3d5a2305e0ec93481df07c2717aa06d (patch)
treee34ac09d222f260ddadbb00f088dc8029d6a7988
parentacf319b3edea4d8dd0fe338778e08e0d99dc49bb (diff)
downloadmpv-26039a38e3d5a2305e0ec93481df07c2717aa06d.tar.bz2
mpv-26039a38e3d5a2305e0ec93481df07c2717aa06d.tar.xz
Move global mDisplay to x11 state struct
-rw-r--r--libvo/gl_common.c1
-rw-r--r--libvo/vo_xv.c104
-rw-r--r--libvo/x11_common.c262
-rw-r--r--libvo/x11_common.h52
-rw-r--r--mplayer.c6
5 files changed, 228 insertions, 197 deletions
diff --git a/libvo/gl_common.c b/libvo/gl_common.c
index ea4847b345..68576504a4 100644
--- a/libvo/gl_common.c
+++ b/libvo/gl_common.c
@@ -13,6 +13,7 @@
#include <string.h>
#include <ctype.h>
#include <math.h>
+#include "old_vo_defines.h"
#include "gl_common.h"
/**
diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c
index eebfb66f89..b324912658 100644
--- a/libvo/vo_xv.c
+++ b/libvo/vo_xv.c
@@ -176,6 +176,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
char *title, uint32_t format)
{
struct MPOpts *opts = vo->opts;
+ struct vo_x11_state *x11 = vo->x11;
XSizeHints hint;
XVisualInfo vinfo;
XGCValues xgcv;
@@ -242,7 +243,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
vm_width = d_width;
vm_height = d_height;
}
- vo_vm_switch(vm_width, vm_height, &modeline_width,
+ vo_vm_switch(vo, vm_width, vm_height, &modeline_width,
&modeline_height);
ctx->mode_switched = 1;
hint.x = (vo_screenwidth - modeline_width) / 2;
@@ -256,12 +257,12 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
hint.flags = PPosition | PSize /* | PBaseSize */ ;
hint.base_width = hint.width;
hint.base_height = hint.height;
- XGetWindowAttributes(mDisplay, DefaultRootWindow(mDisplay),
+ XGetWindowAttributes(x11->display, DefaultRootWindow(x11->display),
&attribs);
depth = attribs.depth;
if (depth != 15 && depth != 16 && depth != 24 && depth != 32)
depth = 24;
- XMatchVisualInfo(mDisplay, mScreen, depth, TrueColor, &vinfo);
+ XMatchVisualInfo(x11->display, mScreen, depth, TrueColor, &vinfo);
xswa.background_pixel = 0;
if (xv_ck_info.method == CK_METHOD_BACKGROUND)
@@ -276,10 +277,10 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
vo_window = WinID ? ((Window) WinID) : mRootWin;
if (WinID)
{
- XUnmapWindow(mDisplay, vo_window);
- XChangeWindowAttributes(mDisplay, vo_window, xswamask,
+ XUnmapWindow(x11->display, vo_window);
+ XChangeWindowAttributes(x11->display, vo_window, xswamask,
&xswa);
- vo_x11_selectinput_witherr(mDisplay, vo_window,
+ vo_x11_selectinput_witherr(x11->display, vo_window,
StructureNotifyMask |
KeyPressMask |
PropertyChangeMask |
@@ -287,10 +288,10 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
ButtonPressMask |
ButtonReleaseMask |
ExposureMask);
- XMapWindow(mDisplay, vo_window);
+ XMapWindow(x11->display, vo_window);
Window mRoot;
uint32_t drwBorderWidth, drwDepth;
- XGetGeometry(mDisplay, vo_window, &mRoot,
+ XGetGeometry(x11->display, vo_window, &mRoot,
&ctx->drwX, &ctx->drwY, &vo_dwidth, &vo_dheight,
&drwBorderWidth, &drwDepth);
if (vo_dwidth <= 0) vo_dwidth = d_width;
@@ -301,22 +302,22 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
{
vo_x11_create_vo_window(vo, &vinfo, vo_dx, vo_dy, d_width, d_height,
flags, CopyFromParent, "xv", title);
- XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa);
+ XChangeWindowAttributes(x11->display, vo_window, xswamask, &xswa);
}
if (vo_gc != None)
- XFreeGC(mDisplay, vo_gc);
- vo_gc = XCreateGC(mDisplay, vo_window, 0L, &xgcv);
- XSync(mDisplay, False);
+ XFreeGC(x11->display, vo_gc);
+ vo_gc = XCreateGC(x11->display, vo_window, 0L, &xgcv);
+ XSync(x11->display, False);
#ifdef HAVE_XF86VM
if (vm)
{
/* Grab the mouse pointer in our window */
if (vo_grabpointer)
- XGrabPointer(mDisplay, vo_window, True, 0,
+ XGrabPointer(x11->display, vo_window, True, 0,
GrabModeAsync, GrabModeAsync,
vo_window, None, CurrentTime);
- XSetInputFocus(mDisplay, vo_window, RevertToNone, CurrentTime);
+ XSetInputFocus(x11->display, vo_window, RevertToNone, CurrentTime);
}
#endif
}
@@ -365,7 +366,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
panscan_calc();
- vo_xv_draw_colorkey(ctx->drwX - (vo_panscan_x >> 1),
+ vo_xv_draw_colorkey(vo, ctx->drwX - (vo_panscan_x >> 1),
ctx->drwY - (vo_panscan_y >> 1),
vo_dwidth + vo_panscan_x - 1,
vo_dheight + vo_panscan_y - 1);
@@ -374,7 +375,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
ctx->drwY, vo_dwidth, vo_dheight);
if (opts->vo_ontop)
- vo_x11_setlayer(mDisplay, vo_window, opts->vo_ontop);
+ vo_x11_setlayer(x11->display, vo_window, opts->vo_ontop);
return 0;
}
@@ -382,12 +383,13 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
static void allocate_xvimage(struct vo *vo, int foo)
{
struct xvctx *ctx = vo->priv;
+ struct vo_x11_state *x11 = vo->x11;
/*
* allocate XvImages. FIXME: no error checking, without
* mit-shm this will bomb... trzing to fix ::atmos
*/
#ifdef HAVE_SHM
- if (mLocalDisplay && XShmQueryExtension(mDisplay))
+ if (mLocalDisplay && XShmQueryExtension(x11->display))
ctx->Shmem_Flag = 1;
else
{
@@ -398,7 +400,7 @@ static void allocate_xvimage(struct vo *vo, int foo)
if (ctx->Shmem_Flag)
{
ctx->xvimage[foo] =
- (XvImage *) XvShmCreateImage(mDisplay, xv_port, ctx->xv_format,
+ (XvImage *) XvShmCreateImage(x11->display, xv_port, ctx->xv_format,
NULL, ctx->image_width, ctx->image_height,
&ctx->Shminfo[foo]);
@@ -408,17 +410,17 @@ static void allocate_xvimage(struct vo *vo, int foo)
ctx->Shminfo[foo].readOnly = False;
ctx->xvimage[foo]->data = ctx->Shminfo[foo].shmaddr;
- XShmAttach(mDisplay, &ctx->Shminfo[foo]);
- XSync(mDisplay, False);
+ XShmAttach(x11->display, &ctx->Shminfo[foo]);
+ XSync(x11->display, False);
shmctl(ctx->Shminfo[foo].shmid, IPC_RMID, 0);
} else
#endif
{
ctx->xvimage[foo] =
- (XvImage *) XvCreateImage(mDisplay, xv_port, ctx->xv_format, NULL,
+ (XvImage *) XvCreateImage(x11->display, xv_port, ctx->xv_format, NULL,
ctx->image_width, ctx->image_height);
ctx->xvimage[foo]->data = malloc(ctx->xvimage[foo]->data_size);
- XSync(mDisplay, False);
+ XSync(x11->display, False);
}
memset(ctx->xvimage[foo]->data, 128, ctx->xvimage[foo]->data_size);
return;
@@ -430,7 +432,7 @@ static void deallocate_xvimage(struct vo *vo, int foo)
#ifdef HAVE_SHM
if (ctx->Shmem_Flag)
{
- XShmDetach(mDisplay, &ctx->Shminfo[foo]);
+ XShmDetach(vo->x11->display, &ctx->Shminfo[foo]);
shmdt(ctx->Shminfo[foo].shmaddr);
} else
#endif
@@ -439,17 +441,18 @@ static void deallocate_xvimage(struct vo *vo, int foo)
}
XFree(ctx->xvimage[foo]);
- XSync(mDisplay, False);
+ XSync(vo->x11->display, False);
return;
}
static inline void put_xvimage(struct vo *vo, XvImage *xvi)
{
struct xvctx *ctx = vo->priv;
+ struct vo_x11_state *x11 = vo->x11;
#ifdef HAVE_SHM
if (ctx->Shmem_Flag)
{
- XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc,
+ XvShmPutImage(x11->display, xv_port, vo_window, vo_gc,
xvi, 0, 0, ctx->image_width,
ctx->image_height, ctx->drwX - (vo_panscan_x >> 1),
ctx->drwY - (vo_panscan_y >> 1), vo_dwidth + vo_panscan_x,
@@ -458,7 +461,7 @@ static inline void put_xvimage(struct vo *vo, XvImage *xvi)
} else
#endif
{
- XvPutImage(mDisplay, xv_port, vo_window, vo_gc,
+ XvPutImage(x11->display, xv_port, vo_window, vo_gc,
xvi, 0, 0, ctx->image_width, ctx->image_height,
ctx->drwX - (vo_panscan_x >> 1), ctx->drwY - (vo_panscan_y >> 1),
vo_dwidth + vo_panscan_x,
@@ -469,13 +472,14 @@ static inline void put_xvimage(struct vo *vo, XvImage *xvi)
static void check_events(struct vo *vo)
{
struct xvctx *ctx = vo->priv;
- int e = vo_x11_check_events(mDisplay);
+ struct vo_x11_state *x11 = vo->x11;
+ int e = vo_x11_check_events(vo);
if (e & VO_EVENT_RESIZE)
{
Window mRoot;
uint32_t drwBorderWidth, drwDepth;
- XGetGeometry(mDisplay, vo_window, &mRoot, &ctx->drwX, &ctx->drwY,
+ XGetGeometry(x11->display, vo_window, &mRoot, &ctx->drwX, &ctx->drwY,
&vo_dwidth, &vo_dheight, &drwBorderWidth, &drwDepth);
mp_msg(MSGT_VO, MSGL_V, "[xv] dx: %d dy: %d dw: %d dh: %d\n", ctx->drwX,
ctx->drwY, vo_dwidth, vo_dheight);
@@ -485,7 +489,7 @@ static void check_events(struct vo *vo)
if (e & VO_EVENT_EXPOSE || e & VO_EVENT_RESIZE)
{
- vo_xv_draw_colorkey(ctx->drwX - (vo_panscan_x >> 1),
+ vo_xv_draw_colorkey(vo, ctx->drwX - (vo_panscan_x >> 1),
ctx->drwY - (vo_panscan_y >> 1),
vo_dwidth + vo_panscan_x - 1,
vo_dheight + vo_panscan_y - 1);
@@ -523,9 +527,9 @@ static void flip_page(struct vo *vo)
{
ctx->current_buf =
vo_directrendering ? 0 : ((ctx->current_buf + 1) % ctx->num_buffers);
- XFlush(mDisplay);
+ XFlush(vo->x11->display);
} else
- XSync(mDisplay, False);
+ XSync(vo->x11->display, False);
return;
}
@@ -702,12 +706,12 @@ static void uninit(struct vo *vo)
deallocate_xvimage(vo, i);
#ifdef HAVE_XF86VM
if (ctx->mode_switched)
- vo_vm_close(mDisplay);
+ vo_vm_close(vo->x11->display);
#endif
if (ctx->event_fd_registered)
- mp_input_rm_event_fd(ConnectionNumber(mDisplay));
+ mp_input_rm_event_fd(ConnectionNumber(vo->x11->display));
// uninit() shouldn't get called unless initialization went past vo_init()
- vo_x11_uninit();
+ vo_x11_uninit(vo);
}
static void x11_fd_callback(void *ctx)
@@ -724,6 +728,7 @@ static int preinit(struct vo *vo, const char *arg)
strarg_t ck_method_arg = { 0, NULL };
struct xvctx *ctx = talloc_zero(vo, struct xvctx);
vo->priv = ctx;
+ struct vo_x11_state *x11 = vo->x11;
opt_t subopts[] =
{
@@ -745,12 +750,12 @@ static int preinit(struct vo *vo, const char *arg)
/* modify colorkey settings according to the given options */
xv_setup_colorkeyhandling( ck_method_arg.str, ck_src_arg.str );
- if (!vo_init())
+ if (!vo_init(vo))
return -1;
/* check for Xvideo extension */
unsigned int ver, rel, req, ev, err;
- if (Success != XvQueryExtension(mDisplay, &ver, &rel, &req, &ev, &err))
+ if (Success != XvQueryExtension(x11->display, &ver, &rel, &req, &ev, &err))
{
mp_msg(MSGT_VO, MSGL_ERR,
MSGTR_LIBVO_XV_XvNotSupportedByX11);
@@ -759,7 +764,7 @@ static int preinit(struct vo *vo, const char *arg)
/* check for Xvideo support */
if (Success !=
- XvQueryAdaptors(mDisplay, DefaultRootWindow(mDisplay), &ctx->adaptors,
+ XvQueryAdaptors(x11->display, DefaultRootWindow(x11->display), &ctx->adaptors,
&ctx->ai))
{
mp_msg(MSGT_VO, MSGL_ERR, MSGTR_LIBVO_XV_XvQueryAdaptorsFailed);
@@ -788,7 +793,7 @@ static int preinit(struct vo *vo, const char *arg)
}
if (port_found)
{
- if (XvGrabPort(mDisplay, xv_port, CurrentTime))
+ if (XvGrabPort(x11->display, xv_port, CurrentTime))
xv_port = 0;
} else
{
@@ -804,7 +809,7 @@ static int preinit(struct vo *vo, const char *arg)
{
for (xv_p = ctx->ai[i].base_id;
xv_p < ctx->ai[i].base_id + ctx->ai[i].num_ports; ++xv_p)
- if (!XvGrabPort(mDisplay, xv_p, CurrentTime))
+ if (!XvGrabPort(x11->display, xv_p, CurrentTime))
{
xv_port = xv_p;
break;
@@ -827,16 +832,15 @@ static int preinit(struct vo *vo, const char *arg)
goto error;
}
- if ( !vo_xv_init_colorkey() )
- {
+ if (!vo_xv_init_colorkey(vo)) {
goto error; // bail out, colorkey setup failed
}
- vo_xv_enable_vsync();
- vo_xv_get_max_img_dim(&ctx->max_width, &ctx->max_height);
+ vo_xv_enable_vsync(vo);
+ vo_xv_get_max_img_dim(vo, &ctx->max_width, &ctx->max_height);
- ctx->fo = XvListImageFormats(mDisplay, xv_port, (int *) &ctx->formats);
+ ctx->fo = XvListImageFormats(x11->display, xv_port, (int *) &ctx->formats);
- mp_input_add_event_fd(ConnectionNumber(mDisplay), x11_fd_callback, vo);
+ mp_input_add_event_fd(ConnectionNumber(x11->display), x11_fd_callback, vo);
ctx->event_fd_registered = 1;
return 0;
@@ -879,11 +883,11 @@ static int control(struct vo *vo, uint32_t request, void *data)
if (old_y != vo_panscan_y)
{
- vo_x11_clearwindow_part(mDisplay, vo_window,
+ vo_x11_clearwindow_part(vo->x11->display, vo_window,
vo_dwidth + vo_panscan_x - 1,
vo_dheight + vo_panscan_y - 1,
1);
- vo_xv_draw_colorkey(ctx->drwX - (vo_panscan_x >> 1),
+ vo_xv_draw_colorkey(vo, ctx->drwX - (vo_panscan_x >> 1),
ctx->drwY - (vo_panscan_y >> 1),
vo_dwidth + vo_panscan_x - 1,
vo_dheight + vo_panscan_y - 1);
@@ -894,18 +898,18 @@ static int control(struct vo *vo, uint32_t request, void *data)
case VOCTRL_SET_EQUALIZER:
{
struct voctrl_set_equalizer_args *args = data;
- return vo_xv_set_eq(xv_port, args->name, args->value);
+ return vo_xv_set_eq(vo, xv_port, args->name, args->value);
}
case VOCTRL_GET_EQUALIZER:
{
struct voctrl_get_equalizer_args *args = data;
- return vo_xv_get_eq(xv_port, args->name, args->valueptr);
+ return vo_xv_get_eq(vo, xv_port, args->name, args->valueptr);
}
case VOCTRL_ONTOP:
vo_x11_ontop(vo);
return VO_TRUE;
case VOCTRL_UPDATE_SCREENINFO:
- update_xinerama_info();
+ update_xinerama_info(vo);
return VO_TRUE;
}
return VO_NOTIMPL;
diff --git a/libvo/x11_common.c b/libvo/x11_common.c
index e5dbee5734..8d30c7601d 100644
--- a/libvo/x11_common.c
+++ b/libvo/x11_common.c
@@ -77,7 +77,6 @@ int stop_xscreensaver = 0;
static int dpms_disabled = 0;
char *mDisplayName = NULL;
-Display *mDisplay = NULL;
Window mRootWin;
int mScreen;
int mLocalDisplay;
@@ -106,8 +105,6 @@ static Atom XA_BLACKBOX_PID;
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;
@@ -134,7 +131,7 @@ void vo_x11_init_state(struct vo_x11_state *s)
* _NET_WM_STATE_ADD -- add state
* _NET_WM_STATE_TOGGLE -- toggle
*/
-void vo_x11_ewmh_fullscreen(int action)
+void vo_x11_ewmh_fullscreen(Display *mDisplay, int action)
{
assert(action == _NET_WM_STATE_REMOVE ||
action == _NET_WM_STATE_ADD || action == _NET_WM_STATE_TOGGLE);
@@ -281,19 +278,20 @@ 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, mRootWin, 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)
{
int i;
int wm = 0;
@@ -304,7 +302,7 @@ static int vo_wm_detect(void)
return 0;
// -- supports layers
- if (x11_get_property(XA_WIN_PROTOCOLS, &args, &nitems))
+ if (x11_get_property(vo->x11, XA_WIN_PROTOCOLS, &args, &nitems))
{
mp_msg(MSGT_VO, MSGL_V, "[x11] Detected wm supports layers.\n");
for (i = 0; i < nitems; i++)
@@ -329,7 +327,7 @@ static int vo_wm_detect(void)
}
}
// --- netwm
- if (x11_get_property(XA_NET_SUPPORTED, &args, &nitems))
+ if (x11_get_property(vo->x11, XA_NET_SUPPORTED, &args, &nitems))
{
mp_msg(MSGT_VO, MSGL_V, "[x11] Detected wm supports NetWM.\n");
for (i = 0; i < nitems; i++)
@@ -340,7 +338,7 @@ static int vo_wm_detect(void)
// (in their implementation it only changes internal window state, nothing more!!!)
if (wm & vo_wm_FULLSCREEN)
{
- if (x11_get_property(XA_BLACKBOX_PID, &args, &nitems))
+ if (x11_get_property(vo->x11, XA_BLACKBOX_PID, &args, &nitems))
{
mp_msg(MSGT_VO, MSGL_V,
"[x11] Detected wm is a broken OpenBox.\n");
@@ -356,7 +354,8 @@ static int vo_wm_detect(void)
return wm;
}
-static void init_atoms(void)
+#define XA_INIT(x) XA##x = XInternAtom(d, #x, False)
+static void init_atoms(Display *d)
{
XA_INIT(_NET_SUPPORTED);
XA_INIT(_NET_WM_STATE);
@@ -373,16 +372,16 @@ static void init_atoms(void)
XA_INIT(WM_DELETE_WINDOW);
}
-void update_xinerama_info(void) {
+void update_xinerama_info(struct vo *vo) {
int screen = xinerama_screen;
xinerama_x = xinerama_y = 0;
#ifdef HAVE_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) {
@@ -410,8 +409,9 @@ void update_xinerama_info(void) {
aspect_save_screenres(vo_screenwidth, vo_screenheight);
}
-int vo_init(void)
+int vo_init(struct vo *vo)
{
+ struct vo_x11_state *x11 = vo->x11;
// int mScreen;
int depth, bpp;
unsigned int mask;
@@ -429,7 +429,7 @@ int vo_init(void)
if (vo_depthonscreen)
{
- saver_off(mDisplay);
+ saver_off(x11->display);
return 1; // already called
}
@@ -445,23 +445,23 @@ 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
+ mScreen = DefaultScreen(x11->display); // screen ID
+ mRootWin = RootWindow(x11->display, mScreen); // root window ID
- init_atoms();
+ init_atoms(vo->x11->display);
#ifdef HAVE_XF86VM
{
int clock;
- XF86VidModeGetModeLine(mDisplay, mScreen, &clock, &modeline);
+ XF86VidModeGetModeLine(x11->display, mScreen, &clock, &modeline);
if (!vo_screenwidth)
vo_screenwidth = modeline.hdisplay;
if (!vo_screenheight)
@@ -470,25 +470,25 @@ int vo_init(void)
#endif
{
if (!vo_screenwidth)
- vo_screenwidth = DisplayWidth(mDisplay, mScreen);
+ vo_screenwidth = DisplayWidth(x11->display, mScreen);
if (!vo_screenheight)
- vo_screenheight = DisplayHeight(mDisplay, mScreen);
+ vo_screenheight = DisplayHeight(x11->display, mScreen);
}
// get color depth (from root window, or the best visual):
- XGetWindowAttributes(mDisplay, mRootWin, &attribs);
+ XGetWindowAttributes(x11->display, mRootWin, &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, mScreen, &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, mRootWin, 0, 0, 1, 1, AllPlanes, ZPixmap);
vo_depthonscreen = depth; // display depth on screen
@@ -538,19 +538,19 @@ int vo_init(void)
vo_screenwidth, vo_screenheight, depth, vo_depthonscreen,
dispName, mLocalDisplay ? "local" : "remote");
- vo_wm_type = vo_wm_detect();
+ vo_wm_type = vo_wm_detect(vo);
vo_fs_type = vo_x11_get_fs_type(vo_wm_type);
fstype_dump(vo_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");
@@ -559,9 +559,9 @@ void vo_uninit(void)
// if( !vo_depthonscreen ) return;
mp_msg(MSGT_VO, MSGL_V, "vo: uninit ...\n");
XSetErrorHandler(NULL);
- XCloseDisplay(mDisplay);
+ XCloseDisplay(x11->display);
vo_depthonscreen = 0;
- mDisplay = NULL;
+ x11->display = NULL;
}
#include "osdep/keycodes.h"
@@ -971,15 +971,15 @@ void vo_setwindow(Window w, GC g)
}
#endif
-void vo_x11_uninit(void)
+void vo_x11_uninit(struct vo *vo)
{
- saver_on(mDisplay);
+ saver_on(vo->x11->display);
if (vo_window != None)
- vo_showcursor(mDisplay, vo_window);
+ vo_showcursor(vo->x11->display, vo_window);
if (f_gc)
{
- XFreeGC(mDisplay, f_gc);
+ XFreeGC(vo->x11->display, f_gc);
f_gc = NULL;
}
#ifdef HAVE_NEW_GUI
@@ -989,22 +989,22 @@ void vo_x11_uninit(void)
{
if (vo_gc)
{
- XSetBackground(mDisplay, vo_gc, 0);
- XFreeGC(mDisplay, vo_gc);
+ XSetBackground(vo->x11->display, vo_gc, 0);
+ XFreeGC(vo->x11->display, vo_gc);
vo_gc = NULL;
}
if (vo_window != None)
{
- XClearWindow(mDisplay, vo_window);
+ XClearWindow(vo->x11->display, vo_window);
if (WinID < 0)
{
XEvent xev;
- XUnmapWindow(mDisplay, vo_window);
- XDestroyWindow(mDisplay, vo_window);
+ XUnmapWindow(vo->x11->display, vo_window);
+ XDestroyWindow(vo->x11->display, vo_window);
do
{
- XNextEvent(mDisplay, &xev);
+ XNextEvent(vo->x11->display, &xev);
}
while (xev.type != DestroyNotify
|| xev.xdestroywindow.event != vo_window);
@@ -1019,8 +1019,9 @@ void vo_x11_uninit(void)
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)
{
+ Display *display = vo->x11->display;
int ret = 0;
XEvent Event;
char buf[100];
@@ -1031,13 +1032,13 @@ int vo_x11_check_events(Display * mydisplay)
if ((vo_mouse_autohide) && mouse_waiting_hide &&
(GetTimerMS() - mouse_timer >= 1000)) {
- vo_hidecursor(mydisplay, vo_window);
+ vo_hidecursor(display, vo_window);
mouse_waiting_hide = 0;
}
- while (XPending(mydisplay))
+ while (XPending(display))
{
- XNextEvent(mydisplay, &Event);
+ XNextEvent(display, &Event);
#ifdef HAVE_NEW_GUI
if (use_gui)
{
@@ -1069,10 +1070,10 @@ int vo_x11_check_events(Display * mydisplay)
int foo;
Window win;
- XGetGeometry(mydisplay, vo_window, &root, &foo, &foo,
+ XGetGeometry(display, vo_window, &root, &foo, &foo,
&foo /*width */ , &foo /*height */ , &foo,
&foo);
- XTranslateCoordinates(mydisplay, vo_window, root, 0, 0,
+ XTranslateCoordinates(display, vo_window, root, 0, 0,
&vo_dx, &vo_dy, &win);
}
#endif
@@ -1108,7 +1109,7 @@ int vo_x11_check_events(Display * mydisplay)
if (vo_mouse_autohide)
{
- vo_showcursor(mydisplay, vo_window);
+ vo_showcursor(display, vo_window);
mouse_waiting_hide = 1;
mouse_timer = GetTimerMS();
}
@@ -1116,7 +1117,7 @@ int vo_x11_check_events(Display * mydisplay)
case ButtonPress:
if (vo_mouse_autohide)
{
- vo_showcursor(mydisplay, vo_window);
+ vo_showcursor(display, vo_window);
mouse_waiting_hide = 1;
mouse_timer = GetTimerMS();
}
@@ -1132,7 +1133,7 @@ int vo_x11_check_events(Display * mydisplay)
case ButtonRelease:
if (vo_mouse_autohide)
{
- vo_showcursor(mydisplay, vo_window);
+ vo_showcursor(display, vo_window);
mouse_waiting_hide = 1;
mouse_timer = GetTimerMS();
}
@@ -1147,7 +1148,7 @@ int vo_x11_check_events(Display * mydisplay)
case PropertyNotify:
{
char *name =
- XGetAtomName(mydisplay, Event.xproperty.atom);
+ XGetAtomName(display, Event.xproperty.atom);
if (!name)
break;
@@ -1159,7 +1160,7 @@ int vo_x11_check_events(Display * mydisplay)
break;
case MapNotify:
vo_hint.win_gravity = old_gravity;
- XSetWMNormalHints(mDisplay, vo_window, &vo_hint);
+ XSetWMNormalHints(display, vo_window, &vo_hint);
vo_fs_flip = 0;
break;
case ClientMessage:
@@ -1175,9 +1176,10 @@ int vo_x11_check_events(Display * mydisplay)
/**
* \brief sets the size and position of the non-fullscreen window.
*/
-static 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);
+ vo_x11_sizehint(vo, x, y, width, height, 0);
if (vo_fs) {
vo_old_x = x;
vo_old_y = y;
@@ -1188,11 +1190,11 @@ static void vo_x11_nofs_sizepos(int x, int y, int width, int height)
{
vo_dwidth = width;
vo_dheight = height;
- XMoveResizeWindow(mDisplay, vo_window, x, y, width, height);
+ XMoveResizeWindow(vo->x11->display, vo_window, x, y, 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;
if (vo_keepaspect)
@@ -1227,7 +1229,7 @@ void vo_x11_sizehint(int x, int y, int width, int height, int max)
vo_hint.flags |= PWinGravity;
vo_hint.win_gravity = StaticGravity;
- XSetWMNormalHints(mDisplay, vo_window, &vo_hint);
+ XSetWMNormalHints(vo->x11->display, vo_window, &vo_hint);
}
static int vo_x11_get_gnome_layer(Display * mDisplay, Window win)
@@ -1304,6 +1306,7 @@ void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y,
const char *classname, const char *title)
{
struct MPOpts *opts = vo->opts;
+ Display *mDisplay = vo->x11->display;
if (vo_window == None) {
XSizeHints hint;
XEvent xev;
@@ -1320,7 +1323,7 @@ void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y,
hint.width = width; hint.height = height;
hint.flags = PPosition | PSize;
XSetStandardProperties(mDisplay, vo_window, title, title, None, NULL, 0, &hint);
- vo_x11_sizehint(x, y, width, height, 0);
+ vo_x11_sizehint(vo, x, y, width, height, 0);
// map window
XMapWindow(mDisplay, vo_window);
XClearWindow(mDisplay, vo_window);
@@ -1335,7 +1338,7 @@ void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y,
ButtonPressMask | ButtonReleaseMask | ExposureMask);
}
if (opts->vo_ontop) vo_x11_setlayer(mDisplay, vo_window, opts->vo_ontop);
- vo_x11_nofs_sizepos(vo_dx, vo_dy, width, height);
+ vo_x11_nofs_sizepos(vo, vo_dx, vo_dy, width, height);
if (!!vo_fs != !!(flags & VOFLAG_FULLSCREEN))
vo_x11_fullscreen(vo);
}
@@ -1516,6 +1519,7 @@ static int vo_x11_get_fs_type(int supported)
void vo_x11_fullscreen(struct vo *vo)
{
struct MPOpts *opts = vo->opts;
+ struct vo_x11_state *x11 = vo->x11;
int x, y, w, h;
if (WinID >= 0 || vo_fs_flip)
@@ -1532,12 +1536,12 @@ void vo_x11_fullscreen(struct vo *vo)
h = vo_old_height;
}
- vo_x11_ewmh_fullscreen(_NET_WM_STATE_REMOVE); // removes fullscreen state if wm supports EWMH
+ vo_x11_ewmh_fullscreen(x11->display, _NET_WM_STATE_REMOVE); // removes fullscreen state if wm supports EWMH
vo_fs = VO_FALSE;
} else
{
// win->fs
- vo_x11_ewmh_fullscreen(_NET_WM_STATE_ADD); // sends fullscreen state to be added if wm supports EWMH
+ vo_x11_ewmh_fullscreen(x11->display, _NET_WM_STATE_ADD); // sends fullscreen state to be added if wm supports EWMH
vo_fs = VO_TRUE;
if ( ! (vo_fs_type & vo_wm_FULLSCREEN) ) // not needed with EWMH fs
@@ -1547,7 +1551,7 @@ void vo_x11_fullscreen(struct vo *vo)
vo_old_width = vo_dwidth;
vo_old_height = vo_dheight;
}
- update_xinerama_info();
+ update_xinerama_info(vo);
x = xinerama_x;
y = xinerama_y;
w = vo_screenwidth;
@@ -1556,7 +1560,7 @@ void vo_x11_fullscreen(struct vo *vo)
{
long dummy;
- XGetWMNormalHints(mDisplay, vo_window, &vo_hint, &dummy);
+ XGetWMNormalHints(x11->display, vo_window, &vo_hint, &dummy);
if (!(vo_hint.flags & PWinGravity))
old_gravity = NorthWestGravity;
else
@@ -1564,29 +1568,29 @@ void vo_x11_fullscreen(struct vo *vo)
}
if (vo_wm_type == 0 && !(vo_fsmode & 16))
{
- XUnmapWindow(mDisplay, vo_window); // required for MWM
- XWithdrawWindow(mDisplay, vo_window, mScreen);
+ XUnmapWindow(x11->display, vo_window); // required for MWM
+ XWithdrawWindow(x11->display, vo_window, mScreen);
vo_fs_flip = 1;
}
if ( ! (vo_fs_type & vo_wm_FULLSCREEN) ) // not needed with EWMH fs
{
- vo_x11_decoration(mDisplay, vo_window, (vo_fs) ? 0 : 1);
- vo_x11_sizehint(x, y, w, h, 0);
- vo_x11_setlayer(mDisplay, vo_window, vo_fs);
+ vo_x11_decoration(x11->display, vo_window, (vo_fs) ? 0 : 1);
+ vo_x11_sizehint(vo, x, y, w, h, 0);
+ vo_x11_setlayer(x11->display, vo_window, vo_fs);
- XMoveResizeWindow(mDisplay, vo_window, x, y, w, h);
+ XMoveResizeWindow(x11->display, vo_window, x, y, w, h);
}
/* some WMs lose ontop after fullscreen */
if ((!(vo_fs)) & opts->vo_ontop)
- vo_x11_setlayer(mDisplay, vo_window, opts->vo_ontop);
+ vo_x11_setlayer(x11->display, vo_window, opts->vo_ontop);
- XMapRaised(mDisplay, vo_window);
+ XMapRaised(x11->display, vo_window);
if ( ! (vo_fs_type & vo_wm_FULLSCREEN) ) // some WMs change window pos on map
- XMoveResizeWindow(mDisplay, vo_window, x, y, w, h);
- XRaiseWindow(mDisplay, vo_window);
- XFlush(mDisplay);
+ XMoveResizeWindow(x11->display, vo_window, x, y, w, h);
+ XRaiseWindow(x11->display, vo_window);
+ XFlush(x11->display);
}
void vo_x11_ontop(struct vo *vo)
@@ -1594,7 +1598,7 @@ void vo_x11_ontop(struct vo *vo)
struct MPOpts *opts = vo->opts;
opts->vo_ontop = !opts->vo_ontop;
- vo_x11_setlayer(mDisplay, vo_window, opts->vo_ontop);
+ vo_x11_setlayer(vo->x11->display, vo_window, opts->vo_ontop);
}
/*
@@ -1604,19 +1608,19 @@ void vo_x11_ontop(struct vo *vo)
static int screensaver_off;
static unsigned int time_last;
-void xscreensaver_heartbeat(void)
+void xscreensaver_heartbeat(struct vo_x11_state *x11)
{
unsigned int time = GetTimerMS();
- if (mDisplay && screensaver_off && (time - time_last) > 30000)
+ if (x11->display && screensaver_off && (time - time_last) > 30000)
{
time_last = time;
- XResetScreenSaver(mDisplay);
+ XResetScreenSaver(x11->display);
}