Notification when switching Spaces?

  • I'd like to write an app that performs certain actions when a user
    switches to a new Space, but I'm unable to determine when that even
    occurs, much less what Space they switched to.  Does anyone know how
    or if the system announces a Space switch?

                        Love,
                        The Server Surfer

    -----BEGIN GEEK CODE BLOCK-----
    Version: 3.12
    GIT d- s+:+ a C++++ UB++ P L+++ E---- W+++ N o- K- w---
    O- M++ V-- PS+++ PE- Y+ PGP t+ 5 X+ R+ tv++ b+ DI+ D
    G+ e h---- r+++ y**
    ------END GEEK CODE BLOCK------
  • On Nov 9, 2007, at 12:05 AM, The Server Surfer wrote:

    > I'd like to write an app that performs certain actions when a user
    > switches to a new Space, but I'm unable to determine when that even
    > occurs, much less what Space they switched to.  Does anyone know how
    > or if the system announces a Space switch?

    There is no notification available of a Spaces switch.

    -eric
  • On Nov 9, 2007, at 10.40, Eric Schlegel wrote:

    > There is no notification available of a Spaces switch.

    How typically weak.  So is there any way at all of determining the
    active space, etc? (For example, polling windows.)

                        Love,
                        The Server Surfer

    -----BEGIN GEEK CODE BLOCK-----
    Version: 3.12
    GIT d- s+:+ a C++++ UB++ P L+++ E---- W+++ N o- K- w---
    O- M++ V-- PS+++ PE- Y+ PGP t+ 5 X+ R+ tv++ b+ DI+ D
    G+ e h---- r+++ y**
    ------END GEEK CODE BLOCK------
  • On Nov 9, 2007, at 8:54 AM, The Server Surfer wrote:

    > So is there any way at all of determining the active space, etc?
    > (For example, polling windows.)

    There may some heuristic you could come up with (I haven't tried), but
    there's no API for determining the active space.

    -eric
  • On 09 Nov, 2007, at 11:54, The Server Surfer wrote:

    > On Nov 9, 2007, at 10.40, Eric Schlegel wrote:
    >
    >> There is no notification available of a Spaces switch.
    >
    > How typically weak.

    You see, everyone, there's a right way and a wrong way to express
    dissatisfaction in a situation like this.

    Who wants to guess which way The Server Surfer chose? Hands up!

    --
    m-s
  • Am 09.11.2007 um 17:54 schrieb The Server Surfer:
    > On Nov 9, 2007, at 10.40, Eric Schlegel wrote:
    >> There is no notification available of a Spaces switch.
    >
    > How typically weak.

      I think that was totally uncalled for. We all are *real people*
    here, and even people as resilient as Apple employees have feelings.
    Most of all, Eric is working his rear end off and also providing
    support on this list in his spare time.

      He really deserves an apology from you.

    > So is there any way at all of determining the active space, etc?
    > (For example, polling windows.)

      Have you looked into the CGWindow APIs that were added in Leopard?
    There's a kCGWindowWorkspace key that kinda sounds like it may provide
    this information, though I'm not sure whether a "workspace" and a
    "space" are the same... try it and let us know your results.

    Cheers,
    -- M. Uli Kusterer
    "The Witnesses of TeachText are everywhere..."
    http://www.zathras.de
  • On Nov 9, 2007, at 8:54 AM, The Server Surfer wrote:

    > How typically weak.

    This is not USENET or Slashdot.  Knock it off if you want any help
    from anyone on this list.

    -jcr
  • On Nov 10, 2007, at 05.01, Uli Kusterer wrote:

    > I think that was totally uncalled for. We all are *real people*
    > here, and even people as resilient as Apple employees have feelings.
    > Most of all, Eric is working his rear end off and also providing
    > support on this list in his spare time.
    >
    > He really deserves an apology from you.
    I honestly had no idea that Eric personally worked on Spaces himself.
    I didn't look at his email address, so I didn't even realize he worked
    for Apple at all.  I am very sorry if I offended you in any way, Eric.

    My response stemmed from the fact that it would seem to be fairly
    trivial for Apple to post a notification when a Spaces switch
    occurred, and also fairly typical for them to not do so, which is kind
    of annoying when someone like me wants to play with the new hotness too.

    Again, I apologize to anyone I may have offended.  My response wasn't
    intended to mean, "You guys suck," or any other kind of personal
    attack.  All it meant was, "Man, that's really annoying.  It seems
    like five extra minutes from 'Apple' would've saved me hours of
    hackery coming up with a solution that doesn't work as well and wastes
    more system resources than are needed."

    > Have you looked into the CGWindow APIs that were added in Leopard?
    > There's a kCGWindowWorkspace key that kinda sounds like it may
    > provide this information, though I'm not sure whether a "workspace"
    > and a "space" are the same... try it and let us know your results.
    Nope.  Never heard of them until just now.  My only experience is with
    AppKit, Foundation, and a tiny bit of CoreData, and all of that was
    basically puttering.  I'll try to find the documentation and see what
    I can figure out.  Thanks for the lead.  Much appreciated.

                        Love,
                        The Server Surfer

    -----BEGIN GEEK CODE BLOCK-----
    Version: 3.12
    GIT d- s+:+ a C++++ UB++ P L+++ E---- W+++ N o- K- w---
    O- M++ V-- PS+++ PE- Y+ PGP t+ 5 X+ R+ tv++ b+ DI+ D
    G+ e h---- r+++ y**
    ------END GEEK CODE BLOCK------
  • On Nov 10, 2007, at 9:43 PM, The Server Surfer wrote:

    > I honestly had no idea that Eric personally worked on Spaces himself.

    I don't, actually, but I've worked with the engineers who do, and I've
    worked on Spaces support in HIToolbox.framework.

    I didn't take offense, but I do think your comment was unwarranted,
    since unless you work at Apple you're probably not aware of what other
    factors might go into a decision about what capabilities to provide.

    > My response stemmed from the fact that it would seem to be fairly
    > trivial for Apple to post a notification when a Spaces switch
    > occurred, and also fairly typical for them to not do so, which is
    > kind of annoying when someone like me wants to play with the new
    > hotness too.

    It would be trivial, but it's also not clear that it's something we
    want to do. Notifications are API just as much as a function call or
    method are; once we start posting a notification on Spaces switch, and
    apps start depending on it, we have to continue to support that
    notification forever. It's entirely possible that a future version of
    Mac OS X will have some new UI for Spaces that will make it difficult
    to continue to support a simple notification. We also generally prefer
    to avoid providing avenues for apps to do arbitrary things in response
    to UI effects such as Spaces or Expose, because as soon as one app
    starts doing something on a Space switch, lots of other apps will too,
    and the end result is that the Space switch stops being an extremely
    smooth animation and starts getting jerky and ugly.

    In general, we prefer to use data-driven approaches, where you tell us
    in advance what you want to do when a space switch happens ("move this
    window to the active space", for example), and we take care of doing
    it for you. That allows us to keep the space switch animation fast and
    fluid, and also allows us to change the space switch behavior in
    future releases while still keeping compatibility with what your app
    requested.

    It's true that this does prevent some developers from doing
    interesting and useful things. The bottom line, though, is that when
    providing an API, including a notification, we have to think in the
    long term - is this something we can support for the next ten years?
    That makes us very conservative about providing new API.

    What would your code do, if you had a notification of a Space switch?

    -eric
  • On Nov 11, 2007, at 01.01, Eric Schlegel wrote:

    > I don't, actually, but I've worked with the engineers who do, and
    > I've worked on Spaces support in HIToolbox.framework.
    Please extend my apologies to your colleagues as well.  Again, I
    wasn't accusing anyone of "slacking."  It just seemed to me like a
    trivial and obvious thing to add.  Clearly, I hadn't given it nearly
    as much thought as you guys have.

    > I didn't take offense, but I do think your comment was unwarranted,
    > since unless you work at Apple you're probably not aware of what
    > other factors might go into a decision about what capabilities to
    > provide.
    True enough and fair enough. :)

    As an end user, my main (read: only :p) concern is generally how/if
    things work for me.

    > It would be trivial, but it's also not clear that it's something we
    > want to do. Notifications are API just as much as a function call or
    > method are; once we start posting a notification on Spaces switch,
    > and apps start depending on it, we have to continue to support that
    > notification forever. It's entirely possible that a future version
    > of Mac OS X will have some new UI for Spaces that will make it
    > difficult to continue to support a simple notification.
    Ah, that makes sense.  I'm generally not that far-sighted. :D

    > We also generally prefer to avoid providing avenues for apps to do
    > arbitrary things in response to UI effects such as Spaces or Expose,
    > because as soon as one app starts doing something on a Space switch,
    > lots of other apps will too, and the end result is that the Space
    > switch stops being an extremely smooth animation and starts getting
    > jerky and ugly.
    I can certainly see why you would want to avoid that.  What if the
    notification were something along the lines of
    NSSpacesSwitchDidOccur?  That way, anything done by third parties
    would occur after the switch, and not detract from its smoothness.

    > In general, we prefer to use data-driven approaches, where you tell
    > us in advance what you want to do when a space switch happens ("move
    > this window to the active space", for example), and we take care of
    > doing it for you. That allows us to keep the space switch animation
    > fast and fluid, and also allows us to change the space switch
    > behavior in future releases while still keeping compatibility with
    > what your app requested.
    It's a good thing that you guys are in charge of this instead of me. :D

    I do see what you're saying, and it's an aspect of Cocoa that I
    appreciate greatly.  That's actually part of the cause of my
    frustration.  If I had an Apple-approved notification to listen for,
    my app would always Just Work™ up until the point where Apple
    implemented its functionality themselves, and I wouldn't have to
    resort to hackery that could break with any/every x.x.x update.

    > It's true that this does prevent some developers from doing
    > interesting and useful things. The bottom line, though, is that when
    > providing an API, including a notification, we have to think in the
    > long term - is this something we can support for the next ten years?
    > That makes us very conservative about providing new API.
    My only thought is, "Can I make this happen?"  If it breaks down the
    road, I figure I'll just have to fix it at that point.

    Obviously, I've never written an API, and I'm not used to the idea of
    having thousands of other developers relying on my code for the proper
    functioning of theirs. ;)

    > What would your code do, if you had a notification of a Space switch?
    Change the Desktop picture.

    It was in response to this discussion thread: http://episteme.arstechnica.com/eve/forums/a/tpc/f/8300945231/m/95000015883
    1


    Basically, the OP wanted to have a different Desktop picture for each
    Space, to aid in identification, and other posters agreed this would
    be very useful.  I don't personally have any need for something like
    this since I only use two Spaces which are easily identified by their
    contents, but being the helpful guy that I am, I pointed out that it
    would only take a few minutes to write an app that listened for the
    notification of a Spaces switch and set the Desktop accordingly, and
    since it could take months or more for Apple to add this functionality
    themselves, I volunteered to write said app.  My initial frustration
    from your response stemmed from the fact that I've spent more time
    composing this email that I likely would've spent writing the app, had
    the notification existed.  My only thought was pleasing my friends,
    certainly not, "Will this still work in 10 years?"  I figured the app
    would be useless by the time 10.6 came out anyway.  I just didn't
    think people should have to wait that long to get what seemed to be
    (IMO) fairly trivial functionality.

    I did try figuring out how/if I could use kCGWindowWorkspace to
    accomplish my goal, but it seems to be some kind of Carbon thingy,
    which I've never used at all (strictly Obj-C/Cocoa), and I was unable
    to find any documentation for it in any case, so at this point, I'm
    pretty much stuck.

    Anyway, thank you for the education in the perils of API programming,
    and all of the assistance provided by yourself and other posters. <3

                        Love,
                        The Server Surfer

    -----BEGIN GEEK CODE BLOCK-----
    Version: 3.12
    GIT d- s+:+ a C++++ UB++ P L+++ E---- W+++ N o- K- w---
    O- M++ V-- PS+++ PE- Y+ PGP t+ 5 X+ R+ tv++ b+ DI+ D
    G+ e h---- r+++ y**
    ------END GEEK CODE BLOCK------
  • on 2007-11-11 2:01 AM, Eric Schlegel at <ericsc...> wrote:

    > What would your code do, if you had a notification of a Space switch?

    I can't answer for The Server Surfer, but personally I've thought for some
    time now that the accessibility API should post notifications for state
    changes in the Dock, Expose and, now, Spaces. You could avoid the animation
    issue you mention by making sure the notification is issued after the switch
    is complete.

    I'll acknowledge that I haven't thought this through, though. For example,
    if a new window becomes the key window when Spaces switches, then hopefully
    I get some accessibility notifications for that already (haven't tested it
    yet).

    --

    Bill Cheeseman - <bill...>
    Quechee Software, Quechee, Vermont, USA
    www.quecheesoftware.com

    PreFab Software - www.prefabsoftware.com
  • On Nov 10, 2007, at 11:01 PM, Eric Schlegel wrote:

    >> My response stemmed from the fact that it would seem to be fairly
    >> trivial for Apple to post a notification when a Spaces switch
    >> occurred, and also fairly typical for them to not do so, which is
    >> kind of annoying when someone like me wants to play with the new
    >> hotness too.
    >
    > It would be trivial, but it's also not clear that it's something we
    > want to do. Notifications are API just as much as a function call
    > or method are; once we start posting a notification on Spaces
    > switch, and apps start depending on it, we have to continue to
    > support that notification forever. It's entirely possible that a
    > future version of Mac OS X will have some new UI for Spaces that
    > will make it difficult to continue to support a simple
    > notification. We also generally prefer to avoid providing avenues
    > for apps to do arbitrary things in response to UI effects such as
    > Spaces or Expose, because as soon as one app starts doing something
    > on a Space switch, lots of other apps will too, and the end result
    > is that the Space switch stops being an extremely smooth animation
    > and starts getting jerky and ugly.

    So you need to make an asynchronous distributed notification?

    > In general, we prefer to use data-driven approaches, where you tell
    > us in advance what you want to do when a space switch happens
    > ("move this window to the active space", for example), and we take
    > care of doing it for you. That allows us to keep the space switch
    > animation fast and fluid, and also allows us to change the space
    > switch behavior in future releases while still keeping
    > compatibility with what your app requested.
    >
    > It's true that this does prevent some developers from doing
    > interesting and useful things. The bottom line, though, is that
    > when providing an API, including a notification, we have to think
    > in the long term - is this something we can support for the next
    > ten years? That makes us very conservative about providing new API.
    >
    > What would your code do, if you had a notification of a Space switch?

    It is exactly because Apple cannot predict why an app might find a
    Spaces switch notification useful that it should provide the API.
    But here's an Appkit release note excerpt that might give you one idea:

    We added NSWorkspaceSessionDidBecomeActiveNotification and
    NSWorkspaceSessionDidResignActiveNotification notifications to
    NSWorkspace, for applications that need to be aware of session
    switching (aka "fast user switching"). For example, an application
    may decide to disable some processing when its user session is
    switched out, and reenable when that session gets switched back in.
    Such an application should register for these notifications.

    Best,

    __jayson

    Circus Ponies NoteBook - Organization for a Creative Mind
    www.circusponies.com
  • Hi Eric,

    thanks for the explanation. Although many of this can be guessed from outside when thinking about what Apple might think, I always find it very helpful to read solid reasoning. Can't imaging to get too much reasoning about anything, actually.

    Kai

    > On Nov 10, 2007, at 9:43 PM, The Server Surfer wrote:
    >
    >> I honestly had no idea that Eric personally worked on Spaces himself.
    >
    > I don't, actually, but I've worked with the engineers who do, and I've worked on Spaces support in HIToolbox.framework.
    >
    > I didn't take offense, but I do think your comment was unwarranted, since unless you work at Apple you're probably not aware of what other factors might go into a decision about what capabilities to provide.
    >
    >> My response stemmed from the fact that it would seem to be fairly trivial for Apple to post a notification when a Spaces switch occurred, and also fairly typical for them to not do so, which is kind of annoying when someone like me wants to play with the new hotness too.
    >
    > It would be trivial, but it's also not clear that it's something we want to do. Notifications are API just as much as a function call or method are; once we start posting a notification on Spaces switch, and apps start depending on it, we have to continue to support that notification forever. It's entirely possible that a future version of Mac OS X will have some new UI for Spaces that will make it difficult to continue to support a simple notification. We also generally prefer to avoid providing avenues for apps to do arbitrary things in response to UI effects such as Spaces or Expose, because as soon as one app starts doing something on a Space switch, lots of other apps will too, and the end result is that the Space switch stops being an extremely smooth animation and starts getting jerky and ugly.
    >
    > In general, we prefer to use data-driven approaches, where you tell us in advance what you want to do when a space switch happens ("move this window to the active space", for example), and we take care of doing it for you. That allows us to keep the space switch animation fast and fluid, and also allows us to change the space switch behavior in future releases while still keeping compatibility with what your app requested.
    >
    > It's true that this does prevent some developers from doing interesting and useful things. The bottom line, though, is that when providing an API, including a notification, we have to think in the long term - is this something we can support for the next ten years? That makes us very conservative about providing new API.
    >
    > What would your code do, if you had a notification of a Space switch?
    >
    > -eric
  • On Nov 11, 2007, at 2:01 AM, Eric Schlegel wrote:

    > In general, we prefer to use data-driven approaches, where you tell
    > us in advance what you want to do when a space switch happens
    > ("move this window to the active space", for example), and we take
    > care of doing it for you. That allows us to keep the space switch
    > animation fast and fluid, and also allows us to change the space
    > switch behavior in future releases while still keeping
    > compatibility with what your app requested.

    Okay, so that explains why there is no notification.  Now can you
    explain why there is no API to actually switch spaces?
  • On 12 Nov 2007, at 18:27, Christopher Hickman wrote:

    > On Nov 11, 2007, at 2:01 AM, Eric Schlegel wrote:
    >
    >> In general, we prefer to use data-driven approaches, where you tell
    >> us in advance what you want to do when a space switch happens
    >> ("move this window to the active space", for example), and we take
    >> care of doing it for you. That allows us to keep the space switch
    >> animation fast and fluid, and also allows us to change the space
    >> switch behavior in future releases while still keeping
    >> compatibility with what your app requested.
    >
    > Okay, so that explains why there is no notification.  Now can you
    > explain why there is no API to actually switch spaces?

    Probably a case of applications switching spaces for users would get
    incredibly annoying when they started doing things the user didn't
    want to happen.

    Bob
  • On 12/11/2007, at 7:32 PM, Thomas Davie wrote:

    > On 12 Nov 2007, at 18:27, Christopher Hickman wrote:
    >
    >> On Nov 11, 2007, at 2:01 AM, Eric Schlegel wrote:
    >>
    >>> In general, we prefer to use data-driven approaches, where you
    >>> tell us in advance what you want to do when a space switch happens
    >>> ("move this window to the active space", for example), and we take
    >>> care of doing it for you. That allows us to keep the space switch
    >>> animation fast and fluid, and also allows us to change the space
    >>> switch behavior in future releases while still keeping
    >>> compatibility with what your app requested.
    >>
    >> Okay, so that explains why there is no notification.  Now can you
    >> explain why there is no API to actually switch spaces?
    >
    > Probably a case of applications switching spaces for users would get
    > incredibly annoying when they started doing things the user didn't
    > want to happen.
    >
    > Bob

    Ah - but isn't that entirely for the consumer of said application to
    decide?  'Annoying' is subjective, and I'd imagine that normal market
    forces (read: annoyed users) would pretty quickly bring enough
    pressure to bear (i.e. not buy software) from a developer that did
    unintuitive things with spaces.  I for one have customers asking me to
    perform switches in Spaces, and cant provide them this feature at
    present.

    My 2 c.

    --
    John Clayton
    http://www.coderage-software.com/


  • Lots of annoying, crappy applications make the entire platform look bad.

    --
    m-s

    On 12 Nov, 2007, at 15:45, John Clayton wrote:

    > On 12/11/2007, at 7:32 PM, Thomas Davie wrote:
    >
    >> On 12 Nov 2007, at 18:27, Christopher Hickman wrote:
    >>
    >>> On Nov 11, 2007, at 2:01 AM, Eric Schlegel wrote:
    >>>
    >>>> In general, we prefer to use data-driven approaches, where you
    >>>> tell us in advance what you want to do when a space switch
    >>>> happens ("move this window to the active space", for example),
    >>>> and we take care of doing it for you. That allows us to keep the
    >>>> space switch animation fast and fluid, and also allows us to
    >>>> change the space switch behavior in future releases while still
    >>>> keeping compatibility with what your app requested.
    >>>
    >>> Okay, so that explains why there is no notification.  Now can you
    >>> explain why there is no API to actually switch spaces?
    >>
    >> Probably a case of applications switching spaces for users would
    >> get incredibly annoying when they started doing things the user
    >> didn't want to happen.
    >>
    >> Bob
    >
    > Ah - but isn't that entirely for the consumer of said application to
    > decide?  'Annoying' is subjective, and I'd imagine that normal
    > market forces (read: annoyed users) would pretty quickly bring
    > enough pressure to bear (i.e. not buy software) from a developer
    > that did unintuitive things with spaces.  I for one have customers
    > asking me to perform switches in Spaces, and cant provide them this
    > feature at present.
    >
    > My 2 c.
    >
    > --
    > John Clayton
    > http://www.coderage-software.com/
    >
    >
    >


previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today