@@ -440,7 +440,7 @@ AddOnManager::_UnregisterAddOn(BEntry& entry)
|
|||||||
gInputServer->SetMethodReplicant(NULL);
|
gInputServer->SetMethodReplicant(NULL);
|
||||||
} else if (method != NULL) {
|
} else if (method != NULL) {
|
||||||
BMessage msg(IS_REMOVE_METHOD);
|
BMessage msg(IS_REMOVE_METHOD);
|
||||||
msg.AddInt32("cookie", (uint32)method);
|
msg.AddInt32("cookie", method->fOwner->Cookie());
|
||||||
if (gInputServer->MethodReplicant())
|
if (gInputServer->MethodReplicant())
|
||||||
gInputServer->MethodReplicant()->SendMessage(&msg);
|
gInputServer->MethodReplicant()->SendMessage(&msg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -625,11 +625,23 @@ void
|
|||||||
InputServer::HandleSetMethod(BMessage* message)
|
InputServer::HandleSetMethod(BMessage* message)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
uint32 cookie;
|
int32 cookie;
|
||||||
if (message->FindInt32("cookie", (int32*)&cookie) == B_OK) {
|
if (message->FindInt32("cookie", &cookie) != B_OK)
|
||||||
BInputServerMethod *method = (BInputServerMethod*)cookie;
|
return;
|
||||||
PRINT(("%s cookie %p\n", __PRETTY_FUNCTION__, method));
|
if (cookie == gKeymapMethod.fOwner->Cookie()) {
|
||||||
SetActiveMethod(method);
|
SetActiveMethod(&gKeymapMethod);
|
||||||
|
} else {
|
||||||
|
BAutolock lock(InputServer::gInputMethodListLocker);
|
||||||
|
for (int32 i = 0; i < gInputMethodList.CountItems(); i++) {
|
||||||
|
BInputServerMethod* method
|
||||||
|
= (BInputServerMethod*)InputServer::gInputMethodList.ItemAt(i);
|
||||||
|
if (method->fOwner->Cookie() == cookie) {
|
||||||
|
PRINT(("%s cookie %" B_PRId32 "\n", __PRETTY_FUNCTION__,
|
||||||
|
cookie));
|
||||||
|
SetActiveMethod(method);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ class _BMethodAddOn_ {
|
|||||||
status_t SetMenu(const BMenu* menu, const BMessenger& messenger);
|
status_t SetMenu(const BMenu* menu, const BMessenger& messenger);
|
||||||
status_t MethodActivated(bool activate);
|
status_t MethodActivated(bool activate);
|
||||||
status_t AddMethod();
|
status_t AddMethod();
|
||||||
|
int32 Cookie() { return fCookie; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BInputServerMethod* fMethod;
|
BInputServerMethod* fMethod;
|
||||||
@@ -106,6 +107,7 @@ class _BMethodAddOn_ {
|
|||||||
uchar fIcon[16*16*1];
|
uchar fIcon[16*16*1];
|
||||||
const BMenu* fMenu;
|
const BMenu* fMenu;
|
||||||
BMessenger fMessenger;
|
BMessenger fMessenger;
|
||||||
|
int32 fCookie;
|
||||||
};
|
};
|
||||||
|
|
||||||
class KeymapMethod : public BInputServerMethod {
|
class KeymapMethod : public BInputServerMethod {
|
||||||
|
|||||||
@@ -153,10 +153,14 @@ BInputServerMethod::_ReservedInputServerMethod4()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int32 sNextMethodCookie = 1;
|
||||||
|
|
||||||
|
|
||||||
_BMethodAddOn_::_BMethodAddOn_(BInputServerMethod *method, const char *name,
|
_BMethodAddOn_::_BMethodAddOn_(BInputServerMethod *method, const char *name,
|
||||||
const uchar *icon)
|
const uchar *icon)
|
||||||
: fMethod(method),
|
: fMethod(method),
|
||||||
fMenu(NULL)
|
fMenu(NULL),
|
||||||
|
fCookie(sNextMethodCookie++)
|
||||||
{
|
{
|
||||||
fName = strdup(name);
|
fName = strdup(name);
|
||||||
if (icon != NULL)
|
if (icon != NULL)
|
||||||
@@ -183,7 +187,7 @@ _BMethodAddOn_::SetName(const char* name)
|
|||||||
fName = strdup(name);
|
fName = strdup(name);
|
||||||
|
|
||||||
BMessage msg(IS_UPDATE_NAME);
|
BMessage msg(IS_UPDATE_NAME);
|
||||||
msg.AddInt32("cookie", (uint32)fMethod);
|
msg.AddInt32("cookie", fCookie);
|
||||||
msg.AddString("name", name);
|
msg.AddString("name", name);
|
||||||
if (((InputServer*)be_app)->MethodReplicant())
|
if (((InputServer*)be_app)->MethodReplicant())
|
||||||
return ((InputServer*)be_app)->MethodReplicant()->SendMessage(&msg);
|
return ((InputServer*)be_app)->MethodReplicant()->SendMessage(&msg);
|
||||||
@@ -203,7 +207,7 @@ _BMethodAddOn_::SetIcon(const uchar* icon)
|
|||||||
memset(fIcon, 0x1d, 16*16*1);
|
memset(fIcon, 0x1d, 16*16*1);
|
||||||
|
|
||||||
BMessage msg(IS_UPDATE_ICON);
|
BMessage msg(IS_UPDATE_ICON);
|
||||||
msg.AddInt32("cookie", (uint32)fMethod);
|
msg.AddInt32("cookie", fCookie);
|
||||||
msg.AddData("icon", B_RAW_TYPE, icon, 16*16*1);
|
msg.AddData("icon", B_RAW_TYPE, icon, 16*16*1);
|
||||||
if (((InputServer*)be_app)->MethodReplicant())
|
if (((InputServer*)be_app)->MethodReplicant())
|
||||||
return ((InputServer*)be_app)->MethodReplicant()->SendMessage(&msg);
|
return ((InputServer*)be_app)->MethodReplicant()->SendMessage(&msg);
|
||||||
@@ -220,7 +224,7 @@ _BMethodAddOn_::SetMenu(const BMenu *menu, const BMessenger &messenger)
|
|||||||
fMessenger = messenger;
|
fMessenger = messenger;
|
||||||
|
|
||||||
BMessage msg(IS_UPDATE_MENU);
|
BMessage msg(IS_UPDATE_MENU);
|
||||||
msg.AddInt32("cookie", (uint32)fMethod);
|
msg.AddInt32("cookie", fCookie);
|
||||||
BMessage menuMsg;
|
BMessage menuMsg;
|
||||||
if (menu)
|
if (menu)
|
||||||
menu->Archive(&menuMsg);
|
menu->Archive(&menuMsg);
|
||||||
@@ -238,10 +242,10 @@ _BMethodAddOn_::MethodActivated(bool activate)
|
|||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
if (fMethod) {
|
if (fMethod) {
|
||||||
PRINT(("%s cookie %p\n", __PRETTY_FUNCTION__, fMethod));
|
PRINT(("%s cookie %" B_PRId32 "\n", __PRETTY_FUNCTION__, fCookie));
|
||||||
if (activate && ((InputServer*)be_app)->MethodReplicant()) {
|
if (activate && ((InputServer*)be_app)->MethodReplicant()) {
|
||||||
BMessage msg(IS_UPDATE_METHOD);
|
BMessage msg(IS_UPDATE_METHOD);
|
||||||
msg.AddInt32("cookie", (uint32)fMethod);
|
msg.AddInt32("cookie", fCookie);
|
||||||
((InputServer*)be_app)->MethodReplicant()->SendMessage(&msg);
|
((InputServer*)be_app)->MethodReplicant()->SendMessage(&msg);
|
||||||
}
|
}
|
||||||
return fMethod->MethodActivated(activate);
|
return fMethod->MethodActivated(activate);
|
||||||
@@ -253,9 +257,9 @@ _BMethodAddOn_::MethodActivated(bool activate)
|
|||||||
status_t
|
status_t
|
||||||
_BMethodAddOn_::AddMethod()
|
_BMethodAddOn_::AddMethod()
|
||||||
{
|
{
|
||||||
PRINT(("%s cookie %p\n", __PRETTY_FUNCTION__, fMethod));
|
PRINT(("%s cookie %" B_PRId32 "\n", __PRETTY_FUNCTION__, fCookie));
|
||||||
BMessage msg(IS_ADD_METHOD);
|
BMessage msg(IS_ADD_METHOD);
|
||||||
msg.AddInt32("cookie", (uint32)fMethod);
|
msg.AddInt32("cookie", fCookie);
|
||||||
msg.AddString("name", fName);
|
msg.AddString("name", fName);
|
||||||
msg.AddData("icon", B_RAW_TYPE, fIcon, 16*16*1);
|
msg.AddData("icon", B_RAW_TYPE, fIcon, 16*16*1);
|
||||||
if (((InputServer*)be_app)->MethodReplicant())
|
if (((InputServer*)be_app)->MethodReplicant())
|
||||||
|
|||||||
Reference in New Issue
Block a user