diff --git a/src/servers/app/Layer.cpp b/src/servers/app/Layer.cpp index 94bef0bbc2..2977d3a34d 100644 --- a/src/servers/app/Layer.cpp +++ b/src/servers/app/Layer.cpp @@ -1060,12 +1060,13 @@ Layer::MoveBy(float x, float y) return; } - BPrivate::PortLink msg(-1, -1); - msg.StartMessage(AS_ROOTLAYER_LAYER_MOVE); - msg.Attach(this); - msg.Attach(x); - msg.Attach(y); - GetRootLayer()->EnqueueMessage(msg); + GetRootLayer()->Lock(); +#ifndef NEW_CLIPPING + move_layer(x, y); +#else + do_MoveBy(x, y); +#endif + GetRootLayer()->Unlock(); STRACE(("Layer(%s)::MoveBy() END\n", Name())); } @@ -1081,12 +1082,13 @@ Layer::ResizeBy(float x, float y) return; } - BPrivate::PortLink msg(-1, -1); - msg.StartMessage(AS_ROOTLAYER_LAYER_RESIZE); - msg.Attach(this); - msg.Attach(x); - msg.Attach(y); - GetRootLayer()->EnqueueMessage(msg); + GetRootLayer()->Lock(); +#ifndef NEW_CLIPPING + resize_layer(x, y); +#else + do_ResizeBy(x, y); +#endif + GetRootLayer()->Unlock(); STRACE(("Layer(%s)::ResizeBy() END\n", Name())); } @@ -1097,12 +1099,13 @@ Layer::ScrollBy(float x, float y) { STRACE(("Layer(%s)::ScrollBy() START\n", Name())); - BPrivate::PortLink msg(-1, -1); - msg.StartMessage(AS_ROOTLAYER_LAYER_SCROLL); - msg.Attach(this); - msg.Attach(x); - msg.Attach(y); - GetRootLayer()->EnqueueMessage(msg); + GetRootLayer()->Lock(); +#ifndef NEW_CLIPPING + // nothing +#else + do_ScrollBy(x, y); +#endif + GetRootLayer()->Unlock(); STRACE(("Layer(%s)::ScrollBy() END\n", Name())); } @@ -1817,14 +1820,9 @@ Layer::SetOverlayBitmap(const ServerBitmap* bitmap) void Layer::CopyBits(BRect& src, BRect& dst, int32 xOffset, int32 yOffset) { - BPrivate::PortLink msg(-1, -1); - msg.StartMessage(AS_ROOTLAYER_LAYER_COPYBITS); - msg.Attach(this); - msg.Attach(src); - msg.Attach(dst); - msg.Attach(xOffset); - msg.Attach(yOffset); - GetRootLayer()->EnqueueMessage(msg); + GetRootLayer()->Lock(); + do_CopyBits(src, dst, xOffset, yOffset); + GetRootLayer()->Unlock(); } void diff --git a/src/servers/app/RootLayer.cpp b/src/servers/app/RootLayer.cpp index 0c1aef72df..6f384e3dd8 100644 --- a/src/servers/app/RootLayer.cpp +++ b/src/servers/app/RootLayer.cpp @@ -207,7 +207,7 @@ RootLayer::WorkingThread(void *data) oneRootLayer->Lock(); #ifndef NEW_CLIPPING oneRootLayer->RebuildFullRegion(); - oneRootLayer->invalidate_layer(oneRootLayer, oneRootLayer->Bounds()); + oneRootLayer->GoInvalidate(oneRootLayer, oneRootLayer->Bounds()); #else oneRootLayer->rebuild_visible_regions( BRegion(oneRootLayer->Bounds()), @@ -252,143 +252,6 @@ RootLayer::WorkingThread(void *data) exit_thread(0); break; - case AS_ROOTLAYER_SHOW_WINBORDER: - { - WinBorder *winBorder = NULL; - messageQueue.Read(&winBorder); - oneRootLayer->show_winBorder(winBorder); - break; - } - case AS_ROOTLAYER_HIDE_WINBORDER: - { - WinBorder *winBorder = NULL; - messageQueue.Read(&winBorder); - oneRootLayer->hide_winBorder(winBorder); - break; - } - case AS_ROOTLAYER_DO_INVALIDATE: - { - BRegion invalidRegion; - Layer *layer = NULL; - messageQueue.Read(&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); - 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); - messageQueue.Read(&x); - messageQueue.Read(&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); - messageQueue.Read(&x); - messageQueue.Read(&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); - messageQueue.Read(&x); - messageQueue.Read(&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); - messageQueue.Read(&src); - messageQueue.Read(&dst); - messageQueue.Read(&xOffset); - messageQueue.Read(&yOffset); - - layer->do_CopyBits(src, dst, xOffset, yOffset); - - break; - } - - case AS_ROOTLAYER_ADD_TO_SUBSET: - { - WinBorder *winBorder = NULL; - WinBorder *toWinBorder = NULL; - messageQueue.Read(&winBorder); - messageQueue.Read(&toWinBorder); - oneRootLayer->fDesktop->AddWinBorderToSubset(winBorder, toWinBorder); - break; - } - case AS_ROOTLAYER_REMOVE_FROM_SUBSET: - { - WinBorder *winBorder = NULL; - WinBorder *fromWinBorder = NULL; - messageQueue.Read(&winBorder); - messageQueue.Read(&fromWinBorder); - oneRootLayer->fDesktop->RemoveWinBorderFromSubset(winBorder, fromWinBorder); - break; - } - case AS_ROOTLAYER_WINBORDER_SET_WORKSPACES: - { - WinBorder *winBorder = NULL; - uint32 oldWks = 0, newWks = 0; - - messageQueue.Read(&winBorder); - messageQueue.Read(&oldWks); - messageQueue.Read(&newWks); - oneRootLayer->SetWinBorderWorskpaces(winBorder, oldWks, newWks); - break; - } - case AS_ROOTLAYER_DO_CHANGE_WINBORDER_FEEL: - { - WinBorder *winBorder = NULL; - int32 newFeel = 0; - - messageQueue.Read(&winBorder); - messageQueue.Read(&newFeel); - oneRootLayer->change_winBorder_feel(winBorder, newFeel); - break; - } default: printf("RootLayer(%s)::WorkingThread received unexpected code %lx\n", oneRootLayer->Name(), code); break; @@ -405,27 +268,21 @@ RootLayer::WorkingThread(void *data) void -RootLayer::GoInvalidate(const Layer *layer, const BRegion ®ion) +RootLayer::GoInvalidate(Layer *layer, const BRegion ®ion) { - BPrivate::PortLink msg(fListenPort, -1); - msg.StartMessage(AS_ROOTLAYER_DO_INVALIDATE); - msg.Attach(layer); - msg.AttachRegion(region); - msg.Flush(); -} + BRegion invalidRegion(region); + Lock(); #ifndef NEW_CLIPPING -void RootLayer::invalidate_layer(Layer *layer, const BRegion ®ion) -{ - // NOTE: our thread (WorkingThread) is locked here. - STRACE(("RootLayer::invalidate_layer(%s)\n", layer->Name())); - if (layer->fParent) layer = layer->fParent; - layer->FullInvalidate(region); -} + layer->FullInvalidate(invalidRegion); +#else + layer->do_Invalidate(invalidRegion); #endif + Unlock(); +} status_t RootLayer::EnqueueMessage(BPrivate::PortLink &message) @@ -437,33 +294,25 @@ RootLayer::EnqueueMessage(BPrivate::PortLink &message) void -RootLayer::GoRedraw(const Layer *layer, const BRegion ®ion) +RootLayer::GoRedraw(Layer *layer, const BRegion ®ion) { - BPrivate::PortLink msg(fListenPort, -1); - msg.StartMessage(AS_ROOTLAYER_DO_REDRAW); - msg.Attach(layer); - msg.AttachRegion(region); - msg.Flush(); -} - + BRegion redrawRegion(region); + + Lock(); #ifndef NEW_CLIPPING -void -RootLayer::redraw_layer(Layer *layer, const BRegion ®ion) -{ - // NOTE: our thread (WorkingThread) is locked here. - - layer->Invalidate(region); -} + layer->Invalidate(redrawRegion); +#else + layer->do_Redraw(redrawRegion); #endif + Unlock(); +} void -RootLayer::GoChangeWinBorderFeel(const WinBorder *winBorder, int32 newFeel) +RootLayer::GoChangeWinBorderFeel(WinBorder *winBorder, int32 newFeel) { - BPrivate::PortLink msg(fListenPort, -1); - msg.StartMessage(AS_ROOTLAYER_DO_CHANGE_WINBORDER_FEEL); - msg.Attach(winBorder); - msg.Attach(newFeel); - msg.Flush(); + Lock(); + change_winBorder_feel(winBorder, newFeel); + Unlock(); } @@ -923,20 +772,18 @@ RootLayer::SaveWorkspaceData(const char *path) void RootLayer::HideWinBorder(WinBorder* winBorder) { - BPrivate::PortLink msg(fListenPort, -1); - msg.StartMessage(AS_ROOTLAYER_HIDE_WINBORDER); - msg.Attach(winBorder); - msg.Flush(); + Lock(); + hide_winBorder(winBorder); + Unlock(); } void RootLayer::ShowWinBorder(WinBorder* winBorder) { - BPrivate::PortLink msg(fListenPort, -1); - msg.StartMessage(AS_ROOTLAYER_SHOW_WINBORDER); - msg.Attach(winBorder); - msg.Flush(); + Lock(); + show_winBorder(winBorder); + Unlock(); } @@ -1026,14 +873,14 @@ RootLayer::RevealNewWMState(Workspace::State &oldWMState) redraw = false; // trigger region rebuilding and redraw #ifndef NEW_CLIPPING - invalidate_layer(this, fFull); + GoInvalidate(this, fFull); #else do_Invalidate(Bounds()); #endif } else if (redraw) { #ifndef NEW_CLIPPING - invalidate_layer(this, dirtyRegion); + GoInvalidate(this, dirtyRegion); #else do_Redraw(dirtyRegion); #endif @@ -1257,7 +1104,7 @@ RootLayer::MouseEventHandler(int32 code, BPrivate::PortLink& msg) break; } case B_MOUSE_MOVED: { -//printf("RootLayer::MouseEventHandler(B_MOUSE_MOVED)\n"); + //printf("RootLayer::MouseEventHandler(B_MOUSE_MOVED)\n"); // Attached data: // 1) int64 - time of mouse click // 2) float - x coordinate of mouse click @@ -1280,7 +1127,7 @@ RootLayer::MouseEventHandler(int32 code, BPrivate::PortLink& msg) break; } 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 // under the cursor. It's pretty stupid to send it to the active window unless a particular // view has locked focus via SetMouseEventMask diff --git a/src/servers/app/RootLayer.h b/src/servers/app/RootLayer.h index 24971a76f1..a4aed87a08 100644 --- a/src/servers/app/RootLayer.h +++ b/src/servers/app/RootLayer.h @@ -130,9 +130,9 @@ public: bool IsLocked() { return fAllRegionsLock.IsLocked(); } void RunThread(); status_t EnqueueMessage(BPrivate::PortLink &message); - void GoInvalidate(const Layer *layer, const BRegion ®ion); - void GoRedraw(const Layer *layer, const BRegion ®ion); - void GoChangeWinBorderFeel(const WinBorder *winBorder, int32 newFeel); + void GoInvalidate(Layer *layer, const BRegion ®ion); + void GoRedraw(Layer *layer, const BRegion ®ion); + void GoChangeWinBorderFeel(WinBorder *winBorder, int32 newFeel); virtual void Draw(const BRect &r); @@ -159,8 +159,6 @@ friend class WinBorder; // temporarily, I need invalidate_layer() #ifndef NEW_CLIPPING void empty_visible_regions(Layer *layer); - void invalidate_layer(Layer *layer, const BRegion ®ion); - void redraw_layer(Layer *layer, const BRegion ®ion); #endif // Input related methods void MouseEventHandler(int32 code, BPrivate::PortLink& link); diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index 195e2e029d..4f14af1e6e 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -1319,12 +1319,9 @@ myRootLayer->Unlock(); fLink.StartMessage(SERVER_TRUE); fLink.Flush(); - // ToDo: this is a pretty expensive and complicated way to send a message... - BPrivate::PortLink msg(-1, -1); - msg.StartMessage(AS_ROOTLAYER_ADD_TO_SUBSET); - msg.Attach(fWinBorder); - msg.Attach(windowBorder); - fWinBorder->GetRootLayer()->EnqueueMessage(msg); + fWinBorder->GetRootLayer()->Lock(); + gDesktop->AddWinBorderToSubset(fWinBorder, windowBorder); + fWinBorder->GetRootLayer()->Unlock(); } else { fLink.StartMessage(SERVER_FALSE); fLink.Flush(); @@ -1346,11 +1343,9 @@ myRootLayer->Unlock(); fLink.StartMessage(SERVER_TRUE); fLink.Flush(); - BPrivate::PortLink msg(-1, -1); - msg.StartMessage(AS_ROOTLAYER_REMOVE_FROM_SUBSET); - msg.Attach(fWinBorder); - msg.Attach(windowBorder); - fWinBorder->GetRootLayer()->EnqueueMessage(msg); + fWinBorder->GetRootLayer()->Lock(); + gDesktop->RemoveWinBorderFromSubset(fWinBorder, windowBorder); + fWinBorder->GetRootLayer()->Unlock(); } else { fLink.StartMessage(SERVER_FALSE); fLink.Flush(); @@ -1376,8 +1371,7 @@ myRootLayer->Unlock(); int32 newFeel; link.Read(&newFeel); - if (myRootLayer) - myRootLayer->GoChangeWinBorderFeel(fWinBorder, newFeel); + fWinBorder->GetRootLayer()->GoChangeWinBorderFeel(winBorder, newFeel); break; } case AS_SET_ALIGNMENT: @@ -1403,17 +1397,15 @@ myRootLayer->Unlock(); } case AS_SET_WORKSPACES: { - // TODO: Implement AS_SET_WORKSPACES STRACE(("ServerWindow %s: Message Set_Workspaces unimplemented\n", Title())); uint32 newWorkspaces; link.Read(&newWorkspaces); - BPrivate::PortLink msg(-1, -1); - msg.StartMessage(AS_ROOTLAYER_WINBORDER_SET_WORKSPACES); - msg.Attach(fWinBorder); - msg.Attach(fWinBorder->Workspaces()); - msg.Attach(newWorkspaces); - fWinBorder->GetRootLayer()->EnqueueMessage(msg); + fWinBorder->GetRootLayer()->Lock(); + fWinBorder->GetRootLayer()->SetWinBorderWorskpaces( fWinBorder, + fWinBorder->Workspaces(), + newWorkspaces); + fWinBorder->GetRootLayer()->Unlock(); break; } case AS_WINDOW_RESIZE: