diff --git a/src/shell/contextmenu/menu_render.cc b/src/shell/contextmenu/menu_render.cc index 0a108cc..b85418f 100644 --- a/src/shell/contextmenu/menu_render.cc +++ b/src/shell/contextmenu/menu_render.cc @@ -87,7 +87,9 @@ menu_render menu_render::create(int x, int y, menu menu, bool run_js) { glfwMakeContextCurrent(rt->window); glfwSwapInterval(config::current->context_menu.vsync ? 1 : 0); + glfwSetWindowAttrib(rt->window, GLFW_MOUSE_PASSTHROUGH, GLFW_FALSE); rt->show(); + SetCapture((HWND)rt->hwnd()); auto menu_wid = std::make_shared( menu, // convert the x and y to the window coordinates diff --git a/src/shell/contextmenu/menu_widget.cc b/src/shell/contextmenu/menu_widget.cc index c444bc1..fe23eea 100644 --- a/src/shell/contextmenu/menu_widget.cc +++ b/src/shell/contextmenu/menu_widget.cc @@ -730,6 +730,19 @@ void mb_shell::mouse_menu_widget_main::update(ui::update_context &ctx) { calibrate_position(ctx); position_calibrated = true; } + + // Override mouse state with GetAsyncKeyState for reliable detection + // in WS_EX_NOACTIVATE windows where GLFW may miss mouse messages + bool lmb_down = (GetAsyncKeyState(VK_LBUTTON) & 0x8000) != 0; + bool rmb_down = (GetAsyncKeyState(VK_RBUTTON) & 0x8000) != 0; + ctx.mouse_down = lmb_down; + ctx.right_mouse_down = rmb_down; + ctx.mouse_clicked = lmb_down && !prev_lmb_down; + ctx.right_mouse_clicked = rmb_down && !prev_rmb_down; + ctx.mouse_up = !lmb_down && prev_lmb_down; + prev_lmb_down = lmb_down; + prev_rmb_down = rmb_down; + menu_wid->update(ctx); auto using_touchscreen = !IsCursorVisible(); diff --git a/src/shell/contextmenu/menu_widget.h b/src/shell/contextmenu/menu_widget.h index 11af3a6..217cf17 100644 --- a/src/shell/contextmenu/menu_widget.h +++ b/src/shell/contextmenu/menu_widget.h @@ -157,6 +157,8 @@ struct mouse_menu_widget_main : public ui::widget { mouse_menu_widget_main(menu menu_data, float x, float y); bool position_calibrated = false, direction_calibrated = false; bool ignore_outside_click_until_mouse_release = false; + bool prev_lmb_down = false; + bool prev_rmb_down = false; popup_direction direction; std::shared_ptr menu_wid;