diff options
author | Simon Rozman <simon@rozman.si> | 2019-09-09 15:53:59 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-09-13 12:07:36 -0400 |
commit | d0cf4426e2bf0876b946630946c6d2413aebf39d (patch) | |
tree | 925c7cb8986207789c6ef6d98d16c6ed58e3d83d /ui/syntax | |
parent | ui: cleanup (diff) | |
download | wireguard-windows-d0cf4426e2bf0876b946630946c6d2413aebf39d.tar.xz wireguard-windows-d0cf4426e2bf0876b946630946c6d2413aebf39d.zip |
ui: fix popup menu placement in syntaxedit
When pop-up menu is invoked using keyboard, the coordinates are (-1,-1).
However, LOWORD/HIWORD return (65535, 65535).
Signed-off-by: Simon Rozman <simon@rozman.si>
Diffstat (limited to 'ui/syntax')
-rw-r--r-- | ui/syntax/syntaxedit.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/ui/syntax/syntaxedit.c b/ui/syntax/syntaxedit.c index c04c1f8a..70ebca63 100644 --- a/ui/syntax/syntaxedit.c +++ b/ui/syntax/syntaxedit.c @@ -9,6 +9,7 @@ #include <string.h> #include <assert.h> #include <windows.h> +#include <windowsx.h> #include <richedit.h> #include <richole.h> #include <tom.h> @@ -281,8 +282,8 @@ static void context_menu(HWND hWnd, INT x, INT y) if (x == -1 && y == -1) { RECT rect; GetWindowRect(hWnd, &rect); - x = rect.left + (rect.right - rect.left) / 2; - y = rect.top + (rect.bottom - rect.top) / 2; + x = (rect.left + rect.right) / 2; + y = (rect.top + rect.bottom) / 2; } if (GetFocus() != hWnd) @@ -356,7 +357,7 @@ static LRESULT CALLBACK child_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lP break; } case WM_CONTEXTMENU: - context_menu(hWnd, LOWORD(lParam), HIWORD(lParam)); + context_menu(hWnd, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); return 0; case WM_THEMECHANGED: highlight_text(hWnd); |