blob: 72651a394ec959cd08d62a2dd1e175540ea733b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_HANDLER_H_
#define UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_HANDLER_H_
#include <X11/Xlib.h>
// Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class.
#undef RootWindow
#include "base/message_loop/message_pump_dispatcher.h"
#include "ui/aura/env_observer.h"
#include "ui/gfx/x/x11_atom_cache.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/views/views_export.h"
template <typename T> struct DefaultSingletonTraits;
namespace views {
// A singleton that owns global objects related to the desktop and listens for
// X11 events on the X11 root window. Destroys itself when aura::Env is
// deleted.
class VIEWS_EXPORT X11DesktopHandler : public base::MessagePumpDispatcher,
public aura::EnvObserver {
public:
// Returns the singleton handler.
static X11DesktopHandler* get();
// Sends a request to the window manager to activate |window|.
// This method should only be called if the window is already mapped.
void ActivateWindow(::Window window);
// Deactivates the |window| and activates the window just below it in z-order.
// |window| must be active.
void DeactivateWindow(::Window window);
// Checks if the current active window is |window|.
bool IsActiveWindow(::Window window) const;
// Processes activation/focus related events. Some of these events are
// dispatched to the X11 window dispatcher, and not to the X11 root-window
// dispatcher. The window dispatcher sends these events to here.
void ProcessXEvent(const base::NativeEvent& event);
// Overridden from MessagePumpDispatcher:
virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE;
// Overridden from aura::EnvObserver:
virtual void OnWindowInitialized(aura::Window* window) OVERRIDE;
virtual void OnWillDestroyEnv() OVERRIDE;
// Allows to override wm_supports_active_window_ value for tests. If the WM
// supports _NET_ACTIVE_WINDOW, activation is async otherwise it is sync.
void SetWMSupportsActiveWindowForTests(bool value) {
wm_supports_active_window_ = value;
}
private:
explicit X11DesktopHandler();
virtual ~X11DesktopHandler();
// Handles changes in activation.
void OnActiveWindowChanged(::Window window);
// The display and the native X window hosting the root window.
XDisplay* xdisplay_;
// The native root window.
::Window x_root_window_;
// The activated window.
::Window current_window_;
ui::X11AtomCache atom_cache_;
bool wm_supports_active_window_;
DISALLOW_COPY_AND_ASSIGN(X11DesktopHandler);
};
} // namespace views
#endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_HANDLER_H_
|