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

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

Issue 2914103002: Remove usages of XInternAtom (Closed)
Patch Set: Address sadrul and sergeyu comments Created 3 years, 6 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
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #include "ui/events/keycodes/keyboard_code_conversion_x.h" 50 #include "ui/events/keycodes/keyboard_code_conversion_x.h"
51 #include "ui/gfx/canvas.h" 51 #include "ui/gfx/canvas.h"
52 #include "ui/gfx/geometry/insets.h" 52 #include "ui/gfx/geometry/insets.h"
53 #include "ui/gfx/geometry/point.h" 53 #include "ui/gfx/geometry/point.h"
54 #include "ui/gfx/geometry/point_conversions.h" 54 #include "ui/gfx/geometry/point_conversions.h"
55 #include "ui/gfx/geometry/rect.h" 55 #include "ui/gfx/geometry/rect.h"
56 #include "ui/gfx/geometry/size.h" 56 #include "ui/gfx/geometry/size.h"
57 #include "ui/gfx/image/image_skia.h" 57 #include "ui/gfx/image/image_skia.h"
58 #include "ui/gfx/image/image_skia_rep.h" 58 #include "ui/gfx/image/image_skia_rep.h"
59 #include "ui/gfx/skia_util.h" 59 #include "ui/gfx/skia_util.h"
60 #include "ui/gfx/x/x11_atom_cache.h"
60 #include "ui/gfx/x/x11_error_tracker.h" 61 #include "ui/gfx/x/x11_error_tracker.h"
61 62
62 #if defined(OS_FREEBSD) 63 #if defined(OS_FREEBSD)
63 #include <sys/sysctl.h> 64 #include <sys/sysctl.h>
64 #include <sys/types.h> 65 #include <sys/types.h>
65 #endif 66 #endif
66 67
67 namespace ui { 68 namespace ui {
68 69
69 namespace { 70 namespace {
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 property, 888 property,
888 type, 889 type,
889 8, 890 8,
890 PropModeReplace, 891 PropModeReplace,
891 reinterpret_cast<const unsigned char*>(value.c_str()), 892 reinterpret_cast<const unsigned char*>(value.c_str()),
892 value.size()); 893 value.size());
893 return !err_tracker.FoundNewError(); 894 return !err_tracker.FoundNewError();
894 } 895 }
895 896
896 XAtom GetAtom(const char* name) { 897 XAtom GetAtom(const char* name) {
897 // TODO(derat): Cache atoms to avoid round-trips to the server. 898 return X11AtomCache::GetInstance()->GetAtom(name);
898 return XInternAtom(gfx::GetXDisplay(), name, false);
899 } 899 }
900 900
901 void SetWindowClassHint(XDisplay* display, 901 void SetWindowClassHint(XDisplay* display,
902 XID window, 902 XID window,
903 const std::string& res_name, 903 const std::string& res_name,
904 const std::string& res_class) { 904 const std::string& res_class) {
905 XClassHint class_hints; 905 XClassHint class_hints;
906 // const_cast is safe because XSetClassHint does not modify the strings. 906 // const_cast is safe because XSetClassHint does not modify the strings.
907 // Just to be safe, the res_name and res_class parameters are local copies, 907 // Just to be safe, the res_name and res_class parameters are local copies,
908 // not const references. 908 // not const references.
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
1384 using_software_rendering_(false), 1384 using_software_rendering_(false),
1385 have_gpu_argb_visual_(false) { 1385 have_gpu_argb_visual_(false) {
1386 int visuals_len = 0; 1386 int visuals_len = 0;
1387 XVisualInfo visual_template; 1387 XVisualInfo visual_template;
1388 visual_template.screen = DefaultScreen(display_); 1388 visual_template.screen = DefaultScreen(display_);
1389 gfx::XScopedPtr<XVisualInfo[]> visual_list(XGetVisualInfo( 1389 gfx::XScopedPtr<XVisualInfo[]> visual_list(XGetVisualInfo(
1390 display_, VisualScreenMask, &visual_template, &visuals_len)); 1390 display_, VisualScreenMask, &visual_template, &visuals_len));
1391 for (int i = 0; i < visuals_len; ++i) 1391 for (int i = 0; i < visuals_len; ++i)
1392 visuals_[visual_list[i].visualid].reset(new XVisualData(visual_list[i])); 1392 visuals_[visual_list[i].visualid].reset(new XVisualData(visual_list[i]));
1393 1393
1394 XAtom NET_WM_CM_S0 = XInternAtom(display_, "_NET_WM_CM_S0", False); 1394 XAtom NET_WM_CM_S0 = GetAtom("_NET_WM_CM_S0");
1395 using_compositing_wm_ = XGetSelectionOwner(display_, NET_WM_CM_S0) != None; 1395 using_compositing_wm_ = XGetSelectionOwner(display_, NET_WM_CM_S0) != None;
1396 1396
1397 // Choose the opaque visual. 1397 // Choose the opaque visual.
1398 default_visual_id_ = 1398 default_visual_id_ =
1399 XVisualIDFromVisual(DefaultVisual(display_, DefaultScreen(display_))); 1399 XVisualIDFromVisual(DefaultVisual(display_, DefaultScreen(display_)));
1400 system_visual_id_ = default_visual_id_; 1400 system_visual_id_ = default_visual_id_;
1401 DCHECK(system_visual_id_); 1401 DCHECK(system_visual_id_);
1402 DCHECK(visuals_.find(system_visual_id_) != visuals_.end()); 1402 DCHECK(visuals_.find(system_visual_id_) != visuals_.end());
1403 1403
1404 // Choose the transparent visual. 1404 // Choose the transparent visual.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1481 visual_info.visual, AllocNone); 1481 visual_info.visual, AllocNone);
1482 } 1482 }
1483 return colormap_; 1483 return colormap_;
1484 } 1484 }
1485 1485
1486 // ---------------------------------------------------------------------------- 1486 // ----------------------------------------------------------------------------
1487 // End of x11_util_internal.h 1487 // End of x11_util_internal.h
1488 1488
1489 1489
1490 } // namespace ui 1490 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/x/selection_utils.cc ('k') | ui/display/manager/chromeos/x11/native_display_delegate_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698