Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/shell/contextmenu/menu_render.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<mouse_menu_widget_main>(
menu,
// convert the x and y to the window coordinates
Expand Down
13 changes: 13 additions & 0 deletions src/shell/contextmenu/menu_widget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/shell/contextmenu/menu_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_widget> menu_wid;

Expand Down
Loading