Skip to content

[GTK] MouseMove-events are not sent after showing popup #3334

@tmssngr

Description

@tmssngr

Describe the bug
After showing a popup menu and closing it, mouse move events are not sent any more (if a mouse down and drag detected listener are registered).

To Reproduce

import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;

public class NoMouseEventsAfterShowingPopup {

	public static void main(String[] args) {
		final Display display = new Display();

		final Shell shell = new Shell(display);
		shell.addListener(SWT.MouseMove, event -> {
			System.out.println("mouse moved " + System.currentTimeMillis() % 1000);
		});

		// these listeners prevent mouse move events after showing the popup:
		shell.addListener(SWT.MouseDown, event -> {
			System.out.println("mouse down");
		});
		shell.addListener(SWT.DragDetect, event -> {
			System.out.println("drag detected");
		});
		// <<

		shell.addListener(SWT.MenuDetect, event -> {
			final Menu menu = new Menu (shell, SWT.POP_UP);
			final MenuItem item = new MenuItem (menu, SWT.PUSH);
			item.setText ("Popup");
			menu.setLocation(event.x, event.y);
			menu.setVisible(true);
		});

		shell.setSize(300, 200);
		shell.open();

		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}

		display.dispose();
	}
}
  • move the mouse over the shell -> events are logged to the console
  • right-click to show a minimal popup menu
  • close the popup menu with ESC
  • move the mouse again -> no events are logged any more
  • left-click into the shell
  • move the mouse again -> now events are logged again

Expected behavior
MouseMove events should be sent independent of whether

  • drag-detect and mouse-down listeners are configured
  • a popup menu has been shown

Screenshots
https://github.com/user-attachments/assets/2947081d-397c-44c7-8b45-b5f7f138dab0

Environment:

  1. Select the platform(s) on which the behavior is seen:
    • All OS
    • Windows
    • Linux
    • macOS
  1. Additional OS info (e.g. OS version, Linux Desktop, etc)
    Ubuntu 26.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions