Page 1 of 1
SizeWindow and SetEventTimeout()
Posted: Mon Sep 12, 2016 11:13 pm
by lazi
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.
Re: SizeWindow and SetEventTimeout()
Posted: Sun Sep 18, 2016 3:52 pm
by airsoftsoftwair
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.
Re: SizeWindow and SetEventTimeout()
Posted: Mon Sep 19, 2016 11:25 pm
by lazi
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?
Re: SizeWindow and SetEventTimeout()
Posted: Wed Sep 21, 2016 4:26 pm
by airsoftsoftwair
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

Re: SizeWindow and SetEventTimeout()
Posted: Wed Sep 21, 2016 7:33 pm
by PEB
"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).
Re: SizeWindow and SetEventTimeout()
Posted: Wed Sep 21, 2016 11:04 pm
by lazi
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.
Re: SizeWindow and SetEventTimeout()
Posted: Thu Sep 29, 2016 5:52 pm
by airsoftsoftwair
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?
Re: SizeWindow and SetEventTimeout()
Posted: Sat Oct 01, 2016 12:28 pm
by Allanon
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

Re: SizeWindow and SetEventTimeout()
Posted: Tue Nov 15, 2016 5:00 pm
by airsoftsoftwair
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