I need to interrupt window closing after the user
press close button of a window. I tried to do it
the following way ( but with no success ):
- On window creation, set raw event handler
…
rcb.event_mask = Ph_EV_WM;
rcb.event_f = window_raw_cb;
rcb.data = NULL;
PtSetArg( &arg[n++], Pt_CB_RAW, &rcb, NULL );
PtCreateWidget( PtWindow, parent, n, arg );
…
- Raw event handler checks whether the event type
is Ph_WM_CLOSE and if so it asks for confirmation
and returns Pt_END if the user doesn’t want to close
window.
int window_raw_cb( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo )
{
PhWindowEvent_t *wmdata = PhGetData( cbinfo->event );
if( wmdata->event_f == Ph_WM_CLOSE )
{
if( !get_confirmation() )
return( Pt_END );
}
return( Pt_CONTINUE );
}
Window Manager still closes the window even if raw handler
returns Pt_END.
What is wrong? Is there other way to interrupt window event processing?
Thanks,
Gen
Gennadiy Gladchun <gen@a-teleport.com> wrote:
: What is wrong? Is there other way to interrupt window event processing?
I answered this in QUICS, but here’s the info for anyone else who needs it.
There’s a better way to do this. It’s described in version 1.14 or later
of the Photon Programmer’s Guide.
Look in:
Window Management
Notification callback
Example: verifying window closure
Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems Ltd.
This is that example, if i’m not mistaken:
int window_close( PtWidget_t *widget, ApInfo_t *apinfo,
PtCallbackInfo_t *cbinfo )
{
PhWindowEvent_t *we = cbinfo->cbdata;
if ( we->event_f == Ph_WM_CLOSE ) {
// Ask the user if we should really exit.
…
exit (EXIT_SUCCESS);
} else // Check for other events
…
return( Pt_CONTINUE );
}
It terminates the further event processing by terminating the
application itself. Too high price!! I need just to stop the current
window manager event.
Thanks,
Gen
Previously, Steve Reid wrote in comp.os.qnx:
Gennadiy Gladchun <> gen@a-teleport.com> > wrote:
: What is wrong? Is there other way to interrupt window event processing?
I answered this in QUICS, but here’s the info for anyone else who needs it.
There’s a better way to do this. It’s described in version 1.14 or later
of the Photon Programmer’s Guide.
Look in:
Window Management
Notification callback
Example: verifying window closure
Steve Reid > stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems Ltd.
Gennadiy Gladchun <gen@a-teleport.com> wrote:
: This is that example, if i’m not mistaken:
:
: int window_close( PtWidget_t *widget, ApInfo_t *apinfo,
: PtCallbackInfo_t *cbinfo )
: {
: PhWindowEvent_t *we = cbinfo->cbdata;
:
: if ( we->event_f == Ph_WM_CLOSE ) {
: // Ask the user if we should really exit.
: …
: exit (EXIT_SUCCESS);
: } else // Check for other events
: …
:
: return( Pt_CONTINUE );
: }
: It terminates the further event processing by terminating the
: application itself. Too high price!! I need just to stop the current
: window manager event.
You could just remove these lines:
// Ask the user if we should really exit.
…
exit (EXIT_SUCCESS);
Then the callback would do nothing…
If you read the rest of that chapter, you’ll find how you can get the
window manager to ignore close events for the window.
Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems Ltd.