diff --git a/src/servers/input/AddOnManager.cpp b/src/servers/input/AddOnManager.cpp index 58717195fc..6d4fed5bca 100644 --- a/src/servers/input/AddOnManager.cpp +++ b/src/servers/input/AddOnManager.cpp @@ -423,55 +423,11 @@ AddOnManager::RegisterMethod(BInputServerMethod *method, const entry_ref &ref, i InputServer::gInputMethodList.AddItem(method); if (((InputServer*)be_app)->MethodReplicant() == NULL) { - app_info info; - be_app->GetAppInfo(&info); - - status_t err = BDeskbar().AddItem(&info.ref); - if (err!=B_OK) { - PRINTERR(("Deskbar refuses to add method replicant\n")); - } - BMessage request(B_GET_PROPERTY); - BMessenger to; - BMessenger status; - - request.AddSpecifier("Messenger"); - request.AddSpecifier("Shelf"); - - // In the Deskbar the Shelf is in the View "Status" in Window "Deskbar" - request.AddSpecifier("View", "Status"); - request.AddSpecifier("Window", "Deskbar"); - to = BMessenger("application/x-vnd.Be-TSKB", -1); - - BMessage reply; - - if ((to.SendMessage(&request, &reply) == B_OK) - && (reply.FindMessenger("result", &status) == B_OK)) { - - // enum replicant in Status view - int32 index = 0; - int32 uid; - while ((uid = GetReplicantAt(status, index++)) >= B_OK) { - BMessage rep_info; - if (GetReplicantName(status, uid, &rep_info) != B_OK) { - continue; - } - const char *name; - if ((rep_info.FindString("result", &name) == B_OK) - && (strcmp(name, REPLICANT_CTL_NAME)==0)) { - BMessage rep_view; - if (GetReplicantView(status, uid, &rep_view)==0) { - BMessenger result; - if (rep_view.FindMessenger("result", &result) == B_OK) { - ((InputServer*)be_app)->SetMethodReplicant(new BMessenger(result)); - } - } - } - } - } + LoadReplicant(); if (((InputServer*)be_app)->MethodReplicant()) { _BMethodAddOn_ *addon = InputServer::gKeymapMethod.fOwner; - addon->AddMethod(); + addon->AddMethod(); } } @@ -482,6 +438,56 @@ AddOnManager::RegisterMethod(BInputServerMethod *method, const entry_ref &ref, i } +void +AddOnManager::LoadReplicant() +{ + CALLED(); + app_info info; + be_app->GetAppInfo(&info); + + status_t err = BDeskbar().AddItem(&info.ref); + if (err!=B_OK) { + PRINTERR(("Deskbar refuses to add method replicant: %s\n", strerror(err))); + } + BMessage request(B_GET_PROPERTY); + BMessenger to; + BMessenger status; + + request.AddSpecifier("Messenger"); + request.AddSpecifier("Shelf"); + + // In the Deskbar the Shelf is in the View "Status" in Window "Deskbar" + request.AddSpecifier("View", "Status"); + request.AddSpecifier("Window", "Deskbar"); + to = BMessenger("application/x-vnd.Be-TSKB", -1); + + BMessage reply; + + if ((to.SendMessage(&request, &reply) == B_OK) + && (reply.FindMessenger("result", &status) == B_OK)) { + + // enum replicant in Status view + int32 index = 0; + int32 uid; + while ((uid = GetReplicantAt(status, index++)) >= B_OK) { + BMessage rep_info; + if (GetReplicantName(status, uid, &rep_info) != B_OK) { + continue; + } + const char *name; + if ((rep_info.FindString("result", &name) == B_OK) + && (strcmp(name, REPLICANT_CTL_NAME)==0)) { + BMessage rep_view; + if (GetReplicantView(status, uid, &rep_view)==0) { + BMessenger result; + if (rep_view.FindMessenger("result", &result) == B_OK) { + ((InputServer*)be_app)->SetMethodReplicant(new BMessenger(result)); + } + } + } + } + } +} // @@ -609,6 +615,9 @@ AddOnManager::MessageReceived(BMessage *message) case SYSTEM_SHUTTING_DOWN: status = HandleSystemShuttingDown(message, &reply); break; + case IS_METHOD_REGISTER: + status = HandleMethodReplicant(message, &reply); + break; default: { return; @@ -738,6 +747,36 @@ status_t AddOnManager::HandleSystemShuttingDown(BMessage *message, BMessage *reply) { + CALLED(); + // TODO return B_OK; } + +/* + * Method: AddOnManager::HandleMethodReplicant() + * Descr: + */ +status_t +AddOnManager::HandleMethodReplicant(BMessage *message, + BMessage *reply) +{ + CALLED(); + LoadReplicant(); + + BAutolock lock(InputServer::gInputMethodListLocker); + + if (((InputServer*)be_app)->MethodReplicant()) { + _BMethodAddOn_ *addon = InputServer::gKeymapMethod.fOwner; + addon->AddMethod(); + + for (int32 i=0; ifOwner; + addon->AddMethod(); + } + } + + return B_OK; +} diff --git a/src/servers/input/AddOnManager.h b/src/servers/input/AddOnManager.h index bf3b556fb4..8a3e2f381a 100644 --- a/src/servers/input/AddOnManager.h +++ b/src/servers/input/AddOnManager.h @@ -43,8 +43,10 @@ class AddOnManager : public BLooper { status_t HandleStartStopDevices(BMessage*, BMessage*); status_t HandleControlDevices(BMessage*, BMessage*); status_t HandleSystemShuttingDown(BMessage*, BMessage*); + status_t HandleMethodReplicant(BMessage*, BMessage*); status_t HandleNodeMonitor(BMessage*); + void LoadReplicant(); int32 GetReplicantAt(BMessenger target, int32 index) const; status_t GetReplicantName(BMessenger target, int32 uid, BMessage *reply) const; status_t GetReplicantView(BMessenger target, int32 uid, BMessage *reply) const; diff --git a/src/servers/input/InputServer.cpp b/src/servers/input/InputServer.cpp index 177db45d68..1656a8c464 100644 --- a/src/servers/input/InputServer.cpp +++ b/src/servers/input/InputServer.cpp @@ -45,6 +45,7 @@ #include "InputServer.h" #include "InputServerTypes.h" +#include "kb_mouse_driver.h" #include "MethodReplicant.h" // include app_server headers for communication @@ -476,6 +477,7 @@ InputServer::MessageReceived(BMessage *message) case IS_STOP_DEVICE: case IS_CONTROL_DEVICES: case SYSTEM_SHUTTING_DOWN: + case IS_METHOD_REGISTER: fAddOnManager->PostMessage(message); return; case B_SOME_APP_LAUNCHED: { @@ -778,6 +780,7 @@ InputServer::HandleSetMousePosition(BMessage *message, BMessage *outbound) if ((outbound->FindData("states", B_UINT8_TYPE, (const void**)&data, &size) == B_OK) && (size == (ssize_t)sizeof(fKey_info.key_states))) memcpy(fKey_info.key_states, data, size); + } default: break; @@ -992,21 +995,21 @@ status_t InputServer::SetNextMethod(bool direction) { LockMethodQueue(); - + int32 index = gInputMethodList.IndexOf(fActiveMethod); - if (index < 0) { - UnlockMethodQueue(); - return B_ERROR; - } - index += (direction ? 1 : -1); - if (index < 0) - index = fMethodQueue.CountItems() - 1; - if (index >= fMethodQueue.CountItems()) - index = 0; + if (index < -1) + index = gInputMethodList.CountItems() - 1; + if (index >= gInputMethodList.CountItems()) + index = -1; - SetActiveMethod((BInputServerMethod *)gInputMethodList.ItemAt(index)); + BInputServerMethod *method = &gKeymapMethod; + + if (index != -1) + method = (BInputServerMethod *)gInputMethodList.ItemAt(index); + + SetActiveMethod(method); UnlockMethodQueue(); return B_OK; @@ -1445,9 +1448,9 @@ InputServer::SanitizeEvents(BList *events) // we scan for Alt+Space key down events which means we change to next input method // Note : Shift+Alt+Space key allows to change to the previous input method if ((fKey_info.modifiers & B_COMMAND_KEY) - && (fKey_info.key_states[B_SPACE >> 3] & (1 << (7 - (B_SPACE % 8))))) { + && (fKey_info.key_states[KEY_Spacebar >> 3] & (1 << (7 - (KEY_Spacebar % 8))))) { SetNextMethod(!fKey_info.modifiers & B_SHIFT_KEY); - + // this event isn't sent to the user events->RemoveItem(index); delete event; @@ -1617,10 +1620,14 @@ InputServer::ControlDevices(const char* name, input_device_type type, uint32 cod * Method: InputServer::DoMouseAcceleration() * Descr: */ -bool -InputServer::DoMouseAcceleration(long *, - long *) +bool +InputServer::DoMouseAcceleration(int32 *x, + int32 *y) { + CALLED(); + int32 speed = fMouseSettings.MouseSpeed() >> 15; + //*y = *x * speed; + PRINT(("DoMouse : %ld %ld %ld %ld\n", *x, *y, speed, fMouseSettings.MouseSpeed())); return true; } @@ -1635,6 +1642,7 @@ InputServer::SetMousePos(long *, long, long) { + CALLED(); return true; } @@ -1648,6 +1656,7 @@ InputServer::SetMousePos(long *, long *, BPoint) { + CALLED(); return true; } @@ -1662,6 +1671,7 @@ InputServer::SetMousePos(long *, float, float) { + CALLED(); return true; } diff --git a/src/servers/input/InputServer.h b/src/servers/input/InputServer.h index 02525dd45e..0398d78300 100644 --- a/src/servers/input/InputServer.h +++ b/src/servers/input/InputServer.h @@ -166,7 +166,7 @@ public: static status_t StartStopDevices(BInputServerDevice *isd, bool); static status_t ControlDevices(const char *, input_device_type, unsigned long, BMessage*); - bool DoMouseAcceleration(long*, long*); + bool DoMouseAcceleration(int32*, int32*); bool SetMousePos(long*, long*, long, long); bool SetMousePos(long*, long*, BPoint); bool SetMousePos(long*, long*, float, float); diff --git a/src/servers/input/MethodReplicant.cpp b/src/servers/input/MethodReplicant.cpp index 53a1a006ad..fbf534c270 100644 --- a/src/servers/input/MethodReplicant.cpp +++ b/src/servers/input/MethodReplicant.cpp @@ -92,6 +92,7 @@ MethodReplicant::~MethodReplicant() MethodReplicant * MethodReplicant::Instantiate(BMessage *data) { + CALLED(); if (!validate_instantiation(data, REPLICANT_CTL_NAME)) return NULL; return new MethodReplicant(data); @@ -111,17 +112,15 @@ MethodReplicant::Archive(BMessage *data, bool deep) const void MethodReplicant::AttachedToWindow() { + CALLED(); BMessenger messenger(this); BMessage msg(IS_METHOD_REGISTER); msg.AddMessenger("address", messenger); BMessenger inputMessenger(fSignature); - BMessage reply; - if (inputMessenger.SendMessage(&msg, &reply)!=B_OK) { + if (inputMessenger.SendMessage(&msg)!=B_OK) { printf("error when contacting input_server\n"); } - - PRINT_OBJECT(reply); }