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:
@@ -423,55 +423,11 @@ 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) {
|
||||||
app_info info;
|
LoadReplicant();
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (((InputServer*)be_app)->MethodReplicant()) {
|
if (((InputServer*)be_app)->MethodReplicant()) {
|
||||||
_BMethodAddOn_ *addon = InputServer::gKeymapMethod.fOwner;
|
_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:
|
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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -992,21 +995,21 @@ status_t
|
|||||||
InputServer::SetNextMethod(bool direction)
|
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,9 +1448,9 @@ 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
|
||||||
events->RemoveItem(index);
|
events->RemoveItem(index);
|
||||||
delete event;
|
delete event;
|
||||||
@@ -1617,10 +1620,14 @@ InputServer::ControlDevices(const char* name, input_device_type type, uint32 cod
|
|||||||
* Method: InputServer::DoMouseAcceleration()
|
* Method: InputServer::DoMouseAcceleration()
|
||||||
* 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user