Page 1 of 1
Intuition input from multiple windows
Posted: Wed Jan 09, 2013 7:22 pm
by trixie
I have a program that uses several "toolbox windows". They all generate Intuition input that I need to process in one place (inside a single event loop). Which would be the best and safest way to go about it:
- To establish a common user IDCMP port and set it via WA_UserPort for all windows, or
- to combine all windows' signal masks into a signal set to Wait() on?
Re: Intuition input from multiple windows
Posted: Wed Jan 09, 2013 7:59 pm
by Rigo
It really depends on how many windows you anticipate having to handle. There are only a limited amount of signals available to each process, and each MsgPort needs one, so there is a good chance that the MsgPort creation might fail if the system has run out of signals.
I would suggest using a common MsgPort for all windows, that's the option I took for CodeBench due to the amount of windows.
Simon
Re: Intuition input from multiple windows
Posted: Wed Jan 09, 2013 8:52 pm
by ssolie
trixie wrote:[*]To establish a common user IDCMP port and set it via WA_UserPort for all windows...
I have had great success with a shared IDCMP port when used with window.class.
Simply invoke WM_HANDLEINPUT on each window object in series after receiving a signal. Everything else is pretty much auto-magic.
Only when you have actual issues with user input events getting lost and/or responsiveness issues would I add the complexity of another MsgPort.
Re: Intuition input from multiple windows
Posted: Wed Jan 09, 2013 9:43 pm
by trixie
@Rigo, ssolie
Thank you both!
ssolie wrote:
Simply invoke WM_HANDLEINPUT on each window object in series after receiving a signal.
And that was going to be my next question: "how do I learn from which window the event was triggered, so that I can call WM_HANDLEINPUT. OK, so the answer is: call the method for each window object there is. Clear.
One last question: before DisposeObject()-ing the windows that use the shared IDCMP port, is it necessary to do any message cleanup?
Re: Intuition input from multiple windows
Posted: Thu Jan 10, 2013 5:43 am
by LyleHaze
The WM_CLOSE method of window class handles that well. From the AutoDoc:
... If the window is sharing a message port with another window the port will be cleaned of messages intended for this Window.
I'd LOVE to know if there is a way to tell which window each message is for, as I am porting older code that did this manually, and the replacement code needs to support the older window styles as well.

Re: Intuition input from multiple windows
Posted: Thu Jan 10, 2013 4:59 pm
by ssolie
LyleHaze wrote:I'd LOVE to know if there is a way to tell which window each message is for, as I am porting older code that did this manually, and the replacement code needs to support the older window styles as well.
Did you consider the IDCMPWindow pointer in the IntuiMessage structure?
Re: Intuition input from multiple windows
Posted: Thu Jan 10, 2013 5:49 pm
by thomasrapp
ssolie wrote:Did you consider the IDCMPWindow pointer in the IntuiMessage structure?
But this is a two step way because the IDCMPWindow pointer pionts to the struct Window and not to the WindowObject. There is no official way to get the object pointer from the window pointer, or is there? You could store the object pointer in the window's UserData field. But this must be maintained manually and reset after each close/iconify. window.class does not maintain this field (WINDOW_UserData is something different and WA_UserData does not seem to exist).
Re: Intuition input from multiple windows
Posted: Thu Jan 10, 2013 7:23 pm
by LyleHaze
Thanks!
I will give this a good try next time I'm working with that app.
Don't know how I missed that the first time anyway, seems clear as can be once it is pointed out to me.
