Same as before. Some code for window selection/moving with the mouse.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8131 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adi Oanca
2004-06-22 21:43:24 +00:00
parent a667ca3cde
commit a635ede332
3 changed files with 56 additions and 43 deletions
+41 -31
View File
@@ -394,59 +394,69 @@ void Desktop::MouseEventHandler(PortMessage *msg)
ws = rl->ActiveWorkspace(); ws = rl->ActiveWorkspace();
target = ws->SearchWinBorder(pt); target = ws->SearchWinBorder(pt);
if (target) if (target)
{
fGeneralLock.Lock();
rl->fMainLock.Lock();
// TODO: it's not that good to use fMouseTarget.
// (you have problems with B_MOUSE_UP, you know... :-)))
// Yes, I know. But it's too late tonight. :-)))
if (target != fMouseTarget)
{ {
WinBorder *previousFocus; WinBorder *previousFocus;
WinBorder *activeFocus; WinBorder *activeFocus;
BRegion invalidRegion; BRegion invalidRegion;
fGeneralLock.Lock();
rl->fMainLock.Lock();
ws->BringToFrontANormalWindow(target); ws->BringToFrontANormalWindow(target);
ws->SearchAndSetNewFront(target); ws->SearchAndSetNewFront(target);
previousFocus = ws->FocusLayer(); previousFocus = ws->FocusLayer();
activeFocus = ws->SetFocusLayer(target); 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(); activeFocus->Window()->Lock();
// TODO: more work needs to be done. Think! Think! Think again! if (target == activeFocus && target->Window()->Flags() & B_WILL_ACCEPT_FIRST_CLICK)
// remember - front != focus. Also put modal windows into equation! target->MouseDown(msg, true);
// a HINT: inside Decorator 'highlight' flag is not set before a redraw with // may be or may be empty.
// activeFocus->fParent->FullInvalidate(invalidRegion); invalidRegion.Include(&(activeFocus->fFull));
if (activeFocus != previousFocus){ invalidRegion.Include(&(activeFocus->fTopLayer->fFull));
// redraw decorator in its active mode.
if (activeFocus){
if (activeFocus->fDecorator){
invalidRegion.Include(&(activeFocus->fVisible));
activeFocus->fParent->FullInvalidate(invalidRegion); activeFocus->fParent->FullInvalidate(invalidRegion);
} // TODO: this is a hack!!! Should be something like this:
// let WinBorder know we have the mouse down. // void Layer::RebuildAndForceRedraw(invalidReg, target){
if (activeFocus->Window()->Flags() & B_WILL_ACCEPT_FIRST_CLICK) // BPoint pt(0,0);
activeFocus->MouseDown(msg, false); // StartRebuildRegions(invalidRegion, NULL, B_LAYER_NONE, pt);
else // if (target) gRedrawReg.Include(target->fFullVisible);
activeFocus->MouseDown(msg, true); // Redraw(gRedrawReg);
} // }
// called like: target->fParent->RebuildAndForceRedraw(reg, target);
activeFocus->fParent->Invalidate(invalidRegion);
// redraw previous window's decorator. It has lost focus state. if (previousFocus != activeFocus && previousFocus)
if (previousFocus) {
if (previousFocus->fDecorator) if (previousFocus->fVisible.CountRects() > 0)
previousFocus->fParent->Invalidate(previousFocus->fVisible); {
invalidRegion.MakeEmpty();
invalidRegion.Include(&(previousFocus->fVisible));
activeFocus->fParent->Invalidate(invalidRegion);
} }
else{
// let WinBorder know we have the mouse down. This is the same window as before.
if (activeFocus)
activeFocus->MouseDown(msg, true);
} }
fMouseTarget = activeFocus; fMouseTarget = activeFocus;
activeFocus->Window()->Unlock();
}
else // target == fMouseTarget
{
target->Window()->Lock();
target->MouseDown(msg, true);
target->Window()->Unlock(); target->Window()->Unlock();
}
rl->fMainLock.Unlock(); rl->fMainLock.Unlock();
fGeneralLock.Unlock(); fGeneralLock.Unlock();
} }
else // target == NULL
{
}
break; break;
} }
case B_MOUSE_UP: case B_MOUSE_UP:
@@ -463,7 +473,7 @@ printf("activeFocus: %s\n", activeFocus? activeFocus->GetName(): "NULL");
fMouseTarget->MouseUp(msg); fMouseTarget->MouseUp(msg);
fMouseTarget->Window()->Unlock(); fMouseTarget->Window()->Unlock();
fMouseTarget = NULL; // fMouseTarget = NULL;
} }
else else
{ {
+2 -1
View File
@@ -465,7 +465,8 @@ void Layer::RequestDraw(const BRegion &reg, Layer *startFrom)
void Layer::Draw(const BRect &r) void Layer::Draw(const BRect &r)
{ {
// TODO/NOTE: this should be an empty method! the next lines are for testing only // TODO/NOTE: this should be an empty method! the next lines are for testing only
printf("Layer::Draw\n");
r.PrintToStream();
STRACE(("Layer::Draw() Called\n")); STRACE(("Layer::Draw() Called\n"));
/* /*
RGBColor col(152,102,51); RGBColor col(152,102,51);
+3 -1
View File
@@ -350,13 +350,15 @@ void WinBorder::MouseUp(PortMessage *msg)
void WinBorder::HighlightDecorator(const bool &active) void WinBorder::HighlightDecorator(const bool &active)
{ {
printf("Decorator->Highlight\n");
fDecorator->SetFocus(active); fDecorator->SetFocus(active);
} }
void WinBorder::Draw(const BRect &r) void WinBorder::Draw(const BRect &r)
{ {
STRACE(("WinBorder(%s)::Draw()\n", GetName())); STRACE(("WinBorder(%s)::Draw()\n", GetName()));
printf("WinBorder::DRAW\n");
r.PrintToStream();
// if we have a visible region, it is decorator's one. // if we have a visible region, it is decorator's one.
if(fDecorator) if(fDecorator)
{ {