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 #ifndef UI_OZONE_PLATFORM_DRM_HOST_DRM_WINDOW_HOST_MANAGER_H_
6 #define UI_OZONE_PLATFORM_DRM_HOST_DRM_WINDOW_HOST_MANAGER_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "ui/gfx/native_widget_types.h"
19 class DrmGpuPlatformSupportHost
;
22 // Responsible for keeping the mapping between the allocated widgets and
24 class DrmWindowHostManager
{
26 DrmWindowHostManager();
27 ~DrmWindowHostManager();
29 gfx::AcceleratedWidget
NextAcceleratedWidget();
31 // Adds a window for |widget|. Note: |widget| should not be associated when
32 // calling this function.
33 void AddWindow(gfx::AcceleratedWidget widget
, DrmWindowHost
* window
);
35 // Removes the window association for |widget|. Note: |widget| must be
36 // associated with a window when calling this function.
37 void RemoveWindow(gfx::AcceleratedWidget widget
);
39 // Returns the window associated with |widget|. Note: This function should
40 // only be called if a valid window has been associated.
41 DrmWindowHost
* GetWindow(gfx::AcceleratedWidget widget
);
43 // Returns the window containing the specified screen location, or NULL.
44 DrmWindowHost
* GetWindowAt(const gfx::Point
& location
);
46 // Returns a window. Probably the first one created.
47 DrmWindowHost
* GetPrimaryWindow();
49 // Tries to set a given widget as the recipient for events. It will
50 // fail if there is already another widget as recipient.
51 void GrabEvents(gfx::AcceleratedWidget widget
);
53 // Unsets a given widget as the recipient for events.
54 void UngrabEvents(gfx::AcceleratedWidget widget
);
56 // Gets the current widget recipient of mouse events.
57 gfx::AcceleratedWidget
event_grabber() const { return event_grabber_
; }
60 typedef std::map
<gfx::AcceleratedWidget
, DrmWindowHost
*> WidgetToWindowMap
;
62 gfx::AcceleratedWidget last_allocated_widget_
= 0;
63 WidgetToWindowMap window_map_
;
65 gfx::AcceleratedWidget event_grabber_
= gfx::kNullAcceleratedWidget
;
67 DISALLOW_COPY_AND_ASSIGN(DrmWindowHostManager
);
72 #endif // UI_OZONE_PLATFORM_DRM_HOST_DRM_WINDOW_HOST_MANAGER_H_