replaced PortLink with BSession as the default hanlding system in DispatchMessage()

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6720 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adi Oanca
2004-02-24 11:54:44 +00:00
parent a00a89d9c6
commit 8fca004965
2 changed files with 160 additions and 176 deletions
+159 -173
View File
@@ -48,7 +48,7 @@
#include "CursorManager.h" #include "CursorManager.h"
#include "Workspace.h" #include "Workspace.h"
//#define DEBUG_SERVERWINDOW #define DEBUG_SERVERWINDOW
//#define DEBUG_SERVERWINDOW_MOUSE //#define DEBUG_SERVERWINDOW_MOUSE
//#define DEBUG_SERVERWINDOW_KEYBOARD //#define DEBUG_SERVERWINDOW_KEYBOARD
@@ -140,23 +140,21 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook,
// fClientWinPort is the port to which the app awaits messages from the server // fClientWinPort is the port to which the app awaits messages from the server
fClientWinPort = winport; fClientWinPort = winport;
// fMessagePort is the port to which the app sends messages for the server // fMessagePort is the port to which the app sends messages for the server
fMessagePort = create_port(30,fTitle.String()); fMessagePort = create_port(30,fTitle.String());
fSession= new BSession(fMessagePort, fClientWinPort); fSession = new BSession(fMessagePort, fClientWinPort);
// Send a reply to our window - it is expecting fMessagePort port. // Send a reply to our window - it is expecting fMessagePort port.
// Temporarily use winlink to save time and memory // Temporarily use winlink to save time and memory
fWinLink=new PortLink(replyport); PortLink winLink(replyport);
fWinLink->SetOpCode(AS_CREATE_WINDOW); winLink.SetOpCode(AS_CREATE_WINDOW);
fWinLink->Attach<port_id>(fMessagePort); winLink.Attach<port_id>(fMessagePort);
fWinLink->Flush(); winLink.Flush();
fWinLink->SetPort(winport);
// Wait for top_view data and create ServerWindow's top most Layer // Wait for top_view data and create ServerWindow's top most Layer
int32 vToken; int32 vToken;
@@ -176,13 +174,18 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook,
pmsg.Read<uint32>(&vFlags); pmsg.Read<uint32>(&vFlags);
pmsg.ReadString(&vName); pmsg.ReadString(&vName);
fTopLayer = new Layer(vFrame, vName, vToken, vResizeMode, vFlags, this); fTopLayer = new Layer(vFrame, vName, vToken, vResizeMode, vFlags, desktop->GetDisplayDriver());
fTopLayer->SetServerWindow(this);
delete vName; delete vName;
cl = fTopLayer; cl = fTopLayer;
// Create a WindoBorder object for our ServerWindow. // Create a WindoBorder object for our ServerWindow.
fWinBorder = new WinBorder(fFrame,fTitle.String(),wlook,wfeel,wflags,this); fWinBorder = NULL;
fWinBorder = new WinBorder(fFrame,fTitle.String(),wlook,wfeel,wflags,this,desktop->GetDisplayDriver());
printf("=============%s\n", desktop->ActiveRootLayer()->GetName());
fWinBorder->SetRootLayer(desktop->ActiveRootLayer());
// NOTE: this MUST be before the monitor thread is spawned! // NOTE: this MUST be before the monitor thread is spawned!
desktop->AddWinBorder(fWinBorder); desktop->AddWinBorder(fWinBorder);
@@ -211,10 +214,6 @@ STRACE(("*ServerWindow (%s):~ServerWindow()\n",fTitle.String()));
delete fSession; delete fSession;
fSession = NULL; fSession = NULL;
} }
if (fWinLink){
delete fWinLink;
fWinLink = NULL;
}
if (fWinBorder){ if (fWinBorder){
delete fWinBorder; delete fWinBorder;
fWinBorder = NULL; fWinBorder = NULL;
@@ -408,13 +407,15 @@ void ServerWindow::Zoom(){
*/ */
void ServerWindow::SetFocus(bool value) void ServerWindow::SetFocus(bool value)
{ {
STRACE(("ServerWindow %s: Set Focus to %s\n",fTitle.String(),value?"true":"false")); STRACE(("ServerWindow %s: Set Focus to %s - UNIMPLEMENTED\n",fTitle.String(),value?"true":"false"));
/*
if(fIsActive!=value) if(fIsActive!=value)
{ {
fIsActive=value; fIsActive=value;
fWinBorder->SetFocus(value); fWinBorder->SetFocus(value);
// fWinBorder->RequestDraw(); // fWinBorder->RequestDraw();
} }
*/
} }
/*! /*!
@@ -538,16 +539,16 @@ bool ServerWindow::IsLocked(void)
return fLocker.IsLocked(); return fLocker.IsLocked();
} }
void ServerWindow::DispatchMessage(PortMessage *msg) void ServerWindow::DispatchMessage(int32 code)
{ {
switch(msg->Code()) switch(code)
{ {
//--------- BView Messages ----------------- //--------- BView Messages -----------------
case AS_SET_CURRENT_LAYER: case AS_SET_CURRENT_LAYER:
{ {
int32 token; int32 token;
msg->Read<int32>(&token); fSession->ReadInt32(&token);
Layer *current = FindLayer(fTopLayer, token); Layer *current = FindLayer(fTopLayer, token);
if (current) if (current)
@@ -652,22 +653,22 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
pattern patt; pattern patt;
int32 clippRegRects; int32 clippRegRects;
msg->Read<BPoint>(&(cl->_layerdata->penlocation)); fSession->ReadPoint(&(cl->_layerdata->penlocation));
msg->Read<float>(&(cl->_layerdata->pensize)); fSession->ReadFloat(&(cl->_layerdata->pensize));
msg->Read<rgb_color>(&highColor); fSession->ReadData(&highColor, sizeof(rgb_color));
msg->Read<rgb_color>(&lowColor); fSession->ReadData(&lowColor, sizeof(rgb_color));
msg->Read<rgb_color>(&viewColor); fSession->ReadData(&viewColor, sizeof(rgb_color));
msg->Read<pattern>(&patt); fSession->ReadData(&patt, sizeof(pattern));
msg->Read<int8>((int8*)&(cl->_layerdata->draw_mode)); fSession->ReadInt8((int8*)&(cl->_layerdata->draw_mode));
msg->Read<BPoint>(&(cl->_layerdata->coordOrigin)); fSession->ReadPoint(&(cl->_layerdata->coordOrigin));
msg->Read<int8>((int8*)&(cl->_layerdata->lineJoin)); fSession->ReadInt8((int8*)&(cl->_layerdata->lineJoin));
msg->Read<int8>((int8*)&(cl->_layerdata->lineCap)); fSession->ReadInt8((int8*)&(cl->_layerdata->lineCap));
msg->Read<float>(&(cl->_layerdata->miterLimit)); fSession->ReadFloat(&(cl->_layerdata->miterLimit));
msg->Read<int8>((int8*)&(cl->_layerdata->alphaSrcMode)); fSession->ReadInt8((int8*)&(cl->_layerdata->alphaSrcMode));
msg->Read<int8>((int8*)&(cl->_layerdata->alphaFncMode)); fSession->ReadInt8((int8*)&(cl->_layerdata->alphaFncMode));
msg->Read<float>(&(cl->_layerdata->scale)); fSession->ReadFloat(&(cl->_layerdata->scale));
msg->Read<bool>(&(cl->_layerdata->fontAliasing)); fSession->ReadBool(&(cl->_layerdata->fontAliasing));
msg->Read<int32>(&clippRegRects); fSession->ReadInt32(&clippRegRects);
cl->_layerdata->patt.Set(*((uint64*)&patt)); cl->_layerdata->patt.Set(*((uint64*)&patt));
cl->_layerdata->highcolor.SetColor(highColor); cl->_layerdata->highcolor.SetColor(highColor);
@@ -683,7 +684,7 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
BRect rect; BRect rect;
for(int32 i = 0; i < clippRegRects; i++){ for(int32 i = 0; i < clippRegRects; i++){
msg->Read<BRect>(&rect); fSession->ReadRect(&rect);
cl->_layerdata->clippReg->Include(rect); cl->_layerdata->clippReg->Include(rect);
} }
@@ -705,11 +706,11 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
{ {
uint16 mask; uint16 mask;
msg->Read<uint16>(&mask); fSession->ReadUInt16(&mask);
if (mask & B_FONT_FAMILY_AND_STYLE){ if (mask & B_FONT_FAMILY_AND_STYLE){
uint32 fontID; uint32 fontID;
msg->Read<int32>((int32*)&fontID); fSession->ReadInt32((int32*)&fontID);
// TODO: implement later. Currently there is no SetFamAndStyle(uint32) // TODO: implement later. Currently there is no SetFamAndStyle(uint32)
// in ServerFont class. DW, could you add one? // in ServerFont class. DW, could you add one?
//cl->_layerdata->font-> //cl->_layerdata->font->
@@ -717,43 +718,43 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
if (mask & B_FONT_SIZE){ if (mask & B_FONT_SIZE){
float size; float size;
msg->Read<float>(&size); fSession->ReadFloat(&size);
cl->_layerdata->font.SetSize(size); cl->_layerdata->font.SetSize(size);
} }
if (mask & B_FONT_SHEAR){ if (mask & B_FONT_SHEAR){
float shear; float shear;
msg->Read<float>(&shear); fSession->ReadFloat(&shear);
cl->_layerdata->font.SetShear(shear); cl->_layerdata->font.SetShear(shear);
} }
if (mask & B_FONT_ROTATION){ if (mask & B_FONT_ROTATION){
float rotation; float rotation;
msg->Read<float>(&rotation); fSession->ReadFloat(&rotation);
cl->_layerdata->font.SetRotation(rotation); cl->_layerdata->font.SetRotation(rotation);
} }
if (mask & B_FONT_SPACING){ if (mask & B_FONT_SPACING){
uint8 spacing; uint8 spacing;
msg->Read<uint8>(&spacing); // uint8 fSession->ReadUInt8(&spacing); // uint8
cl->_layerdata->font.SetSpacing(spacing); cl->_layerdata->font.SetSpacing(spacing);
} }
if (mask & B_FONT_ENCODING){ if (mask & B_FONT_ENCODING){
uint8 encoding; uint8 encoding;
msg->Read<int8>((int8*)&encoding); // uint8 fSession->ReadUInt8((uint8*)&encoding); // uint8
cl->_layerdata->font.SetEncoding(encoding); cl->_layerdata->font.SetEncoding(encoding);
} }
if (mask & B_FONT_FACE){ if (mask & B_FONT_FACE){
uint16 face; uint16 face;
msg->Read<uint16>(&face); // uint16 fSession->ReadUInt16(&face); // uint16
cl->_layerdata->font.SetFace(face); cl->_layerdata->font.SetFace(face);
} }
if (mask & B_FONT_FLAGS){ if (mask & B_FONT_FLAGS){
uint32 flags; uint32 flags;
msg->Read<uint32>(&flags); // uint32 fSession->ReadUInt32(&flags); // uint32
cl->_layerdata->font.SetFlags(flags); cl->_layerdata->font.SetFlags(flags);
} }
@@ -775,46 +776,46 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
patt = ld->patt.GetInt64(); patt = ld->patt.GetInt64();
// TODO: DW implement such a method in ServerFont class! // TODO: DW implement such a method in ServerFont class!
fWinLink->Attach<uint32>(0UL /*uint32 ld->font.GetFamAndStyle()*/); fSession->WriteUInt32(0UL /*uint32 ld->font.GetFamAndStyle()*/);
fWinLink->Attach<float>(ld->font.Size()); fSession->WriteFloat(ld->font.Size());
fWinLink->Attach<float>(ld->font.Shear()); fSession->WriteFloat(ld->font.Shear());
fWinLink->Attach<float>(ld->font.Rotation()); fSession->WriteFloat(ld->font.Rotation());
fWinLink->Attach<uint8>(ld->font.Spacing()); fSession->WriteUInt8(ld->font.Spacing());
fWinLink->Attach<uint8>(ld->font.Encoding()); fSession->WriteUInt8(ld->font.Encoding());
fWinLink->Attach<uint16>(ld->font.Face()); fSession->WriteUInt16(ld->font.Face());
fWinLink->Attach<uint32>(ld->font.Flags()); fSession->WriteUInt32(ld->font.Flags());
fWinLink->Attach<BPoint>(ld->penlocation); fSession->WritePoint(ld->penlocation);
fWinLink->Attach<float>(ld->pensize); fSession->WriteFloat(ld->pensize);
fWinLink->Attach<rgb_color>(hc); fSession->WriteData(&hc, sizeof(rgb_color));
fWinLink->Attach<rgb_color>(lc); fSession->WriteData(&lc, sizeof(rgb_color));
fWinLink->Attach<rgb_color>(vc); fSession->WriteData(&vc, sizeof(rgb_color));
// TODO: fix this to use the templatized version // TODO: fix this to use the templatized version
fWinLink->Attach(&patt,sizeof(pattern)); fSession->WriteData(&patt,sizeof(pattern));
fWinLink->Attach<BPoint>(ld->coordOrigin); fSession->WritePoint(ld->coordOrigin);
fWinLink->Attach<uint8>((uint8)(ld->draw_mode)); fSession->WriteUInt8((uint8)(ld->draw_mode));
fWinLink->Attach<uint8>((uint8)(ld->lineCap)); fSession->WriteUInt8((uint8)(ld->lineCap));
fWinLink->Attach<uint8>((uint8)(ld->lineJoin)); fSession->WriteUInt8((uint8)(ld->lineJoin));
fWinLink->Attach<float>(ld->miterLimit); fSession->WriteFloat(ld->miterLimit);
fWinLink->Attach<uint8>((uint8)(ld->alphaSrcMode)); fSession->WriteUInt8((uint8)(ld->alphaSrcMode));
fWinLink->Attach<uint8>((uint8)(ld->alphaFncMode)); fSession->WriteUInt8((uint8)(ld->alphaFncMode));
fWinLink->Attach<float>(ld->scale); fSession->WriteFloat(ld->scale);
fWinLink->Attach<bool>(ld->fontAliasing); fSession->WriteFloat(ld->fontAliasing);
int32 noOfRects = 0; int32 noOfRects = 0;
if (ld->clippReg) if (ld->clippReg)
noOfRects = ld->clippReg->CountRects(); noOfRects = ld->clippReg->CountRects();
fWinLink->Attach<int32>(noOfRects); fSession->WriteInt32(noOfRects);
for(int i = 0; i < noOfRects; i++){ for(int i = 0; i < noOfRects; i++){
fWinLink->Attach<BRect>(ld->clippReg->RectAt(i)); fSession->WriteRect(ld->clippReg->RectAt(i));
} }
fWinLink->Attach<float>(cl->_frame.left); fSession->WriteFloat(cl->_frame.left);
fWinLink->Attach<float>(cl->_frame.top); fSession->WriteFloat(cl->_frame.top);
fWinLink->Attach<BRect>(cl->_frame.OffsetToCopy(cl->_boundsLeftTop)); fSession->WriteRect(cl->_frame.OffsetToCopy(cl->_boundsLeftTop));
fWinLink->Flush(); fSession->Sync();
STRACE(("ServerWindow %s: Message AS_LAYER_GET_STATE: Layer: %s\n",fTitle.String(), cl->_name->String())); STRACE(("ServerWindow %s: Message AS_LAYER_GET_STATE: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
@@ -823,8 +824,8 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
{ {
float x, y; float x, y;
msg->Read<float>(&x); fSession->ReadFloat(&x);
msg->Read<float>(&y); fSession->ReadFloat(&y);
cl->MoveBy(x, y); cl->MoveBy(x, y);
@@ -835,8 +836,8 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
{ {
float newWidth, newHeight; float newWidth, newHeight;
msg->Read<float>(&newWidth); fSession->ReadFloat(&newWidth);
msg->Read<float>(&newHeight); fSession->ReadFloat(&newHeight);
// TODO: check for minimum alowed. WinBorder should provide such // TODO: check for minimum alowed. WinBorder should provide such
// a method, based on its decorator. // a method, based on its decorator.
@@ -848,10 +849,10 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
} }
case AS_LAYER_GET_COORD: case AS_LAYER_GET_COORD:
{ {
fWinLink->Attach<float>(cl->_frame.left); fSession->WriteFloat(cl->_frame.left);
fWinLink->Attach<float>(cl->_frame.top); fSession->WriteFloat(cl->_frame.top);
fWinLink->Attach<BRect>(cl->_frame.OffsetToCopy(cl->_boundsLeftTop)); fSession->WriteRect(cl->_frame.OffsetToCopy(cl->_boundsLeftTop));
fWinLink->Flush(); fSession->Sync();
STRACE(("ServerWindow %s: Message AS_LAYER_GET_COORD: Layer: %s\n",fTitle.String(), cl->_name->String())); STRACE(("ServerWindow %s: Message AS_LAYER_GET_COORD: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
@@ -860,8 +861,8 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
{ {
float x, y; float x, y;
msg->Read<float>(&x); fSession->ReadFloat(&x);
msg->Read<float>(&y); fSession->ReadFloat(&y);
cl->_layerdata->coordOrigin.Set(x, y); cl->_layerdata->coordOrigin.Set(x, y);
@@ -870,15 +871,15 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
} }
case AS_LAYER_GET_ORIGIN: case AS_LAYER_GET_ORIGIN:
{ {
fWinLink->Attach<BPoint>(cl->_layerdata->coordOrigin); fSession->WritePoint(cl->_layerdata->coordOrigin);
fWinLink->Flush(); fSession->Sync();
STRACE(("ServerWindow %s: Message AS_LAYER_GET_ORIGIN: Layer: %s\n",fTitle.String(), cl->_name->String())); STRACE(("ServerWindow %s: Message AS_LAYER_GET_ORIGIN: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_RESIZE_MODE: case AS_LAYER_RESIZE_MODE:
{ {
msg->Read<uint32>(&(cl->_resize_mode)); fSession->ReadUInt32(&(cl->_resize_mode));
STRACE(("ServerWindow %s: Message AS_LAYER_RESIZE_MODE: Layer: %s\n",fTitle.String(), cl->_name->String())); STRACE(("ServerWindow %s: Message AS_LAYER_RESIZE_MODE: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
@@ -887,7 +888,7 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
{ {
int32 token; int32 token;
msg->Read<int32>(&token); fSession->ReadInt32(&token);
cursormanager->SetCursor(token); cursormanager->SetCursor(token);
@@ -896,7 +897,7 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
} }
case AS_LAYER_SET_FLAGS: case AS_LAYER_SET_FLAGS:
{ {
msg->Read<uint32>(&(cl->_flags)); fSession->ReadUInt32(&(cl->_flags));
STRACE(("ServerWindow %s: Message AS_LAYER_SET_FLAGS: Layer: %s\n",fTitle.String(), cl->_name->String())); STRACE(("ServerWindow %s: Message AS_LAYER_SET_FLAGS: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
@@ -924,9 +925,9 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
// it was called. e.g.: different lineCap or lineJoin. Strange result // it was called. e.g.: different lineCap or lineJoin. Strange result
// would appear. // would appear.
msg->Read<int8>(&lineCap); fSession->ReadInt8(&lineCap);
msg->Read<int8>(&lineJoin); fSession->ReadInt8(&lineJoin);
msg->Read<float>(&(cl->_layerdata->miterLimit)); fSession->ReadFloat(&(cl->_layerdata->miterLimit));
cl->_layerdata->lineCap = (cap_mode)lineCap; cl->_layerdata->lineCap = (cap_mode)lineCap;
cl->_layerdata->lineJoin = (join_mode)lineJoin; cl->_layerdata->lineJoin = (join_mode)lineJoin;
@@ -936,10 +937,10 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
} }
case AS_LAYER_GET_LINE_MODE: case AS_LAYER_GET_LINE_MODE:
{ {
fWinLink->Attach<int8>((int8)(cl->_layerdata->lineCap)); fSession->WriteInt8((int8)(cl->_layerdata->lineCap));
fWinLink->Attach<int8>((int8)(cl->_layerdata->lineJoin)); fSession->WriteInt8((int8)(cl->_layerdata->lineJoin));
fWinLink->Attach<float>(cl->_layerdata->miterLimit); fSession->WriteFloat(cl->_layerdata->miterLimit);
fWinLink->Flush(); fSession->Sync();
STRACE(("ServerWindow %s: Message AS_LAYER_GET_LINE_MODE: Layer: %s\n",fTitle.String(), cl->_name->String())); STRACE(("ServerWindow %s: Message AS_LAYER_GET_LINE_MODE: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
@@ -973,7 +974,7 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
} }
case AS_LAYER_SET_SCALE: case AS_LAYER_SET_SCALE:
{ {
msg->Read<float>(&(cl->_layerdata->scale)); fSession->ReadFloat(&(cl->_layerdata->scale));
STRACE(("ServerWindow %s: Message AS_LAYER_SET_SCALE: Layer: %s\n",fTitle.String(), cl->_name->String())); STRACE(("ServerWindow %s: Message AS_LAYER_SET_SCALE: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
@@ -986,8 +987,8 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
while((ld = ld->prevState)) while((ld = ld->prevState))
scale *= ld->scale; scale *= ld->scale;
fWinLink->Attach<float>(scale); fSession->WriteFloat(scale);
fWinLink->Flush(); fSession->Sync();
STRACE(("ServerWindow %s: Message AS_LAYER_SET_SCALE: Layer: %s\n",fTitle.String(), cl->_name->String())); STRACE(("ServerWindow %s: Message AS_LAYER_SET_SCALE: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
@@ -996,8 +997,8 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
{ {
float x, y; float x, y;
msg->Read<float>(&x); fSession->ReadFloat(&x);
msg->Read<float>(&y); fSession->ReadFloat(&y);
cl->_layerdata->penlocation.Set(x, y); cl->_layerdata->penlocation.Set(x, y);
@@ -1006,23 +1007,23 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
} }
case AS_LAYER_GET_PEN_LOC: case AS_LAYER_GET_PEN_LOC:
{ {
fWinLink->Attach<BPoint>(cl->_layerdata->penlocation); fSession->WritePoint(cl->_layerdata->penlocation);
fWinLink->Flush(); fSession->Sync();
STRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_LOC: Layer: %s\n",fTitle.String(), cl->_name->String())); STRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_LOC: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_SET_PEN_SIZE: case AS_LAYER_SET_PEN_SIZE:
{ {
msg->Read<float>(&(cl->_layerdata->pensize)); fSession->ReadFloat(&(cl->_layerdata->pensize));
STRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_SIZE: Layer: %s\n",fTitle.String(), cl->_name->String())); STRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_SIZE: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_GET_PEN_SIZE: case AS_LAYER_GET_PEN_SIZE:
{ {
fWinLink->Attach<float>(cl->_layerdata->pensize); fSession->WriteFloat(cl->_layerdata->pensize);
fWinLink->Flush(); fSession->Sync();
STRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_SIZE: Layer: %s\n",fTitle.String(), cl->_name->String())); STRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_SIZE: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
@@ -1031,7 +1032,7 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
{ {
rgb_color c; rgb_color c;
msg->Read<rgb_color>(&c); fSession->ReadData(&c, sizeof(rgb_color));
cl->_layerdata->highcolor.SetColor(c); cl->_layerdata->highcolor.SetColor(c);
@@ -1042,7 +1043,7 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
{ {
rgb_color c; rgb_color c;
msg->Read<rgb_color>(&c); fSession->ReadData(&c, sizeof(rgb_color));
cl->_layerdata->lowcolor.SetColor(c); cl->_layerdata->lowcolor.SetColor(c);
@@ -1053,7 +1054,7 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
{ {
rgb_color c; rgb_color c;
msg->Read<rgb_color>(&c); fSession->ReadData(&c, sizeof(rgb_color));
cl->_layerdata->viewcolor.SetColor(c); cl->_layerdata->viewcolor.SetColor(c);
@@ -1068,10 +1069,10 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
lowColor = cl->_layerdata->lowcolor.GetColor32(); lowColor = cl->_layerdata->lowcolor.GetColor32();
viewColor = cl->_layerdata->viewcolor.GetColor32(); viewColor = cl->_layerdata->viewcolor.GetColor32();
fWinLink->Attach<rgb_color>(highColor); fSession->WriteData(&highColor, sizeof(rgb_color));
fWinLink->Attach<rgb_color>(lowColor); fSession->WriteData(&lowColor, sizeof(rgb_color));
fWinLink->Attach<rgb_color>(viewColor); fSession->WriteData(&viewColor, sizeof(rgb_color));
fWinLink->Flush(); fSession->Sync();
STRACE(("ServerWindow %s: Message AS_LAYER_GET_COLORS: Layer: %s\n",fTitle.String(), cl->_name->String())); STRACE(("ServerWindow %s: Message AS_LAYER_GET_COLORS: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
@@ -1080,8 +1081,8 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
{ {
int8 srcAlpha, alphaFunc; int8 srcAlpha, alphaFunc;
msg->Read<int8>(&srcAlpha); fSession->ReadInt8(&srcAlpha);
msg->Read<int8>(&alphaFunc); fSession->ReadInt8(&alphaFunc);
cl->_layerdata->alphaSrcMode = (source_alpha)srcAlpha; cl->_layerdata->alphaSrcMode = (source_alpha)srcAlpha;
cl->_layerdata->alphaFncMode = (alpha_function)alphaFunc; cl->_layerdata->alphaFncMode = (alpha_function)alphaFunc;
@@ -1091,9 +1092,9 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
} }
case AS_LAYER_GET_BLEND_MODE: case AS_LAYER_GET_BLEND_MODE:
{ {
fWinLink->Attach<int8>((int8)(cl->_layerdata->alphaSrcMode)); fSession->WriteInt8((int8)(cl->_layerdata->alphaSrcMode));
fWinLink->Attach<int8>((int8)(cl->_layerdata->alphaFncMode)); fSession->WriteInt8((int8)(cl->_layerdata->alphaFncMode));
fWinLink->Flush(); fSession->Sync();
STRACE(("ServerWindow %s: Message AS_LAYER_GET_BLEND_MODE: Layer: %s\n",fTitle.String(), cl->_name->String())); STRACE(("ServerWindow %s: Message AS_LAYER_GET_BLEND_MODE: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
@@ -1102,7 +1103,7 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
{ {
int8 drawingMode; int8 drawingMode;
msg->Read<int8>(&drawingMode); fSession->ReadInt8(&drawingMode);
cl->_layerdata->draw_mode = (drawing_mode)drawingMode; cl->_layerdata->draw_mode = (drawing_mode)drawingMode;
@@ -1111,15 +1112,15 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
} }
case AS_LAYER_GET_DRAW_MODE: case AS_LAYER_GET_DRAW_MODE:
{ {
fWinLink->Attach<int8>((int8)(cl->_layerdata->draw_mode)); fSession->WriteInt8((int8)(cl->_layerdata->draw_mode));
fWinLink->Flush(); fSession->Sync();
STRACE(("ServerWindow %s: Message AS_LAYER_GET_DRAW_MODE: Layer: %s\n",fTitle.String(), cl->_name->String())); STRACE(("ServerWindow %s: Message AS_LAYER_GET_DRAW_MODE: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
} }
case AS_LAYER_PRINT_ALIASING: case AS_LAYER_PRINT_ALIASING:
{ {
msg->Read<bool>(&(cl->_layerdata->fontAliasing)); fSession->ReadBool(&(cl->_layerdata->fontAliasing));
STRACE(("ServerWindow %s: Message AS_LAYER_PRINT_ALIASING: Layer: %s\n",fTitle.String(), cl->_name->String())); STRACE(("ServerWindow %s: Message AS_LAYER_PRINT_ALIASING: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
@@ -1130,8 +1131,8 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
int32 pictureToken; int32 pictureToken;
BPoint where; BPoint where;
msg->Read<int32>(&pictureToken); fSession->ReadInt32(&pictureToken);
msg->Read<BPoint>(&where); fSession->ReadPoint(&where);
BRegion reg; BRegion reg;
@@ -1172,11 +1173,11 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
// we need to rebuild the visible region, we may have a valid one. // we need to rebuild the visible region, we may have a valid one.
if (cl->_parent && !(cl->_hidden)){ if (cl->_parent && !(cl->_hidden)){
cl->_parent->RebuildChildRegions(cl->_full.Frame(), cl); // cl->_parent->RebuildChildRegions(cl->_full.Frame(), cl);
} }
else{ else{
// will this happen? Maybe... // will this happen? Maybe...
cl->RebuildRegions(cl->_full.Frame()); // cl->RebuildRegions(cl->_full.Frame());
} }
// include our full visible region in the region to be redrawn // include our full visible region in the region to be redrawn
@@ -1199,8 +1200,8 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
int32 pictureToken; int32 pictureToken;
BPoint where; BPoint where;
msg->Read<int32>(&pictureToken); fSession->ReadInt32(&pictureToken);
msg->Read<BPoint>(&where); fSession->ReadPoint(&where);
ServerPicture *sp = NULL; ServerPicture *sp = NULL;
int32 i = 0; int32 i = 0;
@@ -1227,7 +1228,7 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
cl->RebuildFullRegion(); cl->RebuildFullRegion();
cl->RequestDraw(cl->clipToPicture->Frame()); // cl->RequestDraw(cl->clipToPicture->Frame());
} }
STRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_INVERSE_PICTURE: Layer: %s\n",fTitle.String(), cl->_name->String())); STRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_INVERSE_PICTURE: Layer: %s\n",fTitle.String(), cl->_name->String()));
@@ -1251,13 +1252,13 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
reg.IntersectWith(ld->clippReg); reg.IntersectWith(ld->clippReg);
noOfRects = reg.CountRects(); noOfRects = reg.CountRects();
fWinLink->Attach<int32>(noOfRects); fSession->WriteInt32(noOfRects);
for(int i = 0; i < noOfRects; i++){ for(int i = 0; i < noOfRects; i++){
fWinLink->Attach<BRect>(reg.RectAt(i)); fSession->WriteRect(reg.RectAt(i));
} }
fWinLink->Flush(); fSession->Sync();
STRACE(("ServerWindow %s: Message AS_LAYER_GET_CLIP_REGION: Layer: %s\n",fTitle.String(), cl->_name->String())); STRACE(("ServerWindow %s: Message AS_LAYER_GET_CLIP_REGION: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
@@ -1273,16 +1274,16 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
else else
cl->_layerdata->clippReg = new BRegion(); cl->_layerdata->clippReg = new BRegion();
msg->Read<int32>(&noOfRects); fSession->ReadInt32(&noOfRects);
for(int i = 0; i < noOfRects; i++){ for(int i = 0; i < noOfRects; i++){
msg->Read<BRect>(&r); fSession->ReadRect(&r);
cl->_layerdata->clippReg->Include(r); cl->_layerdata->clippReg->Include(r);
} }
cl->RebuildFullRegion(); cl->RebuildFullRegion();
cl->RequestDraw(cl->clipToPicture->Frame()); // cl->RequestDraw(cl->clipToPicture->Frame());
STRACE(("ServerWindow %s: Message AS_LAYER_SET_CLIP_REGION: Layer: %s\n",fTitle.String(), cl->_name->String())); STRACE(("ServerWindow %s: Message AS_LAYER_SET_CLIP_REGION: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
@@ -1293,11 +1294,11 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
// TODO: watch out for the coordinate system // TODO: watch out for the coordinate system
BRect invalRect; BRect invalRect;
msg->Read<BRect>(&invalRect); fSession->ReadRect(&invalRect);
cl->Invalidate(invalRect); cl->Invalidate(invalRect);
cl->RequestDraw(invalRect); // cl->RequestDraw(invalRect);
STRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n",fTitle.String(), cl->_name->String())); STRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
@@ -1309,16 +1310,16 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
int32 noOfRects; int32 noOfRects;
BRect rect; BRect rect;
msg->Read<int32>(&noOfRects); fSession->ReadInt32(&noOfRects);
for(int i = 0; i < noOfRects; i++){ for(int i = 0; i < noOfRects; i++){
msg->Read<BRect>(&rect); fSession->ReadRect(&rect);
invalReg.Include(rect); invalReg.Include(rect);
} }
cl->Invalidate(invalReg); cl->Invalidate(invalReg);
cl->RequestDraw(invalReg.Frame()); // cl->RequestDraw(invalReg.Frame());
STRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n",fTitle.String(), cl->_name->String())); STRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n",fTitle.String(), cl->_name->String()));
break; break;
@@ -1503,7 +1504,7 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
} }
default: default:
{ {
printf("ServerWindow %s received unexpected code - message offset %lx\n",fTitle.String(), msg->Code() - SERVER_TRUE); printf("ServerWindow %s received unexpected code - message offset %lx\n",fTitle.String(), code - SERVER_TRUE);
break; break;
} }
} }
@@ -1523,14 +1524,16 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer)
uint32 sizeRemaining = (uint32)msgsize; uint32 sizeRemaining = (uint32)msgsize;
BRegion WindowClipRegion; BRegion WindowClipRegion;
BRegion LayerClipRegion; BRegion LayerClipRegion;
Layer *sibling; // Layer *sibling;
int32 numRects = 0; int32 numRects = 0;
if (!msgsize || !msgbuffer) if (!msgsize || !msgbuffer)
return; return;
if (IsHidden()) if (IsHidden())
return; return;
// TODO: fix!
/*
WindowClipRegion.Set(fWinBorder->Frame()); WindowClipRegion.Set(fWinBorder->Frame());
sibling = fWinBorder->UpperSibling(); sibling = fWinBorder->UpperSibling();
while (sibling) while (sibling)
@@ -1538,7 +1541,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer)
WindowClipRegion.Exclude(sibling->Frame()); WindowClipRegion.Exclude(sibling->Frame());
sibling = sibling->UpperSibling(); sibling = sibling->UpperSibling();
} }
*/
if (!WindowClipRegion.Frame().IsValid()) if (!WindowClipRegion.Frame().IsValid())
return; return;
@@ -1553,7 +1556,8 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer)
layer = NULL;//fWorkspace->GetRoot()->FindLayer(view_token); layer = NULL;//fWorkspace->GetRoot()->FindLayer(view_token);
if (layer) if (layer)
{ {
layerdata = layer->GetLayerData(); // TODO: fix!
// layerdata = layer->GetLayerData();
LayerClipRegion.Set(layer->Frame()); LayerClipRegion.Set(layer->Frame());
LayerClipRegion.IntersectWith(&WindowClipRegion); LayerClipRegion.IntersectWith(&WindowClipRegion);
numRects = LayerClipRegion.CountRects(); numRects = LayerClipRegion.CountRects();
@@ -2059,35 +2063,16 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer)
int32 ServerWindow::MonitorWin(void *data) int32 ServerWindow::MonitorWin(void *data)
{ {
ServerWindow *win = (ServerWindow *)data; ServerWindow *win = (ServerWindow *)data;
PortQueue msgqueue(win->fMessagePort); BSession *ses = win->fSession;
PortMessage *msg; bool quitting = false;
bool quitting = false; int32 code;
while(!quitting) while(!quitting)
{ {
if(!msgqueue.MessagesWaiting()) ses->ReadInt32(&code);
msgqueue.GetMessagesFromPort(true);
else
msgqueue.GetMessagesFromPort(false);
msg = msgqueue.GetMessageFromQueue(); switch(code)
if(!msg)
continue;
switch(msg->Code())
{ {
case AS_QUIT_APP:
{
// Received when the app_server is told to shut down
STRACE(("ServerWindow %s received server shutdown notification\n",win->Title()));
if(DISPLAYDRIVER!=HWDRIVER)
{
BMessage pleaseQuit(B_QUIT_REQUESTED);
win->SendMessageToClient(&pleaseQuit);
}
break;
}
case 0: case 0:
{ {
// this means the client has been killed // this means the client has been killed
@@ -2104,13 +2089,14 @@ int32 ServerWindow::MonitorWin(void *data)
{ {
STRACE(("ServerWindow %s received Quit request\n",win->Title())); STRACE(("ServerWindow %s received Quit request\n",win->Title()));
quitting = true; quitting = true;
printf("Deleting window...\n");
delete win; delete win;
break; break;
} }
default: default:
{ {
STRACE(("ServerWindow %s: got a message to dispatch\n",win->Title())); STRACE(("ServerWindow %s: got a message to dispatch\n",win->Title()));
win->DispatchMessage(msg); win->DispatchMessage(code);
break; break;
} }
} }
@@ -2119,7 +2105,7 @@ int32 ServerWindow::MonitorWin(void *data)
} }
/*! /*!
\brief Passes mouse event messages to the appropriate window \brief PasfSession mouse event messages to the appropriate window
\param code Message code of the mouse message \param code Message code of the mouse message
\param buffer Attachment buffer for the mouse message \param buffer Attachment buffer for the mouse message
*/ */
@@ -2260,7 +2246,7 @@ void ServerWindow::HandleMouseEvent(PortMessage *msg)
} }
/*! /*!
\brief Passes key event messages to the appropriate window \brief PasfSession key event messages to the appropriate window
\param code Message code of the key message \param code Message code of the key message
\param buffer Attachment buffer for the key message \param buffer Attachment buffer for the key message
*/ */
+1 -3
View File
@@ -95,7 +95,7 @@ public:
bool IsLocked(void); bool IsLocked(void);
thread_id ThreadID(void) const { return fMonitorThreadID;} thread_id ThreadID(void) const { return fMonitorThreadID;}
void DispatchMessage(PortMessage *msg); void DispatchMessage(int32 code);
void DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer); void DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer);
static int32 MonitorWin(void *data); static int32 MonitorWin(void *data);
static void HandleMouseEvent(PortMessage *msg); static void HandleMouseEvent(PortMessage *msg);
@@ -151,8 +151,6 @@ protected:
port_id fClientWinPort; port_id fClientWinPort;
port_id fClientLooperPort; port_id fClientLooperPort;
PortLink *fWinLink;
BLocker fLocker; BLocker fLocker;
BRect fFrame; BRect fFrame;
uint32 fToken; uint32 fToken;