-
Notifications
You must be signed in to change notification settings - Fork 136
Implement WM_ContextMenu #53
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
Conversation
Definitively a useful addition, I planed this initially (this is why there was a placeholder) but somehow it never got in. I will make a small code review, because there is something I don't see as very useful. |
src/NotifyIconWpf/Interop/WinApi.cs
Outdated
@@ -87,5 +87,15 @@ internal static class WinApi | |||
|
|||
[DllImport(User32, SetLastError = true)] | |||
public static extern bool GetCursorPos(ref Point lpPoint); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm all for clean code and reuse, but somethings we should not over engineer code.
I actually don't see any re-use for this, unless there is no need for this elsewhere I would suggest to just have this inside the switch statement with the WindowsMessages.WM_CONTEXTMENU
src/NotifyIconWpf/TaskbarIcon.cs
Outdated
@@ -132,6 +132,7 @@ public TaskbarIcon() | |||
|
|||
// register event listeners | |||
messageSink.MouseEventReceived += OnMouseEvent; | |||
messageSink.ContextMenuReceived += OnContextMenuEvent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if the added redirect via the OnContextMenuEvent adds anything to clear up the code, maybe we just do the following?
messageSink.ContextMenuReceived += ShowContextMenu;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know whether DPI has any effect on the wParam-Position, so I just added another method here.
@@ -242,8 +248,11 @@ private void ProcessWindowMessage(uint msg, IntPtr wParam, IntPtr lParam) | |||
switch (message) | |||
{ | |||
case WindowsMessages.WM_CONTEXTMENU: | |||
// TODO: Handle WM_CONTEXTMENU, see https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shell_notifyiconw | |||
Debug.WriteLine("Unhandled WM_CONTEXTMENU"); | |||
ContextMenuReceived?.Invoke(new Point() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in the other comment, why not place the code to do the low / high bit logic directly here, as it's probably not used elsewhere.
Is there any chance you can also check the other TODOs in the WindowMessageSink? |
I think it would be beneficial to add those aswell. |
Checked and implemented NIN_SELECT and NIN_KEYSELECT - implementation is equal to WM_CONTEXTMENU. |
Looks great from a code perspective, I will have a quick try later. |
@punker76 @hardcodet this PR solves some of the small TODOs that were still open for keyboard usage. |
@Lakritzator IMO we should work on the develop branch until we want to release a new version which will be merged to the master and a new branch like release/x.x.x. |
@punker76 I should have added my suggestion... yes, work in develop, and branch out. The 1.1 hasn't been branched out, I will do so, so I can merge this. |
@Lakritzator The missing branch was a mistake by me |
Okay, push it |
@Lakritzator done |
@AliveDevil thank you for your work. I currently can't tell when this is released, keep an eye out on the project. |
Needed this functionality as a user requested it once. Would appreciate that this is taken upstream, instead of relying on our private fork, from 2016.