views: Add WindowStateWatcher
This commit is contained in:
parent
84fcfd1fac
commit
06cc27c6b3
5 changed files with 66 additions and 0 deletions
2
atom.gyp
2
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',
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<GlobalMenuBarX11> global_menu_bar_;
|
||||
#endif
|
||||
|
||||
// Handles window state events.
|
||||
scoped_ptr<WindowStateWatcher> window_state_watcher_;
|
||||
|
||||
// Handles unhandled keyboard messages coming back from the renderer process.
|
||||
scoped_ptr<views::UnhandledKeyboardEventHandler> keyboard_event_handler_;
|
||||
|
||||
|
|
28
atom/browser/ui/views/window_state_watcher.cc
Normal file
28
atom/browser/ui/views/window_state_watcher.cc
Normal file
|
@ -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
|
28
atom/browser/ui/views/window_state_watcher.h
Normal file
28
atom/browser/ui/views/window_state_watcher.h
Normal file
|
@ -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
|
Loading…
Reference in a new issue