Commit 62956918 authored by sadrul@chromium.org's avatar sadrul@chromium.org

x11: Prefer using ui::GetXDisplay() over getting the Display from the X11 message-pump.

BUG=none
R=oshima@chromium.org

Review URL: https://codereview.chromium.org/23622035

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223621 0039d316-1c4b-4281-b951-d872f2087c98
parent ccce6e2f
......@@ -34,6 +34,10 @@
#include "ui/gfx/image/image_skia_operations.h"
#include "ui/gfx/native_widget_types.h"
#if defined(USE_X11)
#include "ui/base/x/x11_util.h"
#endif
namespace ash {
namespace internal {
namespace {
......@@ -43,8 +47,7 @@ namespace {
void DisableInput(XID window) {
long event_mask = ExposureMask | VisibilityChangeMask |
StructureNotifyMask | PropertyChangeMask;
XSelectInput(base::MessagePumpX11::GetDefaultXDisplay(),
window, event_mask);
XSelectInput(ui::GetXDisplay(), window, event_mask);
}
#endif
......
......@@ -363,7 +363,7 @@ class RootWindowHostX11::MouseMoveFilter {
RootWindowHostX11::RootWindowHostX11(const gfx::Rect& bounds)
: delegate_(NULL),
xdisplay_(base::MessagePumpX11::GetDefaultXDisplay()),
xdisplay_(ui::GetXDisplay()),
xwindow_(0),
x_root_window_(DefaultRootWindow(xdisplay_)),
current_cursor_(ui::kCursorNull),
......@@ -1090,7 +1090,7 @@ RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) {
// static
gfx::Size RootWindowHost::GetNativeScreenSize() {
::Display* xdisplay = base::MessagePumpX11::GetDefaultXDisplay();
::Display* xdisplay = ui::GetXDisplay();
return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0));
}
......
......@@ -11,13 +11,13 @@
#endif
#include "base/logging.h"
#include "base/message_loop/message_pump_x11.h"
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/aura/test/ui_controls_factory_aura.h"
#include "ui/base/keycodes/keyboard_code_conversion_x.h"
#include "ui/base/test/ui_controls_aura.h"
#include "ui/base/x/x11_util.h"
#include "ui/compositor/dip_util.h"
namespace aura {
......@@ -73,9 +73,7 @@ class EventWaiter : public base::MessageLoopForUI::Observer {
// Returns atom that indidates that the XEvent is marker event.
Atom MarkerEventAtom() {
return XInternAtom(base::MessagePumpX11::GetDefaultXDisplay(),
"marker_event",
False);
return XInternAtom(ui::GetXDisplay(), "marker_event", False);
}
// Returns true when the event is a marker event.
......@@ -117,7 +115,7 @@ class UIControlsX11 : public UIControlsAura {
if (alt)
SetKeycodeAndSendThenMask(&xevent, XK_Alt_L, Mod1Mask);
xevent.xkey.keycode =
XKeysymToKeycode(base::MessagePumpX11::GetDefaultXDisplay(),
XKeysymToKeycode(ui::GetXDisplay(),
ui::XKeysymForWindowsKeyCode(key, shift));
root_window_->PostNativeEvent(&xevent);
......@@ -227,8 +225,7 @@ class UIControlsX11 : public UIControlsAura {
KeySym keysym,
unsigned int mask) {
xevent->xkey.keycode =
XKeysymToKeycode(base::MessagePumpX11::GetDefaultXDisplay(),
keysym);
XKeysymToKeycode(ui::GetXDisplay(), keysym);
root_window_->PostNativeEvent(xevent);
xevent->xkey.state |= mask;
}
......@@ -238,8 +235,7 @@ class UIControlsX11 : public UIControlsAura {
KeySym keysym) {
xevent->xkey.state ^= mask;
xevent->xkey.keycode =
XKeysymToKeycode(base::MessagePumpX11::GetDefaultXDisplay(),
keysym);
XKeysymToKeycode(ui::GetXDisplay(), keysym);
root_window_->PostNativeEvent(xevent);
}
......
......@@ -260,9 +260,7 @@ double GetTouchParamFromXEvent(XEvent* xev,
}
Atom GetNoopEventAtom() {
return XInternAtom(
base::MessagePumpX11::GetDefaultXDisplay(),
"noop", False);
return XInternAtom(ui::GetXDisplay(), "noop", False);
}
} // namespace
......
......@@ -238,12 +238,11 @@ DesktopDragDropClientAuraX11::X11DragContext::X11DragContext(
// created by some other process. Listen for messages on it.
base::MessagePumpX11::Current()->AddDispatcherForWindow(
this, source_window_);
XSelectInput(base::MessagePumpX11::GetDefaultXDisplay(),
source_window_, PropertyChangeMask);
XSelectInput(ui::GetXDisplay(), source_window_, PropertyChangeMask);
// We must perform a full sync here because we could be racing
// |source_window_|.
XSync(base::MessagePumpX11::GetDefaultXDisplay(), False);
XSync(ui::GetXDisplay(), False);
} else {
// This drag originates from an aura window within our process. This means
// that we can shortcut the X11 server and ask the owning SelectionOwner
......@@ -289,7 +288,7 @@ void DesktopDragDropClientAuraX11::X11DragContext::RequestNextTarget() {
::Atom target = unfetched_targets_.back();
unfetched_targets_.pop_back();
XConvertSelection(base::MessagePumpX11::GetDefaultXDisplay(),
XConvertSelection(ui::GetXDisplay(),
atom_cache_->GetAtom(kXdndSelection),
target,
atom_cache_->GetAtom(kChromiumDragReciever),
......
......@@ -114,7 +114,7 @@ DesktopRootWindowHostX11::DesktopRootWindowHostX11(
DesktopNativeWidgetAura* desktop_native_widget_aura,
const gfx::Rect& initial_bounds)
: close_widget_factory_(this),
xdisplay_(base::MessagePumpX11::GetDefaultXDisplay()),
xdisplay_(ui::GetXDisplay()),
xwindow_(0),
x_root_window_(DefaultRootWindow(xdisplay_)),
atom_cache_(xdisplay_, kAtomsToCache),
......
......@@ -38,7 +38,7 @@ X11DesktopHandler* X11DesktopHandler::get() {
}
X11DesktopHandler::X11DesktopHandler()
: xdisplay_(base::MessagePumpX11::GetDefaultXDisplay()),
: xdisplay_(ui::GetXDisplay()),
x_root_window_(DefaultRootWindow(xdisplay_)),
current_window_(None),
atom_cache_(xdisplay_, kAtomsToCache) {
......@@ -58,7 +58,7 @@ X11DesktopHandler::~X11DesktopHandler() {
}
void X11DesktopHandler::ActivateWindow(::Window window) {
DCHECK_EQ(base::MessagePumpX11::GetDefaultXDisplay(), xdisplay_);
DCHECK_EQ(ui::GetXDisplay(), xdisplay_);
XEvent xclient;
memset(&xclient, 0, sizeof(xclient));
......
......@@ -64,7 +64,7 @@ bool X11WholeScreenMoveLoop::RunMoveLoop(aura::Window* source,
DCHECK(!in_move_loop_); // Can only handle one nested loop at a time.
in_move_loop_ = true;
Display* display = base::MessagePumpX11::GetDefaultXDisplay();
Display* display = ui::GetXDisplay();
// Creates an invisible, InputOnly toplevel window. This window will receive
// all mouse movement for drags. It turns out that normal windows doing a
......@@ -116,7 +116,7 @@ void X11WholeScreenMoveLoop::EndMoveLoop() {
// the chrome process.
// Ungrab before we let go of the window.
Display* display = base::MessagePumpX11::GetDefaultXDisplay();
Display* display = ui::GetXDisplay();
XUngrabPointer(display, CurrentTime);
base::MessagePumpX11::Current()->RemoveDispatcherForWindow(
......@@ -129,7 +129,7 @@ void X11WholeScreenMoveLoop::EndMoveLoop() {
}
bool X11WholeScreenMoveLoop::GrabPointerWithCursor(gfx::NativeCursor cursor) {
Display* display = base::MessagePumpX11::GetDefaultXDisplay();
Display* display = ui::GetXDisplay();
XGrabServer(display);
XUngrabPointer(display, CurrentTime);
int ret = XGrabPointer(
......
......@@ -9,12 +9,12 @@
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include "base/message_loop/message_pump_x11.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window_delegate.h"
#include "ui/base/events/event.h"
#include "ui/base/events/event_utils.h"
#include "ui/base/hit_test.h"
#include "ui/base/x/x11_util.h"
#include "ui/views/widget/native_widget_aura.h"
namespace {
......@@ -59,7 +59,7 @@ namespace views {
X11WindowEventFilter::X11WindowEventFilter(
aura::RootWindow* root_window)
: xdisplay_(base::MessagePumpX11::GetDefaultXDisplay()),
: xdisplay_(ui::GetXDisplay()),
xwindow_(root_window->GetAcceleratedWidget()),
x_root_window_(DefaultRootWindow(xdisplay_)),
atom_cache_(xdisplay_, kAtomsToCache),
......@@ -76,7 +76,7 @@ void X11WindowEventFilter::SetUseHostWindowBorders(bool use_os_border) {
motif_hints.decorations = use_os_border ? 1 : 0;
::Atom hint_atom = atom_cache_.GetAtom("_MOTIF_WM_HINTS");
XChangeProperty(base::MessagePumpX11::GetDefaultXDisplay(),
XChangeProperty(ui::GetXDisplay(),
xwindow_,
hint_atom,
hint_atom,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment