Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
99 user(s) are online (89 user(s) are browsing Forums)

Members: 1
Guests: 98

hlt, more...

Support us!

Headlines

 
  Register To Post  

Need some help to close active window by input.device
Home away from home
Home away from home


See User information
I trying to port little commoditie from os3, to os4, and for one of key-combos, i want to close any active window. Code looks like this:

case EVT_HOTKEY:

              
lock LockIBase(0);
              
window=((struct IntuitionBase *)IntuitionBase)->ActiveWindow;
              
UnlockIBase(lock);

//----- close active window by input.device

              
input_mp=CreateMsgPort();
              
io=CreateIORequest(input_mp,sizeof(struct IOStdReq));
              
OpenDevice("input.device",NULL,(struct IORequest *)io,NULL);

              
IE=AllocMem(sizeof(struct InputEvent),MEMF_PUBLIC);

              
IE->ie_Class IECLASS_CLOSEWINDOW;
              
IE->ie_EventAddress = &window;

              
io->io_Command IND_WRITEEVENT;
              
io->io_Length sizeof(struct InputEvent);
              
io->io_Data = (APTR)IE;


              
DoIO((struct IORequest *)io);

              
CloseDevice((struct IORequest *)io);

              
DeleteIORequest(io);

              
FreeMem(IE,sizeof(struct InputEvent));

              
DeleteMsgPort(input_mp);
//------
              
break;


The problem, that when i run commoditie, all the applications windowses (like notpade, dopus4, etc), closes fine. But WB windowses are not. I.e. i press for example on "system" icon, have opened window, press by key-combo, and window not closes (but start to be inactive).

On os3 it works fine, and close all the windowses of any app, and WB itself too. Any ideas ?

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: Need some help to close active window by input.device
Just popping in
Just popping in


See User information
@kas1e

From winbar docky :

Quote:

static void SendWindowCloseEvent(__BASE__, struct IOStdReq *inputReq, struct InputEvent *ie)
{

IUtility->ClearMem(ie, sizeof(*ie));

ie->ie_Class = IECLASS_CLOSEWINDOW;

inputReq->io_Command = IND_WRITEEVENT;
inputReq->io_Data = ie;
inputReq->io_Length = sizeof(*ie);

IExec->SendIO((struct IORequest *)inputReq);
}



Edit: you'd better use MEMF_SHARED for input events, as AFAIK they are never read from interrupt code.

Go to top
Re: Need some help to close active window by input.device
Home away from home
Home away from home


See User information
@centaurz
Imho code the same as my.. I changed also PUBLIC on SHARED => all the same. I also check window_bar_dockye - pretty strange works with closing of active windowses. It show meny for "close" only when window are not active, and for now i cant found how to close active window by that dookie.

But for example FKEY commoditie, works fine for "close window". Active it or not. Dunno through, which way it use (maybe not input.device, but something else?). What is a bit strange for me: why my code works for all the windowses, but not for WB ones ? I.e. for dopus4, for shell, for owb, for notepad, for any programm it works. But when i try to close by that combo WB window, it just start to be not-active, but not closes.


Edited by kas1e on 2010/9/11 11:15:14
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: Need some help to close active window by input.device
Home away from home
Home away from home


See User information
@all

There is full test-source code.
Compiling line are:
Quote:

gcc -D__USE_INLINE__=1 test.c -lamiga -lauto


You can run it with run >NIL: (to make it fully commoditie), or just as it (in that way it also will be as commodite, but can be stopped by ctrl+c).

Maybe someone can point me why it not works ? It close by alt+f5 all the app windowses, but not WB ones.

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: Need some help to close active window by input.device
Home away from home
Home away from home


See User information
@all
Bug is found (thank to gazelle), it was because i not clear the allocated memory. Before it was:

IE=AllocMem(sizeof(*IE),MEMF_SHARED);

And it have such strange bug. But now it have:

IE=AllocMem(sizeof(*IE),MEMF_SHARED|MEMF_CLEAR);

And all works as should.

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: Need some help to close active window by input.device
Quite a regular
Quite a regular


See User information
@kas1e

So now if you close the window of a running app, it will crash, so what is the use of this commodity? Is it just to remove windows of crashed apps from the WB?

cheers
tony
Go to top
Re: Need some help to close active window by input.device
Home away from home
Home away from home


See User information
@tonyw

Why it will crash ? (for me it not crashes). App should just close window by key-combo.

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: Need some help to close active window by input.device
Quite a regular
Quite a regular


See User information
@kas1e

If the app has a window open, and some other program comes along and closes the window, how is the original app to know that the window has been closed? On its first reference to the (non-existent) window after it has been closed, the app will crash.

Or are you not just closing the window from outside, but sending a "CloseWindow" command to the app?

cheers
tony
Go to top
Re: Need some help to close active window by input.device
Not too shy to talk
Not too shy to talk


See User information
@tonyw

He does not close the window. He sends the order to close the window to the application. The application can then still refuse to actually close its window. For the application the same happens as if the user clicked the close button.

Go to top
Re: Need some help to close active window by input.device
Home away from home
Home away from home


See User information
@tonyw
Yep, Thomas are right.

For example when i "close" by commoditie dopus4, it ask "want you quit from dopus?". I.e. it not hardcore closing of window, it just the same action, which happenes when user press close gadget on any window of any programm.

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: Need some help to close active window by input.device
Quite a regular
Quite a regular


See User information
@kas1e

Fair enough. My mistake.

cheers
tony
Go to top
Re: Need some help to close active window by input.device
Just can't stay away
Just can't stay away


See User information
@kas1e

This feature already exists in Fkey.

Philippe 'Elwood' FERRUCCI
Sam460ex 1.10 Ghz
http://elwoodb.free.fr
Go to top
Re: Need some help to close active window by input.device
Home away from home
Home away from home


See User information
@Elwood

yes, i know, question was about code in general. that commoditie about which i talk in the begining, do few more actions, which also can be handled by Fkey (swith screeen and alt+tab windowses), but while Fkey works buggy for window-switching (because of AmiDock), i port that my old tool (already on os4depot, called "awin") which do all of this fine. But yes, if you need only closing windowses , then Fkey are good enough for.

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top

  Register To Post

 




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




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project