8000 feat: allow setting window shape (#13789) (backport 2-1-x) by nornagon · Pull Request #13989 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: allow setting window shape (#13789) (backport 2-1-x) #13989

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 9, 2018

Conversation

nornagon
Copy link
Contributor
@nornagon nornagon commented Aug 8, 2018

This binds Widget::SetShape, an API that already exists in Chromium (for
Windows and Linux). It's a more reliable method of having some parts of
your window be "click-through" than the current setIgnoreMouseEvents
API, which messes around with the WS_EX_LAYERED window style on
Windows, causing strange bugs and incompatibility with hardware
acceleration.

@nornagon nornagon requested review from a team August 8, 2018 21:38
@nornagon nornagon force-pushed the backport-setshape branch from a2090c1 to 4c3d310 Compare August 8, 2018 21:41
Copy link
Member
@ckerr ckerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to be targeted to 2-1-x, not 2-0-x

@ckerr ckerr added the semver/minor backwards-compatible functionality label Aug 8, 2018
@nornagon nornagon changed the base branch from 2-0-x to 2-1-x August 8, 2018 22:04
@nornagon nornagon force-pushed the backport-setshape branch 3 times, most recently from 4f73dae to 055ab61 Compare August 8, 2018 22:33
This binds Widget::SetShape, an API that already exists in Chromium (for
Windows and Linux). It's a more reliable method of having some parts of
your window be "click-through" than the current `setIgnoreMouseEvents`
API, which messes around with the `WS_EX_LAYERED` window style on
Windows, causing strange bugs and incompatibility with hardware
acceleration.
@nornagon nornagon force-pushed the backport-setshape branch from 055ab61 to d74e25f Compare August 8, 2018 23:09
Copy link
Member
@ckerr ckerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work wrt keeping the patch simple. The static_cast is probably the least bad option wrt getting the view::Widget.

auto native_window_views = static_cast<NativeWindowViews*>(window_.get());
auto shape = base::MakeUnique<SkRegion>();
for (const auto& rect : rects)
shape->op(gfx::RectToSkIRect(rect), SkRegion::kUnion_Op);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SkRegion::setRects() documentation suggests it be used instead of the above:

    /**
     *  Set this region to the union of an array of rects. This is generally
     *  faster than calling region.op(rect, kUnion_Op) in a loop. If count is
     *  0, then this region is set to the empty region.
     *  @return true if the resulting region is non-empty
     */
    bool setRects(const SkIRect rects[], int count);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh! I copied this code from the DesktopWindowTreeHostX11::SetShape code.

@MarshallOfSound MarshallOfSound changed the title feat: allow setting window shape (#13789) (backport 2-0-x) feat: allow setting window shape (#13789) (backport 2-1-x) Aug 9, 2018
@ckerr ckerr merged commit 8683ba3 into 2-1-x Aug 9, 2018
@ckerr ckerr deleted the backport-setshape branch August 9, 2018 04:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/minor backwards-compatible functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0