diff options
author | attila <attila@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-06-14 04:53:03 +0000 |
---|---|---|
committer | attila <attila@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-06-14 04:53:03 +0000 |
commit | 0e4e21aac59563f297b3ece42cec0031fcfd47b1 (patch) | |
tree | f985373c16526ebb690273613e94b694b711b6db /libvo/x11_common.c | |
parent | b44c3a048ad7e1a7ac0e20316947783aa20ca226 (diff) | |
download | mpv-0e4e21aac59563f297b3ece42cec0031fcfd47b1.tar.bz2 mpv-0e4e21aac59563f297b3ece42cec0031fcfd47b1.tar.xz |
major reindentation of x11 code try #2
note that this is plain ident output, i didnt tweak it by
hand like the last attempt.
if anyone is interested in the indent profile i used, just drop me a mail.
please contact me on irc on how to send me my share of cola,
but be aware that i will only accept swiss or german cola, as the japanese is
way to sweet :)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@12583 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo/x11_common.c')
-rw-r--r-- | libvo/x11_common.c | 2956 |
1 files changed, 1689 insertions, 1267 deletions
diff --git a/libvo/x11_common.c b/libvo/x11_common.c index 5be6285f85..e6a28df904 100644 --- a/libvo/x11_common.c +++ b/libvo/x11_common.c @@ -57,30 +57,30 @@ #define WIN_LAYER_NORMAL 4 #define WIN_LAYER_ONTOP 6 #define WIN_LAYER_ABOVE_DOCK 10 - -int fs_layer=WIN_LAYER_ABOVE_DOCK; -static int orig_layer=0; + +int fs_layer = WIN_LAYER_ABOVE_DOCK; +static int orig_layer = 0; static int old_gravity = NorthWestGravity; -int stop_xscreensaver=0; +int stop_xscreensaver = 0; -static int dpms_disabled=0; -static int timeout_save=0; -static int kdescreensaver_was_running=0; +static int dpms_disabled = 0; +static int timeout_save = 0; +static int kdescreensaver_was_running = 0; -char* mDisplayName=NULL; -Display* mDisplay=NULL; -Window mRootWin; +char *mDisplayName = NULL; +Display *mDisplay = NULL; +Window mRootWin; int mScreen; int mLocalDisplay; /* output window id */ -int WinID=-1; +int WinID = -1; int vo_mouse_autohide = 0; int vo_wm_type = 0; static int vo_fs_type = 0; static int vo_fs_flip = 0; -char** vo_fstype_list; +char **vo_fstype_list; /* if equal to 1 means that WM is a metacity (broken as hell) */ int metacity_hack = 0; @@ -110,7 +110,7 @@ int xinerama_x = 0; int xinerama_y = 0; #endif #ifdef HAVE_XF86VM -XF86VidModeModeInfo **vidmodes=NULL; +XF86VidModeModeInfo **vidmodes = NULL; XF86VidModeModeLine modeline; #endif @@ -124,80 +124,85 @@ 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(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 ) - { - XEvent xev; - - /* init X event structure for _NET_WM_FULLSCREEN client msg */ - xev.xclient.type = ClientMessage; - xev.xclient.serial = 0; - xev.xclient.send_event = True; - xev.xclient.message_type = XInternAtom( mDisplay, - "_NET_WM_STATE", False ); - xev.xclient.window = vo_window; - xev.xclient.format = 32; - xev.xclient.data.l[0] = action; - xev.xclient.data.l[1] = XInternAtom( mDisplay, - "_NET_WM_STATE_FULLSCREEN", False ); - 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, - SubstructureRedirectMask | SubstructureNotifyMask, &xev ) ) + assert(action == _NET_WM_STATE_REMOVE || + action == _NET_WM_STATE_ADD || action == _NET_WM_STATE_TOGGLE); + + if (vo_fs_type & vo_wm_FULLSCREEN) { - mp_msg( MSGT_VO,MSGL_ERR, MSGTR_EwmhFullscreenStateFailed ); + XEvent xev; + + /* init X event structure for _NET_WM_FULLSCREEN client msg */ + xev.xclient.type = ClientMessage; + xev.xclient.serial = 0; + xev.xclient.send_event = True; + xev.xclient.message_type = XInternAtom(mDisplay, + "_NET_WM_STATE", False); + xev.xclient.window = vo_window; + xev.xclient.format = 32; + xev.xclient.data.l[0] = action; + xev.xclient.data.l[1] = XInternAtom(mDisplay, + "_NET_WM_STATE_FULLSCREEN", + False); + 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, + SubstructureRedirectMask | SubstructureNotifyMask, + &xev)) + { + mp_msg(MSGT_VO, MSGL_ERR, MSGTR_EwmhFullscreenStateFailed); + } } - } } -void vo_hidecursor ( Display *disp , Window win ) +void vo_hidecursor(Display * disp, Window win) { - Cursor no_ptr; - Pixmap bm_no; - XColor black,dummy; - Colormap colormap; - static unsigned char bm_no_data[] = { 0,0,0,0, 0,0,0,0 }; - - if(WinID==0) return; // do not hide, if we're playing at rootwin - - colormap = DefaultColormap(disp,DefaultScreen(disp)); - XAllocNamedColor(disp,colormap,"black",&black,&dummy); - bm_no = XCreateBitmapFromData(disp, win, bm_no_data, 8,8); - no_ptr=XCreatePixmapCursor(disp, bm_no, bm_no,&black, &black,0, 0); - XDefineCursor(disp,win,no_ptr); - XFreeCursor( disp,no_ptr ); - if (bm_no != None) - XFreePixmap(disp, bm_no); + Cursor no_ptr; + Pixmap bm_no; + XColor black, dummy; + Colormap colormap; + static unsigned char bm_no_data[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + + if (WinID == 0) + return; // do not hide, if we're playing at rootwin + + colormap = DefaultColormap(disp, DefaultScreen(disp)); + XAllocNamedColor(disp, colormap, "black", &black, &dummy); + bm_no = XCreateBitmapFromData(disp, win, bm_no_data, 8, 8); + no_ptr = XCreatePixmapCursor(disp, bm_no, bm_no, &black, &black, 0, 0); + XDefineCursor(disp, win, no_ptr); + XFreeCursor(disp, no_ptr); + if (bm_no != None) + XFreePixmap(disp, bm_no); } -void vo_showcursor( Display *disp, Window win ) -{ - if ( WinID==0 ) return; - XDefineCursor( disp,win,0 ); +void vo_showcursor(Display * disp, Window win) +{ + if (WinID == 0) + return; + XDefineCursor(disp, win, 0); } -static int x11_errorhandler(Display *display, XErrorEvent *event) +static int x11_errorhandler(Display * display, XErrorEvent * event) { #define MSGLEN 60 char msg[MSGLEN]; - - XGetErrorText(display, event->error_code, (char *)&msg, MSGLEN); - - mp_msg(MSGT_VO,MSGL_ERR,"X11 error: %s\n", msg); - - mp_msg(MSGT_VO,MSGL_V,"Type: %x, display: %x, resourceid: %x, serial: %x\n", - event->type, event->display, event->resourceid, event->serial); - mp_msg(MSGT_VO,MSGL_V,"Error code: %x, request code: %x, minor code: %x\n", - event->error_code, event->request_code, event->minor_code); - + + XGetErrorText(display, event->error_code, (char *) &msg, MSGLEN); + + mp_msg(MSGT_VO, MSGL_ERR, "X11 error: %s\n", msg); + + mp_msg(MSGT_VO, MSGL_V, + "Type: %x, display: %x, resourceid: %x, serial: %x\n", + event->type, event->display, event->resourceid, event->serial); + mp_msg(MSGT_VO, MSGL_V, + "Error code: %x, request code: %x, minor code: %x\n", + event->error_code, event->request_code, event->minor_code); + abort(); //exit_player("X11 error"); #undef MSGLEN @@ -205,278 +210,314 @@ static int x11_errorhandler(Display *display, XErrorEvent *event) void fstype_help(void) { - mp_msg(MSGT_VO, MSGL_INFO, MSGTR_AvailableFsType); - - mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "none", "don't set fullscreen window layer"); - mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "layer", "use _WIN_LAYER hint with default layer"); - mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "layer=<0..15>", "use _WIN_LAYER hint with a given layer number"); - mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "netwm", "force NETWM style"); - mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "above", "use _NETWM_STATE_ABOVE hint if available"); - mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "below", "use _NETWM_STATE_BELOW hint if available"); - mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "fullscreen", "use _NETWM_STATE_FULLSCREEN hint if availale"); - mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "stays_on_top", "use _NETWM_STATE_STAYS_ON_TOP hint if available"); - mp_msg(MSGT_VO, MSGL_INFO, "You can also negate the settings with simply putting '-' in the beginning"); + mp_msg(MSGT_VO, MSGL_INFO, MSGTR_AvailableFsType); + + mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "none", + "don't set fullscreen window layer"); + mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "layer", + "use _WIN_LAYER hint with default layer"); + mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "layer=<0..15>", + "use _WIN_LAYER hint with a given layer number"); + mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "netwm", + "force NETWM style"); + mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "above", + "use _NETWM_STATE_ABOVE hint if available"); + mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "below", + "use _NETWM_STATE_BELOW hint if available"); + mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "fullscreen", + "use _NETWM_STATE_FULLSCREEN hint if availale"); + mp_msg(MSGT_VO, MSGL_INFO, " %-15s %s\n", "stays_on_top", + "use _NETWM_STATE_STAYS_ON_TOP hint if available"); + mp_msg(MSGT_VO, MSGL_INFO, + "You can also negate the settings with simply putting '-' in the beginning"); } static void fstype_dump(int fstype) { if (fstype) { - mp_msg(MSGT_VO, MSGL_V, "[x11] Current fstype setting honours"); - if (fstype & vo_wm_LAYER) - mp_msg(MSGT_VO, MSGL_V, " LAYER"); - if (fstype & vo_wm_FULLSCREEN) - mp_msg(MSGT_VO, MSGL_V, " FULLSCREEN"); - if (fstype & vo_wm_STAYS_ON_TOP) - mp_msg(MSGT_VO, MSGL_V, " STAYS_ON_TOP"); - if (fstype & vo_wm_ABOVE) - mp_msg(MSGT_VO, MSGL_V, " ABOVE"); - if (fstype & vo_wm_BELOW) - mp_msg(MSGT_VO, MSGL_V, " BELOW"); - mp_msg(MSGT_VO, MSGL_V, " X atoms\n"); - } - else - mp_msg(MSGT_VO, MSGL_V, "[x11] Current fstype setting doesn't honour any X atoms\n"); + mp_msg(MSGT_VO, MSGL_V, "[x11] Current fstype setting honours"); + if (fstype & vo_wm_LAYER) + mp_msg(MSGT_VO, MSGL_V, " LAYER"); + if (fstype & vo_wm_FULLSCREEN) + mp_msg(MSGT_VO, MSGL_V, " FULLSCREEN"); + if (fstype & vo_wm_STAYS_ON_TOP) + mp_msg(MSGT_VO, MSGL_V, " STAYS_ON_TOP"); + if (fstype & vo_wm_ABOVE) + mp_msg(MSGT_VO, MSGL_V, " ABOVE"); + if (fstype & vo_wm_BELOW) + mp_msg(MSGT_VO, MSGL_V, " BELOW"); + mp_msg(MSGT_VO, MSGL_V, " X atoms\n"); + } else + mp_msg(MSGT_VO, MSGL_V, + "[x11] Current fstype setting doesn't honour any X atoms\n"); } - + static int net_wm_support_state_test(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; } } - - NET_WM_STATE_TEST(FULLSCREEN); - NET_WM_STATE_TEST(ABOVE); - NET_WM_STATE_TEST(STAYS_ON_TOP); - NET_WM_STATE_TEST(BELOW); - return 0; + + NET_WM_STATE_TEST(FULLSCREEN); + NET_WM_STATE_TEST(ABOVE); + NET_WM_STATE_TEST(STAYS_ON_TOP); + NET_WM_STATE_TEST(BELOW); + return 0; } -static int x11_get_property(Atom type, Atom **args, unsigned long *nitems) +static int x11_get_property(Atom type, Atom ** args, unsigned long *nitems) { - int format; - unsigned long bytesafter; - - return (Success == XGetWindowProperty( mDisplay,mRootWin,type,0,16384, - False,AnyPropertyType,&type,&format,nitems,&bytesafter, - (unsigned char **) args ) && *nitems > 0 ); + int format; + unsigned long bytesafter; + + return (Success == + XGetWindowProperty(mDisplay, mRootWin, type, 0, 16384, False, + AnyPropertyType, &type, &format, nitems, + &bytesafter, (unsigned char **) args) + && *nitems > 0); } static int vo_wm_detect(void) { - int i; - int wm = 0; - unsigned long nitems; - Atom * args = NULL; - - if ( WinID >= 0 ) return 0; - -// -- supports layers - if (x11_get_property(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) { - wm |= vo_wm_LAYER; - metacity_hack |= 1; - } else - // metacity is the only manager I know which reports support only for _WIN_LAYER - // hint in _WIN_PROTOCOLS (what's more support for it is broken) - metacity_hack |= 2; - } - XFree( args ); - if (wm && (metacity_hack == 1)) - { - // metacity reports that it supports layers, but it is not really truth :-) - wm ^= vo_wm_LAYER; - mp_msg( MSGT_VO,MSGL_V,"[x11] Using workaround for Metacity bugs.\n" ); - } - } + int i; + int wm = 0; + unsigned long nitems; + Atom *args = NULL; + + if (WinID >= 0) + return 0; +// -- supports layers + if (x11_get_property(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) + { + wm |= vo_wm_LAYER; + metacity_hack |= 1; + } else + // metacity is the only manager I know which reports support only for _WIN_LAYER + // hint in _WIN_PROTOCOLS (what's more support for it is broken) + metacity_hack |= 2; + } + XFree(args); + if (wm && (metacity_hack == 1)) + { + // metacity reports that it supports layers, but it is not really truth :-) + wm ^= vo_wm_LAYER; + mp_msg(MSGT_VO, MSGL_V, + "[x11] Using workaround for Metacity bugs.\n"); + } + } // --- netwm - if (x11_get_property(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]); - XFree( args ); + if (x11_get_property(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]); + XFree(args); #if 0 - // ugly hack for broken OpenBox _NET_WM_STATE_FULLSCREEN support - // (in their implementation it only changes internal state of window, nothing more!!!) - if (wm & vo_wm_FULLSCREEN) - { - if (x11_get_property(XA_BLACKBOX_PID, &args, &nitems)) - { - mp_msg( MSGT_VO,MSGL_V,"[x11] Detected wm is a broken OpenBox.\n" ); - wm ^= vo_wm_FULLSCREEN; - } - XFree (args); - } + // ugly hack for broken OpenBox _NET_WM_STATE_FULLSCREEN support + // (in their implementation it only changes internal state of window, nothing more!!!) + if (wm & vo_wm_FULLSCREEN) + { + if (x11_get_property(XA_BLACKBOX_PID, &args, &nitems)) + { + mp_msg(MSGT_VO, MSGL_V, + "[x11] Detected wm is a broken OpenBox.\n"); + wm ^= vo_wm_FULLSCREEN; + } + XFree(args); + } #endif - } + } - if ( wm == 0 ) mp_msg( MSGT_VO,MSGL_V,"[x11] Unknown wm type...\n" ); - return wm; -} + if (wm == 0) + mp_msg(MSGT_VO, MSGL_V, "[x11] Unknown wm type...\n"); + return wm; +} static void init_atoms(void) { - XA_INIT(_NET_SUPPORTED); - XA_INIT(_NET_WM_STATE); - XA_INIT(_NET_WM_STATE_FULLSCREEN); - XA_INIT(_NET_WM_STATE_ABOVE); - XA_INIT(_NET_WM_STATE_STAYS_ON_TOP); - XA_INIT(_NET_WM_STATE_BELOW); - XA_INIT(_NET_WM_PID); - XA_INIT(_WIN_PROTOCOLS); - XA_INIT(_WIN_LAYER); - XA_INIT(_WIN_HINTS); - XA_INIT(_BLACKBOX_PID); + XA_INIT(_NET_SUPPORTED); + XA_INIT(_NET_WM_STATE); + XA_INIT(_NET_WM_STATE_FULLSCREEN); + XA_INIT(_NET_WM_STATE_ABOVE); + XA_INIT(_NET_WM_STATE_STAYS_ON_TOP); + XA_INIT(_NET_WM_STATE_BELOW); + XA_INIT(_NET_WM_PID); + XA_INIT(_WIN_PROTOCOLS); + XA_INIT(_WIN_LAYER); + XA_INIT(_WIN_HINTS); + XA_INIT(_BLACKBOX_PID); } -int vo_init( void ) +int vo_init(void) { // int mScreen; - int depth, bpp; - unsigned int mask; + int depth, bpp; + unsigned int mask; + // char * DisplayName = ":0.0"; // Display * mDisplay; - XImage * mXImage = NULL; + XImage *mXImage = NULL; + // Window mRootWin; - XWindowAttributes attribs; - char* dispName; + XWindowAttributes attribs; + char *dispName; - if(vo_depthonscreen) return 1; // already called + if (vo_depthonscreen) + return 1; // already called - XSetErrorHandler(x11_errorhandler); + XSetErrorHandler(x11_errorhandler); #if 0 - if (!mDisplayName) - if (!(mDisplayName=getenv("DISPLAY"))) - mDisplayName=strdup(":0.0"); + if (!mDisplayName) + if (!(mDisplayName = getenv("DISPLAY"))) + mDisplayName = strdup(":0.0"); #else - dispName = XDisplayName(mDisplayName); + dispName = XDisplayName(mDisplayName); #endif - mp_msg(MSGT_VO,MSGL_V,"X11 opening display: %s\n", dispName); + mp_msg(MSGT_VO, MSGL_V, "X11 opening display: %s\n", dispName); + + mDisplay = XOpenDisplay(dispName); + if (!mDisplay) + { + 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. - mDisplay=XOpenDisplay(dispName); - if ( !mDisplay ) - { - 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. + init_atoms(); - init_atoms(); - #ifdef HAVE_XINERAMA - if(XineramaIsActive(mDisplay)) - { - XineramaScreenInfo *screens; - int num_screens; - - screens = XineramaQueryScreens(mDisplay, &num_screens); - if(xinerama_screen >= num_screens) xinerama_screen = 0; - if (! vo_screenwidth) - vo_screenwidth=screens[xinerama_screen].width; - if (! vo_screenheight) - vo_screenheight=screens[xinerama_screen].height; - xinerama_x = screens[xinerama_screen].x_org; - xinerama_y = screens[xinerama_screen].y_org; - - XFree(screens); - } - else + if (XineramaIsActive(mDisplay)) + { + XineramaScreenInfo *screens; + int num_screens; + + screens = XineramaQueryScreens(mDisplay, &num_screens); + if (xinerama_screen >= num_screens) + xinerama_screen = 0; + if (!vo_screenwidth) + vo_screenwidth = screens[xinerama_screen].width; + if (!vo_screenheight) + vo_screenheight = screens[xinerama_screen].height; + xinerama_x = screens[xinerama_screen].x_org; + xinerama_y = screens[xinerama_screen].y_org; + + XFree(screens); + } else #endif #ifdef HAVE_XF86VM - { - int clock; - XF86VidModeGetModeLine( mDisplay,mScreen,&clock ,&modeline ); - if ( !vo_screenwidth ) vo_screenwidth=modeline.hdisplay; - if ( !vo_screenheight ) vo_screenheight=modeline.vdisplay; - } + { + int clock; + + XF86VidModeGetModeLine(mDisplay, mScreen, &clock, &modeline); + if (!vo_screenwidth) + vo_screenwidth = modeline.hdisplay; + if (!vo_screenheight) + vo_screenheight = modeline.vdisplay; + } #endif - { - if (! vo_screenwidth) - vo_screenwidth=DisplayWidth( mDisplay,mScreen ); - if (! vo_screenheight) - vo_screenheight=DisplayHeight( mDisplay,mScreen ); - } - // get color depth (from root window, or the best visual): - XGetWindowAttributes(mDisplay, 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); - if (depth != -1) - mXImage=XCreateImage(mDisplay, visual, depth, ZPixmap, - 0, NULL, 1, 1, 8, 1); - } else - mXImage=XGetImage( mDisplay,mRootWin,0,0,1,1,AllPlanes,ZPixmap ); - - vo_depthonscreen = depth; // display depth on screen - - // get bits/pixel from XImage structure: - if (mXImage == NULL) { - mask = 0; - } else { - /* - * 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 - * 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 - mask=mXImage->red_mask|mXImage->green_mask|mXImage->blue_mask; - mp_msg(MSGT_VO,MSGL_V,"vo: X11 color mask: %X (R:%lX G:%lX B:%lX)\n", - mask,mXImage->red_mask,mXImage->green_mask,mXImage->blue_mask); - XDestroyImage( mXImage ); - } - if(((vo_depthonscreen+7)/8)==2){ - if(mask==0x7FFF) vo_depthonscreen=15; else - if(mask==0xFFFF) vo_depthonscreen=16; - } + { + if (!vo_screenwidth) + vo_screenwidth = DisplayWidth(mDisplay, mScreen); + if (!vo_screenheight) + vo_screenheight = DisplayHeight(mDisplay, mScreen); + } + // get color depth (from root window, or the best visual): + XGetWindowAttributes(mDisplay, 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); + if (depth != -1) + mXImage = XCreateImage(mDisplay, visual, depth, ZPixmap, + 0, NULL, 1, 1, 8, 1); + } else + mXImage = + XGetImage(mDisplay, mRootWin, 0, 0, 1, 1, AllPlanes, ZPixmap); + + vo_depthonscreen = depth; // display depth on screen + + // get bits/pixel from XImage structure: + if (mXImage == NULL) + { + mask = 0; + } else + { + /* + * 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 + * 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 + mask = + mXImage->red_mask | mXImage->green_mask | mXImage->blue_mask; + mp_msg(MSGT_VO, MSGL_V, + "vo: X11 color mask: %X (R:%lX G:%lX B:%lX)\n", mask, + mXImage->red_mask, mXImage->green_mask, mXImage->blue_mask); + XDestroyImage(mXImage); + } + if (((vo_depthonscreen + 7) / 8) == 2) + { + if (mask == 0x7FFF) + vo_depthonscreen = 15; + else if (mask == 0xFFFF) + vo_depthonscreen = 16; + } // XCloseDisplay( mDisplay ); /* slightly improved local display detection AST */ - if ( strncmp(dispName, "unix:", 5) == 0) - dispName += 4; - else if ( strncmp(dispName, "localhost:", 10) == 0) - dispName += 9; - if (*dispName==':' && atoi(dispName+1)<10) mLocalDisplay=1; else mLocalDisplay=0; - mp_msg(MSGT_VO,MSGL_INFO,"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"); - - vo_wm_type=vo_wm_detect(); - - vo_fs_type=vo_x11_get_fs_type(vo_wm_type); - - fstype_dump(vo_fs_type); - - saver_off(mDisplay); - return 1; + if (strncmp(dispName, "unix:", 5) == 0) + dispName += 4; + else if (strncmp(dispName, "localhost:", 10) == 0) + dispName += 9; + if (*dispName == ':' && atoi(dispName + 1) < 10) + mLocalDisplay = 1; + else + mLocalDisplay = 0; + mp_msg(MSGT_VO, MSGL_INFO, + "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"); + + vo_wm_type = vo_wm_detect(); + + vo_fs_type = vo_x11_get_fs_type(vo_wm_type); + + fstype_dump(vo_fs_type); + + saver_off(mDisplay); + return 1; } -void vo_uninit( void ) +void vo_uninit(void) { - if (!mDisplay) - { - mp_msg(MSGT_VO, MSGL_V, "vo: x11 uninit called but X11 not inited..\n"); - return; - } + if (!mDisplay) + { + mp_msg(MSGT_VO, MSGL_V, + "vo: x11 uninit called but X11 not inited..\n"); + return; + } // if( !vo_depthonscreen ) return; - mp_msg(MSGT_VO,MSGL_V,"vo: uninit ...\n" ); - XSetErrorHandler(NULL); - XCloseDisplay( mDisplay ); - vo_depthonscreen = 0; - mDisplay=NULL; + mp_msg(MSGT_VO, MSGL_V, "vo: uninit ...\n"); + XSetErrorHandler(NULL); + XCloseDisplay(mDisplay); + vo_depthonscreen = 0; + mDisplay = NULL; } #include "../osdep/keycodes.h" @@ -485,120 +526,285 @@ void vo_uninit( void ) extern void mplayer_put_key(int code); #ifdef XF86XK_AudioPause -void vo_x11_putkey_ext(int keysym){ - switch ( keysym ) - { - case XF86XK_AudioPause: mplayer_put_key(KEY_XF86_PAUSE); break; - case XF86XK_AudioStop: mplayer_put_key(KEY_XF86_STOP); break; - case XF86XK_AudioPrev: mplayer_put_key(KEY_XF86_PREV); break; - case XF86XK_AudioNext: mplayer_put_key(KEY_XF86_NEXT); break; - default: break; - } +void vo_x11_putkey_ext(int keysym) +{ + switch (keysym) + { + case XF86XK_AudioPause: + mplayer_put_key(KEY_XF86_PAUSE); + break; + case XF86XK_AudioStop: + mplayer_put_key(KEY_XF86_STOP); + break; + case XF86XK_AudioPrev: + mplayer_put_key(KEY_XF86_PREV); + break; + case XF86XK_AudioNext: + mplayer_put_key(KEY_XF86_NEXT); + break; + default: + break; + } } #endif -void vo_x11_putkey(int key){ - switch ( key ) - { - case wsLeft: mplayer_put_key(KEY_LEFT); break; - case wsRight: mplayer_put_key(KEY_RIGHT); break; - case wsUp: mplayer_put_key(KEY_UP); break; - case wsDown: mplayer_put_key(KEY_DOWN); break; - case wsSpace: mplayer_put_key(' '); break; - case wsEscape: mplayer_put_key(KEY_ESC); break; - case wsEnter: mplayer_put_key(KEY_ENTER); break; - case wsBackSpace: mplayer_put_key(KEY_BS); break; - case wsDelete: mplayer_put_key(KEY_DELETE); break; - case wsInsert: mplayer_put_key(KEY_INSERT); break; - case wsHome: mplayer_put_key(KEY_HOME); break; - case wsEnd: mplayer_put_key(KEY_END); break; - case wsPageUp: mplayer_put_key(KEY_PAGE_UP); break; - case wsPageDown: mplayer_put_key(KEY_PAGE_DOWN); break; - case wsF1: mplayer_put_key(KEY_F+1); break; - case wsF2: mplayer_put_key(KEY_F+2); break; - case wsF3: mplayer_put_key(KEY_F+3); break; - case wsF4: mplayer_put_key(KEY_F+4); break; - case wsF5: mplayer_put_key(KEY_F+5); break; - case wsF6: mplayer_put_key(KEY_F+6); break; - case wsF7: mplayer_put_key(KEY_F+7); break; - case wsF8: mplayer_put_key(KEY_F+8); break; - case wsF9: mplayer_put_key(KEY_F+9); break; - case wsF10: mplayer_put_key(KEY_F+10); break; - case wsF11: mplayer_put_key(KEY_F+11); break; - case wsF12: mplayer_put_key(KEY_F+12); break; - case wsq: - case wsQ: mplayer_put_key('q'); break; - case wsp: - case wsP: mplayer_put_key('p'); break; - case wsMinus: - case wsGrayMinus: mplayer_put_key('-'); break; - case wsPlus: - case wsGrayPlus: mplayer_put_key('+'); break; - case wsGrayMul: - case wsMul: mplayer_put_key('*'); break; - case wsGrayDiv: - case wsDiv: mplayer_put_key('/'); break; - case wsLess: mplayer_put_key('<'); break; - case wsMore: mplayer_put_key('>'); break; - case wsGray0: mplayer_put_key(KEY_KP0); break; - case wsGrayEnd: - case wsGray1: mplayer_put_key(KEY_KP1); break; - case wsGrayDown: - case wsGray2: mplayer_put_key(KEY_KP2); break; - case wsGrayPgDn: - case wsGray3: mplayer_put_key(KEY_KP3); break; - case wsGrayLeft: - case wsGray4: mplayer_put_key(KEY_KP4); break; - case wsGray5Dup: - case wsGray5: mplayer_put_key(KEY_KP5); break; - case wsGrayRight: - case wsGray6: mplayer_put_key(KEY_KP6); break; - case wsGrayHome: - case wsGray7: mplayer_put_key(KEY_KP7); break; - case wsGrayUp: - case wsGray8: mplayer_put_key(KEY_KP8); break; - case wsGrayPgUp: - case wsGray9: mplayer_put_key(KEY_KP9); break; - case wsGrayDecimal: mplayer_put_key(KEY_KPDEC); break; - case wsGrayInsert: mplayer_put_key(KEY_KPINS); break; - case wsGrayDelete: mplayer_put_key(KEY_KPDEL); break; - case wsGrayEnter: mplayer_put_key(KEY_KPENTER); break; - case wsm: - case wsM: mplayer_put_key('m'); break; - case wso: - case wsO: mplayer_put_key('o'); break; - - case wsGrave: mplayer_put_key('`'); break; - case wsTilde: mplayer_put_key('~'); break; - case wsExclSign: mplayer_put_key('!'); break; - case wsAt: mplayer_put_key('@'); break; - case wsHash: mplayer_put_key('#'); break; - case wsDollar: mplayer_put_key('$'); break; - case wsPercent: mplayer_put_key('%'); break; - case wsCircumflex: mplayer_put_key('^'); break; - case wsAmpersand: mplayer_put_key('&'); break; - case wsobracket: mplayer_put_key('('); break; - case wscbracket: mplayer_put_key(')'); break; - case wsUnder: mplayer_put_key('_'); break; - case wsocbracket: mplayer_put_key('{'); break; - case wsccbracket: mplayer_put_key('}'); break; - case wsColon: mplayer_put_key(':'); break; - case wsSemicolon: mplayer_put_key(';'); break; - case wsDblQuote: mplayer_put_key('\"'); break; - case wsAcute: mplayer_put_key('\''); break; - case wsComma: mplayer_put_key(','); break; - case wsPoint: mplayer_put_key('.'); break; - case wsQuestSign: mplayer_put_key('?'); break; - case wsBSlash: mplayer_put_key('\\'); break; - case wsPipe: mplayer_put_key('|'); break; - case wsEqual: mplayer_put_key('='); break; - case wsosbrackets: mplayer_put_key('['); break; - case wscsbrackets: mplayer_put_key(']'); break; - - - default: if((key>='a' && key<='z')||(key>='A' && key<='Z')|| - (key>='0' && key<='9')) mplayer_put_key(key); - } +void vo_x11_putkey(int key) +{ + switch (key) + { + case wsLeft: + mplayer_put_key(KEY_LEFT); + break; + case wsRight: + mplayer_put_key(KEY_RIGHT); + break; + case wsUp: + mplayer_put_key(KEY_UP); + break; + case wsDown: + mplayer_put_key(KEY_DOWN); + break; + case wsSpace: + mplayer_put_key(' '); + break; + case wsEscape: + mplayer_put_key(KEY_ESC); + break; + case wsEnter: + mplayer_put_key(KEY_ENTER); + break; + case wsBackSpace: + mplayer_put_key(KEY_BS); + break; + case wsDelete: + mplayer_put_key(KEY_DELETE); + break; + case wsInsert: + mplayer_put_key(KEY_INSERT); + break; + case wsHome: + mplayer_put_key(KEY_HOME); + break; + case wsEnd: + mplayer_put_key(KEY_END); + break; + case wsPageUp: + mplayer_put_key(KEY_PAGE_UP); + break; + case wsPageDown: + mplayer_put_key(KEY_PAGE_DOWN); + break; + case wsF1: + mplayer_put_key(KEY_F + 1); + break; + case wsF2: + mplayer_put_key(KEY_F + 2); + break; + case wsF3: + mplayer_put_key(KEY_F + 3); + break; + case wsF4: + mplayer_put_key(KEY_F + 4); + break; + case wsF5: + mplayer_put_key(KEY_F + 5); + break; + case wsF6: + mplayer_put_key(KEY_F + 6); + break; + case wsF7: + mplayer_put_key(KEY_F + 7); + break; + case wsF8: + mplayer_put_key(KEY_F + 8); + break; + case wsF9: + mplayer_put_key(KEY_F + 9); + break; + case wsF10: + mplayer_put_key(KEY_F + 10); + break; + case wsF11: + mplayer_put_key(KEY_F + 11); + break; + case wsF12: + mplayer_put_key(KEY_F + 12); + break; + case wsq: + case wsQ: + mplayer_put_key('q'); + break; + case wsp: + case wsP: + mplayer_put_key('p'); + break; + case wsMinus: + case wsGrayMinus: + mplayer_put_key('-'); + break; + case wsPlus: + case wsGrayPlus: + mplayer_put_key('+'); + break; + case wsGrayMul: + case wsMul: + mplayer_put_key('*'); + break; + case wsGrayDiv: + case wsDiv: + mplayer_put_key('/'); + break; + case wsLess: + mplayer_put_key('<'); + break; + case wsMore: + mplayer_put_key('>'); + break; + case wsGray0: + mplayer_put_key(KEY_KP0); + break; + case wsGrayEnd: + case wsGray1: + mplayer_put_key(KEY_KP1); + break; + case wsGrayDown: + case wsGray2: + mplayer_put_key( |