summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorkcwu@chromium.org <kcwu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-27 05:07:30 +0000
committerkcwu@chromium.org <kcwu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-27 05:07:30 +0000
commitbfe5d023c833ded283de54e502a552816b641d49 (patch)
treed07192aafad97e68127d079a2c2573b39366b85e /ui
parent2bf7a5582c3ac76ba94005cd9abaca91c98b9e45 (diff)
downloadchromium_src-bfe5d023c833ded283de54e502a552816b641d49.zip
chromium_src-bfe5d023c833ded283de54e502a552816b641d49.tar.gz
chromium_src-bfe5d023c833ded283de54e502a552816b641d49.tar.bz2
Move ui/base/x/x11_error_tracker to base/x11.
This is to share common x11 code for ui/x and chromeos/display. R=thakis@chromium.org Review URL: https://codereview.chromium.org/24160005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225662 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/base/x/x11_error_tracker.cc37
-rw-r--r--ui/base/x/x11_error_tracker.h33
-rw-r--r--ui/base/x/x11_error_tracker_gtk.cc29
-rw-r--r--ui/base/x/x11_util.cc10
-rw-r--r--ui/ui.gyp6
5 files changed, 5 insertions, 110 deletions
diff --git a/ui/base/x/x11_error_tracker.cc b/ui/base/x/x11_error_tracker.cc
deleted file mode 100644
index 22bc798..0000000
--- a/ui/base/x/x11_error_tracker.cc
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/base/x/x11_error_tracker.h"
-
-#include "ui/base/x/x11_util.h"
-
-namespace {
-
-unsigned char g_x11_error_code = 0;
-
-int X11ErrorHandler(XDisplay* display, XErrorEvent* error) {
- g_x11_error_code = error->error_code;
- return 0;
-}
-
-}
-
-namespace ui {
-
-X11ErrorTracker::X11ErrorTracker() {
- old_handler_ = XSetErrorHandler(X11ErrorHandler);
-}
-
-X11ErrorTracker::~X11ErrorTracker() {
- XSetErrorHandler(old_handler_);
-}
-
-bool X11ErrorTracker::FoundNewError() {
- XSync(gfx::GetXDisplay(), False);
- unsigned char error = g_x11_error_code;
- g_x11_error_code = 0;
- return error != 0;
-}
-
-} // namespace ui
diff --git a/ui/base/x/x11_error_tracker.h b/ui/base/x/x11_error_tracker.h
deleted file mode 100644
index 57d46d1..0000000
--- a/ui/base/x/x11_error_tracker.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <X11/Xlib.h>
-
-#include "base/basictypes.h"
-#include "ui/base/ui_export.h"
-
-namespace ui {
-
-// X11ErrorTracker catches X11 errors in a non-fatal way. It does so by
-// temporarily changing the X11 error handler. The old error handler is
-// restored when the tracker is destroyed.
-class UI_EXPORT X11ErrorTracker {
- public:
- X11ErrorTracker();
- ~X11ErrorTracker();
-
- // Returns whether an X11 error happened since this function was last called
- // (or since the creation of the tracker). This is potentially expensive,
- // since this causes a sync with the X server.
- bool FoundNewError();
-
- private:
-#if !defined(TOOLKIT_GTK)
- XErrorHandler old_handler_;
-#endif
-
- DISALLOW_COPY_AND_ASSIGN(X11ErrorTracker);
-};
-
-} // namespace ui
diff --git a/ui/base/x/x11_error_tracker_gtk.cc b/ui/base/x/x11_error_tracker_gtk.cc
deleted file mode 100644
index 2806d34..0000000
--- a/ui/base/x/x11_error_tracker_gtk.cc
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/base/x/x11_error_tracker.h"
-
-#include <gdk/gdkx.h>
-
-#include "base/logging.h"
-
-namespace ui {
-
-X11ErrorTracker::X11ErrorTracker() {
- gdk_error_trap_push();
-}
-
-X11ErrorTracker::~X11ErrorTracker() {
- gdk_error_trap_pop();
-}
-
-bool X11ErrorTracker::FoundNewError() {
- gdk_flush();
- bool found_error = gdk_error_trap_pop() != 0;
-
- gdk_error_trap_push();
- return found_error;
-}
-
-} // namespace ui
diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc
index 86914195..ec29ef7 100644
--- a/ui/base/x/x11_util.cc
+++ b/ui/base/x/x11_util.cc
@@ -32,9 +32,9 @@
#include "base/strings/stringprintf.h"
#include "base/sys_byteorder.h"
#include "base/threading/thread.h"
+#include "base/x11/x11_error_tracker.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkPostConfig.h"
-#include "ui/base/x/x11_error_tracker.h"
#include "ui/base/x/x11_util_internal.h"
#include "ui/events/event_utils.h"
#include "ui/events/keycodes/keyboard_code_conversion_x.h"
@@ -302,7 +302,7 @@ static SharedMemorySupport DoQuerySharedMemorySupport(XDisplay* dpy) {
memset(&shminfo, 0, sizeof(shminfo));
shminfo.shmid = shmkey;
- X11ErrorTracker err_tracker;
+ base::X11ErrorTracker err_tracker;
bool result = XShmAttach(dpy, &shminfo);
if (result)
VLOG(1) << "X got shared memory segment " << shmkey;
@@ -871,7 +871,7 @@ bool SetIntArrayProperty(XID window,
for (size_t i = 0; i < value.size(); ++i)
data[i] = value[i];
- X11ErrorTracker err_tracker;
+ base::X11ErrorTracker err_tracker;
XChangeProperty(gfx::GetXDisplay(),
window,
name_atom,
@@ -896,7 +896,7 @@ bool SetAtomArrayProperty(XID window,
for (size_t i = 0; i < value.size(); ++i)
data[i] = value[i];
- X11ErrorTracker err_tracker;
+ base::X11ErrorTracker err_tracker;
XChangeProperty(gfx::GetXDisplay(),
window,
name_atom,
@@ -1189,7 +1189,7 @@ bool GetWindowManagerName(std::string* wm_name) {
// _NET_SUPPORTING_WM_CHECK property pointing to itself (to avoid a stale
// property referencing an ID that's been recycled for another window), so we
// check that too.
- X11ErrorTracker err_tracker;
+ base::X11ErrorTracker err_tracker;
int wm_window_property = 0;
bool result = GetIntProperty(
wm_window, "_NET_SUPPORTING_WM_CHECK", &wm_window_property);
diff --git a/ui/ui.gyp b/ui/ui.gyp
index deb44b2..0103dc0 100644
--- a/ui/ui.gyp
+++ b/ui/ui.gyp
@@ -327,9 +327,6 @@
'base/x/selection_utils.h',
'base/x/work_area_watcher_x.cc',
'base/x/work_area_watcher_x.h',
- 'base/x/x11_error_tracker.cc',
- 'base/x/x11_error_tracker.h',
- 'base/x/x11_error_tracker_gtk.cc',
'base/x/x11_util.cc',
'base/x/x11_util.h',
'base/x/x11_util_internal.h',
@@ -766,9 +763,6 @@
'gfx/image/cairo_cached_surface.h',
'gfx/scoped_gobject.h',
],
- 'sources!': [
- 'base/x/x11_error_tracker.cc',
- ],
}],
['chromeos==1 or (use_aura==1 and OS=="linux" and use_x11==0)', {
'sources!': [