2014-09-04 19:53:40 +02:00
|
|
|
diff --git desktop_aura/desktop_screen_win.cc desktop_aura/desktop_screen_win.cc
|
2014-11-12 20:25:15 +01:00
|
|
|
index a8e088c..838b6a0 100644
|
2014-09-04 19:53:40 +02:00
|
|
|
--- desktop_aura/desktop_screen_win.cc
|
|
|
|
+++ desktop_aura/desktop_screen_win.cc
|
2014-11-12 20:25:15 +01:00
|
|
|
@@ -32,6 +32,8 @@ gfx::Display DesktopScreenWin::GetDisplayMatching(
|
2013-12-07 02:55:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
HWND DesktopScreenWin::GetHWNDFromNativeView(gfx::NativeView window) const {
|
|
|
|
+ if (!window)
|
|
|
|
+ return NULL;
|
2014-04-04 18:50:38 +02:00
|
|
|
aura::WindowTreeHost* host = window->GetHost();
|
|
|
|
return host ? host->GetAcceleratedWidget() : NULL;
|
2013-12-07 02:55:22 +01:00
|
|
|
}
|
2014-09-04 19:53:40 +02:00
|
|
|
diff --git desktop_aura/desktop_window_tree_host_win.cc desktop_aura/desktop_window_tree_host_win.cc
|
2015-07-24 02:06:56 +02:00
|
|
|
index 93b3c5b..e0e505e 100644
|
2014-09-04 19:53:40 +02:00
|
|
|
--- desktop_aura/desktop_window_tree_host_win.cc
|
|
|
|
+++ desktop_aura/desktop_window_tree_host_win.cc
|
2015-07-24 02:06:56 +02:00
|
|
|
@@ -131,7 +131,9 @@ void DesktopWindowTreeHostWin::Init(aura::Window* content_window,
|
2014-02-19 17:27:54 +01:00
|
|
|
native_widget_delegate_);
|
|
|
|
|
|
|
|
HWND parent_hwnd = NULL;
|
2014-04-04 18:50:38 +02:00
|
|
|
- if (params.parent && params.parent->GetHost())
|
|
|
|
+ if (params.parent_widget)
|
2014-02-19 17:27:54 +01:00
|
|
|
+ parent_hwnd = params.parent_widget;
|
2014-04-04 18:50:38 +02:00
|
|
|
+ else if (params.parent && params.parent->GetHost())
|
|
|
|
parent_hwnd = params.parent->GetHost()->GetAcceleratedWidget();
|
|
|
|
|
|
|
|
message_handler_->set_remove_standard_frame(params.remove_standard_frame);
|
2015-07-24 02:06:56 +02:00
|
|
|
@@ -793,6 +795,7 @@ void DesktopWindowTreeHostWin::HandleFrameChanged() {
|
2014-06-06 21:04:21 +02:00
|
|
|
|
|
|
|
void DesktopWindowTreeHostWin::HandleNativeFocus(HWND last_focused_window) {
|
|
|
|
// TODO(beng): inform the native_widget_delegate_.
|
|
|
|
+ GetWidget()->GetNativeWindow()->Focus();
|
2015-06-06 00:06:48 +02:00
|
|
|
}
|
2014-06-06 21:04:21 +02:00
|
|
|
|
|
|
|
void DesktopWindowTreeHostWin::HandleNativeBlur(HWND focused_window) {
|
2014-09-04 19:53:40 +02:00
|
|
|
diff --git desktop_aura/desktop_window_tree_host_x11.cc desktop_aura/desktop_window_tree_host_x11.cc
|
2015-07-24 02:06:56 +02:00
|
|
|
index a56deb7..a5e8422 100644
|
2014-09-04 19:53:40 +02:00
|
|
|
--- desktop_aura/desktop_window_tree_host_x11.cc
|
|
|
|
+++ desktop_aura/desktop_window_tree_host_x11.cc
|
2015-07-24 02:06:56 +02:00
|
|
|
@@ -171,7 +171,8 @@ DesktopWindowTreeHostX11::DesktopWindowTreeHostX11(
|
2015-03-19 23:06:16 +01:00
|
|
|
window_parent_(NULL),
|
2014-05-29 19:15:34 +02:00
|
|
|
custom_window_shape_(false),
|
2014-10-10 19:54:35 +02:00
|
|
|
urgency_hint_set_(false),
|
|
|
|
- close_widget_factory_(this) {
|
|
|
|
+ close_widget_factory_(this),
|
2014-05-22 23:01:22 +02:00
|
|
|
+ xwindow_destroyed_(false) {
|
|
|
|
}
|
|
|
|
|
|
|
|
DesktopWindowTreeHostX11::~DesktopWindowTreeHostX11() {
|
2015-07-24 02:06:56 +02:00
|
|
|
@@ -381,7 +382,8 @@ void DesktopWindowTreeHostX11::CloseNow() {
|
2014-05-22 23:01:22 +02:00
|
|
|
// Actually free our native resources.
|
|
|
|
if (ui::PlatformEventSource::GetInstance())
|
|
|
|
ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this);
|
|
|
|
- XDestroyWindow(xdisplay_, xwindow_);
|
|
|
|
+ if (!xwindow_destroyed_)
|
|
|
|
+ XDestroyWindow(xdisplay_, xwindow_);
|
|
|
|
xwindow_ = None;
|
|
|
|
|
|
|
|
desktop_native_widget_aura_->OnHostClosed();
|
2015-07-24 02:06:56 +02:00
|
|
|
@@ -525,6 +527,8 @@ void DesktopWindowTreeHostX11::GetWindowPlacement(
|
2014-07-09 00:37:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
gfx::Rect DesktopWindowTreeHostX11::GetWindowBoundsInScreen() const {
|
|
|
|
+ if (!screen_bounds_.IsEmpty())
|
|
|
|
+ return screen_bounds_;
|
2015-03-04 02:00:13 +01:00
|
|
|
return ToDIPRect(bounds_in_pixels_);
|
2014-07-09 00:37:06 +02:00
|
|
|
}
|
|
|
|
|
2015-07-24 02:06:56 +02:00
|
|
|
@@ -962,6 +966,8 @@ void DesktopWindowTreeHostX11::HideImpl() {
|
2014-10-29 19:14:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
gfx::Rect DesktopWindowTreeHostX11::GetBounds() const {
|
|
|
|
+ if (!screen_bounds_.IsEmpty())
|
|
|
|
+ return screen_bounds_;
|
2015-03-04 02:00:13 +01:00
|
|
|
return bounds_in_pixels_;
|
2014-10-29 19:14:47 +01:00
|
|
|
}
|
|
|
|
|
2015-07-24 02:06:56 +02:00
|
|
|
@@ -1018,6 +1024,8 @@ void DesktopWindowTreeHostX11::SetBounds(
|
2014-07-09 00:37:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
gfx::Point DesktopWindowTreeHostX11::GetLocationOnNativeScreen() const {
|
|
|
|
+ if (!screen_bounds_.IsEmpty())
|
|
|
|
+ return screen_bounds_.origin();
|
2015-03-04 02:00:13 +01:00
|
|
|
return bounds_in_pixels_.origin();
|
2014-07-09 00:37:06 +02:00
|
|
|
}
|
|
|
|
|
2015-07-24 02:06:56 +02:00
|
|
|
@@ -1131,9 +1139,13 @@ void DesktopWindowTreeHostX11::InitX11Window(
|
2014-05-29 19:15:34 +02:00
|
|
|
}
|
|
|
|
}
|
2014-05-22 23:01:22 +02:00
|
|
|
|
|
|
|
+ gfx::AcceleratedWidget parent_widget = params.parent_widget;
|
|
|
|
+ if (parent_widget == gfx::kNullAcceleratedWidget)
|
|
|
|
+ parent_widget = x_root_window_;
|
|
|
|
+
|
2015-03-04 02:00:13 +01:00
|
|
|
bounds_in_pixels_ = ToPixelRect(params.bounds);
|
|
|
|
bounds_in_pixels_.set_size(AdjustSize(bounds_in_pixels_.size()));
|
|
|
|
- xwindow_ = XCreateWindow(xdisplay_, x_root_window_, bounds_in_pixels_.x(),
|
|
|
|
+ xwindow_ = XCreateWindow(xdisplay_, parent_widget, bounds_in_pixels_.x(),
|
|
|
|
bounds_in_pixels_.y(), bounds_in_pixels_.width(),
|
|
|
|
bounds_in_pixels_.height(),
|
|
|
|
0, // border width
|
2015-07-24 02:06:56 +02:00
|
|
|
@@ -1782,6 +1794,10 @@ uint32_t DesktopWindowTreeHostX11::DispatchEvent(
|
2014-05-22 23:01:22 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
+ case DestroyNotify:
|
|
|
|
+ xwindow_destroyed_ = true;
|
|
|
|
+ CloseNow();
|
|
|
|
+ break;
|
|
|
|
case FocusOut:
|
|
|
|
if (xev->xfocus.mode != NotifyGrab) {
|
|
|
|
ReleaseCapture();
|
2014-09-04 19:53:40 +02:00
|
|
|
diff --git desktop_aura/desktop_window_tree_host_x11.h desktop_aura/desktop_window_tree_host_x11.h
|
2015-07-24 02:06:56 +02:00
|
|
|
index 787372d..d9d57b8 100644
|
2014-09-04 19:53:40 +02:00
|
|
|
--- desktop_aura/desktop_window_tree_host_x11.h
|
|
|
|
+++ desktop_aura/desktop_window_tree_host_x11.h
|
2015-07-24 02:06:56 +02:00
|
|
|
@@ -85,6 +85,8 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11
|
|
|
|
// internal list of open windows.
|
|
|
|
static void CleanUpWindowList(void (*func)(aura::Window* window));
|
2014-07-09 00:37:06 +02:00
|
|
|
|
|
|
|
+ void set_screen_bounds(const gfx::Rect& bounds) { screen_bounds_ = bounds; }
|
|
|
|
+
|
|
|
|
protected:
|
|
|
|
// Overridden from DesktopWindowTreeHost:
|
2014-11-12 20:25:15 +01:00
|
|
|
void Init(aura::Window* content_window,
|
2015-07-24 02:06:56 +02:00
|
|
|
@@ -262,6 +264,9 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11
|
2014-07-09 00:37:06 +02:00
|
|
|
// The bounds of |xwindow_|.
|
2015-03-04 02:00:13 +01:00
|
|
|
gfx::Rect bounds_in_pixels_;
|
2014-07-09 00:37:06 +02:00
|
|
|
|
|
|
|
+ // Override the screen bounds when the host is a child window.
|
|
|
|
+ gfx::Rect screen_bounds_;
|
|
|
|
+
|
|
|
|
// Whenever the bounds are set, we keep the previous set of bounds around so
|
2015-03-04 02:00:13 +01:00
|
|
|
// we can have a better chance of getting the real
|
|
|
|
// |restored_bounds_in_pixels_|. Window managers tend to send a Configure
|
2015-07-24 02:06:56 +02:00
|
|
|
@@ -348,6 +353,9 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11
|
2014-09-04 19:53:40 +02:00
|
|
|
|
2014-10-10 19:54:35 +02:00
|
|
|
base::WeakPtrFactory<DesktopWindowTreeHostX11> close_widget_factory_;
|
2014-05-22 23:01:22 +02:00
|
|
|
|
|
|
|
+ // True if the xwindow has already been destroyed.
|
|
|
|
+ bool xwindow_destroyed_;
|
|
|
|
+
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(DesktopWindowTreeHostX11);
|
|
|
|
};
|
|
|
|
|
2014-09-04 19:53:40 +02:00
|
|
|
diff --git widget.cc widget.cc
|
2015-07-24 02:06:56 +02:00
|
|
|
index 280969a..8ea7f0b 100644
|
2014-09-04 19:53:40 +02:00
|
|
|
--- widget.cc
|
|
|
|
+++ widget.cc
|
2015-07-24 02:06:56 +02:00
|
|
|
@@ -118,6 +118,7 @@ Widget::InitParams::InitParams()
|
2014-11-12 20:25:15 +01:00
|
|
|
use_system_default_icon(false),
|
2014-02-07 00:36:29 +01:00
|
|
|
show_state(ui::SHOW_STATE_DEFAULT),
|
|
|
|
parent(NULL),
|
2014-05-22 23:01:22 +02:00
|
|
|
+ parent_widget(gfx::kNullAcceleratedWidget),
|
2014-02-07 00:36:29 +01:00
|
|
|
native_widget(NULL),
|
2014-02-19 17:27:54 +01:00
|
|
|
desktop_window_tree_host(NULL),
|
2015-04-20 13:11:11 +02:00
|
|
|
layer_type(ui::LAYER_TEXTURED),
|
2015-07-24 02:06:56 +02:00
|
|
|
@@ -141,6 +142,7 @@ Widget::InitParams::InitParams(Type type)
|
2014-11-12 20:25:15 +01:00
|
|
|
use_system_default_icon(false),
|
2014-02-06 23:33:18 +01:00
|
|
|
show_state(ui::SHOW_STATE_DEFAULT),
|
|
|
|
parent(NULL),
|
2014-05-22 23:01:22 +02:00
|
|
|
+ parent_widget(gfx::kNullAcceleratedWidget),
|
2014-02-06 23:33:18 +01:00
|
|
|
native_widget(NULL),
|
2014-02-19 17:27:54 +01:00
|
|
|
desktop_window_tree_host(NULL),
|
2015-04-20 13:11:11 +02:00
|
|
|
layer_type(ui::LAYER_TEXTURED),
|
2015-07-24 02:06:56 +02:00
|
|
|
@@ -315,7 +317,7 @@ void Widget::Init(const InitParams& in_params) {
|
2014-06-12 22:28:58 +02:00
|
|
|
InitParams params = in_params;
|
|
|
|
|
|
|
|
params.child |= (params.type == InitParams::TYPE_CONTROL);
|
|
|
|
- is_top_level_ = !params.child;
|
|
|
|
+ is_top_level_ = !params.child || params.parent_widget;
|
|
|
|
|
|
|
|
if (params.opacity == views::Widget::InitParams::INFER_OPACITY &&
|
|
|
|
params.type != views::Widget::InitParams::TYPE_WINDOW &&
|
2015-07-24 02:06:56 +02:00
|
|
|
@@ -378,7 +380,12 @@ void Widget::Init(const InitParams& in_params) {
|
2014-03-12 15:36:18 +01:00
|
|
|
Minimize();
|
|
|
|
} else if (params.delegate) {
|
|
|
|
SetContentsView(params.delegate->GetContentsView());
|
|
|
|
- SetInitialBoundsForFramelessWindow(params.bounds);
|
|
|
|
+ if (params.parent_widget) {
|
|
|
|
+ // Set the bounds directly instead of applying an inset.
|
|
|
|
+ SetBounds(params.bounds);
|
|
|
|
+ } else {
|
|
|
|
+ SetInitialBoundsForFramelessWindow(params.bounds);
|
|
|
|
+ }
|
|
|
|
}
|
2014-07-02 20:25:22 +02:00
|
|
|
// This must come after SetContentsView() or it might not be able to find
|
|
|
|
// the correct NativeTheme (on Linux). See http://crbug.com/384492
|
2014-09-04 19:53:40 +02:00
|
|
|
diff --git widget.h widget.h
|
2015-07-24 02:06:56 +02:00
|
|
|
index 320332b..8d46883 100644
|
2014-09-04 19:53:40 +02:00
|
|
|
--- widget.h
|
|
|
|
+++ widget.h
|
2015-07-24 02:06:56 +02:00
|
|
|
@@ -233,6 +233,7 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate,
|
2014-11-12 20:25:15 +01:00
|
|
|
// Whether the widget should be maximized or minimized.
|
|
|
|
ui::WindowShowState show_state;
|
2013-12-07 02:55:22 +01:00
|
|
|
gfx::NativeView parent;
|
|
|
|
+ gfx::AcceleratedWidget parent_widget;
|
|
|
|
// Specifies the initial bounds of the Widget. Default is empty, which means
|
|
|
|
// the NativeWidget may specify a default size. If the parent is specified,
|
|
|
|
// |bounds| is in the parent's coordinate system. If the parent is not
|