Commit e7a74187 authored by Tom Anderson's avatar Tom Anderson Committed by Commit Bot

X11: Fix windows not getting restored to correct workspace

Due to the way workspace data is stored for the session [1], it is necessary not
to optimize the case where "workspace_ == workspace_str" because the
SessionCommand to set the workspace would not get created on browser start (only
when windows are created or moved between workspaces).

[1] https://cs.chromium.org/chromium/src/components/sessions/core/session_service_commands.cc?rcl=34077ec24a99e50f6211585b0ae652fe97ced33c&l=756

R=sky

Change-Id: I6021c8ce0a5ff38529b88bff067188378e5739b0
Reviewed-on: https://chromium-review.googlesource.com/1044946Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#556472}
parent bf8e840d
......@@ -671,20 +671,15 @@ gfx::Rect DesktopWindowTreeHostX11::GetRestoredBounds() const {
}
std::string DesktopWindowTreeHostX11::GetWorkspace() const {
if (workspace_.empty())
const_cast<DesktopWindowTreeHostX11*>(this)->UpdateWorkspace();
return workspace_;
return workspace_ ? base::IntToString(workspace_.value()) : std::string();
}
bool DesktopWindowTreeHostX11::UpdateWorkspace() {
int workspace_int;
if (!ui::GetWindowDesktop(xwindow_, &workspace_int))
return false;
std::string workspace_str = base::IntToString(workspace_int);
if (workspace_ == workspace_str)
return false;
workspace_ = workspace_str;
return true;
void DesktopWindowTreeHostX11::UpdateWorkspace() {
int workspace;
if (ui::GetWindowDesktop(xwindow_, &workspace))
workspace_ = workspace;
else
workspace_ = base::nullopt;
}
gfx::Rect DesktopWindowTreeHostX11::GetWorkAreaBoundsInScreen() const {
......@@ -894,7 +889,7 @@ void DesktopWindowTreeHostX11::SetVisibleOnAllWorkspaces(bool always_visible) {
return;
}
workspace_ = base::IntToString(kAllDesktops);
workspace_ = kAllDesktops;
XEvent xevent;
memset (&xevent, 0, sizeof (xevent));
xevent.type = ClientMessage;
......@@ -1504,7 +1499,7 @@ void DesktopWindowTreeHostX11::InitX11Window(
if (is_always_on_top_)
state_atom_list.push_back(gfx::GetAtom("_NET_WM_STATE_ABOVE"));
workspace_.clear();
workspace_ = base::nullopt;
if (params.visible_on_all_workspaces) {
state_atom_list.push_back(gfx::GetAtom("_NET_WM_STATE_STICKY"));
ui::SetIntProperty(xwindow_, "_NET_WM_DESKTOP", "CARDINAL", kAllDesktops);
......@@ -2267,7 +2262,9 @@ uint32_t DesktopWindowTreeHostX11::DispatchEvent(
} else if (changed_atom == gfx::GetAtom("_NET_FRAME_EXTENTS")) {
OnFrameExtentsUpdated();
} else if (changed_atom == gfx::GetAtom("_NET_WM_DESKTOP")) {
if (UpdateWorkspace())
base::Optional<int> old_workspace = workspace_;
UpdateWorkspace();
if (workspace_ != old_workspace)
OnHostWorkspaceChanged();
}
break;
......
......@@ -225,8 +225,8 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11
void OnFocusEvent(bool focus_in, int mode, int detail);
// Makes a round trip to the X server to get the enclosing workspace for this
// window. Returns true iff |workspace_| was changed.
bool UpdateWorkspace();
// window.
void UpdateWorkspace();
// Updates |xwindow_|'s minimum and maximum size.
void UpdateMinAndMaxSize();
......@@ -329,8 +329,9 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11
// |xwindow_|'s maximum size.
gfx::Size max_size_in_pixels_;
// The workspace containing |xwindow_|.
std::string workspace_;
// The workspace containing |xwindow_|. This will be base::nullopt when
// _NET_WM_DESKTOP is unset.
base::Optional<int> workspace_;
// The window manager state bits.
base::flat_set<::Atom> window_properties_;
......
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