diff --git a/src/DesktopPlusUI/UIManager.cpp b/src/DesktopPlusUI/UIManager.cpp index 0ab4752..c3ff6dc 100644 --- a/src/DesktopPlusUI/UIManager.cpp +++ b/src/DesktopPlusUI/UIManager.cpp @@ -582,7 +582,7 @@ void UIManager::HandleIPCMessage(const MSG& msg, bool handle_delayed) int overlay_id = (msg.lParam != -1) ? (int)msg.lParam : m_VRKeyboard.GetWindow().GetAssignedOverlayID(); //Only set auto-visibility if source overlay is desktop/window capture (avoid overriding browser auto-visible keyboards) - if (OverlayManager::Get().GetConfigData((unsigned int)overlay_id).ConfigInt[configid_int_overlay_capture_source] <= ovrl_capsource_winrt_capture) + if ( (overlay_id >= 0) && (OverlayManager::Get().GetConfigData((unsigned int)overlay_id).ConfigInt[configid_int_overlay_capture_source] <= ovrl_capsource_winrt_capture) ) { m_VRKeyboard.GetWindow().SetAutoVisibility(overlay_id, (msg.lParam != -1)); } diff --git a/src/DesktopPlusUI/VRKeyboard.cpp b/src/DesktopPlusUI/VRKeyboard.cpp index bcfd730..c55bea5 100644 --- a/src/DesktopPlusUI/VRKeyboard.cpp +++ b/src/DesktopPlusUI/VRKeyboard.cpp @@ -545,7 +545,6 @@ void VRKeyboard::OnImGuiNewFrame() if ( (!m_KeyboardHiddenLastFrame) && ( (m_InputTarget != kbdtarget_ui) || (!m_WindowKeyboard.IsVisible()) ) ) { m_InputTarget = kbdtarget_ui; - m_WindowKeyboard.Show(); bool do_assign_to_ui = false; int assigned_id = m_WindowKeyboard.GetAssignedOverlayID(); @@ -563,8 +562,10 @@ void VRKeyboard::OnImGuiNewFrame() if (do_assign_to_ui) { - m_WindowKeyboard.SetAssignedOverlayID(-2); + m_WindowKeyboard.SetAutoVisibility(-2, true); } + + m_WindowKeyboard.Show(); } } else if (m_WindowKeyboard.IsVisible()) @@ -580,10 +581,10 @@ void VRKeyboard::OnImGuiNewFrame() m_WindowKeyboard.Show(); //Show() updates window title } - //If keyboard is visible for the UI, assign to global + //If keyboard is visible for the UI, turn off auto-visibility if (assigned_id == -2) { - m_WindowKeyboard.SetAssignedOverlayID(-1); + m_WindowKeyboard.SetAutoVisibility(-2, false); } //Check if overlay target should be used @@ -627,6 +628,7 @@ void VRKeyboard::OnWindowHidden() if (io.WantTextInput) { ImGui::ClearActiveID(); + m_ActiveInputText = 0; io.WantTextInput = false; } diff --git a/src/DesktopPlusUI/WindowKeyboard.cpp b/src/DesktopPlusUI/WindowKeyboard.cpp index 92cabbe..6feb976 100644 --- a/src/DesktopPlusUI/WindowKeyboard.cpp +++ b/src/DesktopPlusUI/WindowKeyboard.cpp @@ -202,13 +202,13 @@ void WindowKeyboard::Hide(bool skip_fade) UIManager::Get()->GetVRKeyboard().OnWindowHidden(); } -bool WindowKeyboard::SetAutoVisibility(unsigned int overlay_id, bool show) +bool WindowKeyboard::SetAutoVisibility(int assigned_overlay_id, bool show) { if (show) { if (!IsVisible()) { - SetAssignedOverlayID(overlay_id); + SetAssignedOverlayID(assigned_overlay_id); m_IsAutoVisible = true; //This will not have a smooth transition if there was another auto-visible keyboard right before this, but let's skip the effort for that for now @@ -217,7 +217,7 @@ bool WindowKeyboard::SetAutoVisibility(unsigned int overlay_id, bool show) return true; } } - else if ( (m_IsAutoVisible) && (GetAssignedOverlayID() == overlay_id) ) + else if ( (m_IsAutoVisible) && (GetAssignedOverlayID() == assigned_overlay_id) ) { SetAssignedOverlayID(-1); Hide(); diff --git a/src/DesktopPlusUI/WindowKeyboard.h b/src/DesktopPlusUI/WindowKeyboard.h index 1c9dd57..875ed6a 100644 --- a/src/DesktopPlusUI/WindowKeyboard.h +++ b/src/DesktopPlusUI/WindowKeyboard.h @@ -70,7 +70,7 @@ class WindowKeyboard : public FloatingWindow virtual void Show(bool skip_fade = false); virtual void Hide(bool skip_fade = false); - bool SetAutoVisibility(unsigned int overlay_id, bool show); //Returns true on success + bool SetAutoVisibility(int assigned_overlay_id, bool show); //Returns true on success virtual vr::VROverlayHandle_t GetOverlayHandle() const; virtual void RebaseTransform(); virtual void ResetTransform(FloatingWindowOverlayStateID state_id); diff --git a/src/DesktopPlusUI/WindowSettings.cpp b/src/DesktopPlusUI/WindowSettings.cpp index 4fe8572..ac7f1b9 100644 --- a/src/DesktopPlusUI/WindowSettings.cpp +++ b/src/DesktopPlusUI/WindowSettings.cpp @@ -931,7 +931,7 @@ void WindowSettings::UpdatePageMainCatInput() //Hide currently auto-visible keyboard if it's shown for a browser overlay int overlay_id = vr_keyboard.GetWindow().GetAssignedOverlayID(); - if (OverlayManager::Get().GetConfigData((unsigned int)overlay_id).ConfigInt[configid_int_overlay_capture_source] == ovrl_capsource_browser) + if ( (overlay_id >= 0) && (OverlayManager::Get().GetConfigData((unsigned int)overlay_id).ConfigInt[configid_int_overlay_capture_source] == ovrl_capsource_browser) ) { vr_keyboard.GetWindow().SetAutoVisibility(overlay_id, false); }