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:
@@ -395,58 +395,68 @@ 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();
|
||||||
|
// 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 *activeFocus;
|
||||||
|
BRegion invalidRegion;
|
||||||
|
|
||||||
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();
|
|
||||||
|
|
||||||
// TODO: more work needs to be done. Think! Think! Think again!
|
activeFocus->Window()->Lock();
|
||||||
// remember - front != focus. Also put modal windows into equation!
|
|
||||||
|
|
||||||
// a HINT: inside Decorator 'highlight' flag is not set before a redraw with
|
if (target == activeFocus && target->Window()->Flags() & B_WILL_ACCEPT_FIRST_CLICK)
|
||||||
// activeFocus->fParent->FullInvalidate(invalidRegion);
|
target->MouseDown(msg, true);
|
||||||
if (activeFocus != previousFocus){
|
|
||||||
// redraw decorator in its active mode.
|
// may be or may be empty.
|
||||||
if (activeFocus){
|
invalidRegion.Include(&(activeFocus->fFull));
|
||||||
if (activeFocus->fDecorator){
|
invalidRegion.Include(&(activeFocus->fTopLayer->fFull));
|
||||||
invalidRegion.Include(&(activeFocus->fVisible));
|
activeFocus->fParent->FullInvalidate(invalidRegion);
|
||||||
activeFocus->fParent->FullInvalidate(invalidRegion);
|
// TODO: this is a hack!!! Should be something like this:
|
||||||
|
// void Layer::RebuildAndForceRedraw(invalidReg, target){
|
||||||
|
// BPoint pt(0,0);
|
||||||
|
// StartRebuildRegions(invalidRegion, NULL, B_LAYER_NONE, pt);
|
||||||
|
// if (target) gRedrawReg.Include(target->fFullVisible);
|
||||||
|
// Redraw(gRedrawReg);
|
||||||
|
// }
|
||||||
|
// called like: target->fParent->RebuildAndForceRedraw(reg, target);
|
||||||
|
activeFocus->fParent->Invalidate(invalidRegion);
|
||||||
|
|
||||||
|
if (previousFocus != activeFocus && previousFocus)
|
||||||
|
{
|
||||||
|
if (previousFocus->fVisible.CountRects() > 0)
|
||||||
|
{
|
||||||
|
invalidRegion.MakeEmpty();
|
||||||
|
invalidRegion.Include(&(previousFocus->fVisible));
|
||||||
|
activeFocus->fParent->Invalidate(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.
|
fMouseTarget = activeFocus;
|
||||||
if (previousFocus)
|
|
||||||
if (previousFocus->fDecorator)
|
activeFocus->Window()->Unlock();
|
||||||
previousFocus->fParent->Invalidate(previousFocus->fVisible);
|
|
||||||
}
|
}
|
||||||
else{
|
else // target == fMouseTarget
|
||||||
// let WinBorder know we have the mouse down. This is the same window as before.
|
{
|
||||||
if (activeFocus)
|
target->Window()->Lock();
|
||||||
activeFocus->MouseDown(msg, true);
|
target->MouseDown(msg, true);
|
||||||
|
target->Window()->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
fMouseTarget = activeFocus;
|
|
||||||
|
|
||||||
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
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -465,7 +465,8 @@ void Layer::RequestDraw(const BRegion ®, 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);
|
||||||
|
|||||||
@@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user