diff options
Diffstat (limited to 'views/window')
-rw-r--r-- | views/window/window_gtk.cc | 33 | ||||
-rw-r--r-- | views/window/window_gtk.h | 17 |
2 files changed, 28 insertions, 22 deletions
diff --git a/views/window/window_gtk.cc b/views/window/window_gtk.cc index 7e833cb..2a9fd97 100644 --- a/views/window/window_gtk.cc +++ b/views/window/window_gtk.cc @@ -68,7 +68,7 @@ GdkCursorType HitTestCodeToGdkCursorType(int hittest_code) { break; } // Default to something defaultish. - return GDK_ARROW; + return GDK_LEFT_PTR; } } // namespace @@ -76,6 +76,7 @@ GdkCursorType HitTestCodeToGdkCursorType(int hittest_code) { namespace views { WindowGtk::~WindowGtk() { + ActiveWindowWatcherX::RemoveObserver(this); } // static @@ -158,7 +159,7 @@ void WindowGtk::Restore() { } bool WindowGtk::IsActive() const { - return force_active_ || WidgetGtk::IsActive(); + return is_active_; } bool WindowGtk::IsVisible() const { @@ -189,7 +190,8 @@ void WindowGtk::EnableClose(bool enable) { } void WindowGtk::DisableInactiveRendering() { - force_active_ = true; + // TODO(sky): this doesn't make sense as bubbles are popups, which don't + // trigger a change in active status. } void WindowGtk::UpdateWindowTitle() { @@ -336,9 +338,17 @@ gboolean WindowGtk::OnWindowStateEvent(GtkWidget* widget, return FALSE; } +void WindowGtk::ActiveWindowChanged(GdkWindow* active_window) { + if (!GetNativeWindow()) + return; + + bool was_active = IsActive(); + is_active_ = (active_window == GTK_WIDGET(GetNativeWindow())->window); + if (was_active != IsActive()) + IsActiveChanged(); +} + void WindowGtk::IsActiveChanged() { - if (force_active_ && WidgetGtk::IsActive()) - force_active_ = false; } //////////////////////////////////////////////////////////////////////////////// @@ -351,9 +361,11 @@ WindowGtk::WindowGtk(WindowDelegate* window_delegate) non_client_view_(new NonClientView(this)), window_state_(GDK_WINDOW_STATE_WITHDRAWN), window_closed_(false), - force_active_(false) { + is_active_(false) { is_window_ = true; window_delegate_->window_.reset(this); + + ActiveWindowWatcherX::AddObserver(this); } void WindowGtk::Init(GtkWindow* parent, const gfx::Rect& bounds) { @@ -369,8 +381,6 @@ void WindowGtk::Init(GtkWindow* parent, const gfx::Rect& bounds) { g_signal_connect(G_OBJECT(GetNativeWindow()), "configure-event", G_CALLBACK(CallConfigureEvent), this); - g_signal_connect(G_OBJECT(GetNativeWindow()), "notify::is-active", - G_CALLBACK(CallIsActiveChanged), this); g_signal_connect(G_OBJECT(GetNativeWindow()), "window-state-event", G_CALLBACK(CallWindowStateEvent), this); @@ -403,13 +413,6 @@ gboolean WindowGtk::CallConfigureEvent(GtkWidget* widget, } // static -void WindowGtk::CallIsActiveChanged(GtkWidget* widget, - GParamSpec* pspec, - WindowGtk* window_gtk) { - return window_gtk->IsActiveChanged(); -} - -// static gboolean WindowGtk::CallWindowStateEvent(GtkWidget* widget, GdkEventWindowState* event, WindowGtk* window_gtk) { diff --git a/views/window/window_gtk.h b/views/window/window_gtk.h index 74482ad..5149f60 100644 --- a/views/window/window_gtk.h +++ b/views/window/window_gtk.h @@ -5,6 +5,7 @@ #ifndef VIEWS_WINDOW_WINDOW_GTK_H_ #define VIEWS_WINDOW_WINDOW_GTK_H_ +#include "app/active_window_watcher_x.h" #include "base/basictypes.h" #include "views/widget/widget_gtk.h" #include "views/window/window.h" @@ -20,7 +21,9 @@ class Client; class WindowDelegate; // Window implementation for GTK. -class WindowGtk : public WidgetGtk, public Window { +class WindowGtk : public WidgetGtk, + public Window, + public ActiveWindowWatcherX::Observer { public: virtual ~WindowGtk(); @@ -68,7 +71,11 @@ class WindowGtk : public WidgetGtk, public Window { virtual gboolean OnWindowStateEvent(GtkWidget* widget, GdkEventWindowState* event); + // Overriden from ActiveWindowWatcherX::Observer. + virtual void ActiveWindowChanged(GdkWindow* active_window); + // WindowGtk specific. + // Invoked when the active status changes. virtual void IsActiveChanged(); protected: @@ -85,9 +92,6 @@ class WindowGtk : public WidgetGtk, public Window { static gboolean CallConfigureEvent(GtkWidget* widget, GdkEventConfigure* event, WindowGtk* window_gtk); - static void CallIsActiveChanged(GtkWidget* widget, - GParamSpec* pspec, - WindowGtk* window_gtk); static gboolean CallWindowStateEvent(GtkWidget* widget, GdkEventWindowState* event, WindowGtk* window_gtk); @@ -118,9 +122,8 @@ class WindowGtk : public WidgetGtk, public Window { // Set to true if the window is in the process of closing. bool window_closed_; - // If true, IsActive returns true. This is set by DisableInactiveRendering - // to force the window to be treated as active even though it isn't. - bool force_active_; + // Are we active? + bool is_active_; DISALLOW_COPY_AND_ASSIGN(WindowGtk); }; |