On Tue, 30 Mar 2010, Xavi wrote:

Hi,

> Sometimes GTWVT leaves the previous mark of cursor. Attached picture
> to illustrate the issue.
> This happens because the pre-cursor position not is marked with
> InvalidateRect (RedrawDiff not find differences) getting knocked out
> of WM_PAINT.

So it means that windows sometimes does not clean previous caret when
it's moved to new position. It would be nice to check when it can
happen. Maybe it's result of some other problems in the code, i.e.
it may happen due to wrong focus switching.

> In GTWVG not happen because overwrite PutChar and for each character
> insert call TouchCell and force RedrawDiff to find differences
> although they are the same characters and atributes.
> 
> IMHO is more effective in Windows marking only the previous cursor position.

Yes of course it is more effective.

> I would like to commit the following patch to the repository.

Sorry but it's wrong solution. You talked about efficient solution
and you chose not very good one. This modification causes that
each cursor movement activates screen redrawing without respecting
set cursor off, dispbegin()/dispend() what may strongly reduce the
performance in some applications. It also calls REDRAW() method
just to execute InvalidateRect() but without any preamble/postamble
code which is inside RFRESH()/REDRAWDIFF() methods so it may confuse
some upper level GTs which may inherit from GTWVT.
The last bad side effect of this modification I can see is disabling
late console window activation because now any call to SETPOS() method
will unconditionally force creating new window on next REFRESH() method.

If you want to force overwriting the cursor position then you should
add code to store previous caret position just after ShowCaret().
It would be nice if this saved position can be used to eliminate
unnecessary calls to SetCaretPos(). Then it's enough to add
InvalidateRect() for given character cell position just before
HideCaret(), DestroyCaret() and SetCaretPos(). Instead of using
REDRAW() method you should create your own function, i.e.:

   static void hb_gt_wvt_invalidateChar( PHB_GT pGT, int iRow, int iCol )
   {
      RECT rect;

      rect.top = rect.bottom = iRow;
      rect.left = rect.right = iCol;
      rect = hb_gt_wvt_GetXYFromColRowRect( pWVT, rect );
      InvalidateRect( pWVT->hWnd, &rect, FALSE );
   }

Anyhow I always prefer to detect real reason of problem first to
check if such modification is really necessary and the problem is
not side effect of some other code or bugs.
Otherwise each of us will add some new peaces of code which only
mask real bugs making the whole code hard to understand and extend.

If you want then I can add code which will make caret SetCaretPos()/
ShowCaret() optimization and maybe it will help you to find when the
cursor is wrongly refreshed.

best regards,
Przemek
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to