Added input method key switching (alt+space)

Added code to enable deskbar replicant loading after input_server is started


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10664 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2005-01-11 00:34:37 +00:00
parent dcab43435a
commit e3c78aded7
5 changed files with 117 additions and 67 deletions
+53 -14
View File
@@ -423,12 +423,31 @@ AddOnManager::RegisterMethod(BInputServerMethod *method, const entry_ref &ref, i
InputServer::gInputMethodList.AddItem(method); InputServer::gInputMethodList.AddItem(method);
if (((InputServer*)be_app)->MethodReplicant() == NULL) { if (((InputServer*)be_app)->MethodReplicant() == NULL) {
LoadReplicant();
if (((InputServer*)be_app)->MethodReplicant()) {
_BMethodAddOn_ *addon = InputServer::gKeymapMethod.fOwner;
addon->AddMethod();
}
}
if (((InputServer*)be_app)->MethodReplicant()) {
_BMethodAddOn_ *addon = method->fOwner;
addon->AddMethod();
}
}
void
AddOnManager::LoadReplicant()
{
CALLED();
app_info info; app_info info;
be_app->GetAppInfo(&info); be_app->GetAppInfo(&info);
status_t err = BDeskbar().AddItem(&info.ref); status_t err = BDeskbar().AddItem(&info.ref);
if (err!=B_OK) { if (err!=B_OK) {
PRINTERR(("Deskbar refuses to add method replicant\n")); PRINTERR(("Deskbar refuses to add method replicant: %s\n", strerror(err)));
} }
BMessage request(B_GET_PROPERTY); BMessage request(B_GET_PROPERTY);
BMessenger to; BMessenger to;
@@ -468,22 +487,9 @@ AddOnManager::RegisterMethod(BInputServerMethod *method, const entry_ref &ref, i
} }
} }
} }
if (((InputServer*)be_app)->MethodReplicant()) {
_BMethodAddOn_ *addon = InputServer::gKeymapMethod.fOwner;
addon->AddMethod();
}
}
if (((InputServer*)be_app)->MethodReplicant()) {
_BMethodAddOn_ *addon = method->fOwner;
addon->AddMethod();
}
} }
// //
int32 int32
AddOnManager::GetReplicantAt(BMessenger target, int32 index) const AddOnManager::GetReplicantAt(BMessenger target, int32 index) const
@@ -609,6 +615,9 @@ AddOnManager::MessageReceived(BMessage *message)
case SYSTEM_SHUTTING_DOWN: case SYSTEM_SHUTTING_DOWN:
status = HandleSystemShuttingDown(message, &reply); status = HandleSystemShuttingDown(message, &reply);
break; break;
case IS_METHOD_REGISTER:
status = HandleMethodReplicant(message, &reply);
break;
default: default:
{ {
return; return;
@@ -738,6 +747,36 @@ status_t
AddOnManager::HandleSystemShuttingDown(BMessage *message, AddOnManager::HandleSystemShuttingDown(BMessage *message,
BMessage *reply) BMessage *reply)
{ {
CALLED();
// TODO // TODO
return B_OK; 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; i<InputServer::gInputMethodList.CountItems(); i++) {
BInputServerMethod *method =
(BInputServerMethod *)InputServer::gInputMethodList.ItemAt(i);
_BMethodAddOn_ *addon = method->fOwner;
addon->AddMethod();
}
}
return B_OK;
}
+2
View File
@@ -43,8 +43,10 @@ class AddOnManager : public BLooper {
status_t HandleStartStopDevices(BMessage*, BMessage*); status_t HandleStartStopDevices(BMessage*, BMessage*);
status_t HandleControlDevices(BMessage*, BMessage*); status_t HandleControlDevices(BMessage*, BMessage*);
status_t HandleSystemShuttingDown(BMessage*, BMessage*); status_t HandleSystemShuttingDown(BMessage*, BMessage*);
status_t HandleMethodReplicant(BMessage*, BMessage*);
status_t HandleNodeMonitor(BMessage*); status_t HandleNodeMonitor(BMessage*);
void LoadReplicant();
int32 GetReplicantAt(BMessenger target, int32 index) const; int32 GetReplicantAt(BMessenger target, int32 index) const;
status_t GetReplicantName(BMessenger target, int32 uid, BMessage *reply) const; status_t GetReplicantName(BMessenger target, int32 uid, BMessage *reply) const;
status_t GetReplicantView(BMessenger target, int32 uid, BMessage *reply) const; status_t GetReplicantView(BMessenger target, int32 uid, BMessage *reply) const;
+23 -13
View File
@@ -45,6 +45,7 @@
#include "InputServer.h" #include "InputServer.h"
#include "InputServerTypes.h" #include "InputServerTypes.h"
#include "kb_mouse_driver.h"
#include "MethodReplicant.h" #include "MethodReplicant.h"
// include app_server headers for communication // include app_server headers for communication
@@ -476,6 +477,7 @@ InputServer::MessageReceived(BMessage *message)
case IS_STOP_DEVICE: case IS_STOP_DEVICE:
case IS_CONTROL_DEVICES: case IS_CONTROL_DEVICES:
case SYSTEM_SHUTTING_DOWN: case SYSTEM_SHUTTING_DOWN:
case IS_METHOD_REGISTER:
fAddOnManager->PostMessage(message); fAddOnManager->PostMessage(message);
return; return;
case B_SOME_APP_LAUNCHED: { 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) if ((outbound->FindData("states", B_UINT8_TYPE, (const void**)&data, &size) == B_OK)
&& (size == (ssize_t)sizeof(fKey_info.key_states))) && (size == (ssize_t)sizeof(fKey_info.key_states)))
memcpy(fKey_info.key_states, data, size); memcpy(fKey_info.key_states, data, size);
} }
default: default:
break; break;
@@ -994,19 +997,19 @@ InputServer::SetNextMethod(bool direction)
LockMethodQueue(); LockMethodQueue();
int32 index = gInputMethodList.IndexOf(fActiveMethod); int32 index = gInputMethodList.IndexOf(fActiveMethod);
if (index < 0) {
UnlockMethodQueue();
return B_ERROR;
}
index += (direction ? 1 : -1); index += (direction ? 1 : -1);
if (index < 0) if (index < -1)
index = fMethodQueue.CountItems() - 1; index = gInputMethodList.CountItems() - 1;
if (index >= fMethodQueue.CountItems()) if (index >= gInputMethodList.CountItems())
index = 0; index = -1;
SetActiveMethod((BInputServerMethod *)gInputMethodList.ItemAt(index)); BInputServerMethod *method = &gKeymapMethod;
if (index != -1)
method = (BInputServerMethod *)gInputMethodList.ItemAt(index);
SetActiveMethod(method);
UnlockMethodQueue(); UnlockMethodQueue();
return B_OK; return B_OK;
@@ -1445,7 +1448,7 @@ InputServer::SanitizeEvents(BList *events)
// we scan for Alt+Space key down events which means we change to next input method // 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 // Note : Shift+Alt+Space key allows to change to the previous input method
if ((fKey_info.modifiers & B_COMMAND_KEY) 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); SetNextMethod(!fKey_info.modifiers & B_SHIFT_KEY);
// this event isn't sent to the user // this event isn't sent to the user
@@ -1618,9 +1621,13 @@ InputServer::ControlDevices(const char* name, input_device_type type, uint32 cod
* Descr: * Descr:
*/ */
bool bool
InputServer::DoMouseAcceleration(long *, InputServer::DoMouseAcceleration(int32 *x,
long *) 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; return true;
} }
@@ -1635,6 +1642,7 @@ InputServer::SetMousePos(long *,
long, long,
long) long)
{ {
CALLED();
return true; return true;
} }
@@ -1648,6 +1656,7 @@ InputServer::SetMousePos(long *,
long *, long *,
BPoint) BPoint)
{ {
CALLED();
return true; return true;
} }
@@ -1662,6 +1671,7 @@ InputServer::SetMousePos(long *,
float, float,
float) float)
{ {
CALLED();
return true; return true;
} }
+1 -1
View File
@@ -166,7 +166,7 @@ public:
static status_t StartStopDevices(BInputServerDevice *isd, bool); static status_t StartStopDevices(BInputServerDevice *isd, bool);
static status_t ControlDevices(const char *, input_device_type, unsigned long, BMessage*); 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*, long, long);
bool SetMousePos(long*, long*, BPoint); bool SetMousePos(long*, long*, BPoint);
bool SetMousePos(long*, long*, float, float); bool SetMousePos(long*, long*, float, float);
+3 -4
View File
@@ -92,6 +92,7 @@ MethodReplicant::~MethodReplicant()
MethodReplicant * MethodReplicant *
MethodReplicant::Instantiate(BMessage *data) MethodReplicant::Instantiate(BMessage *data)
{ {
CALLED();
if (!validate_instantiation(data, REPLICANT_CTL_NAME)) if (!validate_instantiation(data, REPLICANT_CTL_NAME))
return NULL; return NULL;
return new MethodReplicant(data); return new MethodReplicant(data);
@@ -111,17 +112,15 @@ MethodReplicant::Archive(BMessage *data, bool deep) const
void void
MethodReplicant::AttachedToWindow() MethodReplicant::AttachedToWindow()
{ {
CALLED();
BMessenger messenger(this); BMessenger messenger(this);
BMessage msg(IS_METHOD_REGISTER); BMessage msg(IS_METHOD_REGISTER);
msg.AddMessenger("address", messenger); msg.AddMessenger("address", messenger);
BMessenger inputMessenger(fSignature); BMessenger inputMessenger(fSignature);
BMessage reply; if (inputMessenger.SendMessage(&msg)!=B_OK) {
if (inputMessenger.SendMessage(&msg, &reply)!=B_OK) {
printf("error when contacting input_server\n"); printf("error when contacting input_server\n");
} }
PRINT_OBJECT(reply);
} }