Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Toggle button in overlay: problem

0 views
Skip to first unread message

Joseph Hindin

unread,
Feb 26, 1995, 9:58:35 AM2/26/95
to
The following program doesn't work properly on IRIX 5.x.
When I give X Intrinsic options like "-bg" or "-fg",
it exits with message
Subject: Toggle button in overlay: problem
Newsgroups: comp.sys.sgi.bugs
Summary:
Keywords:

The following program doesn't work properly on IRIX 5.x.
When I give X Intrinsic options like "-bg" or "-fg",
it exits with message:

Warning:
Cannot allocate colormap entry for default background

X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 91 (X_QueryColors)
Value in failed request: 0x7
Serial number of failed request: 60
Current serial number in output stream: 60

What is the strangest thing, specifying background
with -xrm "*background: red" works!

On IRIX 4.x problem doesn't happen.


----------- Start of program -----------
#include <Xm/Xm.h>
#include <Xm/ToggleB.h>


#include <X11/Xmd.h>

#include <stdio.h>

typedef struct _overlayData {
CARD32 visualid;
CARD32 transparent_type;
CARD32 value;
CARD32 layer;
} overlayData;


int findOverlayVisual(Display *dpy,XVisualInfo *vi);

XtAppContext appContext;
Display *display;

int main(int argc,char **argv)
{
Colormap ovrlColormap;
XVisualInfo visualInfo;

Widget button,shell,rowColumn,gfx;

XtToolkitInitialize();
appContext = XtCreateApplicationContext();

display = XtOpenDisplay(appContext, NULL, "example", "Example",
0, 0, &argc, argv);


if (!display) {
XtWarning("Robcad : can't open display, exiting...");
exit(0);
}


if (findOverlayVisual(display,&visualInfo) && !getenv("EXAMPLE_NO_OVERLAY")) {
ovrlColormap = XCreateColormap(display,
DefaultRootWindow(display),
visualInfo.visual,
AllocNone);

shell = XtVaAppCreateShell("example","Example",
applicationShellWidgetClass,
display,
XmNcolormap,ovrlColormap,
XmNdepth,visualInfo.depth,
XmNvisual,visualInfo.visual,
0);
} else {
shell = XtVaAppCreateShell("example","Example",
applicationShellWidgetClass,
display,
0);
}


button = XtVaCreateManagedWidget("button",
xmToggleButtonWidgetClass,
shell,
XmNlabelString,
XmStringCreateLtoR("Push me",(XmStringCharSet) XmSTRING_DEFAULT_CHARSET),
0);


XtRealizeWidget(shell);
XtAppMainLoop(appContext);
}


int findOverlayVisual(Display *dpy,XVisualInfo *vi)
{
Atom ServerOverlayVisual = XInternAtom(dpy,"SERVER_OVERLAY_VISUALS", False);
Atom actualType;
int overlayData_size32,actualFormat,dummy,n_visuals;
int i;
int first = True;

unsigned long nitems, bytes_after, prop_size;
XVisualInfo template, *visual_info, *current,*lastVisual,*firstVisual;
overlayData *overlay_visuals;

prop_size = 1000;
overlayData_size32 = sizeof(overlayData) / sizeof(CARD32);

if ((XGetWindowProperty(dpy,
RootWindow(dpy, DefaultScreen(dpy)),
ServerOverlayVisual, 0L,
prop_size, False,
ServerOverlayVisual, &actualType,
&actualFormat, &nitems, &bytes_after,
(unsigned char **)&overlay_visuals) != Success) ||
actualType != ServerOverlayVisual ||
actualFormat != 32 ||
nitems < overlayData_size32) {
/* property doesn't exists */
return False;
}
if ( bytes_after != 0 ) {
fprintf(stderr, "warning: SERVER_OVERLAY_VISUALS property was not completely read.");
return False;
}

n_visuals = nitems / overlayData_size32;
if ( n_visuals < 1 )
return False;
/*
* The desired visual is the last one in SERVER_OVERLAY_VISUALS
* having 2-bit PseudoColor and
*
* This assumes that the window manager (4Dwm) is configured
* to use the popup planes (which is the default).
* Such configuration is controled via the 4DWm resource:
* "*SG_visualType: popup"
*/
visual_info = NULL;

firstVisual = lastVisual = 0;
for ( i = 0; i < n_visuals; i++ ) {
template.visualid = overlay_visuals[i].visualid;
template.screen = DefaultScreen(dpy);
template.depth = 2;
template.class = PseudoColor;
current = XGetVisualInfo(dpy,
VisualIDMask | VisualScreenMask |
VisualDepthMask | VisualClassMask,
&template, &dummy);

if ( current ) {
if (first) {
first = FALSE;
firstVisual = current;
} else {
lastVisual = current;
}
}
}
if (lastVisual!=0) {
XFree((char *)overlay_visuals);
*vi = *lastVisual;
return True;
} else { /* Look for 8bit overlay */
for ( i = 0; i < n_visuals; i++ ) {
template.visualid = overlay_visuals[i].visualid;
template.screen = DefaultScreen(dpy);
template.depth = 8;
template.class = PseudoColor;
current = XGetVisualInfo(dpy,
VisualIDMask | VisualScreenMask |
VisualDepthMask | VisualClassMask,
&template, &dummy);


if ( current ) {
*vi = *current;
return True;
}
}
}
return False;
}
-------- End of program -------------

--
Hindin Joseph _ _ _ _ _ _ Tel: (972) 9-594721
Robcad, Ltd |_) | | |_) | |_| | \ Fax: (972) 9-544402
Ha-Galim blvd, 16 | \ |_| |_) |_ | | |_/ E-mail: hindin%rob...@uunet.uu.net
Herzlia, Israel 46733

Gregor Samsa awoke one morning to find himself
transformed into an enormous software defect.

--
Hindin Joseph _ _ _ _ _ _ Tel: (972) 9-594721
Robcad, Ltd |_) | | |_) | |_| | \ Fax: (972) 9-544402
Ha-Galim blvd, 16 | \ |_| |_) |_ | | |_/ E-mail: hindin%rob...@uunet.uu.net
Herzlia, Israel 46733

Gregor Samsa awoke one morning to find himself
transformed into an enormous software defect.


Brian Furtaw

unread,
Apr 18, 1995, 3:00:00 AM4/18/95
to
I have tried this code on my Indy under IRIX 5.3 and it seems to work
fine, what hardware platform are you running on. You probably don't
have enough planes in your overlay buffer to support this operation
under IRIX 5.3, which is why you are getting the "Cannot allocate
colormap entry for default...", hey people change, operating systems
change, everything changes. This is a neat program though, if you tell
me what machine you are running on I can check this out further. Send
me an uname -a, hinv and /usr/gfx/gfxinfo.

Brian
>


0 new messages