|
From: Daniel J S. <dan...@ie...> - 2014-03-09 00:31:38
|
At first I thought there was some kind of artifact in the x11.trm code
regarding X11_ymax_saved, and the following related snippets:
/* Dima Kogan Sep 2012: Above is true when generating the plot THE
FIRST
TIME. I now save the sizing information every time the window sizes
change (in the ..._saved variables). Thus I no longer need
to ask for this information NOW, and can just use it.
*/
if (X11_ymax_saved > 0.0) { /* use saved sizes if they're valid */
term->h_char = X11_hchar_saved;
term->v_char = X11_vchar_saved;
term->h_tic = term->v_tic = X11_vchar_saved / 2.5;
term->ymax = X11_ymax_saved;
}
/* Cached sizing values for the x11 terminal.
* Updated/Maintained in mouse.c
*/
int X11_hchar_saved, X11_vchar_saved;
double X11_ymax_saved = -1.0;
Nowhere in x11.trm is X11_ymax_saved set anywhere. But then I saw in
mouse.c the following:
/* EAM FIXME: Despite the name, only X11 uses this to pass font info. */
/* Everyone else passes just the plot height and width. */
if (!strcmp(term->name,"x11")) {
/* These are declared in ../term/x11.trm */
extern int X11_hchar_saved, X11_vchar_saved;
extern double X11_ymax_saved;
/* Cached...
This is a very good example of the code quality issues that Péter
pointed out. Here is a core-level file (mouse.c) that is going to a
terminal file to modify some global variables via "extern". These kinds
of caching things should be kept local to the specific terminal.
[I wonder why
X11_ymax_saved = (double)term->xmax * (double)ge->my /
fabs((double)ge->mx);
is being done in response to a GE_fontprops command. Is GE_fontprops
somehow guaranteed to happen if the user uses the mouse to resize the
X11 window? I then ask if caching the window size actually saves
anything if this code in do_event() is being accessed more than
X11_graphics() is, which in both cases might not be all that often.]
Furthermore, the mouse.c routine is do_event() which is what I called
into question a little over a week ago. Was it the Qt terminal that was
calling this do_event routine directly in a recursive way? And it
seemed to me that Qt terminal didn't really need to do so because the
information it was using was already available to the core code.
I don't think it is worth fixing right now, but grepping for "ifdef X11"
shows up 20 times in a few core files. It would be nice to disentangle
that terminal from the main code.
Dan
|