Add window opacity support

This commit is contained in:
Ted Kim 2017-09-29 11:26:02 +09:00
parent 0c9ada08a4
commit 7f2c4a9e06
11 changed files with 57 additions and 0 deletions

View file

@ -814,6 +814,19 @@ bool NativeWindowViews::HasShadow() {
!= wm::ShadowElevation::NONE;
}
void NativeWindowViews::SetOpacity(const double opacity) {
#if defined(OS_WIN)
if (!layered_) {
LONG ex_style = ::GetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE);
ex_style |= WS_EX_LAYERED;
::SetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE, ex_style);
layered_ = true;
}
::SetLayeredWindowAttributes(GetAcceleratedWidget(), 0, opacity * 255, LWA_ALPHA);
#endif
}
void NativeWindowViews::SetIgnoreMouseEvents(bool ignore, bool forward) {
#if defined(OS_WIN)
LONG ex_style = ::GetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE);
@ -821,6 +834,8 @@ void NativeWindowViews::SetIgnoreMouseEvents(bool ignore, bool forward) {
ex_style |= (WS_EX_TRANSPARENT | WS_EX_LAYERED);
else
ex_style &= ~(WS_EX_TRANSPARENT | WS_EX_LAYERED);
if (layered_)
ex_style |= WS_EX_LAYERED;
::SetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE, ex_style);
// Forwarding is always disabled when not ignoring mouse messages.