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