SizeWindow and SetEventTimeout()

Report any Hollywood bugs here
Post Reply
User avatar
lazi
Posts: 382
Joined: Thu Feb 24, 2011 11:08 pm

SizeWindow and SetEventTimeout()

Post by lazi » Mon Sep 12, 2016 11:13 pm

Look at this simple script (tested on OS4 and MOS Peg2/R9250):

Code: Select all

@DISPLAY {sizeable=True}

SetEventTimeout(50)

Function p_sizewindow(msg)
	NPrint(msg.width," x ",msg.height)
EndFunction

InstallEventHandler({sizewindow=p_sizewindow})

Repeat
	WaitEvent
Forever
When the window size reaches an amount, there will be no more SizeWindow events occured.
If the seteventtimeout is increased then the window size is increasing too where still sends SizeWindow events.
If I set SetEventTimeout(50) then the window does not send sizewindow events around and upward 1024x768.

The other thing is that the sizewindow is triggered even when the window size is not changed only the size gadget are clicked.

Solid windows sizing is set in the system.

User avatar
airsoftsoftwair
Posts: 3355
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: SizeWindow and SetEventTimeout()

Post by airsoftsoftwair » Sun Sep 18, 2016 3:52 pm

This looks like normal behaviour to me. You're setting the event timeout to a very low threshold (50 milliseconds) which means that most of the size events will be lost because Hollywood first handles the resizing internally before handling the event in script code and running the internal resize handler often takes longer than 50 milliseconds so your event will be killed because of the low timeout threshold before it is passed to the script.

The other problem you mentioned is a feature, not a bug. The OS sends a resize event when just clicking the size gadget and Hollywood just forwards this event. Hollywood doesn't check if the size has really changed before forwarding the event because that could entail unwanted consequences under certain circumstances which is why Hollywood relies on the OS to only send meaningful resize events and it forwards every resize event it gets from the OS by principle.

User avatar
lazi
Posts: 382
Joined: Thu Feb 24, 2011 11:08 pm

Re: SizeWindow and SetEventTimeout()

Post by lazi » Mon Sep 19, 2016 11:25 pm

Thanks for the clarification!

What can I do to avoid repeating events while the script is busy working on a previous event call?
I have a picture zoomer with mousewheel. I would like to drop the cached mousewheel events while the actual scaling is finished.
Is there a current solution for that?

User avatar
airsoftsoftwair
Posts: 3355
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: SizeWindow and SetEventTimeout()

Post by airsoftsoftwair » Wed Sep 21, 2016 4:26 pm

Hmm, I don't understand the problem here. What do you mean by "I would like to drop the cached mousewheel events while the actual scaling is finished"? The use of "while" is confusing me here :)

PEB
Posts: 280
Joined: Sun Feb 21, 2010 1:28 am

Re: SizeWindow and SetEventTimeout()

Post by PEB » Wed Sep 21, 2016 7:33 pm

"while" should be "until"

Lazi would like to ignore all of the event notifications until the final one (when the mouse wheel stops for a certain length of time).

User avatar
lazi
Posts: 382
Joined: Thu Feb 24, 2011 11:08 pm

Re: SizeWindow and SetEventTimeout()

Post by lazi » Wed Sep 21, 2016 11:04 pm

Thanks PEB, that is more precise.

I have got the idea that it would solve my problem if I can flush event cache when needed.

User avatar
airsoftsoftwair
Posts: 3355
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: SizeWindow and SetEventTimeout()

Post by airsoftsoftwair » Thu Sep 29, 2016 5:52 pm

Ok, now I see what you mean. There is currently no way to flush the event cache and this isn't planned either because it's potentially dangerous since important events could get lost. An alternative would be to implement a selective flush, i.e. the user decides which events should be flushed (e.g. only mousewheel events) but I still don't really like this because it's too low level. I think the best idea would be to add a timestamp to every event that is passed as part of the event message. Then you could just compare the timestamps and simply ignore all mouse wheel events that were generated during scaling. What do you think?

User avatar
Allanon
Posts: 464
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: SizeWindow and SetEventTimeout()

Post by Allanon » Sat Oct 01, 2016 12:28 pm

In few occasions I had the necessity to ignore events generated prior to certain operations, for me the timestamp solution is very nice and clean :)
----------------------------
[Allanon] Fabio Falcucci
AMC - Creative Development // Docs Site // Support Forum
Support me on Patreon for Hollywood libraries!

User avatar
airsoftsoftwair
Posts: 3355
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: SizeWindow and SetEventTimeout()

Post by airsoftsoftwair » Tue Nov 15, 2016 5:00 pm

Code: Select all

- New: All events posted by WaitEvent() or CheckEvent() now contain an additional field in their
  message named "Timestamp"; this contains the timestamp when the event was first received by
  Hollywood's event handler; you can compare this time stamp to the latest time stamp obtained
  through GetTimestamp() and filter old events
- New: Added GetTimestamp() function; this returns the number of seconds that have elapsed since
  Hollywood was started as a fractional number

Post Reply