mod/maxgui.mod/fltkmaxgui.mod/src/Fl.cxx
void fl_fix_focus() {
#ifdef DEBUG
  puts("fl_fix_focus();");
#endif // DEBUG

  if (Fl::grab()) return; // don't do anything while grab is on.

  // set focus based on Fl::modal() and fl_xfocus
  Fl_Widget* w = fl_xfocus;
  if (w) {
    int saved = Fl::e_keysym;
    if (Fl::e_keysym < (FL_Button + FL_LEFT_MOUSE) ||
        Fl::e_keysym > (FL_Button + FL_RIGHT_MOUSE))
      Fl::e_keysym = 0; // make sure widgets don't think a keystroke moved focus
    while (w->parent()) w = w->parent();
    if (Fl::modal()) w = Fl::modal();
    if (!w->contains(Fl::focus()))
      if (!w->take_focus()) Fl::focus(w);
    Fl::e_keysym = saved;
  } else
    Fl::focus(0);

// MRS: Originally we checked the button state, but a user reported that it
//      broke click-to-focus in FLWM?!?
//  if (!(Fl::event_state() & 0x7f00000 /*FL_BUTTONS*/)) {
  if (!Fl::pushed()) {
    // set belowmouse based on Fl::modal() and fl_xmousewin:
    w = fl_xmousewin;
    if (w) {
      if (Fl::modal()) w = Fl::modal();
      if (!w->contains(Fl::belowmouse())) {
        int old_event = Fl::e_number;
	w->handle(Fl::e_number = FL_ENTER);
	Fl::e_number = old_event;
	if (!w->contains(Fl::belowmouse())) Fl::belowmouse(w);
      } else {
	// send a FL_MOVE event so the enter/leave state is up to date
	Fl::e_x = Fl::e_x_root-fl_xmousewin->x();
	Fl::e_y = Fl::e_y_root-fl_xmousewin->y();
        int old_event = Fl::e_number;
	w->handle(Fl::e_number = FL_MOVE);
	Fl::e_number = old_event;
      }
    } else {
      Fl::belowmouse(0);
      Fl_Tooltip::enter(0);
    }
  }
}
// Update modal(), focus() and other state according to system state,
// and send FL_ENTER, FL_LEAVE, FL_FOCUS, and/or FL_UNFOCUS events.
// This is the only function that produces these events in response
// to system activity.
// This is called whenever a window is added or hidden, and whenever
// X says the focus or mouse window have changed.
Update modal(), focus() and other state according to system state,
and send FL_ENTER, FL_LEAVE, FL_FOCUS, and/or FL_UNFOCUS events.
This is the only function that produces these events in response
to system activity.
This is called whenever a window is added or hidden, and whenever
X says the focus or mouse window have changed.
Update modal () focus () and other state according to system state and send FL_ENTER FL_LEAVE FL_FOCUS and / or FL_UNFOCUS events . This is the only function that produces these events in response to system activity . This is called whenever a window is added or hidden and whenever X says the focus or mouse window have changed .
void fl_fix_focus() {
#ifdef DEBUG
  puts("fl_fix_focus();");
#endif 
  if (Fl::grab()) return; 
  Fl_Widget* w = fl_xfocus;
  if (w) {
    int saved = Fl::e_keysym;
    if (Fl::e_keysym < (FL_Button + FL_LEFT_MOUSE) ||
        Fl::e_keysym > (FL_Button + FL_RIGHT_MOUSE))
      Fl::e_keysym = 0; 
    while (w->parent()) w = w->parent();
    if (Fl::modal()) w = Fl::modal();
    if (!w->contains(Fl::focus()))
      if (!w->take_focus()) Fl::focus(w);
    Fl::e_keysym = saved;
  } else
    Fl::focus(0);
  if (!Fl::pushed()) {
    w = fl_xmousewin;
    if (w) {
      if (Fl::modal()) w = Fl::modal();
      if (!w->contains(Fl::belowmouse())) {
        int old_event = Fl::e_number;
	w->handle(Fl::e_number = FL_ENTER);
	Fl::e_number = old_event;
	if (!w->contains(Fl::belowmouse())) Fl::belowmouse(w);
      } else {
	Fl::e_x = Fl::e_x_root-fl_xmousewin->x();
	Fl::e_y = Fl::e_y_root-fl_xmousewin->y();
        int old_event = Fl::e_number;
	w->handle(Fl::e_number = FL_MOVE);
	Fl::e_number = old_event;
      }
    } else {
      Fl::belowmouse(0);
      Fl_Tooltip::enter(0);
    }
  }
}
void fl_fix_focus ( ) { #ifdef DEBUG puts ( " " ) ; #endif if ( Fl :: grab ( ) ) return ; Fl_Widget * w = fl_xfocus ; if ( w ) { int saved = Fl :: e_keysym ; if ( Fl :: e_keysym < ( FL_Button + FL_LEFT_MOUSE ) || Fl :: e_keysym > ( FL_Button + FL_RIGHT_MOUSE ) ) Fl :: e_keysym = 0 ; while ( w -> parent ( ) ) w = w -> parent ( ) ; if ( Fl :: modal ( ) ) w = Fl :: modal ( ) ; if ( ! w -> contains ( Fl :: focus ( ) ) ) if ( ! w -> take_focus ( ) ) Fl :: focus ( w ) ; Fl :: e_keysym = saved ; } else Fl :: focus ( 0 ) ; if ( ! Fl :: pushed ( ) ) { w = fl_xmousewin ; if ( w ) { if ( Fl :: modal ( ) ) w = Fl :: modal ( ) ; if ( ! w -> contains ( Fl :: belowmouse ( ) ) ) { int old_event = Fl :: e_number ; w -> handle ( Fl :: e_number = FL_ENTER ) ; Fl :: e_number = old_event ; if ( ! w -> contains ( Fl :: belowmouse ( ) ) ) Fl :: belowmouse ( w ) ; } else { Fl :: e_x = Fl :: e_x_root - fl_xmousewin -> x ( ) ; Fl :: e_y = Fl :: e_y_root - fl_xmousewin -> y ( ) ; int old_event = Fl :: e_number ; w -> handle ( Fl :: e_number = FL_MOVE ) ; Fl :: e_number = old_event ; } } else { Fl :: belowmouse ( 0 ) ; Fl_Tooltip :: enter ( 0 ) ; } } }
Update modal(), focus() and other state according to system state,
and send FL_ENTER, FL_LEAVE, FL_FOCUS, and/or FL_UNFOCUS events.
Update modal () focus () and other state according to system state and send FL_ENTER FL_LEAVE FL_FOCUS and / or FL_UNFOCUS events .
// DEBUG // don't do anything while grab is on. // set focus based on Fl::modal() and fl_xfocus // make sure widgets don't think a keystroke moved focus // MRS: Originally we checked the button state, but a user reported that it //      broke click-to-focus in FLWM?!? //  if (!(Fl::event_state() & 0x7f00000 /*FL_BUTTONS*/)) { // set belowmouse based on Fl::modal() and fl_xmousewin: // send a FL_MOVE event so the enter/leave state is up to date