exercises

8. implementation support

EXERCISE 8.4

A user has a word-processor and a drawing package open. The word-processor's window is uppermost. The user then clicks on the drawing window (see figure below). The drawing window then pops to the front.

Describe in detail the things that the window manager and applications perform during the processing of the mouse click in the above scenario. Explain any assumptions you make about the kind of window manager or application toolkits that are being used.

windows

answer available for tutors only

The details of this differ between different window systems; two typical examples are given here. The detail expected from students depends on what systems they have been using for practical work.

event-loop style window manager with 'retained bitmap' (keeps its own record of hidden window contents)

  • the mouse click goes first to a low-level part of the window manager
  • the window manager works out which window is under the mouse and sees that it is not the current top-window
  • it creates a 'you are hidden' event and adds it to the word-processor's event queue
  • it creates a 'you are on top' (expose) event and adds it to the drawing package's event queue
  • it creates an appropriate 'mouse clicked' data structure for the application adding the mouse coordinates, shift key info, time, etc.
  • it records the overlapping bit of the window-manager's window in an 'off-screen buffer'
  • it draws the hidden bit of the drawing package window
  • it makes a note to pass future drawing from the word-processor to the off-screen buffer
  • when the drawing package next reads its events it gets the expose event and the mouse-click event in that order
  • it makes a note that future keystrokes go to the drawing package
    (assuming a click-to-type interface)

notifier style window manager with NO 'retained bitmap'

  • the mouse click goes first to a low-level part of the window manager
  • the window manager works out which window is under the mouse and sees that it is not the current top-window
  • it records the fact that future drawing from the word-processor to the overlapping area of the screen should be prevented and that the drawing package (which was previously prevented) be allowed to draw to it.
  • it creates a 'you are hidden' event and invokes the appropriate word-processor callback for this event
  • it calls the drawing package redraw routine telling it which part of the screen to redraw
  • it creates a 'you are on top' (expose) event and invokes the appropriate drawing package callback for this event
  • it creates a 'mouse clicked' data structure for the application including the mouse coordinates, shift key info, time, etc. and passes this to the appropriate drawing package callback for this event
  • it passes this event to the appropriate drawing package callback
  • it makes a note that future keystrokes go to the drawing package
    (assuming a click-to-type interface)

Other exercises in this chapter

ex.8.1 (ans), ex.8.2 (ans), ex.8.3 (tut), ex.8.4 (tut), ex.8.5 (tut), ex.8.6 (tut), ex.8.7 (tut), ex.8.8 (tut), ex.8.9 (tut)

all exercises for this chapter