anchor.diff:    KeySym: TKeySym;
     Popup: TfpgWidget;
     status: TStatus;
  +  needToWait: boolean;
   
     // debug purposes only
     procedure PrintKeyEvent(const event: TXEvent);
  
positive.code:       // Poll would be better but FPC has no official poll interface (if I'm right)
        fpFD_ZERO(rfds);
        fpFD_SET(xfd, rfds);
        r := fpSelect(xfd + 1, @rfds, nil, nil, atimeoutms);
  
        if r <= 0 then
          Exit; // no event received.
      end;
      XNextEvent(display, @ev);
    until (not XFilterEvent(@ev, X.None));
    
    // if the event filter returns true then it ate the message
    if Assigned(FEventFilter) and FEventFilter(ev) then
      exit; // no more processing required for that event
  
negative.code:   
  begin
    xfd := XConnectionNumber(display);
    XFlush(display);
  (*
    repeat
  
      if (atimeoutms >= 0) and (XPending(display) < 1) then   { there are no X messages }
      begin
        if Assigned(FOnIdle) then
          OnIdle(self);
  