I'm in the middle of corect window drawing while using the mouse.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8083 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adi Oanca
2004-06-20 20:02:32 +00:00
parent 24b7442c3f
commit a68bab127c
5 changed files with 67 additions and 25 deletions
+42 -4
View File
@@ -395,15 +395,53 @@ void Desktop::MouseEventHandler(PortMessage *msg)
target = ws->SearchWinBorder(pt); target = ws->SearchWinBorder(pt);
if (target) if (target)
{ {
WinBorder *previousFocus;
WinBorder *activeFocus;
BRegion invalidRegion;
fGeneralLock.Lock(); fGeneralLock.Lock();
rl->fMainLock.Lock(); rl->fMainLock.Lock();
target->Window()->Lock();
ws->BringToFrontANormalWindow(target);
ws->SearchAndSetNewFront(target); ws->SearchAndSetNewFront(target);
ws->SetFocusLayer(target); previousFocus = ws->FocusLayer();
activeFocus = ws->SetFocusLayer(target);
printf("target: %s\n", target? target->GetName(): "NULL");
printf("previousFocus: %s\n", previousFocus? previousFocus->GetName(): "NULL");
printf("activeFocus: %s\n", activeFocus? activeFocus->GetName(): "NULL");
activeFocus->Window()->Lock();
fMouseTarget = target; // TODO: more work needs to be done. Think! Think! Think again!
target->MouseDown(msg); // remember - front != focus. Also put modal windows into equation!
// a HINT: inside Decorator 'highlight' flag is not set before a redraw with
// activeFocus->fParent->FullInvalidate(invalidRegion);
if (activeFocus != previousFocus){
// redraw decorator in its active mode.
if (activeFocus){
if (activeFocus->fDecorator){
invalidRegion.Include(&(activeFocus->fVisible));
activeFocus->fParent->FullInvalidate(invalidRegion);
}
// let WinBorder know we have the mouse down.
if (activeFocus->Window()->Flags() & B_WILL_ACCEPT_FIRST_CLICK)
activeFocus->MouseDown(msg, false);
else
activeFocus->MouseDown(msg, true);
}
// redraw previous window's decorator. It has lost focus state.
if (previousFocus)
if (previousFocus->fDecorator)
previousFocus->fParent->Invalidate(previousFocus->fVisible);
}
else{
// let WinBorder know we have the mouse down. This is the same window as before.
if (activeFocus)
activeFocus->MouseDown(msg, true);
}
fMouseTarget = activeFocus;
target->Window()->Unlock(); target->Window()->Unlock();
rl->fMainLock.Unlock(); rl->fMainLock.Unlock();
+12 -16
View File
@@ -136,7 +136,6 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook,
fWorkspaces = index; fWorkspaces = index;
fWinBorder = NULL; fWinBorder = NULL;
fTopLayer = NULL;
// 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;
@@ -163,12 +162,6 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook,
if(vCode != AS_LAYER_CREATE) if(vCode != AS_LAYER_CREATE)
debugger("SERVER ERROR: ServerWindow(xxx): NO top_view data received! - 2\n"); debugger("SERVER ERROR: ServerWindow(xxx): NO top_view data received! - 2\n");
// Start receiving top_view data -- pass NULL as the parent view.
// This should be the *only* place where this happens.
fTopLayer = CreateLayerTree(NULL);
fTopLayer->SetAsTopLayer(true);
cl = fTopLayer;
STRACE(("ServerWindow %s:\n",fTitle.String())); STRACE(("ServerWindow %s:\n",fTitle.String()));
STRACE(("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",rect.left,rect.top,rect.right,rect.bottom)); STRACE(("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",rect.left,rect.top,rect.right,rect.bottom));
STRACE(("\tPort: %ld\n",fMessagePort)); STRACE(("\tPort: %ld\n",fMessagePort));
@@ -181,8 +174,14 @@ void ServerWindow::Init(void)
this, desktop->GetDisplayDriver()); this, desktop->GetDisplayDriver());
fWinBorder->RebuildFullRegion(); fWinBorder->RebuildFullRegion();
// Start receiving top_view data -- pass NULL as the parent view.
// This should be the *only* place where this happens.
fWinBorder->fTopLayer = CreateLayerTree(NULL);
fWinBorder->fTopLayer->SetAsTopLayer(true);
cl = fWinBorder->fTopLayer;
// connect decorator and top layer. // connect decorator and top layer.
fWinBorder->AddChild(fTopLayer, NULL); fWinBorder->AddChild(fWinBorder->fTopLayer, NULL);
// 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);
@@ -216,9 +215,6 @@ ServerWindow::~ServerWindow(void)
cl = NULL; cl = NULL;
if (fTopLayer)
delete fTopLayer;
STRACE(("#ServerWindow(%s) will exit NOW!!!\n", fTitle.String())); STRACE(("#ServerWindow(%s) will exit NOW!!!\n", fTitle.String()));
} }
//5700 - fara servo , fara cas //5700 - fara servo , fara cas
@@ -292,13 +288,13 @@ void ServerWindow::Show(void)
WinBorder *previousFocus; WinBorder *previousFocus;
BRegion invalidRegion; BRegion invalidRegion;
Workspace *ws; Workspace *ws;
// TODO: can you unify this method with Desktop::MouseEventHandler::B_MOUSE_DOWN
ws = rl->WorkspaceAt(i+1); ws = rl->WorkspaceAt(i+1);
ws->BringToFrontANormalWindow(fWinBorder); ws->BringToFrontANormalWindow(fWinBorder);
ws->SearchAndSetNewFront(fWinBorder); ws->SearchAndSetNewFront(fWinBorder);
previousFocus = ws->FocusLayer(); previousFocus = ws->FocusLayer();
ws->SetFocusLayer(fWinBorder); ws->SetFocusLayer(fWinBorder);
// TODO: only do this in for the active workspace!
// first redraw previous window's decorator. It has lost focus state. // first redraw previous window's decorator. It has lost focus state.
if (previousFocus) if (previousFocus)
if (previousFocus->fDecorator) if (previousFocus->fDecorator)
@@ -306,9 +302,9 @@ void ServerWindow::Show(void)
// we must build the rebuild region. we have nowhere to take it from. // we must build the rebuild region. we have nowhere to take it from.
// include decorator's(if any) and fTopLayer's full regions. // include decorator's(if any) and fTopLayer's full regions.
fTopLayer->RebuildFullRegion(); fWinBorder->fTopLayer->RebuildFullRegion();
fWinBorder->RebuildFullRegion(); fWinBorder->RebuildFullRegion();
invalidRegion.Include(&(fTopLayer->fFull)); invalidRegion.Include(&(fWinBorder->fTopLayer->fFull));
if (fWinBorder->fDecorator) if (fWinBorder->fDecorator)
invalidRegion.Include(&(fWinBorder->fFull)); invalidRegion.Include(&(fWinBorder->fFull));
@@ -828,7 +824,7 @@ void ServerWindow::DispatchMessage(int32 code)
fSession->ReadInt32(&token); fSession->ReadInt32(&token);
Layer *current = FindLayer(fTopLayer, token); Layer *current = FindLayer(fWinBorder->fTopLayer, token);
if (current) if (current)
cl=current; cl=current;
-1
View File
@@ -160,7 +160,6 @@ protected:
int32 fHandlerToken; int32 fHandlerToken;
BSession *fSession; BSession *fSession;
Layer *fTopLayer;
// cl is short for currentLayer. We'll use it a lot, that's why it's short :-) // cl is short for currentLayer. We'll use it a lot, that's why it's short :-)
Layer *cl; Layer *cl;
+8 -3
View File
@@ -91,6 +91,7 @@ WinBorder::WinBorder(const BRect &r, const char *name, const int32 look, const i
fKeyModifiers = 0; fKeyModifiers = 0;
fMainWinBorder = NULL; fMainWinBorder = NULL;
fDecorator = NULL; fDecorator = NULL;
fTopLayer = NULL;
fAdFlags = fAdFlags | B_LAYER_CHILDREN_DEPENDANT; fAdFlags = fAdFlags | B_LAYER_CHILDREN_DEPENDANT;
fFlags = B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE; fFlags = B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE;
@@ -114,6 +115,11 @@ WinBorder::WinBorder(const BRect &r, const char *name, const int32 look, const i
WinBorder::~WinBorder(void) WinBorder::~WinBorder(void)
{ {
STRACE(("WinBorder(%s)::~WinBorder()\n",GetName())); STRACE(("WinBorder(%s)::~WinBorder()\n",GetName()));
if (fTopLayer){
delete fTopLayer;
fTopLayer = NULL;
}
if (fDecorator) if (fDecorator)
{ {
delete fDecorator; delete fDecorator;
@@ -132,7 +138,7 @@ void WinBorder::RebuildFullRegion(void)
fDecorator->GetFootprint(&fFull); fDecorator->GetFootprint(&fFull);
} }
void WinBorder::MouseDown(PortMessage *msg) void WinBorder::MouseDown(PortMessage *msg, bool sendMessage)
{ {
if (!(Window()->IsLocked())) if (!(Window()->IsLocked()))
debugger("you must lock the attached ServerWindow object\n\t before calling WinBorder::MouseDown()\n"); debugger("you must lock the attached ServerWindow object\n\t before calling WinBorder::MouseDown()\n");
@@ -225,8 +231,7 @@ void WinBorder::MouseDown(PortMessage *msg)
} }
} }
} }
else else if (sendMessage){
{
BMessage msg; BMessage msg;
msg.what= B_MOUSE_DOWN; msg.what= B_MOUSE_DOWN;
msg.AddInt64("when", time); msg.AddInt64("when", time);
+5 -1
View File
@@ -36,6 +36,7 @@ class ServerWindow;
class Decorator; class Decorator;
class DisplayDriver; class DisplayDriver;
class PortMessage; class PortMessage;
class Desktop;
class WinBorder : public Layer class WinBorder : public Layer
{ {
@@ -51,7 +52,7 @@ public:
virtual void RebuildFullRegion(void); virtual void RebuildFullRegion(void);
void MouseDown(PortMessage *msg); void MouseDown(PortMessage *msg, bool sendMessage);
void MouseMoved(PortMessage *msg); void MouseMoved(PortMessage *msg);
void MouseUp(PortMessage *msg); void MouseUp(PortMessage *msg);
@@ -79,8 +80,11 @@ public:
protected: protected:
friend class Layer; friend class Layer;
friend class ServerWindow; friend class ServerWindow;
friend class Desktop;
Decorator *fDecorator; Decorator *fDecorator;
Layer *fTopLayer;
int32 fMouseButtons; int32 fMouseButtons;
int32 fKeyModifiers; int32 fKeyModifiers;
BPoint fLastMousePosition; BPoint fLastMousePosition;