Skip to content

Objects list: open the right-click menu after the button is released - #651

Draft
SmallTardigrade wants to merge 1 commit into
CrealityOfficial:masterfrom
SmallTardigrade:fix/objectlist-context-menu-on-release
Draft

SmallTardigrade wants to merge 1 commit into
CrealityOfficial:masterfrom
SmallTardigrade:fix/objectlist-context-menu-on-release

Conversation

@SmallTardigrade

Copy link
Copy Markdown

Description

Right-clicking a part or plate in the Objects list on Linux flashes the menu and closes it straight away. Other right-click menus, including the 3D view's, are fine. This opens the Objects list menu after the button is released instead of while it's held.

This is a draft because the patch has not been compiled or run. The cause below was measured on the released 7.3.1 build. See Tests.

Cause

  1. A row detects the right click with ImGui::IsItemClicked(ImGuiMouseButton_Right), which is true on the press frame, then posts EVT_OBJ_LIST_COLUMN_SELECT. The menu therefore opens with the button still down.
  2. A posted event runs outside any GDK event. With no current event, wxWidgets' DoPopupMenu uses a temporary one with time = GDK_CURRENT_TIME (0), and GTK takes the menu's activation time from that.
  3. gtk_menu_shell_button_release only ignores a release within 500 ms of the activation time. Measured from 0, that allowance never applies, so the release closes the menu.

The 3D view gets the same time of 0, but it posts its event from RightUp, so no release is left to arrive.

Changes

  • Both places that posted the event (render_plate and handle_obj_list_select_event) now set m_context_menu_pending.
  • The end of the table's render function posts the event once ImGui::IsMouseDown(ImGuiMouseButton_Right) is false.
  • Selection still happens on press. Only the menu waits.

This applies on every platform, so the menu will also open on release on Windows and macOS. ImGui's own BeginPopupContextItem and the 3D view already work that way.

Screenshots/Recordings/Graphs

None. Logged menu opens on 7.3.1 are under Tests.

Tests

Environment: V7.3.1.6378 AppImage, Fedora 44, KDE Wayland, Mesa Intel, GTK 3.24.52. It also happens with GDK_BACKEND=x11, so it isn't Wayland-specific.

Measured on the unpatched 7.3.1 build:

  • An LD_PRELOAD logger around gtk_menu_popup_at_rect gave the same two lines in two runs, 3D view first and Objects list second:
    [diag] at_rect trigger_time=0 current_event_time=0 button_held=0
    [diag] at_rect trigger_time=0 current_event_time=0 button_held=1
    
  • A second LD_PRELOAD shim ignores a menu's first release if a button is held when it opens. With it, the Objects list menu stays open, and it logged catching that release nine times in one run. That shim is only a workaround and isn't part of this PR.

Not tested:

  • This patch. I didn't do the full dependency and slicer build, so it hasn't been compiled and the behaviour is unconfirmed.
  • The redraw after release. The menu only opens if a frame renders after the button comes up. From reading GLCanvas3D::on_mouse it should, since events ImGui handles trigger a render, but this is the first thing to check.
  • To check once built: the menu on plate, object and volume rows; pressing on a row and releasing elsewhere; menu items on the first click; Windows and macOS.

🤖 Generated with Claude Code

A row reports a right click on press (ImGui::IsItemClicked), and the menu
opens from a posted event while the button is still down. On GTK that menu
has no activation time, because a posted event has no current GDK event, so
wxWidgets passes GDK_CURRENT_TIME (0). GTK's 500 ms allowance for a quick
press and release then never applies, and the release closes the menu.

Selection still happens on press. Only the menu waits for the button to come
up, which is when the 3D view opens its menu too.

Not compiled or run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant