Skip to content

Mouse capture implementation question #5

@PaulBol

Description

@PaulBol

Something else that I noticed...

UngrabWindow in XplatUICocoa.cs includes these lines

if (LastEnteredHwnd != IntPtr.Zero && LastEnteredHwnd != grabbed)
{
	var lparam = IntPtr.Zero; // TODO: should contain mouse coords? See WindowsEventResponder.TranslateMouseEvent()
	var wparam = (IntPtr)(NSEvent.CurrentModifierFlags.ToWParam() | Mac.Extensions.ButtonMaskToWParam(NSEvent.CurrentPressedMouseButtons));
	SendMessage(grabbed, Msg.WM_MOUSELEAVE, wparam, lparam);
	SendMessage(LastEnteredHwnd, Msg.WM_MOUSE_ENTER, wparam, lparam);
}

This leads to a nested call of WndProc with WM_MOUSELEAVE when the mouse button is released (WM_LBUTTONUP) while captured.

My code was not prepared to deal with this. I'm not daring to suggest this is a bug in XplatUICocoa.cs that needs to be fixed. Only wondering if it should be PostMessage instead of SendMessage so that the button up message handling is completed before WM_MOUSELEAVE. I figured out this is what System.Windows.Forms.CarbonInternal.MouseHandler does in TranslateMessage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions