Skip to content

I have added window transparency here, but it will cause my mouse penetration issue. How can I solve it #1357

@shileias

Description

@shileias

I have added window transparency here, but it will cause my mouse penetration issue. How can I solve it
win32_edge.hh:
noresult set_background_colour_impl(unsigned char r, unsigned char g, unsigned char b, unsigned char a) override {
// Set window background color
if (m_window) {
COLORREF color = RGB(r, g, b);
HBRUSH brush = CreateSolidBrush(color);
HBRUSH oldBrush = (HBRUSH)SetClassLongPtr(m_window, GCLP_HBRBACKGROUND, (LONG_PTR)brush);
if (oldBrush) {
DeleteObject(oldBrush);
}

// Handle layered window transparency for the entire window
LONG ex_style = GetWindowLong(m_window, GWL_EXSTYLE);
if (!(ex_style & WS_EX_LAYERED)) {
  SetWindowLong(m_window, GWL_EXSTYLE, ex_style | WS_EX_LAYERED);
}
// Set window transparency based on alpha value (0-255)
SetLayeredWindowAttributes(m_window, 0  ,128,LWA_COLORKEY);
InvalidateRect(m_window, nullptr, TRUE);

}

// Set widget background color
if (m_widget) {
COLORREF color = RGB(r, g, b);
HBRUSH brush = CreateSolidBrush(color);
HBRUSH oldBrush = (HBRUSH)SetClassLongPtr(m_widget, GCLP_HBRBACKGROUND, (LONG_PTR)brush);
if (oldBrush) {
DeleteObject(oldBrush);
}
InvalidateRect(m_widget, nullptr, TRUE);
}

// Set WebView background color (WebView2 only supports 0 or 255 for alpha)
if (m_controller) {
// WebView2 only supports 0 (transparent) or 255 (opaque) for alpha
COREWEBVIEW2_COLOR color = {a, r, g, b};
ICoreWebView2Controller2 *controller2 = nullptr;
if (SUCCEEDED(m_controller->QueryInterface(IID_ICoreWebView2Controller2, (void **)&controller2))) {
controller2->put_DefaultBackgroundColor(color);
controller2->Release();
}

}
return {};
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions