Skip to content

v39.0.0-beta.3 resizability broken with transparent window #48554

Closed

Description

@t57ser

Preflight Checklist

Electron Version

39.0.0-beta.3

What operating system(s) are you using?

Windows

Operating System Version

10

What arch are you using?

x64

Last Known Working Electron version

39.0.0-beta.2

Does the issue also appear in Chromium / Google Chrome?

I don't know how to test

Expected Behavior

Window should be transparent and resizable if created as transparent and resizable

Actual Behavior

both win11 and win10, resizing does no longer work if the window is transparent

This most likely was caused by: #48378

Testcase Gist URL

https://gist.github.com/t57ser/df9af8f7024137dfaf59de3e7b8909bc

Additional Information

the gist is from this issue I created: #48421
please check the issue for additional information, testing can be done the same way

Related issue for transparency being broken in win10: #48592

Activity

  1. added theissue type on Oct 14, 2025
  2. added
    has-repro-gist
    on Oct 14, 2025
  3. moved this to 👀 Unsorted Items in 39-x-yon Oct 14, 2025
  4. zoy-l commented on Oct 14, 2025

    @zoy-l
    Contributor

    Transparent windows don’t support resizing by dragging the borders. I need to find a machine to test the issue where transparent windows don’t work on Windows 10.

  5. t57ser commented on Oct 14, 2025

    @t57ser
    ContributorAuthor

    @zoy-l Electron has been supporting transparent resizable windows up until 39.0.0-beta.3 and it only broke with the change therefor I can not imagine how this can be true

  6. zoy-l commented on Oct 14, 2025

    @zoy-l
    Contributor

    @t57ser I tested v36 and v37.2.5, and neither of them supports resizing by dragging the window border. 😦

  7. added
    bug/regression ↩️
    on Oct 14, 2025
  8. t57ser commented on Oct 14, 2025

    @t57ser
    ContributorAuthor

    37.2.5 test:

    clip0001.webm

    You can reproduce this by using electron fiddle, just use the default template and add

    transparent: true,
    frame: false,
    resizable: true
    
  9. nikwen commented on Oct 14, 2025

    @nikwen
    Member

    I can resize the window from the testcase gist on v37.2.5. I can't resize it on v39.0.0-beta.3.

    (Note that the testcase gist from the issue only makes the window resizable after 10 seconds.)

  10. added
    status/confirmed
    on Oct 14, 2025
  11. 50 remaining items

  12. zoy-l commented on Jan 9, 2026

    @zoy-l
    Contributor

    @mayfield
    I believe this is a conflict between the design goals and the actual behavior. From the logic of the code, a transparent window should not be resizable via dragging. As for why it worked previously, I think it was either due to a particular combination of configurations that bypassed this limitation or an incomplete implementation. Window configuration on Windows is quite fragile, and I can only make changes according to the original design intent of the code and the documentation; otherwise, it may lead to unexpected issues.

  13. zoy-l commented on Jan 9, 2026

    @zoy-l
    Contributor

    There is also another possible solution: adding the WS_THICKFRAME window style to the transparent window via a Node.js addon. Electron can obtain the native window handle, and this approach can be used as a temporary workaround until this issue is fully identified and clarified.

    // main.js
    const { app, BrowserWindow } = require('electron');
    
    app.whenReady().then(() => {
      const win = new BrowserWindow({
        transparent: true,
        frame: false,
      });
    
      // On Windows, this returns an HWND buffer
      const hwnd = win.getNativeWindowHandle();
    
      // Pass the HWND to native addon
      const addon = require('./build/Release/window_style_addon.node');
      addon.addThickFrame(hwnd);
    });
    #include <napi.h>
    #include <windows.h>
    
    /**
     * This code was generated by an AI (Gemini).
     * Function: AddThickFrame
     * Purpose: Dynamically adds the WS_THICKFRAME style to an Electron window to 
     * enable native resizing for frameless windows on Windows.
     */
    
    void AddThickFrame(const Napi::CallbackInfo& info) {
        Napi::Env env = info.Env();
    
        // 1. Retrieve the HWND (Window Handle) from the Node.js Buffer.
        // getNativeWindowHandle() returns a buffer containing the memory address of the HWND.
        HWND hwnd = *reinterpret_cast<HWND*>(info[0].As<Napi::Buffer<char>>().Data());
    
        // 2. Get current window styles using GetWindowLong.
        LONG currentStyle = GetWindowLong(hwnd, GWL_STYLE);
    
        // 3. Apply the WS_THICKFRAME flag using a bitwise OR (|) operation.
        // This adds the "resizable" border style while preserving all existing styles.
        SetWindowLong(hwnd, GWL_STYLE, currentStyle | WS_THICKFRAME);
    
        // 4. Force the window to recalculate its non-client area (frame).
        // Without SWP_FRAMECHANGED, the visual change won't take effect immediately.
        // SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER ensures we only refresh without moving the window.
        SetWindowPos(
            hwnd, 
            NULL, 
            0, 0, 0, 0, 
            SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED
        );
    }
    
    Napi::Object Init(Napi::Env env, Napi::Object exports) {
        exports.Set("addThickFrame", Napi::Function::New(env, AddThickFrame));
        return exports;
    }
    
    NODE_API_MODULE(window_style_addon, Init)
  14. mayfield commented on Jan 9, 2026

    @mayfield
    Contributor

    Hello @zoy-l

    Thanks for commenting and offering a potential workaround.

    I have learned a few more things that upset the applecart, for better or worse, but I think for the better.

    I went down the path of trying to see exactly what the mechanism for resizing was and as it turns out there are two different resize modes. When the window is frame-less, a chromium/electron specific hit-test method is used instead of the operating systems native resize handling. There are two particular functions that gate this functionality based on IsResisable() and CanResize(), which is why this functionality broke for win32..

    See:

    int NativeWindow::NonClientHitTest(const gfx::Point& point) {
    #if !BUILDFLAG(IS_MAC)
    // We need to ensure we account for resizing borders on Windows and Linux.
    if ((!has_frame() || has_client_frame()) && IsResizable()) {
    auto* frame =
    static_cast<FramelessView*>(widget()->non_client_view()->frame_view());
    int border_hit = frame->ResizingBorderHitTest(point);
    if (border_hit != HTNOWHERE)
    return border_hit;
    }
    #endif
    // This is to disable dragging in HTML5 full screen mode.
    // Details: https://github.com/electron/electron/issues/41002
    if (widget()->IsFullscreen())
    return HTNOWHERE;
    for (auto* provider : draggable_region_providers_) {
    int hit = provider->NonClientHitTest(point);
    if (hit != HTNOWHERE)
    return hit;
    }
    return HTNOWHERE;
    }

    and:

    int FramelessView::ResizingBorderHitTestImpl(const gfx::Point& point,
    const gfx::Insets& resize_border) {
    // to be used for resize handles.
    bool can_ever_resize = frame_->widget_delegate()
    ? frame_->widget_delegate()->CanResize()
    : false;
    // https://github.com/electron/electron/issues/611
    // If window isn't resizable, we should always return HTNOWHERE, otherwise the
    // hover state of DOM will not be cleared probably.
    if (!can_ever_resize)
    return HTNOWHERE;
    // Don't allow overlapping resize handles when the window is maximized or
    // fullscreen, as it can't be resized in those states.
    bool allow_overlapping_handles =
    !frame_->IsMaximized() && !frame_->IsFullscreen();
    return GetHTComponentForFrame(
    point, allow_overlapping_handles ? resize_border : gfx::Insets(),
    kResizeAreaCornerSize, kResizeAreaCornerSize, can_ever_resize);
    }

    If I make no other changes but to hack those two functions to believe resizing is allowed, then it makes no difference what windows style flags are set; resize just works regardless.

    With this hack..

    diff --git a/shell/browser/native_window.cc b/shell/browser/native_window.cc
    index 5e02ef25c6..af0b8826ec 100644
    --- a/shell/browser/native_window.cc
    +++ b/shell/browser/native_window.cc
    @@ -668,7 +668,7 @@ void NativeWindow::NotifyWindowMessage(UINT message,
     int NativeWindow::NonClientHitTest(const gfx::Point& point) {
     #if !BUILDFLAG(IS_MAC)
       // We need to ensure we account for resizing borders on Windows and Linux.
    -  if ((!has_frame() || has_client_frame()) && IsResizable()) {
    +  if ((!has_frame() || has_client_frame()) && (IsResizable() || true)) { // XXX Required for resize
         auto* frame =
             static_cast<FramelessView*>(widget()->non_client_view()->frame_view());
         int border_hit = frame->ResizingBorderHitTest(point);
    diff --git a/shell/browser/ui/views/frameless_view.cc b/shell/browser/ui/views/frameless_view.cc
    index 420a825f27..0b9194af8d 100644
    --- a/shell/browser/ui/views/frameless_view.cc
    +++ b/shell/browser/ui/views/frameless_view.cc
    @@ -40,6 +40,8 @@ int FramelessView::ResizingBorderHitTestImpl(const gfx::Point& point,
       bool can_ever_resize = frame_->widget_delegate()
                                  ? frame_->widget_delegate()->CanResize()
                                  : false;
    +  printf("Hacking ResizingBorderHitTestImpl: can_ever_resize = true\n");
    +  can_ever_resize = true;
    
       // https://github.com/electron/electron/issues/611
       // If window isn't resizable, we should always return HTNOWHERE, otherwise the
    

    And this quick and dirty replacement of SetFocusable so I can toggle the WS_THICKFRAME flag at runtime easily..

    diff --git a/shell/browser/native_window_views.cc b/shell/browser/native_window_views.cc
    index 05e40ed631..1ada7d1ee0 100644
    --- a/shell/browser/native_window_views.cc
    +++ b/shell/browser/native_window_views.cc
    @@ -1354,6 +1354,13 @@ bool NativeWindowViews::IsContentProtected() const {
     }
    
     void NativeWindowViews::SetFocusable(bool focusable) {
    +  printf("HIJACKED set focusable to toggle thickframe: %d\n", focusable);
    +  FlipWindowStyle(GetAcceleratedWidget(), focusable, WS_THICKFRAME);
    +  //FlipWindowStyle(GetAcceleratedWidget(), focusable, WS_CAPTION);
    +  ::SetWindowPos(GetAcceleratedWidget(), NULL, 0, 0, 0, 0,
    +               SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
    +  return;
    +  /*
       widget()->widget_delegate()->SetCanActivate(focusable);
     #if BUILDFLAG(IS_WIN)
       LONG ex_style = ::GetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE);

    And finally this bare bones electron app that changes the WS_THICKFRAME flag every 4 seconds...

    electron.app.on('ready', () => {
        const win = new electron.BrowserWindow({
            frame: false,
            transparent: true,
        });
        win.loadFile('resize-test.html');
        win.show();
    
        let on = true;
        setInterval(() => {
            console.warn("OKAY, flip the bit", on ? 'ON' : 'OFF');
            win.setFocusable(on);
            on = !on;
        }, 4000);
    });

    You can see in the video below that both, resizing still works and the WS_THICKFRAME flag, while affecting the shadows of the window, has no bearing on its' resizability.

    window-9.mp4

    Where the WS_THICKFRAME option does matter, is when frame:true. When the frame is present the hit-test method is not used and the operating system is expected to handle this. Without WS_THICKFRAME resize truly is disabled on win32.

    My gut says the correct place to focus is on harmonizing IsResizable() and CanResize(), possibly with a unified implementation. And making it clear that setting thickFrame:false only applies when frame:true as well.

    I'll sleep on this and await further comment before offering a PR, but I feel a bit more confident that this can be resolved with a fairly safe patch.

  15. zoy-l commented on Jan 9, 2026

    @zoy-l
    Contributor

    @mayfield When you’re ready, you can submit a PR directly, because that’s the only way the API team will review it. You can also discuss the API design with team members there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    39-x-ybug 🪲bug/regression ↩️component/transparenthas-repro-gistplatform/windowsstatus/confirmed

    Type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions