home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gwm18a.zip / doc / overview.tex (.txt) < prev    next >
LaTeX Document  |  1995-07-03  |  14KB  |  249 lines

  1. \chapter{Overview}
  2. \sloppy
  3. {\GWM} like any other window manager is in charge of all that is {\bf
  4. exterior} to other application windows on the display. It performs its task
  5. by {\bf decorating} the existing windows on the screen with its own windows.
  6. The appearance and behavior of these windows are described by the user through
  7. programs written in the lisp-like {\WOOL} language, which are interpreted by
  8. the built-in {\WOOL} interpreter of {\GWM}.
  9. The {\GWM} Window manager is composed of 2 modules: the window manager itself,
  10. {\GWM}, and the lisp interpreter {\WOOL}. The role of the garbage-collected
  11. {\WOOL} objects is to build shared descriptors that will be used by {\GWM}
  12. to build its (non-shared and non-garbage-collected) objects.
  13. {\GWM} was designed in 1988 and was developed on 68020 unix stations with 4K
  14. of main memory, and thus tradeoffs in its design has been made to make it as
  15. efficient as current C window managers, often at the expense of ease of
  16. customization. But the power is there under the hood if you need it.
  17. My main research interest was on window management metaphors, but the design
  18. and development of the platform flexible enough to implement my views as
  19. {\WOOL} profiles has taken me too much time, and I did not find time to
  20. implement the rooms-like metaphors I wanted to try. But I, and some others,
  21. still use only {\GWM} as it provides features yet unseen in any other WMs to
  22. date.
  23. \section{GWM Window OBjects: the wobs}
  24. {\GWM} is built upon the notion of a {\bf wob}, which, not unlike an X {\sl
  25. Widget\/} is an object composed of:
  26. \begin{description} 
  27. \item[an X11 window] used to display the wob on the screen (output)
  28. \item[a {\WOOL} finite state machine] used to trigger {\bf WOOL}
  29. functions in response to X11 events sent to the wob (input)
  30. \end{description}
  31. Wobs are not directly created with {\WOOL} constructors, they are {\bf
  32. described}, and {\GWM} uses this description to physically create the
  33. wobs when it needs to, when decorating a new client window for instance.
  34. Like any X11 window, the user can choose the width, color(s), and tiling
  35. pixmap of the border of the wob (which is considered to be in the wob for
  36. input purposes). There are four kinds of wobs:
  37. \begin{description}
  38. \item[Window] An X11 application, such as XTERM(1) or XCLOCK(1) usually opens
  39. one or more windows directly on the screen (in fact the {\em root window\/}).
  40. We will call these windows, which are not created by {\GWM}, {\bf client
  41. windows}.  {\GWM} will ``decorate'' these client windows by {\em
  42. reparenting\/} them, i.e. by creating a {\bf Window} wob and making the client
  43. window a son of this newly created window.
  44. A window is a wob made by creating a new toplevel X window, reparenting  the
  45. client window as its child, and framing it with four (optional) {\em bars},
  46. children of the new toplevel window. Note that the inside of a window wob is
  47. thus never visible, since it is entirely covered by the bars and the client
  48. window.
  49. \item[Bar] The only extensible wob, it has a width and an extensible length.
  50. It is a line (vertical or horizontal) of bars or {\em plugs\/} centered on the
  51. axis of the bar with optional stretchable space between them. Horizontal bars
  52. contains vertical bars and vertical bars contains horizontal bars.
  53. \item[Plug] The simplest of all wobs, its contents is just a graphic
  54. which is displayed in their X window. It acts thus like some kind of button.
  55. Current graphics are text and pixmaps.
  56. \item[Menu] A bar of bars (horizontal menus consist of a
  57. horizontal bar of vertical bars, vertical menus are a vertical bar of
  58. horizontal ones).
  59. Menus are the only ``stand-alone'' wobs, their windows are directly created
  60. by {\GWM} on the screen. They can be used to implement pop-up, pull-down or
  61. fixed menus, control panels, message windows and icon boxes.
  62. \end{description}
  63. \subsubsection{Other GWM objects}
  64. Other gwm objects are just X objects (fonts, pixel colors \ldots) that are
  65. referenced by their X id, and are accessed via encapsulating
  66. {\WOOL} types, such as Numbers or Pixmaps.
  67. \section{WOOL objects}
  68. {\WOOL} is a lisp interpreter of a special kind, since it has some important
  69. design differences from ``real'' lisps:
  70. \begin{description}
  71. \item[incremental garbage collection] {\WOOL} has a {\sl reference-count\/}
  72. driven memory management scheme. This means that the load of memory
  73. management is evenly distributed on all phases of computing, thus avoiding
  74. the dreadful garbage collection pauses. But, since reference count memory
  75. management doesn't work with circular lists, no {\WOOL} function allows the
  76. user to do physical replacements on lists\footnote{In fact, some do, but are
  77. flagged as ``for experts only'' in the documentation}. 
  78. \item[no real lists, but arrays] {\WOOL} lists are internally stored as
  79. arrays, speeding up list scanning. We do not really need the
  80. generality of the chained cells model, since we do not want to have circular
  81. lists.
  82. \item[monovalued atoms] In classical lisp dialects, you can give a variable
  83. and a function the same name without conflict. In {\WOOL}, an atom can only
  84. have one value.
  85. \item[internally typed objects] All of the {\WOOL} interpreter is written in
  86. an object oriented way. This is not visible to the user, since we do not
  87. offer a way to define user types, but it greatly improves the modularity of
  88. the code, and allows us to provide generic functions, such as the \verb"+"
  89. function operating on numbers, lists, or strings.
  90. \end{description}
  91. {\WOOL} alas lacks lots of features from real lisps, for the sake of small
  92. footprint. But the {\WOOL} code accounts for about 50k of the total text size of
  93. 150k of {\GWM}.
  94. The different {\WOOL} objects are:
  95. \begin{description}
  96. \item[atoms] associates any {\WOOL} object to any other via a hash table.
  97. Only one wool object can be referenced, which implies that a \verb"(setq foo1)"
  98. assignment will remove any function definition made by \verb"(defun foo ...)".
  99. There is {\bf no} limit on the length of atom names. Atom names can
  100. be composed of any printable ASCII character except {\tt " ' ( )}, and
  101. cannot begin by a digit.
  102. \item[active values] are predefined atoms that can be used as atoms or
  103. functions. If \verb"foo" is an active value, then \verb"foo" and
  104. \verb"(foo)" give the same result, and the calls \verb"(setq foo obj)" and
  105. \verb"(foo obj)" have the same effect.
  106. Active values are just like other atoms, but setting and evaluating them
  107. trigger specific functions to allow for greater expressive power. For
  108. instance, just setting a wob's \verb"borderwidth" will actually resize the
  109. corresponding X window's border, and declaring a local value for it by a
  110. \verb"(with (wob-borderwidth 3) ...)" will actually change the borderwidth
  111. of the current wob on the screen during the execution of the \verb"with"
  112. body, and then revert to the previous value.
  113. \item[numeric variables] are atoms that can only store integer values. Like
  114. active values, they can be used as variables or functions. Setting them to 
  115. \verb"()" or \verb"t" equivalent to setting them to \verb"0" or \verb"1".
  116. \item[namespaces] are sets of variable names that have a different value for 
  117. each state of the namespace. For instance, the most useful namespace is the
  118. \verb"screen." one, having one state for each screen. So each name in this
  119. namespace, such as \verb"white", can hold a screen-dependent value that will
  120. always eval to the correct value relative to the screen.
  121. \item[integers] are 32-bit signed integer values.
  122. \item[strings] are 8-bit strings of characters, with no size limit.
  123. \item[functions] may evaluate or not their arguments and have a fixed
  124. or variable parity.
  125. \item[fsms] the finite state machines. They are {\WOOL} objects shared by
  126. wobs and respond to both X events and {\WOOL}-made events, the so-called
  127. ``user'' events.
  128. \item[wobs descriptors: plug, bar, menu, client] are used by {\GWM} to build
  129. its wobs.
  130. \item[X objects: pixmaps, cursors, events, labels] allow X
  131. resources to be shared via the {\WOOL} memory management.
  132. \item[internal objects] used to improve efficiency (These include
  133. collections and quoted expressions).
  134. \end{description}
  135. \section{Operation}
  136. When you start {\GWM}, it:
  137. \begin{itemize}
  138. \item connects to the display it must manage to initialize its X11 structures
  139. \item reads and interprets the user's {\WOOL} profile (searched for in a
  140. user-defined path, see usage). This profile must define at least two
  141. {\WOOL} functions:
  142. \begin{description}
  143. \item[describe-window] which will be called by {\GWM} to know how to decorate
  144. any client window and must return a list of two window descriptors, one for
  145. the window itself, and one for the associated icon;
  146. \item[describe-screen] which will be called by {\GWM} for each managed
  147. screen and must return a window descriptor;
  148. \end{description}
  149. \item looks to see if it is the only window manager running; if not, it
  150. aborts.
  151. \item decorates the managed screens by calling the user-defined {\tt
  152. describe-screen} function for each one, with the \verb"screen" active value
  153. being set to the current screen.
  154. \item decorates all already mapped client windows, by calling {\tt
  155. describe-window} with the current client window being set to each window.
  156. \item executes the (user-defined) opening function for each screen.
  157. \item enters {\GWM} main loop, which consists in:
  158. \begin{itemize}
  159. \item waiting for an X event
  160. \item examining the received event, and if it is for an existing wob, sends
  161. it to the {\em fsm\/} of this wob, else if it is a new window which is being
  162. mapped for the first time, decorates it (by calling {\tt describe-window})
  163. \end{itemize}
  164. When an event is sent to a {\em fsm}, it is matched against the
  165. transitions in the current state of the fsm, and as soon as one matches, the
  166. corresponding {\WOOL} expression is evaluated, and the fsm changes state if
  167. necessary. If no transition is waiting for the event, it is discarded.
  168. \end{itemize}
  169. \section{Lazy evaluation}
  170. For sub-wobs of wobs, i.e., bars of a window, plugs of a bar, bars of a
  171. menu, and menu of any wob, lazy evaluation is performed. That is, on the
  172. realization of the wob the field is re-evaluated if the result is not
  173. of the expected type. This allows for constructs such as:
  174. {\exemplefont\begin{verbatim}
  175.         (plug-make '(label-make window-name))
  176. \end{verbatim}}
  177. which creates a plug whose text is fetched as the name of the
  178. window on each realization, you do not have to explicitly \verb"eval" a
  179. quoted expression.
  180. \section{Screen-dependent objects}
  181. An invocation of {\GWM} can manage all screens attached to a display (there
  182. is one keyboard and mouse per display), but in X, screens are very distinct
  183. worlds. If you create a pixmap or a color on a screen, you cannot use it on
  184. another one. The list of objects created on one screen that cannot be used
  185. on another is:
  186. \desc{pixmaps}{Objects}{made by}{
  187. colors & color-make\\
  188. pixmaps & pixmap-make, label-make, active-label-make\\
  189. cursor & cursor-make\\
  190. menus & menu-make\\
  191. And of course, all the wobs and windows are screen-specific.
  192. \section{Sending commands to GWM}
  193. Any program can make {\GWM} execute any {\WOOL} code by putting the {\WOOL}
  194. code to execute as an ASCII string in the {\bf GWM\_EXECUTE}
  195. \label{GWM_EXECUTE} property on any root window or client window
  196. of the screens managed by {\GWM}, which will parse and evaluate the given
  197. string with the current window being the one on which the property was set.
  198. This feature is built in, so that it will work regardless of the
  199. profile used.
  200. You can also use the program {\tt gwmsend} in the contrib/gwmsend
  201. directory in the distribution to send commands to {\GWM}.
  202. It takes its first argument and puts in the {\bf GWM\_EXECUTE} property on
  203. the root window. It can thus be used like:
  204. \begin{verbatim}
  205.     gwmsend '(? "Hello there\n")'
  206. \end{verbatim}
  207. A better way is to use the \verb|-I| option to make {\GWM} read its standard
  208. input for commands. a recommended use is to run not \verb|gwm| directly but a
  209. command like:
  210. \begin{verbatim}
  211.     xterm -title gwm -e fep gwm -IP
  212. \end{verbatim}
  213. \verb|fep| is a pseudo-tty driver which gives its argument line editing and
  214. history capabilities, like \verb|ile| or the GNU library \verb|readline|.
  215. \section{Using {\tt gwmchat} as a shell to GWM}
  216. If you want to communicate with {\GWM} more interactively, via {\WOOL}, you
  217. can use the program {\tt gwmchat} (in the contrib/gwmchat
  218. directory). Start {\tt gwmchat} in any 
  219. terminal window, with the same flags as you would have given {\GWM}. It
  220. forks off {\GWM} and then waits for commands to send it. Output from {\GWM}
  221. goes to the same terminal window. 
  222. In your {\tt .xinitrc} or {\tt .xsession} or correspondingly, where
  223. you normally would start {\GWM}, you may instead have something like:
  224. \begin{verbatim}
  225.     xterm -e gwmchat
  226. \end{verbatim}
  227. \begin{verbatim}
  228.     xterm -geometry =80x16-1-1 -e gwmchat -f vtwm
  229. \end{verbatim}
  230. {\tt gwmchat} can be compiled to use the {\tt readline} package. This
  231. is strongly recommended if it is available and if {\tt gwmchat} is to
  232. be used in other ways than from inside Emacs, since otherwise it will
  233. have no command line editing mechanisms whatsoever (other than erasing
  234. backwards). 
  235. % Obsolete formulation
  236. %\section{Sending commands with {\tt gwmsend} }
  237. %If you rather want to send commands to {\GWM} one at a time, or to an
  238. %already running {\GWM}, you could use the program {\tt gwmsend}. It takes
  239. %a {\WOOL} command as argument and sends it to {\GWM}:
  240. %\begin{verbatim}
  241. %    gwmsend '(? "Hello there\n")'
  242. %\end{verbatim}
  243. \section{Checking that GWM is running}
  244. On each screen it manages, {\GWM} will maintain a hidden window whose
  245. X Id will be given as a 32-bit Id in the {\bf GWM\_RUNNING} property
  246. on the root window {\bf and} the hidden window itself. Thus, if this
  247. window exists, and has the {\bf GWM\_RUNNING} property set, you can be
  248. sure that the screen is managed by {\GWM}.
  249.