-
Notifications
You must be signed in to change notification settings - Fork 16.2k
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
Conversation
a2090c1
to
4c3d310
Compare
There was a problem hiding this 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
4f73dae
to
055ab61
Compare
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.
055ab61
to
d74e25f
Compare
There was a problem hiding this 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); |
There was a problem hiding this comment.
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);
There was a problem hiding this comment.
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.
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 onWindows, causing strange bugs and incompatibility with hardware
acceleration.