[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

1880.0. "X-error dependent on icon state" by ULTRA::WRAY (John Wray, Secure Systems Development) Sun Dec 10 1989 17:11

    My application (in response to a button on a pull-down menu) brings up
    a modal file-selection widget.  When this is first created, it is read
    from the UID file, so this takes a few seconds.  If during this time, I
    iconize my shell window, de-iconize it, and iconize it again, then when
    the file-selection widget appears, I see only the widget outline (no
    text) and I get an X-error signalled from the server:
    
    	X error event received from server: BadMatch - parameter mismatch
          Failed request major op code 42 (S_SetInputFocus)
          Failed request minor op code 0 (if applicable)
          ResourceId 0x80004f in failed request (if applicable)
          Serial number of failed request 1207
          Current serial number in output stream 1208
    
    Any ideas as to what's wrong?  Is this likely to be a bug in my
    program, or in the toolkit?
    
    John
T.RTitleUserPersonal
Name
DateLines
1880.1ASTs disabled, tooULTRA::WRAYJohn Wray, Secure Systems DevelopmentMon Dec 11 1989 15:085
    Also, when this condition is signalled (on VMS), user-mode ASTs are
    disabled.  This means that my condition-handler has to be very
    carefully coded to avoid a deadlock.  In particular, I can't do any
    Ada I/O in the condition-handler without locking up the program.
    
1880.2GOSOX::RYANDECwindows MailTue Dec 12 1989 07:5510
	Nothing to do with AST's - you can't set input focus to an
	iconified window. Your file-selection widget must be parented
	to your shell, and been iconified at the time it was mapped
	and the attempt was made to set focus to it. The best way to
	avoid this is to set focus in an event handler for the
	MapNotify event, but even that's no guarantee - you should also
	set up an X error handler which will ignore BadMatch errors
	on X_SetInputFocus.

	Mike
1880.3Call VtkSetErrorHandler before XtMainLoop and you're offDECWIN::KLEINTue Dec 12 1989 12:3799
/* vtkerrorhandler.c

*****************************************************************************
*									    *
*  COPYRIGHT (c) 1989  BY               				    *
*  DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASSACHUSETTS.		    *
*  ALL RIGHTS RESERVED.						    	    *
* 									    *
*  THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED    *
*  ONLY IN  ACCORDANCE WITH  THE  TERMS  OF  SUCH  LICENSE  AND WITH THE    *
*  INCLUSION OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR  ANY  OTHER    *
*  COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY    *
*  OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF  THE  SOFTWARE IS  HEREBY    *
*  TRANSFERRED.							            * 
* 									    *
*  THE INFORMATION IN THIS SOFTWARE IS  SUBJECT TO CHANGE WITHOUT NOTICE    *
*  AND  SHOULD  NOT  BE  CONSTRUED AS  A COMMITMENT BY DIGITAL EQUIPMENT    *
*  CORPORATION.							            *
* 									    *
*  DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE  OR  RELIABILITY OF ITS    *
*  SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL.		    *
*									    *
*****************************************************************************

FACILITY:	FileView
ENVIRONMENT:	DECwindows
AUTHORS:	Steve Klein

	This module contains the replacement XLib error handler for FileView.

MODIFICATION HISTORY:

16-May-1989 (sjk) Remove call to lib$signal, since it adds no information.
15-May-1989 (sjk) Initial entry.
*/

#include "stdio.h"
#include "decw$xlibmsg.h"
#include "MrmAppl.h"
#include "XProto.h"

#define BUFSIZ 256

static void ErrorHandler(dpy, event)
    Display *dpy;
    XErrorEvent *event;
{
    char bufA[BUFSIZ];
    char msgA[BUFSIZ];
    char numberA[32];
    char *mtype = "XlibMessage";

    /* Ignore soft errors. */

    if (
	/* Attempted to assign input focus to a window, but that window was 
	 * iconified at the time the server processed the request. */

        ((event->error_code == BadMatch) &&
         (event->request_code == X_SetInputFocus)) ||

	/* Attempted to select for ButtonPress on the root window, but
	 * another application already has selected for it. */

        ((event->error_code == BadAccess) &&
         (event->request_code == X_ChangeWindowAttributes))) return;

    XGetErrorText (dpy, event->error_code, bufA, BUFSIZ);
    XGetErrorDatabaseText (dpy, mtype, "XError", "X Error", msgA, BUFSIZ);
    fprintf (stderr, "%s:  %s\n  ", msgA, bufA);
    XGetErrorDatabaseText (dpy, mtype, "MajorCode", "Request Major code %d", 
	msgA, BUFSIZ);
    fprintf (stderr, msgA, event->request_code);
    sprintf (numberA, "%d", event->request_code);
    XGetErrorDatabaseText (dpy, "XRequest", numberA, "", bufA, BUFSIZ);
    fprintf (stderr, " (%s)", bufA);
    fputs ("\n  ", stderr);
    XGetErrorDatabaseText (dpy, mtype, "MinorCode", "Request Minor code", 
	msgA, BUFSIZ);
    fprintf (stderr, msgA, event->minor_code);
    fputs ("\n  ", stderr);
    XGetErrorDatabaseText (dpy, mtype, "ResourceID", "ResourceID 0x%x",
	msgA, BUFSIZ);
    fprintf (stderr, msgA, event->resourceid);
    fputs ("\n  ", stderr);
    XGetErrorDatabaseText (dpy, mtype, "ErrorSerial", "Error Serial #%d", 
	msgA, BUFSIZ);
    fprintf (stderr, msgA, event->serial);
    fputs ("\n  ", stderr);
    XGetErrorDatabaseText (dpy, mtype, "CurrentSerial", "Current Serial #%d",
	msgA, BUFSIZ);
    fprintf (stderr, msgA, dpy->request);
    fputs ("\n", stderr);
}

void VtkSetErrorHandler()
{
    XSetErrorHandler (ErrorHandler);
}
1880.4ULTRA::WRAYJohn Wray, Secure Systems DevelopmentTue Dec 12 1989 14:2520
Re .-1
    >	Nothing to do with AST's
    
    	No, I wasn't suggesting that the problem had anything to do with
    ASTs.  However, when the error is raised, user-mode ASTs are disabled,
    which seems like bad practice, since it makes writing a generic
    condition-handler for an application difficult.
    
>	The best way to
>	avoid this is to set focus in an event handler for the
>	MapNotify event, but even that's no guarantee - you should also
>	set up an X error handler which will ignore BadMatch errors
>	on X_SetInputFocus.
    
    If this is required, shouldn't the file-selection widget do it itself?
    After all, it's the widget (not my code) that is doing the
    SetInputFocus.  Probably all modal widgets ought to be prepared for
    this possibility.
    
    John
1880.5GOSOX::RYANDECwindows MailWed Dec 13 1989 08:454
	An X error handler is global to your application - you really don't
	want widgets taking it upon themselves to set up error handlers.

	Mike
1880.6ULTRA::WRAYJohn Wray, Secure Systems DevelopmentWed Dec 13 1989 08:5312
>	An X error handler is global to your application - you really don't
>	want widgets taking it upon themselves to set up error handlers.
    
    True.  This is probably a deficiency in the toolkit itself, in that
    error-handling requirements typically aren't global to the application,
    so the toolkit ought to provide some local (either stack-based or
    widget-based) error-handling functionality.
    
    In this particular case, though, the preferred solution would be for
    the widget to avoid raising the error in the first place.  Is it really
    that difficult for it to check whether it is iconized before it tries
    to SetFocus?
1880.7Can't checkDECWIN::KLEINWed Dec 13 1989 13:1613
>>    In this particular case, though, the preferred solution would be for
>>    the widget to avoid raising the error in the first place.  Is it really
>>    that difficult for it to check whether it is iconized before it tries
>>    to SetFocus?

Actually, it is impossible.  Because of the asynchronous window manager
activity, a check may say "Yes, you're mapped", and by the time the
XSetFocus call is received by the server, the window manager has iconified
the window.

I don't see any way around using an error handler.

-steve
1880.8Nothing is impossible in software!SMURF::JJGJeff GlassWed Dec 27 1989 13:5813
> Actually, it is impossible.  Because of the asynchronous window manager
> activity, a check may say "Yes, you're mapped", and by the time the
> XSetFocus call is received by the server, the window manager has iconified
> the window.

The widget could grab the server, check whether it is mapped, and only if
it is, set the input focus, and then ungrab the server.  Voila--no async
window manager activity.

/jeff

Whether it's a good idea for clients to go around grabbing the server
is another question...