[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

1141.0. "why is XSetInputFocus intermittently failing?" by HANNAH::OSMAN (see HANNAH::IGLOO$:[OSMAN]ERIC.VT240) Wed Jul 19 1989 16:26

    
    I'm getting an intermittent problem with
    
    	XSetInputFocus.
    
    I'm using that procedure when I get "configure notify" events, in order
    to move input focus to my dialogue area whenever it has been newly
    mapped.
    
    Usually it works fine.  However, every once in a while, the program
    "burps" like this:
    
    X error event received from server:  BadMatch - parameter mismatch
      Failed request major op code 42 (X_SetInputFocus)
      Failed request minor op code 0 (if applicable)
      ResourceID 0x40002d in failed request (if applicable)
      Serial number of failed request 6400
      Current serial number in output stream 6440
    
    
    I assume it has something to do with attempting to set input focus
    when the target window has been obscured or something like that ?
    If so, I don't know how to get around that, since such obstruction
    would be by totally unrelated applications.
    
    How can I avoid this error ?
    
    THanks.
    
    /Eric

T.RTitleUserPersonal
Name
DateLines
1141.1LEOVAX::TREGGIARIWed Jul 19 1989 17:2711
You could do this before calling XSetInputFocus:

                    XGetWindowAttributes(XtDisplay(h), h->core.window,
                                       &window_attrs);
                    if (window_attrs.map_state == IsViewable)
 
On the other hand, I would think it would make more sense to look
for MapNotify rather than ConfigureNotify.

Leo

1141.2I have hit this problem as wellLARVAE::BULLARDThu Jul 20 1989 05:059
    I hit a similar problem with XSetInputFocus.In my example I created
    a number of windows and immediately set input focus to them.I then
    got intermittent bad parameter mismatch errors.I posted this in
    note #647 in the RDVAX::X conference.This received no response and
    as it was a customer who found the problem I SPR'ed it.As yet I
    haven't had a response from engineering.    
    
    regards Mark

1141.3GOSOX::RYANDECwindows MailThu Jul 20 1989 08:289
	Like .1 said, you have to either wait for MapNotify, or check the
	mapped state before attempting to set focus. However, even that's
	no guarantee that you won't get the error, because it is possible
	that the window will become unmapped by the time the XSetInputFocus
	reaches it. The only thing to do is to set up an X error handler to
	ignore this error.

	Mike

1141.4DECWIN::FISHERBurns Fisher 381-1466, ZKO3-4/W23Thu Jul 20 1989 14:196
In the case of .2 the problem is almost certainly that they windows have not
actually been mapped yet, since the window manager does the mapping asynchronously
from the request.  I'm not sure if that relates to Eric's problem or not.

Burns

1141.5how does toolkit avoid XSetInputFocus problems?HANNAH::OSMANsee HANNAH::IGLOO$:[OSMAN]ERIC.VT240Thu Jul 20 1989 15:068
    
    Could someone please enlighten us as to how the toolkit itself
    avoids this problem ?
    
    Thanks.
    
    /Eric

1141.6is there non-ugly way to to XSetInputFocus ?HANNAH::OSMANsee HANNAH::IGLOO$:[OSMAN]ERIC.VT240Thu Jul 20 1989 15:1919
    
    I just checked, and I already do the XSetInputFocus in the MapNotify
    event handler.
    
    I'd hate to have to have my own error handler just for this.  For one
    thing, the standard error handler prints out the detailed error
    message.
    
    If I did have my own, is there a way I can call the part that prints
    the detailed message as a subroutine ?
    
    I assume I'd have to use XNextRequest, remember the number, then
    call XSetInputFocus.  But how long would I have to remember the
    number for ?  Maybe I'd need to do some sort of synch or flush ?
    
    This is starting to sound ugly.
    
    /Eric

1141.7Call VtkSetErrorHandler before XtMainLoopDECWIN::KLEINThu Jul 20 1989 17:36100
/* 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 <decw$include/DECwDwtWidgetProg.h>
#include <decw$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);
}

1141.8Why DWT doesn't get error (I think)DECWIN::KLEINThu Jul 20 1989 17:4212
>>    Could someone please enlighten us as to how the toolkit itself
>>    avoids this problem ?

I don't believe that the DWT widgets ever grab focus without having
first received a TAKE_FOCUS client message from the Window Manager.

Waiting for a MapNotify, then grabbing focus, is the best way I can
think of to solve this.  And you still need an error handler.  See
previous reply.

-steve-