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:
parent
bf0f315cc3
commit
da4a68b7f5
@ -1060,12 +1060,13 @@ Layer::MoveBy(float x, float y)
|
||||
return;
|
||||
}
|
||||
|
||||
BPrivate::PortLink msg(-1, -1);
|
||||
msg.StartMessage(AS_ROOTLAYER_LAYER_MOVE);
|
||||
msg.Attach<Layer*>(this);
|
||||
msg.Attach<float>(x);
|
||||
msg.Attach<float>(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<Layer*>(this);
|
||||
msg.Attach<float>(x);
|
||||
msg.Attach<float>(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<Layer*>(this);
|
||||
msg.Attach<float>(x);
|
||||
msg.Attach<float>(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<Layer*>(this);
|
||||
msg.Attach<BRect>(src);
|
||||
msg.Attach<BRect>(dst);
|
||||
msg.Attach<int32>(xOffset);
|
||||
msg.Attach<int32>(yOffset);
|
||||
GetRootLayer()->EnqueueMessage(msg);
|
||||
GetRootLayer()->Lock();
|
||||
do_CopyBits(src, dst, xOffset, yOffset);
|
||||
GetRootLayer()->Unlock();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -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*>(&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:
|
||||
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<const Layer*>(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<const Layer*>(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<const WinBorder*>(winBorder);
|
||||
msg.Attach<int32>(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*>(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*>(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
|
||||
|
@ -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);
|
||||
|
@ -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<WinBorder*>(fWinBorder);
|
||||
msg.Attach<WinBorder*>(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<WinBorder*>(fWinBorder);
|
||||
msg.Attach<WinBorder*>(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<int32>(&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<uint32>(&newWorkspaces);
|
||||
|
||||
BPrivate::PortLink msg(-1, -1);
|
||||
msg.StartMessage(AS_ROOTLAYER_WINBORDER_SET_WORKSPACES);
|
||||
msg.Attach<WinBorder*>(fWinBorder);
|
||||
msg.Attach<uint32>(fWinBorder->Workspaces());
|
||||
msg.Attach<uint32>(newWorkspaces);
|
||||
fWinBorder->GetRootLayer()->EnqueueMessage(msg);
|
||||
fWinBorder->GetRootLayer()->Lock();
|
||||
fWinBorder->GetRootLayer()->SetWinBorderWorskpaces( fWinBorder,
|
||||
fWinBorder->Workspaces(),
|
||||
newWorkspaces);
|
||||
fWinBorder->GetRootLayer()->Unlock();
|
||||
break;
|
||||
}
|
||||
case AS_WINDOW_RESIZE:
|
||||
|
Loading…
Reference in New Issue
Block a user