From 1de8306c830611d22e9d684ad1372e6f506f21af Mon Sep 17 00:00:00 2001
From: Andrey Kleshchev <andreykproductengine@lindenlab.com>
Date: Thu, 11 Aug 2022 23:03:14 +0300
Subject: SL-17965 Closing some floaters shifts focus to menu bar

Focus root now only covers menu, status and nav bar to not steal focus from floaters
This partially reverts commit 1d6bfb727a8015e82cd4060a0c73cf3fc719e818.
---
 indra/newview/llpanelpresetscamerapulldown.cpp   |  5 +++-
 indra/newview/llpanelpresetspulldown.cpp         |  3 +++
 indra/newview/llpanelpulldown.cpp                |  2 ++
 indra/newview/llviewerwindow.cpp                 | 15 +++++++----
 indra/newview/skins/default/xui/en/main_view.xml | 33 ++++++++++--------------
 5 files changed, 32 insertions(+), 26 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llpanelpresetscamerapulldown.cpp b/indra/newview/llpanelpresetscamerapulldown.cpp
index 183123e534..4c9c30160c 100644
--- a/indra/newview/llpanelpresetscamerapulldown.cpp
+++ b/indra/newview/llpanelpresetscamerapulldown.cpp
@@ -127,7 +127,10 @@ void LLPanelPresetsCameraPulldown::onRowClick(const LLSD& user_data)
             LL_DEBUGS() << "selected '" << name << "'" << LL_ENDL;
 			LLFloaterCamera::switchToPreset(name);
 
-			setVisible(FALSE);
+            // Scroll grabbed focus, drop it to prevent selection of parent menu
+            setFocus(FALSE);
+
+            setVisible(FALSE);
 		}
         else
         {
diff --git a/indra/newview/llpanelpresetspulldown.cpp b/indra/newview/llpanelpresetspulldown.cpp
index d52ad8056f..23e4fa8887 100644
--- a/indra/newview/llpanelpresetspulldown.cpp
+++ b/indra/newview/llpanelpresetspulldown.cpp
@@ -122,6 +122,9 @@ void LLPanelPresetsPulldown::onRowClick(const LLSD& user_data)
             LL_DEBUGS() << "selected '" << name << "'" << LL_ENDL;
 			LLPresetsManager::getInstance()->loadPreset(PRESETS_GRAPHIC, name);
 
+            // Scroll grabbed focus, drop it to prevent selection of parent menu
+            setFocus(FALSE);
+
 			setVisible(FALSE);
 		}
         else
diff --git a/indra/newview/llpanelpulldown.cpp b/indra/newview/llpanelpulldown.cpp
index 4de6ee8182..075278f44c 100644
--- a/indra/newview/llpanelpulldown.cpp
+++ b/indra/newview/llpanelpulldown.cpp
@@ -51,6 +51,7 @@ void LLPanelPulldown::onMouseEnter(S32 x, S32 y, MASK mask)
 /*virtual*/
 void LLPanelPulldown::onTopLost()
 {
+    setFocus(FALSE); // drop focus to prevent transfer to parent
     setVisible(FALSE);
 }
 
@@ -113,6 +114,7 @@ void LLPanelPulldown::draw()
 
     if (alpha == 0.f)
     {
+        setFocus(FALSE); // drop focus to prevent transfer to parent
         setVisible(FALSE);
     }
 }
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index cf243f085f..ebbc9c0681 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -2224,26 +2224,31 @@ void LLViewerWindow::initWorldUI()
 	// Force gFloaterTools to initialize
 	LLFloaterReg::getInstance("build");
 
-
 	// Status bar
 	LLPanel* status_bar_container = getRootView()->getChild<LLPanel>("status_bar_container");
 	gStatusBar = new LLStatusBar(status_bar_container->getLocalRect());
-	gStatusBar->setFollowsAll();
+	gStatusBar->setFollows(FOLLOWS_LEFT | FOLLOWS_TOP | FOLLOWS_RIGHT);
 	gStatusBar->setShape(status_bar_container->getLocalRect());
 	// sync bg color with menu bar
 	gStatusBar->setBackgroundColor( gMenuBarView->getBackgroundColor().get() );
     // add InBack so that gStatusBar won't be drawn over menu
-	status_bar_container->addChildInBack(gStatusBar);
-	status_bar_container->setVisible(TRUE);
+    status_bar_container->addChildInBack(gStatusBar, 2/*tab order, after menu*/);
+    status_bar_container->setVisible(TRUE);
 
 	// Navigation bar
-	LLPanel* nav_bar_container = getRootView()->getChild<LLPanel>("nav_bar_container");
+	LLView* nav_bar_container = getRootView()->getChild<LLView>("nav_bar_container");
 
 	LLNavigationBar* navbar = LLNavigationBar::getInstance();
 	navbar->setShape(nav_bar_container->getLocalRect());
 	navbar->setBackgroundColor(gMenuBarView->getBackgroundColor().get());
 	nav_bar_container->addChild(navbar);
 	nav_bar_container->setVisible(TRUE);
+
+    // Navigation bar is outside visible area, expand status_bar_container to show it
+    S32 new_height = nav_bar_container->getRect().getHeight() + status_bar_container->getRect().getHeight();
+    S32 new_width = status_bar_container->getRect().getWidth();
+    status_bar_container->reshape(new_width, new_height, TRUE);
+
 	
 	if (!gSavedSettings.getBOOL("ShowNavbarNavigationPanel"))
 	{
diff --git a/indra/newview/skins/default/xui/en/main_view.xml b/indra/newview/skins/default/xui/en/main_view.xml
index 842184de88..bab37c6258 100644
--- a/indra/newview/skins/default/xui/en/main_view.xml
+++ b/indra/newview/skins/default/xui/en/main_view.xml
@@ -8,16 +8,6 @@
  tab_stop="false" 
  name="main_view"
  width="1024">
-
-  <!-- At the moment layout_stack is not an LLUICtrl,
-  but Tab requires focus_root to function and focus_root
-  functionality is implemented in LLUICtrl -->
-  <panel follows="all"
-         height="768"
-         name="menu_tab_wrapper"
-         mouse_opaque="false"
-         focus_root="true"
-         top="0">
   <layout_stack border_size="0"
                 follows="all"
                 mouse_opaque="false"
@@ -25,31 +15,35 @@
                 name="menu_stack"
                 orientation="vertical"
                 top="0">
+    <!-- Menu, nav bar and status bar need common focus_root-->
     <layout_panel mouse_opaque="true"
               follows="left|right|top"
               name="status_bar_container"
+              focus_root="true"
               height="19"
               left="0"
               top="0"
               width="1024"
               auto_resize="false"
-              default_tab_group="1"
               visible="true">
       <view mouse_opaque="false"
-            follows="all"
+            follows="top|left|right"
             name="menu_bar_holder"
+            tab_group="1"
             left="0"
             top="0"
             width="1024"
-            tab_group="1"
             height="19"/>
+      <view mouse_opaque="false"
+            follows="top|left|right"
+            name="nav_bar_container"
+            tab_group="3"
+            left="0"
+            top="19"
+            width="1024"
+            height="34"
+            visible="false"/>
     </layout_panel>
-    <layout_panel auto_resize="false"
-                  height="34"
-                  mouse_opaque="false"
-                  name="nav_bar_container"
-                  width="1024"
-                  visible="false"/>
     <layout_panel auto_resize="true"  
                   follows="all"
                   height="500"
@@ -109,7 +103,6 @@
              tab_stop="false"/>
     </layout_panel>
   </layout_stack>
-  </panel> <!--menu_tab_wrapper-->
  
   <panel top="0"
         follows="all"
-- 
cgit v1.2.3