summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-23 22:56:17 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-23 22:56:17 +0000
commit2a021c45241b0556918f42df51709fdd7ff7a4fa (patch)
treeccc1ed736029022b7aed62a0d76a9ecdebe3b033 /views
parente091b14467c3329a64c47b96bf6bbb75c0a5e4d5 (diff)
downloadchromium_src-2a021c45241b0556918f42df51709fdd7ff7a4fa.zip
chromium_src-2a021c45241b0556918f42df51709fdd7ff7a4fa.tar.gz
chromium_src-2a021c45241b0556918f42df51709fdd7ff7a4fa.tar.bz2
Convert some WidgetWin construction to use CreateParams.
BUG=72040 TEST=none Review URL: http://codereview.chromium.org/6719006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79211 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/widget/native_widget.h2
-rw-r--r--views/widget/widget.cc10
-rw-r--r--views/widget/widget.h4
-rw-r--r--views/widget/widget_gtk.cc10
-rw-r--r--views/widget/widget_gtk.h2
-rw-r--r--views/widget/widget_win.cc14
-rw-r--r--views/widget/widget_win.h2
7 files changed, 26 insertions, 18 deletions
diff --git a/views/widget/native_widget.h b/views/widget/native_widget.h
index 9d6051f..b362453 100644
--- a/views/widget/native_widget.h
+++ b/views/widget/native_widget.h
@@ -88,7 +88,7 @@ class NativeWidget {
virtual gfx::Rect GetWindowScreenBounds() const = 0;
virtual gfx::Rect GetClientAreaScreenBounds() const = 0;
virtual void SetBounds(const gfx::Rect& bounds) = 0;
- virtual void MoveAbove(Widget* widget) = 0;
+ virtual void MoveAbove(gfx::NativeView native_view) = 0;
virtual void SetShape(gfx::NativeRegion shape) = 0;
virtual void Close() = 0;
virtual void CloseNow() = 0;
diff --git a/views/widget/widget.cc b/views/widget/widget.cc
index 62f9cf9..4963ce6 100644
--- a/views/widget/widget.cc
+++ b/views/widget/widget.cc
@@ -21,6 +21,7 @@ Widget::CreateParams::CreateParams()
: type(TYPE_TOPLEVEL),
transparent(false),
accept_events(true),
+ can_activate(true),
delete_on_destroy(true),
mirror_origin_in_rtl(true),
has_dropshadow(false),
@@ -31,6 +32,7 @@ Widget::CreateParams::CreateParams(Type type)
: type(type),
transparent(false),
accept_events(true),
+ can_activate(type != TYPE_POPUP && type != TYPE_MENU),
delete_on_destroy(true),
mirror_origin_in_rtl(true),
has_dropshadow(false),
@@ -131,8 +133,12 @@ void Widget::SetBounds(const gfx::Rect& bounds) {
native_widget_->SetBounds(bounds);
}
-void Widget::MoveAbove(Widget* widget) {
- native_widget_->MoveAbove(widget);
+void Widget::MoveAboveWidget(Widget* widget) {
+ native_widget_->MoveAbove(widget->GetNativeView());
+}
+
+void Widget::MoveAbove(gfx::NativeView native_view) {
+ native_widget_->MoveAbove(native_view);
}
void Widget::SetShape(gfx::NativeRegion shape) {
diff --git a/views/widget/widget.h b/views/widget/widget.h
index c164c16..cb6a3ce 100644
--- a/views/widget/widget.h
+++ b/views/widget/widget.h
@@ -75,6 +75,7 @@ class Widget : public internal::NativeWidgetDelegate,
bool transparent;
bool accept_events;
+ bool can_activate;
bool delete_on_destroy;
bool mirror_origin_in_rtl;
bool has_dropshadow;
@@ -164,7 +165,8 @@ class Widget : public internal::NativeWidgetDelegate,
void SetBounds(const gfx::Rect& bounds);
// Places the widget in front of the specified widget in z-order.
- void MoveAbove(Widget* widget);
+ void MoveAboveWidget(Widget* widget);
+ void MoveAbove(gfx::NativeView native_view);
// Sets a shape on the widget. This takes ownership of shape.
void SetShape(gfx::NativeRegion shape);
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc
index d547386..b2371f8 100644
--- a/views/widget/widget_gtk.cc
+++ b/views/widget/widget_gtk.cc
@@ -18,6 +18,7 @@
#include "ui/base/dragdrop/drag_drop_types.h"
#include "ui/base/dragdrop/os_exchange_data.h"
#include "ui/base/dragdrop/os_exchange_data_provider_gtk.h"
+#include "ui/base/gtk/gtk_windowing.h"
#include "ui/base/x/x11_util.h"
#include "ui/gfx/canvas_skia_paint.h"
#include "ui/gfx/path.h"
@@ -815,13 +816,8 @@ void WidgetGtk::SetBounds(const gfx::Rect& bounds) {
}
}
-void WidgetGtk::MoveAbove(Widget* widget) {
- DCHECK(widget_);
- DCHECK(widget_->window);
- // TODO(oshima): gdk_window_restack is not available in gtk2.0, so
- // we're simply raising the window to the top. We should switch to
- // gdk_window_restack when we upgrade gtk to 2.18 or up.
- gdk_window_raise(widget_->window);
+void WidgetGtk::MoveAbove(gfx::NativeView native_view) {
+ ui::StackPopupWindow(GetNativeView(), native_view);
}
void WidgetGtk::SetShape(gfx::NativeRegion region) {
diff --git a/views/widget/widget_gtk.h b/views/widget/widget_gtk.h
index ed9e9fb..963076f 100644
--- a/views/widget/widget_gtk.h
+++ b/views/widget/widget_gtk.h
@@ -191,7 +191,7 @@ class WidgetGtk : public Widget,
virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE;
virtual gfx::Rect GetClientAreaScreenBounds() const OVERRIDE;
virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
- virtual void MoveAbove(Widget* widget) OVERRIDE;
+ virtual void MoveAbove(gfx::NativeView native_view) OVERRIDE;
virtual void SetShape(gfx::NativeRegion shape) OVERRIDE;
virtual void Close() OVERRIDE;
virtual void CloseNow() OVERRIDE;
diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc
index bd8a049..147c443 100644
--- a/views/widget/widget_win.cc
+++ b/views/widget/widget_win.cc
@@ -157,13 +157,15 @@ void WidgetWin::SetCreateParams(const CreateParams& params) {
// Set non-style attributes.
set_delete_on_destroy(params.delete_on_destroy);
- DWORD style = 0;
+ DWORD style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
DWORD ex_style = 0;
DWORD class_style = CS_DBLCLKS;
// Set type-independent style attributes.
if (!params.accept_events)
ex_style |= WS_EX_TRANSPARENT;
+ if (!params.can_activate)
+ ex_style |= WS_EX_NOACTIVATE;
if (params.mirror_origin_in_rtl)
ex_style |= l10n_util::GetExtendedTooltipStyles();
if (params.transparent)
@@ -182,11 +184,11 @@ void WidgetWin::SetCreateParams(const CreateParams& params) {
break;
case CreateParams::TYPE_POPUP:
style |= WS_POPUP;
- ex_style |= WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE;
+ ex_style |= WS_EX_TOOLWINDOW;
break;
case CreateParams::TYPE_MENU:
style |= WS_POPUP;
- ex_style |= WS_EX_TOPMOST | WS_EX_NOACTIVATE;
+ ex_style |= WS_EX_TOPMOST;
is_mouse_down_ =
((GetKeyState(VK_LBUTTON) & 0x80) ||
(GetKeyState(VK_RBUTTON) & 0x80) ||
@@ -354,8 +356,8 @@ void WidgetWin::SetBounds(const gfx::Rect& bounds) {
SWP_NOACTIVATE | SWP_NOZORDER);
}
-void WidgetWin::MoveAbove(Widget* other) {
- SetWindowPos(other->GetNativeView(), 0, 0, 0, 0,
+void WidgetWin::MoveAbove(gfx::NativeView native_view) {
+ SetWindowPos(native_view, 0, 0, 0, 0,
SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
}
@@ -740,6 +742,8 @@ void WidgetWin::OnKillFocus(HWND focused_window) {
LRESULT WidgetWin::OnMouseActivate(UINT message,
WPARAM w_param,
LPARAM l_param) {
+ if (GetWindowLong(GWL_EXSTYLE) & WS_EX_NOACTIVATE)
+ return MA_NOACTIVATE;
SetMsgHandled(FALSE);
return MA_ACTIVATE;
}
diff --git a/views/widget/widget_win.h b/views/widget/widget_win.h
index 41e24f9..b5bc23c 100644
--- a/views/widget/widget_win.h
+++ b/views/widget/widget_win.h
@@ -212,7 +212,7 @@ class WidgetWin : public ui::WindowImpl,
virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE;
virtual gfx::Rect GetClientAreaScreenBounds() const OVERRIDE;
virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
- virtual void MoveAbove(Widget* widget) OVERRIDE;
+ virtual void MoveAbove(gfx::NativeView native_view) OVERRIDE;
virtual void SetShape(gfx::NativeRegion shape) OVERRIDE;
virtual void Close() OVERRIDE;
virtual void CloseNow() OVERRIDE;