| 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/x11_desktop_handler.h" | 5 #include "ui/views/widget/x11_desktop_handler.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "ui/aura/desktop/desktop_activation_client.h" | 8 #include "ui/aura/desktop/desktop_activation_client.h" |
| 9 #include "ui/aura/dispatcher_linux.h" | |
| 10 #include "ui/aura/env.h" | 9 #include "ui/aura/env.h" |
| 11 #include "ui/aura/focus_manager.h" | 10 #include "ui/aura/focus_manager.h" |
| 12 #include "ui/aura/root_window.h" | 11 #include "ui/aura/root_window.h" |
| 13 #include "ui/base/x/x11_util.h" | 12 #include "ui/base/x/x11_util.h" |
| 14 #include "ui/views/widget/desktop_native_widget_helper_aura.h" | 13 #include "ui/views/widget/desktop_native_widget_helper_aura.h" |
| 15 | 14 |
| 16 namespace { | 15 namespace { |
| 17 | 16 |
| 18 const char* kAtomsToCache[] = { | 17 const char* kAtomsToCache[] = { |
| 19 "_NET_ACTIVE_WINDOW", | 18 "_NET_ACTIVE_WINDOW", |
| (...skipping 15 matching lines...) Expand all Loading... |
| 35 return g_handler; | 34 return g_handler; |
| 36 } | 35 } |
| 37 | 36 |
| 38 X11DesktopHandler::X11DesktopHandler() | 37 X11DesktopHandler::X11DesktopHandler() |
| 39 : xdisplay_(base::MessagePumpAuraX11::GetDefaultXDisplay()), | 38 : xdisplay_(base::MessagePumpAuraX11::GetDefaultXDisplay()), |
| 40 x_root_window_(DefaultRootWindow(xdisplay_)), | 39 x_root_window_(DefaultRootWindow(xdisplay_)), |
| 41 atom_cache_(xdisplay_, kAtomsToCache), | 40 atom_cache_(xdisplay_, kAtomsToCache), |
| 42 focus_manager_(new aura::FocusManager), | 41 focus_manager_(new aura::FocusManager), |
| 43 desktop_activation_client_( | 42 desktop_activation_client_( |
| 44 new aura::DesktopActivationClient(focus_manager_.get())) { | 43 new aura::DesktopActivationClient(focus_manager_.get())) { |
| 45 static_cast<aura::DispatcherLinux*>( | 44 base::MessagePumpAuraX11::Current()->AddDispatcherForRootWindow(this); |
| 46 aura::Env::GetInstance()->GetDispatcher())-> | |
| 47 AddDispatcherForRootWindow(this); | |
| 48 aura::Env::GetInstance()->AddObserver(this); | 45 aura::Env::GetInstance()->AddObserver(this); |
| 49 | 46 |
| 50 XWindowAttributes attr; | 47 XWindowAttributes attr; |
| 51 XGetWindowAttributes(xdisplay_, x_root_window_, &attr); | 48 XGetWindowAttributes(xdisplay_, x_root_window_, &attr); |
| 52 XSelectInput(xdisplay_, x_root_window_, | 49 XSelectInput(xdisplay_, x_root_window_, |
| 53 attr.your_event_mask | PropertyChangeMask | | 50 attr.your_event_mask | PropertyChangeMask | |
| 54 StructureNotifyMask | SubstructureNotifyMask); | 51 StructureNotifyMask | SubstructureNotifyMask); |
| 55 } | 52 } |
| 56 | 53 |
| 57 X11DesktopHandler::~X11DesktopHandler() { | 54 X11DesktopHandler::~X11DesktopHandler() { |
| 58 aura::Env::GetInstance()->RemoveObserver(this); | 55 aura::Env::GetInstance()->RemoveObserver(this); |
| 59 static_cast<aura::DispatcherLinux*>( | 56 base::MessagePumpAuraX11::Current()->RemoveDispatcherForRootWindow(this); |
| 60 aura::Env::GetInstance()->GetDispatcher())-> | |
| 61 RemoveDispatcherForRootWindow(this); | |
| 62 } | 57 } |
| 63 | 58 |
| 64 bool X11DesktopHandler::Dispatch(const base::NativeEvent& event) { | 59 bool X11DesktopHandler::Dispatch(const base::NativeEvent& event) { |
| 65 // Check for a change to the active window. | 60 // Check for a change to the active window. |
| 66 switch (event->type) { | 61 switch (event->type) { |
| 67 case PropertyNotify: { | 62 case PropertyNotify: { |
| 68 ::Atom active_window = atom_cache_.GetAtom("_NET_ACTIVE_WINDOW"); | 63 ::Atom active_window = atom_cache_.GetAtom("_NET_ACTIVE_WINDOW"); |
| 69 | 64 |
| 70 if (event->xproperty.window == x_root_window_ && | 65 if (event->xproperty.window == x_root_window_ && |
| 71 event->xproperty.atom == active_window) { | 66 event->xproperty.atom == active_window) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 96 aura::RootWindow* root_window = | 91 aura::RootWindow* root_window = |
| 97 aura::RootWindow::GetForAcceleratedWidget(xid); | 92 aura::RootWindow::GetForAcceleratedWidget(xid); |
| 98 aura::Window* window = root_window ? | 93 aura::Window* window = root_window ? |
| 99 views::DesktopNativeWidgetHelperAura::GetViewsWindowForRootWindow( | 94 views::DesktopNativeWidgetHelperAura::GetViewsWindowForRootWindow( |
| 100 root_window) : NULL; | 95 root_window) : NULL; |
| 101 | 96 |
| 102 desktop_activation_client_->ActivateWindow(window); | 97 desktop_activation_client_->ActivateWindow(window); |
| 103 } | 98 } |
| 104 | 99 |
| 105 } // namespace views | 100 } // namespace views |
| OLD | NEW |