bring back configurable X "visual" with --x11-visual=XX
This commit is contained in:
parent
b73090d017
commit
2adba37461
4 changed files with 119 additions and 113 deletions
22
dist/x48ng.man.1
vendored
22
dist/x48ng.man.1
vendored
|
@ -29,7 +29,7 @@
|
|||
.\"
|
||||
.\" $XFree86: xc/programs/xcalc/xcalc.man,v 1.5 2003/03/19 01:49:28 dawes Exp $
|
||||
.\"
|
||||
.de EX \"Begin example
|
||||
.de EX \"Begin example
|
||||
.ne 5
|
||||
.if n .sp 1
|
||||
.if t .sp .5
|
||||
|
@ -91,23 +91,25 @@ where options include:
|
|||
.br
|
||||
\-T \-\-throttle try to emulate real speed (default: false)
|
||||
.br
|
||||
\-\-sdl\-no\-chrome [SDL] only display the LCD (default: false)
|
||||
\-\-sdl\-no\-chrome only display the LCD (default: false)
|
||||
.br
|
||||
\-\-sdl\-fullscreen [SDL] make the UI fullscreen (default: false)
|
||||
\-\-sdl\-fullscreen make the UI fullscreen (default: false)
|
||||
.br
|
||||
\-\-x11\-netbook [X11] make the UI horizontal (default: false)
|
||||
\-\-x11\-netbook make the UI horizontal (default: false)
|
||||
.br
|
||||
\-\-x11\-mono [X11] make the UI monochrome (default: false)
|
||||
\-\-x11\-mono make the UI monochrome (default: false)
|
||||
.br
|
||||
\-\-x11\-gray [X11] make the UI grayscale (default: false)
|
||||
\-\-x11\-gray make the UI grayscale (default: false)
|
||||
.br
|
||||
\-\-x11\-small\-font=<fontname> [X11] use <fontname> as small font
|
||||
\-\-x11\-visual=<X visual> use visual <X visual> (default: default), possible values: <default | staticgray | staticcolor | truecolor | grayscale | pseudocolor | directcolor | 0xnn | nn>
|
||||
.br
|
||||
\-\-x11\-medium\-font=<fontname> [X11] use <fontname> as medium font
|
||||
\-\-x11\-small\-font=<fontname> use <fontname> as small font
|
||||
.br
|
||||
\-\-x11\-large\-font=<fontname> [X11] use <fontname> as large font
|
||||
\-\-x11\-medium\-font=<fontname> use <fontname> as medium font
|
||||
.br
|
||||
\-\-x11\-connection\-font=<fontname> [X11] use <fontname> as connection font
|
||||
\-\-x11\-large\-font=<fontname> use <fontname> as large font
|
||||
.br
|
||||
\-\-x11\-connection\-font=<fontname> use <fontname> as connection font
|
||||
|
||||
.SH DESCRIPTION
|
||||
.I x48ng
|
||||
|
|
|
@ -38,7 +38,10 @@ char* title = "x48ng";
|
|||
char* geometry;
|
||||
/* char* iconGeom; */
|
||||
/* char* iconName; */
|
||||
/* int x11_visual = -1; */
|
||||
char* x11_visual = "default";
|
||||
/* default | staticgray | staticcolor | truecolor | grayscale |
|
||||
* pseudocolor | directcolor | 0xnn | nn
|
||||
*/
|
||||
int mono = 0;
|
||||
int gray = 0;
|
||||
int monoIcon = 0;
|
||||
|
@ -87,6 +90,7 @@ int parse_args( int argc, char* argv[] ) {
|
|||
{ "x11-netbook", no_argument, &netbook, 1 },
|
||||
{ "x11-mono", no_argument, &mono, 1 },
|
||||
{ "x11-gray", no_argument, &gray, 1 },
|
||||
{ "x11-visual", required_argument, NULL, 8110 },
|
||||
{ "x11-small-font", required_argument, NULL, 8111 },
|
||||
{ "x11-medium-font", required_argument, NULL, 8112 },
|
||||
{ "x11-large-font", required_argument, NULL, 8113 },
|
||||
|
@ -129,17 +133,21 @@ int parse_args( int argc, char* argv[] ) {
|
|||
"\t-i --initialize\t\t\tinitialize the content of <config-dir>\n"
|
||||
"\t-r --reset\t\t\tperform a reset on startup\n"
|
||||
"\t-T --throttle\t\t\ttry to emulate real speed (default: false)\n"
|
||||
"\t --sdl-no-chrome\t\t[SDL only] only display the LCD (default: "
|
||||
"\t --sdl-no-chrome\t\tonly display the LCD (default: "
|
||||
"false)\n"
|
||||
"\t --sdl-fullscreen\t\t[SDL only] make the UI fullscreen "
|
||||
"\t --sdl-fullscreen\t\tmake the UI fullscreen "
|
||||
"(default: "
|
||||
"false)\n"
|
||||
"\t --x11-netbook\t\t[X11 only] make the UI horizontal (default: "
|
||||
"\t --x11-netbook\t\tmake the UI horizontal (default: "
|
||||
"false)\n"
|
||||
"\t --x11-mono\t\t\t[X11 only] make the UI monochrome (default: "
|
||||
"\t --x11-mono\t\t\tmake the UI monochrome (default: "
|
||||
"false)\n"
|
||||
"\t --x11-gray\t\t\t[X11 only] make the UI grayscale (default: "
|
||||
"\t --x11-gray\t\t\tmake the UI grayscale (default: "
|
||||
"false)\n"
|
||||
"\t --x11-visual=<X visual>\tuse visual <X visual> (default: "
|
||||
"default), possible values: "
|
||||
"<default | staticgray | staticcolor | truecolor | grayscale | "
|
||||
"pseudocolor | directcolor | 0xnn | nn>\n"
|
||||
"\t --x11-small-font=<X font name>\tuse <X font name> as small "
|
||||
"font (default: %s)\n"
|
||||
"\t --x11-medium-font=<X font name>\tuse <X font name> as medium "
|
||||
|
@ -183,6 +191,9 @@ int parse_args( int argc, char* argv[] ) {
|
|||
case 1015:
|
||||
serialLine = optarg;
|
||||
break;
|
||||
case 8110:
|
||||
x11_visual = optarg;
|
||||
break;
|
||||
case 8111:
|
||||
smallFont = optarg;
|
||||
break;
|
||||
|
|
|
@ -36,7 +36,7 @@ extern char* title;
|
|||
extern char* geometry;
|
||||
/* extern char* iconGeom; */
|
||||
/* extern char* iconName; */
|
||||
/* extern int x11_visual; */
|
||||
extern char* x11_visual;
|
||||
extern int mono;
|
||||
extern int gray;
|
||||
extern int monoIcon;
|
||||
|
|
185
src/ui_x11.c
185
src/ui_x11.c
|
@ -1388,102 +1388,95 @@ static void fatal_exit( char* error, char* advice ) {
|
|||
exit( 1 );
|
||||
}
|
||||
|
||||
/* static Visual* pick_visual_of_class( Display* dpy, int visual_class, */
|
||||
/* unsigned int* depth ) { */
|
||||
/* XVisualInfo vi_in, *vi_out; */
|
||||
/* int out_count; */
|
||||
inline Visual* pick_visual_of_class( Display* dpy, int visual_class,
|
||||
unsigned int* depth ) {
|
||||
XVisualInfo vi_in, *vi_out;
|
||||
int out_count;
|
||||
|
||||
/* vi_in.class = visual_class; */
|
||||
/* vi_in.screen = DefaultScreen( dpy ); */
|
||||
/* vi_out = XGetVisualInfo( dpy, VisualClassMask | VisualScreenMask, &vi_in,
|
||||
*/
|
||||
/* &out_count ); */
|
||||
/* if ( vi_out ) { /\* choose the 'best' one, if multiple *\/ */
|
||||
/* int i, best; */
|
||||
/* Visual* visual; */
|
||||
/* for ( i = 0, best = 0; i < out_count; i++ ) */
|
||||
/* if ( vi_out[ i ].depth > vi_out[ best ].depth ) */
|
||||
/* best = i; */
|
||||
/* visual = vi_out[ best ].visual; */
|
||||
/* *depth = vi_out[ best ].depth; */
|
||||
/* XFree( ( char* )vi_out ); */
|
||||
/* return visual; */
|
||||
/* } else { */
|
||||
/* *depth = DefaultDepth( dpy, DefaultScreen( dpy ) ); */
|
||||
/* return DefaultVisual( dpy, DefaultScreen( dpy ) ); */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
/* static Visual* id_to_visual( Display* dpy, int id, unsigned int* depth ) { */
|
||||
/* XVisualInfo vi_in, *vi_out; */
|
||||
/* int out_count; */
|
||||
|
||||
/* vi_in.screen = DefaultScreen( dpy ); */
|
||||
/* vi_in.visualid = id; */
|
||||
/* vi_out = XGetVisualInfo( dpy, VisualScreenMask | VisualIDMask, &vi_in, */
|
||||
/* &out_count ); */
|
||||
/* if ( vi_out ) { */
|
||||
/* Visual* v = vi_out[ 0 ].visual; */
|
||||
/* *depth = vi_out[ 0 ].depth; */
|
||||
/* XFree( ( char* )vi_out ); */
|
||||
/* return v; */
|
||||
/* } */
|
||||
/* return 0; */
|
||||
/* } */
|
||||
|
||||
static Visual* get_visual_resource( Display* dpy, char* name, char* class,
|
||||
unsigned int* depth ) {
|
||||
/* char c; */
|
||||
/* char *tmp, *s; */
|
||||
/* int vclass; */
|
||||
/* int id; */
|
||||
|
||||
/* s = get_string_resource( name, class ); */
|
||||
/* if ( s ) */
|
||||
/* for ( tmp = s; *tmp; tmp++ ) */
|
||||
/* if ( isupper( *tmp ) ) */
|
||||
/* *tmp = tolower( *tmp ); */
|
||||
|
||||
/* if ( !s || !strcmp( s, "default" ) ) */
|
||||
/* vclass = -1; */
|
||||
/* else if ( !strcmp( s, "staticgray" ) ) */
|
||||
/* vclass = StaticGray; */
|
||||
/* else if ( !strcmp( s, "staticcolor" ) ) */
|
||||
/* vclass = StaticColor; */
|
||||
/* else if ( !strcmp( s, "truecolor" ) ) */
|
||||
/* vclass = TrueColor; */
|
||||
/* else if ( !strcmp( s, "grayscale" ) ) */
|
||||
/* vclass = GrayScale; */
|
||||
/* else if ( !strcmp( s, "pseudocolor" ) ) */
|
||||
/* vclass = PseudoColor; */
|
||||
/* else if ( !strcmp( s, "directcolor" ) ) */
|
||||
/* vclass = DirectColor; */
|
||||
/* else if ( 1 == sscanf( s, " %d %c", &id, &c ) ) */
|
||||
/* vclass = -2; */
|
||||
/* else if ( 1 == sscanf( s, " 0x%x %c", &id, &c ) ) */
|
||||
/* vclass = -2; */
|
||||
/* else { */
|
||||
/* fprintf( stderr, "unrecognized visual \"%s\".\n", s ); */
|
||||
/* vclass = -1; */
|
||||
/* } */
|
||||
/* if ( s ) */
|
||||
/* free( s ); */
|
||||
|
||||
/* if ( vclass == -1 ) { */
|
||||
*depth = DefaultDepth( dpy, DefaultScreen( dpy ) );
|
||||
return DefaultVisual( dpy, DefaultScreen( dpy ) );
|
||||
/* } else if ( vclass == -2 ) { */
|
||||
/* Visual* v = id_to_visual( dpy, id, depth ); */
|
||||
/* if ( v ) */
|
||||
/* return v; */
|
||||
/* fprintf( stderr, "no visual with id 0x%x.\n", id ); */
|
||||
/* *depth = DefaultDepth( dpy, DefaultScreen( dpy ) ); */
|
||||
/* return DefaultVisual( dpy, DefaultScreen( dpy ) ); */
|
||||
/* } else */
|
||||
/* return pick_visual_of_class( dpy, vclass, depth ); */
|
||||
vi_in.class = visual_class;
|
||||
vi_in.screen = DefaultScreen( dpy );
|
||||
vi_out = XGetVisualInfo( dpy, VisualClassMask | VisualScreenMask, &vi_in,
|
||||
&out_count );
|
||||
if ( vi_out ) { /* choose the 'best' one, if multiple */
|
||||
int i, best;
|
||||
Visual* visual;
|
||||
for ( i = 0, best = 0; i < out_count; i++ )
|
||||
if ( vi_out[ i ].depth > vi_out[ best ].depth )
|
||||
best = i;
|
||||
visual = vi_out[ best ].visual;
|
||||
*depth = vi_out[ best ].depth;
|
||||
XFree( ( char* )vi_out );
|
||||
return visual;
|
||||
} else {
|
||||
*depth = DefaultDepth( dpy, DefaultScreen( dpy ) );
|
||||
return DefaultVisual( dpy, DefaultScreen( dpy ) );
|
||||
}
|
||||
}
|
||||
|
||||
static XFontStruct* load_x11_font( Display* dpy, char* fontname ) {
|
||||
inline Visual* id_to_visual( Display* dpy, int id, unsigned int* depth ) {
|
||||
XVisualInfo vi_in, *vi_out;
|
||||
int out_count;
|
||||
|
||||
vi_in.screen = DefaultScreen( dpy );
|
||||
vi_in.visualid = id;
|
||||
vi_out = XGetVisualInfo( dpy, VisualScreenMask | VisualIDMask, &vi_in,
|
||||
&out_count );
|
||||
if ( vi_out ) {
|
||||
Visual* v = vi_out[ 0 ].visual;
|
||||
*depth = vi_out[ 0 ].depth;
|
||||
XFree( ( char* )vi_out );
|
||||
return v;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Visual* get_visual_resource( Display* dpy, unsigned int* depth ) {
|
||||
char c;
|
||||
int vclass;
|
||||
int id;
|
||||
|
||||
if ( !x11_visual || !strcmp( x11_visual, "default" ) )
|
||||
vclass = -1;
|
||||
else if ( !strcmp( x11_visual, "staticgray" ) )
|
||||
vclass = StaticGray;
|
||||
else if ( !strcmp( x11_visual, "staticcolor" ) )
|
||||
vclass = StaticColor;
|
||||
else if ( !strcmp( x11_visual, "truecolor" ) )
|
||||
vclass = TrueColor;
|
||||
else if ( !strcmp( x11_visual, "grayscale" ) )
|
||||
vclass = GrayScale;
|
||||
else if ( !strcmp( x11_visual, "pseudocolor" ) )
|
||||
vclass = PseudoColor;
|
||||
else if ( !strcmp( x11_visual, "directcolor" ) )
|
||||
vclass = DirectColor;
|
||||
else if ( 1 == sscanf( x11_visual, " %d %c", &id, &c ) )
|
||||
vclass = -2;
|
||||
else if ( 1 == sscanf( x11_visual, " 0x%x %c", &id, &c ) )
|
||||
vclass = -2;
|
||||
else {
|
||||
fprintf( stderr, "unrecognized visual \"%s\".\n", x11_visual );
|
||||
vclass = -1;
|
||||
}
|
||||
|
||||
if ( vclass == -1 ) {
|
||||
*depth = DefaultDepth( dpy, DefaultScreen( dpy ) );
|
||||
|
||||
return DefaultVisual( dpy, DefaultScreen( dpy ) );
|
||||
} else if ( vclass == -2 ) {
|
||||
Visual* v = id_to_visual( dpy, id, depth );
|
||||
if ( v )
|
||||
return v;
|
||||
|
||||
fprintf( stderr, "no visual with id 0x%x.\n", id );
|
||||
|
||||
*depth = DefaultDepth( dpy, DefaultScreen( dpy ) );
|
||||
|
||||
return DefaultVisual( dpy, DefaultScreen( dpy ) );
|
||||
} else
|
||||
return pick_visual_of_class( dpy, vclass, depth );
|
||||
}
|
||||
|
||||
XFontStruct* load_x11_font( Display* dpy, char* fontname ) {
|
||||
XFontStruct* f = ( XFontStruct* )0;
|
||||
|
||||
f = XLoadQueryFont( dpy, fontname );
|
||||
|
@ -2938,7 +2931,7 @@ int handle_xerror( Display* the_dpy, XErrorEvent* eev ) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void CreateDispWindow( void ) {
|
||||
void CreateLCDWindow( void ) {
|
||||
XSetWindowAttributes xswa;
|
||||
XGCValues val;
|
||||
unsigned long gc_mask;
|
||||
|
@ -3210,7 +3203,7 @@ int CreateWindows( int argc, char** argv ) {
|
|||
}
|
||||
|
||||
class = InputOutput;
|
||||
visual = get_visual_resource( dpy, "visual", "Visual", &depth );
|
||||
visual = get_visual_resource( dpy, &depth );
|
||||
if ( visual != DefaultVisual( dpy, screen ) ) {
|
||||
if ( visual->class == DirectColor )
|
||||
cmap = XCreateColormap( dpy, RootWindow( dpy, screen ), visual,
|
||||
|
@ -3439,7 +3432,7 @@ int CreateWindows( int argc, char** argv ) {
|
|||
/*
|
||||
* create the display
|
||||
*/
|
||||
CreateDispWindow();
|
||||
CreateLCDWindow();
|
||||
|
||||
/*
|
||||
* create the keypad
|
||||
|
|
Loading…
Reference in a new issue