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
3 // found in the LICENSE file.
5 #ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_HANDLER_H_
6 #define UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_HANDLER_H_
9 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class.
12 #include "base/message_loop/message_loop.h"
13 #include "ui/aura/env_observer.h"
14 #include "ui/gfx/x/x11_atom_cache.h"
15 #include "ui/gfx/x/x11_types.h"
16 #include "ui/views/views_export.h"
18 template <typename T> struct DefaultSingletonTraits;
22 // A singleton that owns global objects related to the desktop and listens for
23 // X11 events on the X11 root window. Destroys itself when aura::Env is
25 class VIEWS_EXPORT X11DesktopHandler : public base::MessageLoop::Dispatcher,
26 public aura::EnvObserver {
28 // Returns the singleton handler.
29 static X11DesktopHandler* get();
31 // Sends a request to the window manager to activate |window|.
32 void ActivateWindow(::Window window);
34 // Checks if the current active window is |window|.
35 bool IsActiveWindow(::Window window) const;
37 // Overridden from MessageLoop::Dispatcher:
38 virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE;
40 // Overridden from aura::EnvObserver:
41 virtual void OnWindowInitialized(aura::Window* window) OVERRIDE;
42 virtual void OnWillDestroyEnv() OVERRIDE;
45 explicit X11DesktopHandler();
46 virtual ~X11DesktopHandler();
48 // Handles changes in activation.
49 void OnActiveWindowChanged(::Window window);
51 // The display and the native X window hosting the root window.
54 // The native root window.
55 ::Window x_root_window_;
57 // The activated window.
58 ::Window current_window_;
60 ui::X11AtomCache atom_cache_;
62 DISALLOW_COPY_AND_ASSIGN(X11DesktopHandler);
67 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_HANDLER_H_