{ import Smalltalk/kernel } { import Smalltalk/geometry } { import XWindow } MyWindow : XWindow ( graphicsContext ) MyWindow withGraphicsContext: aGraphicsContext [ self := self new. graphicsContext := aGraphicsContext ] MyWindow fromWindow: aWindow [ self := self withGraphicsContext: aWindow display defaultGraphicsContext. display := aWindow display. _window := aWindow _window. ] MyWindow undefined: event [ self error: 'undefined event' ] MyWindow keyPress: event [ 'Goodbye!' println. Smalltalk quit ] MyWindow keyRelease: event [ 'keyRelease' println ] MyWindow buttonPress: event [ 'buttonPress' println ] MyWindow buttonRelease: event [ 'buttonRelease' println ] MyWindow motionNotify: event [ 'motionNotify' println ] MyWindow enterNotify: event [ 'enterNotify' println ] MyWindow leaveNotify: event [ 'leaveNotify' println ] MyWindow focusIn: event [ 'focusIn' println ] MyWindow focusOut: event [ 'focusOut' println ] MyWindow keymapNotify: event [ 'keymapNotify' println ] MyWindow expose: event [ self drawString: 'unmap (iconify)' at: 4@28 context: graphicsContext; drawString: ' me to exit. ' at: 4@42 context: graphicsContext. display synchronise ] MyWindow graphicsExpose: event [ 'graphicsExpose' println ] MyWindow noExpose: event [ 'noExpose' println ] MyWindow visibilityNotify: event [ 'visibilityNotify' println ] MyWindow createNotify: event [ 'createNotify' println ] MyWindow destroyNotify: event [ 'destroyNotify' println ] MyWindow unmapNotify: event [ 'unmapNotify' println ] MyWindow mapNotify: event [ 'mapNotify' println ] MyWindow mapRequest: event [ 'mapRequest' println ] MyWindow reparentNotify: event [ 'reparentNotify' println ] MyWindow configureNotify: event [ 'configureNotify' println ] MyWindow configureRequest: event [ 'configureRequest' println ] MyWindow gravityNotify: event [ 'gravityNotify' println ] MyWindow resizeRequest: event [ 'resizeRequest' println ] MyWindow circulateNotify: event [ 'circulateNotify' println ] MyWindow circulateRequest: event [ 'circulateRequest' println ] MyWindow propertyNotify: event [ 'propertyNotify' println ] MyWindow selectionClear: event [ 'selectionClear' println ] MyWindow selectionRequest: event [ 'selectionRequest' println ] MyWindow selectionNotify: event [ 'selectionNotify' println ] MyWindow colormapNotify: event [ 'colormapNotify' println ] MyWindow clientMessage: event [ 'clientMessage' println ] MyWindow mappingNotify: event [ 'mappingNotify' println ] [ | display window | display := XDisplay open": ':0.0'". window := display defaultRootWindow createSimpleWindowX: 0 y: 0 width: 640 height: 480 borderWidth: 5 border: 0 background: -1. window := MyWindow fromWindow: window. window changeAttributes: ((XSetWindowAttributes new) eventMask: 0x1ffffff; yourself) mask: XSetWindowAttributes eventMaskMask. window map. display synchronise. [ | event | event := display nextEvent. window perform: ( #( undefined: undefined: keyPress: keyRelease: buttonPress: buttonRelease: motionNotify: enterNotify: leaveNotify: focusIn: focusOut: keymapNotify: expose: graphicsExpose: noExpose: visibilityNotify: createNotify: destroyNotify: unmapNotify: mapNotify: mapRequest: reparentNotify: configureNotify: configureRequest: gravityNotify: resizeRequest: circulateNotify: circulateRequest: propertyNotify: selectionClear: selectionRequest: selectionNotify: colormapNotify: clientMessage: mappingNotify: ) at: event type ) with: event ] repeat. ]