Index: ui/views/widget/desktop_aura/x11_desktop_handler.cc |
diff --git a/ui/views/widget/desktop_aura/x11_desktop_handler.cc b/ui/views/widget/desktop_aura/x11_desktop_handler.cc |
index dc3c8acc860ab8aa6faa19b1b38d5ebf70183fa9..6ea3912d7d5e4cd509c9c46dec5380600ef1b061 100644 |
--- a/ui/views/widget/desktop_aura/x11_desktop_handler.cc |
+++ b/ui/views/widget/desktop_aura/x11_desktop_handler.cc |
@@ -13,6 +13,8 @@ |
#include "ui/base/x/x11_foreign_window_manager.h" |
#include "ui/base/x/x11_menu_list.h" |
#include "ui/base/x/x11_util.h" |
+#include "ui/events/event_targeter.h" |
+#include "ui/events/null_event_targeter.h" |
#include "ui/events/platform/platform_event_source.h" |
#include "ui/gfx/x/x11_error_tracker.h" |
#include "ui/views/ime/input_method.h" |
@@ -47,7 +49,8 @@ X11DesktopHandler::X11DesktopHandler() |
current_window_(None), |
current_window_active_state_(NOT_ACTIVE), |
atom_cache_(xdisplay_, kAtomsToCache), |
- wm_supports_active_window_(false) { |
+ wm_supports_active_window_(false), |
+ modal_dialog_xid_(None) { |
if (ui::PlatformEventSource::GetInstance()) |
ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); |
aura::Env::GetInstance()->AddObserver(this); |
@@ -172,6 +175,13 @@ uint32_t X11DesktopHandler::DispatchEvent(const ui::PlatformEvent& event) { |
::Window window; |
if (ui::GetXIDProperty(x_root_window_, "_NET_ACTIVE_WINDOW", &window) && |
window) { |
+ // Set focus to the modal dialog. |
+ if (modal_dialog_xid_) { |
+ XSetInputFocus(xdisplay_, modal_dialog_xid_, RevertToParent, |
+ CurrentTime); |
+ break; |
+ } |
+ |
OnActiveWindowChanged(window, ACTIVE); |
} |
} |
@@ -247,4 +257,18 @@ void X11DesktopHandler::OnWindowCreatedOrDestroyed(int event_type, |
} |
} |
+void X11DesktopHandler::SetModalDialog(XID dialog) { |
+ modal_dialog_xid_ = dialog; |
+ |
+ if (dialog) { |
+ DesktopWindowTreeHostX11* host = |
+ views::DesktopWindowTreeHostX11::GetHostForXID(current_window_); |
+ // ScopedWindowTargeter is used to temporarily replace the event-targeter |
+ // with NullEventTargeter for the host window. |
+ scoped_targeter_.reset(new aura::ScopedWindowTargeter(host->window(), |
sadrul
2015/04/21 19:50:01
the indent here is wrong.
|
+ scoped_ptr<ui::EventTargeter>(new ui::NullEventTargeter))); |
+ } else |
+ scoped_targeter_.reset(); |
+} |
+ |
} // namespace views |