From c36b4a44091575e421eeef733d3f5562dd0e9ed9 Mon Sep 17 00:00:00 2001 From: DarkWyrm Date: Sun, 23 Jan 2005 15:39:01 +0000 Subject: [PATCH] messaging fixes to RootLayer and ViewDriver minor tweaks to ServerWindow git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10977 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/server/RootLayer.cpp | 21 ++++++++++---- src/servers/app/server/ServerWindow.cpp | 15 +++++----- src/servers/app/server/ViewDriver.cpp | 38 +++++++++++++------------ 3 files changed, 43 insertions(+), 31 deletions(-) diff --git a/src/servers/app/server/RootLayer.cpp b/src/servers/app/server/RootLayer.cpp index e8d509c751..428d9687a3 100644 --- a/src/servers/app/server/RootLayer.cpp +++ b/src/servers/app/server/RootLayer.cpp @@ -941,6 +941,12 @@ void RootLayer::MouseEventHandler(int32 code, BPortLink& msg) WinBorder *activeFocus=NULL; BRegion invalidRegion; + // TODO: Figure out the be:view_where field in B_MOUSE_DOWN for RootLayer + // A little sniffing around R5's B_MOUSE_DOWN messages has revealed an + // undocumented field: a BPoint entry called "be:view_where" which probably + // helps the window determine the target view. Testing so far has revealed + // that it has the same value as the "where" field + BMessage downmsg(B_MOUSE_DOWN); downmsg.AddInt64("when",evt.when); downmsg.AddPoint("where",evt.where); @@ -996,7 +1002,6 @@ void RootLayer::MouseEventHandler(int32 code, BPortLink& msg) { target->Window()->Lock(); target->MouseDown(evt, true); - target->Window()->SendMessageToClient(&downmsg); target->Window()->Unlock(); } else @@ -1152,7 +1157,7 @@ void RootLayer::KeyboardEventHandler(int32 code, BPortLink& msg) // generated string // 8) Character string generated by the keystroke // 9) int8[16] state of all keys - + bigtime_t time; int32 scancode, modifiers; int8 utf[3]; @@ -1166,8 +1171,8 @@ void RootLayer::KeyboardEventHandler(int32 code, BPortLink& msg) msg.Read(&time); msg.Read(&scancode); msg.Read(&raw_char); - msg.Read(&modifiers); msg.Read(&repeatcount); + msg.Read(&modifiers); msg.Read(utf, sizeof(utf)); msg.ReadString(&string); msg.Read(keystates,sizeof(int8)*16); @@ -1322,9 +1327,10 @@ void RootLayer::KeyboardEventHandler(int32 code, BPortLink& msg) { BMessage keymsg(B_KEY_DOWN); keymsg.AddInt64("when",time); +// keymsg.AddInt32("modifiers",modifiers); keymsg.AddInt32("key",scancode); - keymsg.AddInt32("be:key_repeat",scancode); - keymsg.AddInt32("modifiers",modifiers); + if(repeatcount>1) + keymsg.AddInt32("be:key_repeat",repeatcount); keymsg.AddData("states",B_INT8_TYPE,keystates,sizeof(int8)*16); for(uint8 i=0;i<4; i++) { @@ -1332,8 +1338,11 @@ void RootLayer::KeyboardEventHandler(int32 code, BPortLink& msg) keymsg.AddInt8("byte",utf[i]); } keymsg.AddString("bytes",string); - keymsg.AddInt32("raw_char",raw_char); +// keymsg.AddInt32("raw_char",raw_char); +printf("RootLayer keyboard message:\n"); +keymsg.PrintToStream(); +printf("\n"); win->SendMessageToClient(&keymsg); } } diff --git a/src/servers/app/server/ServerWindow.cpp b/src/servers/app/server/ServerWindow.cpp index 8e2c49a7bc..f74bd9b743 100644 --- a/src/servers/app/server/ServerWindow.cpp +++ b/src/servers/app/server/ServerWindow.cpp @@ -30,7 +30,7 @@ #include #include #include -#include // for B_XXXXX_MOUSE_BUTTON defines +#include #include #include #include @@ -192,7 +192,7 @@ ServerWindow::~ServerWindow(void) STRACE(("*ServerWindow (%s):~ServerWindow()\n",fTitle.String())); desktop->RemoveWinBorder(fWinBorder); - STRACE(("SW(%s) Successfully removed from the desktop\n", fTitle.String())); + STRACE(("ServerWindow(%s) Successfully removed from the desktop\n", fTitle.String())); if(fMsgSender) { @@ -712,7 +712,7 @@ void ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link) case AS_LAYER_CREATE_ROOT: { STRACE(("ServerWindow %s: Message AS_LAYER_CREATE_ROOT\n", fTitle.String())); - + // Start receiving top_view data -- pass NULL as the parent view. // This should be the *only* place where this happens. if (cl != NULL) @@ -808,13 +808,11 @@ void ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link) patt = ld->patt.GetInt64(); // TODO: Implement when ServerFont::SetfamilyAndStyle(int32) exists + // TODO: Implement *what*? SetFamilyAndStyle exists. :) fMsgSender->StartMessage(SERVER_TRUE); // Attach font state - - // TODO: need a ServerFont::GetFamAndStyle -// fMsgSender->Attach(0UL uint32 ld->font.GetFamAndStyle()); - fMsgSender->Attach(0UL); + fMsgSender->Attach(ld->font.GetFamilyAndStyle()); fMsgSender->Attach(ld->font.Size()); fMsgSender->Attach(ld->font.Shear()); fMsgSender->Attach(ld->font.Rotation()); @@ -2115,18 +2113,21 @@ void ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link) } case AS_LAYER_DRAG_IMAGE: { + // TODO: Implement AS_LAYER_DRAG_IMAGE STRACE(("ServerWindow %s: Message AS_DRAG_IMAGE unimplemented\n",fTitle.String())); DTRACE(("ServerWindow %s: Message AS_DRAG_IMAGE unimplemented\n",fTitle.String())); break; } case AS_LAYER_DRAG_RECT: { + // TODO: Implement AS_LAYER_DRAG_RECT STRACE(("ServerWindow %s: Message AS_DRAG_RECT unimplemented\n",fTitle.String())); DTRACE(("ServerWindow %s: Message AS_DRAG_RECT unimplemented\n",fTitle.String())); break; } case AS_LAYER_GET_MOUSE_COORDS: { + // TODO: Implement AS_LAYER_MOUSE_COORDS STRACE(("ServerWindow %s: Message AS_GET_MOUSE_COORDS unimplemented\n",fTitle.String())); DTRACE(("ServerWindow %s: Message AS_GET_MOUSE_COORDS unimplemented\n",fTitle.String())); // Attached Data: diff --git a/src/servers/app/server/ViewDriver.cpp b/src/servers/app/server/ViewDriver.cpp index 1479c085c1..5c82a738b0 100644 --- a/src/servers/app/server/ViewDriver.cpp +++ b/src/servers/app/server/ViewDriver.cpp @@ -147,6 +147,7 @@ void VDView::Draw(BRect rect) void VDView::MouseDown(BPoint pt) { +#ifdef ENABLE_INPUT_SERVER_EMULATION // Attach data: // 1) int64 - time of mouse click // 2) float - x coordinate of mouse click @@ -154,17 +155,16 @@ void VDView::MouseDown(BPoint pt) // 4) int32 - modifier keys down // 5) int32 - buttons down // 6) int32 - clicks -#ifdef ENABLE_INPUT_SERVER_EMULATION - BPoint p; - - uint32 buttons, - mod=modifiers(), - clicks=1; // can't get the # of clicks without a *lot* of extra work :( - + + uint32 buttons, mod, clicks=1; int64 time=(int64)real_time_clock(); - - GetMouse(&p,&buttons); - + + BMessage *msg=Window()->CurrentMessage(); + msg->FindPoint("where",&pt); + msg->FindInt32("modifiers",(int32*)&mod); + msg->FindInt32("buttons",(int32*)&buttons); + msg->FindInt32("clicks",(int32*)&clicks); + serverlink->StartMessage(B_MOUSE_DOWN); serverlink->Attach(&time, sizeof(int64)); serverlink->Attach(&pt.x,sizeof(float)); @@ -283,19 +283,23 @@ void VDWindow::MessageReceived(BMessage *msg) int8 utf8data[4]; BString string; int8 keyarray[16]; - + systime=(int64)real_time_clock(); msg->FindInt32("key",&scancode); - msg->FindInt32("be:key_repeat",&repeatcount); + if(msg->FindInt32("be:key_repeat",&repeatcount)!=B_OK) + { + // TODO: see if repeatcount should be 0 or 1 when not repeating in ViewDriver + repeatcount=1; + } msg->FindInt32("modifiers",&modifiers); msg->FindInt32("raw_char",&asciicode); msg->FindInt8("byte",0,utf8data); if(msg->FindInt8("byte",1,utf8data+1)!=B_OK) utf8data[1]=0; - if(msg->FindInt8("byte",1,utf8data+2)!=B_OK) + if(msg->FindInt8("byte",2,utf8data+2)!=B_OK) utf8data[2]=0; - if(msg->FindInt8("byte",1,utf8data+3)!=B_OK) + if(msg->FindInt8("byte",3,utf8data+3)!=B_OK) utf8data[3]=0; msg->FindString("bytes",&string); for(int8 i=0;i<15;i++) @@ -307,8 +311,7 @@ void VDWindow::MessageReceived(BMessage *msg) view->serverlink->Attach(repeatcount); view->serverlink->Attach(modifiers); view->serverlink->Attach(utf8data,sizeof(int8)*3); - view->serverlink->Attach(string.Length()+1); - view->serverlink->Attach(string.String()); + view->serverlink->AttachString(string.String()); view->serverlink->Attach(keyarray,sizeof(int8)*16); view->serverlink->Flush(); break; @@ -351,8 +354,7 @@ void VDWindow::MessageReceived(BMessage *msg) view->serverlink->Attach(asciicode); view->serverlink->Attach(modifiers); view->serverlink->Attach(utf8data,sizeof(int8)*3); - view->serverlink->Attach(string.Length()+1); - view->serverlink->Attach(string.String()); + view->serverlink->AttachString(string.String()); view->serverlink->Attach(keyarray,sizeof(int8)*16); view->serverlink->Flush(); break;