Input parameters of the move algorithm are the identification numbers
of the existing window, the window to be moved, and the direction of
the movement. The output parameters are the two highest level nodes
affected by the move operation to be used for screen update, one for
the new location and the other for the old window location. The
pseudo-code algorithm of the move operation (MoveWindow) is listed
in Appendix .
The move algorithm first detaches the window to be moved, call it W, from its old location by using the CloseWindow function. Since CloseWindow does not deallocate WindowNode structure for W it can be used in the rest of the algorithm.
If the new location is inside an existing window, call it TO
(Case 3, Figure ), it is checked whether it has
any children and it is an empty window. In that case node TO
becomes an H-Node and node W is inserted as the only
child. Coordinates of the windows are updated and propagated to lower
level windows. In other cases an error is returned.
If the new location is next to the existing window, simply the AddWindow function is called and a new window, call it T, is added in the direction of movement. If the window types of W and T match simply copy W onto T and propagate changes down to lower level windows. In the case of mismatch a G-Node is created as an intermediary between T and W and changes are propagated from T down to lower level windows.
The algorithm for the copy operation resembles the move algorithm, except that the window to be copied is not detached from its parent but a copy of it is created and that copy is used in the rest of the algorithm.