window_manager icon indicating copy to clipboard operation
window_manager copied to clipboard

Parameter «Forward» in setIgnoreMouseEvents

Open itspectre opened this issue 2 years ago • 4 comments

Related to #89 Thank you for adding setIgnoreMouseEvents, it works, but there is the unused parameter «forward» in the declaration of this function. It exists but does nothing. In electron.js if it is «true» then the window will also be getting mouse movement events. It can be useful for detecting enter/leave mouse to some widgets in the app window for setIgnoreMouseEvents toggling, especially if the window is always on top.

I have tried to add «mainWindow.acceptsMouseMovedEvents = true» in setIgnoreMouseEvents In WindowManager.swift (I use MacOS). It started detection mouse movement in case setIgnoreMouseEvents(true) (I use Listener and MouseRegion with their movement handlers). But when I click on the app window and its focus is lost, that moving detection also stops. Although I see the app window above another window (isAlwaysOnTop is true). In electron.js this way works right. Is it possible to implement «forward» with such right behavior? I mean, the next situation: setIgnoreMouseEvents(true, forward: true) setAlwaysOnTop(true)

In these settings, we can click on the app window, it loses focus, but can get mouse moving events. (the window under it gets all mouse events). It would be really good if you could add «forward» with such behavior.

From Electron documentation:

  • forward boolean (optional) macOS Windows - If true, forwards mouse move messages to Chromium, enabling mouse related events such as mouseleave. Only used when ignore is true. If ignore is false, forwarding is always disabled regardless of this value.

itspectre avatar Mar 12 '22 13:03 itspectre

The forward parameter is already supported on the macos platform, you can view the example.

lijy91 avatar Mar 19 '22 06:03 lijy91

But I haven't found out how to implement it on windows platform

lijy91 avatar Mar 19 '22 06:03 lijy91

The forward parameter is already supported on the macos platform, you can view the example.

The problem is that adding "acceptsMouseMovedEvents" in the swift file probably is not enough for getting desired behavior. Or it could be made by something else. I have created two simple demo projects - one uses Electron.js and another - Flutter with the new version window_manager from this repository. You can watch videos in these repositories that demonstrate this problem.

In Electron I can continue getting mouse movement events after clicking on the application window with parameter "forward = true", but in Flutter window_manager it doesn't work, although before clicking I can get these events. In the Electron video, when the mouse enters the button's area, I can change window opacity and ignore mode. But I can't do it in window_manager because the app window doesn't get mouse movement events after clicking on it.

Also, there is some strange behavior - with "forward = false" when mouse leaves the window area and then returns - my window starts getting movement events. But in Electron.js I have found out similar situation.

This is for Flutter (including video): https://github.com/bdorlov/wm_test

This is for Electron (including video): https://github.com/bdorlov/ignore-mouse-events-electron-test

The code with Flutter demo here: https://github.com/bdorlov/wm_test/blob/master/lib/main.dart

itspectre avatar Mar 20 '22 21:03 itspectre