diff --git a/atom.gyp b/atom.gyp index 9805db874f80..61ace73f4e57 100644 --- a/atom.gyp +++ b/atom.gyp @@ -175,6 +175,8 @@ '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', diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 05a72fbe5596..beba0891f6da 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -13,6 +13,7 @@ #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" @@ -188,6 +189,9 @@ NativeWindowViews::NativeWindowViews(content::WebContents* web_contents, window_->Init(params); + // 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; diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index 97baa2a4630b..dd0e901e9857 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -22,6 +22,7 @@ namespace atom { class GlobalMenuBarX11; class MenuBar; +class WindowStateWatcher; class NativeWindowViews : public NativeWindow, public views::WidgetDelegateView, @@ -146,6 +147,9 @@ class NativeWindowViews : public NativeWindow, scoped_ptr global_menu_bar_; #endif + // Handles window state events. + scoped_ptr window_state_watcher_; + // Handles unhandled keyboard messages coming back from the renderer process. scoped_ptr keyboard_event_handler_; diff --git a/atom/browser/ui/views/window_state_watcher.cc b/atom/browser/ui/views/window_state_watcher.cc new file mode 100644 index 000000000000..2d4545226952 --- /dev/null +++ b/atom/browser/ui/views/window_state_watcher.cc @@ -0,0 +1,28 @@ +// Copyright (c) 2014 GitHub, Inc. +// 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 "ui/events/platform/platform_event_source.h" + +namespace atom { + +WindowStateWatcher::WindowStateWatcher(NativeWindowViews* window) + : window_(window), + widget_(window->GetAcceleratedWidget()) { + ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this); +} + +WindowStateWatcher::~WindowStateWatcher() { + ui::PlatformEventSource::GetInstance()->RemovePlatformEventObserver(this); +} + +void WindowStateWatcher::WillProcessEvent(const ui::PlatformEvent& event) { + LOG(ERROR) << "WillProcessEvent"; +} + +void WindowStateWatcher::DidProcessEvent(const ui::PlatformEvent& event) { +} + +} // namespace atom diff --git a/atom/browser/ui/views/window_state_watcher.h b/atom/browser/ui/views/window_state_watcher.h new file mode 100644 index 000000000000..b78086c29949 --- /dev/null +++ b/atom/browser/ui/views/window_state_watcher.h @@ -0,0 +1,28 @@ +// Copyright (c) 2014 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#include "ui/events/platform/platform_event_observer.h" + +#include "atom/browser/native_window_views.h" + +namespace atom { + +class WindowStateWatcher : public ui::PlatformEventObserver { + public: + explicit WindowStateWatcher(NativeWindowViews* window); + virtual ~WindowStateWatcher(); + + protected: + // ui::PlatformEventObserver: + void WillProcessEvent(const ui::PlatformEvent& event) override; + void DidProcessEvent(const ui::PlatformEvent& event) override; + + private: + NativeWindowViews* window_; + gfx::AcceleratedWidget widget_; + + DISALLOW_COPY_AND_ASSIGN(WindowStateWatcher); +}; + +} // namespace atom