Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: ui/views/widget/desktop_aura/x11_desktop_handler.cc

Issue 138903007: Fixes _NET_ACTIVE_WINDOW support check in order to not always return no. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@aura_deactivate
Patch Set: fix views_unittests Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/widget/desktop_aura/x11_desktop_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 wm_supports_active_window_(false) { 48 wm_supports_active_window_(false) {
49 base::MessagePumpX11::Current()->AddDispatcherForRootWindow(this); 49 base::MessagePumpX11::Current()->AddDispatcherForRootWindow(this);
50 aura::Env::GetInstance()->AddObserver(this); 50 aura::Env::GetInstance()->AddObserver(this);
51 51
52 XWindowAttributes attr; 52 XWindowAttributes attr;
53 XGetWindowAttributes(xdisplay_, x_root_window_, &attr); 53 XGetWindowAttributes(xdisplay_, x_root_window_, &attr);
54 XSelectInput(xdisplay_, x_root_window_, 54 XSelectInput(xdisplay_, x_root_window_,
55 attr.your_event_mask | PropertyChangeMask | 55 attr.your_event_mask | PropertyChangeMask |
56 StructureNotifyMask | SubstructureNotifyMask); 56 StructureNotifyMask | SubstructureNotifyMask);
57 57
58 std::vector<Atom> atoms; 58 ::Window active_window;
59 if (ui::GetAtomArrayProperty(x_root_window_, "_NET_ACTIVE_WINDOW", &atoms)) { 59 wm_supports_active_window_ =
60 Atom active_window = atom_cache_.GetAtom("_NET_ACTIVE_WINDOW"); 60 ui::GetXIDProperty(x_root_window_, "_NET_ACTIVE_WINDOW", &active_window) &&
61 for (std::vector<Atom>::iterator iter = atoms.begin(); iter != atoms.end(); 61 active_window;
62 ++iter) {
63 if (*(iter) == active_window) {
64 wm_supports_active_window_ = true;
65 break;
66 }
67 }
68 }
69 } 62 }
70 63
71 X11DesktopHandler::~X11DesktopHandler() { 64 X11DesktopHandler::~X11DesktopHandler() {
72 aura::Env::GetInstance()->RemoveObserver(this); 65 aura::Env::GetInstance()->RemoveObserver(this);
73 base::MessagePumpX11::Current()->RemoveDispatcherForRootWindow(this); 66 base::MessagePumpX11::Current()->RemoveDispatcherForRootWindow(this);
74 } 67 }
75 68
76 void X11DesktopHandler::ActivateWindow(::Window window) { 69 void X11DesktopHandler::ActivateWindow(::Window window) {
77 if (wm_supports_active_window_) { 70 if (wm_supports_active_window_) {
78 DCHECK_EQ(gfx::GetXDisplay(), xdisplay_); 71 DCHECK_EQ(gfx::GetXDisplay(), xdisplay_);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 break; 122 break;
130 default: 123 default:
131 NOTREACHED(); 124 NOTREACHED();
132 } 125 }
133 } 126 }
134 127
135 bool X11DesktopHandler::Dispatch(const base::NativeEvent& event) { 128 bool X11DesktopHandler::Dispatch(const base::NativeEvent& event) {
136 // Check for a change to the active window. 129 // Check for a change to the active window.
137 switch (event->type) { 130 switch (event->type) {
138 case PropertyNotify: { 131 case PropertyNotify: {
139 ::Atom active_window = atom_cache_.GetAtom("_NET_ACTIVE_WINDOW"); 132 ::Atom active_window_atom = atom_cache_.GetAtom("_NET_ACTIVE_WINDOW");
140 133
141 if (event->xproperty.window == x_root_window_ && 134 if (event->xproperty.window == x_root_window_ &&
142 event->xproperty.atom == active_window) { 135 event->xproperty.atom == active_window_atom) {
143 int window; 136 ::Window window;
144 if (ui::GetIntProperty(x_root_window_, "_NET_ACTIVE_WINDOW", &window) && 137 if (ui::GetXIDProperty(x_root_window_, "_NET_ACTIVE_WINDOW", &window) &&
145 window) { 138 window) {
146 OnActiveWindowChanged(static_cast< ::Window>(window)); 139 OnActiveWindowChanged(window);
147 } 140 }
148 } 141 }
149 break; 142 break;
150 } 143 }
151 } 144 }
152 145
153 return true; 146 return true;
154 } 147 }
155 148
156 void X11DesktopHandler::OnWindowInitialized(aura::Window* window) { 149 void X11DesktopHandler::OnWindowInitialized(aura::Window* window) {
(...skipping 14 matching lines...) Expand all
171 164
172 DesktopWindowTreeHostX11* new_host = 165 DesktopWindowTreeHostX11* new_host =
173 views::DesktopWindowTreeHostX11::GetHostForXID(xid); 166 views::DesktopWindowTreeHostX11::GetHostForXID(xid);
174 if (new_host) 167 if (new_host)
175 new_host->HandleNativeWidgetActivationChanged(true); 168 new_host->HandleNativeWidgetActivationChanged(true);
176 169
177 current_window_ = xid; 170 current_window_ = xid;
178 } 171 }
179 172
180 } // namespace views 173 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/x11_desktop_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698