Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!mailrus!purdue!decwrl!hplabs!hp-pcd!hpcvlx!fred
From: fred@hpcvlx.HP.COM (Fred Taft)
Newsgroups: comp.windows.x
Subject: Re: HP's Xtk Fixes (as Context Diffs)
Message-ID: <1610046@hpcvlx.HP.COM>
Date: 19 Aug 88 19:52:01 GMT
References: <1610043@hpcvlx.HP.COM>
Organization: Hewlett-Packard Co., Corvallis, OR, USA
Lines: 67

VERSION:
	Xtk release 2

SYNOPSIS:
	AddForwardingHandler() does not take window borders into
        consideration when checking if cursor is in a window.

DESCRIPTION:
	AddForwardingHandler(), which is part of the input focus
        mechanism within Xtk, does not take window borders into
        consideration when it checks to see if the cursor is already
        in the window to which the focus is being set.  This causes
        the widget to not get the initial FocusIn event, which is also
        generated by AddForwardingHandler().

FIX:

*** Event.c	Fri Aug 19 11:31:15 1988
--- Event.new.c	Fri Aug 19 11:30:57 1988
***************
*** 995,1000
      Boolean might_have_focus = False;
      Boolean had_focus_already = False;
      register XtEventHandler proc = ForwardEvent; /* compiler bug */
  
      /* %%%
         Until we implement a mechanism for propagating keyboard event

--- 995,1001 -----
      Boolean might_have_focus = False;
      Boolean had_focus_already = False;
      register XtEventHandler proc = ForwardEvent; /* compiler bug */
+     int	ul_x,lr_x,ul_y,lr_y;
  
      /* %%%
         Until we implement a mechanism for propagating keyboard event
***************
*** 1044,1051
  	XQueryPointer( XtDisplay(widget), XtWindow(widget),
  		       &root, &child, &root_x, &root_y,
  		       &win_x, &win_y, &mask );
! 	if (win_x >= 0 && win_x < widget->core.width &&
! 	    win_y >= 0 && win_y < widget->core.height) {
  	    had_focus_already = True;
  	}
      }

--- 1045,1064 -----
  	XQueryPointer( XtDisplay(widget), XtWindow(widget),
  		       &root, &child, &root_x, &root_y,
  		       &win_x, &win_y, &mask );
! 
! 	/*
! 	 * The work vars are necessary because the core height
! 	 * and width fields are unsigned, and win_x and win_y
! 	 * may be negative; if they are, then the comparison can
! 	 * fail when it shouldn't. Also, border width needs to
! 	 * be considered.
!   	 */
! 	ul_x = (int ) (0 - widget->core.border_width);
! 	ul_y = (int ) (0 - widget->core.border_width);
! 	lr_x = (int ) (widget->core.width - (widget->core.border_width << 1));
! 	lr_y = (int ) (widget->core.height - (widget->core.border_width << 1));
! 	if ((win_x >= ul_x) && (win_x < lr_x) &&
! 	    (win_y >= ul_y) && (win_y < lr_y)) {
  	    had_focus_already = True;
  	}
      }