summaryrefslogtreecommitdiffstats
path: root/chromeos
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-14 20:25:13 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-14 20:25:13 +0000
commit3f4cfd5be0fd65c13252c122c0a80cd46e247c3e (patch)
treed105761e52ce364d6432d4ed0fb1c8a9189fba4f /chromeos
parentcf28cd1ed8bc378ba1260a94897ab8c9aecbc894 (diff)
downloadchromium_src-3f4cfd5be0fd65c13252c122c0a80cd46e247c3e.zip
chromium_src-3f4cfd5be0fd65c13252c122c0a80cd46e247c3e.tar.gz
chromium_src-3f4cfd5be0fd65c13252c122c0a80cd46e247c3e.tar.bz2
x11: Create a gfx_x11 component.
Separate out the X11 related code in gfx into a separate gfx_x11 component that only depends on gfx_geometry. This change makes it possible to add a dependency on gfx_x11 without pulling in a lot of additional dependencies on chromeos/. With this updated dependency, use gfx::GetXDisplay() to get to the X11 connection without having to depend on the message-pump inside chromeos/. BUG=354062 R=derat@chromium.org, sky@chromium.org Review URL: https://codereview.chromium.org/225803003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263718 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r--chromeos/DEPS3
-rw-r--r--chromeos/chromeos.gyp6
-rw-r--r--chromeos/ime/ime_keyboard_x11.cc23
-rw-r--r--chromeos/ime/ime_keyboard_x11_unittest.cc3
4 files changed, 20 insertions, 15 deletions
diff --git a/chromeos/DEPS b/chromeos/DEPS
index 82f85b3..63bcc90 100644
--- a/chromeos/DEPS
+++ b/chromeos/DEPS
@@ -3,5 +3,6 @@ include_rules = [
"+net",
"+third_party/cros_system_api",
"+third_party/libxml",
- "+ui/gfx/geometry"
+ "+ui/gfx/geometry",
+ "+ui/gfx/x"
]
diff --git a/chromeos/chromeos.gyp b/chromeos/chromeos.gyp
index c03fe1a..bc73f6a 100644
--- a/chromeos/chromeos.gyp
+++ b/chromeos/chromeos.gyp
@@ -372,6 +372,7 @@
['use_x11 == 1', {
'dependencies': [
'../build/linux/system.gyp:x11',
+ '../ui/gfx/gfx.gyp:gfx_x11',
],
}, {
# use_x11 == 0
@@ -547,6 +548,11 @@
],
},
],
+ ['use_x11 == 1', {
+ 'dependencies': [
+ '../ui/gfx/gfx.gyp:gfx_x11',
+ ],
+ }]
],
},
{
diff --git a/chromeos/ime/ime_keyboard_x11.cc b/chromeos/ime/ime_keyboard_x11.cc
index 952a8d9..6390d2a 100644
--- a/chromeos/ime/ime_keyboard_x11.cc
+++ b/chromeos/ime/ime_keyboard_x11.cc
@@ -21,6 +21,7 @@
#include "base/strings/stringprintf.h"
#include "base/sys_info.h"
#include "base/threading/thread_checker.h"
+#include "ui/gfx/x/x11_types.h"
// These includes conflict with base/tracked_objects.h so must come last.
#include <X11/XKBlib.h>
@@ -30,10 +31,6 @@ namespace chromeos {
namespace input_method {
namespace {
-Display* GetXDisplay() {
- return base::MessagePumpForUI::GetDefaultXDisplay();
-}
-
// The delay in milliseconds that we'll wait between checking if
// setxkbmap command finished.
const int kSetLayoutCommandCheckDelayMs = 100;
@@ -182,7 +179,7 @@ ImeKeyboardX11::ImeKeyboardX11()
: is_running_on_chrome_os_(base::SysInfo::IsRunningOnChromeOS()),
weak_factory_(this) {
// X must be already initialized.
- CHECK(GetXDisplay());
+ CHECK(gfx::GetXDisplay());
num_lock_mask_ = GetNumLockMask();
@@ -213,7 +210,7 @@ unsigned int ImeKeyboardX11::GetNumLockMask() {
unsigned int real_mask = kBadMask;
XkbDescPtr xkb_desc =
- XkbGetKeyboard(GetXDisplay(), XkbAllComponentsMask, XkbUseCoreKbd);
+ XkbGetKeyboard(gfx::GetXDisplay(), XkbAllComponentsMask, XkbUseCoreKbd);
if (!xkb_desc)
return kBadMask;
@@ -252,7 +249,7 @@ void ImeKeyboardX11::SetLockedModifiers(bool caps_lock_enabled) {
value_mask |= (caps_lock_enabled ? LockMask : 0);
current_caps_lock_status_ = caps_lock_enabled;
- XkbLockModifiers(GetXDisplay(), XkbUseCoreKbd, affect_mask, value_mask);
+ XkbLockModifiers(gfx::GetXDisplay(), XkbUseCoreKbd, affect_mask, value_mask);
}
bool ImeKeyboardX11::SetLayoutInternal(const std::string& layout_name,
@@ -349,7 +346,7 @@ void ImeKeyboardX11::PollUntilChildFinish(const base::ProcessHandle handle) {
bool ImeKeyboardX11::CapsLockIsEnabled() {
DCHECK(thread_checker_.CalledOnValidThread());
XkbStateRec status;
- XkbGetState(GetXDisplay(), XkbUseCoreKbd, &status);
+ XkbGetState(gfx::GetXDisplay(), XkbUseCoreKbd, &status);
return (status.locked_mods & LockMask);
}
@@ -371,9 +368,9 @@ bool ImeKeyboardX11::IsAltGrAvailable() const {
bool ImeKeyboardX11::SetAutoRepeatEnabled(bool enabled) {
if (enabled)
- XAutoRepeatOn(GetXDisplay());
+ XAutoRepeatOn(gfx::GetXDisplay());
else
- XAutoRepeatOff(GetXDisplay());
+ XAutoRepeatOff(gfx::GetXDisplay());
DVLOG(1) << "Set auto-repeat mode to: " << (enabled ? "on" : "off");
return true;
}
@@ -382,7 +379,7 @@ bool ImeKeyboardX11::SetAutoRepeatRate(const AutoRepeatRate& rate) {
DVLOG(1) << "Set auto-repeat rate to: "
<< rate.initial_delay_in_ms << " ms delay, "
<< rate.repeat_interval_in_ms << " ms interval";
- if (XkbSetAutoRepeatRate(GetXDisplay(), XkbUseCoreKbd,
+ if (XkbSetAutoRepeatRate(gfx::GetXDisplay(), XkbUseCoreKbd,
rate.initial_delay_in_ms,
rate.repeat_interval_in_ms) != True) {
DVLOG(1) << "Failed to set auto-repeat rate";
@@ -440,13 +437,13 @@ void ImeKeyboardX11::OnSetLayoutFinish() {
// static
bool ImeKeyboard::GetAutoRepeatEnabledForTesting() {
XKeyboardState state = {};
- XGetKeyboardControl(GetXDisplay(), &state);
+ XGetKeyboardControl(gfx::GetXDisplay(), &state);
return state.global_auto_repeat != AutoRepeatModeOff;
}
// static
bool ImeKeyboard::GetAutoRepeatRateForTesting(AutoRepeatRate* out_rate) {
- return XkbGetAutoRepeatRate(GetXDisplay(),
+ return XkbGetAutoRepeatRate(gfx::GetXDisplay(),
XkbUseCoreKbd,
&(out_rate->initial_delay_in_ms),
&(out_rate->repeat_interval_in_ms)) == True;
diff --git a/chromeos/ime/ime_keyboard_x11_unittest.cc b/chromeos/ime/ime_keyboard_x11_unittest.cc
index 0cbda3a..cbf7cc7 100644
--- a/chromeos/ime/ime_keyboard_x11_unittest.cc
+++ b/chromeos/ime/ime_keyboard_x11_unittest.cc
@@ -12,6 +12,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/x/x11_types.h"
#include <X11/Xlib.h>
@@ -40,7 +41,7 @@ class ImeKeyboardTest : public testing::Test {
// Returns true if X display is available.
bool DisplayAvailable() {
- return (base::MessagePumpForUI::GetDefaultXDisplay() != NULL);
+ return gfx::GetXDisplay() != NULL;
}
} // namespace