* The move/resize window protocol now uses absolute coordinates rather than
relative ones. This fixes bugs #2658, and #3213; in BWindow::ScreenChanged() the window does not yet know that it moved on the new screen (when it already had a position on that workspace). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28908 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1530,7 +1530,7 @@ BWindow::Zoom()
|
|||||||
The dimensions that non-virtual Zoom() passes to hook Zoom() are deduced from
|
The dimensions that non-virtual Zoom() passes to hook Zoom() are deduced from
|
||||||
the smallest of three rectangles:
|
the smallest of three rectangles:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// fallback in case retrieving the decorator settings fails (highly unlikely)
|
// fallback in case retrieving the decorator settings fails (highly unlikely)
|
||||||
float borderWidth = 5.0;
|
float borderWidth = 5.0;
|
||||||
float tabHeight = 21.0;
|
float tabHeight = 21.0;
|
||||||
@@ -1541,7 +1541,7 @@ BWindow::Zoom()
|
|||||||
tabHeight = tabRect.Height();
|
tabHeight = tabRect.Height();
|
||||||
settings.FindFloat("border width", &borderWidth);
|
settings.FindFloat("border width", &borderWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1) the rectangle defined by SetZoomLimits(),
|
// 1) the rectangle defined by SetZoomLimits(),
|
||||||
float zoomedWidth = fMaxZoomWidth;
|
float zoomedWidth = fMaxZoomWidth;
|
||||||
float zoomedHeight = fMaxZoomHeight;
|
float zoomedHeight = fMaxZoomHeight;
|
||||||
@@ -2251,89 +2251,87 @@ BWindow::LastMouseMovedView() const
|
|||||||
void
|
void
|
||||||
BWindow::MoveBy(float dx, float dy)
|
BWindow::MoveBy(float dx, float dy)
|
||||||
{
|
{
|
||||||
if ((dx == 0.0 && dy == 0.0) || !Lock())
|
if ((dx != 0.0f || dy != 0.0f) && Lock()) {
|
||||||
return;
|
MoveTo(fFrame.left + dx, fFrame.top + dy);
|
||||||
|
Unlock();
|
||||||
fLink->StartMessage(AS_WINDOW_MOVE);
|
}
|
||||||
fLink->Attach<float>(dx);
|
|
||||||
fLink->Attach<float>(dy);
|
|
||||||
|
|
||||||
status_t status;
|
|
||||||
if (fLink->FlushWithReply(status) == B_OK && status == B_OK)
|
|
||||||
fFrame.OffsetBy(dx, dy);
|
|
||||||
|
|
||||||
Unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BWindow::MoveTo(BPoint point)
|
BWindow::MoveTo(BPoint point)
|
||||||
{
|
{
|
||||||
if (!Lock())
|
MoveTo(point.x, point.y);
|
||||||
return;
|
|
||||||
|
|
||||||
point.x = roundf(point.x);
|
|
||||||
point.y = roundf(point.y);
|
|
||||||
|
|
||||||
if (fFrame.left != point.x || fFrame.top != point.y) {
|
|
||||||
float xOffset = point.x - fFrame.left;
|
|
||||||
float yOffset = point.y - fFrame.top;
|
|
||||||
|
|
||||||
MoveBy(xOffset, yOffset);
|
|
||||||
}
|
|
||||||
|
|
||||||
Unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BWindow::MoveTo(float x, float y)
|
BWindow::MoveTo(float x, float y)
|
||||||
{
|
{
|
||||||
MoveTo(BPoint(x, y));
|
if (!Lock())
|
||||||
|
return;
|
||||||
|
|
||||||
|
x = roundf(x);
|
||||||
|
y = roundf(y);
|
||||||
|
|
||||||
|
if (fFrame.left != x || fFrame.top != y) {
|
||||||
|
fLink->StartMessage(AS_WINDOW_MOVE);
|
||||||
|
fLink->Attach<float>(x);
|
||||||
|
fLink->Attach<float>(y);
|
||||||
|
|
||||||
|
status_t status;
|
||||||
|
if (fLink->FlushWithReply(status) == B_OK && status == B_OK)
|
||||||
|
fFrame.OffsetTo(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BWindow::ResizeBy(float dx, float dy)
|
BWindow::ResizeBy(float dx, float dy)
|
||||||
{
|
{
|
||||||
if (!Lock())
|
if (Lock()) {
|
||||||
return;
|
ResizeTo(fFrame.Width() + dx, fFrame.Height() + dy);
|
||||||
|
Unlock();
|
||||||
dx = roundf(dx);
|
|
||||||
dy = roundf(dy);
|
|
||||||
|
|
||||||
// stay in minimum & maximum frame limits
|
|
||||||
if (fFrame.Width() + dx < fMinWidth)
|
|
||||||
dx = fMinWidth - fFrame.Width();
|
|
||||||
if (fFrame.Width() + dx > fMaxWidth)
|
|
||||||
dx = fMaxWidth - fFrame.Width();
|
|
||||||
if (fFrame.Height() + dy < fMinHeight)
|
|
||||||
dy = fMinHeight - fFrame.Height();
|
|
||||||
if (fFrame.Height() + dy > fMaxHeight)
|
|
||||||
dy = fMaxHeight - fFrame.Height();
|
|
||||||
|
|
||||||
if (dx != 0.0 || dy != 0.0) {
|
|
||||||
fLink->StartMessage(AS_WINDOW_RESIZE);
|
|
||||||
fLink->Attach<float>(dx);
|
|
||||||
fLink->Attach<float>(dy);
|
|
||||||
|
|
||||||
status_t status;
|
|
||||||
if (fLink->FlushWithReply(status) == B_OK && status == B_OK) {
|
|
||||||
fFrame.SetRightBottom(fFrame.RightBottom() + BPoint(dx, dy));
|
|
||||||
_AdoptResize();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BWindow::ResizeTo(float width, float height)
|
BWindow::ResizeTo(float width, float height)
|
||||||
{
|
{
|
||||||
if (Lock()) {
|
if (!Lock())
|
||||||
ResizeBy(width - fFrame.Width(), height - fFrame.Height());
|
return;
|
||||||
Unlock();
|
|
||||||
|
width = roundf(width);
|
||||||
|
height = roundf(height);
|
||||||
|
|
||||||
|
// stay in minimum & maximum frame limits
|
||||||
|
if (width < fMinWidth)
|
||||||
|
width = fMinWidth;
|
||||||
|
else if (width > fMaxWidth)
|
||||||
|
width = fMaxWidth;
|
||||||
|
|
||||||
|
if (height < fMinHeight)
|
||||||
|
height = fMinHeight;
|
||||||
|
else if (height > fMaxHeight)
|
||||||
|
height = fMaxHeight;
|
||||||
|
|
||||||
|
if (width != fFrame.Width() || height != fFrame.Height()) {
|
||||||
|
fLink->StartMessage(AS_WINDOW_RESIZE);
|
||||||
|
fLink->Attach<float>(width);
|
||||||
|
fLink->Attach<float>(height);
|
||||||
|
|
||||||
|
status_t status;
|
||||||
|
if (fLink->FlushWithReply(status) == B_OK && status == B_OK) {
|
||||||
|
fFrame.right = fFrame.left + width;
|
||||||
|
fFrame.bottom = fFrame.top + height;
|
||||||
|
_AdoptResize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3166,7 +3164,7 @@ BWindow::_SanitizeMessage(BMessage* message, BHandler* target, bool usePreferred
|
|||||||
if (message->what != B_MOUSE_MOVED) {
|
if (message->what != B_MOUSE_MOVED) {
|
||||||
// Yep, the meaning of "where" is different
|
// Yep, the meaning of "where" is different
|
||||||
// for regular mouse moved messages versus
|
// for regular mouse moved messages versus
|
||||||
// mouse up/down!
|
// mouse up/down!
|
||||||
message->AddPoint("where", viewWhere);
|
message->AddPoint("where", viewWhere);
|
||||||
}
|
}
|
||||||
message->AddPoint("be:view_where", viewWhere);
|
message->AddPoint("be:view_where", viewWhere);
|
||||||
|
|||||||
@@ -938,14 +938,14 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
|||||||
}
|
}
|
||||||
case AS_WINDOW_RESIZE:
|
case AS_WINDOW_RESIZE:
|
||||||
{
|
{
|
||||||
float xResizeBy;
|
float xResizeTo;
|
||||||
float yResizeBy;
|
float yResizeTo;
|
||||||
link.Read<float>(&xResizeBy);
|
link.Read<float>(&xResizeTo);
|
||||||
if (link.Read<float>(&yResizeBy) != B_OK)
|
if (link.Read<float>(&yResizeTo) != B_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
DTRACE(("ServerWindow %s: Message AS_WINDOW_RESIZE %.1f, %.1f\n",
|
DTRACE(("ServerWindow %s: Message AS_WINDOW_RESIZE %.1f, %.1f\n",
|
||||||
Title(), xResizeBy, yResizeBy));
|
Title(), xResizeTo, yResizeTo));
|
||||||
|
|
||||||
// comment this code for the time being, as some apps rely
|
// comment this code for the time being, as some apps rely
|
||||||
// on the programmatically resize behavior during user resize
|
// on the programmatically resize behavior during user resize
|
||||||
@@ -955,7 +955,9 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
|||||||
// fLink.StartMessage(B_BUSY);
|
// fLink.StartMessage(B_BUSY);
|
||||||
// } else {
|
// } else {
|
||||||
//fDesktop->UnlockSingleWindow();
|
//fDesktop->UnlockSingleWindow();
|
||||||
fDesktop->ResizeWindowBy(fWindow, xResizeBy, yResizeBy);
|
fDesktop->ResizeWindowBy(fWindow,
|
||||||
|
xResizeTo - fWindow->Frame().Width(),
|
||||||
|
yResizeTo - fWindow->Frame().Height());
|
||||||
//fDesktop->LockSingleWindow();
|
//fDesktop->LockSingleWindow();
|
||||||
fLink.StartMessage(B_OK);
|
fLink.StartMessage(B_OK);
|
||||||
// }
|
// }
|
||||||
@@ -964,14 +966,14 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
|||||||
}
|
}
|
||||||
case AS_WINDOW_MOVE:
|
case AS_WINDOW_MOVE:
|
||||||
{
|
{
|
||||||
float xMoveBy;
|
float xMoveTo;
|
||||||
float yMoveBy;
|
float yMoveTo;
|
||||||
link.Read<float>(&xMoveBy);
|
link.Read<float>(&xMoveTo);
|
||||||
if (link.Read<float>(&yMoveBy) != B_OK)
|
if (link.Read<float>(&yMoveTo) != B_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
DTRACE(("ServerWindow %s: Message AS_WINDOW_MOVE: %.1f, %.1f\n",
|
DTRACE(("ServerWindow %s: Message AS_WINDOW_MOVE: %.1f, %.1f\n",
|
||||||
Title(), xMoveBy, yMoveBy));
|
Title(), xMoveTo, yMoveTo));
|
||||||
|
|
||||||
if (fWindow->IsDragging()) {
|
if (fWindow->IsDragging()) {
|
||||||
// While the user moves the window, we ignore
|
// While the user moves the window, we ignore
|
||||||
@@ -979,7 +981,8 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
|||||||
fLink.StartMessage(B_BUSY);
|
fLink.StartMessage(B_BUSY);
|
||||||
} else {
|
} else {
|
||||||
//fDesktop->UnlockSingleWindow();
|
//fDesktop->UnlockSingleWindow();
|
||||||
fDesktop->MoveWindowBy(fWindow, xMoveBy, yMoveBy);
|
fDesktop->MoveWindowBy(fWindow, xMoveTo - fWindow->Frame().left,
|
||||||
|
yMoveTo - fWindow->Frame().top);
|
||||||
//fDesktop->LockSingleWindow();
|
//fDesktop->LockSingleWindow();
|
||||||
fLink.StartMessage(B_OK);
|
fLink.StartMessage(B_OK);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user