* Fixed BWindow::Show()/Hide(): fShowLevel was changed and checked without
holding the window lock. * Run() is now called before creating the window in the app_server when Show() is called for the first time (which is now checked with fRunCalled instead of some thread arithmetics). * Minimize() now sends the show level of a window to the app_server, so that it can actually determine if minimizing or maximizing the window should have any effect. This fixes bug #225. * fShowLevel's meaning is now reversed; when it's above zero, it now means the window is shown (before, a level less than 1 meant shown). This definitely better fits its name :) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16536 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
f8d8085d7a
commit
9b5a183539
@ -478,6 +478,7 @@ BWindow::Minimize(bool minimize)
|
|||||||
|
|
||||||
fLink->StartMessage(AS_MINIMIZE_WINDOW);
|
fLink->StartMessage(AS_MINIMIZE_WINDOW);
|
||||||
fLink->Attach<bool>(minimize);
|
fLink->Attach<bool>(minimize);
|
||||||
|
fLink->Attach<int32>(fShowLevel);
|
||||||
fLink->Flush();
|
fLink->Flush();
|
||||||
|
|
||||||
Unlock();
|
Unlock();
|
||||||
@ -2038,25 +2039,21 @@ BWindow::ResizeTo(float width, float height)
|
|||||||
void
|
void
|
||||||
BWindow::Show()
|
BWindow::Show()
|
||||||
{
|
{
|
||||||
bool isLocked = this->IsLocked();
|
if (!fRunCalled) {
|
||||||
|
// this is the fist time Show() is called, which implicetly runs the looper
|
||||||
fShowLevel--;
|
Run();
|
||||||
|
|
||||||
if (fShowLevel == 0) {
|
|
||||||
STRACE(("BWindow(%s): sending AS_SHOW_WINDOW message...\n", Name()));
|
|
||||||
if (Lock()) {
|
|
||||||
fLink->StartMessage(AS_SHOW_WINDOW);
|
|
||||||
fLink->Flush();
|
|
||||||
Unlock();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if it's the fist time Show() is called... start the Looper thread.
|
if (Lock()) {
|
||||||
if (Thread() == B_ERROR) {
|
fShowLevel++;
|
||||||
// normally this won't happen, but I want to be sure!
|
|
||||||
if (!isLocked)
|
if (fShowLevel == 1) {
|
||||||
Lock();
|
STRACE(("BWindow(%s): sending AS_SHOW_WINDOW message...\n", Name()));
|
||||||
Run();
|
fLink->StartMessage(AS_SHOW_WINDOW);
|
||||||
|
fLink->Flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
Unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2064,19 +2061,22 @@ BWindow::Show()
|
|||||||
void
|
void
|
||||||
BWindow::Hide()
|
BWindow::Hide()
|
||||||
{
|
{
|
||||||
if (fShowLevel == 0 && Lock()) {
|
if (!Lock())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (--fShowLevel == 0) {
|
||||||
fLink->StartMessage(AS_HIDE_WINDOW);
|
fLink->StartMessage(AS_HIDE_WINDOW);
|
||||||
fLink->Flush();
|
fLink->Flush();
|
||||||
Unlock();
|
|
||||||
}
|
}
|
||||||
fShowLevel++;
|
|
||||||
|
Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BWindow::IsHidden() const
|
BWindow::IsHidden() const
|
||||||
{
|
{
|
||||||
return fShowLevel > 0;
|
return fShowLevel <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2177,7 +2177,7 @@ BWindow::_InitData(BRect frame, const char* title, window_look look,
|
|||||||
|
|
||||||
fInTransaction = false;
|
fInTransaction = false;
|
||||||
fActive = false;
|
fActive = false;
|
||||||
fShowLevel = 1;
|
fShowLevel = 0;
|
||||||
|
|
||||||
fTopView = NULL;
|
fTopView = NULL;
|
||||||
fFocus = NULL;
|
fFocus = NULL;
|
||||||
|
@ -544,9 +544,16 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
|||||||
case AS_MINIMIZE_WINDOW:
|
case AS_MINIMIZE_WINDOW:
|
||||||
{
|
{
|
||||||
DTRACE(("ServerWindow %s: Message AS_MINIMIZE_WINDOW\n", Title()));
|
DTRACE(("ServerWindow %s: Message AS_MINIMIZE_WINDOW\n", Title()));
|
||||||
|
int32 showLevel;
|
||||||
bool minimize;
|
bool minimize;
|
||||||
if (link.Read<bool>(&minimize) == B_OK) {
|
|
||||||
// TODO: this actually needs to take the window's show/hide counter into account
|
link.Read<bool>(&minimize);
|
||||||
|
if (link.Read<int32>(&showLevel) == B_OK) {
|
||||||
|
if (showLevel <= 0) {
|
||||||
|
// window is currently hidden - ignore the minimize request
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (minimize && !fWindowLayer->IsHidden())
|
if (minimize && !fWindowLayer->IsHidden())
|
||||||
_Hide();
|
_Hide();
|
||||||
else if (!minimize && fWindowLayer->IsHidden())
|
else if (!minimize && fWindowLayer->IsHidden())
|
||||||
|
Loading…
Reference in New Issue
Block a user