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

feat: Added Browser Window Click Event (Issue #24351) #41898

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 41 additions & 0 deletions shell/browser/browser_win.cc
Expand Up @@ -50,6 +50,7 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/events/keycodes/keyboard_code_conversion_win.h"
#include "ui/strings/grit/ui_strings.h"
#include <Windows.h>

namespace electron {

Expand Down Expand Up @@ -778,4 +779,44 @@ void Browser::SetAboutPanelOptions(base::Value::Dict options) {
about_panel_options_ = std::move(options);
}

int Browser::GetClickType(WPARAM wParam) {
if (wParam == WM_LBUTTONDOWN) {
return 0;
}
else if (wParam == WM_RBUTTONDOWN) {
return 1;
}
else if (wParam == WM_MBUTTONDOWN) {
return 2;
}

return -1;
}

LRESULT CALLBACK Browser::MouseHookProc(int nCode, WPARAM wparam, LPARAM lparam){
if(nCode >= 0){
return GetClickType(wParam);
}

return CallNextHookEx(NULL, nCode, wParam, lParam);
}

void Browser::WindowClickEvent() {
HINSTANCE hInstance = GetModuleHandle(NULL);
HHOOK hHook = SetWindowsHookEx(WH_MOUSE_LL, MouseHookProc, hInstance, 0)

if(hHook == NULL){
return;
}

MSG msg;
while(GetMessage(&msg, NULL, 0, 0)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}

UnhookWindowsHookEx(hHook);
return;
}

} // namespace electron