On Wed, 13 Aug 2003 15:28:11 -0700
"Sean 'Shaleh' Perry" <[EMAIL PROTECTED]> wrote:
> On Wednesday 13 August 2003 13:00, Dave Serls wrote:
> > I'd like to add a 'feature' to my home version (0.65) of blackbox, but
> > I'm non-compis-C++ I'm afraid.
> > When the 'exit' menu item is taken in Rootmenu.cc, I would like to
> > scan through the list of windows looking for certain titles (the only
> > identification that I know of) and, either
> > (1) Issue an xmessage indicating that they are still running and that
> > the session exit will not be taken; or,
> > (2) actually send a close to those windows ( those windows should accept
> > close, of course ).
> > I should not be messing with the code, of course, seeing as I know almost
> > nothing about C++, not even enough to search the Blackboxwindow list.
> > I could make my own 'special' window list at create-time, I suppose.
> >
> > Thanks for any suggestions, clues.
> >
>
> Enclosed is a rather quicky and stupid implementation. That's what you get
> for 15 minutes of hacking (-:
>
> I used system() to implement the script calling. This has good sides and bad
> sides.
>
> Good:
> you can put anything in the command string, I tested it with
> '[exithook] (Exit test3) {DISPLAY=":0" xlsclients | grep -qv bob}'
>
> Bad:
> You can *NOT* run any commands which open a X window from this hook. If you
> do blackbox will hang forever. You see, system() blocks the parent until it
> exists. So blackbox is not awake to notice your window's request. To make
> it so a window could be opened we would have to separate from the child (like
> we do with a normal menu execute) and then wait for the child's return
> status. Which is not that much harder, I just did not take the time to code
> it. With this example someone should be able to add that in short order.
>
> If the script exits with a 0 exit code (shell success) Blackbox exits.
> Otherwise it keeps running. If you want the inverse just change the
> 'if (WEXITSTATUS(ret) == 0)' line to a !=.
>
> Long term blackbox needs a way to open a dialog box internally. Then the code
> could do:
>
> if we decide not to exit:
> open_dialog text="Decided not to exit after all"
>
> As an added bonus this small patch explains how to add a new menu entry type
> to the menu code (-:
>
Thanks. I didn't know about xlsclients!!
My hack was:
> case BScreen::Exit:
> if (item->exec()) {
> int retc;
> retc = system(item->exec());
> if ( retc != 0 ) {
> char nxmsg[128];
> strcpy( nxmsg, "xmessage " );
> strcat( nxmsg, item->exec() );
> strcat( nxmsg, " disallowed session exit." );
> bexec( nxmsg, getScreen()->displayString() );
> break;
> }
> }
--
************************************************************************
* Dave Serls Littleton, CO, USA *
* dashs.denver.co.us sorrybiscuit.com *
************************************************************************
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
List archives: http://asgardsrealm.net/lurker/splash/index.html
Trouble? Contact [EMAIL PROTECTED]