From cad57f1e23c459ad2b5fc60eb89bbefa3d6445e2 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Sat, 8 Mar 2014 14:08:56 +0100 Subject: [PATCH] FIRE-10908: CTRL-W closes multifloater instead of active child floater --- indra/llui/llmultifloater.cpp | 56 ++++++++++++++++++++++++++++++ indra/llui/llmultifloater.h | 6 ++++ indra/newview/llviewermenufile.cpp | 38 -------------------- 3 files changed, 62 insertions(+), 38 deletions(-) diff --git a/indra/llui/llmultifloater.cpp b/indra/llui/llmultifloater.cpp index 92f256b64b..83d27cf445 100755 --- a/indra/llui/llmultifloater.cpp +++ b/indra/llui/llmultifloater.cpp @@ -387,6 +387,7 @@ void LLMultiFloater::setVisible(BOOL visible) BOOL LLMultiFloater::handleKeyHere(KEY key, MASK mask) { + // This won't work - CTRL-W is intercepted by LLFileCloseWindow! if (key == 'W' && mask == MASK_CONTROL) { LLFloater* floater = getActiveFloater(); @@ -576,3 +577,58 @@ void LLMultiFloater::computeResizeLimits(S32& new_min_width, S32& new_min_height } } } + +// CTRL-W doesn't work with multifloaters +void LLMultiFloater::closeFloater(bool app_quitting) +{ + if (app_quitting) + { + LLFloater::closeFloater(app_quitting); + return; + } + + LLFloater* floater = getActiveFloater(); + // is user closeable and is system closeable + if (floater && floater->canClose() && floater->isCloseable()) + { + floater->closeFloater(); + + // EXT-5695 (Tabbed IM window loses focus if close any tabs by Ctrl+W) + // bring back focus on tab container if there are any tab left + if(mTabContainer->getTabCount() > 0) + { + mTabContainer->setFocus(TRUE); + } + else + { + // Call closeFloater() here so that focus gets properly handed over + LLFloater::closeFloater(); + } + + return; + } + + // Close multifloater itself if we can't close any hosted floaters + LLFloater::closeFloater(); +} + +void LLMultiFloater::onClickCloseBtn(bool app_quitting) +{ + LLFloater::closeFloater(false); +} + +// Ansa: Will be called when toggling view - in that case we want to +// toggle the whole floater instead of the active hosted floater +void LLMultiFloater::closeHostedFloater() +{ + // When toggling *visibility*, close the host instead of the floater when hosted + if (getHost()) + { + getHost()->closeFloater(); + } + else + { + LLFloater::closeFloater(false); + } +} +// diff --git a/indra/llui/llmultifloater.h b/indra/llui/llmultifloater.h index 44ef765f2c..f7d59a53cf 100755 --- a/indra/llui/llmultifloater.h +++ b/indra/llui/llmultifloater.h @@ -79,6 +79,12 @@ public: virtual void updateResizeLimits(); virtual void updateFloaterTitle(LLFloater* floaterp); + // CTRL-W doesn't work with multifloaters + /*virtual*/ void closeFloater(bool app_quitting = false); + /*virtual*/ void onClickCloseBtn(bool app_quitting = false); + /*virtual*/ void closeHostedFloater(); + // + protected: struct LLFloaterData { diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 938c9a5d87..443eeae1ff 100755 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -675,44 +675,6 @@ class LLFileCloseWindow : public view_listener_t { bool handleEvent(const LLSD& userdata) { - // If the IM container is focused, try to close the selected tab instead of the container -KC - // [FS communication UI] - //LLIMFloaterContainer* im_container = LLIMFloaterContainer::getInstance(); - FSFloaterIMContainer* im_container = FSFloaterIMContainer::getInstance(); - // [FS communication UI] - if (im_container && im_container->hasFocus()) - { - LLFloater* floater = im_container->getActiveFloater(); - // is user closeable and is system closeable - if (floater && floater->canClose()) - { - if (floater->isCloseable()) - { - floater->closeFloater(); - // and return focus back to the container - im_container->setFocus(TRUE); - } - else - { - // close the im container if selected tab is not closable (ie. contacts or nerby chat) -KC - im_container->closeFloater(); - - // if nothing took focus after closing focused floater - // give it to next floater (to allow closing multiple windows via keyboard in rapid succession) - if (gFocusMgr.getKeyboardFocus() == NULL) - { - // HACK: use gFloaterView directly in case we are using Ctrl-W to close snapshot window - // which sits in gSnapshotFloaterView, and needs to pass focus on to normal floater view - gFloaterView->focusFrontFloater(); - } - } - - - - return true; - } - } - LLFloater::closeFrontmostFloater(); return true; }