| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef UI_BASE_X_X11_FOREIGN_WINDOW_MANAGER_H_ | |
| 6 #define UI_BASE_X_X11_FOREIGN_WINDOW_MANAGER_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <vector> | |
| 10 | |
| 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" | |
| 15 | |
| 16 // A process wide singleton for selecting events on X windows which were not | |
| 17 // created by Chrome. | |
| 18 template <typename T> struct DefaultSingletonTraits; | |
| 19 | |
| 20 namespace ui { | |
| 21 | |
| 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(); | |
| 28 | |
| 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; | |
| 32 | |
| 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); | |
| 37 | |
| 38 // Called by X11DesktopHandler when |xid| is destroyed. | |
| 39 void OnWindowDestroyed(XID xid); | |
| 40 | |
| 41 private: | |
| 42 friend struct DefaultSingletonTraits<XForeignWindowManager>; | |
| 43 | |
| 44 struct Request { | |
| 45 Request(int request_id, long entry_event_mask); | |
| 46 ~Request(); | |
| 47 | |
| 48 int request_id; | |
| 49 long event_mask; | |
| 50 }; | |
| 51 | |
| 52 XForeignWindowManager(); | |
| 53 ~XForeignWindowManager(); | |
| 54 | |
| 55 // Updates which events are selected on |xid|. | |
| 56 void UpdateSelectedEvents(XID xid); | |
| 57 | |
| 58 // The id of the next request. | |
| 59 int next_request_id_; | |
| 60 | |
| 61 typedef std::vector<Request> RequestVector; | |
| 62 std::map<XID, RequestVector> request_map_; | |
| 63 | |
| 64 DISALLOW_COPY_AND_ASSIGN(XForeignWindowManager); | |
| 65 }; | |
| 66 | |
| 67 } // namespace ui | |
| 68 | |
| 69 #endif // UI_BASE_X_X11_FOREIGN_WINDOW_MANAGER_H_ | |
| OLD | NEW |