View Issue Details

IDProjectCategoryView StatusLast Update
0037414LazarusLCLpublic2020-09-23 03:44
ReporterJoeny Ang Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version2.1 (SVN) 
Summary0037414: [Patch] GTK2: TGtk2WidgetSet.GetWindowRect() returns wrong origin of an invisible TForm
DescriptionTGtk2WidgetSet.GetWindowRect() returns wrong origin of an invisible TForm if a TLabel is inside a TPanel or TRadioGroup.

gdk_window_get_origin() returns an invalid TPoint if the widget is invisible. If a TLabel is inside a TPanel on the TForm, Widget^.window "somehow" gets initialized, thus the check "not GDK_IS_WINDOW(Widget^.window)" will be FALSE and this will skip the size initialization workaround.
Steps To ReproduceUsing the test project, the form is supposed to be screen centered.
Without the TLabel, the form is properly centered.
TagsNo tags attached.
Fixed in Revisionr63641
LazTarget-
WidgetsetGTK 2
Attached Files

Activities

Joeny Ang

2020-07-24 06:21

reporter  

gtk2-getwindowrect-wrong-for-invisible-tforms.patch (571 bytes)   
--- lcl/interfaces/gtk2/gtk2winapi.inc.63640
+++ lcl/interfaces/gtk2/gtk2winapi.inc
@@ -6293,8 +6293,7 @@
       AForm := TCustomForm(AInfo^.LCLObject);
       if not IsFormDesign(AForm) and (AForm.BorderStyle <> bsNone) and
         not (AForm.FormStyle in [fsMDIChild, fsSplash])
-      and (Gtk2WidgetSet.GetDummyWidgetFrame <> Rect(0, 0, 0, 0)) and
-      not GDK_IS_WINDOW(Widget^.window) then
+      and (Gtk2WidgetSet.GetDummyWidgetFrame <> Rect(0, 0, 0, 0)) then
       begin
         R := AForm.BoundsRect;
         AFrame := Gtk2WidgetSet.GetDummyWidgetFrame;

Juha Manninen

2020-07-24 09:43

developer   ~0124295

Without the patch :
$ ./project1
  create: 710:290 - 500:500
    show: 710:290 - 190:130
activate: 0:0 - 190:130

With the patch :
$ ./project1
  create: 710:290 - 500:500
    show: 865:460 - 190:130
activate: 0:0 - 190:130

Only FormShow indicates a small difference. Is this expected? Which one is correct?

Joeny Ang

2020-07-24 10:24

reporter   ~0124298

Last edited: 2020-07-24 10:30

View 3 revisions

Hi, is your screen resolution 1280x1050? If so, the 2nd one is correct, the window is properly centered (Position=poScreenCenter).

Try increasing the size of the form during design, and run it, the deviation will be more visible.

Now, try removing the TLabel, the form will center properly.

Joeny Ang

2020-07-24 10:49

reporter   ~0124299

Last edited: 2020-07-24 10:50

View 2 revisions

Sorry... I think my description was vague here... :)

I was trying to use TForm's AutoSize with poScreenCenter. At designtime, I don't bother to resize the form to the proper dimensions since AutoSize will do that for me. And it happens that some of my forms does not center properly, and I traced it to TGtk2WidgetSet.GetWindowRect() not giving the correct form origin when there is a TLabel inside a TPanel (when the form is still not visible)

Hope this is clearer. Cheers :)

Juha Manninen

2020-07-24 13:16

developer   ~0124302

Ok, I believe it is correct. Applied, thanks.
BTW, my screen resolution is 1920 * 1080.

Joeny Ang

2020-07-24 16:19

reporter   ~0124305

Ooppss... my bad :)

> show: 865:460 - 190:130
865 + 190 + 865 = 1920
460 + 130 + 460 = 1050 (the missing 30 must be your top or bottom bar)

> activate: 0:0 - 190:130
How come your Top/Left is 0:0? On my machine, onShow and onActivate produce the same rects.

Thanks :)

Issue History

Date Modified Username Field Change
2020-07-24 06:21 Joeny Ang New Issue
2020-07-24 06:21 Joeny Ang File Added: gtk2-getwindowrect-wrong-for-invisible-tforms.patch
2020-07-24 06:21 Joeny Ang File Added: gtk2-getwindowrect-wrong-for-invisible-tforms-test-01.zip
2020-07-24 09:43 Juha Manninen Note Added: 0124295
2020-07-24 10:24 Joeny Ang Note Added: 0124298
2020-07-24 10:28 Joeny Ang Note Edited: 0124298 View Revisions
2020-07-24 10:30 Joeny Ang Note Edited: 0124298 View Revisions
2020-07-24 10:50 Joeny Ang Note Added: 0124299
2020-07-24 10:50 Joeny Ang Note Edited: 0124299 View Revisions
2020-07-24 11:34 Juha Manninen Assigned To => Juha Manninen
2020-07-24 11:34 Juha Manninen Status new => assigned
2020-07-24 13:16 Juha Manninen Status assigned => resolved
2020-07-24 13:16 Juha Manninen Resolution open => fixed
2020-07-24 13:16 Juha Manninen Fixed in Revision => r63641
2020-07-24 13:16 Juha Manninen LazTarget => -
2020-07-24 13:16 Juha Manninen Widgetset GTK 2 => GTK 2
2020-07-24 13:16 Juha Manninen Note Added: 0124302
2020-07-24 16:19 Joeny Ang Note Added: 0124305
2020-09-23 03:44 Joeny Ang Status resolved => closed