Commit 5c8399fd authored by Antonio Gomes's avatar Antonio Gomes Committed by Santosh Mahto

Add basic mouse events support

This CL adds basic mouse events support. Events over overlapping
areas of multiple Chrome windows is still broken, but should be
fixed in a follow up CL.
parent 0ab13293
......@@ -53,17 +53,27 @@ Display::~Display() {
focus_controller_.reset();
}
if (!binding_) {
for (auto& pair : window_manager_display_root_map_)
pair.second->window_manager_state()->OnDisplayDestroying(this);
} else if (!window_manager_display_root_map_.empty()) {
// If there is a |binding_| then the tree was created specifically for this
// display (which corresponds to a WindowTreeHost).
// Notify the window manager state that the display is being destroyed.
for (auto& pair : window_manager_display_root_map_)
pair.second->window_manager_state()->OnDisplayDestroying(this);
if (binding_ && !window_manager_display_root_map_.empty()) {
// If there is a |binding_| then the tree was created specifically for one
// or more displays, which correspond to WindowTreeHosts.
WindowManagerDisplayRoot* display_root =
window_manager_display_root_map_.begin()->second;
if (display_root->window_manager_state())
window_server_->DestroyTree(
display_root->window_manager_state()->window_tree());
WindowTree* tree = display_root->window_manager_state()->window_tree();
ServerWindow* root = display_root->root();
if (tree) {
// Delete the window root corresponding to that display.
ClientWindowId root_id;
if (tree->IsWindowKnown(root, &root_id))
tree->DeleteWindow(root_id);
// Destroy the tree once all the roots have been removed.
if (tree->roots().empty())
window_server_->DestroyTree(tree);
}
}
}
......@@ -215,14 +225,26 @@ void Display::InitDisplayRoot() {
DCHECK(window_server_->IsInExternalWindowMode());
DCHECK(binding_);
external_mode_root_ = base::MakeUnique<WindowManagerDisplayRoot>(this);
std::unique_ptr<WindowManagerDisplayRoot> display_root_ptr(
new WindowManagerDisplayRoot(this));
// TODO(tonikitoo): Code still has assumptions that even in external window
// mode make 'window_manager_display_root_map_' needed.
window_manager_display_root_map_[service_manager::mojom::kRootUserID] =
external_mode_root_.get();
display_root_ptr.get();
ServerWindow* server_window = external_mode_root_->root();
WindowTree* window_tree = window_server_->GetTreeForExternalWindowMode();
ServerWindow* server_window = display_root_ptr->root();
std::unique_ptr<WindowManagerState> window_manager_state =
base::MakeUnique<WindowManagerState>(window_tree);
display_root_ptr->window_manager_state_ = window_manager_state.get();
window_tree->AddExternalModeWindowManagerState(
std::move(window_manager_state));
WindowManagerDisplayRoot* display_root = display_root_ptr.get();
display_root->window_manager_state_->AddWindowManagerDisplayRoot(
std::move(display_root_ptr));
window_tree->AddRoot(server_window);
window_tree->DoOnEmbed(nullptr /*mojom::WindowTreePtr*/, server_window);
}
......
......@@ -39,6 +39,7 @@ class DisplayBinding;
class DisplayManager;
class FocusController;
class WindowManagerDisplayRoot;
class WindowManagerState;
class WindowServer;
class WindowTree;
......@@ -227,8 +228,6 @@ class Display : public PlatformDisplayDelegate,
WindowManagerDisplayRootMap window_manager_display_root_map_;
std::unique_ptr<WindowManagerDisplayRoot> external_mode_root_;
DISALLOW_COPY_AND_ASSIGN(Display);
};
......
......@@ -47,9 +47,11 @@ void ExternalWindowTreeFactory::Register(
// window mode, the WindowTreePtr is created on the aura/WindowTreeClient
// side.
//
// NOTE: This call to ::AddTree calls ::Init. However, it will not trigger a
// ::OnEmbed call because the WindowTree instance was created above passing
// 'nullptr' as the ServerWindow, hence there is no 'root' yet.
// NOTE: WindowServer::AddTree calls WindowTree::Init, which can trigger a
// WindowTreeClient::OnEmbed call. In the particular flow though, WTC::OnEmbed
// will not get called because the WindowTree instance was created above
// taking 'nullptr' as the ServerWindow parameter, hence the WindowTree has no
// 'root' yet.
WindowTree* tree_ptr = tree.get();
window_server_->AddTree(std::move(tree), std::move(tree_binding),
nullptr /*mojom::WindowTreePtr*/);
......
......@@ -439,7 +439,8 @@ void WindowManagerState::OnDisplayDestroying(Display* display) {
(*iter)->root()->AddObserver(this);
orphaned_window_manager_display_roots_.push_back(std::move(*iter));
window_manager_display_roots_.erase(iter);
window_tree_->OnDisplayDestroying(display->GetId());
if (!window_server()->IsInExternalWindowMode())
window_tree_->OnDisplayDestroying(display->GetId());
orphaned_window_manager_display_roots_.back()->display_ = nullptr;
return;
}
......
......@@ -494,8 +494,6 @@ bool WindowTree::ProcessSetBlockingContainers(
bool WindowTree::SetCapture(const ClientWindowId& client_window_id) {
ServerWindow* window = GetWindowByClientId(client_window_id);
WindowManagerDisplayRoot* display_root = GetWindowManagerDisplayRoot(window);
if (display_root && !display_root->window_manager_state())
return false;
ServerWindow* current_capture_window =
display_root ? display_root->window_manager_state()->capture_window()
: nullptr;
......@@ -513,8 +511,6 @@ bool WindowTree::SetCapture(const ClientWindowId& client_window_id) {
bool WindowTree::ReleaseCapture(const ClientWindowId& client_window_id) {
ServerWindow* window = GetWindowByClientId(client_window_id);
WindowManagerDisplayRoot* display_root = GetWindowManagerDisplayRoot(window);
if (display_root && !display_root->window_manager_state())
return false;
ServerWindow* current_capture_window =
display_root ? display_root->window_manager_state()->capture_window()
: nullptr;
......@@ -1186,6 +1182,11 @@ Id WindowTree::ClientWindowIdToTransportId(
base::checked_cast<ClientSpecificId>(client_window_id.sink_id());
}
void WindowTree::AddExternalModeWindowManagerState(
std::unique_ptr<WindowManagerState> window_manager_state) {
external_mode_wm_states_.insert(std::move(window_manager_state));
}
bool WindowTree::ShouldRouteToWindowManager(const ServerWindow* window) const {
if (window_manager_state_)
return false; // We are the window manager, don't route to ourself.
......
......@@ -328,6 +328,10 @@ class WindowTree : public mojom::WindowTree,
// that created the window.
Id ClientWindowIdToTransportId(const ClientWindowId& client_window_id) const;
// TODO(tonikitoo,msisov): Add a comment.
void AddExternalModeWindowManagerState(
std::unique_ptr<WindowManagerState> window_manager_state);
private:
friend class test::WindowTreeTestApi;
......@@ -750,6 +754,8 @@ class WindowTree : public mojom::WindowTree,
// See mojom for details.
bool automatically_create_display_roots_ = true;
std::set<std::unique_ptr<WindowManagerState>> external_mode_wm_states_;
std::unique_ptr<WaitingForTopLevelWindowInfo>
waiting_for_top_level_window_info_;
bool embedder_intercepts_events_ = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment