* 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:
@@ -94,7 +94,7 @@ InputDeviceListItem::Start()
|
|||||||
if (err != B_OK) {
|
if (err != B_OK) {
|
||||||
PRINTERR((" error: %s (%lx)\n", strerror(err), err));
|
PRINTERR((" error: %s (%lx)\n", strerror(err), err));
|
||||||
}
|
}
|
||||||
fRunning = true;
|
fRunning = err == B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -240,10 +240,8 @@ InputServer::InputServer()
|
|||||||
InputServer::~InputServer()
|
InputServer::~InputServer()
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
if (fAddOnManager != NULL) {
|
if (fAddOnManager->Lock())
|
||||||
fAddOnManager->Lock();
|
|
||||||
fAddOnManager->Quit();
|
fAddOnManager->Quit();
|
||||||
}
|
|
||||||
|
|
||||||
_ReleaseInput(NULL);
|
_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
|
status_t
|
||||||
InputServer::GetDeviceInfo(const char* name, input_device_type *_type,
|
InputServer::GetDeviceInfo(const char* name, input_device_type *_type,
|
||||||
bool *_isRunning)
|
bool *_isRunning)
|
||||||
@@ -1220,8 +1203,12 @@ InputServer::StartStopDevices(const char* name, input_device_type type,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (item->Matches(name, type)) {
|
if (item->Matches(name, type)) {
|
||||||
if (!doStart ^ item->Running())
|
if (doStart == item->Running()) {
|
||||||
return B_ERROR;
|
if (name)
|
||||||
|
return B_OK;
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (doStart)
|
if (doStart)
|
||||||
item->Start();
|
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_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -1247,17 +1236,20 @@ InputServer::StartStopDevices(BInputServerDevice& serverDevice, bool doStart)
|
|||||||
CALLED();
|
CALLED();
|
||||||
BAutolock lock(fInputDeviceListLocker);
|
BAutolock lock(fInputDeviceListLocker);
|
||||||
|
|
||||||
InputDeviceListItem* item = _FindInputDeviceListItem(serverDevice);
|
for (int32 i = fInputDeviceList.CountItems() - 1; i >= 0; i--) {
|
||||||
if (item != NULL) {
|
InputDeviceListItem* item = (InputDeviceListItem*)fInputDeviceList.ItemAt(i);
|
||||||
if (!doStart ^ item->Running())
|
|
||||||
return B_ERROR;
|
if (item->ServerDevice() != &serverDevice)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (doStart == item->Running())
|
||||||
|
continue;
|
||||||
|
|
||||||
if (doStart)
|
if (doStart)
|
||||||
item->Start();
|
item->Start();
|
||||||
else
|
else
|
||||||
item->Stop();
|
item->Stop();
|
||||||
}
|
}
|
||||||
EXIT();
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,8 +206,6 @@ class InputServer : public BApplication {
|
|||||||
status_t _AcquireInput(BMessage& message, BMessage& reply);
|
status_t _AcquireInput(BMessage& message, BMessage& reply);
|
||||||
void _ReleaseInput(BMessage* message);
|
void _ReleaseInput(BMessage* message);
|
||||||
|
|
||||||
InputDeviceListItem* _FindInputDeviceListItem(BInputServerDevice& device);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool fEventLoopRunning;
|
bool fEventLoopRunning;
|
||||||
bool fSafeMode;
|
bool fSafeMode;
|
||||||
|
|||||||
Reference in New Issue
Block a user