[comp.sys.amiga.programmer] Problems with ReportMouse

schwager@cs.uiuc.edu (Michael Schwager) (01/23/91)

Ok, I'm stumped.  Sheesh, I can't even get a ReportMouse() to work (Workbench 
version 1.3.2 on an A500)!  Here's what I've got:

I set up a NewWindow structure for a backdrop window:

struct NewWindow BackWindowOrig = {
  0,0,                                       /* left edge, top edge */
  SCR_WIDTH,SCR_HEIGHT,                      /* width, height */
  -1, -1,                                    /* detailpen, blockpen */
  VANILLAKEY|CLOSEWINDOW       /* IDCMP flags */
    |MENUPICK|MOUSEBUTTONS|MOUSEMOVE,
    BORDERLESS|WINDOWCLOSE|REPORTMOUSE|
      SMART_REFRESH|BACKDROP, /* Window Flags */
      NULL, /* &MyGadget */ /* Gadget */
      NULL,
      (UBYTE *) NULL,
      NULL,
      NULL,
      0,0,                                          /* smallest size */
      SCR_WIDTH, SCR_HEIGHT,                        /* largest size */
      CUSTOMSCREEN
      };


Then I open up my window:

struct Window *BackWindow = NULL;
if ((BackWindow = (struct Window *) OpenWindow (&BackWindowOrig)) ==
                                                                 NULL){
       shutdown ("Unable to open up background window");
     }

JUST after that, I do this:

ReportMouse (BackWindow, FALSE);

And it fails to un-report mouse events.
If I do this:

ReportMouse (BackWindow, TRUE);

The machine gurus immediately with a memory error.  I'm using Aztec C, v
3.6 (I know, I know, get that upgrade...), Amiga 500 with 3 Meg of RAM,
Supra SCSI interface.

So, do I just need more sleep, or what?  Why can't I toggle mouse
reportage?  Thanks.
-Mike Schwager                             |"Weapons are the tools of fear;
INTERNET:schwager@cs.uiuc.edu              | a decent man will avoid them...
UUCP:{uunet|convex|pur-ee}!uiucdcs!schwager| His enemies are not demons,
BITNET:schwager@mike.cs.uiuc.edu           | but human beings like himself...."
University of Illinois, Dept. of Comp. Sci.|  -Tao Te Ching, chapter 31

jlavin@cie.uoregon.edu (Jeff Lavin) (01/23/91)

In article <1991Jan23.031010.11248@cs.uiuc.edu> schwager@cs.uiuc.edu (Michael Schwager) writes:
>Ok, I'm stumped.  Sheesh, I can't even get a ReportMouse() to work (Workbench 
>version 1.3.2 on an A500)!  Here's what I've got:
>
>I set up a NewWindow structure for a backdrop window:
>
>struct NewWindow BackWindowOrig = {
>  0,0,                                       /* left edge, top edge */
>  SCR_WIDTH,SCR_HEIGHT,                      /* width, height */
>  -1, -1,                                    /* detailpen, blockpen */
>  VANILLAKEY|CLOSEWINDOW       /* IDCMP flags */
>    |MENUPICK|MOUSEBUTTONS|MOUSEMOVE,
>    BORDERLESS|WINDOWCLOSE|REPORTMOUSE|
>      SMART_REFRESH|BACKDROP, /* Window Flags */
>      NULL, /* &MyGadget */ /* Gadget */
>      NULL,
>      (UBYTE *) NULL,
>      NULL,
>      NULL,
>      0,0,                                          /* smallest size */
>      SCR_WIDTH, SCR_HEIGHT,                        /* largest size */
>      CUSTOMSCREEN
>      };
>
[stuff deleted]
>
>So, do I just need more sleep, or what?  Why can't I toggle mouse
>reportage?  Thanks.
>-Mike Schwager                             |"Weapons are the tools of fear;
>INTERNET:schwager@cs.uiuc.edu              | a decent man will avoid them...
>UUCP:{uunet|convex|pur-ee}!uiucdcs!schwager| His enemies are not demons,
>BITNET:schwager@mike.cs.uiuc.edu           | but human beings like himself...."
>University of Illinois, Dept. of Comp. Sci.|  -Tao Te Ching, chapter 31

MOUSEMOVE is an IDCMP flag
REPORTMOUSE is a Window flag

Jeff-

The Puzzle Factory, Inc.  | Jeff Lavin -- jlavin@cie.uoregon.edu
Veneta, Oregon            |-------------------------------------
Voice : (503) 935-3709    | Remainder of signature line
Data  : (503) 935-7883    | under construction.

rosenber@ra.abo.fi (Robin Rosenberg INF) (01/24/91)

In article <1991Jan23.031010.11248@cs.uiuc.edu> schwager@cs.uiuc.edu (Michael Schwager) writes:
>Ok, I'm stumped.  Sheesh, I can't even get a ReportMouse() to work (Workbench 
>version 1.3.2 on an A500)!  Here's what I've got:
[...]
>struct Window *BackWindow = NULL;
>if ((BackWindow = (struct Window *) OpenWindow (&BackWindowOrig)) ==
>                                                                 NULL){
>       shutdown ("Unable to open up background window");
>     }

>JUST after that, I do this:

>ReportMouse (BackWindow, FALSE);

>And it fails to un-report mouse events.
>If I do this:

>ReportMouse (BackWindow, TRUE);

>The machine gurus immediately with a memory error.  I'm using Aztec C, v
>3.6 (I know, I know, get that upgrade...), Amiga 500 with 3 Meg of RAM,
>Supra SCSI interface.

From the FM (RKM)

!SPECIAL NOTE:
!	Some compilers and link files switch the arguments to this function
!	about in unpredictable ways. The call will take one of the two forms:
!
!		ReportMouse(Window, (ULONG)Boolean);
!			--or--
!		ReportMouse(Boolean, Window);
!
!	The Manx Aztec compiler prefers the second form....

----
	Robin

ken@cbmvax.commodore.com (Ken Farinsky - CATS) (01/24/91)

In article <1991Jan23.031010.11248@cs.uiuc.edu> schwager@cs.uiuc.edu (Michael Schwager) writes:
>Ok, I'm stumped.  Sheesh, I can't even get a ReportMouse() to work (Workbench 
>version 1.3.2 on an A500)!  Here's what I've got:
>
>ReportMouse (BackWindow, TRUE);
>
>The machine gurus immediately with a memory error.  I'm using Aztec C, v
>3.6 (I know, I know, get that upgrade...), Amiga 500 with 3 Meg of RAM,
>Supra SCSI interface.
>-Mike Schwager INTERNET:schwager@cs.uiuc.edu

Reading the Autodocs, it seems that Manx likes ReportMouse(Boolean,Window).
Try reversing the order of the args.
-- 
--
Ken Farinsky - CATS - (215) 431-9421 - Commodore Business Machines
uucp: ken@cbmvax.commodore.com   or  ...{uunet,rutgers}!cbmvax!ken
bix:  kfarinsky

schwager@cs.uiuc.edu (Michael Schwager) (01/24/91)

Well, thanks for the responses.  Damn!  The authors of these manuals really 
know how to piss me off.  On p. 54 of the revised RKM, Libs and Devices, 
they say to "Consult your compiler manual for the correct calling sequence."
So I whip it out, and there on p. libamiga.19 it says quite proudly,

void ReportMouse (wind, boolean)
	struct Window *wind; long boolean;

which, as we now know, is incorrect.  I wish these guys would get it together
so my brain wouldn't hurt so much.
-Mike

schwager@cs.uiuc.edu (Michael Schwager) (01/25/91)

Well, dang.  I tried it the new way, and it still wouldn't work.  The only 
thing that would was actually setting the Window's flags.  Which is fine, but
I don't like wild-goose chases.  Ugh.

-Mike

andy@cbmvax.commodore.com (Andy Finkel) (01/26/91)

In article <1991Jan24.220856.1366@cs.uiuc.edu> schwager@cs.uiuc.edu (Michael Schwager) writes:
>Well, dang.  I tried it the new way, and it still wouldn't work.  The only 
>thing that would was actually setting the Window's flags.  Which is fine, but
>I don't like wild-goose chases.  Ugh.
>
>-Mike


The intuition.library has the parameters to ReportMouse defined one way.
However, when you call an Amiga library routine, you are usually not calling
the library directly.  Instead first you go through a stub routine supplied
by your compiler mfgr that pulls the arguments off the stack, and sticks
them in the appropriate register.  In the case of ReportMouse, one of the
compiler mfgrs got it wrong, and had his/her stub routine putting
the arguments in the wrong registers. 

That's why the docs tell you to look in the docs that came with your compiler.

Or you could disassemble your stub and see what its doing, of course.

			andy
-- 
andy finkel		{uunet|rutgers|amiga}!cbmvax!andy
Commodore-Amiga, Inc.

"God was able to create the world in only seven days because there
 was no installed base to consider."

Any expressed opinions are mine; but feel free to share.
I disclaim all responsibilities, all shapes, all sizes, all colors.