A Generic Handler For desktopChanged

Rob Cozens rcozens at pon.net
Fri Apr 14 14:59:50 EDT 2006


Hi All,

In an effort to provide some minimal TPC compliance for Revolution, I 
am now testing the following handler:

on checkStackPositions includeInvisibleStacks,theseStacksOnly
    put (includeInvisibleStacks is not false) into 
includeInvisibleStacks -- defaults to true
    lock screen
    get theseStacksOnly
    if it is empty then get the openStacks
    if includeInvisibleStacks then put it into stackNames
    else
       put empty into stackNames
       repeat for each line openedStack in it
          if the visible of stack openedStack then put 
openedStack&return after stackNames
       end repeat
    end if
    get the working screenRect
    put item 3 of it into maxWidth
    put item 4 of it into maxHeight
    repeat for each line openedStack in stackNames
       set the right of stack openedStack to min(the right of stack 
openedStack,maxWidth)
       set the bottom of stack openedStack to min(the bottom of stack 
openedStack,maxHeight)
    end repeat
    unlock screen
end checkStackPositions

Unless/until RRLtd incorporates TPC compliance into Revolution, the 
checkStackPositions handler will be included in future releases of 
Serendipity Library.  checkStackPositions is meant to be called from a 
developer's desktopChanged handler.  Note: desktopChanged is a new 
message in v2.7+.

on desktopChanged
    checkStackPositions
end desktopChanged

The checkStackPositions handler is just a starting point.  It ensures 
that windows that are partially offscreen on the bottom or right when 
the desktop is changed will be raised or moved left so the bottom & 
right are fully visible.  I'm sure there will be other logic needed 
(eg: what if the stack is wider or taller than the working screenRect 
allows [though this is something people developing for TPCs should be 
aware of when setting stack size], displayed on something other than 
the primary monitor [use "working screenRects"], or to stagger windows 
that must be moved).

In my testing, the handler responds to both changes in screen 
orientation and hiding/showing the TPC Input Panel.  My presumption is 
this should also work for responding to runtime changes in the position 
of the Dock on MacOSX platforms--at least for moving the Dock to the 
bottom or right; however, I can't test this on MacOSX without compiling 
an app on my TPC specifically for that purpose.

So I'm posting this for testing by anyone using v2.7...especially on 
MacOSX.

I'm also interested in any design comments or suggestions.  I started 
out writing a handler for a specific stack; but felt that 
desktopChanged should, where possible, deal with all open stacks in one 
swell foop.  But not knowing how others (or moi, for that matter) might 
end up using this, I added filtering for invisible files and the 
ability to pass a list of specific stacks as an option to checking all 
open stacks.

Rob Cozens
CCW, Serendipity Software Company

"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."

from "The Triple Foole" by John Donne (1572-1631)




More information about the use-livecode mailing list