1
|
1 /*
|
|
2 * video_out.c,
|
|
3 *
|
|
4 * Copyright (C) Aaron Holtzman - June 2000
|
|
5 *
|
|
6 * mpeg2dec is free software; you can redistribute it and/or modify
|
|
7 * it under the terms of the GNU General Public License as published by
|
|
8 * the Free Software Foundation; either version 2, or (at your option)
|
|
9 * any later version.
|
|
10 *
|
|
11 * mpeg2dec is distributed in the hope that it will be useful,
|
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 * GNU General Public License for more details.
|
|
15 *
|
|
16 * You should have received a copy of the GNU General Public License
|
|
17 * along with GNU Make; see the file COPYING. If not, write to
|
|
18 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
19 *
|
|
20 */
|
|
21
|
|
22 #include <stdio.h>
|
|
23 #include <stdlib.h>
|
|
24 #include <string.h>
|
|
25
|
|
26 #include <unistd.h>
|
|
27 #include <sys/mman.h>
|
|
28
|
|
29 #include "config.h"
|
|
30 #include "video_out.h"
|
|
31
|
|
32 #include "../linux/shmem.h"
|
|
33
|
|
34 //
|
|
35 // Externally visible list of all vo drivers
|
|
36 //
|
|
37
|
|
38 extern vo_functions_t video_out_mga;
|
|
39 extern vo_functions_t video_out_xmga;
|
|
40 extern vo_functions_t video_out_x11;
|
|
41 extern vo_functions_t video_out_xv;
|
|
42 extern vo_functions_t video_out_gl;
|
|
43 extern vo_functions_t video_out_sdl;
|
|
44 extern vo_functions_t video_out_3dfx;
|
|
45 extern vo_functions_t video_out_null;
|
|
46 extern vo_functions_t video_out_odivx;
|
|
47 extern vo_functions_t video_out_pgm;
|
|
48 extern vo_functions_t video_out_md5;
|
|
49 extern vo_functions_t video_out_syncfb;
|
|
50
|
|
51 vo_functions_t* video_out_drivers[] =
|
|
52 {
|
|
53 #ifdef HAVE_MGA
|
|
54 #ifdef HAVE_X11
|
|
55 &video_out_xmga,
|
|
56 #endif
|
|
57 &video_out_mga,
|
|
58 #endif
|
|
59 #ifdef HAVE_SYNCFB
|
|
60 &video_out_syncfb,
|
|
61 #endif
|
|
62 #ifdef HAVE_3DFX
|
|
63 &video_out_3dfx,
|
|
64 #endif
|
|
65 #ifdef HAVE_XV
|
|
66 &video_out_xv,
|
|
67 #endif
|
|
68 #ifdef HAVE_X11
|
|
69 &video_out_x11,
|
|
70 #endif
|
|
71 #ifdef HAVE_GL
|
|
72 &video_out_gl,
|
|
73 #endif
|
|
74 #ifdef HAVE_SDL
|
|
75 &video_out_sdl,
|
|
76 #endif
|
|
77 &video_out_null,
|
|
78 &video_out_odivx,
|
|
79 &video_out_pgm,
|
|
80 &video_out_md5,
|
|
81 NULL
|
|
82 };
|
|
83
|
|
84 #ifdef X11_FULLSCREEN
|
|
85
|
|
86 #include <X11/Xlib.h>
|
|
87 #include <X11/Xutil.h>
|
|
88 #include <X11/Xatom.h>
|
|
89
|
|
90 int vo_depthonscreen=0;
|
|
91 int vo_screenwidth=0;
|
|
92 int vo_screenheight=0;
|
|
93
|
|
94 int vo_init( void )
|
|
95 {
|
|
96 int CompletionType = -1;
|
|
97 int mScreen;
|
|
98 int bpp;
|
|
99 char * DisplayName = ":0.0";
|
|
100 Display * mDisplay;
|
|
101 XImage * mXImage;
|
|
102 Window mRootWin;
|
|
103 static XWindowAttributes attribs;
|
|
104
|
|
105 if(vo_depthonscreen) return 1; // already called
|
|
106
|
|
107 if ( getenv( "DISPLAY" ) ) DisplayName=getenv( "DISPLAY" );
|
|
108 mDisplay=XOpenDisplay( DisplayName );
|
|
109 if ( !mDisplay )
|
|
110 {
|
|
111 fprintf( stderr,"vo: couldn't open the X11 display!\n" );
|
|
112 return 0;
|
|
113 }
|
|
114 mScreen=DefaultScreen( mDisplay ); // Screen ID.
|
|
115 mRootWin=RootWindow( mDisplay,mScreen );// Root window ID.
|
|
116 vo_screenwidth=DisplayWidth( mDisplay,mScreen );
|
|
117 vo_screenheight=DisplayHeight( mDisplay,mScreen );
|
|
118 // get color depth:
|
|
119 // XGetWindowAttributes(mydisplay, DefaultRootWindow(mDisplay), &attribs);
|
|
120 XGetWindowAttributes(mDisplay, mRootWin, &attribs);
|
|
121 vo_depthonscreen=attribs.depth;
|
|
122 // get bits/pixel:
|
|
123 mXImage=XGetImage( mDisplay,mRootWin,0,0,1,1,AllPlanes,ZPixmap );
|
|
124 bpp=mXImage->bits_per_pixel;
|
|
125 XDestroyImage( mXImage );
|
|
126 if((vo_depthonscreen+7)/8 != (bpp+7)/8) vo_depthonscreen=bpp; // by A'rpi
|
|
127 XCloseDisplay( mDisplay );
|
|
128 printf("X11 running at %dx%d depth: %d\n",vo_screenwidth,vo_screenheight,vo_depthonscreen);
|
|
129 return 1;
|
|
130 }
|
|
131
|
|
132 #include "../linux/keycodes.h"
|
|
133 extern void mplayer_put_key(int code);
|
|
134
|
|
135 void vo_keyboard( int key )
|
|
136 {
|
|
137 switch ( key )
|
|
138 {
|
|
139 case wsLeft: mplayer_put_key(KEY_LEFT); break;
|
|
140 case wsRight: mplayer_put_key(KEY_RIGHT); break;
|
|
141 case wsUp: mplayer_put_key(KEY_UP); break;
|
|
142 case wsDown: mplayer_put_key(KEY_DOWN); break;
|
|
143 case wsSpace: mplayer_put_key(' '); break;
|
|
144 case wsEscape: mplayer_put_key(KEY_ESC); break;
|
|
145 case wsEnter: mplayer_put_key(KEY_ENTER); break;
|
|
146 case wsq:
|
|
147 case wsQ: mplayer_put_key('q'); break;
|
|
148 case wsp:
|
|
149 case wsP: mplayer_put_key('p'); break;
|
|
150 case wsMinus:
|
|
151 case wsGrayMinus: mplayer_put_key('-'); break;
|
|
152 case wsPlus:
|
|
153 case wsGrayPlus: mplayer_put_key('+'); break;
|
|
154 }
|
|
155 }
|
|
156
|
|
157
|
|
158 // ----- Motif header: -------
|
|
159
|
|
160 #define MWM_HINTS_DECORATIONS 2
|
|
161
|
|
162 typedef struct
|
|
163 {
|
|
164 long flags;
|
|
165 long functions;
|
|
166 long decorations;
|
|
167 long input_mode;
|
|
168 } MotifWmHints;
|
|
169
|
|
170 extern MotifWmHints vo_MotifWmHints;
|
|
171 extern Atom vo_MotifHints;
|
|
172 extern int vo_depthonscreen;
|
|
173 extern int vo_screenwidth;
|
|
174 extern int vo_screenheight;
|
|
175
|
|
176 static MotifWmHints vo_MotifWmHints;
|
|
177 static Atom vo_MotifHints = None;
|
|
178
|
|
179 void vo_decoration( Display * vo_Display,Window w,int d )
|
|
180 {
|
|
181 vo_MotifHints=XInternAtom( vo_Display,"_MOTIF_WM_HINTS",0 );
|
|
182 if ( vo_MotifHints != None )
|
|
183 {
|
|
184 vo_MotifWmHints.flags=2;
|
|
185 vo_MotifWmHints.decorations=d;
|
|
186 XChangeProperty( vo_Display,w,vo_MotifHints,vo_MotifHints,32,
|
|
187 PropModeReplace,(unsigned char *)&vo_MotifWmHints,4 );
|
|
188 }
|
|
189 }
|
|
190
|
|
191 #include <signal.h>
|
|
192
|
|
193 int vo_eventhandler_pid=-1;
|
|
194
|
|
195 void vo_kill_eventhandler(){
|
|
196 if(vo_eventhandler_pid!=-1) kill(vo_eventhandler_pid,SIGTERM);
|
|
197
|
|
198 }
|
|
199
|
|
200 #endif
|
|
201
|