* Mark InputDeviceListItems only as running if calling Start() for the

device returned B_OK.
* In the InputServer destructor, don't check the fAddOnManager pointer,
  but check the success of calling Lock() on it instead, which should
  be much safer.
* In StartStopDevices(), really start or stop all published devices for
  the given BInputServerDevice, not only the first one found. Simplify
  the check whether anything needs to be done.
* Change a bit the return codes of StartStopDevices(). Especially the
  version that's supposed to start or stop all devices will still try
  to do it for the rest of them.
* Removed no longer needed _FindInputDeviceListItem().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28351 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2008-10-27 22:19:55 +00:00
parent dab68c33ed
commit 393f282c79
2 changed files with 19 additions and 29 deletions
+19 -27
View File
@@ -94,7 +94,7 @@ InputDeviceListItem::Start()
if (err != B_OK) {
PRINTERR((" error: %s (%lx)\n", strerror(err), err));
}
fRunning = true;
fRunning = err == B_OK;
}
@@ -240,10 +240,8 @@ InputServer::InputServer()
InputServer::~InputServer()
{
CALLED();
if (fAddOnManager != NULL) {
fAddOnManager->Lock();
if (fAddOnManager->Lock())
fAddOnManager->Quit();
}
_ReleaseInput(NULL);
}
@@ -1067,21 +1065,6 @@ InputServer::EventLoopRunning()
}
/*! The fInputDeviceListLocker must be locked when calling this function */
InputDeviceListItem*
InputServer::_FindInputDeviceListItem(BInputServerDevice& device)
{
for (int32 i = fInputDeviceList.CountItems() - 1; i >= 0; i--) {
InputDeviceListItem* item = (InputDeviceListItem*)fInputDeviceList.ItemAt(i);
if (item->ServerDevice() == &device)
return item;
}
return NULL;
}
status_t
InputServer::GetDeviceInfo(const char* name, input_device_type *_type,
bool *_isRunning)
@@ -1220,8 +1203,12 @@ InputServer::StartStopDevices(const char* name, input_device_type type,
continue;
if (item->Matches(name, type)) {
if (!doStart ^ item->Running())
return B_ERROR;
if (doStart == item->Running()) {
if (name)
return B_OK;
else
continue;
}
if (doStart)
item->Start();
@@ -1233,8 +1220,10 @@ InputServer::StartStopDevices(const char* name, input_device_type type,
}
}
if (name)
if (name) {
// item not found
return B_ERROR;
}
return B_OK;
}
@@ -1247,17 +1236,20 @@ InputServer::StartStopDevices(BInputServerDevice& serverDevice, bool doStart)
CALLED();
BAutolock lock(fInputDeviceListLocker);
InputDeviceListItem* item = _FindInputDeviceListItem(serverDevice);
if (item != NULL) {
if (!doStart ^ item->Running())
return B_ERROR;
for (int32 i = fInputDeviceList.CountItems() - 1; i >= 0; i--) {
InputDeviceListItem* item = (InputDeviceListItem*)fInputDeviceList.ItemAt(i);
if (item->ServerDevice() != &serverDevice)
continue;
if (doStart == item->Running())
continue;
if (doStart)
item->Start();
else
item->Stop();
}
EXIT();
return B_OK;
}
-2
View File
@@ -206,8 +206,6 @@ class InputServer : public BApplication {
status_t _AcquireInput(BMessage& message, BMessage& reply);
void _ReleaseInput(BMessage* message);
InputDeviceListItem* _FindInputDeviceListItem(BInputServerDevice& device);
private:
bool fEventLoopRunning;
bool fSafeMode;