mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 04:39:22 +02:00
(Qt): Fixed cpu burning by qtcaret.
git-svn-id: trunk@12198 -
This commit is contained in:
parent
027e9997ff
commit
6fee3feb5e
@ -49,6 +49,7 @@ type
|
|||||||
TEmulatedCaret = class(TComponent)
|
TEmulatedCaret = class(TComponent)
|
||||||
private
|
private
|
||||||
FTimer: TTimer;
|
FTimer: TTimer;
|
||||||
|
FOldRect: TRect;
|
||||||
FWidget: TQtWidget;
|
FWidget: TQtWidget;
|
||||||
FPixmap: QPixmapH;
|
FPixmap: QPixmapH;
|
||||||
FWidth, FHeight: Integer;
|
FWidth, FHeight: Integer;
|
||||||
@ -259,6 +260,8 @@ begin
|
|||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
InitializeCriticalSection(FCritSect);
|
InitializeCriticalSection(FCritSect);
|
||||||
|
|
||||||
|
FOldRect := Rect(0, 0, 1, 1);
|
||||||
|
|
||||||
FTimer := TTimer.Create(self);
|
FTimer := TTimer.Create(self);
|
||||||
FTimer.Enabled := False;
|
FTimer.Enabled := False;
|
||||||
FTimer.Interval := GetCaretBlinkTime;
|
FTimer.Interval := GetCaretBlinkTime;
|
||||||
@ -338,31 +341,11 @@ end;
|
|||||||
|
|
||||||
procedure TEmulatedCaret.SetPos(const Value: TQtPoint);
|
procedure TEmulatedCaret.SetPos(const Value: TQtPoint);
|
||||||
begin
|
begin
|
||||||
if RespondToFocus then
|
if ((FPos.x <> Value.x) or (FPos.y <> Value.y)) then
|
||||||
begin
|
begin
|
||||||
if ((FPos.x <> Value.x) or (FPos.y <> Value.y)) then
|
FPos := Value;
|
||||||
begin
|
if RespondToFocus then
|
||||||
Hide;
|
UpdateCaret;
|
||||||
try
|
|
||||||
FPos := Value;
|
|
||||||
finally
|
|
||||||
Show(FWidget);
|
|
||||||
end;
|
|
||||||
end else
|
|
||||||
FPos := Value;
|
|
||||||
end else
|
|
||||||
begin
|
|
||||||
if FVisible and ((FPos.x <> Value.x) or (FPos.y <> Value.y)) then
|
|
||||||
begin
|
|
||||||
Hide;
|
|
||||||
try
|
|
||||||
FPos := Value;
|
|
||||||
finally
|
|
||||||
Show(FWidget);
|
|
||||||
end;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
FPos := Value;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -442,7 +425,13 @@ begin
|
|||||||
R.Top := FPos.y;
|
R.Top := FPos.y;
|
||||||
R.Right := R.Left + FWidth + 2;
|
R.Right := R.Left + FWidth + 2;
|
||||||
R.Bottom := R.Top + FHeight + 2;
|
R.Bottom := R.Top + FHeight + 2;
|
||||||
FWidget.Update(@R);
|
if FWidget.Context = 0 then
|
||||||
|
begin
|
||||||
|
if not EqualRect(FOldRect, R) then
|
||||||
|
FWidget.Update(@FOldRect);
|
||||||
|
FWidget.Update(@R);
|
||||||
|
end;
|
||||||
|
FOldRect := R;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user