RootLayer thread only handles input messages now. All other actions (move/resize/scroll/invalidate/etc) are performed by locking the RootLayer object and taking the respective action from the calling thread(usulay a ServerWindow one).

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14489 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adi Oanca
2005-10-24 16:02:23 +00:00
parent bf0f315cc3
commit da4a68b7f5
4 changed files with 71 additions and 236 deletions
+24 -26
View File
@@ -1060,12 +1060,13 @@ Layer::MoveBy(float x, float y)
return; return;
} }
BPrivate::PortLink msg(-1, -1); GetRootLayer()->Lock();
msg.StartMessage(AS_ROOTLAYER_LAYER_MOVE); #ifndef NEW_CLIPPING
msg.Attach<Layer*>(this); move_layer(x, y);
msg.Attach<float>(x); #else
msg.Attach<float>(y); do_MoveBy(x, y);
GetRootLayer()->EnqueueMessage(msg); #endif
GetRootLayer()->Unlock();
STRACE(("Layer(%s)::MoveBy() END\n", Name())); STRACE(("Layer(%s)::MoveBy() END\n", Name()));
} }
@@ -1081,12 +1082,13 @@ Layer::ResizeBy(float x, float y)
return; return;
} }
BPrivate::PortLink msg(-1, -1); GetRootLayer()->Lock();
msg.StartMessage(AS_ROOTLAYER_LAYER_RESIZE); #ifndef NEW_CLIPPING
msg.Attach<Layer*>(this); resize_layer(x, y);
msg.Attach<float>(x); #else
msg.Attach<float>(y); do_ResizeBy(x, y);
GetRootLayer()->EnqueueMessage(msg); #endif
GetRootLayer()->Unlock();
STRACE(("Layer(%s)::ResizeBy() END\n", Name())); STRACE(("Layer(%s)::ResizeBy() END\n", Name()));
} }
@@ -1097,12 +1099,13 @@ Layer::ScrollBy(float x, float y)
{ {
STRACE(("Layer(%s)::ScrollBy() START\n", Name())); STRACE(("Layer(%s)::ScrollBy() START\n", Name()));
BPrivate::PortLink msg(-1, -1); GetRootLayer()->Lock();
msg.StartMessage(AS_ROOTLAYER_LAYER_SCROLL); #ifndef NEW_CLIPPING
msg.Attach<Layer*>(this); // nothing
msg.Attach<float>(x); #else
msg.Attach<float>(y); do_ScrollBy(x, y);
GetRootLayer()->EnqueueMessage(msg); #endif
GetRootLayer()->Unlock();
STRACE(("Layer(%s)::ScrollBy() END\n", Name())); STRACE(("Layer(%s)::ScrollBy() END\n", Name()));
} }
@@ -1817,14 +1820,9 @@ Layer::SetOverlayBitmap(const ServerBitmap* bitmap)
void void
Layer::CopyBits(BRect& src, BRect& dst, int32 xOffset, int32 yOffset) { Layer::CopyBits(BRect& src, BRect& dst, int32 xOffset, int32 yOffset) {
BPrivate::PortLink msg(-1, -1); GetRootLayer()->Lock();
msg.StartMessage(AS_ROOTLAYER_LAYER_COPYBITS); do_CopyBits(src, dst, xOffset, yOffset);
msg.Attach<Layer*>(this); GetRootLayer()->Unlock();
msg.Attach<BRect>(src);
msg.Attach<BRect>(dst);
msg.Attach<int32>(xOffset);
msg.Attach<int32>(yOffset);
GetRootLayer()->EnqueueMessage(msg);
} }
void void
+32 -185
View File
@@ -207,7 +207,7 @@ RootLayer::WorkingThread(void *data)
oneRootLayer->Lock(); oneRootLayer->Lock();
#ifndef NEW_CLIPPING #ifndef NEW_CLIPPING
oneRootLayer->RebuildFullRegion(); oneRootLayer->RebuildFullRegion();
oneRootLayer->invalidate_layer(oneRootLayer, oneRootLayer->Bounds()); oneRootLayer->GoInvalidate(oneRootLayer, oneRootLayer->Bounds());
#else #else
oneRootLayer->rebuild_visible_regions( oneRootLayer->rebuild_visible_regions(
BRegion(oneRootLayer->Bounds()), BRegion(oneRootLayer->Bounds()),
@@ -252,143 +252,6 @@ RootLayer::WorkingThread(void *data)
exit_thread(0); exit_thread(0);
break; break;
case AS_ROOTLAYER_SHOW_WINBORDER:
{
WinBorder *winBorder = NULL;
messageQueue.Read<WinBorder*>(&winBorder);
oneRootLayer->show_winBorder(winBorder);
break;
}
case AS_ROOTLAYER_HIDE_WINBORDER:
{
WinBorder *winBorder = NULL;
messageQueue.Read<WinBorder*>(&winBorder);
oneRootLayer->hide_winBorder(winBorder);
break;
}
case AS_ROOTLAYER_DO_INVALIDATE:
{
BRegion invalidRegion;
Layer *layer = NULL;
messageQueue.Read<Layer*>(&layer);
messageQueue.ReadRegion(&invalidRegion);
#ifndef NEW_CLIPPING
oneRootLayer->invalidate_layer(layer, invalidRegion);
#else
layer->do_Invalidate(invalidRegion);
#endif
break;
}
case AS_ROOTLAYER_DO_REDRAW:
{
BRegion redrawRegion;
Layer *layer = NULL;
messageQueue.Read<Layer*>(&layer);
messageQueue.ReadRegion(&redrawRegion);
#ifndef NEW_CLIPPING
oneRootLayer->redraw_layer(layer, redrawRegion);
#else
layer->do_Redraw(redrawRegion);
#endif
break;
}
case AS_ROOTLAYER_LAYER_MOVE:
{
Layer *layer = NULL;
float x, y;
messageQueue.Read<Layer*>(&layer);
messageQueue.Read<float>(&x);
messageQueue.Read<float>(&y);
#ifndef NEW_CLIPPING
layer->move_layer(x, y);
#else
layer->do_MoveBy(x, y);
#endif
break;
}
case AS_ROOTLAYER_LAYER_RESIZE:
{
Layer *layer = NULL;
float x, y;
messageQueue.Read<Layer*>(&layer);
messageQueue.Read<float>(&x);
messageQueue.Read<float>(&y);
#ifndef NEW_CLIPPING
layer->resize_layer(x, y);
#else
layer->do_ResizeBy(x, y);
#endif
break;
}
case AS_ROOTLAYER_LAYER_SCROLL:
{
Layer *layer = NULL;
float x, y;
messageQueue.Read<Layer*>(&layer);
messageQueue.Read<float>(&x);
messageQueue.Read<float>(&y);
#ifndef NEW_CLIPPING
// nothing
#else
layer->do_ScrollBy(x, y);
#endif
break;
}
case AS_ROOTLAYER_LAYER_COPYBITS:
{
Layer *layer = NULL;
int32 xOffset, yOffset;
BRect src, dst;
messageQueue.Read<Layer*>(&layer);
messageQueue.Read<BRect>(&src);
messageQueue.Read<BRect>(&dst);
messageQueue.Read<int32>(&xOffset);
messageQueue.Read<int32>(&yOffset);
layer->do_CopyBits(src, dst, xOffset, yOffset);
break;
}
case AS_ROOTLAYER_ADD_TO_SUBSET:
{
WinBorder *winBorder = NULL;
WinBorder *toWinBorder = NULL;
messageQueue.Read<WinBorder*>(&winBorder);
messageQueue.Read<WinBorder*>(&toWinBorder);
oneRootLayer->fDesktop->AddWinBorderToSubset(winBorder, toWinBorder);
break;
}
case AS_ROOTLAYER_REMOVE_FROM_SUBSET:
{
WinBorder *winBorder = NULL;
WinBorder *fromWinBorder = NULL;
messageQueue.Read<WinBorder*>(&winBorder);
messageQueue.Read<WinBorder*>(&fromWinBorder);
oneRootLayer->fDesktop->RemoveWinBorderFromSubset(winBorder, fromWinBorder);
break;
}
case AS_ROOTLAYER_WINBORDER_SET_WORKSPACES:
{
WinBorder *winBorder = NULL;
uint32 oldWks = 0, newWks = 0;
messageQueue.Read<WinBorder*>(&winBorder);
messageQueue.Read<uint32>(&oldWks);
messageQueue.Read<uint32>(&newWks);
oneRootLayer->SetWinBorderWorskpaces(winBorder, oldWks, newWks);
break;
}
case AS_ROOTLAYER_DO_CHANGE_WINBORDER_FEEL:
{
WinBorder *winBorder = NULL;
int32 newFeel = 0;
messageQueue.Read<WinBorder*>(&winBorder);
messageQueue.Read<int32>(&newFeel);
oneRootLayer->change_winBorder_feel(winBorder, newFeel);
break;
}
default: default:
printf("RootLayer(%s)::WorkingThread received unexpected code %lx\n", oneRootLayer->Name(), code); printf("RootLayer(%s)::WorkingThread received unexpected code %lx\n", oneRootLayer->Name(), code);
break; break;
@@ -405,27 +268,21 @@ RootLayer::WorkingThread(void *data)
void void
RootLayer::GoInvalidate(const Layer *layer, const BRegion &region) RootLayer::GoInvalidate(Layer *layer, const BRegion &region)
{ {
BPrivate::PortLink msg(fListenPort, -1); BRegion invalidRegion(region);
msg.StartMessage(AS_ROOTLAYER_DO_INVALIDATE);
msg.Attach<const Layer*>(layer);
msg.AttachRegion(region);
msg.Flush();
}
Lock();
#ifndef NEW_CLIPPING #ifndef NEW_CLIPPING
void RootLayer::invalidate_layer(Layer *layer, const BRegion &region)
{
// NOTE: our thread (WorkingThread) is locked here.
STRACE(("RootLayer::invalidate_layer(%s)\n", layer->Name()));
if (layer->fParent) if (layer->fParent)
layer = layer->fParent; layer = layer->fParent;
layer->FullInvalidate(region); layer->FullInvalidate(invalidRegion);
} #else
layer->do_Invalidate(invalidRegion);
#endif #endif
Unlock();
}
status_t status_t
RootLayer::EnqueueMessage(BPrivate::PortLink &message) RootLayer::EnqueueMessage(BPrivate::PortLink &message)
@@ -437,33 +294,25 @@ RootLayer::EnqueueMessage(BPrivate::PortLink &message)
void void
RootLayer::GoRedraw(const Layer *layer, const BRegion &region) RootLayer::GoRedraw(Layer *layer, const BRegion &region)
{ {
BPrivate::PortLink msg(fListenPort, -1); BRegion redrawRegion(region);
msg.StartMessage(AS_ROOTLAYER_DO_REDRAW);
msg.Attach<const Layer*>(layer); Lock();
msg.AttachRegion(region);
msg.Flush();
}
#ifndef NEW_CLIPPING #ifndef NEW_CLIPPING
void layer->Invalidate(redrawRegion);
RootLayer::redraw_layer(Layer *layer, const BRegion &region) #else
{ layer->do_Redraw(redrawRegion);
// NOTE: our thread (WorkingThread) is locked here.
layer->Invalidate(region);
}
#endif #endif
Unlock();
}
void void
RootLayer::GoChangeWinBorderFeel(const WinBorder *winBorder, int32 newFeel) RootLayer::GoChangeWinBorderFeel(WinBorder *winBorder, int32 newFeel)
{ {
BPrivate::PortLink msg(fListenPort, -1); Lock();
msg.StartMessage(AS_ROOTLAYER_DO_CHANGE_WINBORDER_FEEL); change_winBorder_feel(winBorder, newFeel);
msg.Attach<const WinBorder*>(winBorder); Unlock();
msg.Attach<int32>(newFeel);
msg.Flush();
} }
@@ -923,20 +772,18 @@ RootLayer::SaveWorkspaceData(const char *path)
void void
RootLayer::HideWinBorder(WinBorder* winBorder) RootLayer::HideWinBorder(WinBorder* winBorder)
{ {
BPrivate::PortLink msg(fListenPort, -1); Lock();
msg.StartMessage(AS_ROOTLAYER_HIDE_WINBORDER); hide_winBorder(winBorder);
msg.Attach<WinBorder*>(winBorder); Unlock();
msg.Flush();
} }
void void
RootLayer::ShowWinBorder(WinBorder* winBorder) RootLayer::ShowWinBorder(WinBorder* winBorder)
{ {
BPrivate::PortLink msg(fListenPort, -1); Lock();
msg.StartMessage(AS_ROOTLAYER_SHOW_WINBORDER); show_winBorder(winBorder);
msg.Attach<WinBorder*>(winBorder); Unlock();
msg.Flush();
} }
@@ -1026,14 +873,14 @@ RootLayer::RevealNewWMState(Workspace::State &oldWMState)
redraw = false; redraw = false;
// trigger region rebuilding and redraw // trigger region rebuilding and redraw
#ifndef NEW_CLIPPING #ifndef NEW_CLIPPING
invalidate_layer(this, fFull); GoInvalidate(this, fFull);
#else #else
do_Invalidate(Bounds()); do_Invalidate(Bounds());
#endif #endif
} }
else if (redraw) { else if (redraw) {
#ifndef NEW_CLIPPING #ifndef NEW_CLIPPING
invalidate_layer(this, dirtyRegion); GoInvalidate(this, dirtyRegion);
#else #else
do_Redraw(dirtyRegion); do_Redraw(dirtyRegion);
#endif #endif
@@ -1257,7 +1104,7 @@ RootLayer::MouseEventHandler(int32 code, BPrivate::PortLink& msg)
break; break;
} }
case B_MOUSE_MOVED: { case B_MOUSE_MOVED: {
//printf("RootLayer::MouseEventHandler(B_MOUSE_MOVED)\n"); //printf("RootLayer::MouseEventHandler(B_MOUSE_MOVED)\n");
// Attached data: // Attached data:
// 1) int64 - time of mouse click // 1) int64 - time of mouse click
// 2) float - x coordinate of mouse click // 2) float - x coordinate of mouse click
@@ -1280,7 +1127,7 @@ RootLayer::MouseEventHandler(int32 code, BPrivate::PortLink& msg)
break; break;
} }
case B_MOUSE_WHEEL_CHANGED: { case B_MOUSE_WHEEL_CHANGED: {
//printf("RootLayer::MouseEventHandler(B_MOUSE_WHEEL_CHANGED)\n"); //printf("RootLayer::MouseEventHandler(B_MOUSE_WHEEL_CHANGED)\n");
// FEATURE: This is a tentative change: mouse wheel messages are always sent to the window // FEATURE: This is a tentative change: mouse wheel messages are always sent to the window
// under the cursor. It's pretty stupid to send it to the active window unless a particular // under the cursor. It's pretty stupid to send it to the active window unless a particular
// view has locked focus via SetMouseEventMask // view has locked focus via SetMouseEventMask
+3 -5
View File
@@ -130,9 +130,9 @@ public:
bool IsLocked() { return fAllRegionsLock.IsLocked(); } bool IsLocked() { return fAllRegionsLock.IsLocked(); }
void RunThread(); void RunThread();
status_t EnqueueMessage(BPrivate::PortLink &message); status_t EnqueueMessage(BPrivate::PortLink &message);
void GoInvalidate(const Layer *layer, const BRegion &region); void GoInvalidate(Layer *layer, const BRegion &region);
void GoRedraw(const Layer *layer, const BRegion &region); void GoRedraw(Layer *layer, const BRegion &region);
void GoChangeWinBorderFeel(const WinBorder *winBorder, int32 newFeel); void GoChangeWinBorderFeel(WinBorder *winBorder, int32 newFeel);
virtual void Draw(const BRect &r); virtual void Draw(const BRect &r);
@@ -159,8 +159,6 @@ friend class WinBorder; // temporarily, I need invalidate_layer()
#ifndef NEW_CLIPPING #ifndef NEW_CLIPPING
void empty_visible_regions(Layer *layer); void empty_visible_regions(Layer *layer);
void invalidate_layer(Layer *layer, const BRegion &region);
void redraw_layer(Layer *layer, const BRegion &region);
#endif #endif
// Input related methods // Input related methods
void MouseEventHandler(int32 code, BPrivate::PortLink& link); void MouseEventHandler(int32 code, BPrivate::PortLink& link);
+12 -20
View File
@@ -1319,12 +1319,9 @@ myRootLayer->Unlock();
fLink.StartMessage(SERVER_TRUE); fLink.StartMessage(SERVER_TRUE);
fLink.Flush(); fLink.Flush();
// ToDo: this is a pretty expensive and complicated way to send a message... fWinBorder->GetRootLayer()->Lock();
BPrivate::PortLink msg(-1, -1); gDesktop->AddWinBorderToSubset(fWinBorder, windowBorder);
msg.StartMessage(AS_ROOTLAYER_ADD_TO_SUBSET); fWinBorder->GetRootLayer()->Unlock();
msg.Attach<WinBorder*>(fWinBorder);
msg.Attach<WinBorder*>(windowBorder);
fWinBorder->GetRootLayer()->EnqueueMessage(msg);
} else { } else {
fLink.StartMessage(SERVER_FALSE); fLink.StartMessage(SERVER_FALSE);
fLink.Flush(); fLink.Flush();
@@ -1346,11 +1343,9 @@ myRootLayer->Unlock();
fLink.StartMessage(SERVER_TRUE); fLink.StartMessage(SERVER_TRUE);
fLink.Flush(); fLink.Flush();
BPrivate::PortLink msg(-1, -1); fWinBorder->GetRootLayer()->Lock();
msg.StartMessage(AS_ROOTLAYER_REMOVE_FROM_SUBSET); gDesktop->RemoveWinBorderFromSubset(fWinBorder, windowBorder);
msg.Attach<WinBorder*>(fWinBorder); fWinBorder->GetRootLayer()->Unlock();
msg.Attach<WinBorder*>(windowBorder);
fWinBorder->GetRootLayer()->EnqueueMessage(msg);
} else { } else {
fLink.StartMessage(SERVER_FALSE); fLink.StartMessage(SERVER_FALSE);
fLink.Flush(); fLink.Flush();
@@ -1376,8 +1371,7 @@ myRootLayer->Unlock();
int32 newFeel; int32 newFeel;
link.Read<int32>(&newFeel); link.Read<int32>(&newFeel);
if (myRootLayer) fWinBorder->GetRootLayer()->GoChangeWinBorderFeel(winBorder, newFeel);
myRootLayer->GoChangeWinBorderFeel(fWinBorder, newFeel);
break; break;
} }
case AS_SET_ALIGNMENT: case AS_SET_ALIGNMENT:
@@ -1403,17 +1397,15 @@ myRootLayer->Unlock();
} }
case AS_SET_WORKSPACES: case AS_SET_WORKSPACES:
{ {
// TODO: Implement AS_SET_WORKSPACES
STRACE(("ServerWindow %s: Message Set_Workspaces unimplemented\n", Title())); STRACE(("ServerWindow %s: Message Set_Workspaces unimplemented\n", Title()));
uint32 newWorkspaces; uint32 newWorkspaces;
link.Read<uint32>(&newWorkspaces); link.Read<uint32>(&newWorkspaces);
BPrivate::PortLink msg(-1, -1); fWinBorder->GetRootLayer()->Lock();
msg.StartMessage(AS_ROOTLAYER_WINBORDER_SET_WORKSPACES); fWinBorder->GetRootLayer()->SetWinBorderWorskpaces( fWinBorder,
msg.Attach<WinBorder*>(fWinBorder); fWinBorder->Workspaces(),
msg.Attach<uint32>(fWinBorder->Workspaces()); newWorkspaces);
msg.Attach<uint32>(newWorkspaces); fWinBorder->GetRootLayer()->Unlock();
fWinBorder->GetRootLayer()->EnqueueMessage(msg);
break; break;
} }
case AS_WINDOW_RESIZE: case AS_WINDOW_RESIZE: