[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

994.0. "please, anyone know how to open a firefox window?" by HANNAH::OSMAN (see HANNAH::IGLOO$:[OSMAN]ERIC.VT240) Wed Jun 21 1989 16:50

    
    We've got our tek4125 emulator for decwindows now in field test.
    
    But we're currently having a crisis I'm hoping one of you can help
    with.
    
    The crisis is that the emulator doesn't work
    on the firefox workstation, but does work on other workstations.
    
    I haven't the slightest idea why, and I'm hoping one of you can give
    me a hint, or point me at someone that might help.
    
    The error is happening where we attempt to open our graphics window.
    
    The error we get is:
    
X error event received from server:  BadMatch - parameter mismatch
Failed request major op code 1
 (X_CreateWindow)
  Failed request minor op code 0 (if applicable)
  ResourceID 0xa00010 in failed request (if applicable)
  Serial number of failed request 669
  Current serial number in output stream 670
    
    
    The offending call is our XCreateWindow call, which works fine
    on other workstations.  Here are the parameters:
    
    argument list:(1)  2102256
                  (2)  10485776
                  (3)  0
                  (4)  0
                  (5)  ABS_VECTOR_MODE+214
                  (6)  ABS_VECTOR_MODE+171
                  (7)  0
                  (8)  ABS_VECTOR_MODE+3
                  (9)  PROMPT_MODE_NEXT_EOM
                  (10)  2104224
                  (11)  26826
                  (12)  STARTUP_X11\x11_gen_start_up\window_attributes.background_pixmap
                  
    
    The source code happens to look like this:
    
register_non_uil_window (x11_graphics_window = XCreateWindow (x11_display,
	x11_graphics_hole, 0, 0, x11_graphics_window_width,
	x11_graphics_window_height, 0,
	x11_visual_info.depth, InputOutput, x11_visual, 
	CWBackingStore | CWColormap | CWBackPixel 
	    | CWBorderPixel | CWBackingPlanes | CWCursor | CWEventMask,
	&window_attributes));
}

    Someone suggested that the problem may have to do with our "x11_visual"
    variable, so in case someone can spot a problem with how we set that
    up, here's the code that does that (about 3 screens long, hang on!) :
    
INTERNAL
void
x11_get_visual ARGLIST ( (vis_name) )
 
LAST_ARG (char		* vis_name)
 
{
REGISTER char		* visual_name;
REGISTER int		visual_depth;
REGISTER int		visual_type;
LOCAL char		name_buffer[80];
REGISTER int		i;
REGISTER Status		stat;
 
visual_name = vis_name;
if (visual_name == NULL) {
    visual_name = GET_ENVIRONMENT_VALUE (ENV_X11_VISUAL);
    }
if (visual_name == NULL) visual_name = DEFAULT_VISUAL;
 
for (i = 0; visual_name[i] != EOS; i++) {
    if (visual_name[i] == ':') break;
    if (isupper(visual_name[i])) {
	name_buffer[i] = _tolower (visual_name[i]);
	}
    else name_buffer[i] = visual_name[i];
    }
 
name_buffer[i] = EOS;
 
visual_depth = (-1);
 
if (visual_name[i] == ':') {
    visual_depth = atoi (visual_name + i + 1);
    }
 
visual_type = (-1);
 
for (i = 0; i < COUNT_OF (x11_visual_type_table); i++) {
    if (strcmp (x11_visual_type_table[i].name, name_buffer) == 0) {
	visual_type = x11_visual_type_table[i].type;
	break;
	}
 
    }
 
if (visual_type == (-1) ) {
    error_string_0 = visual_name;
    report_tek_error (TEK$_BADVISUAL, "XX02");
    visual_type = DEFAULT_VISUAL_TYPE;
    }
 
if (visual_depth != (-1) ) {
    x11_visual_info.visual = (Visual *) 0;
    stat = XMatchVisualInfo (x11_display, x11_screen_number, visual_depth, 
	    visual_type, &x11_visual_info);
    }
 
else {
    stat = False;
    for (visual_depth = MAX_NUMBER_PLANES;	    /* not PlanesOfScreen ! */
	    visual_depth > 0;
	    visual_depth--) {
	x11_visual_info.visual = (Visual *) 0;
	stat = XMatchVisualInfo (x11_display, x11_screen_number, visual_depth,
		visual_type, &x11_visual_info);
#if 0
	if (stat == True) break;
#else
	if (x11_visual_info.visual != (Visual *) 0) break;
#endif
	}
 
    }
 
if (x11_visual_info.visual == (Visual *) 0) {
    x11_visual_info.visual = DefaultVisualOfScreen (x11_screen);
    x11_visual_info.depth = DefaultDepthOfScreen (x11_screen);
    }
 
x11_visual = x11_visual_info.visual;
 
}
    
    
    
    Anyone have any ideas ?  We don't even have a firefox here in Westford,
    so I'm going to have to go to Spitbrook tomorrow to attempt to debug
    this.  Unless one of you has a firefox you'd allow me to define my
    DECW$DISPLAY logical name and debug from remotely ?
    
    Thanks for any info.
    
    /Eric

T.RTitleUserPersonal
Name
DateLines
994.1You need to debug on a Firefox workstationHANNAH::MESSENGERBob MessengerWed Jun 21 1989 20:3712
Re: .0

>    Unless one of you has a firefox you'd allow me to define my
>    DECW$DISPLAY logical name and debug from remotely ?
    
I doubt that would work, Eric: your problem is with the Firefox server, not
the Firefox client.  My guess (without looking at your code, just based on
our earlier conversations) is that your colormap's visual doesn't match the
visual or depth in your XCreateWindow call.

				-- Bob

994.2WSINT::MCLEMANA fine line between bad taste and cleverness.Wed Jun 21 1989 21:265
    re: .0
    
    Remember to inquire the default visual and code accordingly.
    

994.3He can't use the default visualHANNAH::MESSENGERBob MessengerWed Jun 21 1989 21:318
Re: .2

That's the problem: he can't use the default visual on a Firefox because
he needs to be able to write to the color map.  He'd like to use a non-default
visual that supports an 8 plane PseudoColor colormap.

				-- Bob

994.4Here's some code that works on FF.POOL::MARRAActs 2:4Thu Jun 22 1989 09:14195
This may, or may not help, but this is a 'test' that puts a set 
of color bars on the screen on *(hopefully)* any machine.
(At least it works on all of DECs color machines).  It works best without
a window manager.

Check out the section that searches for a visual to use, and notice that
the background pixel must be set as well as the border pixel in order for
the createwindow to work...

You may not want to use this though, it works on both VMS and UNIX 
machines (gasp!).


						.dave.

/****
 *
 *   color_bars.c   A program to generate eight color bars on the server.
 *
 ****/

#include "Xlib.h"
#include "Xatom.h"
#include "Xutil.h"
#include <stdio.h>
#include math;

#define max_error_size 60
#define white 65535
/*
    Handler to report errors.
 */

int error_handler(disp, error_event)

  Display     *disp;
  XErrorEvent *error_event;

  {
    char error_text_buf[max_error_size];

    XGetErrorText(disp, error_event->error_code, error_text_buf, max_error_size);
    printf("\n You received an error packet of '%s'.\n", error_text_buf);
    return(0);
  }


    int    reds[] =   { 65535,     0, 65535,     0, 65535,     0, 65535, 0 };
    int    greens[] = { 65535, 65535,     0,     0, 65535, 65535,     0, 0 };
    int    blues[] =  { 65535, 65535, 65535, 65535,     0,     0,     0, 0 };

    char   *color_names[] = { " White ", " Cyan ", " Magenta ", " Blue ", " Yellow ", 
                              " Green ", " Red ", " Black " };
    char   *PressAnyKey = " Press any key to continue ";

/*
    Body of the program.
 */

main(argc, argv)
int argc;
char **argv;
  {
    char           *display_name;
    Display        *display_arg;
    Colormap       cmap;
    Status         sts;
    unsigned int   ncolors;
    int            inc, x, y, z, Dx, Dy, winX, winY;
    int            number_of_colors = 8;
    GC             gc;
    XGCValues      gcv;
    XColor         xcolors[8];
    XEvent         xevent;
    XFontStruct    *font;
    Window         window_arg;
    long           vinfo_mask;
    XVisualInfo    vinfo_return;
    XVisualInfo    *pVisualInfo,vInfoDummy;
    int            num_items_return, nVis, vinfo_number, ScrNum;
    XSetWindowAttributes xswa;

                                                       
    XSetErrorHandler(error_handler);
                           
    display_name = getenv("DISPLAY");

    if ((display_arg = XOpenDisplay(display_name)) == NULL)
      {
        printf ("\n_Rats! - XOpenDisplay (%s) failed.\n", display_name);
        exit (-1);
      }

    ScrNum = XDefaultScreen(display_arg);
    winX = XWidthOfScreen(XDefaultScreenOfDisplay(display_arg));
    winY = XHeightOfScreen(XDefaultScreenOfDisplay(display_arg));

    sts = XMatchVisualInfo(display_arg, ScrNum, 8, PseudoColor, &vinfo_return);
    if (!sts) 
      {                                                                      
        sts = XMatchVisualInfo(display_arg, ScrNum, 4, PseudoColor, &vinfo_return);
          if (!sts)                                
            {
              printf ("\n - Can't find a visual to use!\n");
              exit (-1);
            }
      }

    vInfoDummy.screen = ScrNum;
    vInfoDummy.class = PseudoColor;
    pVisualInfo = XGetVisualInfo(display_arg, VisualClassMask|VisualScreenMask,
					   	&vInfoDummy,&nVis);


    cmap = XCreateColormap(display_arg, XRootWindow(display_arg, ScrNum),
                           vinfo_return.visual, AllocAll);

    for (x=0; x<number_of_colors; x++)
      {
        xcolors[x].pixel = x;
        xcolors[x].red = reds[x];
        xcolors[x].green = greens[x];
        xcolors[x].blue = blues[x];
        xcolors[x].flags = DoRed|DoGreen|DoBlue;
      }

    XStoreColors (display_arg, cmap, xcolors, number_of_colors);

    xswa.background_pixel = 0;
    xswa.border_pixel = 7;   
    xswa.colormap = cmap;
    window_arg = XCreateWindow(display_arg, XRootWindow(display_arg, ScrNum), 0, 0, winX, winY,
                                     0, vinfo_return.depth, InputOutput, vinfo_return.visual,  
                                     CWBackPixel | CWColormap | CWBorderPixel, &xswa);
    XMapWindow(display_arg, window_arg);
    XInstallColormap(display_arg,cmap);
    XForceScreenSaver(display_arg, ScreenSaverReset);

    gc = XCreateGC (display_arg, window_arg, 0, NULL);
    Dx = winX/number_of_colors;
    Dy = winY;
    x = 0;

    for (inc=0; inc<number_of_colors; inc++)    
      {                                         
        gcv.foreground = inc;     
        gcv.background = 7-inc;   
        XChangeGC(display_arg, gc, GCForeground|GCBackground, &gcv );
        XFillRectangle(display_arg, window_arg,
                       gc, x, 0, Dx, Dy);       
/*
        XDrawImageString(display_arg, window_arg,
          gc, x+(Dx/3), 100+(inc*20), color_names[inc], strlen(color_names[inc]));
*/
        XDrawImageString(display_arg, window_arg, gc,
          x+(Dx/2)-XTextWidth(XQueryFont(display_arg, XGContextFromGC(gc)), color_names[inc], strlen
          100+(inc*20), color_names[inc], strlen(color_names[inc]));

        x+=Dx;                                  
        XSync(display_arg, 0);
      }                                         
  
/***
 *  This next XDrawImageString relies on the background being white and the foreground being 
 *  black as a leftover or the colorbars XDrawImageString.
 ***/

    XDrawImageString(display_arg, 
                     window_arg,
                     gc, 
                     XHeightOfScreen(XDefaultScreenOfDisplay(display_arg))/2, 
                     XWidthOfScreen(XDefaultScreenOfDisplay(display_arg))/3,
/*                       -XTextWidth(XQueryFont(display_arg, gc), PressAnyKey, strlen(PressAnyKey)),
                     PressAnyKey, strlen(PressAnyKey));

    XSync(display_arg, 0);

    XSync(display_arg, 0);
    XMapWindow(display_arg, window_arg);
    XSync(display_arg, 0);
    XForceScreenSaver(display_arg, ScreenSaverReset);
    XSync(display_arg, 0);

    XSelectInput (display_arg, window_arg, KeyPressMask);
    XSync(display_arg, 0);

    XNextEvent (display_arg, &xevent);

/*    XFreeColors (display_arg, cmap, pixels, number_of_colors, 0); */

    XCloseDisplay(display_arg);
    exit(1);
  }

994.5that code example helped me get firefox workingHANNAH::OSMANsee HANNAH::IGLOO$:[OSMAN]ERIC.VT240Mon Jun 26 1989 09:1112
    
    Thanks, that code example assisted me greatly.
    
    I now have XCreateWindow and proper colors working on the firefox.
    
    Unfortunately, now many of my colors come out grey on the 4-plane
    gpx.
    
    So now I have to figure out how to make ALL the systems work.
    
    /Eric