As so often FPC and LCL work easily on Windows, but on Linux I have endless pain. Again I need your help.
I want to write a little program which shows a PopupNotifier for some seconds, but I don't want to see the Form of the program meanwhile. It should completely hide. I reduced it to a small demo:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, PopupNotifier, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
public
end;
var Form1: TForm1;
implementation
{$R *.lfm}
var PN1: TPopupNotifier;
procedure popNotifyOn(x0,y0, xb,yh: integer; title,msg: ansistring);
{displays a PopupNotifier until popNotifyOff() is called}
begin
PN1:=TPopupNotifier.Create(nil);
PN1.Title:=title;
PN1.Text:=msg;
PN1.Color:=TColor($C0FFFF); {Background-color}
PN1.vNotifierForm.Width:=xb;
PN1.vNotifierForm.Height:=yh;
writeln('ShowAtPos: ', x0, ' / ', y0);
PN1.ShowAtPos(x0,y0);
Application.ProcessMessages;
sleep(2000); // this line is only for testing purposes to demonstrate
end; // that the PopupNotifier is definitely visible
procedure popNotifyOff;
{hides the PopupNotifier which was enabled by popNotifyOn()}
begin
PN1.Hide;
PN1.Free;
end;
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var n: integer;
begin
self.Hide;
Application.ProcessMessages;
// sleep(1500);
popNotifyOn(300,800,300,100, 'Title', 'This is a message');
writeln('Start Loop...'); // deleting this line doesn't help
for n:=1 to 40 do {wait 4 seconds: }
begin
Application.ProcessMessages;
sleep(100);
end;
writeln('Hide PopupNotifier now');
popNotifyOff;
Close;
end;
end.
On Windows everything works perfectly: the Form is hidden (line 57) and the PopupNotifier is displayed (line 40), until popNotifyOff() is called (line 70).
But on Linux the PopupNotifier is visible only for 2 seconds (line 42). As soon as "Start Loop..." is displayed (line 62), the PopupNotifier disappears! So during the following loop (4 seconds) I don't see the PopupNotifier...
What I don't understand: in line 41 Application.ProcessMessages() and sleep() dont't disturb, but in line 66 exactly the same commands hide the PopupNotifier.
I'm on Linux Ubuntu 18.04 and tried with Lazarus 2.0.10 and 2.0.6 and 1.8.4 with all the same result.
What do I do wrong? I attached a compilable demo. Thanks in advance.