From 08d9a6e30d49aac2ac85f0d141408bb66f7712c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 27 Jun 2005 02:06:15 +0000 Subject: [PATCH] Some minor work on minimum window sizes. A WinBorder now makes sure it has a valid size on construction; DefaultDecorator should do that as well. ServerApp AS_CREATE_WINDOW now makes sure it passes a valid rectangle to ServerWindow's constructor. Smaller default size for Layers that have been created with an invalid frame. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13291 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/DefaultDecorator.cpp | 5 ++++- src/servers/app/Layer.cpp | 4 ++-- src/servers/app/ServerApp.cpp | 6 ++++++ src/servers/app/WinBorder.cpp | 29 +++++++++++++++++++++++----- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/servers/app/DefaultDecorator.cpp b/src/servers/app/DefaultDecorator.cpp index 89cf545563..98828fe1c7 100644 --- a/src/servers/app/DefaultDecorator.cpp +++ b/src/servers/app/DefaultDecorator.cpp @@ -58,8 +58,11 @@ DefaultDecorator::DefaultDecorator(BRect rect, int32 wlook, int32 wfeel, int32 w // Do initial decorator setup _DoLayout(); + // ToDo: if the decorator was created with a frame too small, it should resize itself! + STRACE(("DefaultDecorator:\n")); - 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)); } DefaultDecorator::~DefaultDecorator(void) diff --git a/src/servers/app/Layer.cpp b/src/servers/app/Layer.cpp index 89f5989736..ab27bae385 100644 --- a/src/servers/app/Layer.cpp +++ b/src/servers/app/Layer.cpp @@ -126,7 +126,7 @@ char helper[1024]; sprintf(helper, "Layer::Layer(BRect(%.1f, %.1f, %.1f, %.1f), name: %s, token: %ld) - frame is invalid\n", frame.left, frame.top, frame.right, frame.bottom, name, token); CRITICAL(helper); - fFrame.Set(0, 0, 10, 10); + fFrame.Set(0, 0, 1, 1); } if (!fDriver) @@ -1040,7 +1040,7 @@ void Layer::ResizeBy(float x, float y) { STRACE(("Layer(%s)::ResizeBy() START\n", Name())); - + if (!fParent) { printf("ERROR: in Layer::ResizeBy()! - No parent!\n"); return; diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index 3588fa477c..e427a1e431 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -443,6 +443,12 @@ ServerApp::_MessageLooper() if (receiver.ReadString(&title) != B_OK) break; + if (!frame.IsValid()) { + // make sure we pass a valid rectangle to ServerWindow + frame.right = frame.left + 1; + frame.bottom = frame.top + 1; + } + // ServerWindow constructor will reply with port_id of a newly created port ServerWindow *window = new ServerWindow(title, this, clientReplyPort, looperPort, token, frame, look, feel, flags, workspaces); diff --git a/src/servers/app/WinBorder.cpp b/src/servers/app/WinBorder.cpp index 90b3bfc0e0..72902caac8 100644 --- a/src/servers/app/WinBorder.cpp +++ b/src/servers/app/WinBorder.cpp @@ -57,7 +57,7 @@ # define STRACE_CLICK(x) ; #endif -WinBorder::WinBorder(const BRect &r, +WinBorder::WinBorder(const BRect &frame, const char *name, const uint32 wlook, const uint32 wfeel, @@ -65,7 +65,7 @@ WinBorder::WinBorder(const BRect &r, const uint32 wwksindex, ServerWindow *win, DisplayDriver *driver) - : Layer(r, name, B_NULL_TOKEN, B_FOLLOW_NONE, 0UL, driver), + : Layer(frame, name, B_NULL_TOKEN, B_FOLLOW_NONE, 0UL, driver), fDecorator(NULL), fTopLayer(NULL), @@ -116,10 +116,29 @@ WinBorder::WinBorder(const BRect &r, QuietlySetFeel(wfeel); if (fFeel != B_NO_BORDER_WINDOW_LOOK) { - fDecorator = gDecorManager.AllocateDecorator(r, name, fLook, fFeel, + // ToDo: these should probably restricted by the decorator only, but + // the code there doesn't look too robust to me currently + fMinWidth = 20; + fMinHeight = 20; + } + + if (fFrame.Width() < fMinWidth) + fFrame.right = fFrame.left + fMinWidth; + if (fFrame.Height() < fMinHeight) + fFrame.bottom = fFrame.top + fMinHeight; + + if (fFeel != B_NO_BORDER_WINDOW_LOOK) { + fDecorator = gDecorManager.AllocateDecorator(frame, name, fLook, fFeel, fWindowFlags, fDriver); - if (fDecorator) + if (fDecorator) { fDecorator->GetSizeLimits(&fMinWidth, &fMinHeight, &fMaxWidth, &fMaxHeight); + + // we need to change our size to let the decorator fit + if (fMinWidth > fFrame.Width()) + fFrame.right = fFrame.left + fMinWidth; + if (fMinHeight > fFrame.Height()) + fFrame.bottom = fFrame.top + fMinHeight; + } } #ifndef NEW_CLIPPING @@ -130,7 +149,7 @@ WinBorder::WinBorder(const BRect &r, STRACE(("WinBorder %s:\n", GetName())); STRACE(("\tFrame: (%.1f, %.1f, %.1f, %.1f)\n", r.left, r.top, r.right, r.bottom)); - STRACE(("\tWindow %s\n",win ? win->Title() : "NULL")); + STRACE(("\tWindow %s\n", win ? win->Title() : "NULL")); } WinBorder::~WinBorder()