From 33140fa00143419ea8a525a6972fc62a376b8d9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Wed, 29 Sep 2004 15:42:47 +0000 Subject: [PATCH] added file debug output for daemon mode added some R5 app_server communication init git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9112 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/input/AddOnManager.cpp | 2 +- src/servers/input/InputServer.cpp | 59 +++++++++++++++++++++--------- src/servers/input/InputServer.h | 34 ++++++++++++----- 3 files changed, 67 insertions(+), 28 deletions(-) diff --git a/src/servers/input/AddOnManager.cpp b/src/servers/input/AddOnManager.cpp index 62be7d58e3..78b71ddb6f 100644 --- a/src/servers/input/AddOnManager.cpp +++ b/src/servers/input/AddOnManager.cpp @@ -253,7 +253,7 @@ AddOnManager::RegisterAddOns() const directory_which directories[] = { B_USER_ADDONS_DIRECTORY, B_COMMON_ADDONS_DIRECTORY, -// B_BEOS_ADDONS_DIRECTORY + B_BEOS_ADDONS_DIRECTORY }; const char subDirectories[][24] = { "input_server/devices", diff --git a/src/servers/input/InputServer.cpp b/src/servers/input/InputServer.cpp index cddc3a0b14..221398bbf4 100644 --- a/src/servers/input/InputServer.cpp +++ b/src/servers/input/InputServer.cpp @@ -31,7 +31,6 @@ #include -#include #include #include #include @@ -40,6 +39,7 @@ #include #include #include +#include #include "InputServer.h" #include "InputServerTypes.h" @@ -74,6 +74,10 @@ BLocker InputServer::gInputMethodListLocker; DeviceManager InputServer::gDeviceManager; +#if DEBUG == 2 +FILE *InputServer::sLogFile = NULL; +#endif + /* * */ @@ -94,6 +98,11 @@ int main() InputServer::InputServer(void) : BApplication(INPUTSERVER_SIGNATURE), sSafeMode(false) { +#if DEBUG == 2 + if (sLogFile == NULL) + sLogFile = fopen("/var/log/input_server.log", "a"); +#endif + CALLED(); void *pointer=NULL; @@ -111,6 +120,20 @@ InputServer::InputServer(void) : BApplication(INPUTSERVER_SIGNATURE), fAddOnManager = new AddOnManager(SafeMode()); fAddOnManager->LoadState(); + + if (has_data(find_thread(NULL))) { + PRINT(("HasData == YES\n")); + uint32 buffer[2]; + memset(buffer, 0, sizeof(buffer)); + int32 code = receive_data(&fAppThreadId, buffer, sizeof(buffer)); + PRINT(("tid : %ld, code :%ld\n", fAppThreadId, code)); + for (int32 i=0; i<2; i++) { + PRINT(("data : %lx\n", buffer[i])); + } + fCursorSem = buffer[0]; + fAppArea = buffer[1]; + + } } /* @@ -121,6 +144,9 @@ InputServer::~InputServer(void) { CALLED(); delete fAddOnManager; +#if DEBUG == 2 + fclose(sLogFile); +#endif } @@ -137,7 +163,6 @@ InputServer::ArgvReceived(int32 argc, char** argv) // :TODO: Shutdown and restart the InputServer. printf("InputServer::ArgvReceived - Restarting ...\n"); status_t quit_status; - //BMessenger msgr = BMessenger("application/x-vnd.OpenBeOS-input_server", -1, &quit_status); BMessenger msgr = BMessenger(INPUTSERVER_SIGNATURE, -1, &quit_status); if (B_OK == quit_status) { BMessage msg = BMessage(B_QUIT_REQUESTED); @@ -312,6 +337,8 @@ InputServer::MessageReceived(BMessage *message) BMessage reply; status_t status = B_OK; + + PRINT(("%s what:%c%c%c%c\n", __PRETTY_FUNCTION__, message->what>>24, message->what>>16, message->what>>8, message->what)); switch(message->what) { @@ -416,7 +443,7 @@ InputServer::MessageReceived(BMessage *message) default: { PRINT(("Default message ... \n")); - PRINT_OBJECT(*message); + //PRINT_OBJECT(*message); BMessenger app_server("application/x-vnd.Be-APPS", -1, NULL); if (app_server.IsValid()) { //app_server->SendMessage(message); @@ -630,9 +657,6 @@ InputServer::HandleSetMousePosition(BMessage *message, BMessage *outbound) ASSERT(outbound == message); - fMousePos.x = 200; - fMousePos.y = 200; - int32 xValue, yValue; message->FindInt32("x",xValue); @@ -1079,7 +1103,7 @@ InputServer::DispatchEvents(BList *eventList) CacheEvents(eventList); - if (fEventsCache.CountItems()>50) { + if (fEventsCache.CountItems()>5) { BMessage *event; @@ -1105,11 +1129,7 @@ InputServer::DispatchEvent(BMessage *message) // variables int32 xValue, yValue; - uint32 buttons = 0; - message->FindInt32("x",xValue); - PRINT(("[DispatchEvent] x = %lu:\n", xValue)); - port_id pid = find_port(SERVER_INPUT_PORT); // BPortLink is incompatible with R5 one @@ -1118,18 +1138,21 @@ InputServer::DispatchEvent(BMessage *message) BPortLink *appsvrlink = new BPortLink(pid); switch(message->what){ case B_MOUSE_MOVED:{ - // get point and button from msg - if((message->FindInt32(X_VALUE,&xValue) == B_OK) && (message->FindInt32(Y_VALUE,&yValue) == B_OK)){ + uint32 buttons; + BPoint pt; + message->FindPoint("where",&pt); + // get point and button from msg + //if((message->FindInt32(X_VALUE,&xValue) == B_OK) && (message->FindInt32(Y_VALUE,&yValue) == B_OK)){ int64 time=(int64)real_time_clock(); appsvrlink->StartMessage(B_MOUSE_MOVED); appsvrlink->Attach(&time,sizeof(int64)); - appsvrlink->Attach((float)xValue); - appsvrlink->Attach((float)yValue); + appsvrlink->Attach(&pt.x,sizeof(float)); + appsvrlink->Attach(&pt.y,sizeof(float)); message->FindInt32("buttons",buttons); - appsvrlink->Attach(&buttons,sizeof(int32)); + appsvrlink->Attach(&buttons,sizeof(uint32)); appsvrlink->Flush(); - PRINT(("B_MOUSE_MOVED: x = %lu: y = %lu: time = %llu: buttons = %lu\n",xValue,yValue,time,buttons)); - } + PRINT(("B_MOUSE_MOVED: x = %lu: y = %lu: time = %llu: buttons = %lu\n",pt.x,pt.y,time,buttons)); + // } break; } case B_MOUSE_DOWN:{ diff --git a/src/servers/input/InputServer.h b/src/servers/input/InputServer.h index c44618dd0e..dfa72bd13e 100644 --- a/src/servers/input/InputServer.h +++ b/src/servers/input/InputServer.h @@ -31,6 +31,7 @@ // BeAPI Headers #include +#include #include #include #include @@ -44,7 +45,6 @@ #include #include -#include #include #include #include @@ -53,14 +53,6 @@ #define INPUTSERVER_SIGNATURE "application/x-vnd.OBOS-input_server" -#if DEBUG>=1 - #define EXIT() printf("EXIT %s\n", __PRETTY_FUNCTION__) - #define CALLED() printf("CALLED %s\n", __PRETTY_FUNCTION__) -#else - #define EXIT() ((void)0) - #define CALLED() ((void)0) -#endif - class BPortLink; class InputDeviceListItem @@ -215,7 +207,31 @@ private: BList fEventsCache; //fMouseState; + + sem_id fCursorSem; + area_id fAppArea; + area_id fCloneArea; + void *fAppBuffer; + thread_id fAppThreadId; +#if DEBUG == 2 +public: + static FILE *sLogFile; +#endif }; +#if DEBUG>=1 +#if DEBUG == 2 + #undef PRINT + inline void _iprint(const char *fmt, ...) { char buf[1024]; va_list ap; va_start(ap, fmt); vsprintf(buf, fmt, ap); va_end(ap); \ + fputs(buf, InputServer::sLogFile); fflush(InputServer::sLogFile); } + #define PRINT(x) _iprint x +#endif + + #define EXIT() PRINT(("EXIT %s\n", __PRETTY_FUNCTION__)) + #define CALLED() PRINT(("CALLED %s\n", __PRETTY_FUNCTION__)) +#else + #define EXIT() ((void)0) + #define CALLED() ((void)0) +#endif #endif