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