]> khamidou — GitHub mirrors - electron.git/commitdiff
Make WindowStateWatcher X11 only
authorCheng Zhao <zcbenz@gmail.com>
Tue, 25 Nov 2014 05:05:04 +0000 (13:05 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Tue, 25 Nov 2014 05:05:04 +0000 (13:05 +0800)
On Windows we need to take another way of detecting window state events.

atom.gyp
atom/browser/native_window_views.cc
atom/browser/native_window_views.h
atom/browser/ui/x/window_state_watcher.cc [moved from atom/browser/ui/views/window_state_watcher.cc with 93% similarity]
atom/browser/ui/x/window_state_watcher.h [moved from atom/browser/ui/views/window_state_watcher.h with 85% similarity]

index 61ace73f4e5765cb6b361f45271e37d5223c2691..c0afe970d716899d1dffacb7bccf49d2e547bb99 100644 (file)
--- a/atom.gyp
+++ b/atom.gyp
       'atom/browser/ui/views/submenu_button.h',
       'atom/browser/ui/views/win_frame_view.cc',
       'atom/browser/ui/views/win_frame_view.h',
-      'atom/browser/ui/views/window_state_watcher.cc',
-      'atom/browser/ui/views/window_state_watcher.h',
       'atom/browser/ui/win/notify_icon_host.cc',
       'atom/browser/ui/win/notify_icon_host.h',
       'atom/browser/ui/win/notify_icon.cc',
       'atom/browser/ui/win/notify_icon.h',
+      'atom/browser/ui/x/window_state_watcher.cc',
+      'atom/browser/ui/x/window_state_watcher.h',
       'atom/browser/ui/x/x_window_utils.cc',
       'atom/browser/ui/x/x_window_utils.h',
       'atom/browser/web_view/web_view_manager.cc',
index beba0891f6da89cd2a9fccf6c3f212bec90b38cd..ae291b9977357dc7a5cd33cb87994278f4d76615 100644 (file)
@@ -13,7 +13,6 @@
 
 #include "atom/browser/ui/views/menu_bar.h"
 #include "atom/browser/ui/views/menu_layout.h"
-#include "atom/browser/ui/views/window_state_watcher.h"
 #include "atom/common/draggable_region.h"
 #include "atom/common/options_switches.h"
 #include "base/strings/utf_string_conversions.h"
@@ -33,6 +32,7 @@
 #include "atom/browser/browser.h"
 #include "atom/browser/ui/views/global_menu_bar_x11.h"
 #include "atom/browser/ui/views/frameless_view.h"
+#include "atom/browser/ui/x/window_state_watcher.h"
 #include "atom/browser/ui/x/x_window_utils.h"
 #include "base/environment.h"
 #include "base/nix/xdg_util.h"
@@ -189,10 +189,10 @@ NativeWindowViews::NativeWindowViews(content::WebContents* web_contents,
 
   window_->Init(params);
 
+#if defined(USE_X11)
   // Start monitoring window states.
   window_state_watcher_.reset(new WindowStateWatcher(this));
 
-#if defined(USE_X11)
   // Set _GTK_THEME_VARIANT to dark if we have "dark-theme" option set.
   bool use_dark_theme = false;
   if (options.Get(switches::kDarkTheme, &use_dark_theme) && use_dark_theme) {
index dd0e901e9857b3c64a28c4de78217e86217cf551..f15f5cb7ceac85bae33fc903e157e6d1b631254a 100644 (file)
@@ -145,10 +145,10 @@ class NativeWindowViews : public NativeWindow,
 
 #if defined(USE_X11)
   scoped_ptr<GlobalMenuBarX11> global_menu_bar_;
-#endif
 
   // Handles window state events.
   scoped_ptr<WindowStateWatcher> window_state_watcher_;
+#endif
 
   // Handles unhandled keyboard messages coming back from the renderer process.
   scoped_ptr<views::UnhandledKeyboardEventHandler> keyboard_event_handler_;
similarity index 93%
rename from atom/browser/ui/views/window_state_watcher.cc
rename to atom/browser/ui/x/window_state_watcher.cc
index 53feafe1c184add321acfd6a50b18bed2f536a31..e1b2716b868f2c441ea43b7b9cf2b31ac1c1f300 100644 (file)
@@ -2,11 +2,9 @@
 // Use of this source code is governed by the MIT license that can be
 // found in the LICENSE file.
 
-#include "atom/browser/ui/views/window_state_watcher.h"
+#include "atom/browser/ui/x/window_state_watcher.h"
 
-#if defined(USE_X11)
 #include <X11/Xlib.h>
-#endif
 
 #include "ui/events/platform/platform_event_source.h"
 
@@ -24,9 +22,7 @@ const char* kAtomsToCache[] = {
 WindowStateWatcher::WindowStateWatcher(NativeWindowViews* window)
     : window_(window),
       widget_(window->GetAcceleratedWidget()),
-#if defined(USE_X11)
       atom_cache_(gfx::GetXDisplay(), kAtomsToCache),
-#endif
       was_minimized_(false),
       was_maximized_(false) {
   ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this);
@@ -73,14 +69,10 @@ void WindowStateWatcher::DidProcessEvent(const ui::PlatformEvent& event) {
 }
 
 bool WindowStateWatcher::IsWindowStateEvent(const ui::PlatformEvent& event) {
-#if defined(USE_X11)
   ::Atom changed_atom = event->xproperty.atom;
   return (changed_atom == atom_cache_.GetAtom("_NET_WM_STATE") &&
           event->type == PropertyNotify &&
           event->xproperty.window == widget_);
-#else
-  return false;
-#endif
 }
 
 }  // namespace atom
similarity index 85%
rename from atom/browser/ui/views/window_state_watcher.h
rename to atom/browser/ui/x/window_state_watcher.h
index 17ad64024a61ed05981ecd7c7bdd4a2f62c02b43..2888c9fc6fec1e68c33479c06c1c017608fa43c1 100644 (file)
@@ -2,13 +2,13 @@
 // Use of this source code is governed by the MIT license that can be
 // found in the LICENSE file.
 
+#ifndef ATOM_BROWSER_UI_X_WINDOW_STATE_WATCHER_H_
+#define ATOM_BROWSER_UI_X_WINDOW_STATE_WATCHER_H_
+
 #include "ui/events/platform/platform_event_observer.h"
 
 #include "atom/browser/native_window_views.h"
-
-#if defined(USE_X11)
 #include "ui/gfx/x/x11_atom_cache.h"
-#endif
 
 namespace atom {
 
@@ -28,9 +28,7 @@ class WindowStateWatcher : public ui::PlatformEventObserver {
   NativeWindowViews* window_;
   gfx::AcceleratedWidget widget_;
 
-#if defined(USE_X11)
   ui::X11AtomCache atom_cache_;
-#endif
 
   bool was_minimized_;
   bool was_maximized_;
@@ -39,3 +37,5 @@ class WindowStateWatcher : public ui::PlatformEventObserver {
 };
 
 }  // namespace atom
+
+#endif  // ATOM_BROWSER_UI_X_WINDOW_STATE_WATCHER_H_