Work in Progress. The server keeps the client window up to date on layer movement/resizing. This fixes quite a few problems and brings support for FrameMoved and Resized hooks. But implementing it this way has its own set of problem, most importantly: When a BView calles Window()->CurrentMessage() in its FrameMoved/Resized hooks, it will see something very different from what it would see in R5. This needs to be fixed, but I have not had a good idea how to do this other than faking the current message in BWindow, which I didn't look into.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12689 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2005-05-16 15:39:58 +00:00
parent a1c5fb3432
commit ad6b480400
6 changed files with 102 additions and 16 deletions
-1
View File
@@ -83,7 +83,6 @@ _BTextInput_::Archive(BMessage *data, bool deep) const
void void
_BTextInput_::FrameResized(float width, float height) _BTextInput_::FrameResized(float width, float height)
{ {
printf("_BTextInput_::FrameResized()\n");
BTextView::FrameResized(width, height); BTextView::FrameResized(width, height);
AlignTextRect(); AlignTextRect();
// TODO: just to get something working, it wouldn't be correct for // TODO: just to get something working, it wouldn't be correct for
+52 -1
View File
@@ -917,7 +917,58 @@ void BWindow::DispatchMessage(BMessage *msg, BHandler *target)
fLink->Flush(); fLink->Flush();
break; break;
} }
case B_VIEW_RESIZED:
case B_VIEW_MOVED: case B_VIEW_MOVED:
{
// NOTE: The problem with this implementation is that BView::Window()->CurrentMessage()
// will show this message, and not what it used to be on R5. This might break apps and
// we need to fix this here or change the way this feature is implemented. However, this
// implementation shows what has to be done when Layers are moved or resized inside the
// app_server. This message is generated from Layer::move_by() and resize_by() in
// Layer::AddToViewsWithInvalidCoords().
int32 token;
BPoint frameLeftTop;
float width;
float height;
BView* view;
for (int32 i = 0; msg->FindInt32("_token", i, &token) >= B_OK; i++) {
if (token >= 0) {
msg->FindPoint("where", i, &frameLeftTop);
msg->FindFloat("width", i, &width);
msg->FindFloat("height", i, &height);
if ((view = findView(top_view, token))) {
// update the views offset in parent
if (view->originX != frameLeftTop.x || view->originY != frameLeftTop.y) {
//printf("updating position (%.1f, %.1f): %s\n", frameLeftTop.x, frameLeftTop.y, view->Name());
view->originX = frameLeftTop.x;
view->originY = frameLeftTop.y;
// optionally call FrameMoved
if (view->fFlags & B_FRAME_EVENTS) {
STRACE(("Calling BView(%s)::FrameMoved( %.1f, %.1f )\n", view->Name(),
frameLeftTop.x, frameLeftTop.y));
view->FrameMoved(frameLeftTop);
}
}
// update the views width and height
if (view->fBounds.Width() != width || view->fBounds.Height() != height) {
//printf("updating size (%.1f, %.1f): %s\n", width, height, view->Name());
// TODO: does this work when a views left/top side is resized?
view->fBounds.right = view->fBounds.left + width;
view->fBounds.bottom = view->fBounds.top + height;
// optionally call FrameResized
if (view->fFlags & B_FRAME_EVENTS) {
STRACE(("Calling BView(%s)::FrameResized( %f, %f )\n", view->Name(), width, height));
view->FrameResized(width, height);
}
}
} else {
fprintf(stderr, "***PANIC: BW: Can't find view with ID: %ld !***\n", token);
}
}
}
break;
}
/* case B_VIEW_MOVED:
{ {
// NOTE: This message only arrives if the // NOTE: This message only arrives if the
// view has flags B_FRAME_EVENTS // view has flags B_FRAME_EVENTS
@@ -963,9 +1014,9 @@ void BWindow::DispatchMessage(BMessage *msg, BHandler *target)
} }
else else
printf("***PANIC: BW: Can't find view with ID: %ld !***\n", token); printf("***PANIC: BW: Can't find view with ID: %ld !***\n", token);
break; break;
} }
*/
case _MENUS_DONE_: case _MENUS_DONE_:
MenusEnded(); MenusEnded();
+35 -5
View File
@@ -570,8 +570,9 @@ Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint ptOf
fFrame.OffsetBy(pt.x, pt.y); fFrame.OffsetBy(pt.x, pt.y);
fFull.OffsetBy(pt.x, pt.y); fFull.OffsetBy(pt.x, pt.y);
// TODO: uncomment later when you'll implement a queue in ServerWindow::SendMessgeToClient() // TODO: investigate combining frame event messages for efficiency
//SendViewMovedMsg(); //SendViewMovedMsg();
AddToViewsWithInvalidCoords();
newAction = B_LAYER_SIMPLE_MOVE; newAction = B_LAYER_SIMPLE_MOVE;
break; break;
@@ -592,8 +593,10 @@ Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint ptOf
fFrame.bottom += pt.y; fFrame.bottom += pt.y;
RebuildFullRegion(); RebuildFullRegion();
// TODO: uncomment later when you'll implement a queue in ServerWindow::SendMessgeToClient() // TODO: investigate combining frame event messages for efficiency
//SendViewResizedMsg(); //SendViewResizedMsg();
AddToViewsWithInvalidCoords();
newAction = B_LAYER_MASK_RESIZE; newAction = B_LAYER_MASK_RESIZE;
break; break;
@@ -617,8 +620,9 @@ Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint ptOf
fFrame.bottom += rSize.y; fFrame.bottom += rSize.y;
RebuildFullRegion(); RebuildFullRegion();
// TODO: uncomment later when you'll implement a queue in ServerWindow::SendMessgeToClient() // TODO: investigate combining frame event messages for efficiency
//SendViewResizedMsg(); //SendViewResizedMsg();
AddToViewsWithInvalidCoords();
newAction = B_LAYER_MASK_RESIZE; newAction = B_LAYER_MASK_RESIZE;
newPt = rSize; newPt = rSize;
@@ -1285,7 +1289,6 @@ printf("no parent in Layer::move_layer() (%s)\n", GetName());
fFrameAction = B_LAYER_ACTION_NONE; fFrameAction = B_LAYER_ACTION_NONE;
return; return;
} }
fParent->StartRebuildRegions(BRegion(rect), this, B_LAYER_MOVE, pt); fParent->StartRebuildRegions(BRegion(rect), this, B_LAYER_MOVE, pt);
fDriver->CopyRegionList(&fRootLayer->fCopyRegList, fDriver->CopyRegionList(&fRootLayer->fCopyRegList,
@@ -1295,6 +1298,8 @@ return;
fParent->Redraw(fRootLayer->fRedrawReg, this); fParent->Redraw(fRootLayer->fRedrawReg, this);
SendViewCoordUpdateMsg();
EmptyGlobals(); EmptyGlobals();
fFrameAction = B_LAYER_ACTION_NONE; fFrameAction = B_LAYER_ACTION_NONE;
@@ -1322,6 +1327,8 @@ return;
fDriver->CopyRegionList(&fRootLayer->fCopyRegList, &fRootLayer->fCopyList, fRootLayer->fCopyRegList.CountItems(), &fFullVisible); fDriver->CopyRegionList(&fRootLayer->fCopyRegList, &fRootLayer->fCopyList, fRootLayer->fCopyRegList.CountItems(), &fFullVisible);
fParent->Redraw(fRootLayer->fRedrawReg, this); fParent->Redraw(fRootLayer->fRedrawReg, this);
SendViewCoordUpdateMsg();
EmptyGlobals(); EmptyGlobals();
fFrameAction = B_LAYER_ACTION_NONE; fFrameAction = B_LAYER_ACTION_NONE;
@@ -1467,6 +1474,29 @@ Layer::SendUpdateMsg(BRegion& reg)
fOwner->Window()->SendMessageToClient(&msg); fOwner->Window()->SendMessageToClient(&msg);
} }
// AddToViewsWithInvalidCoords
void
Layer::AddToViewsWithInvalidCoords() const
{
if (fServerWin) {
fServerWin->fClientViewsWithInvalidCoords.AddInt32("_token", fViewToken);
fServerWin->fClientViewsWithInvalidCoords.AddPoint("where", fFrame.LeftTop());
fServerWin->fClientViewsWithInvalidCoords.AddFloat("width", fFrame.Width());
fServerWin->fClientViewsWithInvalidCoords.AddFloat("height", fFrame.Height());
}
}
// SendViewCoordUpdateMsg
void
Layer::SendViewCoordUpdateMsg() const
{
if (fServerWin && !fServerWin->fClientViewsWithInvalidCoords.IsEmpty()) {
fServerWin->SendMessageToClient(&fServerWin->fClientViewsWithInvalidCoords);
fServerWin->fClientViewsWithInvalidCoords.MakeEmpty();
}
}
/*
//! Sends a B_VIEW_MOVED message to the client BWindow //! Sends a B_VIEW_MOVED message to the client BWindow
void void
Layer::SendViewMovedMsg() Layer::SendViewMovedMsg()
@@ -1502,5 +1532,5 @@ Layer::SendViewResizedMsg()
fServerWin->SendMessageToClient(&msg); fServerWin->SendMessageToClient(&msg);
} }
} }
*/
+4 -2
View File
@@ -246,8 +246,10 @@ class Layer {
ServerWindow* SearchForServerWindow(); ServerWindow* SearchForServerWindow();
void SendUpdateMsg(BRegion& reg); void SendUpdateMsg(BRegion& reg);
void SendViewMovedMsg(); void AddToViewsWithInvalidCoords() const;
void SendViewResizedMsg(); void SendViewCoordUpdateMsg() const;
// void SendViewMovedMsg();
// void SendViewResizedMsg();
}; };
+2 -1
View File
@@ -122,7 +122,8 @@ ServerWindow::ServerWindow( const char *string,
// 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),
fClientLooperPort(looperPort), fClientLooperPort(looperPort),
fHandlerToken(handlerID) fHandlerToken(handlerID),
fClientViewsWithInvalidCoords(B_VIEW_RESIZED)
{ {
STRACE(("ServerWindow(%s)::ServerWindow()\n",string? string: "NULL")); STRACE(("ServerWindow(%s)::ServerWindow()\n",string? string: "NULL"));
+8 -5
View File
@@ -27,17 +27,18 @@
#ifndef _SERVERWIN_H_ #ifndef _SERVERWIN_H_
#define _SERVERWIN_H_ #define _SERVERWIN_H_
#include <SupportDefs.h>
#include <GraphicsDefs.h> #include <GraphicsDefs.h>
#include <OS.h> #include <LinkMsgReader.h>
#include <LinkMsgSender.h>
#include <Locker.h> #include <Locker.h>
#include <Message.h>
#include <OS.h>
#include <Rect.h> #include <Rect.h>
#include <String.h> #include <String.h>
#include <Window.h> #include <Window.h>
#include <LinkMsgReader.h>
#include <LinkMsgSender.h>
#include "TokenSpace.h"
#include "FMWList.h" #include "FMWList.h"
#include "TokenSpace.h"
class BString; class BString;
class BMessenger; class BMessenger;
@@ -150,6 +151,8 @@ protected:
LinkMsgReader* fMsgReader; LinkMsgReader* fMsgReader;
LinkMsgSender* fMsgSender; LinkMsgSender* fMsgSender;
BMessage fClientViewsWithInvalidCoords;
BLocker fLocker; BLocker fLocker;
int32 fHandlerToken; int32 fHandlerToken;