| 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 24 matching lines...) Expand all Loading... |
| 35 X11DesktopHandler* X11DesktopHandler::get() { | 35 X11DesktopHandler* X11DesktopHandler::get() { |
| 36 if (!g_handler) | 36 if (!g_handler) |
| 37 g_handler = new X11DesktopHandler; | 37 g_handler = new X11DesktopHandler; |
| 38 | 38 |
| 39 return g_handler; | 39 return g_handler; |
| 40 } | 40 } |
| 41 | 41 |
| 42 X11DesktopHandler::X11DesktopHandler() | 42 X11DesktopHandler::X11DesktopHandler() |
| 43 : xdisplay_(gfx::GetXDisplay()), | 43 : xdisplay_(gfx::GetXDisplay()), |
| 44 x_root_window_(DefaultRootWindow(xdisplay_)), | 44 x_root_window_(DefaultRootWindow(xdisplay_)), |
| 45 wm_user_time_ms_(0), |
| 45 current_window_(None), | 46 current_window_(None), |
| 46 atom_cache_(xdisplay_, kAtomsToCache), | 47 atom_cache_(xdisplay_, kAtomsToCache), |
| 47 wm_supports_active_window_(false) { | 48 wm_supports_active_window_(false) { |
| 48 if (ui::PlatformEventSource::GetInstance()) | 49 if (ui::PlatformEventSource::GetInstance()) |
| 49 ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); | 50 ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); |
| 50 aura::Env::GetInstance()->AddObserver(this); | 51 aura::Env::GetInstance()->AddObserver(this); |
| 51 | 52 |
| 52 XWindowAttributes attr; | 53 XWindowAttributes attr; |
| 53 XGetWindowAttributes(xdisplay_, x_root_window_, &attr); | 54 XGetWindowAttributes(xdisplay_, x_root_window_, &attr); |
| 54 XSelectInput(xdisplay_, x_root_window_, | 55 XSelectInput(xdisplay_, x_root_window_, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 71 if (wm_supports_active_window_) { | 72 if (wm_supports_active_window_) { |
| 72 DCHECK_EQ(gfx::GetXDisplay(), xdisplay_); | 73 DCHECK_EQ(gfx::GetXDisplay(), xdisplay_); |
| 73 | 74 |
| 74 XEvent xclient; | 75 XEvent xclient; |
| 75 memset(&xclient, 0, sizeof(xclient)); | 76 memset(&xclient, 0, sizeof(xclient)); |
| 76 xclient.type = ClientMessage; | 77 xclient.type = ClientMessage; |
| 77 xclient.xclient.window = window; | 78 xclient.xclient.window = window; |
| 78 xclient.xclient.message_type = atom_cache_.GetAtom("_NET_ACTIVE_WINDOW"); | 79 xclient.xclient.message_type = atom_cache_.GetAtom("_NET_ACTIVE_WINDOW"); |
| 79 xclient.xclient.format = 32; | 80 xclient.xclient.format = 32; |
| 80 xclient.xclient.data.l[0] = 1; // Specified we are an app. | 81 xclient.xclient.data.l[0] = 1; // Specified we are an app. |
| 81 xclient.xclient.data.l[1] = CurrentTime; | 82 xclient.xclient.data.l[1] = wm_user_time_ms_; |
| 82 xclient.xclient.data.l[2] = None; | 83 xclient.xclient.data.l[2] = None; |
| 83 xclient.xclient.data.l[3] = 0; | 84 xclient.xclient.data.l[3] = 0; |
| 84 xclient.xclient.data.l[4] = 0; | 85 xclient.xclient.data.l[4] = 0; |
| 85 | 86 |
| 86 XSendEvent(xdisplay_, x_root_window_, False, | 87 XSendEvent(xdisplay_, x_root_window_, False, |
| 87 SubstructureRedirectMask | SubstructureNotifyMask, | 88 SubstructureRedirectMask | SubstructureNotifyMask, |
| 88 &xclient); | 89 &xclient); |
| 89 } else { | 90 } else { |
| 90 XRaiseWindow(xdisplay_, window); | 91 XRaiseWindow(xdisplay_, window); |
| 91 | 92 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 // Update the current window ID to effectively change the active widget. | 186 // Update the current window ID to effectively change the active widget. |
| 186 current_window_ = xid; | 187 current_window_ = xid; |
| 187 | 188 |
| 188 DesktopWindowTreeHostX11* new_host = | 189 DesktopWindowTreeHostX11* new_host = |
| 189 views::DesktopWindowTreeHostX11::GetHostForXID(xid); | 190 views::DesktopWindowTreeHostX11::GetHostForXID(xid); |
| 190 if (new_host) | 191 if (new_host) |
| 191 new_host->HandleNativeWidgetActivationChanged(true); | 192 new_host->HandleNativeWidgetActivationChanged(true); |
| 192 } | 193 } |
| 193 | 194 |
| 194 } // namespace views | 195 } // namespace views |
| OLD | NEW |