Skip to content

Hit testing is wrong for drag areas in frameless window (Windows) #7347

Closed

Description

@bsclifton
  • Electron version:
    1.4.1
  • Operating system:
    Windows 7 Pro, x64 (with display set to 150%)

Problem description
When using a BrowserWindow with frame: false, electron does not always appear to be doing proper hit testing (mouse over, click, etc) for draggable areas. It works great with my stock Windows settings, but if you scale up your display to 150% it breaks. Unfortunately, some laptops/PCs ship with this setting NOT being 100%.

Steps to reproduce

  • Have a machine w/ Windows 7 (physical or VM)
  • Right click desktop, pick Personalize
  • Click display in the bottom left corner
  • Pick 150% and hit apply
    win7-magnifier
  • open a shell and clone my demo project:
    • git clone [email protected]:bsclifton/electron-quick-start.git
    • cd electron-quick-start
    • npm start
  • You'll see the following:
    screen shot 2016-09-25 at 11 31 11 pm

The red area is tagged with -webkit-app-region: drag and the overlapping yellow area is tagged with -webkit-app-region: no-drag.

  • Try clicking and dragging in the red area. You'll notice it's inconsistent.
  • Close program, set display scaling back to 100% and relaunch program
  • Notice that dragging works great

Activity

  1. bsclifton commented on Sep 26, 2016

    @bsclifton
    ContributorAuthor

    Dug in some more, here are my current findings:
    When at 150% display size, the cursor is reporting the wrong position. Here's a quick screenshot I put together:
    image

    Quick overview for the colors / how to read this:

    • red colored divs are ones w/ -webkit-app-region: drag
    • yellow colored divs are ones w/ -webkit-app-region: no-drag
    • blue colored divs are ones I manually plotted (coords obtained by dumping the RECTs out of the draggable_region member variable using an iterator. This change was made in atom/browser/ui/views/frameless_view.cc::NonClientHitTest())

    You'll also notice (gotta look close) a brown X in the bottom right. I added some code to electron to write the cursor position and noticed that:

    • in the above example, I physically put my cursor where the brown X is (bottom right)
    • electron reports the coordinates for my cursor being where the aqua colored X is (above and left of the brown X). This is off by ~277 pixels on the X axis and 27 on the Y axis.

    Looking deeper into the code now...

  2. bsclifton commented on Sep 26, 2016

    @bsclifton
    ContributorAuthor

    No progress made, still digging. The hitboxes which exist in draggable_region are correct. However, the mouse coordinates are not. Since my resolution is set to 150%, I can get the proper coordinates by multiplying the x and y by 1.5. I'm trying to find the code which is capturing the mouse coordinates, to understand why it's capturing them wrong.

  3. bsclifton commented on Sep 27, 2016

    @bsclifton
    ContributorAuthor

    Root cause found and fixed in my fork with https://github.com/bsclifton/electron/commit/f217aa0d588aa2a513e962a94d3b34c87e2b8462

    I'll submit an upstream patch soon 😄 Special thanks to @bridiver for digging in with me and finding the missing call

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