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

Side by Side Diff: ui/gfx/icc_profile_x11.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
« no previous file with comments | « ui/events/platform/x11/x11_hotplug_event_handler.cc ('k') | ui/gfx/x/x11_atom_cache.h » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <stddef.h> 5 #include <stddef.h>
6 6
7 extern "C" { 7 extern "C" {
8 #include <X11/Xatom.h> 8 #include <X11/Xatom.h>
9 #include <X11/Xlib.h> 9 #include <X11/Xlib.h>
10 } 10 }
11 11
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "ui/gfx/icc_profile.h" 13 #include "ui/gfx/icc_profile.h"
14 #include "ui/gfx/switches.h" 14 #include "ui/gfx/switches.h"
15 #include "ui/gfx/x/x11_atom_cache.h"
15 #include "ui/gfx/x/x11_types.h" 16 #include "ui/gfx/x/x11_types.h"
16 17
17 namespace gfx { 18 namespace gfx {
18 19
19 // static 20 // static
20 ICCProfile ICCProfile::FromBestMonitor() { 21 ICCProfile ICCProfile::FromBestMonitor() {
21 if (HasForcedProfile()) 22 if (HasForcedProfile())
22 return GetForcedProfile(); 23 return GetForcedProfile();
23 24
24 ICCProfile icc_profile; 25 ICCProfile icc_profile;
25 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kHeadless)) 26 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kHeadless))
26 return icc_profile; 27 return icc_profile;
27 Atom property = XInternAtom(GetXDisplay(), "_ICC_PROFILE", true); 28 Atom property = ui::X11AtomCache::GetInstance()->GetAtom("_ICC_PROFILE");
28 if (property != None) { 29 if (property != None) {
29 Atom prop_type = None; 30 Atom prop_type = None;
30 int prop_format = 0; 31 int prop_format = 0;
31 unsigned long nitems = 0; 32 unsigned long nitems = 0;
32 unsigned long nbytes = 0; 33 unsigned long nbytes = 0;
33 char* property_data = NULL; 34 char* property_data = NULL;
34 if (XGetWindowProperty( 35 if (XGetWindowProperty(
35 GetXDisplay(), DefaultRootWindow(GetXDisplay()), property, 0, 36 GetXDisplay(), DefaultRootWindow(GetXDisplay()), property, 0,
36 0x1FFFFFFF /* MAXINT32 / 4 */, False, AnyPropertyType, &prop_type, 37 0x1FFFFFFF /* MAXINT32 / 4 */, False, AnyPropertyType, &prop_type,
37 &prop_format, &nitems, &nbytes, 38 &prop_format, &nitems, &nbytes,
38 reinterpret_cast<unsigned char**>(&property_data)) == Success) { 39 reinterpret_cast<unsigned char**>(&property_data)) == Success) {
39 icc_profile = FromData(property_data, nitems); 40 icc_profile = FromData(property_data, nitems);
40 XFree(property_data); 41 XFree(property_data);
41 } 42 }
42 } 43 }
43 return icc_profile; 44 return icc_profile;
44 } 45 }
45 46
46 } // namespace gfx 47 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/events/platform/x11/x11_hotplug_event_handler.cc ('k') | ui/gfx/x/x11_atom_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698