annotate libvo/vo_xmga.c @ 411:53203545daa7

-bpp added.
author se7encode
date Sat, 14 Apr 2001 18:19:40 +0000
parents b0e4e5744899
children 198b46b739d8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
100
201c2f931497 added #define SHOW_TIME option... (debug)
arpi_esp
parents: 56
diff changeset
1
201c2f931497 added #define SHOW_TIME option... (debug)
arpi_esp
parents: 56
diff changeset
2 //#define SHOW_TIME
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
3
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
4 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
5 * video_out_xmga.c
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
6 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
7 * Copyright (C) Zoltan Ponekker - Jan 2001
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
8 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
9 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11 * mpeg2dec is free software; you can redistribute it and/or modify
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13 * the Free Software Foundation; either version 2, or (at your option)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14 * any later version.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16 * mpeg2dec is distributed in the hope that it will be useful,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19 * GNU General Public License for more details.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
22 * along with GNU Make; see the file COPYING. If not, write to
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
23 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
24 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
25 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27 #include <stdio.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28 #include <stdlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29 #include <string.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
30
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
31 #include "config.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32 #include "video_out.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
33 #include "video_out_internal.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35 LIBVO_EXTERN( xmga )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37 #include <sys/ioctl.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
38 #include <unistd.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39 #include <fcntl.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40 #include <sys/mman.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42 #include "drivers/mga_vid.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
44 #include <X11/Xlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
45 #include <X11/Xutil.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46 #include <errno.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
48 #include "x11_common.h"
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
49
182
80a7b40f201a *** empty log message ***
pontscho
parents: 120
diff changeset
50 #ifdef SHOW_TIME
100
201c2f931497 added #define SHOW_TIME option... (debug)
arpi_esp
parents: 56
diff changeset
51 #include "../linux/timer.h"
201c2f931497 added #define SHOW_TIME option... (debug)
arpi_esp
parents: 56
diff changeset
52 static unsigned int timer=0;
201c2f931497 added #define SHOW_TIME option... (debug)
arpi_esp
parents: 56
diff changeset
53 static unsigned int timerd=0;
201c2f931497 added #define SHOW_TIME option... (debug)
arpi_esp
parents: 56
diff changeset
54 #endif
201c2f931497 added #define SHOW_TIME option... (debug)
arpi_esp
parents: 56
diff changeset
55
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 static vo_info_t vo_info =
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58 "X11 (Matrox G200/G400 overlay in window using /dev/mga_vid)",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 "xmga",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60 "Zoltan Ponekker <pontscho@makacs.poliod.hu>",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61 ""
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 static Display * mDisplay;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 static Window mWindow;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66 static GC mGC;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 static XGCValues wGCV;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 static XImage * myximage;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71 static uint32_t mDepth, bpp, mode;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72 static XWindowAttributes attribs;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 static uint32_t X_already_started=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75 static uint32_t wndHeight;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 static uint32_t wndWidth;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 static uint32_t wndX;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78 static uint32_t wndY;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80 static uint32_t fgColor;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82 static uint32_t mvHeight;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83 static uint32_t mvWidth;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
85 static Window mRoot;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
86 static uint32_t drwX,drwY,drwWidth,drwHeight,drwBorderWidth,drwDepth;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87 static uint32_t drwcX,drwcY,dwidth,dheight,mFullscreen;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89 static XSetWindowAttributes xWAttribs;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
91 #include "mga_common.c"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
92
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93 static void mDrawColorKey( void )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
95 XClearWindow( mDisplay,mWindow );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96 XSetForeground( mDisplay,mGC,fgColor );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
97 XFillRectangle( mDisplay,mWindow,mGC,drwX,drwY,drwWidth,(mFullscreen?drwHeight - 1:drwHeight) );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
98 XFlush( mDisplay );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
99 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
100
120
93ea0c6aae7f common window setup code moved to set_window()
arpi_esp
parents: 100
diff changeset
101 static void set_window(){
93ea0c6aae7f common window setup code moved to set_window()
arpi_esp
parents: 100
diff changeset
102
93ea0c6aae7f common window setup code moved to set_window()
arpi_esp
parents: 100
diff changeset
103 XGetGeometry( mDisplay,mWindow,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth );
93ea0c6aae7f common window setup code moved to set_window()
arpi_esp
parents: 100
diff changeset
104 drwX=0; drwY=0; // drwWidth=wndWidth; drwHeight=wndHeight;
93ea0c6aae7f common window setup code moved to set_window()
arpi_esp
parents: 100
diff changeset
105 XTranslateCoordinates( mDisplay,mWindow,mRoot,0,0,&drwcX,&drwcY,&mRoot );
340
1f7c824033fb less, and more informal printfs
arpi_esp
parents: 324
diff changeset
106 //fprintf( stderr,"[xmga] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight );
120
93ea0c6aae7f common window setup code moved to set_window()
arpi_esp
parents: 100
diff changeset
107
93ea0c6aae7f common window setup code moved to set_window()
arpi_esp
parents: 100
diff changeset
108 if ( mFullscreen )
93ea0c6aae7f common window setup code moved to set_window()
arpi_esp
parents: 100
diff changeset
109 {
93ea0c6aae7f common window setup code moved to set_window()
arpi_esp
parents: 100
diff changeset
110 drwX=( vo_screenwidth - (dwidth > vo_screenwidth?vo_screenwidth:dwidth) ) / 2;
93ea0c6aae7f common window setup code moved to set_window()
arpi_esp
parents: 100
diff changeset
111 drwcX+=drwX;
93ea0c6aae7f common window setup code moved to set_window()
arpi_esp
parents: 100
diff changeset
112 drwY=( vo_screenheight - (dheight > vo_screenheight?vo_screenheight:dheight) ) / 2;
93ea0c6aae7f common window setup code moved to set_window()
arpi_esp
parents: 100
diff changeset
113 drwcY+=drwY;
93ea0c6aae7f common window setup code moved to set_window()
arpi_esp
parents: 100
diff changeset
114 drwWidth=(dwidth > vo_screenwidth?vo_screenwidth:dwidth);
93ea0c6aae7f common window setup code moved to set_window()
arpi_esp
parents: 100
diff changeset
115 drwHeight=(dheight > vo_screenheight?vo_screenheight:dheight);
340
1f7c824033fb less, and more informal printfs
arpi_esp
parents: 324
diff changeset
116 //fprintf( stderr,"[xmga-fs] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight );
120
93ea0c6aae7f common window setup code moved to set_window()
arpi_esp
parents: 100
diff changeset
117 }
93ea0c6aae7f common window setup code moved to set_window()
arpi_esp
parents: 100
diff changeset
118
93ea0c6aae7f common window setup code moved to set_window()
arpi_esp
parents: 100
diff changeset
119 mDrawColorKey();
93ea0c6aae7f common window setup code moved to set_window()
arpi_esp
parents: 100
diff changeset
120
93ea0c6aae7f common window setup code moved to set_window()
arpi_esp
parents: 100
diff changeset
121 mga_vid_config.x_org=drwcX;
93ea0c6aae7f common window setup code moved to set_window()
arpi_esp
parents: 100
diff changeset
122 mga_vid_config.y_org=drwcY;
93ea0c6aae7f common window setup code moved to set_window()
arpi_esp
parents: 100
diff changeset
123 mga_vid_config.dest_width=drwWidth;
93ea0c6aae7f common window setup code moved to set_window()
arpi_esp
parents: 100
diff changeset
124 mga_vid_config.dest_height=drwHeight;
93ea0c6aae7f common window setup code moved to set_window()
arpi_esp
parents: 100
diff changeset
125
93ea0c6aae7f common window setup code moved to set_window()
arpi_esp
parents: 100
diff changeset
126 }
93ea0c6aae7f common window setup code moved to set_window()
arpi_esp
parents: 100
diff changeset
127
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
128 static void check_events(void)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
129 {
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
130 int e=vo_x11_check_events(mDisplay);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
131
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
132 if(e&VO_EVENT_RESIZE){
120
93ea0c6aae7f common window setup code moved to set_window()
arpi_esp
parents: 100
diff changeset
133 set_window();
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
134 if ( ioctl( f,MGA_VID_CONFIG,&mga_vid_config ) )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
135 {
340
1f7c824033fb less, and more informal printfs
arpi_esp
parents: 324
diff changeset
136 fprintf( stderr,"Error in mga_vid_config ioctl (wrong mga_vid.o version?)" );
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
137 // exit( 0 );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
138 }
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
139
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
140 } else
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
141 if(e&VO_EVENT_EXPOSE) mDrawColorKey();
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
142
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
143 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
145 static void flip_page(void){
182
80a7b40f201a *** empty log message ***
pontscho
parents: 120
diff changeset
146 #ifdef SHOW_TIME
100
201c2f931497 added #define SHOW_TIME option... (debug)
arpi_esp
parents: 56
diff changeset
147 unsigned int t;
201c2f931497 added #define SHOW_TIME option... (debug)
arpi_esp
parents: 56
diff changeset
148 t=GetTimer();
201c2f931497 added #define SHOW_TIME option... (debug)
arpi_esp
parents: 56
diff changeset
149 printf(" [timer: %08X diff: %6d dd: %6d ] \n",t,t-timer,(t-timer)-timerd);
201c2f931497 added #define SHOW_TIME option... (debug)
arpi_esp
parents: 56
diff changeset
150 timerd=t-timer;
201c2f931497 added #define SHOW_TIME option... (debug)
arpi_esp
parents: 56
diff changeset
151 timer=t;
182
80a7b40f201a *** empty log message ***
pontscho
parents: 120
diff changeset
152 #endif
100
201c2f931497 added #define SHOW_TIME option... (debug)
arpi_esp
parents: 56
diff changeset
153
213
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
154 vo_draw_text(mga_vid_config.src_width,mga_vid_config.src_height,draw_alpha);
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents: 182
diff changeset
155
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
156 check_events();
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
157 vo_mga_flip_page();
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
158 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
160 static uint32_t init( uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
161 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
162 char * frame_mem;
56
cdb2e30be421 mga_vid fixes, code cleanup
arpi_esp
parents: 47
diff changeset
163 // uint32_t frame_size;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164 int mScreen;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165 unsigned int fg, bg;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
166 char * mTitle=(title == NULL) ? "XMGA render" : title;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
167 char * name=":0.0";
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
168 XSizeHints hint;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169 XVisualInfo vinfo;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170 XEvent xev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
171
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
172 XGCValues xgcv;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
173 unsigned long xswamask;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
175 f=open( "/dev/mga_vid",O_RDWR );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
176 if ( f == -1 )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
177 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
178 fprintf(stderr,"Couldn't open /dev/mga_vid\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179 return(-1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
181
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
182 switch(format)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
183 {
182
80a7b40f201a *** empty log message ***
pontscho
parents: 120
diff changeset
184 case IMGFMT_YV12:
56
cdb2e30be421 mga_vid fixes, code cleanup
arpi_esp
parents: 47
diff changeset
185 mga_vid_config.format=MGA_VID_FORMAT_YV12;
182
80a7b40f201a *** empty log message ***
pontscho
parents: 120
diff changeset
186 mga_vid_config.frame_size=( ( width + 31 ) & ~31 ) * height + ( ( ( width + 31 ) & ~31 ) * height ) / 2;
56
cdb2e30be421 mga_vid fixes, code cleanup
arpi_esp
parents: 47
diff changeset
187 break;
cdb2e30be421 mga_vid fixes, code cleanup
arpi_esp
parents: 47
diff changeset
188 case IMGFMT_YUY2:
cdb2e30be421 mga_vid fixes, code cleanup
arpi_esp
parents: 47
diff changeset
189 mga_vid_config.format=MGA_VID_FORMAT_YUY2;
182
80a7b40f201a *** empty log message ***
pontscho
parents: 120
diff changeset
190 mga_vid_config.frame_size=( ( width + 31 ) & ~31 ) * height * 2;
56
cdb2e30be421 mga_vid fixes, code cleanup
arpi_esp
parents: 47
diff changeset
191 break;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
192 default: fprintf(stderr,"mga: invalid output format %0X\n",format); return (-1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
193 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
194
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
195 if ( X_already_started ) return -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
196
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
197 vo_init();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
198
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
199 if ( getenv( "DISPLAY" ) ) name=getenv( "DISPLAY" );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
200 mDisplay=XOpenDisplay(name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
201 if ( mDisplay == NULL )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
202 {
340
1f7c824033fb less, and more informal printfs
arpi_esp
parents: 324
diff changeset
203 fprintf( stderr,"Can not open X11 display\n" );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
204 return -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
205 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
206
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
207 mScreen=DefaultScreen( mDisplay );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
208
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
209 mvWidth=width; mvHeight=height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
210
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
211 wndX=0; wndY=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
212 wndWidth=d_width; wndHeight=d_height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
213 dwidth=d_width; dheight=d_height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
214 mFullscreen=fullscreen;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
215
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
216 if ( fullscreen )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
217 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
218 wndWidth=vo_screenwidth;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
219 wndHeight=vo_screenheight;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
220 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
221
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
222 XGetWindowAttributes( mDisplay,DefaultRootWindow( mDisplay ),&attribs );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
223 mDepth=attribs.depth;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
224 if ( mDepth != 15 && mDepth != 16 && mDepth != 24 && mDepth != 32 ) mDepth=24;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
225 XMatchVisualInfo( mDisplay,mScreen,mDepth,TrueColor,&vinfo );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
226 xWAttribs.colormap=XCreateColormap( mDisplay,RootWindow( mDisplay,mScreen ),vinfo.visual,AllocNone );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
227 switch ( vo_depthonscreen )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
228 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
229 case 32:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
230 case 24: fgColor=0x00ff00ffL; break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
231 case 16: fgColor=0xf81fL; break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
232 case 15: fgColor=0x7c1fL; break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
233 default: fprintf( stderr,"Sorry, this (%d) color depth not supported.\n",vo_depthonscreen ); return -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
234 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
235 xWAttribs.background_pixel=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
236 xWAttribs.border_pixel=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
237 xWAttribs.event_mask=StructureNotifyMask | ExposureMask | KeyPressMask;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
238 xswamask=CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
239
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
240 mWindow=XCreateWindow( mDisplay,RootWindow( mDisplay,mScreen ),
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
241 wndX,wndY,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
242 wndWidth,wndHeight,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
243 xWAttribs.border_pixel,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
244 mDepth,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
245 InputOutput,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
246 vinfo.visual,xswamask,&xWAttribs );
384
b0e4e5744899 Autohide X11 cursor
lgb
parents: 340
diff changeset
247 vo_hidecursor(mDisplay,mWindow);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
248
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
249 if ( fullscreen ) vo_x11_decoration( mDisplay,mWindow,0 );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
250
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
251 XGetNormalHints( mDisplay,mWindow,&hint );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
252 hint.x=wndX; hint.y=wndY;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
253 hint.width=wndWidth; hint.height=wndHeight;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
254 hint.base_width=wndWidth; hint.base_height=wndHeight;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
255 hint.flags=USPosition | USSize;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
256 XSetNormalHints( mDisplay,mWindow,&hint );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
257 XStoreName( mDisplay,mWindow,mTitle );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
258
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
259 mGC=XCreateGC( mDisplay,mWindow,GCForeground,&wGCV );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
260
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
261 XMapWindow( mDisplay,mWindow );
182
80a7b40f201a *** empty log message ***
pontscho
parents: 120
diff changeset
262
120
93ea0c6aae7f common window setup code moved to set_window()
arpi_esp
parents: 100
diff changeset
263 set_window();
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
264
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
265 mga_vid_config.src_width=width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
266 mga_vid_config.src_height=height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
267
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
268 mga_vid_config.colkey_on=1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
269 mga_vid_config.colkey_red=255;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
270 mga_vid_config.colkey_green=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
271 mga_vid_config.colkey_blue=255;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
272
56
cdb2e30be421 mga_vid fixes, code cleanup
arpi_esp
parents: 47
diff changeset
273 if(mga_init()) return -1;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
274
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
275 XFlush( mDisplay );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
276 XSync( mDisplay,False );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
277
324
720c640332c8 Szebb es jobb screensaver-kikapcsolo resz
laaz
parents: 213
diff changeset
278 saver_off(mDisplay);
720c640332c8 Szebb es jobb screensaver-kikapcsolo resz
laaz
parents: 213
diff changeset
279
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
280 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
281 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
282
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
283 static const vo_info_t* get_info( void )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
284 { return &vo_info; }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
285
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
286
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
287 static void
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
288 uninit(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
289 {
324
720c640332c8 Szebb es jobb screensaver-kikapcsolo resz
laaz
parents: 213
diff changeset
290 saver_on(mDisplay);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
291 ioctl( f,MGA_VID_OFF,0 );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
292 printf("vo: uninit!\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
293 }