2 * Copyright 2005, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
6 * Axel Dörfler, axeld@pinc-software.de
9 // TODO: introduce means to define event stream features (like local vs. net)
10 // TODO: introduce the possibility to identify a stream by a unique name
13 #include "EventStream.h"
14 #include "InputManager.h"
19 InputManager
* gInputManager
;
20 // the global input manager will be created by the AppServer
23 InputManager::InputManager()
24 : BLocker("input manager"),
25 fFreeStreams(2, true),
31 InputManager::~InputManager()
37 InputManager::AddStream(EventStream
* stream
)
40 return fFreeStreams
.AddItem(stream
);
45 InputManager::RemoveStream(EventStream
* stream
)
48 fFreeStreams
.RemoveItem(stream
);
53 InputManager::GetStream()
57 EventStream
* stream
= NULL
;
60 // this deletes the previous invalid stream
62 stream
= fFreeStreams
.RemoveItemAt(0);
63 } while (stream
!= NULL
&& !stream
->IsValid());
68 fUsedStreams
.AddItem(stream
);
74 InputManager::PutStream(EventStream
* stream
)
81 fUsedStreams
.RemoveItem(stream
, false);
82 if (stream
->IsValid())
83 fFreeStreams
.AddItem(stream
);
90 InputManager::UpdateScreenBounds(BRect bounds
)
94 for (int32 i
= fUsedStreams
.CountItems(); i
-- > 0;) {
95 fUsedStreams
.ItemAt(i
)->UpdateScreenBounds(bounds
);
98 for (int32 i
= fFreeStreams
.CountItems(); i
-- > 0;) {
99 fFreeStreams
.ItemAt(i
)->UpdateScreenBounds(bounds
);