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 "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "ui/aura/env.h" | 8 #include "ui/aura/env.h" |
9 #include "ui/aura/focus_manager.h" | 9 #include "ui/aura/focus_manager.h" |
10 #include "ui/aura/root_window.h" | 10 #include "ui/aura/root_window.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 // static | 32 // static |
33 X11DesktopHandler* X11DesktopHandler::get() { | 33 X11DesktopHandler* X11DesktopHandler::get() { |
34 if (!g_handler) | 34 if (!g_handler) |
35 g_handler = new X11DesktopHandler; | 35 g_handler = new X11DesktopHandler; |
36 | 36 |
37 return g_handler; | 37 return g_handler; |
38 } | 38 } |
39 | 39 |
40 X11DesktopHandler::X11DesktopHandler() | 40 X11DesktopHandler::X11DesktopHandler() |
41 : xdisplay_(base::MessagePumpAuraX11::GetDefaultXDisplay()), | 41 : xdisplay_(base::MessagePumpX11::GetDefaultXDisplay()), |
42 x_root_window_(DefaultRootWindow(xdisplay_)), | 42 x_root_window_(DefaultRootWindow(xdisplay_)), |
43 current_window_(None), | 43 current_window_(None), |
44 atom_cache_(xdisplay_, kAtomsToCache) { | 44 atom_cache_(xdisplay_, kAtomsToCache) { |
45 base::MessagePumpAuraX11::Current()->AddDispatcherForRootWindow(this); | 45 base::MessagePumpX11::Current()->AddDispatcherForRootWindow(this); |
46 aura::Env::GetInstance()->AddObserver(this); | 46 aura::Env::GetInstance()->AddObserver(this); |
47 | 47 |
48 XWindowAttributes attr; | 48 XWindowAttributes attr; |
49 XGetWindowAttributes(xdisplay_, x_root_window_, &attr); | 49 XGetWindowAttributes(xdisplay_, x_root_window_, &attr); |
50 XSelectInput(xdisplay_, x_root_window_, | 50 XSelectInput(xdisplay_, x_root_window_, |
51 attr.your_event_mask | PropertyChangeMask | | 51 attr.your_event_mask | PropertyChangeMask | |
52 StructureNotifyMask | SubstructureNotifyMask); | 52 StructureNotifyMask | SubstructureNotifyMask); |
53 } | 53 } |
54 | 54 |
55 X11DesktopHandler::~X11DesktopHandler() { | 55 X11DesktopHandler::~X11DesktopHandler() { |
56 aura::Env::GetInstance()->RemoveObserver(this); | 56 aura::Env::GetInstance()->RemoveObserver(this); |
57 base::MessagePumpAuraX11::Current()->RemoveDispatcherForRootWindow(this); | 57 base::MessagePumpX11::Current()->RemoveDispatcherForRootWindow(this); |
58 } | 58 } |
59 | 59 |
60 void X11DesktopHandler::ActivateWindow(::Window window) { | 60 void X11DesktopHandler::ActivateWindow(::Window window) { |
61 DCHECK_EQ(base::MessagePumpAuraX11::GetDefaultXDisplay(), xdisplay_); | 61 DCHECK_EQ(base::MessagePumpX11::GetDefaultXDisplay(), xdisplay_); |
62 | 62 |
63 XEvent xclient; | 63 XEvent xclient; |
64 memset(&xclient, 0, sizeof(xclient)); | 64 memset(&xclient, 0, sizeof(xclient)); |
65 xclient.type = ClientMessage; | 65 xclient.type = ClientMessage; |
66 xclient.xclient.window = window; | 66 xclient.xclient.window = window; |
67 xclient.xclient.message_type = atom_cache_.GetAtom("_NET_ACTIVE_WINDOW"); | 67 xclient.xclient.message_type = atom_cache_.GetAtom("_NET_ACTIVE_WINDOW"); |
68 xclient.xclient.format = 32; | 68 xclient.xclient.format = 32; |
69 xclient.xclient.data.l[0] = 1; // Specified we are an app. | 69 xclient.xclient.data.l[0] = 1; // Specified we are an app. |
70 xclient.xclient.data.l[1] = CurrentTime; | 70 xclient.xclient.data.l[1] = CurrentTime; |
71 xclient.xclient.data.l[2] = None; | 71 xclient.xclient.data.l[2] = None; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 118 |
119 DesktopRootWindowHostX11* new_host = | 119 DesktopRootWindowHostX11* new_host = |
120 views::DesktopRootWindowHostX11::GetHostForXID(xid); | 120 views::DesktopRootWindowHostX11::GetHostForXID(xid); |
121 if (new_host) | 121 if (new_host) |
122 new_host->HandleNativeWidgetActivationChanged(true); | 122 new_host->HandleNativeWidgetActivationChanged(true); |
123 | 123 |
124 current_window_ = xid; | 124 current_window_ = xid; |
125 } | 125 } |
126 | 126 |
127 } // namespace views | 127 } // namespace views |
OLD | NEW |