summaryrefslogtreecommitdiffstats
path: root/views/widget
diff options
context:
space:
mode:
authorjohnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-04 22:12:02 +0000
committerjohnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-04 22:12:02 +0000
commitb71f818c64df5a5d8501a37da84ce4c7cae494fa (patch)
treeee3ca693c1b349f6ccc0d340346811e2f1f681c5 /views/widget
parent177ac431c361d9bcec1350d3f622ae82b471f1ae (diff)
downloadchromium_src-b71f818c64df5a5d8501a37da84ce4c7cae494fa.zip
chromium_src-b71f818c64df5a5d8501a37da84ce4c7cae494fa.tar.gz
chromium_src-b71f818c64df5a5d8501a37da84ce4c7cae494fa.tar.bz2
On Windows, detect the WM_DISPLAYCHANGE message which indicates the desktop size is changing. Pass this event using the NotificationService, and listen for it in desktop notification code in order to adjust metrics properly for the corner of the screen.
BUG=35464 TEST=resize desktop after starting chrome; create notifications. Review URL: http://codereview.chromium.org/606007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40670 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget')
-rw-r--r--views/widget/widget.h7
-rwxr-xr-xviews/widget/widget_delegate.h23
-rw-r--r--views/widget/widget_gtk.cc11
-rw-r--r--views/widget/widget_gtk.h6
-rw-r--r--views/widget/widget_win.cc17
-rw-r--r--views/widget/widget_win.h8
6 files changed, 70 insertions, 2 deletions
diff --git a/views/widget/widget.h b/views/widget/widget.h
index a3959b4..3f537f6 100644
--- a/views/widget/widget.h
+++ b/views/widget/widget.h
@@ -26,6 +26,7 @@ class FocusManager;
class RootView;
class TooltipManager;
class View;
+class WidgetDelegate;
class Window;
////////////////////////////////////////////////////////////////////////////////
@@ -91,6 +92,12 @@ class Widget {
// contents as the window is sized.
virtual void Init(gfx::NativeView parent, const gfx::Rect& bounds) = 0;
+ // Returns the WidgetDelegate for delegating certain events.
+ virtual WidgetDelegate* GetWidgetDelegate() = 0;
+
+ // Sets the WidgetDelegate.
+ virtual void SetWidgetDelegate(WidgetDelegate* delegate) = 0;
+
// Sets the specified view as the contents of this Widget. There can only
// be one contents view child of this Widget's RootView. This view is sized to
// fit the entire size of the RootView. The RootView takes ownership of this
diff --git a/views/widget/widget_delegate.h b/views/widget/widget_delegate.h
new file mode 100755
index 0000000..4607376
--- /dev/null
+++ b/views/widget/widget_delegate.h
@@ -0,0 +1,23 @@
+// Copyright (c) 2006-2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef VIEWS_WIDGET_WIDGET_DELEGATE_H_
+#define VIEWS_WIDGET_WIDGET_DELEGATE_H_
+
+namespace views {
+
+// WidgetDelegate interface
+// Handles events on Widgets in context-specific ways.
+class WidgetDelegate {
+ public:
+ virtual ~WidgetDelegate() {}
+
+ // Called with the display changes (color depth or resolution).
+ virtual void DisplayChanged() = 0;
+};
+
+} // namespace views
+
+#endif // VIEWS_WIDGET_WIDGET_DELEGATE_H_
+
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc
index b14f118..bfd0ab4 100644
--- a/views/widget/widget_gtk.cc
+++ b/views/widget/widget_gtk.cc
@@ -105,7 +105,8 @@ WidgetGtk::WidgetGtk(Type type)
is_active_(false),
transient_to_parent_(false),
got_initial_focus_in_(false),
- has_focus_(false) {
+ has_focus_(false),
+ delegate_(NULL) {
static bool installed_message_loop_observer = false;
if (!installed_message_loop_observer) {
installed_message_loop_observer = true;
@@ -379,6 +380,14 @@ void WidgetGtk::Init(GtkWidget* parent,
}
}
+WidgetDelegate* WidgetWin::GetWidgetDelegate() {
+ return delegate_;
+}
+
+void WidgetDelegate::SetWidgetDelegate(WidgetDelegate* delegate) {
+ delegate_ = delegate;
+}
+
void WidgetGtk::SetContentsView(View* view) {
root_view_->SetContentsView(view);
}
diff --git a/views/widget/widget_gtk.h b/views/widget/widget_gtk.h
index 29d99be..87baeb5 100644
--- a/views/widget/widget_gtk.h
+++ b/views/widget/widget_gtk.h
@@ -137,6 +137,8 @@ class WidgetGtk
// Overridden from Widget:
virtual void Init(gfx::NativeView parent, const gfx::Rect& bounds);
+ virtual WidgetDelegate* GetWidgetDelegate();
+ virtual void SetWidgetDelegate(WidgetDelegate* delegate);
virtual void SetContentsView(View* view);
virtual void GetBounds(gfx::Rect* out, bool including_frame) const;
virtual void SetBounds(const gfx::Rect& bounds);
@@ -470,6 +472,10 @@ class WidgetGtk
// this to determine whether we should process the event.
bool has_focus_;
+ // Non owned pointer to optional delegate. May be NULL if no delegate is
+ // being used.
+ WidgetDelegate* delegate_;
+
DISALLOW_COPY_AND_ASSIGN(WidgetGtk);
};
diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc
index 5fb5cf8..5527190 100644
--- a/views/widget/widget_win.cc
+++ b/views/widget/widget_win.cc
@@ -20,6 +20,7 @@
#include "views/widget/default_theme_provider.h"
#include "views/widget/drop_target_win.h"
#include "views/widget/root_view.h"
+#include "views/widget/widget_delegate.h"
#include "views/window/window_win.h"
namespace views {
@@ -55,7 +56,8 @@ WidgetWin::WidgetWin()
last_mouse_event_was_move_(false),
is_mouse_down_(false),
is_window_(false),
- restore_focus_when_enabled_(false) {
+ restore_focus_when_enabled_(false),
+ delegate_(NULL) {
}
WidgetWin::~WidgetWin() {
@@ -160,6 +162,14 @@ void WidgetWin::Init(gfx::NativeView parent, const gfx::Rect& bounds) {
ImmAssociateContextEx(hwnd(), NULL, 0);
}
+WidgetDelegate* WidgetWin::GetWidgetDelegate() {
+ return delegate_;
+}
+
+void WidgetWin::SetWidgetDelegate(WidgetDelegate* delegate) {
+ delegate_ = delegate;
+}
+
void WidgetWin::SetContentsView(View* view) {
root_view_->SetContentsView(view);
}
@@ -534,6 +544,11 @@ void WidgetWin::OnDestroy() {
RemoveProp(hwnd(), kRootViewWindowProperty);
}
+void WidgetWin::OnDisplayChange(UINT bits_per_pixel, CSize screen_size) {
+ if (GetWidgetDelegate())
+ GetWidgetDelegate()->DisplayChanged();
+}
+
LRESULT WidgetWin::OnDwmCompositionChanged(UINT msg,
WPARAM w_param,
LPARAM l_param) {
diff --git a/views/widget/widget_win.h b/views/widget/widget_win.h
index b8246da..f5ac2d1 100644
--- a/views/widget/widget_win.h
+++ b/views/widget/widget_win.h
@@ -122,6 +122,7 @@ class WidgetWin : public app::WindowImpl,
MSG_WM_COMMAND(OnCommand)
MSG_WM_CREATE(OnCreate)
MSG_WM_DESTROY(OnDestroy)
+ MSG_WM_DISPLAYCHANGE(OnDisplayChange)
MSG_WM_ERASEBKGND(OnEraseBkgnd)
MSG_WM_ENDSESSION(OnEndSession)
MSG_WM_ENTERSIZEMOVE(OnEnterSizeMove)
@@ -180,6 +181,8 @@ class WidgetWin : public app::WindowImpl,
// Overridden from Widget:
virtual void Init(gfx::NativeView parent, const gfx::Rect& bounds);
+ virtual WidgetDelegate* GetWidgetDelegate();
+ virtual void SetWidgetDelegate(WidgetDelegate* delegate);
virtual void SetContentsView(View* view);
virtual void GetBounds(gfx::Rect* out, bool including_frame) const;
virtual void SetBounds(const gfx::Rect& bounds);
@@ -325,6 +328,7 @@ class WidgetWin : public app::WindowImpl,
// WARNING: If you override this be sure and invoke super, otherwise we'll
// leak a few things.
virtual void OnDestroy();
+ virtual void OnDisplayChange(UINT bits_per_pixel, CSize screen_size);
virtual LRESULT OnDwmCompositionChanged(UINT msg,
WPARAM w_param,
LPARAM l_param);
@@ -544,6 +548,10 @@ class WidgetWin : public app::WindowImpl,
ScopedComPtr<IAccessible> accessibility_root_;
scoped_ptr<DefaultThemeProvider> default_theme_provider_;
+
+ // Non owned pointer to optional delegate. May be NULL if no delegate is
+ // being used.
+ WidgetDelegate* delegate_;
};
} // namespace views