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 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1352 window_type = atom_cache_.GetAtom("_NET_WM_WINDOW_TYPE_NORMAL"); | 1352 window_type = atom_cache_.GetAtom("_NET_WM_WINDOW_TYPE_NORMAL"); |
1353 break; | 1353 break; |
1354 } | 1354 } |
1355 // An in-activatable window should not interact with the system wm. | 1355 // An in-activatable window should not interact with the system wm. |
1356 if (!activatable_) | 1356 if (!activatable_) |
1357 swa.override_redirect = True; | 1357 swa.override_redirect = True; |
1358 | 1358 |
1359 if (swa.override_redirect) | 1359 if (swa.override_redirect) |
1360 attribute_mask |= CWOverrideRedirect; | 1360 attribute_mask |= CWOverrideRedirect; |
1361 | 1361 |
1362 const bool enable_transparent_visuals = | 1362 bool enable_transparent_visuals; |
1363 params.type == Widget::InitParams::TYPE_DRAG || | 1363 switch (params.opacity) { |
1364 params.type == Widget::InitParams::TYPE_WINDOW; | 1364 case Widget::InitParams::OPAQUE_WINDOW: |
| 1365 enable_transparent_visuals = false; |
| 1366 break; |
| 1367 case Widget::InitParams::TRANSLUCENT_WINDOW: |
| 1368 enable_transparent_visuals = true; |
| 1369 break; |
| 1370 case Widget::InitParams::INFER_OPACITY: |
| 1371 default: |
| 1372 enable_transparent_visuals = params.type == Widget::InitParams::TYPE_DRAG; |
| 1373 } |
1365 | 1374 |
1366 Visual* visual = CopyFromParent; | 1375 Visual* visual = CopyFromParent; |
1367 int depth = CopyFromParent; | 1376 int depth = CopyFromParent; |
1368 ui::ChooseVisualForWindow(enable_transparent_visuals, &visual, &depth); | 1377 Colormap colormap = CopyFromParent; |
1369 if (enable_transparent_visuals && depth == 32) { | 1378 ui::XVisualManager::GetInstance()->ChooseVisualForWindow( |
1370 attribute_mask |= CWColormap; | 1379 enable_transparent_visuals, &visual, &depth, &colormap, |
1371 swa.colormap = | 1380 &use_argb_visual_); |
1372 XCreateColormap(xdisplay_, x_root_window_, visual, AllocNone); | |
1373 | 1381 |
1374 // x.org will BadMatch if we don't set a border when the depth isn't the | 1382 attribute_mask |= CWColormap; |
1375 // same as the parent depth. | 1383 swa.colormap = colormap; |
1376 attribute_mask |= CWBorderPixel; | |
1377 swa.border_pixel = 0; | |
1378 | 1384 |
1379 // A compositing manager is required to support transparency. | 1385 // x.org will BadMatch if we don't set a border when the depth isn't the |
1380 use_argb_visual_ = | 1386 // same as the parent depth. |
1381 XGetSelectionOwner(xdisplay_, atom_cache_.GetAtom("_NET_WM_CM_S0")) != | 1387 attribute_mask |= CWBorderPixel; |
1382 None; | 1388 swa.border_pixel = 0; |
1383 } | |
1384 | 1389 |
1385 bounds_in_pixels_ = ToPixelRect(params.bounds); | 1390 bounds_in_pixels_ = ToPixelRect(params.bounds); |
1386 bounds_in_pixels_.set_size(AdjustSize(bounds_in_pixels_.size())); | 1391 bounds_in_pixels_.set_size(AdjustSize(bounds_in_pixels_.size())); |
1387 xwindow_ = XCreateWindow(xdisplay_, x_root_window_, bounds_in_pixels_.x(), | 1392 xwindow_ = XCreateWindow(xdisplay_, x_root_window_, bounds_in_pixels_.x(), |
1388 bounds_in_pixels_.y(), bounds_in_pixels_.width(), | 1393 bounds_in_pixels_.y(), bounds_in_pixels_.width(), |
1389 bounds_in_pixels_.height(), | 1394 bounds_in_pixels_.height(), |
1390 0, // border width | 1395 0, // border width |
1391 depth, InputOutput, visual, attribute_mask, &swa); | 1396 depth, InputOutput, visual, attribute_mask, &swa); |
1392 if (ui::PlatformEventSource::GetInstance()) | 1397 if (ui::PlatformEventSource::GetInstance()) |
1393 ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); | 1398 ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); |
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2313 if (linux_ui) { | 2318 if (linux_ui) { |
2314 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); | 2319 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); |
2315 if (native_theme) | 2320 if (native_theme) |
2316 return native_theme; | 2321 return native_theme; |
2317 } | 2322 } |
2318 | 2323 |
2319 return ui::NativeThemeAura::instance(); | 2324 return ui::NativeThemeAura::instance(); |
2320 } | 2325 } |
2321 | 2326 |
2322 } // namespace views | 2327 } // namespace views |
OLD | NEW |