[Customdrawn] Some patches

Giuliano Colla giuliano.colla at fastwebnet.it
Fri Mar 30 15:20:24 CEST 2012


Il 30/03/2012 14:06, Felipe Monteiro de Carvalho ha scritto:
> Hello,
>
> Some more patch comments:
>
> 1>  TCDX11Timer should be added in customdrawn_x11proc.pas we should
> keep as few as possible stuff in customdrawnint.pas
>
I'll do it ASAP, and send the revised patch. Unless you prefer do it 
yourself. Let me know.
> 2>  Could you explain these 2 changes?
>
> -    XFlush(FDisplay);
> +    //XFlush(FDisplay);
>
Xpending which is called immediately after already performs an XFlush, 
therefore this call is unnecessary. xlib docs say that XFlush is 
normally pretty much useless, as the same function is performed by 
XPending, which is the standard way to check if there are pending messages:

http://tronche.com/gui/x/xlib/event-handling/XFlush.html

Harmless, but just to save an useless call.
>       if XPending(FDisplay)>  0 then Exit; // We have a X message to process
>
> @@ -562,9 +713,25 @@
>       for i := 0 to XConnections.Count-1 do
>         fpFD_SET(cint(PtrInt(XConnections.Items[i])), rfds);
>
> -    selectresult := fpSelect(xconnnum + 1, @rfds, nil, nil, lTimeoutInterval);
> +    selectresult := fpSelect(fpFD_SETSIZE, @rfds, nil, nil, lTimeoutInterval);
>

The nfds parameter for the POSIX function select sets a limit to the set 
numbers which are taken into account (see man select).
If you add other connections to your first one (xconnum), then you 
should put nfds equal to the highest connection number you have (which 
is not necessarily xconnum+1), otherwise some connections will not be 
considered: if you have two forms (as in androidtest), it's likely (but 
not 100% sure) that the connection for the second form will be 
xconnum+1,  but if you open a third form (maybe a dialog, a popup, 
anything), the connection number may be xconnum+2 or more, and you won't 
receive any X message generated on that form.

This parameter becomes important only if you have added (via FD_SET) 
some connections, but
a) you don't want look at them
b) the ones you don't want to see are the highest in number
which is very rarely the case.

In all practical situations it's normal practice to set nfds to a value 
high enough to encompass all your connection numbers, and enable the 
ones you want to check via FD_SET.
Delphi people, in Kylix, provided a default parameter FD_SETSIZE, with 
value 1024, which is good enough for any practical purpose. This 
parameter can still be found in fpc libc, but it has not been replicated 
in BaseUnix, which only includes the macros FD_ZERO and FD_SET. 
Therefore I've added it.

Giuliano





More information about the Customdrawn mailing list