Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add MessageFilter to selectively block window message #183

Merged
merged 7 commits into from
May 8, 2024

Conversation

ruby3141
Copy link
Contributor

This PR introduces BREANKING changes described below;

  • add MessageFilter to selectively block window message
    Blocking every window message blocks intentional user actions like minimizing, closing(Alt-F4 doesn't work either), resizing, etc.
    This commit fixes that kind of problem by providing bitflag interface to block certain predefined range of window messages.
    To block every messages like before, you can return MessageFilter::all() on set_message_filter().

This PR fixes #182.

Blocking every window message blocks intentional user actions
like minimizing, closing(Alt-F4 doesn't work either), resizing etc.

This commit fixes that kind of problem by providing bitflag interface
to block certain predefined range of window messages.

To block every messages like before,
you can return `MessageFilter::all()` on `set_message_filter()`.
@veeenu
Copy link
Owner

veeenu commented Apr 16, 2024

Thank you for your contribution! 🙏
Please allow me a bit of time to thoroughly review this, but I like what I've seen so far.

Copy link
Owner

@veeenu veeenu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution. I like this!

I'd like to have a few changes but otherwise this looks good. Also, could you please implement the new method in the test hook? This would be helpful both to users looking for an example and to us to check that the thing works correctly. Could e.g. ignore events according to time elapsed from first_time (2s ignore keyboard, 4s ignore mouse etc).

src/renderer/msg_filter.rs Outdated Show resolved Hide resolved
src/renderer/msg_filter.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/renderer/msg_filter.rs Outdated Show resolved Hide resolved
There was some perspective mistake during naming the method.
It's getter for pipeline, not setter for user code.
The method would(and maybe should) not be used in user code,
so make it protected seems good idea.
- Explanation about using MessageFilter is added.
- Wrap consts like `WM_USER` with backticks(`)
Harness doesn't seem to handle any input events,
so only thing we can simply test is `MessageFilter::WindowControl`
@ruby3141 ruby3141 requested a review from veeenu May 7, 2024 07:22
@ruby3141
Copy link
Contributor Author

ruby3141 commented May 7, 2024

In addition to your change requests, I made MessageFilter::is_blocking() pub(crate),
because it would not be used in user code.

Test for only MessageFilter::WindowControl is added to the test hook, because harness itself doesn't seems to handle any input.

@ruby3141
Copy link
Contributor Author

ruby3141 commented May 7, 2024

out.webm

Copy link
Owner

@veeenu veeenu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thank you again! 🙌

(p.s. what font is that in your editor? I like it!)

@ruby3141
Copy link
Contributor Author

ruby3141 commented May 8, 2024

The font is NeoDunggeunmo Code.
It's one of a few programming fonts that natively supports korean glyphs, and because of its bitmap appearance and square sizing it matches very well with unifont fallback.

@veeenu veeenu merged commit e34f748 into veeenu:main May 8, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

need ways to filter certain windows message, without blocking everything
2 participants