Use one BPortLink (fAppServerLink) instead of always creating a new one to send events to the app_server.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12427 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
597c548ca3
commit
fd5ac83a1a
@ -179,6 +179,11 @@ InputServer::InputServer(void) : BApplication(INPUTSERVER_SIGNATURE),
|
|||||||
if ((err = send_data(appThreadId, 0, buffer, sizeof(buffer)))!=B_OK)
|
if ((err = send_data(appThreadId, 0, buffer, sizeof(buffer)))!=B_OK)
|
||||||
PRINTERR(("error when send_data %s\n", strerror(err)));
|
PRINTERR(("error when send_data %s\n", strerror(err)));
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
port_id input_port = find_port(SERVER_INPUT_PORT);
|
||||||
|
if (input_port == B_NAME_NOT_FOUND)
|
||||||
|
PRINTERR(("input_server couldn't find app_server's input port\n"));
|
||||||
|
fAppServerLink = new BPortLink(input_port);
|
||||||
#endif // USE_R5_STYLE_COMM
|
#endif // USE_R5_STYLE_COMM
|
||||||
|
|
||||||
InitKeyboardMouseStates();
|
InitKeyboardMouseStates();
|
||||||
@ -1096,7 +1101,7 @@ status_t
|
|||||||
InputServer::EventLoop()
|
InputServer::EventLoop()
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
fEventLooperPort = create_port(100, "obos_is_event_port");
|
fEventLooperPort = create_port(100, "haiku_is_event_port");
|
||||||
if(fEventLooperPort < 0) {
|
if(fEventLooperPort < 0) {
|
||||||
PRINTERR(("InputServer: create_port error: (0x%x) %s\n", fEventLooperPort, strerror(fEventLooperPort)));
|
PRINTERR(("InputServer: create_port error: (0x%x) %s\n", fEventLooperPort, strerror(fEventLooperPort)));
|
||||||
}
|
}
|
||||||
@ -1191,22 +1196,24 @@ InputServer::DispatchEvent(BMessage *message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef USE_R5_STYLE_COMM
|
#ifndef USE_R5_STYLE_COMM
|
||||||
port_id pid = find_port(SERVER_INPUT_PORT);
|
if (!fAppServerLink) {
|
||||||
|
debugger("InputServer::DispatchEvent(): app_server link not valid\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
BPortLink *appsvrlink = new BPortLink(pid);
|
|
||||||
switch(message->what){
|
switch(message->what){
|
||||||
case B_MOUSE_MOVED:{
|
case B_MOUSE_MOVED:{
|
||||||
uint32 buttons;
|
uint32 buttons;
|
||||||
BPoint pt;
|
BPoint pt;
|
||||||
message->FindPoint("where",&pt);
|
message->FindPoint("where",&pt);
|
||||||
int64 time=(int64)real_time_clock();
|
int64 time=(int64)real_time_clock();
|
||||||
appsvrlink->StartMessage(B_MOUSE_MOVED);
|
fAppServerLink->StartMessage(B_MOUSE_MOVED);
|
||||||
appsvrlink->Attach(&time,sizeof(int64));
|
fAppServerLink->Attach(&time,sizeof(int64));
|
||||||
appsvrlink->Attach(&pt.x,sizeof(float));
|
fAppServerLink->Attach(&pt.x,sizeof(float));
|
||||||
appsvrlink->Attach(&pt.y,sizeof(float));
|
fAppServerLink->Attach(&pt.y,sizeof(float));
|
||||||
message->FindInt32("buttons",buttons);
|
message->FindInt32("buttons",buttons);
|
||||||
appsvrlink->Attach(&buttons,sizeof(uint32));
|
fAppServerLink->Attach(&buttons,sizeof(uint32));
|
||||||
appsvrlink->Flush();
|
fAppServerLink->Flush();
|
||||||
PRINT(("B_MOUSE_MOVED: x = %lu: y = %lu: time = %llu: buttons = %lu\n",pt.x,pt.y,time,buttons));
|
PRINT(("B_MOUSE_MOVED: x = %lu: y = %lu: time = %llu: buttons = %lu\n",pt.x,pt.y,time,buttons));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1222,14 +1229,14 @@ InputServer::DispatchEvent(BMessage *message)
|
|||||||
message->FindInt32("clicks",&clicks)!=B_OK)
|
message->FindInt32("clicks",&clicks)!=B_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
appsvrlink->StartMessage(B_MOUSE_DOWN);
|
fAppServerLink->StartMessage(B_MOUSE_DOWN);
|
||||||
appsvrlink->Attach(&time, sizeof(int64));
|
fAppServerLink->Attach(&time, sizeof(int64));
|
||||||
appsvrlink->Attach(&pt.x,sizeof(float));
|
fAppServerLink->Attach(&pt.x,sizeof(float));
|
||||||
appsvrlink->Attach(&pt.y,sizeof(float));
|
fAppServerLink->Attach(&pt.y,sizeof(float));
|
||||||
appsvrlink->Attach(&mod, sizeof(uint32));
|
fAppServerLink->Attach(&mod, sizeof(uint32));
|
||||||
appsvrlink->Attach(&buttons, sizeof(uint32));
|
fAppServerLink->Attach(&buttons, sizeof(uint32));
|
||||||
appsvrlink->Attach(&clicks, sizeof(uint32));
|
fAppServerLink->Attach(&clicks, sizeof(uint32));
|
||||||
appsvrlink->Flush();
|
fAppServerLink->Flush();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_MOUSE_UP:{
|
case B_MOUSE_UP:{
|
||||||
@ -1241,12 +1248,12 @@ InputServer::DispatchEvent(BMessage *message)
|
|||||||
message->FindInt32("modifiers",&mod)!=B_OK)
|
message->FindInt32("modifiers",&mod)!=B_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
appsvrlink->StartMessage(B_MOUSE_UP);
|
fAppServerLink->StartMessage(B_MOUSE_UP);
|
||||||
appsvrlink->Attach(&time, sizeof(int64));
|
fAppServerLink->Attach(&time, sizeof(int64));
|
||||||
appsvrlink->Attach(&pt.x,sizeof(float));
|
fAppServerLink->Attach(&pt.x,sizeof(float));
|
||||||
appsvrlink->Attach(&pt.y,sizeof(float));
|
fAppServerLink->Attach(&pt.y,sizeof(float));
|
||||||
appsvrlink->Attach(&mod, sizeof(uint32));
|
fAppServerLink->Attach(&mod, sizeof(uint32));
|
||||||
appsvrlink->Flush();
|
fAppServerLink->Flush();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_MOUSE_WHEEL_CHANGED:{
|
case B_MOUSE_WHEEL_CHANGED:{
|
||||||
@ -1255,11 +1262,11 @@ InputServer::DispatchEvent(BMessage *message)
|
|||||||
message->FindFloat("be:wheel_delta_y",&y);
|
message->FindFloat("be:wheel_delta_y",&y);
|
||||||
int64 time=real_time_clock();
|
int64 time=real_time_clock();
|
||||||
|
|
||||||
appsvrlink->StartMessage(B_MOUSE_WHEEL_CHANGED);
|
fAppServerLink->StartMessage(B_MOUSE_WHEEL_CHANGED);
|
||||||
appsvrlink->Attach(&time,sizeof(int64));
|
fAppServerLink->Attach(&time,sizeof(int64));
|
||||||
appsvrlink->Attach(x);
|
fAppServerLink->Attach(x);
|
||||||
appsvrlink->Attach(y);
|
fAppServerLink->Attach(y);
|
||||||
appsvrlink->Flush();
|
fAppServerLink->Flush();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_KEY_DOWN:{
|
case B_KEY_DOWN:{
|
||||||
@ -1280,16 +1287,16 @@ InputServer::DispatchEvent(BMessage *message)
|
|||||||
message->FindString("bytes",&string);
|
message->FindString("bytes",&string);
|
||||||
for(int8 i=0;i<15;i++)
|
for(int8 i=0;i<15;i++)
|
||||||
message->FindInt8("states",i,&keyarray[i]);
|
message->FindInt8("states",i,&keyarray[i]);
|
||||||
appsvrlink->StartMessage(B_KEY_DOWN);
|
fAppServerLink->StartMessage(B_KEY_DOWN);
|
||||||
appsvrlink->Attach(&systime,sizeof(bigtime_t));
|
fAppServerLink->Attach(&systime,sizeof(bigtime_t));
|
||||||
appsvrlink->Attach(scancode);
|
fAppServerLink->Attach(scancode);
|
||||||
appsvrlink->Attach(asciicode);
|
fAppServerLink->Attach(asciicode);
|
||||||
appsvrlink->Attach(repeatcount);
|
fAppServerLink->Attach(repeatcount);
|
||||||
appsvrlink->Attach(modifiers);
|
fAppServerLink->Attach(modifiers);
|
||||||
appsvrlink->Attach(utf8data,sizeof(int8)*3);
|
fAppServerLink->Attach(utf8data,sizeof(int8)*3);
|
||||||
appsvrlink->AttachString(string.String());
|
fAppServerLink->AttachString(string.String());
|
||||||
appsvrlink->Attach(keyarray,sizeof(int8)*16);
|
fAppServerLink->Attach(keyarray,sizeof(int8)*16);
|
||||||
appsvrlink->Flush();
|
fAppServerLink->Flush();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_KEY_UP:{
|
case B_KEY_UP:{
|
||||||
@ -1309,15 +1316,15 @@ InputServer::DispatchEvent(BMessage *message)
|
|||||||
message->FindString("bytes",&string);
|
message->FindString("bytes",&string);
|
||||||
for(int8 i=0;i<15;i++)
|
for(int8 i=0;i<15;i++)
|
||||||
message->FindInt8("states",i,&keyarray[i]);
|
message->FindInt8("states",i,&keyarray[i]);
|
||||||
appsvrlink->StartMessage(B_KEY_UP);
|
fAppServerLink->StartMessage(B_KEY_UP);
|
||||||
appsvrlink->Attach(&systime,sizeof(bigtime_t));
|
fAppServerLink->Attach(&systime,sizeof(bigtime_t));
|
||||||
appsvrlink->Attach(scancode);
|
fAppServerLink->Attach(scancode);
|
||||||
appsvrlink->Attach(asciicode);
|
fAppServerLink->Attach(asciicode);
|
||||||
appsvrlink->Attach(modifiers);
|
fAppServerLink->Attach(modifiers);
|
||||||
appsvrlink->Attach(utf8data,sizeof(int8)*3);
|
fAppServerLink->Attach(utf8data,sizeof(int8)*3);
|
||||||
appsvrlink->AttachString(string.String());
|
fAppServerLink->AttachString(string.String());
|
||||||
appsvrlink->Attach(keyarray,sizeof(int8)*16);
|
fAppServerLink->Attach(keyarray,sizeof(int8)*16);
|
||||||
appsvrlink->Flush();
|
fAppServerLink->Flush();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_UNMAPPED_KEY_DOWN:{
|
case B_UNMAPPED_KEY_DOWN:{
|
||||||
@ -1330,12 +1337,12 @@ InputServer::DispatchEvent(BMessage *message)
|
|||||||
message->FindInt32("modifiers",&modifiers);
|
message->FindInt32("modifiers",&modifiers);
|
||||||
for(int8 i=0;i<15;i++)
|
for(int8 i=0;i<15;i++)
|
||||||
message->FindInt8("states",i,&keyarray[i]);
|
message->FindInt8("states",i,&keyarray[i]);
|
||||||
appsvrlink->StartMessage(B_UNMAPPED_KEY_DOWN);
|
fAppServerLink->StartMessage(B_UNMAPPED_KEY_DOWN);
|
||||||
appsvrlink->Attach(&systime,sizeof(bigtime_t));
|
fAppServerLink->Attach(&systime,sizeof(bigtime_t));
|
||||||
appsvrlink->Attach(scancode);
|
fAppServerLink->Attach(scancode);
|
||||||
appsvrlink->Attach(modifiers);
|
fAppServerLink->Attach(modifiers);
|
||||||
appsvrlink->Attach(keyarray,sizeof(int8)*16);
|
fAppServerLink->Attach(keyarray,sizeof(int8)*16);
|
||||||
appsvrlink->Flush();
|
fAppServerLink->Flush();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_UNMAPPED_KEY_UP:{
|
case B_UNMAPPED_KEY_UP:{
|
||||||
@ -1348,12 +1355,12 @@ InputServer::DispatchEvent(BMessage *message)
|
|||||||
message->FindInt32("modifiers",&modifiers);
|
message->FindInt32("modifiers",&modifiers);
|
||||||
for(int8 i=0;i<15;i++)
|
for(int8 i=0;i<15;i++)
|
||||||
message->FindInt8("states",i,&keyarray[i]);
|
message->FindInt8("states",i,&keyarray[i]);
|
||||||
appsvrlink->StartMessage(B_UNMAPPED_KEY_UP);
|
fAppServerLink->StartMessage(B_UNMAPPED_KEY_UP);
|
||||||
appsvrlink->Attach(&systime,sizeof(bigtime_t));
|
fAppServerLink->Attach(&systime,sizeof(bigtime_t));
|
||||||
appsvrlink->Attach(scancode);
|
fAppServerLink->Attach(scancode);
|
||||||
appsvrlink->Attach(modifiers);
|
fAppServerLink->Attach(modifiers);
|
||||||
appsvrlink->Attach(keyarray,sizeof(int8)*16);
|
fAppServerLink->Attach(keyarray,sizeof(int8)*16);
|
||||||
appsvrlink->Flush();
|
fAppServerLink->Flush();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_MODIFIERS_CHANGED:{
|
case B_MODIFIERS_CHANGED:{
|
||||||
@ -1367,20 +1374,19 @@ InputServer::DispatchEvent(BMessage *message)
|
|||||||
message->FindInt32("be:old_modifiers",&oldmodifiers);
|
message->FindInt32("be:old_modifiers",&oldmodifiers);
|
||||||
for(int8 i=0;i<15;i++)
|
for(int8 i=0;i<15;i++)
|
||||||
message->FindInt8("states",i,&keyarray[i]);
|
message->FindInt8("states",i,&keyarray[i]);
|
||||||
appsvrlink->StartMessage(B_MODIFIERS_CHANGED);
|
fAppServerLink->StartMessage(B_MODIFIERS_CHANGED);
|
||||||
appsvrlink->Attach(&systime,sizeof(bigtime_t));
|
fAppServerLink->Attach(&systime,sizeof(bigtime_t));
|
||||||
appsvrlink->Attach(scancode);
|
fAppServerLink->Attach(scancode);
|
||||||
appsvrlink->Attach(modifiers);
|
fAppServerLink->Attach(modifiers);
|
||||||
appsvrlink->Attach(oldmodifiers);
|
fAppServerLink->Attach(oldmodifiers);
|
||||||
appsvrlink->Attach(keyarray,sizeof(int8)*16);
|
fAppServerLink->Attach(keyarray,sizeof(int8)*16);
|
||||||
appsvrlink->Flush();
|
fAppServerLink->Flush();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
delete appsvrlink;
|
|
||||||
|
|
||||||
#else // USE_R5_STYLE_COMM
|
#else // USE_R5_STYLE_COMM
|
||||||
|
|
||||||
|
@ -236,9 +236,7 @@ private:
|
|||||||
|
|
||||||
#ifndef USE_R5_STYLE_COMM
|
#ifndef USE_R5_STYLE_COMM
|
||||||
// added this to communicate via portlink
|
// added this to communicate via portlink
|
||||||
|
BPortLink *fAppServerLink;
|
||||||
BPortLink *serverlink;
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
sem_id fCursorSem;
|
sem_id fCursorSem;
|
||||||
|
Loading…
Reference in New Issue
Block a user