Commit 509f2ac
qt: context menu + PyQt6/PySide6 Linux embedding fixes
Add RunContextMenu Cython/C++ dispatch so Python can intercept CEF's
context menu and replace it with a native QMenu:
- src/handlers/context_menu_handler.pyx: new file; RunContextMenuCallback
and MenuModel (snapshot) cdef classes, MENUITEMTYPE_* constants,
ContextMenuHandler_RunContextMenu C-public entry point
- src/client_handler/context_menu_handler.cpp/.h: add RunContextMenu
override that calls the Cython entry point
- src/cefpython.pyx: include context_menu_handler.pyx
- src/browser.pyx: allow "RunContextMenu" client callback
examples/qt.py:
- PyQt6/PySide6: force QT_QPA_PLATFORM=xcb so Qt6 uses X11 (same as CEF
which uses ozone-platform=x11); Wayland and X11 backends are incompatible
- PyQt6/PySide6: embed CEF directly into cef_widget.winId() (Qt6 uses XCB
like CEF); skip hidden_window/_linux_embed_info reparent path (PyQt5 only)
- Remove WA_PaintOnScreen; it causes XGetWindowAttributes failures and
"paintEngine: Should no longer be called" warnings under Qt6
- Add _x11_button_state() via python-xlib XQueryPointer: reads real X11
pointer button mask even while CEF holds an X11 grab (Qt mouseButtons()
is unreliable during grab)
- OnGotFocus (focus-follows-mouse WM): fast-path dismiss only if a button
is pressed AND cursor is outside menu; always start poll timer after check
- _start_focus_poll(): 5 ms QTimer; hides menu on outside-click without
dismissing it when user clicks a menu item (cursor-inside check)
- show_menu(): dismiss any already-open menu before showing a new one to
prevent menu stacking on repeated right-clicks; connect aboutToHide to
stop the poll timer; clean up _active_menu after exec_() returns
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 46ad61a commit 509f2ac
7 files changed
Lines changed: 449 additions & 104 deletions
0 commit comments