OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" | 5 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" |
6 | 6 |
7 #include <X11/extensions/shape.h> | 7 #include <X11/extensions/shape.h> |
8 #include <X11/extensions/XInput2.h> | 8 #include <X11/extensions/XInput2.h> |
9 #include <X11/Xatom.h> | 9 #include <X11/Xatom.h> |
10 #include <X11/Xregion.h> | 10 #include <X11/Xregion.h> |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 | 219 |
220 void DesktopWindowTreeHostX11::CleanUpWindowList() { | 220 void DesktopWindowTreeHostX11::CleanUpWindowList() { |
221 delete open_windows_; | 221 delete open_windows_; |
222 open_windows_ = NULL; | 222 open_windows_ = NULL; |
223 } | 223 } |
224 | 224 |
225 //////////////////////////////////////////////////////////////////////////////// | 225 //////////////////////////////////////////////////////////////////////////////// |
226 // DesktopWindowTreeHostX11, DesktopWindowTreeHost implementation: | 226 // DesktopWindowTreeHostX11, DesktopWindowTreeHost implementation: |
227 | 227 |
228 void DesktopWindowTreeHostX11::Init(aura::Window* content_window, | 228 void DesktopWindowTreeHostX11::Init(aura::Window* content_window, |
229 const Widget::InitParams& params) { | 229 const Widget::InitParams& params, |
| 230 ui::ContextFactory* context_factory) { |
230 content_window_ = content_window; | 231 content_window_ = content_window; |
231 | 232 |
232 // TODO(erg): Check whether we *should* be building a WindowTreeHost here, or | 233 // TODO(erg): Check whether we *should* be building a WindowTreeHost here, or |
233 // whether we should be proxying requests to another DRWHL. | 234 // whether we should be proxying requests to another DRWHL. |
234 | 235 |
235 // In some situations, views tries to make a zero sized window, and that | 236 // In some situations, views tries to make a zero sized window, and that |
236 // makes us crash. Make sure we have valid sizes. | 237 // makes us crash. Make sure we have valid sizes. |
237 Widget::InitParams sanitized_params = params; | 238 Widget::InitParams sanitized_params = params; |
238 if (sanitized_params.bounds.width() == 0) | 239 if (sanitized_params.bounds.width() == 0) |
239 sanitized_params.bounds.set_width(100); | 240 sanitized_params.bounds.set_width(100); |
240 if (sanitized_params.bounds.height() == 0) | 241 if (sanitized_params.bounds.height() == 0) |
241 sanitized_params.bounds.set_height(100); | 242 sanitized_params.bounds.set_height(100); |
242 | 243 |
243 InitX11Window(sanitized_params); | 244 InitX11Window(sanitized_params, context_factory); |
244 } | 245 } |
245 | 246 |
246 void DesktopWindowTreeHostX11::OnNativeWidgetCreated( | 247 void DesktopWindowTreeHostX11::OnNativeWidgetCreated( |
247 const Widget::InitParams& params) { | 248 const Widget::InitParams& params) { |
248 window()->SetProperty(kViewsWindowForRootWindow, content_window_); | 249 window()->SetProperty(kViewsWindowForRootWindow, content_window_); |
249 window()->SetProperty(kHostForRootWindow, this); | 250 window()->SetProperty(kHostForRootWindow, this); |
250 | 251 |
251 // Ensure that the X11DesktopHandler exists so that it dispatches activation | 252 // Ensure that the X11DesktopHandler exists so that it dispatches activation |
252 // messages to us. | 253 // messages to us. |
253 X11DesktopHandler::get(); | 254 X11DesktopHandler::get(); |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
929 // DesktopWindowTreeHostX11, ui::EventSource implementation: | 930 // DesktopWindowTreeHostX11, ui::EventSource implementation: |
930 | 931 |
931 ui::EventProcessor* DesktopWindowTreeHostX11::GetEventProcessor() { | 932 ui::EventProcessor* DesktopWindowTreeHostX11::GetEventProcessor() { |
932 return dispatcher(); | 933 return dispatcher(); |
933 } | 934 } |
934 | 935 |
935 //////////////////////////////////////////////////////////////////////////////// | 936 //////////////////////////////////////////////////////////////////////////////// |
936 // DesktopWindowTreeHostX11, private: | 937 // DesktopWindowTreeHostX11, private: |
937 | 938 |
938 void DesktopWindowTreeHostX11::InitX11Window( | 939 void DesktopWindowTreeHostX11::InitX11Window( |
939 const Widget::InitParams& params) { | 940 const Widget::InitParams& params, |
| 941 ui::ContextFactory* context_factory) { |
940 unsigned long attribute_mask = CWBackPixmap; | 942 unsigned long attribute_mask = CWBackPixmap; |
941 XSetWindowAttributes swa; | 943 XSetWindowAttributes swa; |
942 memset(&swa, 0, sizeof(swa)); | 944 memset(&swa, 0, sizeof(swa)); |
943 swa.background_pixmap = None; | 945 swa.background_pixmap = None; |
944 | 946 |
945 ::Atom window_type; | 947 ::Atom window_type; |
946 switch (params.type) { | 948 switch (params.type) { |
947 case Widget::InitParams::TYPE_MENU: | 949 case Widget::InitParams::TYPE_MENU: |
948 swa.override_redirect = True; | 950 swa.override_redirect = True; |
949 window_type = atom_cache_.GetAtom("_NET_WM_WINDOW_TYPE_MENU"); | 951 window_type = atom_cache_.GetAtom("_NET_WM_WINDOW_TYPE_MENU"); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1113 window_parent_->window_children_.insert(this); | 1115 window_parent_->window_children_.insert(this); |
1114 } | 1116 } |
1115 | 1117 |
1116 // If we have a delegate which is providing a default window icon, use that | 1118 // If we have a delegate which is providing a default window icon, use that |
1117 // icon. | 1119 // icon. |
1118 gfx::ImageSkia* window_icon = ViewsDelegate::views_delegate ? | 1120 gfx::ImageSkia* window_icon = ViewsDelegate::views_delegate ? |
1119 ViewsDelegate::views_delegate->GetDefaultWindowIcon() : NULL; | 1121 ViewsDelegate::views_delegate->GetDefaultWindowIcon() : NULL; |
1120 if (window_icon) { | 1122 if (window_icon) { |
1121 SetWindowIcons(gfx::ImageSkia(), *window_icon); | 1123 SetWindowIcons(gfx::ImageSkia(), *window_icon); |
1122 } | 1124 } |
1123 CreateCompositor(GetAcceleratedWidget()); | 1125 CreateCompositor(GetAcceleratedWidget(), context_factory); |
1124 } | 1126 } |
1125 | 1127 |
1126 void DesktopWindowTreeHostX11::OnWMStateUpdated() { | 1128 void DesktopWindowTreeHostX11::OnWMStateUpdated() { |
1127 std::vector< ::Atom> atom_list; | 1129 std::vector< ::Atom> atom_list; |
1128 if (!ui::GetAtomArrayProperty(xwindow_, "_NET_WM_STATE", &atom_list)) | 1130 if (!ui::GetAtomArrayProperty(xwindow_, "_NET_WM_STATE", &atom_list)) |
1129 return; | 1131 return; |
1130 | 1132 |
1131 window_properties_.clear(); | 1133 window_properties_.clear(); |
1132 std::copy(atom_list.begin(), atom_list.end(), | 1134 std::copy(atom_list.begin(), atom_list.end(), |
1133 inserter(window_properties_, window_properties_.begin())); | 1135 inserter(window_properties_, window_properties_.begin())); |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1711 if (linux_ui) { | 1713 if (linux_ui) { |
1712 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); | 1714 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); |
1713 if (native_theme) | 1715 if (native_theme) |
1714 return native_theme; | 1716 return native_theme; |
1715 } | 1717 } |
1716 | 1718 |
1717 return ui::NativeTheme::instance(); | 1719 return ui::NativeTheme::instance(); |
1718 } | 1720 } |
1719 | 1721 |
1720 } // namespace views | 1722 } // namespace views |
OLD | NEW |