| 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 old_host->HandleNativeWidgetActivationChanged(false); | 221 old_host->HandleNativeWidgetActivationChanged(false); |
| 222 } | 222 } |
| 223 | 223 |
| 224 // Update the current window ID to effectively change the active widget. | 224 // Update the current window ID to effectively change the active widget. |
| 225 current_window_ = xid; | 225 current_window_ = xid; |
| 226 current_window_active_state_ = active_state; | 226 current_window_active_state_ = active_state; |
| 227 | 227 |
| 228 if (active_state == ACTIVE) { | 228 if (active_state == ACTIVE) { |
| 229 DesktopWindowTreeHostX11* new_host = | 229 DesktopWindowTreeHostX11* new_host = |
| 230 views::DesktopWindowTreeHostX11::GetHostForXID(xid); | 230 views::DesktopWindowTreeHostX11::GetHostForXID(xid); |
| 231 if (new_host) | 231 if (new_host) { |
| 232 new_host->HandleNativeWidgetActivationChanged(true); | 232 // Set focus to the modal dialog instead of the host window. |
| 233 if (new_host->GetModalDialog()) { |
| 234 XSetInputFocus(xdisplay_, new_host->GetModalDialog(), |
| 235 RevertToParent, CurrentTime); |
| 236 } else { |
| 237 new_host->HandleNativeWidgetActivationChanged(true); |
| 238 } |
| 239 } |
| 233 } | 240 } |
| 234 } | 241 } |
| 235 | 242 |
| 236 void X11DesktopHandler::OnWindowCreatedOrDestroyed(int event_type, | 243 void X11DesktopHandler::OnWindowCreatedOrDestroyed(int event_type, |
| 237 XID window) { | 244 XID window) { |
| 238 // Menus created by Chrome can be drag and drop targets. Since they are | 245 // Menus created by Chrome can be drag and drop targets. Since they are |
| 239 // direct children of the screen root window and have override_redirect | 246 // direct children of the screen root window and have override_redirect |
| 240 // we cannot use regular _NET_CLIENT_LIST_STACKING property to find them | 247 // we cannot use regular _NET_CLIENT_LIST_STACKING property to find them |
| 241 // and use a separate cache to keep track of them. | 248 // and use a separate cache to keep track of them. |
| 242 // TODO(varkha): Implement caching of all top level X windows and their | 249 // TODO(varkha): Implement caching of all top level X windows and their |
| 243 // coordinates and stacking order to eliminate repeated calls to the X server | 250 // coordinates and stacking order to eliminate repeated calls to the X server |
| 244 // during mouse movement, drag and shaping events. | 251 // during mouse movement, drag and shaping events. |
| 245 if (event_type == CreateNotify) { | 252 if (event_type == CreateNotify) { |
| 246 // The window might be destroyed if the message pump did not get a chance to | 253 // The window might be destroyed if the message pump did not get a chance to |
| 247 // run but we can safely ignore the X error. | 254 // run but we can safely ignore the X error. |
| 248 gfx::X11ErrorTracker error_tracker; | 255 gfx::X11ErrorTracker error_tracker; |
| 249 ui::XMenuList::GetInstance()->MaybeRegisterMenu(window); | 256 ui::XMenuList::GetInstance()->MaybeRegisterMenu(window); |
| 250 } else { | 257 } else { |
| 251 ui::XMenuList::GetInstance()->MaybeUnregisterMenu(window); | 258 ui::XMenuList::GetInstance()->MaybeUnregisterMenu(window); |
| 252 } | 259 } |
| 253 | 260 |
| 254 if (event_type == DestroyNotify) { | 261 if (event_type == DestroyNotify) { |
| 255 // Notify the XForeignWindowManager that |window| has been destroyed. | 262 // Notify the XForeignWindowManager that |window| has been destroyed. |
| 256 ui::XForeignWindowManager::GetInstance()->OnWindowDestroyed(window); | 263 ui::XForeignWindowManager::GetInstance()->OnWindowDestroyed(window); |
| 257 } | 264 } |
| 258 } | 265 } |
| 259 | 266 |
| 260 } // namespace views | 267 } // namespace views |
| OLD | NEW |