From 3aa0c906ba47095bf95f2ed822a2ae9939ba1c7b Mon Sep 17 00:00:00 2001 From: haydentech Date: Wed, 25 Jun 2003 20:50:42 +0000 Subject: [PATCH] Fixed a crasher in setFocus() and some dead code in ResizeTo() git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3666 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Window.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp index bdadd8fc34..dc2587518d 100644 --- a/src/kits/interface/Window.cpp +++ b/src/kits/interface/Window.cpp @@ -53,7 +53,7 @@ #include // Local Includes -------------------------------------------------------------- -#include "WindowAux.h" +#include #include #include "MessageUtils.h" @@ -1769,11 +1769,11 @@ void BWindow::ResizeBy(float dx, float dy){ void BWindow::ResizeTo(float width, float height){ // stay in minimum & maximum frame limits - width < fMinWindWidth ? fMinWindWidth : width; - width > fMaxWindWidth ? fMaxWindWidth : width; + width = (width < fMinWindWidth) ? fMinWindWidth : width; + width = (width > fMaxWindWidth) ? fMaxWindWidth : width; - height < fMinWindHeight ? fMinWindHeight : height; - height > fMaxWindHeight ? fMaxWindHeight : height; + height = (height < fMinWindHeight) ? fMinWindHeight : height; + height = (height > fMaxWindHeight) ? fMaxWindHeight : height; serverLink->SetOpCode( AS_WINDOW_RESIZE ); serverLink->Attach( width ); @@ -2418,12 +2418,20 @@ void BWindow::detachView(BView *aView){ //------------------------------------------------------------------------------ void BWindow::setFocus(BView *focusView, bool notifyInputServer){ + BView* previousFocus = fFocus; + + if (previousFocus == focusView) + return; fFocus = NULL; - fFocus->Draw( fFocus->Bounds() ); + + if (previousFocus != NULL) + previousFocus->Invalidate(); fFocus = focusView; - fFocus->Draw( fFocus->Bounds() ); + + if (focusView != NULL) + focusView->Invalidate(); // TODO: find out why do we have to notify input server. if (notifyInputServer){