blob: db2556d76155f0e1cdb8000f5a0ab6af217f901a (
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
|
// Copyright 2016 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_AURA_MUS_FOCUS_SYNCHRONIZER_H_
#define UI_AURA_MUS_FOCUS_SYNCHRONIZER_H_
#include "base/macros.h"
#include "ui/aura/client/focus_change_observer.h"
#include "ui/aura/env_observer.h"
namespace ui {
namespace mojom {
class WindowTree;
}
}
namespace aura {
class FocusSynchronizerDelegate;
class WindowMus;
namespace client {
class FocusClient;
}
// FocusSynchronizer is resonsible for keeping focus in sync between aura
// and the mus server.
class FocusSynchronizer : public client::FocusChangeObserver,
public EnvObserver {
public:
FocusSynchronizer(FocusSynchronizerDelegate* delegate,
ui::mojom::WindowTree* window_tree);
~FocusSynchronizer() override;
// Called when the server side wants to change focus to |window|.
void SetFocusFromServer(WindowMus* window);
// Called when the focused window is destroyed.
void OnFocusedWindowDestroyed();
WindowMus* focused_window() { return focused_window_; }
private:
void SetActiveFocusClient(client::FocusClient* focus_client);
// Called internally to set |focused_window_| and update the server.
void SetFocusedWindow(WindowMus* window);
// Overriden from client::FocusChangeObserver:
void OnWindowFocused(Window* gained_focus, Window* lost_focus) override;
// Overrided from EnvObserver:
void OnWindowInitialized(Window* window) override;
void OnActiveFocusClientChanged(client::FocusClient* focus_client,
Window* window) override;
FocusSynchronizerDelegate* delegate_;
ui::mojom::WindowTree* window_tree_;
client::FocusClient* active_focus_client_ = nullptr;
bool setting_focus_ = false;
WindowMus* window_setting_focus_to_ = nullptr;
WindowMus* focused_window_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(FocusSynchronizer);
};
} // namespace aura
#endif // UI_AURA_MUS_FOCUS_SYNCHRONIZER_H_
|