View Issue Details

IDProjectCategoryView StatusLast Update
0008576LazarusLCLpublic2019-10-03 14:44
ReporterValdas Jankūnas Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformi386 32bitOSkUbuntu 
Product Version0.9.21 (SVN) 
Target Version1.4 
Summary0008576: After Mini/Maximizing window 'RestoredLeft/Top' values changes to "unreal" values
Description I again about 'RestoredLeft/Top'....

 After Minimize or Maximize the window values 'RetoredTop/Left' changes to not correct values, i think these values is of window position, whet it firstly appear after app execution. When window restored from minimization these values remain same until move or resize window.

 Samples in pics:
 - "before_minimizing.png": window placed near topleft corner, RestoredTop/Left is corect,
 - "when_minimized.png": window minimized, pop up (MessageDlg) displays that RestoredLeft/Top is wrong;
 - "after_restore.png": window restores correct, but RestoredLeft/Top remains same- incorrect;

 Sample (old) test app source attached.
Tagspatch
Fixed in Revisionr46292
LazTarget1.4
WidgetsetGTK, GTK 2
Attached Files

Relationships

related to 0015069 closedZeljan Rikalo Hide/Show changes window position 
related to 0021119 resolvedZeljan Rikalo When a form is started as wsMaximized height and width report design time values 
related to 0030281 closedOndrej Pokorny Moved is called for already destroyed form an produces AV 
related to 0036127 resolvedJuha Manninen [Patch] TForm's bounds and restored bounds are inconsistent 

Activities

Vincent Snijders

2007-03-26 19:52

manager   ~0012004

There are no files attached.

2007-03-26 20:16

 

Archyvas.zip (3,740 bytes)

Valdas Jankūnas

2007-03-26 20:16

reporter   ~0012005

Oops

2007-03-26 20:17

 

before_minimizing.png (95,607 bytes)   
before_minimizing.png (95,607 bytes)   

2007-03-26 20:19

 

when_minimized.png (5,531 bytes)   
when_minimized.png (5,531 bytes)   

2007-03-26 20:20

 

after_restore.png (48,797 bytes)   
after_restore.png (48,797 bytes)   

Brett

2008-11-11 04:22

reporter   ~0023298

I was just about to file a bug on this myself and found this report. I'd like to add that that this bug does not seem to be present on Linux for me (GKT1 or 2), I can only get it to occur on Windows (XP SP3). And it is present in Lazarus 0.9.26.

I've also attached my own sample app demonstrating it.

2008-11-11 04:23

 

Valdas Jankūnas

2009-11-29 01:35

reporter   ~0032567

This bug also exist in gtk2 (Lazarus r22855, Kubuntu 9.10 32bit)

samuel herzog

2010-02-27 13:49

developer   ~0034831

This problem seems to be fixed. Could not reproduce this issue on winXP sp3 with today's version SVN23799.

Zeljan Rikalo

2010-02-27 15:36

developer   ~0034832

But this bug exists on linux (gtk & gtk2), so it's not fixed.

samuel herzog

2010-02-27 16:41

developer   ~0034835

I read the comment from Brett (2008.11.11).
He says that he could not reproduce this problem on GTK1 and GTK2, but he coud reproduce the problem on winxp sp3.
So I retested on winxp sp3 and could not reproduce it anymore.

Zeljan Rikalo

2010-03-30 10:12

developer   ~0036277

Please retest with r >= 24291 (gtk2).(from your example I always see "Everything is fine").

Valdas Jankūnas

2010-04-02 19:10

reporter   ~0036408

Last edited: 2010-04-22 18:58

Tested with svn 24371

Bug still here:
- start demo app, maximize: pos = screen center;
- restore, move to topleft corner of desktop, maximize: pos still = screen center;
- restore, move to another pos (not necessary), maximize: now pos = topleft corner of desktop.

In short: when window is maximized, Restored* holds values memorized before one-step-back maximization.

P.S. Autosize function of Labels not work (Gtk2, Qt)

P.S. In Qt widgetset Restored values after maximization shows current pos and dim of window

Bart Broersma

2011-01-06 14:45

developer   ~0044943

I cannot reproduce this in Linux/GTK2 (r28871).
Maybe it's fixed by r25519 (for issue 0015069)?

Valdas Jankūnas

2011-01-26 22:47

reporter   ~0045501

Tested with svn v29207 in gtk2 ws (Kubuntu 10.10) - bug still there, in additional now is no matter where You place app window before maximization - after maximization restored* values ALWAYS stays same: pos and size when app window appears first time when app executed.

Stephano

2011-01-26 23:40

developer   ~0045502

I can confirm the behaviour.

When the form is maximized and even restored, TForm.RestoredLeft and RestoredTop hold wrong values. If the form is restored, it is enough to nudge it in order to have correct values again.

Lazarus 0.9.31 r29162 FPC 2.4.2 i386-linux-gtk 2

Ubuntu 10.04

Zeljan Rikalo

2012-02-04 12:45

developer   ~0056367

Postponed, not blocker - depends on gtk2lcl implementation.

Yury Plashenkov

2013-03-06 18:02

reporter   ~0066072

I can confirm the bug. Encountered on Windows 7 x64.

When form is in normal state, everything is okay, but when it is maximized, RestoredLeft/Top contain wrong values.

Yuichiro Takahashi

2013-10-24 11:21

reporter  

RestoredRect.patch (3,693 bytes)   
Index: lcl/forms.pp
===================================================================
--- lcl/forms.pp	(revision 43301)
+++ lcl/forms.pp	(working copy)
@@ -458,14 +458,13 @@
     function GetEffectiveShowInTaskBar: TShowInTaskBar;
     function GetMonitor: TMonitor;
     function GetPixelsPerInch: Longint;
-    function GetRestoredLeft: integer;
-    function GetRestoredTop: integer;
     function IsAutoScrollStored: Boolean;
     function IsForm: Boolean;
     function IsIconStored: Boolean;
     procedure CloseModal;
     procedure FreeIconHandles;
     procedure IconChanged(Sender: TObject);
+    procedure Moved(Data: PtrInt);
     procedure SetActive(AValue: Boolean);
     procedure SetActiveControl(AWinControl: TWinControl);
     procedure SetActiveDefaultControl(AControl: TControl);
@@ -489,6 +488,7 @@
     procedure WMActivate(var Message : TLMActivate); message LM_ACTIVATE;
     procedure WMCloseQuery(var message: TLMessage); message LM_CLOSEQUERY;
     procedure WMHelp(var Message: TLMHelp); message LM_HELP;
+    procedure WMMove(var Message: TLMMove); message LM_MOVE;
     procedure WMShowWindow(var message: TLMShowWindow); message LM_SHOWWINDOW;
     procedure WMSize(var message: TLMSize); message LM_Size;
     procedure WMWindowPosChanged(var Message: TLMWindowPosChanged); message LM_WINDOWPOSCHANGED;
@@ -688,8 +688,8 @@
     property ParentFont default False;
     property PixelsPerInch: Longint read GetPixelsPerInch write FPixelsPerInch stored False;
     property Position: TPosition read FPosition write SetPosition default poDesigned;
-    property RestoredLeft: integer read GetRestoredLeft;
-    property RestoredTop: integer read GetRestoredTop;
+    property RestoredLeft: integer read FRestoredLeft;
+    property RestoredTop: integer read FRestoredTop;
     property RestoredWidth: integer read FRestoredWidth;
     property RestoredHeight: integer read FRestoredHeight;
     property ShowInTaskBar: TShowInTaskbar read FShowInTaskbar write SetShowInTaskBar
Index: lcl/include/customform.inc
===================================================================
--- lcl/include/customform.inc	(revision 43301)
+++ lcl/include/customform.inc	(working copy)
@@ -754,16 +754,29 @@
 
   inherited WMSize(Message);
 
-  if (Message.SizeType and SIZE_RESTORED) > 0 then
+  if (Message.SizeType and not SIZE_SourceIsInterface) = SIZE_RESTORED then
   begin
-    FRestoredLeft := Left;
-    FRestoredTop := Top;
     FRestoredWidth := Width;
     FRestoredHeight := Height;
     //DebugLn('[TCustomForm.WMSize] saving restored bounds ',DbgSName(Self),' ',dbgs(FRestoredWidth),'x',dbgs(FRestoredHeight));
   end;
 end;
 
+procedure TCustomForm.WMMove(var Message: TLMMove);
+begin
+  inherited WMMove(Message);
+  Application.QueueAsyncCall(@Moved, 0)
+end;
+
+procedure TCustomForm.Moved(Data: PtrInt);
+begin
+  if WindowState = wsNormal then
+  begin
+    FRestoredLeft := Left;
+    FRestoredTop := Top;
+  end;
+end;
+
 procedure TCustomForm.WMWindowPosChanged(var Message: TLMWindowPosChanged);
 begin
   if (Parent = nil) and Assigned(Message.WindowPos) and ((Message.WindowPos^.flags and SWP_SourceIsInterface)>0) then
@@ -2282,22 +2295,6 @@
   Result := Screen.MonitorFromWindow(Handle, mdNearest);
 end;
 
-function TCustomForm.GetRestoredLeft: integer;
-begin
-  if WindowState=wsNormal then
-    Result := Left
-  else
-    Result := FRestoredLeft;
-end;
-
-function TCustomForm.GetRestoredTop: integer;
-begin
-  if WindowState=wsNormal then
-    Result := Top
-  else
-    Result := FRestoredTop;
-end;
-
 {------------------------------------------------------------------------------
   TCustomForm Method SetFocusedControl
 
RestoredRect.patch (3,693 bytes)   

Yuichiro Takahashi

2013-10-24 11:21

reporter   ~0070958

You'd try my patch(RestoredRect.patch).

I've tested it in Lazarus 1.0.12, Windows (2000 and 7).

Mike Thompson

2014-09-16 00:04

developer   ~0077291

Last edited: 2014-09-16 00:05

View 2 revisions

Lazarus 1.3/win32/SVN 45863
* On first run, restoredwidth & restoredheight are reported 0. When I click the button, correct values are populated everywhere.
* When I move the form, then minimise, the designed coordinates are displayed in the messagedlg (restoredXXX values)
* When I restore the form - correct values are displayed. When I click button, these values remain unchanged.
* When I maximise, again - design coordinates are displayed - also when I click the button when maximised.

Lazarus 1.2.4/GTK2/Windows
* Identical results.

Attached patch not tested

Juha Manninen

2014-09-22 19:29

developer   ~0077547

I applied and committed the patch from Yuichiro Takahashi.
It seems to fix the error and I did not notice any problems caused by it.
Yet, there may be side effects which I don't understand. For example it uses :
  Application.QueueAsyncCall(@Moved, 0)

Please everybody test and report any possible side effect, either with a new report or by reopening this one.

Issue History

Date Modified Username Field Change
2007-03-26 18:52 Valdas Jankūnas New Issue
2007-03-26 18:52 Valdas Jankūnas Widgetset => GTK
2007-03-26 19:51 Vincent Snijders LazTarget => 1.0
2007-03-26 19:51 Vincent Snijders Status new => acknowledged
2007-03-26 19:52 Vincent Snijders Note Added: 0012004
2007-03-26 20:16 Valdas Jankūnas File Added: Archyvas.zip
2007-03-26 20:16 Valdas Jankūnas Note Added: 0012005
2007-03-26 20:17 Valdas Jankūnas File Added: before_minimizing.png
2007-03-26 20:19 Valdas Jankūnas File Added: when_minimized.png
2007-03-26 20:20 Valdas Jankūnas File Added: after_restore.png
2008-04-24 09:57 Vincent Snijders Target Version => 1.0.0
2008-11-11 04:22 Brett Note Added: 0023298
2008-11-11 04:23 Brett File Added: RestoredTopRestoredLeftBug.zip
2009-11-29 01:35 Valdas Jankūnas Note Added: 0032567
2009-11-29 09:38 Zeljan Rikalo Widgetset GTK => GTK, GTK 2
2010-02-27 13:49 samuel herzog Note Added: 0034831
2010-02-27 15:36 Zeljan Rikalo Note Added: 0034832
2010-02-27 16:41 samuel herzog Note Added: 0034835
2010-03-30 10:12 Zeljan Rikalo Note Added: 0036277
2010-03-30 10:12 Zeljan Rikalo Status acknowledged => feedback
2010-04-02 19:10 Valdas Jankūnas Note Added: 0036408
2010-04-22 18:58 Valdas Jankūnas Note Edited: 0036408
2010-11-02 16:00 Vincent Snijders Status feedback => acknowledged
2011-01-06 14:45 Bart Broersma Note Added: 0044943
2011-01-06 14:45 Bart Broersma Status acknowledged => feedback
2011-01-26 22:47 Valdas Jankūnas Note Added: 0045501
2011-01-26 23:40 Stephano Note Added: 0045502
2012-02-04 12:45 Zeljan Rikalo LazTarget 1.0 => 1.2
2012-02-04 12:45 Zeljan Rikalo Note Added: 0056367
2012-03-13 07:50 Vincent Snijders Target Version 1.0.0 => 1.2.0
2013-03-06 18:02 Yury Plashenkov Note Added: 0066072
2013-10-24 11:21 Yuichiro Takahashi File Added: RestoredRect.patch
2013-10-24 11:21 Yuichiro Takahashi Note Added: 0070958
2014-01-20 13:36 Martin Friebe Target Version 1.2.0 => 1.4
2014-01-20 13:44 Martin Friebe LazTarget 1.2 => 1.4
2014-09-16 00:04 Mike Thompson Note Added: 0077291
2014-09-16 00:05 Mike Thompson Tag Attached: patch
2014-09-16 00:05 Mike Thompson Note Edited: 0077291 View Revisions
2014-09-16 20:28 Juha Manninen Relationship added related to 0021119
2014-09-22 08:08 Juha Manninen Relationship added related to 0015069
2014-09-22 19:20 Juha Manninen Assigned To => Juha Manninen
2014-09-22 19:20 Juha Manninen Status feedback => assigned
2014-09-22 19:29 Juha Manninen Fixed in Revision => r46292
2014-09-22 19:29 Juha Manninen Note Added: 0077547
2014-09-22 19:29 Juha Manninen Status assigned => resolved
2014-09-22 19:29 Juha Manninen Resolution open => fixed
2015-02-16 12:49 Valdas Jankūnas Status resolved => closed
2016-08-01 18:37 Ondrej Pokorny Relationship added related to 0030281
2019-10-03 14:44 Juha Manninen Relationship added related to 0036127