Browse Source

Implement SetIgnoreMouseEvents for Windows

Cheng Zhao 9 years ago
parent
commit
cae25cab3e

+ 0 - 3
atom/browser/native_window.cc

@@ -281,9 +281,6 @@ bool NativeWindow::IsDocumentEdited() {
   return false;
 }
 
-void NativeWindow::SetIgnoreMouseEvents(bool ignore) {
-}
-
 void NativeWindow::SetMenu(ui::MenuModel* menu) {
 }
 

+ 1 - 1
atom/browser/native_window.h

@@ -154,7 +154,7 @@ class NativeWindow : public base::SupportsUserData,
   virtual std::string GetRepresentedFilename();
   virtual void SetDocumentEdited(bool edited);
   virtual bool IsDocumentEdited();
-  virtual void SetIgnoreMouseEvents(bool ignore);
+  virtual void SetIgnoreMouseEvents(bool ignore) = 0;
   virtual void SetMenu(ui::MenuModel* menu);
   virtual bool HasModalDialog();
   virtual gfx::NativeWindow GetNativeWindow() = 0;

+ 11 - 0
atom/browser/native_window_views.cc

@@ -672,6 +672,17 @@ bool NativeWindowViews::HasShadow() {
   return wm::GetShadowType(GetNativeWindow()) != wm::SHADOW_TYPE_NONE;
 }
 
+void NativeWindowViews::SetIgnoreMouseEvents(bool ignore) {
+#if defined(OS_WIN)
+  LONG ex_style = ::GetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE);
+  if (ignore)
+    ex_style |= (WS_EX_TRANSPARENT | WS_EX_LAYERED);
+  else
+    ex_style &= ~(WS_EX_TRANSPARENT | WS_EX_LAYERED);
+  ::SetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE, ex_style);
+#endif
+}
+
 void NativeWindowViews::SetMenu(ui::MenuModel* menu_model) {
   if (menu_model == nullptr) {
     // Remove accelerators

+ 1 - 0
atom/browser/native_window_views.h

@@ -91,6 +91,7 @@ class NativeWindowViews : public NativeWindow,
   void SetBackgroundColor(const std::string& color_name) override;
   void SetHasShadow(bool has_shadow) override;
   bool HasShadow() override;
+  void SetIgnoreMouseEvents(bool ignore) override;
   void SetMenu(ui::MenuModel* menu_model) override;
   gfx::NativeWindow GetNativeWindow() override;
   void SetOverlayIcon(const gfx::Image& overlay,