Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Side by Side Diff: ui/base/x/x11_util.cc

Issue 2280433004: Fix missing shadows for tooltip and menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // This file defines utility functions for X11 (Linux only). This code has been 5 // This file defines utility functions for X11 (Linux only). This code has been
6 // ported from XCB since we can't use XCB on Ubuntu while its 32-bit support 6 // ported from XCB since we can't use XCB on Ubuntu while its 32-bit support
7 // remains woefully incomplete. 7 // remains woefully incomplete.
8 8
9 #include "ui/base/x/x11_util.h" 9 #include "ui/base/x/x11_util.h"
10 10
(...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 << " (" << error_str << "), " 1408 << " (" << error_str << "), "
1409 << "request_code " << static_cast<int>(error_event.request_code) << ", " 1409 << "request_code " << static_cast<int>(error_event.request_code) << ", "
1410 << "minor_code " << static_cast<int>(error_event.minor_code) 1410 << "minor_code " << static_cast<int>(error_event.minor_code)
1411 << " (" << request_str << ")"; 1411 << " (" << request_str << ")";
1412 } 1412 }
1413 1413
1414 #if !defined(OS_CHROMEOS) 1414 #if !defined(OS_CHROMEOS)
1415 void ChooseVisualForWindow(bool enable_transparent_visuals, 1415 void ChooseVisualForWindow(bool enable_transparent_visuals,
1416 Visual** visual, 1416 Visual** visual,
1417 int* depth) { 1417 int* depth) {
1418 static Visual* s_visual = NULL; 1418 static Visual* s_default_visual = NULL;
1419 static int s_depth = 0; 1419 static Visual* s_transparent_visual = NULL;
1420 static int s_default_depth = 0;
1421 static int s_transparent_depth = 0;
1420 1422
1421 if (!s_visual) { 1423 if (!s_default_visual || !s_transparent_visual) {
1422 XDisplay* display = gfx::GetXDisplay(); 1424 XDisplay* display = gfx::GetXDisplay();
1423 XAtom NET_WM_CM_S0 = XInternAtom(display, "_NET_WM_CM_S0", False); 1425 XAtom NET_WM_CM_S0 = XInternAtom(display, "_NET_WM_CM_S0", False);
1424 1426
1425 if (enable_transparent_visuals && 1427 if (enable_transparent_visuals &&
1426 XGetSelectionOwner(display, NET_WM_CM_S0) != None) { 1428 XGetSelectionOwner(display, NET_WM_CM_S0) != None) {
1427 // Choose the first ARGB8888 visual 1429 // Choose the first ARGB8888 visual
1428 XVisualInfo visual_template; 1430 XVisualInfo visual_template;
1429 visual_template.screen = 0; 1431 visual_template.screen = 0;
1430 1432
1431 int visuals_len; 1433 int visuals_len;
1432 gfx::XScopedPtr<XVisualInfo[]> visual_list(XGetVisualInfo( 1434 gfx::XScopedPtr<XVisualInfo[]> visual_list(XGetVisualInfo(
1433 display, VisualScreenMask, &visual_template, &visuals_len)); 1435 display, VisualScreenMask, &visual_template, &visuals_len));
1434 for (int i = 0; i < visuals_len; ++i) { 1436 for (int i = 0; i < visuals_len; ++i) {
1435 // Why support only 8888 ARGB? Because it's all that GTK+ supports. In 1437 // Why support only 8888 ARGB? Because it's all that GTK+ supports. In
1436 // gdkvisual-x11.cc, they look for this specific visual and use it for 1438 // gdkvisual-x11.cc, they look for this specific visual and use it for
1437 // all their alpha channel using needs. 1439 // all their alpha channel using needs.
1438 const XVisualInfo& info = visual_list[i]; 1440 const XVisualInfo& info = visual_list[i];
1439 if (info.depth == 32 && info.visual->red_mask == 0xff0000 && 1441 if (info.depth == 32 && info.visual->red_mask == 0xff0000 &&
1440 info.visual->green_mask == 0x00ff00 && 1442 info.visual->green_mask == 0x00ff00 &&
1441 info.visual->blue_mask == 0x0000ff) { 1443 info.visual->blue_mask == 0x0000ff) {
1442 s_visual = info.visual; 1444 s_transparent_visual = info.visual;
1443 s_depth = info.depth; 1445 s_transparent_depth = info.depth;
1446 DCHECK(s_transparent_visual);
1444 break; 1447 break;
1445 } 1448 }
1446 } 1449 }
1447 } else {
1448 XWindowAttributes windowAttribs;
1449 Window root = XDefaultRootWindow(display);
1450 Status status = XGetWindowAttributes(display, root, &windowAttribs);
1451 DCHECK(status != 0);
1452 s_visual = windowAttribs.visual;
1453 s_depth = windowAttribs.depth;
1454 } 1450 }
1455 } // !s_visual
1456 1451
1457 DCHECK(s_visual); 1452 XWindowAttributes windowAttribs;
sadrul 2016/09/02 19:53:24 window_attribs, or attribs. Sorry, missed this in
Julien Isorce Samsung 2016/09/02 20:59:08 My fault, thx.
1458 DCHECK(s_depth > 0); 1453 Window root = XDefaultRootWindow(display);
1454 Status status = XGetWindowAttributes(display, root, &windowAttribs);
1455 DCHECK(status != 0);
1456 s_default_visual = windowAttribs.visual;
1457 s_default_depth = windowAttribs.depth;
1458
1459 if (!s_transparent_visual) {
1460 s_transparent_visual = s_default_visual;
1461 s_transparent_depth = s_default_depth;
1462 }
1463 } // !s_default_visual || !s_transparent_visual
1464
1465 DCHECK(s_default_visual);
1466 DCHECK(s_default_depth > 0);
1467 DCHECK(s_transparent_visual);
1468 DCHECK(s_transparent_depth > 0);
1459 1469
1460 if (visual) 1470 if (visual)
1461 *visual = s_visual; 1471 *visual =
1472 enable_transparent_visuals ? s_transparent_visual : s_default_visual;
1462 if (depth) 1473 if (depth)
1463 *depth = s_depth; 1474 *depth = enable_transparent_visuals ? s_transparent_depth : s_default_depth;
1464 } 1475 }
1465 #endif 1476 #endif
1466 1477
1467 // ---------------------------------------------------------------------------- 1478 // ----------------------------------------------------------------------------
1468 // End of x11_util_internal.h 1479 // End of x11_util_internal.h
1469 1480
1470 1481
1471 } // namespace ui 1482 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698