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" |
11 #include "ui/aura/env.h" | 11 #include "ui/aura/env.h" |
12 #include "ui/aura/window_event_dispatcher.h" | 12 #include "ui/aura/window_event_dispatcher.h" |
13 #include "ui/base/x/x11_foreign_window_manager.h" | 13 #include "ui/base/x/x11_foreign_window_manager.h" |
14 #include "ui/base/x/x11_menu_list.h" | 14 #include "ui/base/x/x11_menu_list.h" |
15 #include "ui/base/x/x11_util.h" | 15 #include "ui/base/x/x11_util.h" |
16 #include "ui/events/event_targeter.h" | |
17 #include "ui/events/null_event_targeter.h" | |
16 #include "ui/events/platform/platform_event_source.h" | 18 #include "ui/events/platform/platform_event_source.h" |
17 #include "ui/gfx/x/x11_error_tracker.h" | 19 #include "ui/gfx/x/x11_error_tracker.h" |
18 #include "ui/views/ime/input_method.h" | 20 #include "ui/views/ime/input_method.h" |
19 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" | 21 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" |
20 | 22 |
21 namespace { | 23 namespace { |
22 | 24 |
23 const char* kAtomsToCache[] = { | 25 const char* kAtomsToCache[] = { |
24 "_NET_ACTIVE_WINDOW", | 26 "_NET_ACTIVE_WINDOW", |
25 NULL | 27 NULL |
(...skipping 14 matching lines...) Expand all Loading... | |
40 return g_handler; | 42 return g_handler; |
41 } | 43 } |
42 | 44 |
43 X11DesktopHandler::X11DesktopHandler() | 45 X11DesktopHandler::X11DesktopHandler() |
44 : xdisplay_(gfx::GetXDisplay()), | 46 : xdisplay_(gfx::GetXDisplay()), |
45 x_root_window_(DefaultRootWindow(xdisplay_)), | 47 x_root_window_(DefaultRootWindow(xdisplay_)), |
46 wm_user_time_ms_(0), | 48 wm_user_time_ms_(0), |
47 current_window_(None), | 49 current_window_(None), |
48 current_window_active_state_(NOT_ACTIVE), | 50 current_window_active_state_(NOT_ACTIVE), |
49 atom_cache_(xdisplay_, kAtomsToCache), | 51 atom_cache_(xdisplay_, kAtomsToCache), |
50 wm_supports_active_window_(false) { | 52 wm_supports_active_window_(false), |
53 modal_dialog_xid_(None) { | |
51 if (ui::PlatformEventSource::GetInstance()) | 54 if (ui::PlatformEventSource::GetInstance()) |
52 ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); | 55 ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); |
53 aura::Env::GetInstance()->AddObserver(this); | 56 aura::Env::GetInstance()->AddObserver(this); |
54 | 57 |
55 XWindowAttributes attr; | 58 XWindowAttributes attr; |
56 XGetWindowAttributes(xdisplay_, x_root_window_, &attr); | 59 XGetWindowAttributes(xdisplay_, x_root_window_, &attr); |
57 XSelectInput(xdisplay_, x_root_window_, | 60 XSelectInput(xdisplay_, x_root_window_, |
58 attr.your_event_mask | PropertyChangeMask | | 61 attr.your_event_mask | PropertyChangeMask | |
59 StructureNotifyMask | SubstructureNotifyMask); | 62 StructureNotifyMask | SubstructureNotifyMask); |
60 | 63 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 uint32_t X11DesktopHandler::DispatchEvent(const ui::PlatformEvent& event) { | 168 uint32_t X11DesktopHandler::DispatchEvent(const ui::PlatformEvent& event) { |
166 switch (event->type) { | 169 switch (event->type) { |
167 case PropertyNotify: { | 170 case PropertyNotify: { |
168 // Check for a change to the active window. | 171 // Check for a change to the active window. |
169 CHECK_EQ(x_root_window_, event->xproperty.window); | 172 CHECK_EQ(x_root_window_, event->xproperty.window); |
170 ::Atom active_window_atom = atom_cache_.GetAtom("_NET_ACTIVE_WINDOW"); | 173 ::Atom active_window_atom = atom_cache_.GetAtom("_NET_ACTIVE_WINDOW"); |
171 if (event->xproperty.atom == active_window_atom) { | 174 if (event->xproperty.atom == active_window_atom) { |
172 ::Window window; | 175 ::Window window; |
173 if (ui::GetXIDProperty(x_root_window_, "_NET_ACTIVE_WINDOW", &window) && | 176 if (ui::GetXIDProperty(x_root_window_, "_NET_ACTIVE_WINDOW", &window) && |
174 window) { | 177 window) { |
178 // Set focus to the modal dialog. | |
179 if (modal_dialog_xid_) { | |
180 XSetInputFocus(xdisplay_, modal_dialog_xid_, RevertToParent, | |
181 CurrentTime); | |
182 break; | |
183 } | |
184 | |
175 OnActiveWindowChanged(window, ACTIVE); | 185 OnActiveWindowChanged(window, ACTIVE); |
176 } | 186 } |
177 } | 187 } |
178 break; | 188 break; |
179 } | 189 } |
180 | 190 |
181 case CreateNotify: | 191 case CreateNotify: |
182 OnWindowCreatedOrDestroyed(event->type, event->xcreatewindow.window); | 192 OnWindowCreatedOrDestroyed(event->type, event->xcreatewindow.window); |
183 break; | 193 break; |
184 case DestroyNotify: | 194 case DestroyNotify: |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
240 } else { | 250 } else { |
241 ui::XMenuList::GetInstance()->MaybeUnregisterMenu(window); | 251 ui::XMenuList::GetInstance()->MaybeUnregisterMenu(window); |
242 } | 252 } |
243 | 253 |
244 if (event_type == DestroyNotify) { | 254 if (event_type == DestroyNotify) { |
245 // Notify the XForeignWindowManager that |window| has been destroyed. | 255 // Notify the XForeignWindowManager that |window| has been destroyed. |
246 ui::XForeignWindowManager::GetInstance()->OnWindowDestroyed(window); | 256 ui::XForeignWindowManager::GetInstance()->OnWindowDestroyed(window); |
247 } | 257 } |
248 } | 258 } |
249 | 259 |
260 void X11DesktopHandler::SetModalDialog(XID dialog) { | |
261 modal_dialog_xid_ = dialog; | |
262 | |
263 if (dialog) { | |
264 DesktopWindowTreeHostX11* host = | |
265 views::DesktopWindowTreeHostX11::GetHostForXID(current_window_); | |
266 // ScopedWindowTargeter is used to temporarily replace the event-targeter | |
267 // with NullEventTargeter for the host window. | |
268 scoped_targeter_.reset(new aura::ScopedWindowTargeter(host->window(), | |
sadrul
2015/04/21 19:50:01
the indent here is wrong.
| |
269 scoped_ptr<ui::EventTargeter>(new ui::NullEventTargeter))); | |
270 } else | |
271 scoped_targeter_.reset(); | |
272 } | |
273 | |
250 } // namespace views | 274 } // namespace views |
OLD | NEW |