Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
87 user(s) are online (49 user(s) are browsing Forums)

Members: 1
Guests: 86

Firetail, more...

Headlines

 
  Register To Post  

(1) 2 »
[Solved] Application library event handling
Supreme Council
Supreme Council


See User information
The documentation is a bit thin on how to handle events for an appwindow.

I want to identify iconify/deiconify events within the appwindow event loop:

BOOL AppEvents(void)
{
 
struct ApplicationMsg *appmsg;
 
struct Message *msg;
 
BOOL done=FALSEreply;
 
BOOL result;

 while ( (
msg=IExec->GetMsg(AppPort)) )
 {
  
appmsg = (struct ApplicationMsg *)msg;
 
  
reply TRUE
  
  
// Check for appmessages
  
switch (appmsg->type)
  {
   case 
APPLIBMT_Quit:
    
done TRUE;
   break;
  }

/*  
  case WMHI_ICONIFY:
   if (RA_Iconify(inst->WinObj)) { inst->Win=0; }
   break;
  case WMHI_UNICONIFY:
   inst->Win=RA_Uniconify(inst->WinObj);
   break;  
*/
       
  
if(reply)
  {
   
IExec->ReplyMsg((struct Message *)msg);
  }
 }

 return 
result;
}


Anyoen know how to get the iconification stuff into my event loop?


Edited by orgin on 2009/3/22 10:57:34
Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Application library event handling
Amigans Defender
Amigans Defender


See User information
@orgin

You need to Wait() on the application.library signal and then handle the events as you would for any other messages.

struct MsgPort *applport;
GetApplicationAttrs(appID, APPATTR_Port,(ULONG)&applport, TAG_DONE);
applsig = (1L << applport->mp_SigBit);

wait = Wait(applsig);

if (wait & applsig)
{
// application.library signal

while ( (applmsg=(struct ApplicationMsg *) GetMsg(applport)) )
{
switch (applmsg->type)
{
case APPLIBMT_Hide:




etc

Go to top
Re: Application library event handling
Supreme Council
Supreme Council


See User information
@Chris

I'm already allocating message port and doing the wait stuff in an outer loop. So I already have that bit covered.

Anyway, "HIDE" is application.library acronym for iconify?

If not then I hope you'll eventually realize what I was asking for, that is: how to combine reading both WMHI_* messages and the application.library messages in the same event loop. (GetMsg() + RA_HandleInput() on the same message port)

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Application library event handling
Amigans Defender
Amigans Defender


See User information
@orgin

No, HIDE is the event I had at the start of the code I copied and pasted.

All you need to do is put the HandleInput in a if(wait & winsig) section, rather then immediately after Wait()



wait = Wait(winsig | applsig)

if(wait & applsig)
{
// GetMsg() for application.library
}
else if(wait & winsig)
{
// RA_HandleInput() for Reaction
}

Go to top
Re: Application library event handling
Just popping in
Just popping in


See User information
@orgin

If you make your Reaction window an appwindow, why don't you use the AppMsgHook feature ? The hook will be called automatically by RA_HandleInput() when an AppMsg is received, so you can use the loop code provided by Chris ?

Go to top
Re: Application library event handling
Supreme Council
Supreme Council


See User information
@centaurz

Probably because I have no idea what you just said nor how to incorporate it into my app.

I have two message ports. One for the appwindow stuff (WINDOW_AppPort+WINDOW_AppWindow=TRUE) and one for the GUI (WINDOW_SharedPort).



@anyone

Btw, I noticed that I get an ApplicationMsg when I drag&drop something on my appwindow, but there's no mention of how to retrieve information (multiple file for example) from the message in the autodoc. There's the appwindow method OpenDoc but that only takes a single file path.

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Application library event handling
Supreme Council
Supreme Council


See User information
@Chris

Doesn't two different sigbits need two different msgports? (There's no way to specify two different ports for this)

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Application library event handling
Amigans Defender
Amigans Defender


See User information
@orgin

Um, maybe, the application.library msgport will be different anyway.

I also think you're confusing AppWindows with application.library. AppWindows are handled by workbench.library with AddAppWindow() and the usual GetMsg(), and are only for dragging icons into windows (but share an interface with AppIcons and AppMenus).

application.library is more like commodities.library, and allows you to control an application from elsewhere (usually AmiDock)

Don't mix the two up or you won't get anywhere.

Chris

Go to top
Re: Application library event handling
Just popping in
Just popping in


See User information
@orgin

Are you sure you're not mixing application.library and workbench.library?

An AppWindow has nothing to do with the application.library. It's from workbench, see AutoDoc for workbench.library/AddAppWindowA

The AppMessage is defined in workbench/workbench.h

If you have two ports, each port will have it's own signal. You get the mask for every port and than wait for the signals.

app_mask 1UL << AppPort->mp_SigBit;
win_mask 1UL << WinPort->mp_SigBit;

do
{
   
signals Wait(app_mask win_mask)

   if (
signals app_mask)
   {
       
/* handle messages from AppPort */
   
}

   if (
signals win_mask)
   {
       
/* handle messages from WinPort */
   
}

}
while (!
done);

Go to top
Re: Application library event handling
Supreme Council
Supreme Council


See User information
@Gazelle

Quote:

Are you sure you're not mixing application.library and workbench.library?

An AppWindow has nothing to do with the application.library. It's from workbench, see AutoDoc for workbench.library/AddAppWindowA

The AppMessage is defined in workbench/workbench.h


Ahh, seems that's what I'm doing, thanks. Finally the message makes sence. If I deiconify the window I get am_Type 8 (AMTYPE_APPICON). And the same if I drag&drop some icons on it. What information in the message tells me what the user is trying to do?


(The rest of you message is not relevant to what I'm doing)

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Application library event handling
Supreme Council
Supreme Council


See User information
Solved it :) The code ended up like this:

BOOL AppEvents(void)
{
 
struct AppMessage *appmsg;
 
struct Message *msg;
 
BOOL done=FALSEreply;

 while ( (
msg=IExec->GetMsg(AppPort)) )
 {
  
appmsg = (struct AppMessage *)msg;
 
  
reply TRUE
    
  if(
appmsg->am_Type==AMTYPE_APPICON)
  {
    if(
appmsg->am_NumArgs==&& appmsg->am_ArgList==NULL)
    {
     
// Trying to deiconify
     
FilerInstance->Win=RA_Uniconify(FilerInstance->WinObj);
    }
    else
    {
     
// Something was dropped on my window
     // Get data from am_NuMArgs + am_ArgList (WBArg structures)
    
}
  }
       
  if(
reply)
  {
   
IExec->ReplyMsg((struct Message *)msg);
  }
 }

 return 
done;
}


Next up is trying to figure out how to drag _from_ my application.

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Application library event handling
Amigans Defender
Amigans Defender


See User information
@orgin

Quote:
Next up is trying to figure out how to drag _from_ my application.


I don't think there's an easy way of doing that unfortunately. I could find a use for this though.

Go to top
Re: Application library event handling
Supreme Council
Supreme Council


See User information
@Chris

Hmm okey, would be nice to be able to create a dragcontext when detecting a drag event in your window. And then intuition/workbench takes over. Once dropped intuition/workbench sends a struct *DropMessage to the receiving window.

struct DropMessage could contain:

struct DropMessage
{
 
struct Message dm_execmessage;
 
struct Window *dm_win// The original window that sent the message
 
APTR *dm_userdata// Containing whatever you want
 
uint32 dm_posx// mouse x position
 
uint32 dmn_posy// mouse y position
}

function 
in IWorkbench or IIntuition:

int32 CreateDragContext(struct Window *windowAPTR *userdata);

 
Dispatch the data to workbench/intuition.
 
Returns 0 on failure.

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Application library event handling
Just popping in
Just popping in


See User information
@orgin

You should also handle AMTYPE_APPWINDOW type Messages. Don't know why you only get AMTYPE_APPICON but as I understand the autodoc you should receive one type for your AppIcon and the other for your AppWindow.

Go to top
Re: Application library event handling
Supreme Council
Supreme Council


See User information
@Gazelle

Yes I'm receiving both. That code has been updated a bit since I pasted it here.

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Application library event handling
Supreme Council
Supreme Council


See User information
@Chris

what would you think of this?:

int32 CreateDragContextAttrs(uint32 tag1, ...);

 
Tells the Workbench that it should enter drag&drop modeOnce the left mouse button is
 released the Workbench will notify the window at that mouse position with either an AppMessage
 
or a DropMessage.

 
Tags:
  
DC_Type (int32)

   
One of (mutually exclusive):

    
DC_Type_DropMessage
     The receiving window will receive a DropMessage containing an IFFData structure
.
    
DC_Type_Appmessage
     The receiving window will receive an AppMessage
, for this type DC_NumArgs and DC_ArgList must
     be set
With DC_ArgList containg a list of valid filenames.

  
DC_Icon (struct DiskObject *)
   
The icon that will be used while dragging. Default NULL. If not specifying this then a default icon will be used.

  
DC_WindowID (APTR)
   
Only for DC_Type_DropMessageWindow identificatorthis identificator will be avaiable in the
   DropMessage received by the remote window


  
DC_IFFData (APTR)   (or struct IFFHandle * ?)
   
Only for DC_Type_DropMessageContains an IFF structure (See iffparsewith application specific data.

  
DC_NumArgs (uint32)
   
Only for DC_Type_AppMessageNumber of arguments in the DC_ArgList

  DC_ArgList 
(APTR)
   
Only for DC_Type_AppMessageContains valid filenames to be sent to the receiving appwindow.

 
/* struct DropMessage contents */
   
struct DropMessage
   
{
    
struct Message dm_execmessage;
    
struct Window *dm_win// The original window that sent the message, used as ID only, do not alter!
    
APTR *IFFData *dm_data// Containing an IFF data structure (or struct IFFHandle * ?)
    
uint32 dm_posx;        // mouse x position
    
uint32 dmn_posy;       // mouse y position
   
}


Edited by orgin on 2009/3/22 13:10:09
Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Application library event handling
Amigans Defender
Amigans Defender


See User information
@orgin

You need a tag to specify the image that is being dragged too. Probably a struct Icon * will be best for Workbench.

I'm not sure DropMessage is needed - anything you will be dragging to would have already registered as an AppWindow or AppIcon, or be Workbench.

The data could be passed in a tag, perhaps WB could store it in a temporary file and then pass the filename. Needs some sort of notification to delete the temp file once it has been finished with (incidentally this is how RISC OS manages dragging directly from one app to another, not sure if the app or the OS writes the temp file though)

Other than that, looks good. Where did I put Workbench's source code?

Go to top
Re: Application library event handling
Supreme Council
Supreme Council


See User information
@Chris

"Where did I put Workbench's source code?"

Well I'm sure that if a proposal was written I could find the right people to send it to for consideration.

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Application library event handling
Amigans Defender
Amigans Defender


See User information
@orgin

I see why you had DropMessage now - for dragging bettween windows belonging to the same application. I think an extended AppMessage structure would be better.

AddAppWindow() and AddAppIcon() could have a new tag:
WBAPPICONA_AllowData
WBAPPWINA_AllowData

This would tell WB that the application is happy to receive data passed in memory as well as filenames.

CreateDragContextAttrs() would then need the following tags:
DC_Data (APTR) pointer to memory area holding some data
DC_DataSize (uint32) size of DC_Data

Also useful might be
DC_UserData (APTR) for other information to pass through AppMessages
and the aforementioned DC_Image (struct DiskObject *)

Only one of DC_Data or DC_ArgList must be supplied.

struct AppMessage would then need the following additions:
am_Data
am_DataSize
am_DCUserData

If the calling application uses DC_Data and the user drags onto an application which does not have WBAPP_AllowData tag set, Workbench would transparently write the data into a temporary file in T: and pass the filename instead.

I haven't figured out yet how WB will know that the temporary file has been finished with (or, indeed, how the calling app will know that the in-memory data can be freed - maybe the receiving app/WB should take care of that?)

Go to top
Re: Application library event handling
Just can't stay away
Just can't stay away


See User information
@Chris

Quote:
CreateDragContextAttrs()


Where do you have this ? I don't have that in the current SDK.

Rock lobster bit me - so I'm here forever
X1000 + AmigaOS 4.1 FE
"Anyone can build a fast CPU. The trick is to build a fast system." - Seymour Cray
Go to top

  Register To Post
(1) 2 »

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2023 The XOOPS Project