Reverse the meaning of BWindow fShowLevel to match BView.
This also matches the client_window_info.show_hide_level field used in Deskbar and other applications. While doing this, keep fShowLevel fully in sync between BWindow and app_server, use one message type for both hiding and showing, and make the decision to show and hide the window in the app_server. Lastly make minimize behave as described in the Be Book: hidden windows cannot be minimized, and minimized windows which get hidden become unminimized.
This commit is contained in:
@@ -352,6 +352,7 @@ private:
|
|||||||
|
|
||||||
void _GetDecoratorSize(float* _borderWidth,
|
void _GetDecoratorSize(float* _borderWidth,
|
||||||
float* _tabHeight) const;
|
float* _tabHeight) const;
|
||||||
|
void _SendShowOrHideMessage();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char* fTitle;
|
char* fTitle;
|
||||||
|
|||||||
@@ -87,8 +87,8 @@ enum {
|
|||||||
AS_GET_CURSOR_BITMAP,
|
AS_GET_CURSOR_BITMAP,
|
||||||
|
|
||||||
// Window definitions
|
// Window definitions
|
||||||
AS_SHOW_WINDOW,
|
AS_SHOW_OR_HIDE_WINDOW,
|
||||||
AS_HIDE_WINDOW,
|
AS_INTERNAL_HIDE_WINDOW,
|
||||||
AS_MINIMIZE_WINDOW,
|
AS_MINIMIZE_WINDOW,
|
||||||
AS_QUIT_WINDOW,
|
AS_QUIT_WINDOW,
|
||||||
AS_SEND_BEHIND,
|
AS_SEND_BEHIND,
|
||||||
|
|||||||
@@ -589,7 +589,8 @@ BWindow::ChildAt(int32 index) const
|
|||||||
void
|
void
|
||||||
BWindow::Minimize(bool minimize)
|
BWindow::Minimize(bool minimize)
|
||||||
{
|
{
|
||||||
if (IsModal() || IsFloating() || fMinimized == minimize || !Lock())
|
if (IsModal() || IsFloating() || IsHidden() || fMinimized == minimize
|
||||||
|
|| !Lock())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fMinimized = minimize;
|
fMinimized = minimize;
|
||||||
@@ -769,10 +770,7 @@ BWindow::MessageReceived(BMessage* msg)
|
|||||||
// connect all views to the server again
|
// connect all views to the server again
|
||||||
fTopView->_CreateSelf();
|
fTopView->_CreateSelf();
|
||||||
|
|
||||||
if (fShowLevel >= 1) {
|
_SendShowOrHideMessage();
|
||||||
fLink->StartMessage(AS_SHOW_WINDOW);
|
|
||||||
fLink->Flush();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return BLooper::MessageReceived(msg);
|
return BLooper::MessageReceived(msg);
|
||||||
@@ -2094,10 +2092,6 @@ BWindow::IsMinimized() const
|
|||||||
if (!locker.IsLocked())
|
if (!locker.IsLocked())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Hiding takes precendence over minimization!!!
|
|
||||||
if (IsHidden())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return fMinimized;
|
return fMinimized;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2607,13 +2601,9 @@ BWindow::Show()
|
|||||||
{
|
{
|
||||||
bool runCalled = true;
|
bool runCalled = true;
|
||||||
if (Lock()) {
|
if (Lock()) {
|
||||||
fShowLevel++;
|
fShowLevel--;
|
||||||
|
|
||||||
if (fShowLevel == 1) {
|
_SendShowOrHideMessage();
|
||||||
fLink->StartMessage(AS_SHOW_WINDOW);
|
|
||||||
fLink->Attach<int32>(fShowLevel);
|
|
||||||
fLink->Flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
runCalled = fRunCalled;
|
runCalled = fRunCalled;
|
||||||
|
|
||||||
@@ -2638,25 +2628,24 @@ BWindow::Show()
|
|||||||
void
|
void
|
||||||
BWindow::Hide()
|
BWindow::Hide()
|
||||||
{
|
{
|
||||||
if (!Lock())
|
if (Lock()) {
|
||||||
return;
|
// If we are minimized and are about to be hidden, unminimize
|
||||||
|
if (IsMinimized() && fShowLevel == 0)
|
||||||
|
Minimize(false);
|
||||||
|
|
||||||
fShowLevel--;
|
fShowLevel++;
|
||||||
|
|
||||||
if (fShowLevel == 0) {
|
_SendShowOrHideMessage();
|
||||||
fLink->StartMessage(AS_HIDE_WINDOW);
|
|
||||||
fLink->Attach<int32>(fShowLevel);
|
|
||||||
fLink->Flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
Unlock();
|
Unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BWindow::IsHidden() const
|
BWindow::IsHidden() const
|
||||||
{
|
{
|
||||||
return fShowLevel <= 0;
|
return fShowLevel > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2793,7 +2782,7 @@ BWindow::_InitData(BRect frame, const char* title, window_look look,
|
|||||||
fInTransaction = bitmapToken >= 0;
|
fInTransaction = bitmapToken >= 0;
|
||||||
fUpdateRequested = false;
|
fUpdateRequested = false;
|
||||||
fActive = false;
|
fActive = false;
|
||||||
fShowLevel = 0;
|
fShowLevel = 1;
|
||||||
|
|
||||||
fTopView = NULL;
|
fTopView = NULL;
|
||||||
fFocus = NULL;
|
fFocus = NULL;
|
||||||
@@ -4061,6 +4050,15 @@ BWindow::_GetDecoratorSize(float* _borderWidth, float* _tabHeight) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BWindow::_SendShowOrHideMessage()
|
||||||
|
{
|
||||||
|
fLink->StartMessage(AS_SHOW_OR_HIDE_WINDOW);
|
||||||
|
fLink->Attach<int32>(fShowLevel);
|
||||||
|
fLink->Flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - C++ binary compatibility kludge
|
// #pragma mark - C++ binary compatibility kludge
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -66,8 +66,8 @@ string_for_message_code(uint32 code, BString& string)
|
|||||||
CODE(AS_GET_CURSOR_BITMAP);
|
CODE(AS_GET_CURSOR_BITMAP);
|
||||||
|
|
||||||
// Window definitions
|
// Window definitions
|
||||||
CODE(AS_SHOW_WINDOW);
|
CODE(AS_SHOW_OR_HIDE_WINDOW);
|
||||||
CODE(AS_HIDE_WINDOW);
|
CODE(AS_INTERNAL_HIDE_WINDOW);
|
||||||
CODE(AS_MINIMIZE_WINDOW);
|
CODE(AS_MINIMIZE_WINDOW);
|
||||||
CODE(AS_QUIT_WINDOW);
|
CODE(AS_QUIT_WINDOW);
|
||||||
CODE(AS_SEND_BEHIND);
|
CODE(AS_SEND_BEHIND);
|
||||||
|
|||||||
@@ -315,7 +315,7 @@ ServerWindow::_PrepareQuit()
|
|||||||
_Hide();
|
_Hide();
|
||||||
fDesktop->UnlockSingleWindow();
|
fDesktop->UnlockSingleWindow();
|
||||||
} else if (fThread >= B_OK)
|
} else if (fThread >= B_OK)
|
||||||
PostMessage(AS_HIDE_WINDOW);
|
PostMessage(AS_INTERNAL_HIDE_WINDOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -481,9 +481,7 @@ ServerWindow::GetInfo(window_info& info)
|
|||||||
info.window_right = (int)floor(fWindow->Frame().right);
|
info.window_right = (int)floor(fWindow->Frame().right);
|
||||||
info.window_bottom = (int)floor(fWindow->Frame().bottom);
|
info.window_bottom = (int)floor(fWindow->Frame().bottom);
|
||||||
|
|
||||||
// This is essentially opposite of the ShowLevel, meaning a window is
|
info.show_hide_level = fWindow->ShowLevel();
|
||||||
// hidden if it is 1 or more, and shown if it is 0 or less.
|
|
||||||
info.show_hide_level = fWindow->ShowLevel() <= 0 ? 1 : 0;
|
|
||||||
info.is_mini = fWindow->IsMinimized();
|
info.is_mini = fWindow->IsMinimized();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,44 +594,32 @@ void
|
|||||||
ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case AS_SHOW_WINDOW:
|
case AS_SHOW_OR_HIDE_WINDOW:
|
||||||
{
|
{
|
||||||
DTRACE(("ServerWindow %s: Message AS_SHOW_WINDOW\n", Title()));
|
int32 showLevel;
|
||||||
|
if (link.Read<int32>(&showLevel) == B_OK) {
|
||||||
|
DTRACE(("ServerWindow %s: Message AS_SHOW_OR_HIDE_WINDOW, "
|
||||||
|
"show level: %d\n", Title(), showLevel));
|
||||||
|
|
||||||
|
fWindow->SetShowLevel(showLevel);
|
||||||
|
if (showLevel <= 0)
|
||||||
_Show();
|
_Show();
|
||||||
|
else
|
||||||
int32 showLevel;
|
|
||||||
if (link.Read<int32>(&showLevel) == B_OK) {
|
|
||||||
fWindow->SetShowLevel(showLevel);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
case AS_HIDE_WINDOW:
|
|
||||||
{
|
|
||||||
DTRACE(("ServerWindow %s: Message AS_HIDE_WINDOW\n", Title()));
|
|
||||||
_Hide();
|
_Hide();
|
||||||
|
|
||||||
int32 showLevel;
|
|
||||||
if (link.Read<int32>(&showLevel) == B_OK) {
|
|
||||||
fWindow->SetShowLevel(showLevel);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// Only for internal use within this class
|
||||||
|
case AS_INTERNAL_HIDE_WINDOW:
|
||||||
|
_Hide();
|
||||||
|
break;
|
||||||
case AS_MINIMIZE_WINDOW:
|
case AS_MINIMIZE_WINDOW:
|
||||||
{
|
{
|
||||||
bool minimize;
|
bool minimize;
|
||||||
|
|
||||||
if (link.Read<bool>(&minimize) == B_OK) {
|
if (link.Read<bool>(&minimize) == B_OK) {
|
||||||
DTRACE(("ServerWindow %s: Message AS_MINIMIZE_WINDOW, "
|
DTRACE(("ServerWindow %s: Message AS_MINIMIZE_WINDOW, "
|
||||||
"minimize: %d\n", Title(), minimize));
|
"minimize: %d\n", Title(), minimize));
|
||||||
|
|
||||||
if (fWindow->ShowLevel() <= 0) {
|
|
||||||
// Window is currently hidden - ignore the minimize
|
|
||||||
// request, but keep the state in sync.
|
|
||||||
fWindow->SetMinimized(minimize);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
fDesktop->UnlockSingleWindow();
|
fDesktop->UnlockSingleWindow();
|
||||||
fDesktop->MinimizeWindow(fWindow, minimize);
|
fDesktop->MinimizeWindow(fWindow, minimize);
|
||||||
fDesktop->LockSingleWindow();
|
fDesktop->LockSingleWindow();
|
||||||
|
|||||||
@@ -102,9 +102,10 @@ Window::Window(const BRect& frame, const char *name,
|
|||||||
fInUpdate(false),
|
fInUpdate(false),
|
||||||
fUpdatesEnabled(true),
|
fUpdatesEnabled(true),
|
||||||
|
|
||||||
// windows start hidden
|
// Windows start hidden
|
||||||
fHidden(true),
|
fHidden(true),
|
||||||
fShowLevel(0),
|
// Hidden is 1 or more
|
||||||
|
fShowLevel(1),
|
||||||
fMinimized(false),
|
fMinimized(false),
|
||||||
fIsFocus(false),
|
fIsFocus(false),
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user