Recent

Author Topic: Form Events, Mouse Events, slow graphics On cocoa  (Read 4156 times)

Josh

  • Hero Member
  • *****
  • Posts: 1270
Form Events, Mouse Events, slow graphics On cocoa
« on: July 07, 2019, 01:22:05 am »
Hi

Attached is a simple program; to demonstrate a few issues.

The application runs some code during the form create;show and activate events; which will take  a few seconds per event.
It has a cocoa and carbon build option for easy switching; make sure you create the application bundle for proper test.

COmpile for carbon; and run from the IDE, all seems OK, and you can drag a button around.
Note that the ACTIVATE window appears and counts to 100.

Now compile for cocoa.
If RUN from the IDE, you will see the ACTIVATE event count up to 100.
NOW run the APP from the APP Bundle, you will have to wait longer for the form to show; but it does count; it appears after activate has finished.

Also try dragging and dropping any of the buttons; the screen keeps a count of the time the Mouse Down and Mouse Up, Mouse Move events are fired; you will see that in cocoa it is a lot more 'jerky' and the mouse up event is not fired to remove the drag panel. 

Sometimes when compiled for cocoa but not always the poistion of the panels are changed.

Using LAZ 2.1 SVN 61504 X86-64-darwin-cocoa, FPC 3.3.1

The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Josh

  • Hero Member
  • *****
  • Posts: 1270
Re: Form Events, Mouse Events, slow graphics On cocoa
« Reply #1 on: July 09, 2019, 09:27:55 am »
Just updated to Latest SVN Version, and the issue still exists.

Can someone confirm the behaviour, so that I can submit the issues to bugtracker.

Thanks
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Form Events, Mouse Events, slow graphics On cocoa
« Reply #2 on: July 09, 2019, 05:58:51 pm »
please bug report

Josh

  • Hero Member
  • *****
  • Posts: 1270
Re: Form Events, Mouse Events, slow graphics On cocoa
« Reply #3 on: August 15, 2019, 11:03:15 am »
Just updated to Lazarus 61695 and latest FPC 3.1.1, and the issues still exists.
Any progress on the above issues?
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Form Events, Mouse Events, slow graphics On cocoa
« Reply #4 on: August 15, 2019, 02:26:43 pm »
it's a bit complex to resolve. Thanks for the sample.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Form Events, Mouse Events, slow graphics On cocoa
« Reply #5 on: August 15, 2019, 04:14:17 pm »
btw, the latest trunk revision should give you a better mouse handling.

LazProgger

  • Full Member
  • ***
  • Posts: 103
Re: Form Events, Mouse Events, slow graphics On cocoa
« Reply #6 on: August 15, 2019, 04:49:40 pm »
btw, the latest trunk revision should give you a better mouse handling.

It seems as if the mouse click position has wrong coordinates in last trunk for custom controls.

When clicking on the top part, you get coordinates for the bottom.
When clicking on the bottom part, you get coordinates for the top.

It seems as if the coordinates are mirrored.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Form Events, Mouse Events, slow graphics On cocoa
« Reply #7 on: August 15, 2019, 04:51:29 pm »
It seems as if the mouse click position has wrong coordinates in last trunk for custom controls.
...
It seems as if the coordinates are mirrored.
ah...i wonder if that's related to the support of borders.

any lightweight sample? (I'm using TTreeView as an example and it seems to be resolving mouse coordinates just fine)
« Last Edit: August 15, 2019, 04:54:49 pm by skalogryz »

LazProgger

  • Full Member
  • ***
  • Posts: 103
Re: Form Events, Mouse Events, slow graphics On cocoa
« Reply #8 on: August 15, 2019, 04:55:40 pm »
ah...i wonder if that's related to the support of borders.

any lightweight sample?

No, but it's maybe related to the mouse event handling.

I'm on the run that moment, but I can try to create an example later.

That behavior was not there in the official release 2.04.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Form Events, Mouse Events, slow graphics On cocoa
« Reply #9 on: August 15, 2019, 05:01:59 pm »
No, but it's maybe related to the mouse event handling.
The most annoying part of Cocoa (AppKit) is their coordinate system, which goes from the bottom to the top. (just like any other).
Carbon did it the "normal" way  (from top to bottom)
UIKit (iOS) does it the "normal" way (from top to bottom)

CustomControl has been updated recently adding another "layer" into its implementation.
I'd think it adds the interference of some sort causing the mouse coordinates to be reverted again... (as there's a code present to mirror the coordinate from Cocoa to LCL)... hmm...

I'm on the run that moment, but I can try to create an example later.

That behavior was not there in the official release 2.04.
the change for the border support was introduced in trunk. (The change is risky, no matter how to do it. I believe you're experiencing the side-effect)
I can wait for the example.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Form Events, Mouse Events, slow graphics On cocoa
« Reply #10 on: August 15, 2019, 09:02:27 pm »
can't replicate:
Code: Pascal  [Select][+][-]
  1. type
  2.   TMyCustomControl = class(TCustomControl);
  3.  
  4. procedure TForm1.FormCreate(Sender: TObject);
  5. var
  6.   cs : TMyCustomControl;
  7. begin  
  8.   cs := TMyCustomControl.Create(Self);
  9.   cs.Parent:=Self;
  10.   cs.Color:=clBlue;
  11.   cs.BoundsRect:=Bounds(5,5,200,200);
  12.   cs.OnMouseDown:=@Form1MouseDown;
  13.   cs.OnMouseUp:=@Form1MouseUp;
  14.   cs.OnMouseMove:=@Form1MouseMove;  
  15. end;
is showing the proper Y values

LazProgger

  • Full Member
  • ***
  • Posts: 103
Re: Form Events, Mouse Events, slow graphics On cocoa
« Reply #11 on: August 15, 2019, 10:32:56 pm »
Here is my example project.

On Windows, the coordinates are correct.
On macOS, the x-values are correct, the y-values are mirrored.

Is that working for you, too?

PS: I have tested a bit and the error seems to happen in LCLIntf.ScreenToClient(self.handle, p) while X and Y of the MouseDown event are correct.
« Last Edit: August 15, 2019, 10:45:39 pm by LazProgger »

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Form Events, Mouse Events, slow graphics On cocoa
« Reply #12 on: August 16, 2019, 04:14:14 pm »
PS: I have tested a bit and the error seems to happen in LCLIntf.ScreenToClient(self.handle, p) while X and Y of the MouseDown event are correct.
r61705

Josh

  • Hero Member
  • *****
  • Posts: 1270
Re: Form Events, Mouse Events, slow graphics On cocoa
« Reply #13 on: August 21, 2019, 11:07:10 pm »
Hi

Trunk of Lazarus (61741) has fixed the mouse event firing issues.

still exists different behaviour of running from IDE and the app bundle (form activate the form is not shown).

The changing of panels seems to be caused by panel.bringtofront.

I have attached project that has a button that allows you to bringtofront a panel, if clicked you will see the panel jump location.
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Form Events, Mouse Events, slow graphics On cocoa
« Reply #14 on: August 22, 2019, 03:31:15 pm »
still exists different behaviour of running from IDE and the app bundle (form activate the form is not shown).
the reason for this to happen is guessed (macOS compositing engine!), and the cure is unknown.

 

TinyPortal © 2005-2018