| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_WM_IPC_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_WM_IPC_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_WM_IPC_H_ | 6 #define CHROME_BROWSER_CHROMEOS_WM_IPC_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
| 10 #include <map> | 10 #include <map> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/singleton.h" | |
| 16 #include "cros/chromeos_wm_ipc_enums.h" | 15 #include "cros/chromeos_wm_ipc_enums.h" |
| 17 | 16 |
| 18 typedef unsigned long Atom; | 17 typedef unsigned long Atom; |
| 19 typedef unsigned long XID; | 18 typedef unsigned long XID; |
| 20 | 19 |
| 20 namespace base { |
| 21 template <typename T> struct DefaultLazyInstanceTraits; |
| 22 } |
| 23 |
| 21 namespace chromeos { | 24 namespace chromeos { |
| 22 | 25 |
| 23 class WmIpc { | 26 class WmIpc { |
| 24 public: | 27 public: |
| 25 enum AtomType { | 28 enum AtomType { |
| 26 ATOM_CHROME_LOGGED_IN = 0, | 29 ATOM_CHROME_LOGGED_IN = 0, |
| 27 ATOM_CHROME_WINDOW_TYPE, | 30 ATOM_CHROME_WINDOW_TYPE, |
| 28 ATOM_CHROME_WM_MESSAGE, | 31 ATOM_CHROME_WM_MESSAGE, |
| 29 ATOM_MANAGER, | 32 ATOM_MANAGER, |
| 30 ATOM_STRING, | 33 ATOM_STRING, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // Specifically, this catches messages about the WM_S0 selection that get sent | 109 // Specifically, this catches messages about the WM_S0 selection that get sent |
| 107 // when a window manager process starts (so that we can re-run InitWmInfo()). | 110 // when a window manager process starts (so that we can re-run InitWmInfo()). |
| 108 // See ICCCM 2.8 for more info about MANAGER selections. | 111 // See ICCCM 2.8 for more info about MANAGER selections. |
| 109 void HandleNonChromeClientMessageEvent(const GdkEventClient& event); | 112 void HandleNonChromeClientMessageEvent(const GdkEventClient& event); |
| 110 | 113 |
| 111 // Sets a _CHROME_LOGGED_IN property on the root window describing whether | 114 // Sets a _CHROME_LOGGED_IN property on the root window describing whether |
| 112 // the user is currently logged in or not. | 115 // the user is currently logged in or not. |
| 113 void SetLoggedInProperty(bool logged_in); | 116 void SetLoggedInProperty(bool logged_in); |
| 114 | 117 |
| 115 private: | 118 private: |
| 116 friend struct DefaultSingletonTraits<WmIpc>; | 119 friend struct base::DefaultLazyInstanceTraits<WmIpc>; |
| 117 | 120 |
| 118 WmIpc(); | 121 WmIpc(); |
| 119 | 122 |
| 120 // Initialize 'wm_' and send the window manager a message telling it the | 123 // Initialize 'wm_' and send the window manager a message telling it the |
| 121 // version of the IPC protocol that we support. This is called in our | 124 // version of the IPC protocol that we support. This is called in our |
| 122 // constructor, but needs to be re-run if the window manager gets restarted. | 125 // constructor, but needs to be re-run if the window manager gets restarted. |
| 123 void InitWmInfo(); | 126 void InitWmInfo(); |
| 124 | 127 |
| 125 // Maps from our Atom enum to the X server's atom IDs and from the | 128 // Maps from our Atom enum to the X server's atom IDs and from the |
| 126 // server's IDs to atoms' string names. These maps aren't necessarily in | 129 // server's IDs to atoms' string names. These maps aren't necessarily in |
| 127 // sync; 'atom_to_xatom_' is constant after the constructor finishes but | 130 // sync; 'atom_to_xatom_' is constant after the constructor finishes but |
| 128 // GetName() caches additional string mappings in 'xatom_to_string_'. | 131 // GetName() caches additional string mappings in 'xatom_to_string_'. |
| 129 std::map<AtomType, Atom> type_to_atom_; | 132 std::map<AtomType, Atom> type_to_atom_; |
| 130 std::map<Atom, std::string> atom_to_string_; | 133 std::map<Atom, std::string> atom_to_string_; |
| 131 | 134 |
| 132 // Cached value of type_to_atom_[ATOM_CHROME_WM_MESSAGE]. | 135 // Cached value of type_to_atom_[ATOM_CHROME_WM_MESSAGE]. |
| 133 Atom wm_message_atom_; | 136 Atom wm_message_atom_; |
| 134 | 137 |
| 135 // Handle to the wm. Used for sending messages. | 138 // Handle to the wm. Used for sending messages. |
| 136 XID wm_; | 139 XID wm_; |
| 137 | 140 |
| 138 DISALLOW_COPY_AND_ASSIGN(WmIpc); | 141 DISALLOW_COPY_AND_ASSIGN(WmIpc); |
| 139 }; | 142 }; |
| 140 | 143 |
| 141 } // namespace chromeos | 144 } // namespace chromeos |
| 142 | 145 |
| 143 #endif // CHROME_BROWSER_CHROMEOS_WM_IPC_H_ | 146 #endif // CHROME_BROWSER_CHROMEOS_WM_IPC_H_ |
| OLD | NEW |