Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ui / base / x / x11_foreign_window_manager.h
blob354cfba6d82be98c068a1dd88ebf48d2e3edc73f
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_
8 #include <map>
9 #include <vector>
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
17 // created by Chrome.
18 template <typename T> struct DefaultSingletonTraits;
20 namespace ui {
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 {
26 public:
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);
41 private:
42 friend struct DefaultSingletonTraits<XForeignWindowManager>;
44 struct Request {
45 Request(int request_id, long entry_event_mask);
46 ~Request();
48 int request_id;
49 long 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.
59 int next_request_id_;
61 typedef std::vector<Request> RequestVector;
62 std::map<XID, RequestVector> request_map_;
64 DISALLOW_COPY_AND_ASSIGN(XForeignWindowManager);
67 } // namespace ui
69 #endif // UI_BASE_X_X11_FOREIGN_WINDOW_MANAGER_H_