Skip to content

Resize cursor appears too quickly on right edge when frame: false #27247

Closed as not planned

Description

@rzhao271

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version:
    • 11.1.1
  • Operating System:
    • Windows 10
  • Last Known Working Electron version:
    • N/A

Expected Behavior

A user usually has to move their cursor very close to the right edge of the window in order for their cursor to change to a resize cursor.
Even when frame: false, this should be the case.

Actual Behavior

In reality, the cursor becomes a resize cursor when the user has moved their cursor to around 25% of the scrollbar width from the right edge of the window.

To Reproduce

Fiddle
https://gist.github.com/rzhao271/cfb7c876b47992c93f7238c7b3038642

Screenshots

See microsoft/vscode#102023 (comment) for animated examples.

Activity

  1. joezappie commented on Feb 19, 2021

    @joezappie

    Any progress on this? I have about a 5px margin around my entire app where the cursor events dont get passed to my app. Wasnt an issue until I needed a scroll bar and then it became apparent this was happening. I have a frameless window thats not resizable, running on Windows 10. I'm seeing exactly what OP had in the animated examples.

  2. rzhao271 commented on Feb 19, 2021

    @rzhao271
    ContributorAuthor

    Now that I got my local clone of the repo set up a bit more properly, I searched through the code a bit and found the following line:
    https://github.com/electron/electron/blob/master/shell/browser/ui/views/frameless_view.cc#L18
    which is used here
    https://github.com/electron/electron/blob/master/shell/browser/ui/views/frameless_view.cc#L35
    and the GetHTComponentForFrame part refers to https://source.chromium.org/chromium/chromium/src/+/master:ui/views/window/non_client_view.cc;l=45?q=non_client_view&ss=chromium

    I find it pretty funny how the margin set turns out to be exactly 5px.

    Changing the value to a non-positive integer didn't work, and changing the value to 1 fixed the issue of the resize cursor appearing too quickly, but it also made resizing the window when I actually wanted to resize it much harder. I think what is happening, is that as soon as the cursor leaves the window, the resize cursor disappears, whereas with the with-frame window, even when the cursor leaves what appears to be the window, there is actually still a slight margin where the resize cursor still shows. I think that difference is why there is this extra margin added to the frameless window, but I'm not sure how one would go about fixing this.

  3. joezappie commented on Feb 19, 2021

    @joezappie

    Interesting find. Yeah, looking at other apps the resize cursor should appear only on the outside of the window for about 10px (basically the size of the shadow). Changing to a non frameless window works in that way. Does there appear to be an outer window padding at all?

    Your attempt to fix the issue would fix it in my particular scenario. My frameless window is set to non resizable so the issue of being hard to resize wouldnt matter. A possible fix for that scenario would be to set it to 1 if resizable is set to false. It probably would be better to figure out how to make the resizable area larger though and remove the inner margin to fix it in all cases.

  4. joezappie commented on Feb 19, 2021

    @joezappie

    I haven't dove into the code for this very deep yet, but my initial though is there is a window mask, maybe that needs to be bigger by 5px so that the window is actually slightly larger than the real window? Not sure if that is what the mask is for but thats just my initial thought.

  5. rzhao271 commented on Mar 1, 2021

    @rzhao271
    ContributorAuthor

    @zcbenz I noticed you wrote the code related to the frameless window, and I also know it's been several years since that initial implementation, but I'm wondering if you have any code pointers or thoughts on this issue?

  6. asd281533890 commented on Jul 7, 2022

    @asd281533890

    I solved this problem in a less elegant way. Here is the code:

    // mainProcess.js
    // mainWindow is an instance of BrowserWindow
    const { screen } = require('electron')
    
    let mainWindowBounds = {}
    let mainWindowResizable = true
    
    setInterval(() => {
      if (!mainWindow || mainWindow.isDestroyed() || !mainWindow.isVisible()) return
      const mousePosition = screen.getCursorScreenPoint()
      const enable = (
        mousePosition.x > (mainWindowBounds.x + mainWindowBounds.width + (mainWindowResizable ? -6 : -1)) ||
        mousePosition.y > (mainWindowBounds.y + mainWindowBounds.height+ (mainWindowResizable ? -6 : -1))
      )
      if (enable !== mainWindow.isResizable()) {
        mainWindow.setResizable(enable)
        mainWindowResizable = enable
      }
    }, 100)
    
    function updateMainWindowBounds () {
      if (!mainWindow || mainWindow.isDestroyed()) return
      mainWindowBounds = mainWindow.getBounds()
    }
    mainWindow.on('resized', updateMainWindowBounds)
    mainWindow.on('moved', updateMainWindowBounds)
  7. github-actions commented on Oct 6, 2022

    @github-actions
    Contributor

    This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

  8. rzhao271 commented on Oct 7, 2022

    @rzhao271
    ContributorAuthor

    Closing as wontfix

  9. rzhao271 commented on Nov 10, 2023

    @rzhao271
    ContributorAuthor

    I'll reopen this issue in a bit because we've yet another downstream issue that has to do with the incongruency between frameless and non-frameless windows in Electron.

    Downstream issue: microsoft/vscode#185249

    TODO before reopen:

    • Upload new gist
    • Write down new Electron versions that the issue reproduces on
  10. rzhao271 commented on Nov 10, 2023

    @rzhao271
    ContributorAuthor

    Actually, I'll create a new issue because the context is a bit different now.

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