Recent

Author Topic: Problem with TForm.ShowModal on Linux  (Read 7246 times)

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Problem with TForm.ShowModal on Linux
« Reply #15 on: March 09, 2019, 11:46:51 pm »
Cerrato,
I did as you requested and, again, it works for me as expected.

Note that in my OS, Ubuntu Mate, the task is not hidden, my taskbar is across the top, from memory on LUbunto its across the bottom. (You are referring to OS taskbar ?)

Now, I am also still not setting my with and height so that it exactly fills the screen. Are you doing that using your own know screen size ? Thats not a great approach, very unportable. But maybe the other things you are doing, like hiding taskbar by forcing it to be covered are also a bit dodgy ? By that I mean its depending on undocumented behaviours, results will vary depending on OS ....

Davo

Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

cerrato

  • New Member
  • *
  • Posts: 10
Re: Problem with TForm.ShowModal on Linux
« Reply #16 on: March 10, 2019, 09:27:02 pm »
Thanks for your help. What you wrote proves to me, that it's probably not a problem with Lazarus/LCL, but with window manager (or something else, but still related to OS, not IDE).

Your tips about width and height of form were obvoius to me, but in this application they really don't matter because code you and I were posting in this thread is sort of PoC, just to show strange and unexpected behavioiur of ShowModal. In real life applications I check resolution of screen and adjust my window size to it (for example by using "width:=screen.width"). As for now, one thing is important - it doesnt't matter, whether size of the window is hard-coded or adjusted to size of the screen. As long as I don't play with Top and Left, ShowModal works fine.

Look at this code - it's final version of my tests. As you can see, I've changed width and height to fit screen size, but as I wrote above, it doesn't change anything.
Code: Pascal  [Select][+][-]
  1.     BorderStyle := bsNone;
  2.     FormStyle := fsSystemStayOnTop;
  3.     Left := 0;
  4.     Top := 0;
  5.     Width := Screen.Width;
  6.     Height := Screen.Height;
When lines 3 and 4 are commented out, ShowModal works properly, but taskbar is still visible on bottom of the screen. And when I uncomment lines setting Top and Left to zero, window is really shown on full screen. but ShowModal stops working - second window is displayed behind main window and I'm not able to bring it to front.

You can see on screenshot attached to this post how application looks, when I don't set Left and Top to 0. The bar at the bottom of screen is OS taskbar. In your last post, you weren't certain to which bar I was referring to ;)
« Last Edit: March 10, 2019, 09:35:13 pm by cerrato »
That game of life is hard to play
I'm gonna lose it anyway
The losing card I'll someday lay
So this is all I have to say

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Problem with TForm.ShowModal on Linux
« Reply #17 on: March 10, 2019, 09:50:48 pm »
About ShowModal behaviour, does it change if you set Form2's PopupParent to Form1 and Form2's PopupMode to pmExplicit?
« Last Edit: March 10, 2019, 09:53:01 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

cerrato

  • New Member
  • *
  • Posts: 10
Re: Problem with TForm.ShowModal on Linux
« Reply #18 on: March 10, 2019, 10:21:09 pm »
@lucamar - I've tried many options, but none of them worked. As far as I remember, playing with  PopupMode and PopupParent gave no result. You can put here some code that works for you, and I'll check it, but I'm afraid that your suggestions won't succeed :(
That game of life is hard to play
I'm gonna lose it anyway
The losing card I'll someday lay
So this is all I have to say

wittbo

  • Full Member
  • ***
  • Posts: 150
Re: Problem with TForm.ShowModal on Linux
« Reply #19 on: March 10, 2019, 10:45:12 pm »
Hallo to all,
I don't have any experience with Lazarus on Linux, but actually I'm getting dubious problems with a very simple dialog form and showmodal on MacOS. Under some conditions it works as expected, others -reproducable- the program hangs with showmodal, third situation there was a setfocus error with a complete separate form.
I will try to make a reduced application to provide for analysis.
And, replacing ShowModal by Show none of these problems appear...
-wittbo-
MBAir with MacOS 10.14.6 / Lazarus 2.2.4
MacStudio with MacOS 13.0.1 / Lazarus 2.2.4

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Problem with TForm.ShowModal on Linux
« Reply #20 on: March 11, 2019, 01:26:28 am »
As far as I remember, playing with  PopupMode and PopupParent gave no result. [...] I'm afraid that your suggestions won't succeed :(

It was just an idea. While reading this thread I remembered having seen recently another similar thread about ShowModal in which the solution rested on the proper use of PopupMode and PopupParent. If that doesn't work for you, sorry. Bad luck. :(


@wittbo,

ShowModal is tricky in that, quite logically, the form/dialog shown modally gets all the application's focus, leaving any other form ... let's say "in limbo". :)  If some problem arises and the modal form isn't correctly closed (or opened!) that may hung your application or cause other problems, but that is a very rare, unusual situation.

Difficult to say more without seeing your code; I'll wait for it.
« Last Edit: March 11, 2019, 01:33:51 am by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

wittbo

  • Full Member
  • ***
  • Posts: 150
Re: Problem with TForm.ShowModal on Linux
« Reply #21 on: March 11, 2019, 04:05:52 pm »
@lucamar. Thank you for your answer.
meanwhile I stripped down my program to the essential functions. It contains three forms:
main, frmDialog, frmTermine.
1.  Click button "Button1"; frmDialog appears correctly; press OK to close.
2.  Click the button with the table symbol; then press OK to close; repeat step 1; errormessage (see attachment)

If I would...
- open frmTermin with ShowModal too, no error    or
- open frmDialog only with Show, no error.
- remove btnOK.SetFocus in frmTermine.FormActivate, no error

It seems, that different opening (Show, ShowModal) of different forms in one application won't work. BTW this is only the case in my MacOS environment, with Windows 10 no problem...
« Last Edit: March 11, 2019, 04:22:02 pm by wittbo »
-wittbo-
MBAir with MacOS 10.14.6 / Lazarus 2.2.4
MacStudio with MacOS 13.0.1 / Lazarus 2.2.4

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Problem with TForm.ShowModal on Linux
« Reply #22 on: March 12, 2019, 05:34:06 am »
OK wittbo, I have tried your demo making both Carbon and Cocoa apps using both Lazarus 2.0.0 and Fixes (2.0.1) and it works fine for me, all four times.

So, what are we doing differently ?

I am using Sierra and building with a 32bit Carbon version of Lazarus in all cases. Both my Lazarus installs are built from source rather than downloaded dmg.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

wittbo

  • Full Member
  • ***
  • Posts: 150
Re: Problem with TForm.ShowModal on Linux
« Reply #23 on: March 12, 2019, 06:23:59 am »
Thanks, Davo, for testing.
It's a real question, what are the differences?
I'm using 2.0.0, not the 2.0.1 fixes.
I will check it this evening (in Germany). I'm not skilled in finding and installing fixes between the regular releases, but I will try it and report afterwards.
-wittbo-
MBAir with MacOS 10.14.6 / Lazarus 2.2.4
MacStudio with MacOS 13.0.1 / Lazarus 2.2.4

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Problem with TForm.ShowModal on Linux
« Reply #24 on: March 12, 2019, 08:04:47 am »
wittbo, I'd encourage you to try fixes but I don't think it will solve your issue. I did not see your problem on 2.0.0 either !

What release of OSX are you using ?  (Obviously a pretty high res screen from your button locations :-)   )

Davo

PS - install fixes ?

You need svn (and, obviously FPC but you have that)
Code: [Select]
svn checkout http://svn.freepascal.org/svn/lazarus/branches/fixes_2_0
cd fixes_2_0
make CPU_TARGET=i386 LCL_PLATFORM=carbon bigide
open startlazarus.app --args "--pcp=~/.fixes_2_0"

Note the --pcp stuff, thats to keep the fixes install from messing with your existing 2.0.0 install.

svn
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

wittbo

  • Full Member
  • ***
  • Posts: 150
Re: Problem with TForm.ShowModal on Linux
« Reply #25 on: March 12, 2019, 09:03:34 pm »
Hallo Dave,

i tried the following combinations (OS version + compiler options):

10.14.3 Mojave
Cocoa      Default   Default   Error
Cocoa      Darwin   X86_64   Error
Cocoa      Darwin   i386      Error
Carbon      Default   Default   No Error   
Carbon      Darwin   X86_64   No Error
Carbon      Darwin   i386      No Error


10.13.6 High Sierra
Cocoa      Default   Default   Error
Cocoa      Darwin   X86_64   Error
Cocoa      Darwin   i386      Error
Carbon      Default   Default   No Error   
Carbon      Darwin   X86_64   No Error
Carbon      Darwin   i386      No Error

So the problem as described can be reproduced with cocoa only; carbon is OK.
In the last minutes i experienced with the svn fixes, I did it the first time, easy install with your tips!
Even with this new version 2.0.1 the problem appears with Cocoa. Perhaps it would be good to report it to bugtracker.
-wittbo-
MBAir with MacOS 10.14.6 / Lazarus 2.2.4
MacStudio with MacOS 13.0.1 / Lazarus 2.2.4

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Problem with TForm.ShowModal on Linux
« Reply #26 on: March 12, 2019, 11:44:08 pm »
...... Perhaps it would be good to report it to bugtracker.

Yep, I agree. Would be nice if we could have a (eg) High Sierra user confirm it but does look like its related to OS. Mention in the bug report you have tried fixes.

Thanks

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

cerrato

  • New Member
  • *
  • Posts: 10
Re: Problem with TForm.ShowModal on Linux
« Reply #27 on: March 22, 2019, 09:32:20 pm »
Funny thing - after upgrading Lazarus to version 2.0.0 everything seems to work OK, ShowModal on Linux does exactly what it is supposed to do. I don't know if it is coincidence or maybe something in LCL has been fixed... anyway, for now my problem seems to be gone.

Thanks you all for your help :)
That game of life is hard to play
I'm gonna lose it anyway
The losing card I'll someday lay
So this is all I have to say

 

TinyPortal © 2005-2018