diff options
Diffstat (limited to 'indra/newview/llimfloater.cpp')
-rw-r--r-- | indra/newview/llimfloater.cpp | 159 |
1 files changed, 126 insertions, 33 deletions
diff --git a/indra/newview/llimfloater.cpp b/indra/newview/llimfloater.cpp index e06e0c94ec..19dbc564d1 100644 --- a/indra/newview/llimfloater.cpp +++ b/indra/newview/llimfloater.cpp @@ -44,6 +44,7 @@ #include "llchiclet.h" #include "llfloaterreg.h" #include "llimfloatercontainer.h" // to replace separate IM Floaters with multifloater container +#include "llinventoryfunctions.h" #include "lllayoutstack.h" #include "lllineeditor.h" #include "lllogchat.h" @@ -110,6 +111,10 @@ LLIMFloater::LLIMFloater(const LLUUID& session_id) } } setOverlapsScreenChannel(true); + + LLTransientFloaterMgr::getInstance()->addControlView(LLTransientFloaterMgr::IM, this); + + setDocked(true); } void LLIMFloater::onFocusLost() @@ -123,13 +128,12 @@ void LLIMFloater::onFocusReceived() { LLIMModel::getInstance()->setActiveSessionID(mSessionID); - // return focus to the input field when active tab in the multitab container is clicked. - if (isChatMultiTab() && mInputEditor) + LLBottomTray::getInstance()->getChicletPanel()->setChicletToggleState(mSessionID, true); + + if (getVisible()) { - mInputEditor->setFocus(TRUE); + LLIMModel::instance().sendNoUnreadMessages(mSessionID); } - - LLBottomTray::getInstance()->getChicletPanel()->setChicletToggleState(mSessionID, true); } // virtual @@ -228,6 +232,7 @@ void LLIMFloater::sendMsg() LLIMFloater::~LLIMFloater() { + LLTransientFloaterMgr::getInstance()->removeControlView(LLTransientFloaterMgr::IM, this); } //virtual @@ -268,6 +273,7 @@ BOOL LLIMFloater::postBuild() mInputEditor->setCommitOnFocusLost( FALSE ); mInputEditor->setRevertOnEsc( FALSE ); mInputEditor->setReplaceNewlinesWithSpaces( FALSE ); + mInputEditor->setPassDelete( TRUE ); std::string session_name(LLIMModel::instance().getName(mSessionID)); @@ -404,12 +410,7 @@ LLIMFloater* LLIMFloater::show(const LLUUID& session_id) } } - if (floater_container) - { - //selecting the panel resets a chiclet's counter - floater_container->selectFloater(floater); - floater_container->setVisible(TRUE); - } + floater->openFloater(floater->getKey()); } else { @@ -443,7 +444,7 @@ LLIMFloater* LLIMFloater::show(const LLUUID& session_id) void LLIMFloater::getAllowedRect(LLRect& rect) { - rect = gViewerWindow->getWorldViewRectRaw(); + rect = gViewerWindow->getWorldViewRectScaled(); static S32 right_padding = 0; if (right_padding == 0) { @@ -459,7 +460,7 @@ void LLIMFloater::getAllowedRect(LLRect& rect) void LLIMFloater::setDocked(bool docked, bool pop_on_undock) { // update notification channel state - LLNotificationsUI::LLScreenChannel* channel = dynamic_cast<LLNotificationsUI::LLScreenChannel*> + LLNotificationsUI::LLScreenChannel* channel = static_cast<LLNotificationsUI::LLScreenChannel*> (LLNotificationsUI::LLChannelManager::getInstance()-> findChannelByID(LLUUID(gSavedSettings.getString("NotificationChannelUUID")))); @@ -478,7 +479,7 @@ void LLIMFloater::setDocked(bool docked, bool pop_on_undock) void LLIMFloater::setVisible(BOOL visible) { - LLNotificationsUI::LLScreenChannel* channel = dynamic_cast<LLNotificationsUI::LLScreenChannel*> + LLNotificationsUI::LLScreenChannel* channel = static_cast<LLNotificationsUI::LLScreenChannel*> (LLNotificationsUI::LLChannelManager::getInstance()-> findChannelByID(LLUUID(gSavedSettings.getString("NotificationChannelUUID")))); LLTransientDockableFloater::setVisible(visible); @@ -490,11 +491,19 @@ void LLIMFloater::setVisible(BOOL visible) channel->redrawToasts(); } - if (visible && mChatHistory && mInputEditor) + BOOL is_minimized = visible && isChatMultiTab() + ? LLIMFloaterContainer::getInstance()->isMinimized() + : !visible; + + if (!is_minimized && mChatHistory && mInputEditor) { //only if floater was construced and initialized from xml updateMessages(); - mInputEditor->setFocus(TRUE); + //prevent stealing focus when opening a background IM tab (EXT-5387, checking focus for EXT-6781) + if (!isChatMultiTab() || hasFocus()) + { + mInputEditor->setFocus(TRUE); + } } if(!visible) @@ -507,20 +516,44 @@ void LLIMFloater::setVisible(BOOL visible) } } +BOOL LLIMFloater::getVisible() +{ + if(isChatMultiTab()) + { + LLIMFloaterContainer* im_container = LLIMFloaterContainer::getInstance(); + + // Treat inactive floater as invisible. + bool is_active = im_container->getActiveFloater() == this; + + //torn off floater is always inactive + if (!is_active && getHost() != im_container) + { + return LLTransientDockableFloater::getVisible(); + } + + // getVisible() returns TRUE when Tabbed IM window is minimized. + return is_active && !im_container->isMinimized() && im_container->getVisible(); + } + else + { + return LLTransientDockableFloater::getVisible(); + } +} + //static bool LLIMFloater::toggle(const LLUUID& session_id) { if(!isChatMultiTab()) { LLIMFloater* floater = LLFloaterReg::findTypedInstance<LLIMFloater>("impanel", session_id); - if (floater && floater->getVisible()) + if (floater && floater->getVisible() && floater->hasFocus()) { // clicking on chiclet to close floater just hides it to maintain existing // scroll/text entry state floater->setVisible(false); return false; } - else if(floater && !floater->isDocked()) + else if(floater && (!floater->isDocked() || floater->getVisible() && !floater->hasFocus())) { floater->setVisible(TRUE); floater->setFocus(TRUE); @@ -555,6 +588,12 @@ void LLIMFloater::sessionInitReplyReceived(const LLUUID& im_session_id) setKey(im_session_id); mControlPanel->setSessionId(im_session_id); } + + // updating "Call" button from group control panel here to enable it without placing into draw() (EXT-4796) + if(gAgent.isInGroup(im_session_id)) + { + mControlPanel->updateCallButton(); + } //*TODO here we should remove "starting session..." warning message if we added it in postBuild() (IB) @@ -576,12 +615,24 @@ void LLIMFloater::updateMessages() bool use_plain_text_chat_history = gSavedSettings.getBOOL("PlainTextChatHistory"); std::list<LLSD> messages; - LLIMModel::instance().getMessages(mSessionID, messages, mLastMessageIndex+1); + + // we shouldn't reset unread message counters if IM floater doesn't have focus + if (hasFocus()) + { + LLIMModel::instance().getMessages(mSessionID, messages, mLastMessageIndex+1); + } + else + { + LLIMModel::instance().getMessagesSilently(mSessionID, messages, mLastMessageIndex+1); + } if (messages.size()) { // LLUIColor chat_color = LLUIColorTable::instance().getColor("IMChatColor"); + LLSD chat_args; + chat_args["use_plain_text_chat_history"] = use_plain_text_chat_history; + std::ostringstream message; std::list<LLSD>::const_reverse_iterator iter = messages.rbegin(); std::list<LLSD>::const_reverse_iterator iter_end = messages.rend(); @@ -593,19 +644,70 @@ void LLIMFloater::updateMessages() LLUUID from_id = msg["from_id"].asUUID(); std::string from = msg["from"].asString(); std::string message = msg["message"].asString(); + bool is_history = msg["is_history"].asBoolean(); LLChat chat; chat.mFromID = from_id; + chat.mSessionID = mSessionID; chat.mFromName = from; - chat.mText = message; chat.mTimeStr = time; + chat.mChatStyle = is_history ? CHAT_STYLE_HISTORY : chat.mChatStyle; + + // process offer notification + if (msg.has("notification_id")) + { + chat.mNotifId = msg["notification_id"].asUUID(); + // if notification exists - embed it + if (LLNotificationsUtil::find(chat.mNotifId) != NULL) + { + // remove embedded notification from channel + LLNotificationsUI::LLScreenChannel* channel = static_cast<LLNotificationsUI::LLScreenChannel*> + (LLNotificationsUI::LLChannelManager::getInstance()-> + findChannelByID(LLUUID(gSavedSettings.getString("NotificationChannelUUID")))); + if (getVisible()) + { + // toast will be automatically closed since it is not storable toast + channel->hideToast(chat.mNotifId); + } + } + // if notification doesn't exist - try to use next message which should be log entry + else + { + continue; + } + } + //process text message + else + { + chat.mText = message; + } - mChatHistory->appendMessage(chat, use_plain_text_chat_history); + mChatHistory->appendMessage(chat, chat_args); mLastMessageIndex = msg["index"].asInteger(); + + // if it is a notification - next message is a notification history log, so skip it + if (chat.mNotifId.notNull() && LLNotificationsUtil::find(chat.mNotifId) != NULL) + { + if (++iter == iter_end) + { + break; + } + else + { + mLastMessageIndex++; + } + } } } } +void LLIMFloater::reloadMessages() +{ + mChatHistory->clear(); + mLastMessageIndex = -1; + updateMessages(); +} + // static void LLIMFloater::onInputEditorFocusReceived( LLFocusableElement* caller, void* userdata ) { @@ -620,15 +722,6 @@ void LLIMFloater::onInputEditorFocusReceived( LLFocusableElement* caller, void* //in disconnected state IM input editor should be disabled self->mInputEditor->setEnabled(!gDisconnected); } - - // when IM Floater is a part of the multitab container LLTabContainer set focus to the first - // child on tab button's mouse up. This leads input field lost focus. See EXT-3852. - if (isChatMultiTab()) - { - // So, clear control captured mouse to prevent LLTabContainer set focus on the panel's first child. - // do not pass self->mInputEditor, this leads to have "Edit Text" mouse pointer wherever it is. - gFocusMgr.setMouseCapture(NULL); - } } // static @@ -830,7 +923,7 @@ BOOL LLIMFloater::dropCallingCard(LLInventoryItem* item, BOOL drop) { if(drop) { - std::vector<LLUUID> ids; + uuid_vec_t ids; ids.push_back(item->getCreatorUUID()); inviteToSession(ids); } @@ -863,7 +956,7 @@ BOOL LLIMFloater::dropCategory(LLInventoryCategory* category, BOOL drop) } else if(drop) { - std::vector<LLUUID> ids; + uuid_vec_t ids; ids.reserve(count); for(S32 i = 0; i < count; ++i) { @@ -900,7 +993,7 @@ private: LLUUID mSessionID; }; -BOOL LLIMFloater::inviteToSession(const std::vector<LLUUID>& ids) +BOOL LLIMFloater::inviteToSession(const uuid_vec_t& ids) { LLViewerRegion* region = gAgent.getRegion(); if (!region) |