* 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:
Axel Dörfler 2006-02-27 16:45:58 +00:00
parent f8d8085d7a
commit 9b5a183539
2 changed files with 31 additions and 24 deletions

View File

@ -478,6 +478,7 @@ BWindow::Minimize(bool minimize)
fLink->StartMessage(AS_MINIMIZE_WINDOW);
fLink->Attach<bool>(minimize);
fLink->Attach<int32>(fShowLevel);
fLink->Flush();
Unlock();
@ -2038,25 +2039,21 @@ BWindow::ResizeTo(float width, float height)
void
BWindow::Show()
{
bool isLocked = this->IsLocked();
fShowLevel--;
if (fShowLevel == 0) {
STRACE(("BWindow(%s): sending AS_SHOW_WINDOW message...\n", Name()));
if (Lock()) {
fLink->StartMessage(AS_SHOW_WINDOW);
fLink->Flush();
Unlock();
}
if (!fRunCalled) {
// this is the fist time Show() is called, which implicetly runs the looper
Run();
}
// if it's the fist time Show() is called... start the Looper thread.
if (Thread() == B_ERROR) {
// normally this won't happen, but I want to be sure!
if (!isLocked)
Lock();
Run();
if (Lock()) {
fShowLevel++;
if (fShowLevel == 1) {
STRACE(("BWindow(%s): sending AS_SHOW_WINDOW message...\n", Name()));
fLink->StartMessage(AS_SHOW_WINDOW);
fLink->Flush();
}
Unlock();
}
}
@ -2064,19 +2061,22 @@ BWindow::Show()
void
BWindow::Hide()
{
if (fShowLevel == 0 && Lock()) {
if (!Lock())
return;
if (--fShowLevel == 0) {
fLink->StartMessage(AS_HIDE_WINDOW);
fLink->Flush();
Unlock();
}
fShowLevel++;
Unlock();
}
bool
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;
fActive = false;
fShowLevel = 1;
fShowLevel = 0;
fTopView = NULL;
fFocus = NULL;

View File

@ -544,9 +544,16 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
case AS_MINIMIZE_WINDOW:
{
DTRACE(("ServerWindow %s: Message AS_MINIMIZE_WINDOW\n", Title()));
int32 showLevel;
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())
_Hide();
else if (!minimize && fWindowLayer->IsHidden())