| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" | 5 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" |
| 6 | 6 |
| 7 #include <X11/Xatom.h> | 7 #include <X11/Xatom.h> |
| 8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
| 9 | 9 |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 } | 179 } |
| 180 | 180 |
| 181 void X11DesktopHandler::OnActiveWindowChanged(::Window xid) { | 181 void X11DesktopHandler::OnActiveWindowChanged(::Window xid) { |
| 182 if (current_window_ == xid) | 182 if (current_window_ == xid) |
| 183 return; | 183 return; |
| 184 DesktopWindowTreeHostX11* old_host = | 184 DesktopWindowTreeHostX11* old_host = |
| 185 views::DesktopWindowTreeHostX11::GetHostForXID(current_window_); | 185 views::DesktopWindowTreeHostX11::GetHostForXID(current_window_); |
| 186 if (old_host) | 186 if (old_host) |
| 187 old_host->HandleNativeWidgetActivationChanged(false); | 187 old_host->HandleNativeWidgetActivationChanged(false); |
| 188 | 188 |
| 189 // Update the current window ID to effectively change the active widget. |
| 190 current_window_ = xid; |
| 191 |
| 189 DesktopWindowTreeHostX11* new_host = | 192 DesktopWindowTreeHostX11* new_host = |
| 190 views::DesktopWindowTreeHostX11::GetHostForXID(xid); | 193 views::DesktopWindowTreeHostX11::GetHostForXID(xid); |
| 191 if (new_host) | 194 if (new_host) |
| 192 new_host->HandleNativeWidgetActivationChanged(true); | 195 new_host->HandleNativeWidgetActivationChanged(true); |
| 193 | |
| 194 current_window_ = xid; | |
| 195 } | 196 } |
| 196 | 197 |
| 197 ::Window X11DesktopHandler::GetNextToActivateInStack( | 198 ::Window X11DesktopHandler::GetNextToActivateInStack( |
| 198 const std::vector< ::Window >& windows) { | 199 const std::vector< ::Window >& windows) { |
| 199 DCHECK(current_window_); | 200 DCHECK(current_window_); |
| 200 | 201 |
| 201 // We start by doing a fast forward in the stack to find the active window. | 202 // We start by doing a fast forward in the stack to find the active window. |
| 202 std::vector< ::Window >::const_iterator it = | 203 std::vector< ::Window >::const_iterator it = |
| 203 std::find(windows.begin(), windows.end(), current_window_); | 204 std::find(windows.begin(), windows.end(), current_window_); |
| 204 | 205 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 230 return *it; | 231 return *it; |
| 231 } | 232 } |
| 232 | 233 |
| 233 // If we reached that point, that means we have not found an appropriate | 234 // If we reached that point, that means we have not found an appropriate |
| 234 // window to activate. There is nothing we can do about it and the caller | 235 // window to activate. There is nothing we can do about it and the caller |
| 235 // should take care of doing the right thing. | 236 // should take care of doing the right thing. |
| 236 return 0; | 237 return 0; |
| 237 } | 238 } |
| 238 | 239 |
| 239 } // namespace views | 240 } // namespace views |
| OLD | NEW |