Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ui / ozone / platform / drm / host / drm_window_host_manager.cc
blob4aad9162d642e5ef810068eed614df6fea50adf9
1 // Copyright 2014 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 #include "ui/ozone/platform/drm/host/drm_window_host_manager.h"
7 #include "base/logging.h"
8 #include "ui/ozone/platform/drm/host/drm_window_host.h"
10 namespace ui {
12 DrmWindowHostManager::DrmWindowHostManager() {
15 DrmWindowHostManager::~DrmWindowHostManager() {
18 gfx::AcceleratedWidget DrmWindowHostManager::NextAcceleratedWidget() {
19 // We're not using 0 since other code assumes that a 0 AcceleratedWidget is an
20 // invalid widget.
21 return ++last_allocated_widget_;
24 void DrmWindowHostManager::AddWindow(gfx::AcceleratedWidget widget,
25 DrmWindowHost* window) {
26 std::pair<WidgetToWindowMap::iterator, bool> result = window_map_.insert(
27 std::pair<gfx::AcceleratedWidget, DrmWindowHost*>(widget, window));
28 DCHECK(result.second) << "Window for " << widget << " already added.";
31 void DrmWindowHostManager::RemoveWindow(gfx::AcceleratedWidget widget) {
32 WidgetToWindowMap::iterator it = window_map_.find(widget);
33 if (it != window_map_.end())
34 window_map_.erase(it);
35 else
36 NOTREACHED() << "Attempting to remove non-existing window " << widget;
38 if (event_grabber_ == widget)
39 event_grabber_ = gfx::kNullAcceleratedWidget;
42 DrmWindowHost* DrmWindowHostManager::GetWindow(gfx::AcceleratedWidget widget) {
43 WidgetToWindowMap::iterator it = window_map_.find(widget);
44 if (it != window_map_.end())
45 return it->second;
47 NOTREACHED() << "Attempting to get non-existing window " << widget;
48 return NULL;
51 DrmWindowHost* DrmWindowHostManager::GetWindowAt(const gfx::Point& location) {
52 for (auto it = window_map_.begin(); it != window_map_.end(); ++it)
53 if (it->second->GetBounds().Contains(location))
54 return it->second;
56 return NULL;
59 DrmWindowHost* DrmWindowHostManager::GetPrimaryWindow() {
60 auto it = window_map_.begin();
61 return it != window_map_.end() ? it->second : nullptr;
64 void DrmWindowHostManager::GrabEvents(gfx::AcceleratedWidget widget) {
65 if (event_grabber_ != gfx::kNullAcceleratedWidget)
66 return;
67 event_grabber_ = widget;
70 void DrmWindowHostManager::UngrabEvents(gfx::AcceleratedWidget widget) {
71 if (event_grabber_ != widget)
72 return;
73 event_grabber_ = gfx::kNullAcceleratedWidget;
76 } // namespace ui