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_BASE_X_X11_FOREIGN_WINDOW_MANAGER_H_
6 #define UI_BASE_X_X11_FOREIGN_WINDOW_MANAGER_H_
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "ui/base/ui_base_export.h"
14 #include "ui/gfx/x/x11_types.h"
16 // A process wide singleton for selecting events on X windows which were not
18 template <typename T
> struct DefaultSingletonTraits
;
22 // Manages the events that Chrome has selected on X windows which were not
23 // created by Chrome. This class allows several clients to select events
24 // on the same X window.
25 class UI_BASE_EXPORT XForeignWindowManager
{
27 static XForeignWindowManager
* GetInstance();
29 // Requests that events associated with |event_mask| on |xid| be reported to
30 // Chrome. Returns an id to use for canceling the request.
31 int RequestEvents(XID xid
, long event_mask
) WARN_UNUSED_RESULT
;
33 // Cancels the request with |request_id|. Unless there is another request for
34 // events on the X window associated with |request_id|, this stops Chrome from
35 // getting events for the X window.
36 void CancelRequest(int request_id
);
38 // Called by X11DesktopHandler when |xid| is destroyed.
39 void OnWindowDestroyed(XID xid
);
42 friend struct DefaultSingletonTraits
<XForeignWindowManager
>;
45 Request(int request_id
, long entry_event_mask
);
52 XForeignWindowManager();
53 ~XForeignWindowManager();
55 // Updates which events are selected on |xid|.
56 void UpdateSelectedEvents(XID xid
);
58 // The id of the next request.
61 typedef std::vector
<Request
> RequestVector
;
62 std::map
<XID
, RequestVector
> request_map_
;
64 DISALLOW_COPY_AND_ASSIGN(XForeignWindowManager
);
69 #endif // UI_BASE_X_X11_FOREIGN_WINDOW_MANAGER_H_