From a24a5156f9fc4c841e23dbb02f13cd23434d8858 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Mon, 18 Jun 2007 13:15:58 +0000 Subject: [PATCH] splitted SetActiveState() into 2 methods, since it was very messy git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21454 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/game/WindowScreen.h | 4 +- src/kits/game/WindowScreen.cpp | 87 ++++++++++++++++++---------------- 2 files changed, 49 insertions(+), 42 deletions(-) diff --git a/headers/os/game/WindowScreen.h b/headers/os/game/WindowScreen.h index 892f87e631..867a330f24 100644 --- a/headers/os/game/WindowScreen.h +++ b/headers/os/game/WindowScreen.h @@ -80,7 +80,9 @@ class BWindowScreen : public BWindow { status_t _InitData(uint32 space, uint32 attributes); void _DisposeData(); - status_t _SetActiveState(int32 state); + status_t _Activate(); + status_t _Deactivate(); + status_t _SetupAccelerantHooks(bool enable); status_t _GetCardInfo(); void _Suspend(); diff --git a/src/kits/game/WindowScreen.cpp b/src/kits/game/WindowScreen.cpp index fbad0f0475..0bcd7d7f29 100644 --- a/src/kits/game/WindowScreen.cpp +++ b/src/kits/game/WindowScreen.cpp @@ -341,7 +341,7 @@ BWindowScreen::Disconnect() if (fLockState == 1) { if (fDebugState) fDebugFirst = true; - _SetActiveState(0); + _Deactivate(); } be_app->ShowCursor(); @@ -354,7 +354,7 @@ BWindowScreen::WindowActivated(bool active) CALLED(); fWindowState = active; if (active && fLockState == 0 && fWorkState) - _SetActiveState(1); + _Activate(); } @@ -365,14 +365,14 @@ BWindowScreen::WorkspaceActivated(int32 ws, bool state) fWorkState = state; if (state) { if (fLockState == 0 && fWindowState) { - _SetActiveState(1); + _Activate(); if (!IsHidden()) { Activate(true); WindowActivated(true); } } } else if (fLockState) - _SetActiveState(0); + _Deactivate(); } @@ -763,51 +763,56 @@ BWindowScreen::_DisposeData() } + status_t -BWindowScreen::_SetActiveState(int32 state) +BWindowScreen::_Activate() { - CALLED(); - status_t status = B_ERROR; - if (state == 1) { - status = _AssertDisplayMode(fDisplayMode); - if (status == B_OK && (status = _SetupAccelerantHooks(true)) == B_OK) { - if (!fActivateState) { - do { - status = acquire_sem(fActivateSem); - } while (status == B_INTERRUPTED); + status_t status = _AssertDisplayMode(fDisplayMode); + if (status < B_OK) + return status; - if (status < B_OK) - return status; - } + status = _SetupAccelerantHooks(true); + if (status < B_OK) + return status; + + if (!fActivateState) { + do { + status = acquire_sem(fActivateSem); + } while (status == B_INTERRUPTED); - SetColorList(fPalette); - if (fDebugState && !fDebugFirst) { - SuspensionHook(true); - _Resume(); - } else { - fDebugFirst = true; - ScreenConnected(true); - } + if (status < B_OK) + return status; + } - if (status == B_OK) - return status; - } else - _SetupAccelerantHooks(false); + SetColorList(fPalette); + if (fDebugState && !fDebugFirst) { + SuspensionHook(true); + _Resume(); } else { - _AssertDisplayMode(fOriginalDisplayMode); + fDebugFirst = true; + ScreenConnected(true); + } - if (fDebugState && !fDebugFirst) { - _Suspend(); - SuspensionHook(false); - } else - ScreenConnected(false); + return B_OK; +} - status = _SetupAccelerantHooks(false); - if (status == B_OK) { - be_app->ShowCursor(); - if (fActivateState) { - // TODO: Set palette - } + +status_t +BWindowScreen::_Deactivate() +{ + _AssertDisplayMode(fOriginalDisplayMode); + + if (fDebugState && !fDebugFirst) { + _Suspend(); + SuspensionHook(false); + } else + ScreenConnected(false); + + status_t status = _SetupAccelerantHooks(false); + if (status == B_OK) { + be_app->ShowCursor(); + if (fActivateState) { + // TODO: reset palette } }