Skip to content

Support click-through of transparency #1335

Open

Description

@tommoor

As commented here, #949 (comment) - transparent windows unfortunately are of limited use unless you can click through the transparent area.

I noticed that in the documentation it is stated that this is blocked by an upstream bug. The nw.js project DOES have support for this, but i'm not sure how different their implementation is...

I think this is worth the issue to track discussion and implementation, so here it is.

Activity

  1. thomasjo commented on Mar 31, 2015

    @thomasjo
    Contributor

    While nw.js does support it, it comes with some pretty hefty drawbacks. First of all it requires disabling GPU acceleration, and secondly it only works on OS X and Windows (based on their documentation).

  2. CharlieHess commented on Mar 31, 2015

    @CharlieHess
    Contributor

    +1, this one's plaguing Slack too, since we display all of our notifications in a transparent window.

  3. YourCyborg commented on May 6, 2015

    @YourCyborg

    +1, this is critical for the project I'm working on.

  4. marcfowler commented on May 8, 2015

    @marcfowler

    +1, this would be excellent.

  5. geelen commented on Jun 23, 2015

    @geelen
    Contributor

    Interested in hearing the latest on this. For my purposes, I'd love if we could set a transparent window to have no click area. So you could have an always-on-top full screen overlay that didn't catch clicks.

  6. TimvdEijnden commented on Dec 1, 2015

    @TimvdEijnden

    I'm interested too, i'm building an app with a semi transparent window that's on top of other applications but mouseevents need to get through to the other applications.

  7. yohaia commented on Jan 7, 2016

    @yohaia

    +1

    Any news about it?

  8. lukeapage commented on Jan 8, 2016

    @lukeapage
    Contributor

    the linked chromium bug is marked wont-fix
    https://code.google.com/p/chromium/issues/detail?id=387234

    the last comment is:

    #11 [email protected]
    You know, just btw, people in Atom team can do it by themselves if their users need it, right?

    so nothing is currently going to happen until someone on the atom team decides to do it or persuades the chrome team it is worth putting on their backlog (and they said it was low priority).

  9. molster commented on Jan 14, 2016

    @molster

    Just ran into this today, It has put a -massive- issues into my plans of using a new window has an overlay. (in fact, it is now impossible)

    I would love a fix for this!

  10. devployment commented on Mar 12, 2016

    @devployment

    Is there any work in progress for this? Will there be a chance for the Electron team to make this possible without being added to Chromium?

  11. stanier commented on Apr 4, 2016

    @stanier

    +1

    Assuming this won't be resolved through the Chromium code, is there a plausible way to have the application listen for a click event and then trigger the proper counterpart in GTK or similar?

  12. kutu commented on Apr 4, 2016

    @kutu

    i use ahkscript

    #c::
        WinSet, ExStyle, ^0x20, A
        WinSet, Transparent, 255, A
        return

    press Win+C on active window, and its click-through now

  13. xeoneux commented on May 28, 2016

    @xeoneux

    @zcbenz Any update on this? 😄

  14. 78 remaining items

  15. raphael10-collab commented on Jul 9, 2023

    @raphael10-collab

    Following the indications found here: https://stackoverflow.com/questions/53357428/how-to-make-mouse-pass-through-window-in-electron I've put focusable: false for the child_window (the `transparent window) :

    child_window = new BrowserWindow({
        //height: 900,
        //width: 1200,
        height: searchWindowHeight,
        width: searchWindowWidth,
        x: searchWindow_x,
        y: searchWindow_y,
        maximizable: false,
        minimizable: false,
        parent: SearchWindow,
        transparent: true,
        skipTaskbar: true,
        movable: false,
        resizable: false,
        focusable: false, // https://stackoverflow.com/questions/53357428/how-to-make-mouse-pass-through-window-in-electron
        frame: false,
        alwaysOnTop: true,
        webPreferences: {
            nodeIntegration: false,
            nodeIntegrationInSubFrames: true,
            scrollBounce: true,
            safeDialogs: true,
            safeDialogsMessage: 'Prevent this page from creating additional dialogs',
            preload: CHILD_WINDOW_PRELOAD_WEBPACK_ENTRY,
            contextIsolation: true,
            sandbox: true,
            enableWebSQL: false,
            // match Chrome's default for anti-fingerprinting purposes (Electron defaults to 0)
            minimumFontSize: 6
        }
    })
    

    Now the top transparent window is not visible anymore, the button Click me in the underneath window is clickable and the screen.getCursorScreenPoint() yields its output

    image

    image

    But, still, I'm not able to get the correct mouse position with getCursorScreenPoint().... I mean... what I would like to do is to get, in the transparent window, child_window, the position {x, y} of the mouse when clicking on the underneath window

  16. LZQCN commented on Jul 9, 2023

    @LZQCN

    @raphael10-collab My code works for this scenario:

    QQ录屏20230710002937

  17. raphael10-collab commented on Jul 9, 2023

    @raphael10-collab

    Wow ...... I do not understand how you are actually using the screen.getCursorScreenPoint 's ouput:
    How are you passing the cursor position from the transparent window to the underneath window , and viceversa, from the underneath window to the transparent window? Through electron.ipcSend ?

  18. LZQCN commented on Jul 9, 2023

    @LZQCN

    @raphael10-collab
    If use my code, clicking on the transparent area of the window no longer generates any mouse events for the window. To be precise, the transparent window will be set to ignore any mouse events when the mouse is over the transparent area. only the content below the transparent window will be clicked.

    Also, if you want to get the clicked position, you should get the clicked position from the window that was actually clicked.

  19. raphael10-collab commented on Jul 9, 2023

    @raphael10-collab

    @LZQCN I've set :

    child_window.setFocusable(false)
    
    child_window.setIgnoreMouseEvents(true,{
        forward: true ,
    })
    

    According to what we read here: https://www.electronjs.org/docs/latest/api/browser-window#winsetignoremouseeventsignore-options :

    win.setIgnoreMouseEvents(ignore[, options])
    
        ignore boolean
        options Object (optional)
            forward boolean (optional) macOS Windows - If true, forwards mouse move messages to Chromium, enabling mouse related events such as mouseleave. Only used when ignore is true. If ignore is false, forwarding is always disabled regardless of this value.
    
    Makes the window ignore all mouse events.
    
    All mouse events happened in this window will be passed to the window below this window, but if this window has focus, it will still receive keyboard events
    

    should be fine....

    Is this not enough for Linux ?
    Why x and y do not change, based on the mouse events? :
    image

  20. raphael10-collab commented on Jul 10, 2023

    @raphael10-collab

    I do not understand why this message sent from the child_window (the transparent window on top of the other window) is not received in the main process:

    child_window renderer :

    React.useEffect(() => {
    window.api.electronIpcSend("hello-from-app-child", "HELLOOOOOOOOO")

    }, [])
    

    in main :

    ipcMain.on("hello-from-app-child", (event, args) => {
        console.log("IpcMain.on-hello-from-app-child-args: ", args)
    })
    

    This is how I defined and created the bottom window (SearchWindow) and the transparent window on top :

    declare const SEARCH_WINDOW_WEBPACK_ENTRY: string;
    declare const SEARCH_WINDOW_PRELOAD_WEBPACK_ENTRY: string;
    
    let SearchWindow: BrowserWindow
    
    let child_window: BrowserWindow
    declare const CHILD_WINDOW_WEBPACK_ENTRY: string;
    declare const CHILD_WINDOW_PRELOAD_WEBPACK_ENTRY: string;
    
    const createSearchWindow = (): void => {
        console.log("createSearchWindow called")
    
    SearchWindow = new BrowserWindow({
        fullscreenable: false,
        height: 900,
        width: 1200,
        kiosk: true,
        webPreferences: {
            preload: SEARCH_WINDOW_PRELOAD_WEBPACK_ENTRY,
            nodeIntegration: false,
            contextIsolation: true,
            nodeIntegrationInWorker: false,
            nodeIntegrationInSubFrames: false,
            webviewTag: true,
            webSecurity: true
        }
    
        let searchWindowHeight: number = SearchWindow.getBounds().height
        let searchWindowWidth: number = SearchWindow.getBounds().width
        let searchWindow_x: number = SearchWindow.getBounds().x
        let searchWindow_y: number = SearchWindow.getBounds().y
    
        child_window = new BrowserWindow({
            height: searchWindowHeight,
            width: searchWindowWidth,
            fullscreenable: false,
            x: searchWindow_x,
            y: searchWindow_y,
            maximizable: false,
            minimizable: false,
            parent: SearchWindow,
            transparent: true,
            skipTaskbar: true,
            movable: false,
            resizable: false,
            //focusable: false, 
            frame: false,
            alwaysOnTop: true,
            webPreferences: {
                nodeIntegration: false,
                nodeIntegrationInSubFrames: true,
                scrollBounce: true,
                safeDialogs: true,
                safeDialogsMessage: 'Prevent this page from creating additional dialogs',
                preload: CHILD_WINDOW_PRELOAD_WEBPACK_ENTRY,
                contextIsolation: true,
                sandbox: true,
                enableWebSQL: false,
                // match Chrome's default for anti-fingerprinting purposes (Electron defaults to 0)
                minimumFontSize: 6
            }
        })
    
        child_window.once('ready-to-show', () => {
            child_window.show()
        })
    
        child_window.setIgnoreMouseEvents(true,{
            forward: true ,
        })
    

    }

  21. foxxy432 commented on Sep 5, 2023

    @foxxy432

    It is ignored by Microsoft because of incompatibilities BUT you can use my fork: https://github.com/lnxx-kernel/electron_touch

  22. frankz61 commented on Nov 17, 2023

    @frankz61

    I've noticed that the Electron API setShape can solve some problems, similar to the Windows setWindowRgn. It allows areas without a set shape to be non-drawable and lets mouse events pass through.
    image
    This solved my problem. If your page's displayed content is not complex, you can use this API.

  23. Nebula-Developer commented on Mar 20, 2024

    @Nebula-Developer

    win.SetShape is currently only supported (experimentally) on Windows and Linux. Are there any efforts towards implementing this on macOS? (and removing it from its 'experimental' state)

  24. tisbutanalt2 commented on Mar 17, 2025

    @tisbutanalt2

    Referring to the workaround proposed by @LZQCN #1355 (comment) I suggest adding an additional check if the window won't have any moving elements.

    • Create variables for the last checked X and Y positions
    • Return if the current X and Y positions are the same

    Note: This is mostly useful only if your window does NOT have any moving elements.

  25. shady-xia commented on Apr 3, 2025

    @shady-xia

    After setting transparent on Windows, click-through functionality is enabled, but this currently does not work on Linux.
    My solution involves using setShape: by monitoring DOM changes via a MutationObserver, I retrieve the dimensions of each visible element, assemble them into a rect array representing the window, and then invoke setShape.

  26. deadcoder0904 commented on Aug 5, 2025

    @deadcoder0904
  27. added a commit that references this issue on Nov 7, 2025
  28. BryanEnid commented on Apr 6, 2026

    @BryanEnid

    I found a workaround.

    I have defined a global variable to toggle between "Interactive" or "click-through" in my front end. I set this value based on mouse events like onMouseEnter onMouseLeave, etc..

    which is then calling on the electron side this:

    export class ModeManager implements AppModule {
      enable({ app }: ModuleContext): void {
        ipcMain.on("set-mode", async (_, mode) => {
          const win = BrowserWindow.getAllWindows()[0];
    
          if (mode === "interactive") win.setIgnoreMouseEvents(false);
          if (mode === "click-through") win.setIgnoreMouseEvents(true, { forward: true });
        });
      }
    }

    In this way, I can click through transparent backgrounds and when the mouse is on top of an element it will make it interactive once more.

  29. Eneris commented on Jun 11, 2026

    @Eneris

    I found a workaround.

    I have defined a global variable to toggle between "Interactive" or "click-through" in my front end. I set this value based on mouse events like onMouseEnter onMouseLeave, etc..

    which is then calling on the electron side this:

    export class ModeManager implements AppModule {
    enable({ app }: ModuleContext): void {
    ipcMain.on("set-mode", async (_, mode) => {
    const win = BrowserWindow.getAllWindows()[0];

      if (mode === "interactive") win.setIgnoreMouseEvents(false);
      if (mode === "click-through") win.setIgnoreMouseEvents(true, { forward: true });
    });
    

    }
    }
    In this way, I can click through transparent backgrounds and when the mouse is on top of an element it will make it interactive once more.

    @BryanEnid Watch out for the bug on Windows when the cursor glitches and blinks while moving it over anything that changes the cursor shape when passing the mouse events

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions