From 70af7b97a550327b3eb67b5cfa32aecf1b10f6cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Thu, 20 May 2010 12:10:44 +0000 Subject: [PATCH] Patch by romain: Fix one particular problem where the terminal buffer area could go out of sync when switching between tabs. Closes #5969, thanks a lot! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36875 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/terminal/TermView.cpp | 9 ++++++ src/apps/terminal/TermWindow.cpp | 51 ++++++++++++++++---------------- 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/src/apps/terminal/TermView.cpp b/src/apps/terminal/TermView.cpp index 7ac083b271..c80ce2d0c7 100644 --- a/src/apps/terminal/TermView.cpp +++ b/src/apps/terminal/TermView.cpp @@ -208,6 +208,8 @@ TermView::TermView(int rows, int columns, int32 argc, const char** argv, if (status != B_OK) throw status; + ResizeToPreferred(); + // TODO: Don't show the dragger, since replicant capabilities // don't work very well ATM. /* @@ -1026,6 +1028,13 @@ TermView::AttachedToWindow() { fMouseButtons = 0; + // update the terminal size because it may have changed while the TermView + // was detached from the window. On such conditions FrameResized was not + // called when the resize occured + int rows; + int columns; + GetTermSizeFromRect(Bounds(), &rows, &columns); + SetTermSize(rows, columns); MakeFocus(true); if (fScrollBar) { fScrollBar->SetSteps(fFontHeight, fFontHeight * fRows); diff --git a/src/apps/terminal/TermWindow.cpp b/src/apps/terminal/TermWindow.cpp index 7911d3e9b1..9033938ea5 100644 --- a/src/apps/terminal/TermWindow.cpp +++ b/src/apps/terminal/TermWindow.cpp @@ -805,6 +805,32 @@ TermWindow::_AddTab(Arguments *args) session->windowTitle = fInitialTitle; fSessions.AddItem(session); + int width, height; + view->GetFontSize(&width, &height); + + float minimumHeight = -1; + if (fMenubar) + minimumHeight += fMenubar->Bounds().Height() + 1; + if (fTabView && fTabView->CountTabs() > 0) + minimumHeight += fTabView->TabHeight() + 1; + SetSizeLimits(MIN_COLS * width - 1, MAX_COLS * width - 1, + minimumHeight + MIN_ROWS * height - 1, + minimumHeight + MAX_ROWS * height - 1); + // TODO: The size limit computation is apparently broken, since + // the terminal can be resized smaller than MIN_ROWS/MIN_COLS! + + // If it's the first time we're called, setup the window + if (fTabView->CountTabs() == 0) { + float viewWidth, viewHeight; + containerView->GetPreferredSize(&viewWidth, &viewHeight); + + // Resize Window + ResizeTo(viewWidth + B_V_SCROLL_BAR_WIDTH, + viewHeight + fMenubar->Bounds().Height() + 1); + // NOTE: Width is one pixel too small, since the scroll view + // is one pixel wider than its parent. + } + BTab *tab = new BTab; fTabView->AddTab(scrollView, tab); tab->SetLabel(session->name.String()); @@ -822,31 +848,6 @@ TermWindow::_AddTab(Arguments *args) _SetTermColors(containerView); - int width, height; - view->GetFontSize(&width, &height); - - float minimumHeight = -1; - if (fMenubar) - minimumHeight += fMenubar->Bounds().Height() + 1; - if (fTabView && fTabView->CountTabs() > 1) - minimumHeight += fTabView->TabHeight() + 1; - SetSizeLimits(MIN_COLS * width - 1, MAX_COLS * width - 1, - minimumHeight + MIN_ROWS * height - 1, - minimumHeight + MAX_ROWS * height - 1); - // TODO: The size limit computation is apparently broken, since - // the terminal can be resized smaller than MIN_ROWS/MIN_COLS! - - // If it's the first time we're called, setup the window - if (fTabView->CountTabs() == 1) { - float viewWidth, viewHeight; - containerView->GetPreferredSize(&viewWidth, &viewHeight); - - // Resize Window - ResizeTo(viewWidth + B_V_SCROLL_BAR_WIDTH, - viewHeight + fMenubar->Bounds().Height() + 1); - // NOTE: Width is one pixel too small, since the scroll view - // is one pixel wider than its parent. - } // TODO: No fTabView->Select(tab); ? fTabView->Select(fTabView->CountTabs() - 1); } catch (...) {