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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 xclient.xclient.data.l[1] = CurrentTime; | 87 xclient.xclient.data.l[1] = CurrentTime; |
88 xclient.xclient.data.l[2] = None; | 88 xclient.xclient.data.l[2] = None; |
89 xclient.xclient.data.l[3] = 0; | 89 xclient.xclient.data.l[3] = 0; |
90 xclient.xclient.data.l[4] = 0; | 90 xclient.xclient.data.l[4] = 0; |
91 | 91 |
92 XSendEvent(xdisplay_, x_root_window_, False, | 92 XSendEvent(xdisplay_, x_root_window_, False, |
93 SubstructureRedirectMask | SubstructureNotifyMask, | 93 SubstructureRedirectMask | SubstructureNotifyMask, |
94 &xclient); | 94 &xclient); |
95 } else { | 95 } else { |
96 XRaiseWindow(xdisplay_, window); | 96 XRaiseWindow(xdisplay_, window); |
| 97 |
| 98 // XRaiseWindow will not give input focus to the window. We now need to ask |
| 99 // the X server to do that. Note that the call will raise an X error if the |
| 100 // window is not mapped. |
| 101 XSetInputFocus(xdisplay_, window, RevertToParent, CurrentTime); |
| 102 |
97 OnActiveWindowChanged(window); | 103 OnActiveWindowChanged(window); |
98 } | 104 } |
99 } | 105 } |
100 | 106 |
101 bool X11DesktopHandler::IsActiveWindow(::Window window) const { | 107 bool X11DesktopHandler::IsActiveWindow(::Window window) const { |
102 return window == current_window_; | 108 return window == current_window_; |
103 } | 109 } |
104 | 110 |
105 void X11DesktopHandler::ProcessXEvent(const base::NativeEvent& event) { | 111 void X11DesktopHandler::ProcessXEvent(const base::NativeEvent& event) { |
106 switch (event->type) { | 112 switch (event->type) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 | 164 |
159 DesktopWindowTreeHostX11* new_host = | 165 DesktopWindowTreeHostX11* new_host = |
160 views::DesktopWindowTreeHostX11::GetHostForXID(xid); | 166 views::DesktopWindowTreeHostX11::GetHostForXID(xid); |
161 if (new_host) | 167 if (new_host) |
162 new_host->HandleNativeWidgetActivationChanged(true); | 168 new_host->HandleNativeWidgetActivationChanged(true); |
163 | 169 |
164 current_window_ = xid; | 170 current_window_ = xid; |
165 } | 171 } |
166 | 172 |
167 } // namespace views | 173 } // namespace views |
OLD | NEW |