discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GNUstep and session management


From: Sašo Kiselkov
Subject: Re: GNUstep and session management
Date: Fri, 07 Oct 2005 21:50:32 +0200
User-agent: Internet Messaging Program (IMP) 3.2.5

Quoting Roman Belenov <rbelenov@yandex.ru>:

> Richard Frith-Macdonald <richard@brainstorm.co.uk> writes:
>
> > I think we can safely infer that the session manager *should* send the
> > NSWorkspaceWillPowerOffNotification to all apps on session termination, but
> we
> > don't know what (if anything) it should do then (other than some sort of
> force
> > quit of applications still running after some interval), and we don't know
> if
> > the gui library should observe NSWorkspaceWillPowerOffNotification and call
> > [NSApp terminate]
>
> Actually, since according to Mac OS X docs "the order in which observers
> receive notifications is undefined" (GNUstep doc doesn't say anything about
> it), observing NSWWPON by the library is not a way to go - application should
> receive this notification before call to applicationShouldTerminate to be
> able
> to process it (and there is a note about this order - see
> http://developer.apple.com/releasenotes/Cocoa/AppKitOlderNotes.html).
>
> --
>                                                       With regards, Roman.

Let's just stop putting up theories about how it may or may not work on OSX and
instead start designing a way that would work for us. That is because proper
session management is an important feature for the user/luser, but not all too
difficult for us to implement or reimplement if need to change the way it's
done in the future.

I'd propose the following implementation (source code samples attached):

 - when the workspace app is about to poweroff (see -[WorkspaceApp
askAppWhetherToPowerOff:] in the attached WorkspaceApp.m file), it will send a
message named -workspaceShouldPowerOff to each application turn. This method
(see -[NSApplication workspaceShouldPowerOff] in the attached
NSApplicationAdditions.m file) asks the delegate with
-applicationShouldTerminate: whether it is ok to terminate and forwards that
decision back to the workspace app. The workspace app will, based on this
decision, do the following:

  + NSTerminateNow - the workspace appwill send
-replyToApplicationShouldTerminate: YES to the app to make it shut down
gracefully.

  + NSTerminateCancel - the workspace app will stop the poweroff procedure.

  + NSTerminateLater - the workspace app will wait for 2 minutes and continually
check whether the app has already shut down or whether the app posted a (newly
added) notification named GSWorkspaceCancelPowerOffNotification. See the source
code file WorkspaceApp.m for a precise description on how these cooperate.

This is my proposal for the procedure.

Known bugs:

Currently this schema doesn't handle NSWorkspaceWillPowerOffNotification in any
way. Such a notification doesn't make any sense, since the workspace cannot
observe how apps handle it (there is no back-stream of information from
observers of notifications to their posters). Thus it doesn't know whether it
should wait for some time after posting the notification or just continue
immediately.

--
Saso

Attachment: NSApplicationAdditions.m
Description: Binary data

Attachment: WorkspaceApp.m
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]