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 #include "chrome/browser/chromeos/wm_ipc.h" | 5 #include "chrome/browser/chromeos/wm_ipc.h" |
6 | 6 |
7 #include <gdk/gdkx.h> | 7 #include <gdk/gdkx.h> |
8 extern "C" { | 8 extern "C" { |
9 #include <X11/Xlib.h> | 9 #include <X11/Xlib.h> |
10 } | 10 } |
11 | 11 |
12 #include "app/x11_util.h" | 12 #include "app/x11_util.h" |
13 #include "base/lazy_instance.h" | |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/scoped_ptr.h" | 15 #include "base/scoped_ptr.h" |
15 #include "base/singleton.h" | |
16 | 16 |
17 namespace chromeos { | 17 namespace chromeos { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 // A value from the Atom enum and the actual name that should be used to | 21 // A value from the Atom enum and the actual name that should be used to |
22 // look up its ID on the X server. | 22 // look up its ID on the X server. |
23 struct AtomInfo { | 23 struct AtomInfo { |
24 WmIpc::AtomType atom; | 24 WmIpc::AtomType atom; |
25 const char* name; | 25 const char* name; |
(...skipping 26 matching lines...) Expand all Loading... | |
52 32, // size in bits of items in 'value' | 52 32, // size in bits of items in 'value' |
53 PropModeReplace, | 53 PropModeReplace, |
54 reinterpret_cast<const unsigned char*>(data.get()), | 54 reinterpret_cast<const unsigned char*>(data.get()), |
55 values.size()); // num items | 55 values.size()); // num items |
56 XFlush(x11_util::GetXDisplay()); | 56 XFlush(x11_util::GetXDisplay()); |
57 return true; | 57 return true; |
58 } | 58 } |
59 | 59 |
60 } // namespace | 60 } // namespace |
61 | 61 |
62 static base::LazyInstance<WmIpc> g_wm_ipc(base::LINKER_INITIALIZED); | |
63 | |
62 // static | 64 // static |
63 WmIpc* WmIpc::instance() { | 65 WmIpc* WmIpc::instance() { |
64 static WmIpc* instance = NULL; | 66 return g_wm_ipc.Pointer(); |
M-A Ruel
2010/12/13 15:54:02
Eh, thanks for fixing it.
| |
65 if (!instance) | |
66 instance = Singleton<WmIpc>::get(); | |
67 return instance; | |
68 } | 67 } |
69 | 68 |
70 bool WmIpc::SetWindowType(GtkWidget* widget, | 69 bool WmIpc::SetWindowType(GtkWidget* widget, |
71 WmIpcWindowType type, | 70 WmIpcWindowType type, |
72 const std::vector<int>* params) { | 71 const std::vector<int>* params) { |
73 std::vector<int> values; | 72 std::vector<int> values; |
74 values.push_back(type); | 73 values.push_back(type); |
75 if (params) | 74 if (params) |
76 values.insert(values.end(), params->begin(), params->end()); | 75 values.insert(values.end(), params->begin(), params->end()); |
77 return SetIntProperty(x11_util::GetX11WindowFromGtkWidget(widget), | 76 return SetIntProperty(x11_util::GetX11WindowFromGtkWidget(widget), |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 // Let the window manager know which version of the IPC messages we support. | 200 // Let the window manager know which version of the IPC messages we support. |
202 Message msg(chromeos::WM_IPC_MESSAGE_WM_NOTIFY_IPC_VERSION); | 201 Message msg(chromeos::WM_IPC_MESSAGE_WM_NOTIFY_IPC_VERSION); |
203 // TODO: The version number is the latest listed in wm_ipc.h -- | 202 // TODO: The version number is the latest listed in wm_ipc.h -- |
204 // ideally, once this header is shared between Chrome and the Chrome OS window | 203 // ideally, once this header is shared between Chrome and the Chrome OS window |
205 // manager, we'll just define the version statically in the header. | 204 // manager, we'll just define the version statically in the header. |
206 msg.set_param(0, 1); | 205 msg.set_param(0, 1); |
207 SendMessage(msg); | 206 SendMessage(msg); |
208 } | 207 } |
209 | 208 |
210 } // namespace chromeos | 209 } // namespace chromeos |
OLD | NEW |