|
1 'From Smalltalk/X, Version:2.8.2 on 29-nov-1993 at 15:22:58'! |
|
2 |
|
3 Object subclass:#WindowGroup |
|
4 instanceVariableNames:'views topViews myProcess mySensor' |
|
5 classVariableNames:'ActiveGroup' |
|
6 poolDictionaries:'' |
|
7 category:'Interface-Support' |
|
8 ! |
|
9 |
|
10 !WindowGroup class methodsFor:'instance creation'! |
|
11 |
|
12 new |
|
13 ^ self basicNew initialize |
|
14 ! ! |
|
15 |
|
16 !WindowGroup methodsFor:'accessing'! |
|
17 |
|
18 addView:aView |
|
19 views isNil ifTrue:[ |
|
20 views := OrderedCollection new. |
|
21 ]. |
|
22 views add:aView |
|
23 ! |
|
24 |
|
25 sensor |
|
26 ^ mySensor |
|
27 ! |
|
28 |
|
29 removeView:aView |
|
30 views notNil ifTrue:[ |
|
31 views remove:aView ifAbsent:[]. |
|
32 views isEmpty ifTrue:[ |
|
33 views := nil |
|
34 ] |
|
35 ]. |
|
36 topViews notNil ifTrue:[ |
|
37 topViews remove:aView ifAbsent:[]. |
|
38 topViews isEmpty ifTrue:[ |
|
39 topViews := nil |
|
40 ] |
|
41 ]. |
|
42 |
|
43 (views isNil and:[topViews isNil]) ifTrue:[ |
|
44 views := nil. |
|
45 topViews := nil. |
|
46 myProcess notNil ifTrue:[ |
|
47 myProcess terminate |
|
48 ] |
|
49 ]. |
|
50 ! |
|
51 |
|
52 views |
|
53 ^ views |
|
54 ! |
|
55 |
|
56 process |
|
57 ^ myProcess |
|
58 ! |
|
59 |
|
60 sensor:aSensor |
|
61 mySensor := aSensor |
|
62 ! |
|
63 |
|
64 addTopView:aView |
|
65 topViews isNil ifTrue:[ |
|
66 topViews := OrderedCollection new. |
|
67 ]. |
|
68 topViews add:aView |
|
69 ! ! |
|
70 |
|
71 !WindowGroup methodsFor:'activation'! |
|
72 |
|
73 processEvents |
|
74 |damage event view rect| |
|
75 |
|
76 [mySensor hasDamage] whileTrue:[ |
|
77 damage := mySensor nextDamage. |
|
78 view := damage at:1. |
|
79 rect := damage at:2. |
|
80 view exposeX:rect left y:rect top width:rect width height:rect height |
|
81 ]. |
|
82 [mySensor hasEvents] whileTrue:[ |
|
83 event := mySensor nextEvent. |
|
84 event sendEvent |
|
85 ] |
|
86 ! |
|
87 |
|
88 startup |
|
89 myProcess isNil ifTrue:[ |
|
90 myProcess := [ |
|
91 [true] whileTrue:[ |
|
92 mySensor eventSemaphore wait. |
|
93 self processEvents |
|
94 ] |
|
95 ] forkAt:Processor userSchedulingPriority. |
|
96 (topViews notNil and:[topViews isEmpty not]) ifTrue:[ |
|
97 "give the handler process a user friendly name" |
|
98 myProcess name:(topViews first name) |
|
99 ] ifFalse:[ |
|
100 myProcess name:'window handler'. |
|
101 ]. |
|
102 myProcess exitAction:[self shutdown] |
|
103 ] |
|
104 ! |
|
105 |
|
106 shutdown |
|
107 topViews notNil ifTrue:[ |
|
108 topViews do:[:aTopView | aTopView destroy] |
|
109 ]. |
|
110 views := nil. |
|
111 topViews := nil. |
|
112 myProcess notNil ifTrue:[ |
|
113 myProcess terminate. |
|
114 myProcess := nil |
|
115 ] |
|
116 ! |
|
117 |
|
118 becomeActive |
|
119 ActiveGroup := self. |
|
120 ! ! |
|
121 |
|
122 !WindowGroup methodsFor:'initialization'! |
|
123 |
|
124 reinitialize |
|
125 myProcess := nil. |
|
126 "throw away old events" |
|
127 mySensor := WindowSensor new. |
|
128 mySensor eventSemaphore:Semaphore new |
|
129 ! |
|
130 |
|
131 initialize |
|
132 mySensor := WindowSensor new. |
|
133 mySensor eventSemaphore:Semaphore new |
|
134 ! ! |