1
mirror of https://github.com/mpv-player/mpv synced 2024-12-28 06:03:45 +01:00

Move global mDisplay to x11 state struct

This commit is contained in:
Uoti Urpala 2008-04-20 09:34:27 +03:00
parent acf319b3ed
commit 26039a38e3
5 changed files with 228 additions and 197 deletions

View File

@ -13,6 +13,7 @@
#include <string.h>
#include <ctype.h>
#include <math.h>
#include "old_vo_defines.h"
#include "gl_common.h"
/**

View File

@ -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;

View File

@ -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);
}
}
static int xss_suspend(Bool suspend)
static int xss_suspend(Display *mDisplay, Bool suspend)
{
#ifndef HAVE_XSS
return 0;
@ -1642,7 +1646,7 @@ static void saver_on(Display * mDisplay)
if (!screensaver_off)
return;
screensaver_off = 0;
if (xss_suspend(False))
if (xss_suspend(mDisplay, False))
return;
#ifdef HAVE_XDPMS
if (dpms_disabled)
@ -1683,7 +1687,7 @@ static void saver_off(Display * mDisplay)
if (screensaver_off)
return;
screensaver_off = 1;
if (xss_suspend(True))
if (xss_suspend(mDisplay, True))
return;
#ifdef HAVE_XDPMS
if (DPMSQueryExtension(mDisplay, &nothing, &nothing))
@ -1758,9 +1762,10 @@ void vo_x11_selectinput_witherr(Display * display, Window w,
}
#ifdef HAVE_XF86VM
void vo_vm_switch(uint32_t X, uint32_t Y, int *modeline_width,
void vo_vm_switch(struct vo *vo, uint32_t X, uint32_t Y, int *modeline_width,
int *modeline_height)
{
Display *mDisplay = vo->x11->display;
int vm_event, vm_error;
int vm_ver, vm_rev;
int i, j, have_vm = 0;
@ -1823,7 +1828,7 @@ void vo_vm_close(Display * dpy)
free(vidmodes);
vidmodes = NULL;
XF86VidModeGetAllModeLines(mDisplay, mScreen, &modecount,
XF86VidModeGetAllModeLines(dpy, mScreen, &modecount,
&vidmodes);
for (i = 0; i < modecount; i++)
if ((vidmodes[i]->hdisplay == vo_screenwidth)
@ -1904,12 +1909,13 @@ static XColor cols[256];
static int cm_size, red_mask, green_mask, blue_mask;
Colormap vo_x11_create_colormap(XVisualInfo * vinfo)
Colormap vo_x11_create_colormap(struct vo *vo, XVisualInfo *vinfo)
{
struct vo_x11_state *x11 = vo->x11;
unsigned k, r, g, b, ru, gu, bu, m, rv, gv, bv, rvu, gvu, bvu;
if (vinfo->class != DirectColor)
return XCreateColormap(mDisplay, mRootWin, vinfo->visual,
return XCreateColormap(x11->display, mRootWin, vinfo->visual,
AllocNone);
/* can this function get called twice or more? */
@ -1953,8 +1959,8 @@ Colormap vo_x11_create_colormap(XVisualInfo * vinfo)
gv += gvu;
bv += bvu;
}
cmap = XCreateColormap(mDisplay, mRootWin, vinfo->visual, AllocAll);
XStoreColors(mDisplay, cmap, cols, cm_size);
cmap = XCreateColormap(x11->display, mRootWin, vinfo->visual, AllocAll);
XStoreColors(x11->display, cmap, cols, cm_size);
return cmap;
}
@ -1981,7 +1987,7 @@ static int transform_color(float val,
return (unsigned short) (s * 65535);
}
uint32_t vo_x11_set_equalizer(char *name, int value)
uint32_t vo_x11_set_equalizer(struct vo *vo, char *name, int value)
{
float gamma, brightness, contrast;
float rf, gf, bf;
@ -2027,8 +2033,8 @@ uint32_t vo_x11_set_equalizer(char *name, int value)
cols[k].blue = transform_color(bf * k, brightness, contrast, gamma);
}
XStoreColors(mDisplay, cmap, cols, cm_size);
XFlush(mDisplay);
XStoreColors(vo->x11->display, cmap, cols, cm_size);
XFlush(vo->x11->display);
return VO_TRUE;
}
@ -2048,7 +2054,7 @@ uint32_t vo_x11_get_equalizer(char *name, int *value)
}
#ifdef HAVE_XV
int vo_xv_set_eq(uint32_t xv_port, char *name, int value)
int vo_xv_set_eq(struct vo *vo, uint32_t xv_port, char *name, int value)
{
XvAttribute *attributes;
int i, howmany, xv_atom;
@ -2056,11 +2062,11 @@ int vo_xv_set_eq(uint32_t xv_port, char *name, int value)
mp_dbg(MSGT_VO, MSGL_V, "xv_set_eq called! (%s, %d)\n", name, value);
/* get available attributes */
attributes = XvQueryPortAttributes(mDisplay, xv_port, &howmany);
attributes = XvQueryPortAttributes(vo->x11->display, xv_port, &howmany);
for (i = 0; i < howmany && attributes; i++)
if (attributes[i].flags & XvSettable)
{
xv_atom = XInternAtom(mDisplay, attributes[i].name, True);
xv_atom = XInternAtom(vo->x11->display, attributes[i].name, True);
/* since we have SET_DEFAULTS first in our list, we can check if it's available
then trigger it if it's ok so that the other values are at default upon query */
if (xv_atom != None)
@ -2111,32 +2117,32 @@ int vo_xv_set_eq(uint32_t xv_port, char *name, int value)
port_value =
(port_value + 100) * (port_max - port_min) / 200 +
port_min;
XvSetPortAttribute(mDisplay, xv_port, xv_atom, port_value);
XvSetPortAttribute(vo->x11->display, xv_port, xv_atom, port_value);
return (VO_TRUE);
}
}
return (VO_FALSE);
}
int vo_xv_get_eq(uint32_t xv_port, char *name, int *value)
int vo_xv_get_eq(struct vo *vo, uint32_t xv_port, char *name, int *value)
{
XvAttribute *attributes;
int i, howmany, xv_atom;
/* get available attributes */
attributes = XvQueryPortAttributes(mDisplay, xv_port, &howmany);
attributes = XvQueryPortAttributes(vo->x11->display, xv_port, &howmany);
for (i = 0; i < howmany && attributes; i++)
if (attributes[i].flags & XvGettable)
{
xv_atom = XInternAtom(mDisplay, attributes[i].name, True);
xv_atom = XInternAtom(vo->x11->display, attributes[i].name, True);
/* since we have SET_DEFAULTS first in our list, we can check if it's available
then trigger it if it's ok so that the other values are at default upon query */
if (xv_atom != None)
{
int val, port_value = 0, port_min, port_max;
XvGetPortAttribute(mDisplay, xv_port, xv_atom,
XvGetPortAttribute(vo->x11->display, xv_port, xv_atom,
&port_value);
port_min = attributes[i].min_value;
@ -2197,20 +2203,21 @@ unsigned int xv_port; ///< The selected Xv port.
* \return Returns the atom if available, else None is returned.
*
*/
static Atom xv_intern_atom_if_exists( char const * atom_name )
static Atom xv_intern_atom_if_exists(struct vo_x11_state *x11,
char const *atom_name)
{
XvAttribute * attributes;
int attrib_count,i;
Atom xv_atom = None;
attributes = XvQueryPortAttributes( mDisplay, xv_port, &attrib_count );
attributes = XvQueryPortAttributes(x11->display, xv_port, &attrib_count );
if( attributes!=NULL )
{
for ( i = 0; i < attrib_count; ++i )
{
if ( strcmp(attributes[i].name, atom_name ) == 0 )
{
xv_atom = XInternAtom( mDisplay, atom_name, False );
xv_atom = XInternAtom(x11->display, atom_name, False );
break; // found what we want, break out
}
}
@ -2224,12 +2231,13 @@ static Atom xv_intern_atom_if_exists( char const * atom_name )
* \brief Try to enable vsync for xv.
* \return Returns -1 if not available, 0 on failure and 1 on success.
*/
int vo_xv_enable_vsync(void)
int vo_xv_enable_vsync(struct vo *vo)
{
Atom xv_atom = xv_intern_atom_if_exists("XV_SYNC_TO_VBLANK");
struct vo_x11_state *x11 = vo->x11;
Atom xv_atom = xv_intern_atom_if_exists(x11, "XV_SYNC_TO_VBLANK");
if (xv_atom == None)
return -1;
return XvSetPortAttribute(mDisplay, xv_port, xv_atom, 1) == Success;
return XvSetPortAttribute(x11->display, xv_port, xv_atom, 1) == Success;
}
/**
@ -2243,13 +2251,13 @@ int vo_xv_enable_vsync(void)
* \param height [out] The maximum height gets stored here.
*
*/
void vo_xv_get_max_img_dim( uint32_t * width, uint32_t * height )
void vo_xv_get_max_img_dim(struct vo *vo, uint32_t * width, uint32_t * height)
{
XvEncodingInfo * encodings;
//unsigned long num_encodings, idx; to int or too long?!
unsigned int num_encodings, idx;
XvQueryEncodings( mDisplay, xv_port, &num_encodings, &encodings);
XvQueryEncodings(vo->x11->display, xv_port, &num_encodings, &encodings);
if ( encodings )
{
@ -2348,13 +2356,14 @@ void vo_xv_print_ck_info(void)
* NOTE: If vo_colorkey has bits set after the first 3 low order bytes
* we don't draw anything as this means it was forced to off.
*/
int vo_xv_init_colorkey(void)
int vo_xv_init_colorkey(struct vo *vo)
{
struct vo_x11_state *x11 = vo->x11;
Atom xv_atom;
int rez;
/* check if colorkeying is needed */
xv_atom = xv_intern_atom_if_exists( "XV_COLORKEY" );
xv_atom = xv_intern_atom_if_exists(vo->x11, "XV_COLORKEY");
/* if we have to deal with colorkeying ... */
if( xv_atom != None && !(vo_colorkey & 0xFF000000) )
@ -2367,9 +2376,9 @@ int vo_xv_init_colorkey(void)
/* check if we have to set the colorkey too */
if ( xv_ck_info.source == CK_SRC_SET )
{
xv_atom = XInternAtom(mDisplay, "XV_COLORKEY",False);
xv_atom = XInternAtom(x11->display, "XV_COLORKEY",False);
rez = XvSetPortAttribute( mDisplay, xv_port, xv_atom, vo_colorkey );
rez = XvSetPortAttribute(x11->display, xv_port, xv_atom, vo_colorkey);
if ( rez != Success )
{
mp_msg( MSGT_VO, MSGL_FATAL,
@ -2382,7 +2391,7 @@ int vo_xv_init_colorkey(void)
{
int colorkey_ret;
rez=XvGetPortAttribute(mDisplay,xv_port, xv_atom, &colorkey_ret);
rez=XvGetPortAttribute(x11->display,xv_port, xv_atom, &colorkey_ret);
if ( rez == Success )
{
xv_colorkey = colorkey_ret;
@ -2396,7 +2405,7 @@ int vo_xv_init_colorkey(void)
}
}
xv_atom = xv_intern_atom_if_exists( "XV_AUTOPAINT_COLORKEY" );
xv_atom = xv_intern_atom_if_exists(vo->x11, "XV_AUTOPAINT_COLORKEY");
/* should we draw the colorkey ourselves or activate autopainting? */
if ( xv_ck_info.method == CK_METHOD_AUTOPAINT )
@ -2405,7 +2414,7 @@ int vo_xv_init_colorkey(void)
if ( xv_atom != None ) // autopaint is supported
{
rez = XvSetPortAttribute( mDisplay, xv_port, xv_atom, 1 );
rez = XvSetPortAttribute(x11->display, xv_port, xv_atom, 1);
}
if ( rez != Success )
@ -2418,7 +2427,7 @@ int vo_xv_init_colorkey(void)
{
if ( xv_atom != None ) // we have autopaint attribute
{
XvSetPortAttribute( mDisplay, xv_port, xv_atom, 0 );
XvSetPortAttribute(x11->display, xv_port, xv_atom, 0);
}
}
}
@ -2443,14 +2452,15 @@ int vo_xv_init_colorkey(void)
* It doesn't call XFlush.
*
*/
void vo_xv_draw_colorkey( int32_t x, int32_t y,
int32_t w, int32_t h )
void vo_xv_draw_colorkey(struct vo *vo, int32_t x, int32_t y,
int32_t w, int32_t h)
{
struct vo_x11_state *x11 = vo->x11;
if( xv_ck_info.method == CK_METHOD_MANUALFILL ||
xv_ck_info.method == CK_METHOD_BACKGROUND )//less tearing than XClearWindow()
{
XSetForeground( mDisplay, vo_gc, xv_colorkey );
XFillRectangle( mDisplay, vo_window, vo_gc,
XSetForeground(x11->display, vo_gc, xv_colorkey );
XFillRectangle(x11->display, vo_window, vo_gc,
x, y,
w, h );
}
@ -2459,22 +2469,22 @@ void vo_xv_draw_colorkey( int32_t x, int32_t y,
/* TODO! move this to vo_x11_clearwindow_part() */
if ( vo_fs )
{
XSetForeground( mDisplay, vo_gc, 0 );
XSetForeground(x11->display, vo_gc, 0 );
/* making non-overlap fills, requires 8 checks instead of 4 */
if ( y > 0 )
XFillRectangle( mDisplay, vo_window, vo_gc,
XFillRectangle(x11->display, vo_window, vo_gc,
0, 0,
vo_screenwidth, y);
if (x > 0)
XFillRectangle( mDisplay, vo_window, vo_gc,
XFillRectangle(x11->display, vo_window, vo_gc,
0, 0,
x, vo_screenheight);
if (x + w < vo_screenwidth)
XFillRectangle( mDisplay, vo_window, vo_gc,
XFillRectangle(x11->display, vo_window, vo_gc,
x + w, 0,
vo_screenwidth, vo_screenheight);
if (y + h < vo_screenheight)
XFillRectangle( mDisplay, vo_window, vo_gc,
XFillRectangle(x11->display, vo_window, vo_gc,
0, y + h,
vo_screenwidth, vo_screenheight);
}

View File

@ -7,7 +7,7 @@
struct vo;
struct vo_x11_state {
int unused; // placeholder to avoid empty struct
Display *display;
};
#ifdef X11_FULLSCREEN
@ -33,7 +33,6 @@ extern int vo_fs_type;
extern char** vo_fstype_list;
extern char *mDisplayName;
extern Display *mDisplay;
extern Window mRootWin;
extern int mScreen;
extern int mLocalDisplay;
@ -41,18 +40,18 @@ extern int mLocalDisplay;
extern int vo_mouse_autohide;
void vo_x11_init_state(struct vo_x11_state *s);
extern int vo_init( void );
extern void vo_uninit( void );
int vo_init(struct vo *vo);
void vo_uninit(struct vo_x11_state *x11);
extern void vo_x11_decoration( Display * vo_Display,Window w,int d );
extern void vo_x11_classhint( Display * display,Window window,char *name );
extern void vo_x11_sizehint( int x, int y, int width, int height, int max );
extern int vo_x11_check_events(Display *mydisplay);
void vo_x11_sizehint(struct vo *vo, int x, int y, int width, int height, int max);
int vo_x11_check_events(struct vo *vo);
extern void vo_x11_selectinput_witherr(Display *display, Window w, long event_mask);
void vo_x11_fullscreen(struct vo *vo);
extern void vo_x11_setlayer( Display * mDisplay,Window vo_window,int layer );
extern void vo_x11_uninit(void);
extern Colormap vo_x11_create_colormap(XVisualInfo *vinfo);
extern uint32_t vo_x11_set_equalizer(char *name, int value);
void vo_x11_uninit(struct vo *vo);
Colormap vo_x11_create_colormap(struct vo *vo, XVisualInfo *vinfo);
uint32_t vo_x11_set_equalizer(struct vo *vo, char *name, int value);
extern uint32_t vo_x11_get_equalizer(char *name, int *value);
extern void fstype_help(void);
void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis,
@ -62,7 +61,7 @@ extern void vo_x11_clearwindow_part(Display *mDisplay, Window vo_window,
int img_width, int img_height, int use_fs);
extern void vo_x11_clearwindow( Display *mDisplay, Window vo_window );
void vo_x11_ontop(struct vo *vo);
extern void vo_x11_ewmh_fullscreen( int action );
void vo_x11_ewmh_fullscreen(Display *mDisplay, int action);
#endif
@ -74,12 +73,12 @@ extern XSizeHints vo_hint;
//XvPortID xv_port;
extern unsigned int xv_port;
extern int vo_xv_set_eq(uint32_t xv_port, char * name, int value);
extern int vo_xv_get_eq(uint32_t xv_port, char * name, int *value);
int vo_xv_set_eq(struct vo *vo, uint32_t xv_port, char * name, int value);
int vo_xv_get_eq(struct vo *vo, uint32_t xv_port, char * name, int *value);
extern int vo_xv_enable_vsync(void);
int vo_xv_enable_vsync(struct vo *vo);
extern void vo_xv_get_max_img_dim( uint32_t * width, uint32_t * height );
void vo_xv_get_max_img_dim(struct vo *vo, uint32_t * width, uint32_t * height);
/*** colorkey handling ***/
typedef struct xv_ck_info_s
@ -99,8 +98,8 @@ typedef struct xv_ck_info_s
extern xv_ck_info_t xv_ck_info;
extern unsigned long xv_colorkey;
extern int vo_xv_init_colorkey(void);
extern void vo_xv_draw_colorkey(int32_t x, int32_t y, int32_t w, int32_t h);
int vo_xv_init_colorkey(struct vo *vo);
void vo_xv_draw_colorkey(struct vo *vo, int32_t x, int32_t y, int32_t w, int32_t h);
extern void xv_setup_colorkeyhandling(char const * ck_method_str, char const * ck_str);
/*** test functions for common suboptions ***/
@ -112,11 +111,11 @@ int xv_test_ckm( void * arg );
extern void vo_x11_putkey(int key);
#ifdef HAVE_XF86VM
void vo_vm_switch(uint32_t, uint32_t, int*, int*);
void vo_vm_switch(struct vo *vo, uint32_t, uint32_t, int*, int*);
void vo_vm_close(Display*);
#endif
void update_xinerama_info(void);
void update_xinerama_info(struct vo *vo);
int vo_find_depth_from_visuals(Display *dpy, int screen, Visual **visual_return);
@ -126,6 +125,23 @@ int vo_find_depth_from_visuals(Display *dpy, int screen, Visual **visual_return)
#define vo_x11_create_vo_window(...) vo_x11_create_vo_window(global_vo, __VA_ARGS__)
#define vo_x11_fullscreen() vo_x11_fullscreen(global_vo)
#define vo_x11_ontop() vo_x11_ontop(global_vo)
#define vo_init() vo_init(global_vo)
#define vo_x11_ewmh_fullscreen(action) vo_x11_ewmh_fullscreen(global_vo->x11->display, action)
#define update_xinerama_info() update_xinerama_info(global_vo)
#define vo_x11_uninit() vo_x11_uninit(global_vo)
#define vo_x11_check_events(display) vo_x11_check_events(global_vo)
#define vo_x11_sizehint(...) vo_x11_sizehint(global_vo, __VA_ARGS__)
#define vo_vm_switch(...) vo_vm_switch(global_vo, __VA_ARGS__)
#define vo_x11_create_colormap(vinfo) vo_x11_create_colormap(global_vo, vinfo)
#define vo_x11_set_equalizer(...) vo_x11_set_equalizer(global_vo, __VA_ARGS__)
#define vo_xv_set_eq(...) vo_xv_set_eq(global_vo, __VA_ARGS__)
#define vo_xv_get_eq(...) vo_xv_get_eq(global_vo, __VA_ARGS__)
#define vo_xv_enable_vsync() vo_xv_enable_vsync(global_vo)
#define vo_xv_get_max_img_dim(...) vo_xv_get_max_img_dim(global_vo, __VA_ARGS__)
#define vo_xv_init_colorkey() vo_xv_init_colorkey(global_vo)
#define vo_xv_draw_colorkey(...) vo_xv_draw_colorkey(global_vo, __VA_ARGS__)
#define mDisplay global_vo->x11->display
#endif
#endif /* MPLAYER_X11_COMMON_H */

View File

@ -151,7 +151,7 @@ static int cfg_include(m_option_t *conf, char *filename){
// XScreensaver
//**************************************************************************//
void xscreensaver_heartbeat(void);
void xscreensaver_heartbeat(struct vo_x11_state *);
//**************************************************************************//
//**************************************************************************//
@ -689,7 +689,7 @@ void exit_player_with_rc(const char* how, int rc){
#ifdef HAVE_NEW_GUI
if ( !use_gui )
#endif
vo_uninit(); // Close the X11 connection (if any is open).
vo_uninit(mpctx->x11_state); // Close the X11 connection (if any is open).
#endif
#ifdef HAVE_FREETYPE
@ -3752,7 +3752,7 @@ if(!mpctx->sh_video) {
#ifdef HAVE_X11
if (stop_xscreensaver) {
current_module = "stop_xscreensaver";
xscreensaver_heartbeat();
xscreensaver_heartbeat(mpctx->x11_state);
}
#endif
if (heartbeat_cmd) {