From 19d801a6b6acbd725e8bb474c3be56d4fa99b66a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 1 Dec 2005 10:31:30 +0000 Subject: [PATCH] Moving/resizing is now routed over the desktop as well. This also allows the workspaces layer for these actions, which is now done as well. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15258 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/Desktop.cpp | 14 +++++++++++ src/servers/app/Desktop.h | 3 +++ src/servers/app/RootLayer.cpp | 40 ++++++++++++++++++++++++++++++++ src/servers/app/RootLayer.h | 3 +++ src/servers/app/ServerWindow.cpp | 16 ++++++------- src/servers/app/WindowLayer.cpp | 6 ++--- 6 files changed, 71 insertions(+), 11 deletions(-) diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp index 1009a2a039..e8d8a60de8 100644 --- a/src/servers/app/Desktop.cpp +++ b/src/servers/app/Desktop.cpp @@ -663,6 +663,20 @@ Desktop::HideWindow(WindowLayer* window) } +void +Desktop::MoveWindowBy(WindowLayer* window, float x, float y) +{ + fRootLayer->MoveWindowBy(window, x, y); +} + + +void +Desktop::ResizeWindowBy(WindowLayer* window, float x, float y) +{ + fRootLayer->ResizeWindowBy(window, x, y); +} + + /*! \brief Adds or removes the window to or from the workspaces it's on. */ diff --git a/src/servers/app/Desktop.h b/src/servers/app/Desktop.h index 1f2b6c564b..8ae0458bcd 100644 --- a/src/servers/app/Desktop.h +++ b/src/servers/app/Desktop.h @@ -93,6 +93,9 @@ class Desktop : public MessageLooper, public ScreenOwner { void ShowWindow(WindowLayer* window); void HideWindow(WindowLayer* window); + void MoveWindowBy(WindowLayer* window, float x, float y); + void ResizeWindowBy(WindowLayer* window, float x, float y); + void SetWindowWorkspaces(WindowLayer* window, uint32 workspaces); diff --git a/src/servers/app/RootLayer.cpp b/src/servers/app/RootLayer.cpp index aa5982a259..7bbb5a0acd 100644 --- a/src/servers/app/RootLayer.cpp +++ b/src/servers/app/RootLayer.cpp @@ -519,6 +519,46 @@ RootLayer::ShowWindowLayer(WindowLayer* windowLayer, bool toFront) } +void +RootLayer::MoveWindowBy(WindowLayer* window, float x, float y) +{ + BAutolock _(fAllRegionsLock); + + // TODO: the MoveBy() should just return a dirty region + window->MoveBy(x, y); + if (window->Parent() == NULL) + return; + + BRegion changed; + _WindowsChanged(changed); + + if (changed.CountRects() > 0) { + MarkForRedraw(changed); + TriggerRedraw(); + } +} + + +void +RootLayer::ResizeWindowBy(WindowLayer* window, float x, float y) +{ + BAutolock _(fAllRegionsLock); + + // TODO: the MoveBy() should just return a dirty region + window->ResizeBy(x, y); + if (window->Parent() == NULL) + return; + + BRegion changed; + _WindowsChanged(changed); + + if (changed.CountRects() > 0) { + MarkForRedraw(changed); + TriggerRedraw(); + } +} + + void RootLayer::SetWindowLayerFeel(WindowLayer *windowLayer, int32 newFeel) { diff --git a/src/servers/app/RootLayer.h b/src/servers/app/RootLayer.h index 69afb1ff81..bf5e57dfed 100644 --- a/src/servers/app/RootLayer.h +++ b/src/servers/app/RootLayer.h @@ -57,6 +57,9 @@ class RootLayer : public Layer { void HideWindowLayer(WindowLayer* windowLayer); void ShowWindowLayer(WindowLayer* windowLayer, bool toFront = true); + void MoveWindowBy(WindowLayer* window, float x, float y); + void ResizeWindowBy(WindowLayer* window, float x, float y); + bool SetFocus(WindowLayer* focus); WindowLayer* Focus() const { return fFocus; } WindowLayer* Front() const { return fFront; } diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index 58d84f22a8..5896fe74fb 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -1373,26 +1373,24 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) { float xResizeBy; float yResizeBy; - link.Read(&xResizeBy); link.Read(&yResizeBy); STRACE(("ServerWindow %s: Message AS_WINDOW_RESIZE %.1f, %.1f\n", Title(), xResizeBy, yResizeBy)); - - fWindowLayer->ResizeBy(xResizeBy, yResizeBy); + + fDesktop->ResizeWindowBy(fWindowLayer, xResizeBy, yResizeBy); break; } case AS_WINDOW_MOVE: { float xMoveBy; float yMoveBy; - link.Read(&xMoveBy); link.Read(&yMoveBy); STRACE(("ServerWindow %s: Message AS_WINDOW_MOVE: %.1f, %.1f\n", Title(), xMoveBy, yMoveBy)); - fWindowLayer->MoveBy(xMoveBy, yMoveBy); + fDesktop->MoveWindowBy(fWindowLayer, xMoveBy, yMoveBy); break; } case AS_SET_SIZE_LIMITS: @@ -1402,17 +1400,19 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) // 2) float maximum width // 3) float minimum height // 4) float maximum height - + float minWidth; float maxWidth; float minHeight; float maxHeight; - + link.Read(&minWidth); link.Read(&maxWidth); link.Read(&minHeight); link.Read(&maxHeight); - + + // TODO: setting size limits can change the window size, and therefore, + // it should be done by the Desktop class as well. fWindowLayer->SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight); // and now, sync the client to the limits that we were able to enforce diff --git a/src/servers/app/WindowLayer.cpp b/src/servers/app/WindowLayer.cpp index 231ce98091..e2f61714ed 100644 --- a/src/servers/app/WindowLayer.cpp +++ b/src/servers/app/WindowLayer.cpp @@ -543,11 +543,11 @@ WindowLayer::MouseMoved(BMessage *msg, BPoint where, int32* _viewToken) if (fIsDragging) { BPoint delta = where - fLastMousePosition; - MoveBy(delta.x, delta.y); + Window()->Desktop()->MoveWindowBy(this, delta.x, delta.y); } if (fIsResizing) { BPoint delta = where - fLastMousePosition; - ResizeBy(delta.x, delta.y); + Window()->Desktop()->ResizeWindowBy(this, delta.x, delta.y); } if (fIsSlidingTab) { // TODO: implement @@ -556,7 +556,7 @@ WindowLayer::MouseMoved(BMessage *msg, BPoint where, int32* _viewToken) fLastMousePosition = where; // change focus in FFM mode - Desktop* desktop = Window()->App()->GetDesktop(); + Desktop* desktop = Window()->Desktop(); DesktopSettings desktopSettings(desktop); if (desktopSettings.MouseMode() != B_NORMAL_MOUSE && !IsFocus())