BMessages which reach BWindow now take full advantage of application_kit's power in sending BMessages to BHandlers

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11282 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adi Oanca 2005-02-07 00:45:59 +00:00
parent 7b76dd8073
commit 0b9056c784
4 changed files with 14 additions and 13 deletions

View File

@ -1301,9 +1301,8 @@ void RootLayer::KeyboardEventHandler(int32 code, BPortLink& msg)
} }
keymsg.AddString("bytes",string); keymsg.AddString("bytes",string);
// keymsg.AddInt32("raw_char",raw_char); // keymsg.AddInt32("raw_char",raw_char);
keymsg.AddInt32("haiku:token", target->fViewToken);
win->SendMessageToClient(&keymsg); win->SendMessageToClient(&keymsg, B_NULL_TOKEN, true);
} }
} }
@ -1397,9 +1396,8 @@ void RootLayer::KeyboardEventHandler(int32 code, BPortLink& msg)
} }
keymsg.AddString("bytes",string); keymsg.AddString("bytes",string);
keymsg.AddInt32("raw_char",raw_char); keymsg.AddInt32("raw_char",raw_char);
keymsg.AddInt32("haiku:token", target->fViewToken);
win->SendMessageToClient(&keymsg); win->SendMessageToClient(&keymsg, B_NULL_TOKEN, true);
} }
} }

View File

@ -51,6 +51,7 @@
#include "DisplayDriver.h" #include "DisplayDriver.h"
#include "ServerPicture.h" #include "ServerPicture.h"
#include "Workspace.h" #include "Workspace.h"
#include "MessagePrivate.h"
//#define DEBUG_SERVERWINDOW //#define DEBUG_SERVERWINDOW
//#define DEBUG_SERVERWINDOW_MOUSE //#define DEBUG_SERVERWINDOW_MOUSE
@ -2285,16 +2286,17 @@ Layer* ServerWindow::FindLayer(const Layer* start, int32 token) const
return NULL; return NULL;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ServerWindow::SendMessageToClient(const BMessage* msg) const void ServerWindow::SendMessageToClient(const BMessage* msg, int32 target, bool usePreferred) const
{ {
ssize_t size; ssize_t size;
char *buffer; char *buffer;
size = msg->FlattenedSize(); size = msg->FlattenedSize();
buffer = new char[size]; buffer = new char[size];
if (msg->Flatten(buffer, size) == B_OK) if (msg->Flatten(buffer, size) == B_OK)
write_port(fClientLooperPort, msg->what, buffer, size); BMessage::Private::SendFlattenedMessage(buffer, size,
fClientLooperPort, target, usePreferred, B_INFINITE_TIMEOUT);
else else
printf("PANIC: ServerWindow %s: can't flatten message in 'SendMessageToClient()'\n", fTitle.String()); printf("PANIC: ServerWindow %s: can't flatten message in 'SendMessageToClient()'\n", fTitle.String());

View File

@ -36,6 +36,7 @@
#include <Window.h> #include <Window.h>
#include <LinkMsgReader.h> #include <LinkMsgReader.h>
#include <LinkMsgSender.h> #include <LinkMsgSender.h>
#include "TokenSpace.h"
#include "FMWList.h" #include "FMWList.h"
class BString; class BString;
@ -96,7 +97,9 @@ public:
// util methods. // util methods.
Layer *FindLayer(const Layer *start, int32 token) const; Layer *FindLayer(const Layer *start, int32 token) const;
void SendMessageToClient( const BMessage *msg ) const; void SendMessageToClient(const BMessage* msg,
int32 target = B_NULL_TOKEN,
bool usePreferred = false) const;
// a few, not that important methods returning some internal settings. // a few, not that important methods returning some internal settings.
int32 Look(void) const { return fLook; } int32 Look(void) const { return fLook; }

View File

@ -31,6 +31,7 @@
#include <Debug.h> #include <Debug.h>
#include "PortLink.h" #include "PortLink.h"
#include "View.h" // for mouse button defines #include "View.h" // for mouse button defines
#include "MessagePrivate.h"
#include "ServerWindow.h" #include "ServerWindow.h"
#include "Decorator.h" #include "Decorator.h"
#include "DisplayDriver.h" #include "DisplayDriver.h"
@ -41,7 +42,6 @@
#include "Globals.h" #include "Globals.h"
#include "RootLayer.h" #include "RootLayer.h"
#include "Workspace.h" #include "Workspace.h"
#include "TokenSpace.h"
// Toggle general function call output // Toggle general function call output
//#define DEBUG_WINBORDER //#define DEBUG_WINBORDER
@ -229,9 +229,8 @@ void WinBorder::MouseDown(PointerEvent& evt, bool sendMessage)
msg.AddInt32("modifiers", evt.modifiers); msg.AddInt32("modifiers", evt.modifiers);
msg.AddInt32("buttons", evt.buttons); msg.AddInt32("buttons", evt.buttons);
msg.AddInt32("clicks", evt.clicks); msg.AddInt32("clicks", evt.clicks);
msg.AddInt32("haiku:token", target? target->fViewToken: B_NULL_TOKEN);
Window()->SendMessageToClient(&msg); Window()->SendMessageToClient(&msg, target->fViewToken, false);
} }
fLastMousePosition = evt.where; fLastMousePosition = evt.where;
@ -368,9 +367,8 @@ void WinBorder::MouseUp(PointerEvent& evt)
upmsg.AddInt64("when",evt.when); upmsg.AddInt64("when",evt.when);
upmsg.AddPoint("where",evt.where); upmsg.AddPoint("where",evt.where);
upmsg.AddInt32("modifiers",evt.modifiers); upmsg.AddInt32("modifiers",evt.modifiers);
upmsg.AddInt32("haiku:token", target? target->fViewToken: B_NULL_TOKEN);
Window()->SendMessageToClient(&upmsg); Window()->SendMessageToClient(&upmsg, target->fViewToken, false);
} }
} }