mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-27 23:37:05 -05:00
fix: Menu bar focus issues
This commit is contained in:
@@ -145,7 +145,6 @@ namespace hex {
|
||||
* @brief A view that draws a regular window. This should be the default for most views
|
||||
*/
|
||||
class View::Window : public View {
|
||||
ImGuiWindow *m_focusedSubWindow;
|
||||
public:
|
||||
explicit Window(UnlocalizedString unlocalizedName, const char *icon) : View(std::move(unlocalizedName), icon), m_focusedSubWindow(nullptr) {}
|
||||
|
||||
@@ -159,6 +158,12 @@ namespace hex {
|
||||
virtual bool allowScroll() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
void handleFocusRestoration();
|
||||
|
||||
private:
|
||||
ImGuiWindow *m_focusedSubWindow;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <imgui.h>
|
||||
|
||||
#include <string>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
namespace hex {
|
||||
|
||||
@@ -117,9 +118,7 @@ namespace hex {
|
||||
return s_lastFocusedView;
|
||||
}
|
||||
|
||||
|
||||
void View::Window::draw(ImGuiWindowFlags extraFlags) {
|
||||
if (this->shouldDraw()) {
|
||||
void View::Window::handleFocusRestoration() {
|
||||
const auto title = fmt::format("{} {}", this->getIcon(), View::toWindowName(this->getUnlocalizedName()));
|
||||
|
||||
const ImGuiContext& g = *ImGui::GetCurrentContext();
|
||||
@@ -155,6 +154,7 @@ namespace hex {
|
||||
|
||||
std::string focusedSubWindowName;
|
||||
if (focusedSubWindow != nullptr || m_focusedSubWindow != nullptr) {
|
||||
if (glfwGetWindowAttrib(ImHexApi::System::getMainWindowHandle(), GLFW_FOCUSED)) {
|
||||
focusedSubWindowName = focusedSubWindow != nullptr ? focusedSubWindow->Name : m_focusedSubWindow->Name;
|
||||
if (focusedSubWindow != nullptr && m_focusedSubWindow != nullptr) {
|
||||
std::string_view windowName = m_focusedSubWindow->Name;
|
||||
@@ -182,6 +182,15 @@ namespace hex {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void View::Window::draw(ImGuiWindowFlags extraFlags) {
|
||||
if (this->shouldDraw()) {
|
||||
const auto title = fmt::format("{} {}", this->getIcon(), View::toWindowName(this->getUnlocalizedName()));
|
||||
|
||||
handleFocusRestoration();
|
||||
|
||||
if (!allowScroll())
|
||||
extraFlags |= ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse;
|
||||
|
||||
@@ -420,7 +420,7 @@ namespace hex {
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0F);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
|
||||
|
||||
ImGuiWindowFlags windowFlags = ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoNavFocus | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse;
|
||||
ImGuiWindowFlags windowFlags = ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse;
|
||||
|
||||
if (!m_emergencyPopupOpen)
|
||||
windowFlags |= ImGuiWindowFlags_MenuBar;
|
||||
|
||||
@@ -495,15 +495,10 @@ namespace hex::plugin::builtin {
|
||||
ON_SCOPE_EXIT { ImGui::PopStyleVar(); };
|
||||
#endif
|
||||
|
||||
if (ImGui::BeginMainMenuBar()) {
|
||||
drawTitleBarBackDrop();
|
||||
ImGui::Dummy({});
|
||||
ImGui::EndMainMenuBar();
|
||||
}
|
||||
|
||||
auto window = ImHexApi::System::getMainWindowHandle();
|
||||
menu::enableNativeMenuBar(s_useNativeMenuBar);
|
||||
if (menu::beginMainMenuBar()) {
|
||||
drawTitleBarBackDrop();
|
||||
if (ImHexApi::System::isBorderlessWindowModeEnabled()) {
|
||||
#if defined(OS_WINDOWS)
|
||||
ImGui::SetCursorPosX(5_scaled);
|
||||
@@ -637,7 +632,7 @@ namespace hex::plugin::builtin {
|
||||
s_logoTexture = ImGuiExt::Texture::fromImage(romfs::get("assets/common/icon.png").span(), ImGuiExt::Texture::Filter::Linear);
|
||||
};
|
||||
|
||||
constexpr static ImGuiWindowFlags windowFlags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoNavFocus | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse;
|
||||
constexpr static ImGuiWindowFlags windowFlags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse;
|
||||
|
||||
ImGuiViewport *viewport = ImGui::GetMainViewport();
|
||||
ImGui::SetNextWindowPos(viewport->WorkPos);
|
||||
|
||||
Reference in New Issue
Block a user