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.c1088
1 files changed, 550 insertions, 538 deletions
diff --git a/libvo/x11_common.c b/libvo/x11_common.c
index 883ada7715..25bed4389a 100644
--- a/libvo/x11_common.c
+++ b/libvo/x11_common.c
@@ -6,9 +6,11 @@
#include <limits.h>
#include "config.h"
+#include "options.h"
#include "mp_msg.h"
#include "mp_fifo.h"
#include "x11_common.h"
+#include "talloc.h"
#ifdef X11_FULLSCREEN
@@ -69,56 +71,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 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.
@@ -127,12 +99,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;
@@ -140,17 +112,17 @@ 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))
{
@@ -159,13 +131,13 @@ void vo_x11_ewmh_fullscreen(int action)
}
}
-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
@@ -184,7 +156,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;
@@ -260,9 +232,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);
@@ -271,20 +243,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;
@@ -294,12 +268,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;
@@ -319,11 +293,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);
}
@@ -332,7 +306,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);
@@ -348,21 +323,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;
@@ -374,19 +350,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;
@@ -402,9 +380,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
}
@@ -420,52 +398,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)
@@ -475,15 +453,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,
@@ -491,12 +469,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 */
@@ -505,27 +483,27 @@ 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");
@@ -534,45 +512,47 @@ void vo_uninit(void)
// if( !vo_depthonscreen ) return;
mp_msg(MSGT_VO, MSGL_V, "vo: uninit ...\n");
XSetErrorHandler(NULL);
- XCloseDisplay(mDisplay);
- vo_depthonscreen = 0;
- mDisplay = NULL;
+ XCloseDisplay(x11->display);
+ x11->depthonscreen = 0;
+ x11->display = NULL;
+ talloc_free(x11);
}
#include "osdep/keycodes.h"
#include "wskeys.h"
#ifdef XF86XK_AudioPause
-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;
switch (keysym)
{
case XF86XK_MenuKB:
- mplayer_put_key(KEY_MENU);
+ mplayer_put_key(f, KEY_MENU);
break;
case XF86XK_AudioPlay:
- mplayer_put_key(KEY_PLAY);
+ mplayer_put_key(f, KEY_PLAY);
break;
case XF86XK_AudioPause:
- mplayer_put_key(KEY_PAUSE);
+ mplayer_put_key(f, KEY_PAUSE);
break;
case XF86XK_AudioStop:
- mplayer_put_key(KEY_STOP);
+ mplayer_put_key(f, KEY_STOP);
break;
case XF86XK_AudioPrev:
- mplayer_put_key(KEY_PREV);
+ mplayer_put_key(f, KEY_PREV);
break;
case XF86XK_AudioNext:
- mplayer_put_key(KEY_NEXT);
+ mplayer_put_key(f, KEY_NEXT);
break;
case XF86XK_AudioMute:
- mplayer_put_key(KEY_MUTE);
+ mplayer_put_key(f, KEY_MUTE);
break;
case XF86XK_AudioLowerVolume:
- mplayer_put_key(KEY_VOLUME_DOWN);
+ mplayer_put_key(f, KEY_VOLUME_DOWN);
break;
case XF86XK_AudioRaiseVolume:
- mplayer_put_key(KEY_VOLUME_UP);
+ mplayer_put_key(f, KEY_VOLUME_UP);
break;
default:
break;
@@ -580,248 +560,249 @@ static void vo_x11_putkey_ext(int keysym)
}
#endif
-void vo_x11_putkey(int key)
+void vo_x11_putkey(struct vo *vo, int key)
{
+ struct mp_fifo *f = vo->key_fifo;
switch (key)
{
case wsLeft:
- mplayer_put_key(KEY_LEFT);
+ mplayer_put_key(f, KEY_LEFT);
break;
case wsRight:
- mplayer_put_key(KEY_RIGHT);
+ mplayer_put_key(f, KEY_RIGHT);
break;
case wsUp:
- mplayer_put_key(KEY_UP);
+ mplayer_put_key(f, KEY_UP);
break;
case wsDown:
- mplayer_put_key(KEY_DOWN);
+ mplayer_put_key(f, KEY_DOWN);
break;
case wsSpace:
- mplayer_put_key(' ');
+ mplayer_put_key(f, ' ');
break;
case wsEscape:
- mplayer_put_key(KEY_ESC);
+ mplayer_put_key(f, KEY_ESC);
break;
case wsTab:
- mplayer_put_key(KEY_TAB);
+ mplayer_put_key(f, KEY_TAB);
break;
case wsEnter:
- mplayer_put_key(KEY_ENTER);
+ mplayer_put_key(f, KEY_ENTER);
break;
case wsBackSpace:
- mplayer_put_key(KEY_BS);
+ mplayer_put_key(f, KEY_BS);
break;
case wsDelete:
- mplayer_put_key(KEY_DELETE);
+ mplayer_put_key(f, KEY_DELETE);
break;
case wsInsert:
- mplayer_put_key(KEY_INSERT);
+ mplayer_put_key(f, KEY_INSERT);
break;
case wsHome:
- mplayer_put_key(KEY_HOME);
+ mplayer_put_key(f, KEY_HOME);
break;
case wsEnd:
- mplayer_put_key(KEY_END);
+ mplayer_put_key(f, KEY_END);
break;
case wsPageUp:
- mplayer_put_key(KEY_PAGE_UP);
+ mplayer_put_key(f, KEY_PAGE_UP);
break;
case wsPageDown:
- mplayer_put_key(KEY_PAGE_DOWN);
+ mplayer_put_key(f, KEY_PAGE_DOWN);
break;
case wsF1:
- mplayer_put_key(KEY_F + 1);
+ mplayer_put_key(f, KEY_F + 1);
break;
case wsF2:
- mplayer_put_key(KEY_F + 2);
+ mplayer_put_key(f, KEY_F + 2);
break;
case wsF3:
- mplayer_put_key(KEY_F + 3);
+ mplayer_put_key(f, KEY_F + 3);
break;
case wsF4:
- mplayer_put_key(KEY_F + 4);
+ mplayer_put_key(f, KEY_F + 4);
break;
case wsF5:
- mplayer_put_key(KEY_F + 5);
+ mplayer_put_key(f, KEY_F + 5);
break;
case wsF6:
- mplayer_put_key(KEY_F + 6);
+ mplayer_put_key(f, KEY_F + 6);
break;
case wsF7:
- mplayer_put_key(KEY_F + 7);
+ mplayer_put_key(f, KEY_F + 7);
break;
case wsF8:
- mplayer_put_key(KEY_F + 8);
+ mplayer_put_key(f, KEY_F + 8);
break;
case wsF9:
- mplayer_put_key(KEY_F + 9);
+ mplayer_put_key(f, KEY_F + 9);
break;
case wsF10:
- mplayer_put_key(KEY_F + 10);
+ mplayer_put_key(f, KEY_F + 10);
break;
case wsF11:
- mplayer_put_key(KEY_F + 11);
+ mplayer_put_key(f, KEY_F + 11);
break;
case wsF12:
- mplayer_put_key(KEY_F + 12);
+ mplayer_put_key(f, KEY_F + 12);
break;
case wsMinus:
case wsGrayMinus:
- mplayer_put_key('-');
+ mplayer_put_key(f, '-');
break;
case wsPlus:
case wsGrayPlus:
- mplayer_put_key('+');
+ mplayer_put_key(f, '+');
break;
case wsGrayMul:
case wsMul:
- mplayer_put_key('*');
+ mplayer_put_key(f, '*');
break;
case wsGrayDiv:
case wsDiv:
- mplayer_put_key('/');
+ mplayer_put_key(f, '/');
break;
case wsLess:
- mplayer_put_key('<');
+ mplayer_put_key(f, '<');
break;
case wsMore:
- mplayer_put_key('>');
+ mplayer_put_key(f, '>');
break;
case wsGray0:
- mplayer_put_key(KEY_KP0);
+ mplayer_put_key(f, KEY_KP0);
break;
case wsGrayEnd:
case wsGray1:
- mplayer_put_key(KEY_KP1);
+ mplayer_put_key(f, KEY_KP1);
break;
case wsGrayDown:
case wsGray2:
- mplayer_put_key(KEY_KP2);
+ mplayer_put_key(f, KEY_KP2);
break;
case wsGrayPgDn:
case wsGray3:
- mplayer_put_key(KEY_KP3);
+ mplayer_put_key(f, KEY_KP3);
break;
case wsGrayLeft:
case wsGray4:
- mplayer_put_key(KEY_KP4);
+ mplayer_put_key(f, KEY_KP4);
break;
case wsGray5Dup:
case wsGray5:
- mplayer_put_key(KEY_KP5);
+ mplayer_put_key(f, KEY_KP5);
break;
case wsGrayRight:
case wsGray6:
- mplayer_put_key(KEY_KP6);
+ mplayer_put_key(f, KEY_KP6);
break;
case wsGrayHome:
case wsGray7:
- mplayer_put_key(KEY_KP7);
+ mplayer_put_key(f, KEY_KP7);
break;
case wsGrayUp:
case wsGray8:
- mplayer_put_key(KEY_KP8);
+ mplayer_put_key(f, KEY_KP8);
break;
case wsGrayPgUp:
case wsGray9:
- mplayer_put_key(KEY_KP9);
+ mplayer_put_key(f, KEY_KP9);
break;
case wsGrayDecimal:
- mplayer_put_key(KEY_KPDEC);
+ mplayer_put_key(f, KEY_KPDEC);
break;
case wsGrayInsert:
- mplayer_put_key(KEY_KPINS);
+ mplayer_put_key(f, KEY_KPINS);
break;
case wsGrayDelete:
- mplayer_put_key(KEY_KPDEL);
+ mplayer_put_key(f, KEY_KPDEL);
break;
case wsGrayEnter:
- mplayer_put_key(KEY_KPENTER);
+ mplayer_put_key(f, KEY_KPENTER);
break;
case wsGrave:
- mplayer_put_key('`');
+ mplayer_put_key(f, '`');
break;
case wsTilde:
- mplayer_put_key('~');
+ mplayer_put_key(f, '~');
break;
case wsExclSign:
- mplayer_put_key('!');
+ mplayer_put_key(f, '!');
break;
case wsAt:
- mplayer_put_key('@');
+ mplayer_put_key(f, '@');
break;
case wsHash:
- mplayer_put_key('#');
+ mplayer_put_key(f, '#');
break;
case wsDollar:
- mplayer_put_key('$');
+ mplayer_put_key(f, '$');
break;
case wsPercent:
- mplayer_put_key('%');
+ mplayer_put_key(f, '%');
break;
case wsCircumflex:
- mplayer_put_key('^');
+ mplayer_put_key(f, '^');
break;
case wsAmpersand:
- mplayer_put_key('&');
+ mplayer_put_key(f, '&');
break;
case wsobracket:
- mplayer_put_key('(');
+ mplayer_put_key(f, '(');
break;
case wscbracket:
- mplayer_put_key(')');
+ mplayer_put_key(f, ')');
break;
case wsUnder:
- mplayer_put_key('_');
+ mplayer_put_key(f, '_');
break;
case wsocbracket:
- mplayer_put_key('{');
+ mplayer_put_key(f, '{');
break;
case wsccbracket:
- mplayer_put_key('}');
+ mplayer_put_key(f, '}');
break;
case wsColon:
- mplayer_put_key(':');
+ mplayer_put_key(f, ':');
break;
case wsSemicolon:
- mplayer_put_key(';');
+ mplayer_put_key(f, ';');
break;
case wsDblQuote:
- mplayer_put_key('\"');
+ mplayer_put_key(f, '\"');
break;
case wsAcute:
- mplayer_put_key('\'');
+ mplayer_put_key(f, '\'');
break;
case wsComma:
- mplayer_put_key(',');
+ mplayer_put_key(f, ',');
break;
case wsPoint:
- mplayer_put_key('.');
+ mplayer_put_key(f, '.');
break;
case wsQuestSign:
- mplayer_put_key('?');
+ mplayer_put_key(f, '?');
break;
case wsBSlash:
- mplayer_put_key('\\');
+ mplayer_put_key(f, '\\');
break;
case wsPipe:
- mplayer_put_key('|');
+ mplayer_put_key(f, '|');
break;
case wsEqual:
- mplayer_put_key('=');
+ mplayer_put_key(f, '=');
break;
case wsosbrackets:
- mplayer_put_key('[');
+ mplayer_put_key(f, '[');
break;
case wscsbrackets:
- mplayer_put_key(']');
+ mplayer_put_key(f, ']');
break;
default:
if ((key >= 'a' && key <= 'z') || (key >= 'A' && key <= 'Z') ||
(key >= '0' && key <= '9'))
- mplayer_put_key(key);
+ mplayer_put_key(f, key);
}
}
@@ -869,12 +850,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;
@@ -884,26 +862,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);
}
}
@@ -913,8 +892,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 =
@@ -923,110 +902,99 @@ 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, char *name)
+void vo_x11_classhint(struct vo *vo, Window window, char *name)
{
+ struct vo_x11_state *x11 = vo->x11;
XClassHint wmClass;
pid_t pid = getpid();
wmClass.res_name = name;
wmClass.res_class = "MPlayer";
- XSetClassHint(display, window, &wmClass);
- XChangeProperty(display, window, 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)
-{
- vo_window = w;
- vo_gc = g;
+ XSetClassHint(x11->display, window, &wmClass);
+ XChangeProperty(x11->display, window, x11->XA_NET_WM_PID, XA_CARDINAL,
+ 32, PropModeReplace, (unsigned char *) &pid, 1);
}
-#endif
-void vo_x11_uninit(void)
+void vo_x11_uninit(struct vo *vo)
{
- saver_on(mDisplay);
- if (vo_window != None)
- vo_showcursor(mDisplay, vo_window);
+ struct vo_x11_state *x11 = vo->x11;
+ saver_on(x11->display);
+ if (x11->window != None)
+ vo_showcursor(x11->display, x11->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);
- XDestroyWindow(mDisplay, vo_window);
+ XUnmapWindow(x11->display, x11->window);
+ 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;
+ struct MPOpts *opts = vo->opts;
+ 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);
+ XNextEvent(display, &Event);
#ifdef CONFIG_GUI
if (use_gui)
{
guiGetEvent(0, (char *) &Event);
- if (vo_window != Event.xany.window)
+ if (x11->window != Event.xany.window)
continue;
}
#endif
@@ -1037,11 +1005,11 @@ 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 (!vo_fs && (Event.xconfigure.width == opts->vo_screenwidth || Event.xconfigure.height == opts->vo_screenheight)) break;
+// if (vo_fs && Event.xconfigure.width != opts->vo_screenwidth && Event.xconfigure.height != opts->vo_screenheight) break;
+ if (x11->wi