views: Make transparent window work
This commit is contained in:
		
					parent
					
						
							
								85685feff4
							
						
					
				
			
			
				commit
				
					
						1a34e09a45
					
				
			
		
					 1 changed files with 17 additions and 1 deletions
				
			
		| 
						 | 
					@ -28,6 +28,7 @@
 | 
				
			||||||
#include "ui/views/window/client_view.h"
 | 
					#include "ui/views/window/client_view.h"
 | 
				
			||||||
#include "ui/views/widget/native_widget_private.h"
 | 
					#include "ui/views/widget/native_widget_private.h"
 | 
				
			||||||
#include "ui/views/widget/widget.h"
 | 
					#include "ui/views/widget/widget.h"
 | 
				
			||||||
 | 
					#include "ui/wm/core/shadow_types.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(USE_X11)
 | 
					#if defined(USE_X11)
 | 
				
			||||||
#include "atom/browser/browser.h"
 | 
					#include "atom/browser/browser.h"
 | 
				
			||||||
| 
						 | 
					@ -183,6 +184,9 @@ NativeWindowViews::NativeWindowViews(content::WebContents* web_contents,
 | 
				
			||||||
  params.type = views::Widget::InitParams::TYPE_WINDOW;
 | 
					  params.type = views::Widget::InitParams::TYPE_WINDOW;
 | 
				
			||||||
  params.remove_standard_frame = !has_frame_;
 | 
					  params.remove_standard_frame = !has_frame_;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (transparent_)
 | 
				
			||||||
 | 
					    params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(USE_X11)
 | 
					#if defined(USE_X11)
 | 
				
			||||||
  std::string name = Browser::Get()->GetName();
 | 
					  std::string name = Browser::Get()->GetName();
 | 
				
			||||||
  // Set WM_WINDOW_ROLE.
 | 
					  // Set WM_WINDOW_ROLE.
 | 
				
			||||||
| 
						 | 
					@ -232,13 +236,20 @@ NativeWindowViews::NativeWindowViews(content::WebContents* web_contents,
 | 
				
			||||||
    bounds = ContentBoundsToWindowBounds(bounds);
 | 
					    bounds = ContentBoundsToWindowBounds(bounds);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(OS_WIN)
 | 
					#if defined(OS_WIN)
 | 
				
			||||||
  if (!has_frame_) {
 | 
					  if (!transparent_ && !has_frame_) {
 | 
				
			||||||
    // Set Window style so that we get a minimize and maximize animation when
 | 
					    // Set Window style so that we get a minimize and maximize animation when
 | 
				
			||||||
    // frameless.
 | 
					    // frameless.
 | 
				
			||||||
    DWORD frame_style = WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX |
 | 
					    DWORD frame_style = WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX |
 | 
				
			||||||
                        WS_CAPTION;
 | 
					                        WS_CAPTION;
 | 
				
			||||||
    ::SetWindowLong(GetAcceleratedWidget(), GWL_STYLE, frame_style);
 | 
					    ::SetWindowLong(GetAcceleratedWidget(), GWL_STYLE, frame_style);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (transparent_) {
 | 
				
			||||||
 | 
					    // Transparent window on Windows has to have WS_EX_COMPOSITED style.
 | 
				
			||||||
 | 
					    LONG ex_style = ::GetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE);
 | 
				
			||||||
 | 
					    ex_style |= WS_EX_COMPOSITED;
 | 
				
			||||||
 | 
					    ::SetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE, ex_style);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // TODO(zcbenz): This was used to force using native frame on Windows 2003, we
 | 
					  // TODO(zcbenz): This was used to force using native frame on Windows 2003, we
 | 
				
			||||||
| 
						 | 
					@ -248,6 +259,11 @@ NativeWindowViews::NativeWindowViews(content::WebContents* web_contents,
 | 
				
			||||||
    window_->FrameTypeChanged();
 | 
					    window_->FrameTypeChanged();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // The given window is most likely not rectangular since it uses
 | 
				
			||||||
 | 
					  // transparency and has no standard frame, don't show a shadow for it.
 | 
				
			||||||
 | 
					  if (transparent_ && !has_frame_)
 | 
				
			||||||
 | 
					    wm::SetShadowType(GetNativeWindow(), wm::SHADOW_TYPE_NONE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  window_->UpdateWindowIcon();
 | 
					  window_->UpdateWindowIcon();
 | 
				
			||||||
  window_->CenterWindow(bounds.size());
 | 
					  window_->CenterWindow(bounds.size());
 | 
				
			||||||
  Layout();
 | 
					  Layout();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue