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

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

Issue 24160005: Move ui/base/x/x11_error_tracker to base/x11. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase Created 7 years, 2 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/base/x/x11_error_tracker_gtk.cc ('k') | ui/ui.gyp » ('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 14 matching lines...) Expand all
25 #include "base/logging.h" 25 #include "base/logging.h"
26 #include "base/memory/scoped_ptr.h" 26 #include "base/memory/scoped_ptr.h"
27 #include "base/memory/singleton.h" 27 #include "base/memory/singleton.h"
28 #include "base/message_loop/message_loop.h" 28 #include "base/message_loop/message_loop.h"
29 #include "base/metrics/histogram.h" 29 #include "base/metrics/histogram.h"
30 #include "base/strings/string_number_conversions.h" 30 #include "base/strings/string_number_conversions.h"
31 #include "base/strings/string_util.h" 31 #include "base/strings/string_util.h"
32 #include "base/strings/stringprintf.h" 32 #include "base/strings/stringprintf.h"
33 #include "base/sys_byteorder.h" 33 #include "base/sys_byteorder.h"
34 #include "base/threading/thread.h" 34 #include "base/threading/thread.h"
35 #include "base/x11/x11_error_tracker.h"
35 #include "third_party/skia/include/core/SkBitmap.h" 36 #include "third_party/skia/include/core/SkBitmap.h"
36 #include "third_party/skia/include/core/SkPostConfig.h" 37 #include "third_party/skia/include/core/SkPostConfig.h"
37 #include "ui/base/x/x11_error_tracker.h"
38 #include "ui/base/x/x11_util_internal.h" 38 #include "ui/base/x/x11_util_internal.h"
39 #include "ui/events/event_utils.h" 39 #include "ui/events/event_utils.h"
40 #include "ui/events/keycodes/keyboard_code_conversion_x.h" 40 #include "ui/events/keycodes/keyboard_code_conversion_x.h"
41 #include "ui/events/x/device_data_manager.h" 41 #include "ui/events/x/device_data_manager.h"
42 #include "ui/events/x/touch_factory_x11.h" 42 #include "ui/events/x/touch_factory_x11.h"
43 #include "ui/gfx/canvas.h" 43 #include "ui/gfx/canvas.h"
44 #include "ui/gfx/image/image_skia.h" 44 #include "ui/gfx/image/image_skia.h"
45 #include "ui/gfx/image/image_skia_rep.h" 45 #include "ui/gfx/image/image_skia_rep.h"
46 #include "ui/gfx/point.h" 46 #include "ui/gfx/point.h"
47 #include "ui/gfx/point_conversions.h" 47 #include "ui/gfx/point_conversions.h"
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 } 295 }
296 296
297 void* address = shmat(shmkey, NULL, 0); 297 void* address = shmat(shmkey, NULL, 0);
298 // Mark the shared memory region for deletion 298 // Mark the shared memory region for deletion
299 shmctl(shmkey, IPC_RMID, NULL); 299 shmctl(shmkey, IPC_RMID, NULL);
300 300
301 XShmSegmentInfo shminfo; 301 XShmSegmentInfo shminfo;
302 memset(&shminfo, 0, sizeof(shminfo)); 302 memset(&shminfo, 0, sizeof(shminfo));
303 shminfo.shmid = shmkey; 303 shminfo.shmid = shmkey;
304 304
305 X11ErrorTracker err_tracker; 305 base::X11ErrorTracker err_tracker;
306 bool result = XShmAttach(dpy, &shminfo); 306 bool result = XShmAttach(dpy, &shminfo);
307 if (result) 307 if (result)
308 VLOG(1) << "X got shared memory segment " << shmkey; 308 VLOG(1) << "X got shared memory segment " << shmkey;
309 else 309 else
310 LOG(WARNING) << "X failed to attach to shared memory segment " << shmkey; 310 LOG(WARNING) << "X failed to attach to shared memory segment " << shmkey;
311 if (err_tracker.FoundNewError()) 311 if (err_tracker.FoundNewError())
312 result = false; 312 result = false;
313 shmdt(address); 313 shmdt(address);
314 if (!result) { 314 if (!result) {
315 LOG(WARNING) << "X failed to attach to shared memory segment " << shmkey; 315 LOG(WARNING) << "X failed to attach to shared memory segment " << shmkey;
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 const std::vector<int>& value) { 864 const std::vector<int>& value) {
865 DCHECK(!value.empty()); 865 DCHECK(!value.empty());
866 Atom name_atom = GetAtom(name.c_str()); 866 Atom name_atom = GetAtom(name.c_str());
867 Atom type_atom = GetAtom(type.c_str()); 867 Atom type_atom = GetAtom(type.c_str());
868 868
869 // XChangeProperty() expects values of type 32 to be longs. 869 // XChangeProperty() expects values of type 32 to be longs.
870 scoped_ptr<long[]> data(new long[value.size()]); 870 scoped_ptr<long[]> data(new long[value.size()]);
871 for (size_t i = 0; i < value.size(); ++i) 871 for (size_t i = 0; i < value.size(); ++i)
872 data[i] = value[i]; 872 data[i] = value[i];
873 873
874 X11ErrorTracker err_tracker; 874 base::X11ErrorTracker err_tracker;
875 XChangeProperty(gfx::GetXDisplay(), 875 XChangeProperty(gfx::GetXDisplay(),
876 window, 876 window,
877 name_atom, 877 name_atom,
878 type_atom, 878 type_atom,
879 32, // size in bits of items in 'value' 879 32, // size in bits of items in 'value'
880 PropModeReplace, 880 PropModeReplace,
881 reinterpret_cast<const unsigned char*>(data.get()), 881 reinterpret_cast<const unsigned char*>(data.get()),
882 value.size()); // num items 882 value.size()); // num items
883 return !err_tracker.FoundNewError(); 883 return !err_tracker.FoundNewError();
884 } 884 }
885 885
886 bool SetAtomArrayProperty(XID window, 886 bool SetAtomArrayProperty(XID window,
887 const std::string& name, 887 const std::string& name,
888 const std::string& type, 888 const std::string& type,
889 const std::vector<Atom>& value) { 889 const std::vector<Atom>& value) {
890 DCHECK(!value.empty()); 890 DCHECK(!value.empty());
891 Atom name_atom = GetAtom(name.c_str()); 891 Atom name_atom = GetAtom(name.c_str());
892 Atom type_atom = GetAtom(type.c_str()); 892 Atom type_atom = GetAtom(type.c_str());
893 893
894 // XChangeProperty() expects values of type 32 to be longs. 894 // XChangeProperty() expects values of type 32 to be longs.
895 scoped_ptr<Atom[]> data(new Atom[value.size()]); 895 scoped_ptr<Atom[]> data(new Atom[value.size()]);
896 for (size_t i = 0; i < value.size(); ++i) 896 for (size_t i = 0; i < value.size(); ++i)
897 data[i] = value[i]; 897 data[i] = value[i];
898 898
899 X11ErrorTracker err_tracker; 899 base::X11ErrorTracker err_tracker;
900 XChangeProperty(gfx::GetXDisplay(), 900 XChangeProperty(gfx::GetXDisplay(),
901 window, 901 window,
902 name_atom, 902 name_atom,
903 type_atom, 903 type_atom,
904 32, // size in bits of items in 'value' 904 32, // size in bits of items in 'value'
905 PropModeReplace, 905 PropModeReplace,
906 reinterpret_cast<const unsigned char*>(data.get()), 906 reinterpret_cast<const unsigned char*>(data.get()),
907 value.size()); // num items 907 value.size()); // num items
908 return !err_tracker.FoundNewError(); 908 return !err_tracker.FoundNewError();
909 } 909 }
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 1182
1183 // It's possible that a window manager started earlier in this X session left 1183 // It's possible that a window manager started earlier in this X session left
1184 // a stale _NET_SUPPORTING_WM_CHECK property when it was replaced by a 1184 // a stale _NET_SUPPORTING_WM_CHECK property when it was replaced by a
1185 // non-EWMH window manager, so we trap errors in the following requests to 1185 // non-EWMH window manager, so we trap errors in the following requests to
1186 // avoid crashes (issue 23860). 1186 // avoid crashes (issue 23860).
1187 1187
1188 // EWMH requires the supporting-WM window to also have a 1188 // EWMH requires the supporting-WM window to also have a
1189 // _NET_SUPPORTING_WM_CHECK property pointing to itself (to avoid a stale 1189 // _NET_SUPPORTING_WM_CHECK property pointing to itself (to avoid a stale
1190 // property referencing an ID that's been recycled for another window), so we 1190 // property referencing an ID that's been recycled for another window), so we
1191 // check that too. 1191 // check that too.
1192 X11ErrorTracker err_tracker; 1192 base::X11ErrorTracker err_tracker;
1193 int wm_window_property = 0; 1193 int wm_window_property = 0;
1194 bool result = GetIntProperty( 1194 bool result = GetIntProperty(
1195 wm_window, "_NET_SUPPORTING_WM_CHECK", &wm_window_property); 1195 wm_window, "_NET_SUPPORTING_WM_CHECK", &wm_window_property);
1196 if (err_tracker.FoundNewError() || !result || 1196 if (err_tracker.FoundNewError() || !result ||
1197 wm_window_property != wm_window) { 1197 wm_window_property != wm_window) {
1198 return false; 1198 return false;
1199 } 1199 }
1200 1200
1201 result = GetStringProperty( 1201 result = GetStringProperty(
1202 static_cast<XID>(wm_window), "_NET_WM_NAME", wm_name); 1202 static_cast<XID>(wm_window), "_NET_WM_NAME", wm_name);
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 << "request_code " << static_cast<int>(error_event.request_code) << ", " 1482 << "request_code " << static_cast<int>(error_event.request_code) << ", "
1483 << "minor_code " << static_cast<int>(error_event.minor_code) 1483 << "minor_code " << static_cast<int>(error_event.minor_code)
1484 << " (" << request_str << ")"; 1484 << " (" << request_str << ")";
1485 } 1485 }
1486 1486
1487 // ---------------------------------------------------------------------------- 1487 // ----------------------------------------------------------------------------
1488 // End of x11_util_internal.h 1488 // End of x11_util_internal.h
1489 1489
1490 1490
1491 } // namespace ui 1491 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/x/x11_error_tracker_gtk.cc ('k') | ui/ui.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698