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

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

Issue 2108933003: Reorder browser list on workspace switch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from erg and thestig Created 4 years, 5 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
« ui/display/desktop_observer.cc ('K') | « ui/display/display.gyp ('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"
11 #include "base/strings/string_number_conversions.h"
11 #include "ui/aura/env.h" 12 #include "ui/aura/env.h"
12 #include "ui/aura/window_event_dispatcher.h" 13 #include "ui/aura/window_event_dispatcher.h"
13 #include "ui/base/x/x11_foreign_window_manager.h" 14 #include "ui/base/x/x11_foreign_window_manager.h"
14 #include "ui/base/x/x11_menu_list.h" 15 #include "ui/base/x/x11_menu_list.h"
15 #include "ui/base/x/x11_util.h" 16 #include "ui/base/x/x11_util.h"
17 #include "ui/display/desktop_observer.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/widget/desktop_aura/desktop_window_tree_host_x11.h" 20 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
19 21
20 namespace { 22 namespace {
21 23
22 const char* kAtomsToCache[] = { 24 const char* const kAtomsToCache[] = {
23 "_NET_ACTIVE_WINDOW", 25 "_NET_ACTIVE_WINDOW",
24 NULL 26 "_NET_CURRENT_DESKTOP",
27 nullptr
25 }; 28 };
26 29
27 // Our global instance. Deleted when our Env() is deleted. 30 // Our global instance. Deleted when our Env() is deleted.
28 views::X11DesktopHandler* g_handler = NULL; 31 views::X11DesktopHandler* g_handler = NULL;
29 32
30 } // namespace 33 } // namespace
31 34
32 namespace views { 35 namespace views {
33 36
34 // static 37 // static
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 180
178 bool X11DesktopHandler::CanDispatchEvent(const ui::PlatformEvent& event) { 181 bool X11DesktopHandler::CanDispatchEvent(const ui::PlatformEvent& event) {
179 return event->type == CreateNotify || event->type == DestroyNotify || 182 return event->type == CreateNotify || event->type == DestroyNotify ||
180 (event->type == PropertyNotify && 183 (event->type == PropertyNotify &&
181 event->xproperty.window == x_root_window_); 184 event->xproperty.window == x_root_window_);
182 } 185 }
183 186
184 uint32_t X11DesktopHandler::DispatchEvent(const ui::PlatformEvent& event) { 187 uint32_t X11DesktopHandler::DispatchEvent(const ui::PlatformEvent& event) {
185 switch (event->type) { 188 switch (event->type) {
186 case PropertyNotify: { 189 case PropertyNotify: {
187 // Check for a change to the active window. 190 if (event->xproperty.atom == atom_cache_.GetAtom("_NET_ACTIVE_WINDOW")) {
188 CHECK_EQ(x_root_window_, event->xproperty.window);
189 ::Atom active_window_atom = atom_cache_.GetAtom("_NET_ACTIVE_WINDOW");
190 if (event->xproperty.atom == active_window_atom) {
191 ::Window window; 191 ::Window window;
192 if (ui::GetXIDProperty(x_root_window_, "_NET_ACTIVE_WINDOW", &window) && 192 if (ui::GetXIDProperty(x_root_window_, "_NET_ACTIVE_WINDOW", &window) &&
193 window) { 193 window) {
194 x_active_window_ = window; 194 x_active_window_ = window;
195 OnActiveWindowChanged(window, ACTIVE); 195 OnActiveWindowChanged(window, ACTIVE);
196 } else { 196 } else {
197 x_active_window_ = None; 197 x_active_window_ = None;
198 } 198 }
199 } else if (event->xproperty.atom ==
200 atom_cache_.GetAtom("_NET_CURRENT_DESKTOP")) {
201 int desktop;
202 if (ui::GetCurrentDesktop(&desktop))
203 display::desktop::OnWorkspaceChanged(base::IntToString(desktop));
199 } 204 }
200 break; 205 break;
201 } 206 }
202
203 case CreateNotify: 207 case CreateNotify:
204 OnWindowCreatedOrDestroyed(event->type, event->xcreatewindow.window); 208 OnWindowCreatedOrDestroyed(event->type, event->xcreatewindow.window);
205 break; 209 break;
206 case DestroyNotify: 210 case DestroyNotify:
207 OnWindowCreatedOrDestroyed(event->type, event->xdestroywindow.window); 211 OnWindowCreatedOrDestroyed(event->type, event->xdestroywindow.window);
208 // If the current active window is being destroyed, reset our tracker. 212 // If the current active window is being destroyed, reset our tracker.
209 if (x_active_window_ == event->xdestroywindow.window) { 213 if (x_active_window_ == event->xdestroywindow.window) {
210 x_active_window_ = None; 214 x_active_window_ = None;
211 } 215 }
212 break; 216 break;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 ui::XMenuList::GetInstance()->MaybeUnregisterMenu(window); 271 ui::XMenuList::GetInstance()->MaybeUnregisterMenu(window);
268 } 272 }
269 273
270 if (event_type == DestroyNotify) { 274 if (event_type == DestroyNotify) {
271 // Notify the XForeignWindowManager that |window| has been destroyed. 275 // Notify the XForeignWindowManager that |window| has been destroyed.
272 ui::XForeignWindowManager::GetInstance()->OnWindowDestroyed(window); 276 ui::XForeignWindowManager::GetInstance()->OnWindowDestroyed(window);
273 } 277 }
274 } 278 }
275 279
276 } // namespace views 280 } // namespace views
OLDNEW
« ui/display/desktop_observer.cc ('K') | « ui/display/display.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698