[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: X and Self 2.0.1
> An annoying property of the display, this need for occasional
> flushing.
Right. X won't do anything until it has to, which means you either
have to prod it explicitly with a flush or a sync, or you need to
implicitly prod it with an XNextEvent.
For those who are interested in using the X support provided in the
current release, here's some information:
The current release includes support for X windows and X events, but
not for X graphics. It does provide Pixrect graphics. The ui, for
example, draws Pixrect graphics in an X window in response to X
events. (This isn't a great situation, but it was a relatively quick
port.) X graphics can be had by gluing them in as primitives--see the
manual.
See the attached file for a sample window object that creates a window
and gets events. The other object that participates is defined in
"eventWatcher.self" (included in the release); X calls go through
xlib.self and xlibPrims.wrappers.self (which are also in the release).
To open a window, do:
window copy
To see the events as they occur, first do
window debug: true
and then open a window.
I will also include this file in the Self ftp directory, in contrib.
Bay
-------------------------------window.self-----------------------------------
traits graphics _AddSlotsIfAbsent: ( | ^ window = () | )
traits window _Define: ( |
parent** = traits clonable.
^ copy = ( resend.copy initialize ).
^ copyOn: disp = ( (resend.copy displayName: disp) initialize ).
_ initialize = (
display: xlib display open: displayName.
xwin: xlib window createOnDisplay: display At: position Size: size.
xwin name: name.
xwin iconName: iconName.
xwin iconified: false Input: true.
xwin catchWMDelete.
xwin eventMask: eventsToCatch.
xwin selectInput.
xwin map.
spawnEventWatcherProcess.
self ).
^ close = (
watcher quit.
finalize ).
_ finalize = (
display close.
self ).
_ spawnEventWatcherProcess = (
watcher: eventWatcher copyForDisplay: display SendingTo: self.
watcherProcess: process copySend:
message copy receiver: watcher
Selector: 'watch'.
watcherProcess resume ).
_ eventsToCatch = xlib events buttonPressMask ||
xlib events buttonReleaseMask ||
xlib events buttonMotionMask ||
xlib events exposureMask ||
xlib events visibilityChangeMask ||
xlib events structureNotifyMask ||
xlib events keyPressMask ||
xlib events colormapChangeMask.
_ eventHandlers* = ( |
reparentNotify: event = (
debugMessage: 'reparentNotify event'.
event delete.
self ).
motionNotify: event = (
debugMessage: 'motionNotify event'.
event delete.
self ).
enterNotify: event = (
debugMessage: 'enterNotify event'.
event delete.
self ).
leaveNotify: event = (
debugMessage: 'leaveNotify event'.
event delete.
self ).
keyPress: event = (
debugMessage: 'keyPress event'.
'\a' print. "beep"
event delete.
self. ).
keyRelease: event = (
debugMessage: 'keyRelease event'.
event delete.
self ).
buttonPress: event = (
debugMessage: 'buttonPress event'.
event window printLine.
event delete.
self ).
buttonRelease: event = (
debugMessage: 'buttonRelease event'.
event delete.
self ).
expose: event = (
debugMessage: 'expose event'.
event delete.
self ).
colormapNotify: event = (
debugMessage: 'colormap event'.
event delete.
self ).
configureNotify: event = (
debugMessage: 'configure event'.
event delete.
self ).
visibilityNotify: event = (
debugMessage: 'visibilityNotify event'.
event delete.
self ).
mapNotify: event = (
debugMessage: 'mapNotify event'.
event delete.
self ).
unmapNotify: event = (
debugMessage: 'unmapNotify event'.
event delete.
self ).
clientMessage: event = (
debugMessage: 'clientMessage event'.
(event message_type = xlib wmProtocols) &&
[(event atomAt: 0) = xlib wmDeleteWindow]
ifTrue: [ ^ quitClientMessage: event ]
False: [ debugMessage: 'unknown clientMessage event' ].
event delete.
self ).
quitClientMessage: event = (
event delete.
quit ).
otherEvent: event = (
debugMessage: 'unknown event: ', event type printString.
event delete.
self ).
| ).
_ debugging* = ( |
^ debug <- false.
_ debugMessage: str = ( debug ifTrue: [ str printLine ] ).
| ).
quit = ( close. self ).
| )
prototypes graphics _AddSlotsIfAbsent: ( | ^ window = () | )
window _Define: ( |
_ parent* = traits window.
name <- 'A Window'.
iconName <- 'window'.
position <- 0@0.
size <- 200@@200.
displayName <- ''.
display <- xlib display.
xwin <- xlib window.
_ watcher <- eventWatcher.
_ watcherProcess <- process.
| )