[comp.sys.amiga.tech] IDCMP ports

dlleigh@mit-amt.MEDIA.MIT.EDU (Darren L. Leigh) (04/21/88)

This is probably a dumb question and so should probably be answered by
mail, but:

If I have an application that has created a custom screen and I don't
want to open any windows, how do I get an IDCMP port between me and
Intuition?  All the documentation talks about windows and I don't see
a way to do it otherwise.  I just want some mouse moves and gadget
information without cluttering up the world with windows.

Is this possible?  If not, is this why I see gratuitous tiny windows
behind so many applications?

=============================================================================
 Darren Leigh			dlleigh@media-lab.mit.edu
 362 Memorial Dr.               mit-amt!dlleigh
 Cambridge, MA 02139   "Fool, fool, back to the beginning is the rule."

thomson@utah-cs.UUCP (Richard A Thomson) (04/21/88)

In article <2336@mit-amt.MEDIA.MIT.EDU> dlleigh@media-lab.UUCP
	(Darren L. Leigh) writes:
>If I have an application that has created a custom screen and I don't
>want to open any windows, how do I get an IDCMP port between me and
>Intuition?  All the documentation talks about windows and I don't see
>a way to do it otherwise.  I just want some mouse moves and gadget
>information without cluttering up the world with windows.

My best guess is that you should open a BORDERLESS BACKDROP window.  For
all intents and purposes, this would appear like a blank screen to the
user, but you could attach an IDCMP port to it to receive mouse events.
It also has the advantage that if you render into the RastPort of the
window, and not the screen, then any title bar and system gadget refreshes
for the screen won't trash your rendered graphics.  It also allows you
to attach a 'menu' to a screen.  (It's actually attached to the borderless,
backdrop window but the user sees only the screen)

>Is this possible?  If not, is this why I see gratuitous tiny windows
>behind so many applications?

Perhaps these gratuitous tiny windows are the result of poor programming?

> Darren Leigh			dlleigh@media-lab.mit.edu

						-- Rich
-- 
Richard Thomson		3190 MEB, University of Utah, Salt Lake City, UT 84112
thomson@cs.utah.edu	(801) 584-4555: Talk to a machine, they're lonely.

avery@puff.cs.wisc.edu (Aaron Avery) (04/21/88)

In article <2336@mit-amt.MEDIA.MIT.EDU> dlleigh@media-lab.UUCP (Darren L. Leigh) writes:
>If I have an application that has created a custom screen and I don't
>want to open any windows, how do I get an IDCMP port between me and
>Intuition?  All the documentation talks about windows and I don't see
>a way to do it otherwise.  I just want some mouse moves and gadget
>information without cluttering up the world with windows.
>Is this possible?  If not, is this why I see gratuitous tiny windows
>behind so many applications?
 
I believe you are correct about everything. You must have a window to get
Intuition to send you IDCMP messages. Yes, this is probably why you see
gratuitous tiny windows all the time. One of the better ways to do what you 
want is to do what uShow does. It opens a tiny, invisible window consisting
entirely of its close gadget in the upper left corner of its screen. This
gives you a close gadget for your screen, and a window structure with which
to manage IDCMP messages. If you're not sure how to make it invisible, try
BORDERLESS and BACKDROP in the NewWindow's Flags field.

-- 
Aaron Avery (avery@puff.cs.wisc.edu)
	    ({seismo,caip,allegra,harvard,rutgers,ihnp4}!uwvax!puff!avery)

mccarrol@topaz.rutgers.edu (Mark C. Carroll <MC>) (04/21/88)

]If I have an application that has created a custom screen and I don't
]want to open any windows, how do I get an IDCMP port between me and
]Intuition?  All the documentation talks about windows and I don't see
]a way to do it otherwise.  I just want some mouse moves and gadget
]information without cluttering up the world with windows.
]
 Well, you can't do it without windows. But, you can create a backdrop
window. ( I don't remember the exact name - my RKM is at home.
Something like BACKDROP in the window type field) A backdrop window
is invisible, has no gadgets, and is always behind every other window.
So you open the backdrop in your custom screen, and it looks like
there is no window - exactly what you want.

		<MC>
-- 
<MC>=Mark C. Carroll,Rutgers CS Student| I won't wear your white feather
mail to: ARPA: CARROLL@AIM.RUTGERS.EDU | I won't carry your white flag
   UUCP: mccarrol@topaz.rutgers.edu    | I will swear to have no nation
   (backbone)!rutgers!topaz!mccarrol   | But I'm PROUD to hold MY heart

cmcmanis%pepper@Sun.COM (Chuck McManis) (04/22/88)

[Net delays are curious things...]
In article <2336@mit-amt.MEDIA.MIT.EDU> (Darren L. Leigh) writes:
>This is probably a dumb question and so should probably be answered by
>mail, but:

Actually it is a pretty common stumbling block for beginners. I sometimes
wonder how fast new people join this group and need to see this information
again.

>If I have an application that has created a custom screen and I don't
>want to open any windows, how do I get an IDCMP port between me and
>Intuition?  All the documentation talks about windows and I don't see
>a way to do it otherwise.  I just want some mouse moves and gadget
>information without cluttering up the world with windows.

The answer is, you open window the same size as the screen and give it
the attributes BORDERLESS+BACKDROP. This window will be 'invisible' 
because it will be the same color as the screen. (color 0). As it 
turns out, the bitmap data will be the same too, that is you can render
through the screen's RastPort (MyScreen -> RastPort) or the windows
RastPort (MyWindow->RPort) and the data will appear at about the same
place. I say about because if the window is not at coordinate 0,0 on
the screen then the coordinates between the two RastPorts will be 
off by the top left edge of the screen. When I use this configuration
I leave the window on line 1 rather than line 0, that way I can still
drag the screen by selecting it's drag bar. 

The vestigal windows on the workbench are usually the result of a 
friendly C compiler trying to make sure you have a StdOut and StdIn
window to play with. If this isn't open and your program does a printf()
then <boom> Mr. Guru to the rescue. Now in other cases there is no easy
way to tell your application to quit so the small window on the workbench
may be nothing more than a remote close gadget that you monitor to tell
you when to stop. RoboCity which double buffers the display does this. 


--Chuck McManis
uucp: {anywhere}!sun!cmcmanis   BIX: cmcmanis  ARPAnet: cmcmanis@sun.com
These opinions are my own and no one elses, but you knew that didn't you.

dillon@CORY.BERKELEY.EDU (Matt Dillon) (04/22/88)

:This is probably a dumb question and so should probably be answered by
:mail, but:
:
:If I have an application that has created a custom screen and I don't
:want to open any windows, how do I get an IDCMP port between me and
:Intuition?  All the documentation talks about windows and I don't see
:a way to do it otherwise.  I just want some mouse moves and gadget
:information without cluttering up the world with windows.
:
:Is this possible?  If not, is this why I see gratuitous tiny windows
:behind so many applications?

	Well, actually, just one window.  If you make it BORDERLESS,
don't include any system gadgets, and have a NULL title, you'd never see
it... add to that either making it BACKDROP or making TopEdge 1 (depending
on whether you want an invisible 'close' gadget or not).  Also can specify
SIMPLE_REFRESH though it doesn't really matter, and probably also
NOCAREREFRESH so you don't have to bother with refresh revents.  Being
the only window on the screen, it doesn't take any extra memory (just
enough for the Window, Layers, and a few other small structures).

	The sole purpose of the window would be to catch all mouse and 
keyboard activity, and to provide menu's for the screen.  The idea is for
the window to not be noticeable ... obviously not everyone has got it down
to a fine art yet.

	As far as I know, you can not get IDCMP from a screen, only a window.

					-Matt

rap@ardent.UUCP (Rob Peck) (04/23/88)

In article <2336@mit-amt.MEDIA.MIT.EDU>, dlleigh@mit-amt.MEDIA.MIT.EDU (Darren L. Leigh) writes:
> If I have an application that has created a custom screen and I don't
> want to open any windows, how do I get an IDCMP port between me and
> Intuition?  > information without cluttering up the world with windows.
> 
> Is this possible?  If not, is this why I see gratuitous tiny windows
> behind so many applications?

Someone suggested the tiny-window 1x1 pixel as ushow uses, but that won't
do what you wish.  Problem is:  if you click in the custom screen, the
tinywindow is no longer the active one, and its IDCMP won't see much
if any input.  Appropriate solution is to open ONE window, covering the
entire custom screen (except perhaps the screen title bar area perhaps).
Make it BACKDROP and BORDERLESS and it won't take much chip memory because
you will be drawing directly into the SCREEN's bitmap.  The IDCMP
associated with this window gives you the event stream you want.  No
matter where you click in the screen with the mouse, this backdrop
window then remains the active one and continues to feed events to
the IDCMP.   Because it is BACKDROP/BORDERLESS, your user won't see
it and you avoid the "clutter".

The so-called gratuitous tiny windows you see are often a result of
the startup code for workbench-launched applications.  They sometimes
need a place to direct their standard output or standard error --
in the absense of this tiny-window, an output (for whatever reason)
perhaps a printf("cannot find serial.device") would crash the
system if there was no place to send the message.  Of course if a
program treats a workbench startup properly, the program can be linked with
some version of a startup that does not need to open the tiny window.
Code similar to:

	if( started_from_CLI )
		SendErrorToCLI(error);
	else
		UseAnAutoRequestor(error);

Rob Peck				...ihnp4!hplabs!ardent!rap

lel@wuphys.UUCP (Lyle E. Levine) (04/23/88)

In article <1592@puff.cs.wisc.edu> avery@puff.WISC.EDU (Aaron Avery) writes:
->In article <2336@mit-amt.MEDIA.MIT.EDU> dlleigh@media-lab.UUCP (Darren L. Leigh) writes:
->>If I have an application that has created a custom screen and I don't
->>want to open any windows, how do I get an IDCMP port between me and
->>Intuition?  All the documentation talks about windows and I don't see
-> 
->I believe you are correct about everything. You must have a window to get
->Intuition to send you IDCMP messages. Yes, this is probably why you see
->gratuitous tiny windows all the time. One of the better ways to do what you 
->want is to do what uShow does. It opens a tiny, invisible window consisting
->entirely of its close gadget in the upper left corner of its screen. This
->gives you a close gadget for your screen, and a window structure with which
->to manage IDCMP messages. If you're not sure how to make it invisible, try
->BORDERLESS and BACKDROP in the NewWindow's Flags field.
->
->-- 
->Aaron Avery (avery@puff.cs.wisc.edu)
->	    ({seismo,caip,allegra,harvard,rutgers,ihnp4}!uwvax!puff!avery)

This is very similar to what I do in the ShowPic() subroutine of my
library.  I put a small invisible window in the upper left corner of
the screen.  I use NO gadgets however.  I use the ACTIVATE flag to
signal me if the window has been clicked in.  If so, I close the
display and exit the subroutine. This seems slightly cleaner and
simpler to me...


==========
IBM is a Division of Sirius Cybernetics Corporation
"their fundamental design flaws are completely hidden by their
superficial design flaws."  
			- "So Long And Thanks For All The Fish"

Lyle Levine: Paths -> ihnp4!wuphys!lel       Best way: (314)889-6379
		      uunet!wucs!wuphys!lel

lel@wuphys.UUCP (Lyle E. Levine) (04/23/88)

In article <538@wuphys.UUCP> lel@wuphys.UUCP (Lyle E. Levine) writes:
>library.  I put a small invisible window in the upper left corner of
>the screen.  I use NO gadgets however.  I use the ACTIVATE flag to
>signal me if the window has been clicked in.  If so, I close the
>display and exit the subroutine. This seems slightly cleaner and
>simpler to me...

Of course, this only works if you don't need an active window on the
screen (obviously a special case).  Should have said this in my first
posting... 

==========
IBM is a Division of Sirius Cybernetics Corporation
"their fundamental design flaws are completely hidden by their
superficial design flaws."  
			- "So Long And Thanks For All The Fish"

Lyle Levine: Paths -> ihnp4!wuphys!lel       Best way: (314)889-6379
		      uunet!wucs!wuphys!lel

hsgj@batcomputer.tn.cornell.edu (Dan Green) (04/23/88)

In article <> (Rob Peck) writes:
>In article <> (Darren L. Leigh) writes:
>> If I have an application that has created a custom screen and I don't
>> want to open any windows, how do I get an IDCMP port between me and
>> Intuition?  > information without cluttering up the world with windows.
>
>Someone suggested the tiny-window 1x1 pixel as ushow uses, but that won't
>do what you wish.  Problem is:  if you click in the custom screen, the
>tinywindow is no longer the active one, and its IDCMP won't see much
>if any input.  Appropriate solution is to open ONE window, covering the
>entire custom screen (except perhaps the screen title bar area perhaps).

An additional point is that you can use a 1x1 pixel window, but make
sure you set the flag (forget the name) that notifies you when you
are no longer  the active window.  I think its (INACTIVE_WINDOW) or
something like that.  Anyways, when you get that message, it means the
user clicked on the screen.  With the message is the mouse X,Y, in case
you need that info.  So then you do an Activate() call to make your
window active again so you can get more IDCMP input.

Please note that everyone will chastize you if you do this sort of
behavior on a screen where windows from other programs exist!  Thus
you can only do this on your own custom screen, which I gather was
the original intent.

-- Dan Green
-- 
ARPA:  hsgj@tcgould.tn.cornell.edu
UUCP:  ihnp4!cornell!batcomputer!hsgj   BITNET:  hsgj@cornella

scott@applix.UUCP (Scott Evernden) (04/27/88)

In article <353@ardent.UUCP> rap@ardent.UUCP (Rob Peck) writes:
>In article <2336@mit-amt.MEDIA.MIT.EDU>, dlleigh@mit-amt.MEDIA.MIT.EDU (Darren L. Leigh) writes:
>> If I have an application that has created a custom screen ...
>> ... how do I get an IDCMP port between me and Intuition? 
>... solution is to open ONE window, ...Make it BACKDROP and BORDERLESS ...
>The IDCMP associated with this window gives you the event stream you want. 

Are there any special considerations when doing double-buffering?

-scott

dpvc@ur-tut (Davide P. Cervone) (05/03/88)

In article <4540@batcomputer.tn.cornell.edu> hsgj@tcgould.tn.cornell.edu (Dan Green) writes:
>An additional point is that you can use a 1x1 pixel window, but make
>sure you set the flag (forget the name) that notifies you when you
>are no longer  the active window.  I think its (INACTIVE_WINDOW) or
>something like that.  Anyways, when you get that message, it means the
>user clicked on the screen.  With the message is the mouse X,Y, in case
>you need that info.  So then you do an Activate() call to make your
>window active again so you can get more IDCMP input.

NO, PLEASE DON'T DO THIS!  This will make it IMPOSSIBLE to select any window
on any other screen!  When you select, say the CLI window, then your program
will get a window-inactive message, and will reactivate your winodw.  The CLI 
will become inactive again, even though the CLI window is on another screen.

The borderless, backdrop approach is the right way to do this.  Let the USER
decide when to activate windows.

>Please note that everyone will chastize you if you do this sort of
>behavior on a screen where windows from other programs exist!  

We'll chastize you wherever you do this!

>Thus
>you can only do this on your own custom screen, which I gather was
>the original intent.

Wrong!  See above.  You should not use this approach even on a custom screen.

>-- Dan Green
>ARPA:  hsgj@tcgould.tn.cornell.edu
>UUCP:  ihnp4!cornell!batcomputer!hsgj   BITNET:  hsgj@cornella

Davide P. Cervone
dpvc@tut.cc.rochester.edu
dpvc@ur-tut.UUCP
DPVC@UORDBV.BITNET 

tada@athena.mit.edu (Michael Zehr) (02/14/89)

Some people have mentioned IDCMP ports lately -- "just open the first
window and use the initialize IDCMP port in it" -- but what if you're
not using Intuition?  I'm creating my own view and viewports.

the amiga ROM manual i've read includes things like -- "if an application
takes control of the machine, and doesn't open intuition, then it can
use the left game port -- otherwise it will be conflicting with the
input.device" 

how can you tell if input.device is running?  does it make a difference
if the program is started with the WB or from a CLI?

any help or pointers to help would be greatly appreciated.

thanks,
michael j zehr

cmcmanis%pepper@Sun.COM (Chuck McManis) (02/15/89)

As Michael begins the journey to becoming Amiga Wizard ...

In article <9246@bloom-beacon.MIT.EDU> (Michael Zehr) writes:
>Some people have mentioned IDCMP ports lately -- "just open the first
>window and use the initialize IDCMP port in it" -- but what if you're
>not using Intuition?  I'm creating my own view and viewports.

IDCMP ports aren't anything fancy, they are just message ports that
Intuition uses to talk to you. If you want a message port, just use
CreatePort() to make one. On the other hand, you can still use
intuition legally while having your own view and viewport, you just
have to make sure that Intuition doesn't remake the display on you.
That is a bit tougher to do though so we'll leave it for a later message.

>the amiga ROM manual i've read includes things like -- "if an application
>takes control of the machine, and doesn't open intuition, then it can
>use the left game port -- otherwise it will be conflicting with the
>input.device" 

This is no longer entirely correct, in fact there is an example by Kodiak
on how to take the mouseport away from intuition. Check out a list of 
programs on the various fish disks or the comp.sys.amiga.sources archive
I believe you will find it there.

>how can you tell if input.device is running?  does it make a difference
>if the program is started with the WB or from a CLI?

When the system boots, input.device is running. Get a copy of the Programmers
Guide to the Amiga by Rob Peck, it has a good description of how the pieces
fit together. Note that there are ways to take over the machine that are
"friendly" and ways that aren't. Generally the one you use is probably 
dependent on how much memory you need versus how much you have. Sometimes
raping the OS for it's memory is the only thing you can do. (But you would
be suprised at how much leeway you get before you have to.)


--Chuck McManis
uucp: {anywhere}!sun!cmcmanis   BIX: cmcmanis  ARPAnet: cmcmanis@sun.com
These opinions are my own and no one elses, but you knew that didn't you.