Make WindowStateWatcher X11 only
On Windows we need to take another way of detecting window state events.
This commit is contained in:
parent
b77e6c369a
commit
588cc3c7ab
5 changed files with 11 additions and 19 deletions
4
atom.gyp
4
atom.gyp
|
@ -175,12 +175,12 @@
|
||||||
'atom/browser/ui/views/submenu_button.h',
|
'atom/browser/ui/views/submenu_button.h',
|
||||||
'atom/browser/ui/views/win_frame_view.cc',
|
'atom/browser/ui/views/win_frame_view.cc',
|
||||||
'atom/browser/ui/views/win_frame_view.h',
|
'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.cc',
|
||||||
'atom/browser/ui/win/notify_icon_host.h',
|
'atom/browser/ui/win/notify_icon_host.h',
|
||||||
'atom/browser/ui/win/notify_icon.cc',
|
'atom/browser/ui/win/notify_icon.cc',
|
||||||
'atom/browser/ui/win/notify_icon.h',
|
'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.cc',
|
||||||
'atom/browser/ui/x/x_window_utils.h',
|
'atom/browser/ui/x/x_window_utils.h',
|
||||||
'atom/browser/web_view/web_view_manager.cc',
|
'atom/browser/web_view/web_view_manager.cc',
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
#include "atom/browser/ui/views/menu_bar.h"
|
#include "atom/browser/ui/views/menu_bar.h"
|
||||||
#include "atom/browser/ui/views/menu_layout.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/draggable_region.h"
|
||||||
#include "atom/common/options_switches.h"
|
#include "atom/common/options_switches.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
|
@ -33,6 +32,7 @@
|
||||||
#include "atom/browser/browser.h"
|
#include "atom/browser/browser.h"
|
||||||
#include "atom/browser/ui/views/global_menu_bar_x11.h"
|
#include "atom/browser/ui/views/global_menu_bar_x11.h"
|
||||||
#include "atom/browser/ui/views/frameless_view.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 "atom/browser/ui/x/x_window_utils.h"
|
||||||
#include "base/environment.h"
|
#include "base/environment.h"
|
||||||
#include "base/nix/xdg_util.h"
|
#include "base/nix/xdg_util.h"
|
||||||
|
@ -189,10 +189,10 @@ NativeWindowViews::NativeWindowViews(content::WebContents* web_contents,
|
||||||
|
|
||||||
window_->Init(params);
|
window_->Init(params);
|
||||||
|
|
||||||
|
#if defined(USE_X11)
|
||||||
// Start monitoring window states.
|
// Start monitoring window states.
|
||||||
window_state_watcher_.reset(new WindowStateWatcher(this));
|
window_state_watcher_.reset(new WindowStateWatcher(this));
|
||||||
|
|
||||||
#if defined(USE_X11)
|
|
||||||
// Set _GTK_THEME_VARIANT to dark if we have "dark-theme" option set.
|
// Set _GTK_THEME_VARIANT to dark if we have "dark-theme" option set.
|
||||||
bool use_dark_theme = false;
|
bool use_dark_theme = false;
|
||||||
if (options.Get(switches::kDarkTheme, &use_dark_theme) && use_dark_theme) {
|
if (options.Get(switches::kDarkTheme, &use_dark_theme) && use_dark_theme) {
|
||||||
|
|
|
@ -145,10 +145,10 @@ class NativeWindowViews : public NativeWindow,
|
||||||
|
|
||||||
#if defined(USE_X11)
|
#if defined(USE_X11)
|
||||||
scoped_ptr<GlobalMenuBarX11> global_menu_bar_;
|
scoped_ptr<GlobalMenuBarX11> global_menu_bar_;
|
||||||
#endif
|
|
||||||
|
|
||||||
// Handles window state events.
|
// Handles window state events.
|
||||||
scoped_ptr<WindowStateWatcher> window_state_watcher_;
|
scoped_ptr<WindowStateWatcher> window_state_watcher_;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Handles unhandled keyboard messages coming back from the renderer process.
|
// Handles unhandled keyboard messages coming back from the renderer process.
|
||||||
scoped_ptr<views::UnhandledKeyboardEventHandler> keyboard_event_handler_;
|
scoped_ptr<views::UnhandledKeyboardEventHandler> keyboard_event_handler_;
|
||||||
|
|
|
@ -2,11 +2,9 @@
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// 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>
|
#include <X11/Xlib.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "ui/events/platform/platform_event_source.h"
|
#include "ui/events/platform/platform_event_source.h"
|
||||||
|
|
||||||
|
@ -24,9 +22,7 @@ const char* kAtomsToCache[] = {
|
||||||
WindowStateWatcher::WindowStateWatcher(NativeWindowViews* window)
|
WindowStateWatcher::WindowStateWatcher(NativeWindowViews* window)
|
||||||
: window_(window),
|
: window_(window),
|
||||||
widget_(window->GetAcceleratedWidget()),
|
widget_(window->GetAcceleratedWidget()),
|
||||||
#if defined(USE_X11)
|
|
||||||
atom_cache_(gfx::GetXDisplay(), kAtomsToCache),
|
atom_cache_(gfx::GetXDisplay(), kAtomsToCache),
|
||||||
#endif
|
|
||||||
was_minimized_(false),
|
was_minimized_(false),
|
||||||
was_maximized_(false) {
|
was_maximized_(false) {
|
||||||
ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this);
|
ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this);
|
||||||
|
@ -73,14 +69,10 @@ void WindowStateWatcher::DidProcessEvent(const ui::PlatformEvent& event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WindowStateWatcher::IsWindowStateEvent(const ui::PlatformEvent& event) {
|
bool WindowStateWatcher::IsWindowStateEvent(const ui::PlatformEvent& event) {
|
||||||
#if defined(USE_X11)
|
|
||||||
::Atom changed_atom = event->xproperty.atom;
|
::Atom changed_atom = event->xproperty.atom;
|
||||||
return (changed_atom == atom_cache_.GetAtom("_NET_WM_STATE") &&
|
return (changed_atom == atom_cache_.GetAtom("_NET_WM_STATE") &&
|
||||||
event->type == PropertyNotify &&
|
event->type == PropertyNotify &&
|
||||||
event->xproperty.window == widget_);
|
event->xproperty.window == widget_);
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
|
@ -2,13 +2,13 @@
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// 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 "ui/events/platform/platform_event_observer.h"
|
||||||
|
|
||||||
#include "atom/browser/native_window_views.h"
|
#include "atom/browser/native_window_views.h"
|
||||||
|
|
||||||
#if defined(USE_X11)
|
|
||||||
#include "ui/gfx/x/x11_atom_cache.h"
|
#include "ui/gfx/x/x11_atom_cache.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
|
@ -28,9 +28,7 @@ class WindowStateWatcher : public ui::PlatformEventObserver {
|
||||||
NativeWindowViews* window_;
|
NativeWindowViews* window_;
|
||||||
gfx::AcceleratedWidget widget_;
|
gfx::AcceleratedWidget widget_;
|
||||||
|
|
||||||
#if defined(USE_X11)
|
|
||||||
ui::X11AtomCache atom_cache_;
|
ui::X11AtomCache atom_cache_;
|
||||||
#endif
|
|
||||||
|
|
||||||
bool was_minimized_;
|
bool was_minimized_;
|
||||||
bool was_maximized_;
|
bool was_maximized_;
|
||||||
|
@ -39,3 +37,5 @@ class WindowStateWatcher : public ui::PlatformEventObserver {
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
||||||
|
#endif // ATOM_BROWSER_UI_X_WINDOW_STATE_WATCHER_H_
|
Loading…
Add table
Reference in a new issue