Commit 24d47c05 authored by zhenw@chromium.org's avatar zhenw@chromium.org

visibility bug fix for 246844 on Linux machines

BUG=246844

It fixes the the bug on Linux machines by propagating the window minimization
information to the content window after receiving X event from the platform, so
the render side can update its visibility properly.

Review URL: https://codereview.chromium.org/340783004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278754 0039d316-1c4b-4281-b951-d872f2087c98
parent 40ee1ab5
...@@ -1180,10 +1180,28 @@ void DesktopWindowTreeHostX11::OnWMStateUpdated() { ...@@ -1180,10 +1180,28 @@ void DesktopWindowTreeHostX11::OnWMStateUpdated() {
if (!ui::GetAtomArrayProperty(xwindow_, "_NET_WM_STATE", &atom_list)) if (!ui::GetAtomArrayProperty(xwindow_, "_NET_WM_STATE", &atom_list))
return; return;
bool was_minimized = IsMinimized();
window_properties_.clear(); window_properties_.clear();
std::copy(atom_list.begin(), atom_list.end(), std::copy(atom_list.begin(), atom_list.end(),
inserter(window_properties_, window_properties_.begin())); inserter(window_properties_, window_properties_.begin()));
// Propagate the window minimization information to the content window, so
// the render side can update its visibility properly. OnWMStateUpdated() is
// called by PropertyNofify event from DispatchEvent() when the browser is
// minimized or shown from minimized state. On Windows, this is realized by
// calling OnHostResized() with an empty size. In particular,
// HWNDMessageHandler::GetClientAreaBounds() returns an empty size when the
// window is minimized. On Linux, returning empty size in GetBounds() or
// SetBounds() does not work.
bool is_minimized = IsMinimized();
if (is_minimized != was_minimized) {
if (is_minimized)
content_window_->Hide();
else
content_window_->Show();
}
if (restored_bounds_.IsEmpty()) { if (restored_bounds_.IsEmpty()) {
DCHECK(!IsFullscreen()); DCHECK(!IsFullscreen());
if (IsMaximized()) { if (IsMaximized()) {
......
...@@ -367,4 +367,82 @@ TEST_F(DesktopWindowTreeHostX11Test, WindowManagerTogglesFullscreen) { ...@@ -367,4 +367,82 @@ TEST_F(DesktopWindowTreeHostX11Test, WindowManagerTogglesFullscreen) {
widget->GetWindowBoundsInScreen().ToString()); widget->GetWindowBoundsInScreen().ToString());
} }
// Tests that the minimization information is propagated to the content window.
TEST_F(DesktopWindowTreeHostX11Test, ToggleMinimizePropogateToContentWindow) {
Widget widget;
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.native_widget = new DesktopNativeWidgetAura(&widget);
widget.Init(params);
widget.Show();
ui::X11EventSource::GetInstance()->DispatchXEvents();
XID xid = widget.GetNativeWindow()->GetHost()->GetAcceleratedWidget();
Display* display = gfx::GetXDisplay();
// Minimize by sending _NET_WM_STATE_HIDDEN
{
const char* kAtomsToCache[] = {
"_NET_WM_STATE",
"_NET_WM_STATE_HIDDEN",
NULL
};
ui::X11AtomCache atom_cache(display, kAtomsToCache);
std::vector< ::Atom> atom_list;
atom_list.push_back(atom_cache.GetAtom("_NET_WM_STATE_HIDDEN"));
ui::SetAtomArrayProperty(xid, "_NET_WM_STATE", "ATOM", atom_list);
XEvent xevent;
memset(&xevent, 0, sizeof(xevent));
xevent.type = PropertyNotify;
xevent.xproperty.type = PropertyNotify;
xevent.xproperty.send_event = 1;
xevent.xproperty.display = display;
xevent.xproperty.window = xid;
xevent.xproperty.atom = atom_cache.GetAtom("_NET_WM_STATE");
xevent.xproperty.state = 0;
XSendEvent(display, DefaultRootWindow(display), False,
SubstructureRedirectMask | SubstructureNotifyMask,
&xevent);
WMStateWaiter waiter(xid, "_NET_WM_STATE_HIDDEN", true);
waiter.Wait();
}
EXPECT_FALSE(widget.GetNativeWindow()->IsVisible());
// Show from minimized by sending _NET_WM_STATE_FOCUSED
{
const char* kAtomsToCache[] = {
"_NET_WM_STATE",
"_NET_WM_STATE_FOCUSED",
NULL
};
ui::X11AtomCache atom_cache(display, kAtomsToCache);
std::vector< ::Atom> atom_list;
atom_list.push_back(atom_cache.GetAtom("_NET_WM_STATE_FOCUSED"));
ui::SetAtomArrayProperty(xid, "_NET_WM_STATE", "ATOM", atom_list);
XEvent xevent;
memset(&xevent, 0, sizeof(xevent));
xevent.type = PropertyNotify;
xevent.xproperty.type = PropertyNotify;
xevent.xproperty.send_event = 1;
xevent.xproperty.display = display;
xevent.xproperty.window = xid;
xevent.xproperty.atom = atom_cache.GetAtom("_NET_WM_STATE");
xevent.xproperty.state = 0;
XSendEvent(display, DefaultRootWindow(display), False,
SubstructureRedirectMask | SubstructureNotifyMask,
&xevent);
WMStateWaiter waiter(xid, "_NET_WM_STATE_FOCUSED", true);
waiter.Wait();
}
EXPECT_TRUE(widget.GetNativeWindow()->IsVisible());
}
} // namespace views } // namespace views
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment