ScreenVWM 0.7 - a Litestep taskbar and VWM
By Jim Babcock

************
* Contents *
************
* 1. Using ScreenVWM
* 2. Adding ScreenVWM to your theme
* 3. Bang commands
* 4. Misc configuration options
* 5. Panels
* 6. Layout options
* 7. Desktop descriptions
* 8. Window descriptions
* 9. Legalities

**********************
* 1. Using ScreenVWM *
**********************
Initially, there will be one virtual desktop shown with all of your tasks in
it. To create a new desktop, drag one of your tasks' icons to an empty part of
the taskbar. You can also switch desktop and move windows between desktops
this way.

The file screenvwm_hotkeys.rc defines a set of hotkeys which all themes that
use ScreenVWM should include. These hotkeys are:
  Win+[1-9]         Switch to the numbered desktop (Win+0 is desk ten).
  Win+Left          Switch to previous desktop.
  Win+Right         Switch to next desktop.
  Win+Down          Merge current desktop with previous desktop.
  Win+Shift+Left    Move current application to previous desktop.
  Win+Shift+Right   Move current application to next desktop.
  Win+Shift+Up      Move current application to a new desktop at the beginning
                    of the list.
  Win+Shift+Down    Move current application to a new desktop at the end of
                    the list.
  Win+Ctrl+Left     Move this desk earlier in the list of desktops
  Win+Ctrl+Right    Move this desk later in the list of desktops
  Win+Ctrl+Down     Combine all desktops into one (gather)
  
*************************************
* 2. Adding ScreenVWM to Your Theme *
*************************************
To add ScreenVWM to your Litestep theme, put
  *NetLoadModule screenvwm.dll
in your theme.rc file. You will then want to configure it; take a look at
defaultSettings.txt for a list of options. In particular, you will at least
want to choose a size and position (the default is a 32-pixel thick bar across
the top of the screen).

IMPORTANT: You cannot use ScreenVWM and another VWM module, such as vwm2 or
rabidvwm, at the same time. When you add the option to load ScreenVWM to your
theme.rc, make sure to disable loading of all other VWMs.

********************
* 3. Bang Commands *
********************
  !swmCreate
    Creates a new desk containing the foreground task and switch to it. This is
    equivalent to dragging the foreground task to an unused part of the
    taskbar, or '!vwmMoveApp new'.

  !swmDestroy        
    Synonym for '!swmMerge prev'

  !swmDesk <desk>
    Switch to the given desk, where <desk> is either a number (eg "!vwmDesk 1")
    or a description (eg "!vwmDesk next"). See "Desk descriptions".

  !swmGather
    Combine all desktops into one, moving all windows on screen.

  !swmMaximizeWindow <window>
    Maximizes the given window. If no window is specified, affects the
    foreground window.

  !swmMerge <desk>
    Merge the current desktop with the specified desktop, leaving one desktop
    with the windows and tasks of both.

  !swmMinimizeWindow <window>
    Minimizes the given window. If no window is specified, affects the
    foreground window.

  !swmMoveApp <window> <desk>
  !swmMoveApp <desk>
    If both arguments are given, moves the specified window to the given desk.
    If only a desk is given, moves the foreground app. In either case, the
    destination desk becomes focused.

  !swmMoveDesk <desk>
    Reorders desktops so that the current desktop is in the specified position.
    For example, "!swmMoveDesk last" moves the current desktop to the end of
    the list, while "!swmMoveDesk prev" moves the current desktop up one.

  !swmMoveWindow
    Moves the foreground window, as though you had picked 'move' from its
    system menu.

  !swmNext/!swmPrev/!swmUp/!swmDown/!swmLeft/!swnRight/!swmDown
    Switches the current desktop. These are  short for !vwmDesk with different
    parameters. See "Desk Descriptions". Up/left means prev and down/right
    means next.

  !swmOntopToggle
    Toggles whether or not ScreenVWM is always on top.

  !swmOpen <desk> <command>
    Switches to the given desk and then runs the given command or program.

  !swmResizeWindow <window>
    Resizes the specified window, as though you had picked 'resize' from its
    system menu.

  !swmSeparate <desk>
  !swmSeparateAll
    CURRENTLY BROKEN (as of 0.7)
    Splits up desktops, making one desktop per window.

  !swmShow/!swmHide
    Makes ScreenVWM visible or invisible.

*********************************
* 4. Misc configuration options *
*********************************
swmKeepEmptyDesktops [bool]
swmKeepEmptyFocusedDesktop
  Default: false
  Whether desktops with no tasks on them should be kept around (true) or
  deleted (false), depending on whether the desk in question is focused or
  not.

swmAutoGather [bool]
  Default: true
  If true, ScreenVWM will gather (merge all desks) on startup. If false, it
  will attempt to preserve information about what desks tasks were on across
  a recycle.

swmRescueOffScreenWindows [bool]
  Default: true
  If a window ends up completely off-screen for some reason, this controls
  whether ScreenVWM will move it back. This may cause problems for poorly
  written apps which move windows off-screen as a way to hide them.

swmPollInterval [int]
  Default: 500
  How often ScreenVWM should refresh the list of windows/tasks. If set to 0,
  polling is disabled; this is not recommended as it will cause the creation of
  new windows to go unnoticed.

*************
* 5. Panels *
*************
ScreenVWM windows are referred to as panels. There is always at least one
panel, which is named 'swm'. Additional panels are given by the swmExtraPanels
options as a whitespace-separated list of names, each of which is a prefix for
panel-specific options. Each panel has the following options:
  <prefix>Visible [bool]
    Default: true
    Whether this panel starts visible.
  
  <prefix>AlwaysOnTop [bool]
    Default: false
    Whether this panel starts out always on top
  
  <prefix>RootElement [identifier]
    Default: swmRoot
    The name of the root layout element which this panel is drawn with.
  
  <prefix>X [coord]
  <prefix>Y [coord]
  <prefix>Width [coord]
  <prefix>Height [coord]
    The location and size of this panel.

*************
* 6. Layout *
*************
The layout of ScreenVWM panels is defined by a hierarchy of widgets, each of
which is identified by a string which is also the prefix of all its options.
Every element must have a type, given as <prefix>Type; this defines what the
element does and looks like and what other options are available, and it is an
error to use an element without defining its type. The following options are
available for all elements, regardless of type:

  <prefix>Type
    Mandatory (no default)
    The element's type. See below for a listing of allowed types.

  <prefix>OnLeftClick [command]
  <prefix>OnMiddleClick [command]
  <prefix>OnRightClick [command]
    Default: none
    The command that will run when this element is clicked on. If this is a
    ScreenVWM bang command, 'clicked' is a valid desk/task description. This
    runs on mouse-down, before (and in addition to) dragging, if the element
    is draggable.

  <prefix>Draggable [bool]
    Default: false
    Whether this element can be picked up and dragged around. In general, it is
    best for draggable elements to be as close to the top of the hierarchy as
    possible; in particular, draggable elements should not be the child of
    branch elements, since if conditions change and the dragged element no
    longer exists, the drag will be cancelled (possibly as soon as it begins!).

  <prefix>DragPlaceholder [element]
    Default: <prefix>
    When this element is picked up and dragged, this is the element which stays
    behind to fill its place.

  <prefix>OnHover_<element> [command]
    Default: none
    What happens when a dragged <element> is hovered over this element. If this
    is a ScreenVWM bang command, 'dragged' and 'hovered' are valid desk/task
    descriptions.

  <prefix>OnDrop_<element> [command]
    Default: none
    What happens when a dragged <element> is dropped on this element. If this
    is a ScreenVWM bang command, 'dragged' and 'hovered' are valid desk/task
    descriptions.

Element Types

The element types are
  branch   One of several children depending on a boolean expression

  flow     A series of elements arranged in sequence, optionally with copies
           for each desk or each task within a desk

  group    A set of elements named in <prefix>Elements drawn on top of
           eachother.

  icon     The icon that belongs to the context task.

  label    A text label with either a fixed string, the context desk's number,
           or the context task's window title.

  minimap  A minimap of the context desk with all its windows.

  texture  A button or decoration with an image or draw effect, drawn with
           XPaintClass.

Branch Elements
  A branch element one of the elements listed in <prefix>Elements. For each of
those elements, <element-name>Condition is a boolean expression which defines
when it should be used. If several conditions are satisfied, the first element
whose conditions are satisfied is the one used.
  Condition expressions may use the & (and), | (or), and ! (not) operators,
plus the following keywords:

  minimized
    True if the context task is minimized.

  focused
    True if the context task's main window is focused, or if there is no
    context task and the context desk is focused.

  deskfocused
    True if the context desk is focused

  true, false
    The literal values true and false.

  dragging
    True if any element is currently being dragged
  
  hovered
    True if the cursor is over this element

Operators in branch condition expressions are right-associative; & and | have
the same precedence, but may be parenthesized.

Flow Elements
  A flow element takes a set of elements (including elements that are
duplicated for each task or desk) and arranges them relative to eachother.
The elements in a flow are listed in <prefix>Elements. Elements which are
copied for each task or desk have '.desks' or '.tasks' before them.
Additionally, numbers in the list of elements add spacer elements, which are
not drawn but create blank space between the elements before and after them.
When desks or tasks are duplicated this way, each child has a "context desk"
or "context task", which is applied recursively to that element and all its
children.
  Flow elements have <prefix>X, <prefix>Y, <prefix>Width, and <prefix>Height
options, which define the area in which children are allowed to appear. There
is currently no handling for when elements overflow the provided area, but
that is planned for future versions. Currently, the only flow layout option is
<prefix>Vertical, which switches between horizontal and vertical layouts.
Future versions will have multiple types of flow layouts and more options for
customizing them.

Group Elements
  A group element is a set of elements listed in <prefix>Elements in order
from bottom to top. Where elements overlap, mouse events go to the topmost
one. <prefix>BaseLength adds to the element's size for flow-layout purposes.

Icon Elements
  Icon elements show the icon of the root window of the context task. Its
size and position are given by <prefix>X, <prefix>Y, <prefix>Width and
<prefix>Height. In general, icons will look best if they are 16x16 or 32x32,
since those are the sizes which other programs provide their icons as; any
other size will be resized and, as a result, less sharp. Also, you may offset
icons so that they are partially clipped using <prefix>OffsetX and
<prefix>OffsetY, which are floats between 0 and 1 defining the fraction of
the icon's size it is offset by..

Label Elements
  A label element displays text, either a configured string or a property of
the context's desk or task. Labels have the following options:

  <prefix>AlignHoriz [left|center|right]
    default: center
    Whether this text is left, center, or right-aligned. This alignment also
    determines the meaning of <align>X; the left side, center, or right side,
    respectively.
  
  <prefix>AlignVert [top|center|bottom]
    default: center
    Whether this text is top, center, or bottom-aligned. This alignment also
    determines the meaning of <align>Y; the top, center, or bottom,
    respectively.

  <prefix>X [coord]
  <prefix>Y [coord]
    Where the edges of the text are. The default depends on alignment.

  <prefix>MinLength [coord]
    default: 0
    The minimum length for this text. If the text is smaller than this, it will
    be expanded and the extra space left blank.
    
  <prefix>MaxLength
    default: 250
    The maximum length for this text. If the text is larger than this, it will
    be shortened and ellipses ('...') used at the end.

  <prefix>Text
    default: .auto
    Either an arbitrary string, which will be drawn as-is, or .auto, .desknum,
    or .taskname. If it's .desknum, the number of the context's desk; if
    .taskname, the window title of the context's task; if .auto, then .taskname
    if available, .desknum if not, or "?" if neither is available.

Additionally, label elements respect all of the options supported by
XPaintClass's text renderer, which are listed in
  http://www.xdocs.ls-universe.info/pie.php?xPaintText
Some of the more useful of these options are <prefix>Font, <prefix>FontHeight
and <prefix>FontColor.

Minimap Elements
  A minimap element shows a tiny map of all the elements on the current desk.
This map has no background; use a texture for that. It has the following
options:
  <prefix>TitleBars [bool]
    default: true
  <prefix>TitleBarThickness [int]
    default: 4
  <prefix>Icons [bool]
    default: true
  <prefix>IconSize [int]
    default: 16
  <prefix>WinColor [color]
    default: ffffff
  <prefix>TitleBarColor [color]
    default: 505050
  <prefix>FocusedTitleBarColor [color]
    default: 0000ff
  <prefix>WinBorderColor [color]
    default: 000000

Texture Elements
  A texture element is a static image or other drawn effect. It is drawn
using XPaintClass, so all of the options given in 
  http://www.xdocs.ls-universe.info/pie.php?xPaintTexture
apply to it. In particular, you need to set <prefix>PaintingMode, usually
to either ".singlecolor" or ".image" (though others are possible).
Additionally, this respects <prefix>X, <prefix>Y, <prefix>Width and
<prefix>Height.

************************
* 7. Desk Descriptions *
************************
Wherever a bang command or variable refers to a desktop, you may choose a
desktop using one of the following descriptions. Note that there may not be
such a desktop; for example, if the last desktop is selected, then "next"
doesn't refer to anything. You may provide a slash-separated list of fallbacks;
for example, the command
    !swmDesk next/first
will switch to the next desk, wrapping around at the end. If no parameter is
given or if none of the described desks exists, defaults to next/prev/current.
The available desk descriptions are:

    [n]
      The nth desktop. There is no 0th desktop. May be any positive integer
      less than or equal to the number of desktops.

    prev, next
      The desktops before and after the focused desktop. If there is no such
      desk, the one opposite (ie when the first desk is focused, 'prev' goes to
      next)

    first, last
      The first and last desktops.
    
    current
      The desktop you are looking at now

    other
      The last desktop you looked at, besides the focused one

    up, left, right, down
      Synonyms for nextwrap and prevwrap provided for compatibility (up/left is
      prevwrap, down/right is nextwrap.)

    newprev, newnext, newfirst, newlast
      New desktops created in the corresponding positions. Note that empty
      desktops will be automatically deleted, so you must either put something
      on it (eg with !swmMoveApp) or set the swmKeepEmptyDesktops option.
    
    hovered
      The desk defined in the context of the hovered element, if any. Undefined
      if the mouse is not over a panel, or if it's over a part of a panel which
      does not correspond to a desk.

    clicked
      If used in a click-event handler, the desk which was clicked on.

    dragged, dropped
      Only meaningful inside a drag 'n drop handler when the dragged (or
      dropped-on) elements have a desk defined in their context.

**************************
* 8. Window Descriptions *
**************************
Whenever a bang command or variable refers to a window, you may choose a
window using one of the following descriptions. Unlike with desks, there is no
fallback, and identifying windows by their title is not currently supported.
(These descriptions are mainly to support mouse event handling and drag and
drop).

If a task owns more than one window, then layout elements involving it will use
the root window. Most bang commands (like !swmMoveApp) will affect the entire
task, including all its child windows.

    focused, foreground
      The current desk's topmost window. Note that this window doesn't have to
      actually have the focus; if a Litestep window has the focus, then the
      topmost window will still be used.

    hovered
      The task defined in the context of the hovered element, if any.
    
    clicked
      If in the context of a mouse click handler, the task which was clicked
      on.
    
    dragged dropped
      If in the context of a drag event handler, the task which is being
      dragged or being dragged onto.

*****************
* 9. Legalities *
*****************

ScreenVWM is copyright (C) 2008 James Babcock. It contains code derived from
LiteStep, which is copyright (C) 1997-2008 The LiteStep Development Team.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
file license.txt for details.
