In a windowed interface, all input is queued into the event-loop. This input can be represented as a stream. The interface accepts streams that conform to the rules imposed by the interface. In other words, an interface can be represented by a finite state machine(FSA). These FSAs specify the grammar for the input stream.
An application can be represented by many such FSAs collaborating with each other. A grammar can be found that generates these FSAs given a specification.