0

[XProto] Remove old x11::* constants

BUG=1066670
R=sky

Change-Id: I3df7737031e8aecc9463b8f42fb5bcf8b5722693
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2410841
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Auto-Submit: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807165}
This commit is contained in:
Tom Anderson
2020-09-15 20:35:25 +00:00
committed by Commit Bot
parent faa1a22bb4
commit 2a460ccaa4
16 changed files with 222 additions and 209 deletions

@ -111,7 +111,7 @@ bool GlobalShortcutListenerX11::RegisterAcceleratorImpl(
// Caps lock, Scroll lock. See comment about |kModifiersMasks|.
for (unsigned int kModifiersMask : kModifiersMasks) {
XGrabKey(x_display_, keycode, modifiers | kModifiersMask,
static_cast<uint32_t>(x_root_window_), x11::False, GrabModeAsync,
static_cast<uint32_t>(x_root_window_), false, GrabModeAsync,
GrabModeAsync);
}

@ -191,8 +191,8 @@ class Simulator {
display_, kVisualIdMask, &visual_info_template, &visual_info_count);
for (int i = 0; i < visual_info_count && !gl_context_; ++i) {
gl_context_ = glXCreateContext(display_, visual_info_list + i, 0,
x11::True /* Direct rendering */);
gl_context_ = glXCreateContext(display_, visual_info_list + i, nullptr,
true /* Direct rendering */);
}
XFree(visual_info_list);

@ -168,7 +168,6 @@ class InputInjectorX11 : public InputInjector {
// X11 graphics context.
x11::Connection connection_;
Display* display_ = connection_.display();
Window root_window_ = x11::None;
// Number of buttons we support.
// Left, Right, Middle, VScroll Up/Down, HScroll Left/Right, back, forward.
@ -243,12 +242,6 @@ bool InputInjectorX11::Core::Init() {
task_runner_->PostTask(FROM_HERE,
base::BindOnce(&Core::InitClipboard, this));
root_window_ = XDefaultRootWindow(display_);
if (!root_window_) {
LOG(ERROR) << "Unable to get the root window";
return false;
}
if (!IgnoreXServerGrabs(&connection_, true)) {
LOG(ERROR) << "Server does not support XTest.";
return false;
@ -393,7 +386,7 @@ bool InputInjectorX11::Core::IsLockKey(KeyCode keycode) {
auto mods = state->baseMods | state->latchedMods | state->lockedMods;
KeySym keysym;
if (state && XkbLookupKeySym(display_, keycode, static_cast<unsigned>(mods),
nullptr, &keysym) == x11::True) {
nullptr, &keysym)) {
return keysym == XK_Caps_Lock || keysym == XK_Num_Lock;
} else {
return false;

@ -4,7 +4,11 @@
#include "remoting/host/linux/x_server_clipboard.h"
#include <limits>
#include "base/callback.h"
#include "base/memory/ref_counted_memory.h"
#include "base/memory/scoped_refptr.h"
#include "base/stl_util.h"
#include "remoting/base/constants.h"
#include "remoting/base/logging.h"
@ -16,15 +20,7 @@
namespace remoting {
XServerClipboard::XServerClipboard()
: clipboard_window_(x11::None),
clipboard_atom_(x11::None),
large_selection_atom_(x11::None),
selection_string_atom_(x11::None),
targets_atom_(x11::None),
timestamp_atom_(x11::None),
utf8_string_atom_(x11::None),
large_selection_property_(x11::None) {}
XServerClipboard::XServerClipboard() = default;
XServerClipboard::~XServerClipboard() = default;
@ -51,11 +47,14 @@ void XServerClipboard::Init(x11::Connection* connection,
connection_->xfixes().QueryVersion(
{x11::XFixes::major_version, x11::XFixes::minor_version});
clipboard_window_ =
XCreateSimpleWindow(connection_->display(),
XDefaultRootWindow(connection_->display()), 0, 0, 1,
1, // x, y, width, height
0, 0, 0);
clipboard_window_ = connection_->GenerateId<x11::Window>();
connection_->CreateWindow({
.wid = clipboard_window_,
.parent = connection_->default_root(),
.width = 1,
.height = 1,
.override_redirect = x11::Bool32(true),
});
// TODO(lambroslambrou): Use ui::X11AtomCache for this, either by adding a
// dependency on ui/ or by moving X11AtomCache to base/.
@ -64,19 +63,27 @@ void XServerClipboard::Init(x11::Connection* connection,
"TIMESTAMP", "UTF8_STRING"};
static const int kNumAtomNames = base::size(kAtomNames);
Atom atoms[kNumAtomNames];
if (XInternAtoms(connection_->display(), const_cast<char**>(kAtomNames),
kNumAtomNames, x11::False, atoms)) {
clipboard_atom_ = atoms[0];
large_selection_atom_ = atoms[1];
selection_string_atom_ = atoms[2];
targets_atom_ = atoms[3];
timestamp_atom_ = atoms[4];
utf8_string_atom_ = atoms[5];
static_assert(kNumAtomNames >= 6, "kAtomNames is too small");
} else {
LOG(ERROR) << "XInternAtoms failed";
x11::Future<x11::InternAtomReply> futures[kNumAtomNames];
for (size_t i = 0; i < kNumAtomNames; i++)
futures[i] = connection_->InternAtom({false, kAtomNames[i]});
connection_->Flush();
x11::Atom atoms[kNumAtomNames];
memset(atoms, 0, sizeof(atoms));
for (size_t i = 0; i < kNumAtomNames; i++) {
if (auto reply = futures[i].Sync()) {
atoms[i] = reply->atom;
} else {
LOG(ERROR) << "Failed to intern atom(s)";
break;
}
}
clipboard_atom_ = atoms[0];
large_selection_atom_ = atoms[1];
selection_string_atom_ = atoms[2];
targets_atom_ = atoms[3];
timestamp_atom_ = atoms[4];
utf8_string_atom_ = atoms[5];
static_assert(kNumAtomNames >= 6, "kAtomNames is too small");
connection_->xfixes().SelectSelectionInput(
{static_cast<x11::Window>(clipboard_window_),
@ -89,7 +96,7 @@ void XServerClipboard::SetClipboard(const std::string& mime_type,
const std::string& data) {
DCHECK(connection_->display());
if (clipboard_window_ == x11::None)
if (clipboard_window_ == x11::Window::None)
return;
// Currently only UTF-8 is supported.
@ -102,13 +109,13 @@ void XServerClipboard::SetClipboard(const std::string& mime_type,
data_ = data;
AssertSelectionOwnership(static_cast<uint32_t>(x11::Atom::PRIMARY));
AssertSelectionOwnership(x11::Atom::PRIMARY);
AssertSelectionOwnership(clipboard_atom_);
}
void XServerClipboard::ProcessXEvent(const x11::Event& event) {
if (clipboard_window_ == x11::None ||
event.window() != static_cast<x11::Window>(clipboard_window_)) {
if (clipboard_window_ == x11::Window::None ||
event.window() != clipboard_window_) {
return;
}
@ -123,14 +130,13 @@ void XServerClipboard::ProcessXEvent(const x11::Event& event) {
if (auto* xfixes_selection_notify =
event.As<x11::XFixes::SelectionNotifyEvent>()) {
OnSetSelectionOwnerNotify(
static_cast<uint32_t>(xfixes_selection_notify->selection),
static_cast<uint32_t>(xfixes_selection_notify->selection_timestamp));
OnSetSelectionOwnerNotify(xfixes_selection_notify->selection,
xfixes_selection_notify->selection_timestamp);
}
}
void XServerClipboard::OnSetSelectionOwnerNotify(Atom selection,
Time timestamp) {
void XServerClipboard::OnSetSelectionOwnerNotify(x11::Atom selection,
x11::Time timestamp) {
// Protect against receiving new XFixes selection notifications whilst we're
// in the middle of waiting for information from the current selection owner.
// A reasonable timeout allows for misbehaving apps that don't respond
@ -160,25 +166,25 @@ void XServerClipboard::OnSetSelectionOwnerNotify(Atom selection,
}
void XServerClipboard::OnPropertyNotify(const x11::PropertyNotifyEvent& event) {
if (large_selection_property_ != x11::None &&
event.atom == static_cast<x11::Atom>(large_selection_property_) &&
if (large_selection_property_ != x11::Atom::None &&
event.atom == large_selection_property_ &&
event.state == x11::Property::NewValue) {
Atom type;
int format;
unsigned long item_count, after;
unsigned char* data;
XGetWindowProperty(connection_->display(), clipboard_window_,
large_selection_property_, 0, ~0L, x11::True,
AnyPropertyType, &type, &format, &item_count, &after,
&data);
if (type != x11::None) {
// TODO(lambroslambrou): Properly support large transfers -
// http://crbug.com/151447.
XFree(data);
auto req = connection_->GetProperty({
.c_delete = true,
.window = clipboard_window_,
.property = large_selection_property_,
.type = x11::Atom::Any,
.long_length = std::numeric_limits<uint32_t>::max(),
});
if (auto reply = req.Sync()) {
if (reply->type != x11::Atom::None) {
// TODO(lambroslambrou): Properly support large transfers -
// http://crbug.com/151447.
// If the property is zero-length then the large transfer is complete.
if (item_count == 0)
large_selection_property_ = x11::None;
// If the property is zero-length then the large transfer is complete.
if (reply->value_len == 0)
large_selection_property_ = x11::Atom::None;
}
}
}
}
@ -186,28 +192,29 @@ void XServerClipboard::OnPropertyNotify(const x11::PropertyNotifyEvent& event) {
void XServerClipboard::OnSelectionNotify(
const x11::SelectionNotifyEvent& event) {
if (event.property != x11::Atom::None) {
Atom type;
int format;
unsigned long item_count, after;
unsigned char* data;
XGetWindowProperty(connection_->display(), clipboard_window_,
static_cast<uint32_t>(event.property), 0, ~0L, x11::True,
AnyPropertyType, &type, &format, &item_count, &after,
&data);
if (type == large_selection_atom_) {
// Large selection - just read and ignore these for now.
large_selection_property_ = static_cast<uint32_t>(event.property);
} else {
// Standard selection - call the selection notifier.
large_selection_property_ = x11::None;
if (type != x11::None) {
HandleSelectionNotify(event, type, format, item_count, data);
XFree(data);
return;
auto req = connection_->GetProperty({
.c_delete = true,
.window = clipboard_window_,
.property = event.property,
.type = x11::Atom::Any,
.long_length = std::numeric_limits<uint32_t>::max(),
});
if (auto reply = req.Sync()) {
if (reply->type == large_selection_atom_) {
// Large selection - just read and ignore these for now.
large_selection_property_ = event.property;
} else {
// Standard selection - call the selection notifier.
large_selection_property_ = x11::Atom::None;
if (reply->type != x11::Atom::None) {
HandleSelectionNotify(event, reply->type, reply->format,
reply->value_len, reply->value->data());
return;
}
}
}
}
HandleSelectionNotify(event, 0, 0, 0, nullptr);
HandleSelectionNotify(event, x11::Atom::None, 0, 0, nullptr);
}
void XServerClipboard::OnSelectionRequest(
@ -219,23 +226,21 @@ void XServerClipboard::OnSelectionRequest(
selection_event.target = event.target;
auto property =
event.property == x11::Atom::None ? event.target : event.property;
if (!IsSelectionOwner(static_cast<uint32_t>(selection_event.selection))) {
if (!IsSelectionOwner(selection_event.selection)) {
selection_event.property = x11::Atom::None;
} else {
selection_event.property = property;
if (selection_event.target == static_cast<x11::Atom>(targets_atom_)) {
SendTargetsResponse(static_cast<uint32_t>(selection_event.requestor),
static_cast<uint32_t>(selection_event.property));
SendTargetsResponse(selection_event.requestor, selection_event.property);
} else if (selection_event.target ==
static_cast<x11::Atom>(timestamp_atom_)) {
SendTimestampResponse(static_cast<uint32_t>(selection_event.requestor),
static_cast<uint32_t>(selection_event.property));
SendTimestampResponse(selection_event.requestor,
selection_event.property);
} else if (selection_event.target ==
static_cast<x11::Atom>(utf8_string_atom_) ||
selection_event.target == x11::Atom::STRING) {
SendStringResponse(static_cast<uint32_t>(selection_event.requestor),
static_cast<uint32_t>(selection_event.property),
static_cast<uint32_t>(selection_event.target));
SendStringResponse(selection_event.requestor, selection_event.property,
selection_event.target);
}
}
x11::SendEvent(selection_event, selection_event.requestor,
@ -243,22 +248,33 @@ void XServerClipboard::OnSelectionRequest(
}
void XServerClipboard::OnSelectionClear(const x11::SelectionClearEvent& event) {
selections_owned_.erase(static_cast<uint32_t>(event.selection));
selections_owned_.erase(event.selection);
}
void XServerClipboard::SendTargetsResponse(Window requestor, Atom property) {
void XServerClipboard::SendTargetsResponse(x11::Window requestor,
x11::Atom property) {
// Respond advertising x11::Atom::STRING, UTF8_STRING and TIMESTAMP data for
// the selection.
Atom targets[3];
targets[0] = timestamp_atom_;
targets[1] = utf8_string_atom_;
targets[2] = static_cast<uint32_t>(x11::Atom::STRING);
XChangeProperty(connection_->display(), requestor, property,
static_cast<uint32_t>(x11::Atom::ATOM), 32, PropModeReplace,
reinterpret_cast<unsigned char*>(targets), 3);
x11::Atom targets[3] = {
timestamp_atom_,
utf8_string_atom_,
x11::Atom::STRING,
};
connection_->ChangeProperty({
.mode = x11::PropMode::Replace,
.window = requestor,
.property = property,
.type = x11::Atom::ATOM,
.format = CHAR_BIT * sizeof(x11::Atom),
.data_len = base::size(targets),
.data = base::MakeRefCounted<base::RefCountedStaticMemory>(
&targets[0], sizeof(targets)),
});
connection_->Flush();
}
void XServerClipboard::SendTimestampResponse(Window requestor, Atom property) {
void XServerClipboard::SendTimestampResponse(x11::Window requestor,
x11::Atom property) {
// Respond with the timestamp of our selection; we always return
// CurrentTime since our selections are set by remote clients, so there
// is no associated local X event.
@ -266,40 +282,53 @@ void XServerClipboard::SendTimestampResponse(Window requestor, Atom property) {
// TODO(lambroslambrou): Should use a proper timestamp here instead of
// CurrentTime. ICCCM recommends doing a zero-length property append,
// and getting a timestamp from the subsequent PropertyNotify event.
Time time = x11::CurrentTime;
XChangeProperty(connection_->display(), requestor, property,
static_cast<uint32_t>(x11::Atom::INTEGER), 32,
PropModeReplace, reinterpret_cast<unsigned char*>(&time), 1);
x11::Time time = x11::Time::CurrentTime;
connection_->ChangeProperty({
.mode = x11::PropMode::Replace,
.window = requestor,
.property = property,
.type = x11::Atom::INTEGER,
.format = CHAR_BIT * sizeof(x11::Time),
.data_len = 1,
.data = base::MakeRefCounted<base::RefCountedStaticMemory>(&time,
sizeof(time)),
});
connection_->Flush();
}
void XServerClipboard::SendStringResponse(Window requestor,
Atom property,
Atom target) {
void XServerClipboard::SendStringResponse(x11::Window requestor,
x11::Atom property,
x11::Atom target) {
if (!data_.empty()) {
// Return the actual string data; we always return UTF8, regardless of
// the configured locale.
XChangeProperty(
connection_->display(), requestor, property, target, 8, PropModeReplace,
reinterpret_cast<unsigned char*>(const_cast<char*>(data_.data())),
data_.size());
connection_->ChangeProperty({
.mode = x11::PropMode::Replace,
.window = requestor,
.property = property,
.type = target,
.format = 8,
.data_len = data_.size(),
.data = base::MakeRefCounted<base::RefCountedStaticMemory>(
data_.data(), data_.size()),
});
connection_->Flush();
}
}
void XServerClipboard::HandleSelectionNotify(
const x11::SelectionNotifyEvent& event,
Atom type,
x11::Atom type,
int format,
int item_count,
void* data) {
const void* data) {
bool finished = false;
auto target = static_cast<uint32_t>(event.target);
if (target == targets_atom_) {
auto target = event.target;
if (target == targets_atom_)
finished = HandleSelectionTargetsEvent(event, format, item_count, data);
} else if (target == utf8_string_atom_ ||
target == static_cast<uint32_t>(x11::Atom::STRING)) {
else if (target == utf8_string_atom_ || target == x11::Atom::STRING)
finished = HandleSelectionStringEvent(event, format, item_count, data);
}
if (finished)
get_selections_time_ = base::TimeTicks();
@ -309,9 +338,9 @@ bool XServerClipboard::HandleSelectionTargetsEvent(
const x11::SelectionNotifyEvent& event,
int format,
int item_count,
void* data) {
auto selection = static_cast<uint32_t>(event.selection);
if (event.property == static_cast<x11::Atom>(targets_atom_)) {
const void* data) {
auto selection = event.selection;
if (event.property == targets_atom_) {
if (data && format == 32) {
// The XGetWindowProperty man-page specifies that the returned
// property data will be an array of |long|s in the case where
@ -328,7 +357,7 @@ bool XServerClipboard::HandleSelectionTargetsEvent(
}
}
}
RequestSelectionString(selection, static_cast<uint32_t>(x11::Atom::STRING));
RequestSelectionString(selection, x11::Atom::STRING);
return false;
}
@ -336,17 +365,16 @@ bool XServerClipboard::HandleSelectionStringEvent(
const x11::SelectionNotifyEvent& event,
int format,
int item_count,
void* data) {
auto property = static_cast<uint32_t>(event.property);
auto target = static_cast<uint32_t>(event.target);
const void* data) {
auto property = event.property;
auto target = event.target;
if (property != selection_string_atom_ || !data || format != 8)
return true;
std::string text(static_cast<char*>(data), item_count);
std::string text(static_cast<const char*>(data), item_count);
if (target == static_cast<uint32_t>(x11::Atom::STRING) ||
target == utf8_string_atom_)
if (target == x11::Atom::STRING || target == utf8_string_atom_)
NotifyClipboardText(text);
return true;
@ -357,29 +385,33 @@ void XServerClipboard::NotifyClipboardText(const std::string& text) {
callback_.Run(kMimeTypeTextUtf8, data_);
}
void XServerClipboard::RequestSelectionTargets(Atom selection) {
XConvertSelection(connection_->display(), selection, targets_atom_,
targets_atom_, clipboard_window_, x11::CurrentTime);
void XServerClipboard::RequestSelectionTargets(x11::Atom selection) {
connection_->ConvertSelection({clipboard_window_, selection, targets_atom_,
selection_string_atom_,
x11::Time::CurrentTime});
}
void XServerClipboard::RequestSelectionString(Atom selection, Atom target) {
XConvertSelection(connection_->display(), selection, target,
selection_string_atom_, clipboard_window_,
x11::CurrentTime);
void XServerClipboard::RequestSelectionString(x11::Atom selection,
x11::Atom target) {
connection_->ConvertSelection({clipboard_window_, selection, target,
selection_string_atom_,
x11::Time::CurrentTime});
}
void XServerClipboard::AssertSelectionOwnership(Atom selection) {
XSetSelectionOwner(connection_->display(), selection, clipboard_window_,
x11::CurrentTime);
if (XGetSelectionOwner(connection_->display(), selection) ==
clipboard_window_) {
void XServerClipboard::AssertSelectionOwnership(x11::Atom selection) {
connection_->SetSelectionOwner(
{clipboard_window_, selection, x11::Time::CurrentTime});
auto reply = connection_->GetSelectionOwner({selection}).Sync();
auto owner = reply ? reply->owner : x11::Window::None;
if (owner == clipboard_window_) {
selections_owned_.insert(selection);
} else {
LOG(ERROR) << "XSetSelectionOwner failed for selection " << selection;
LOG(ERROR) << "XSetSelectionOwner failed for selection "
<< static_cast<uint32_t>(selection);
}
}
bool XServerClipboard::IsSelectionOwner(Atom selection) {
bool XServerClipboard::IsSelectionOwner(x11::Atom selection) {
return selections_owned_.find(selection) != selections_owned_.end();
}

@ -53,7 +53,7 @@ class XServerClipboard {
private:
// Handlers called by ProcessXEvent() for each event type.
void OnSetSelectionOwnerNotify(Atom selection, Time timestamp);
void OnSetSelectionOwnerNotify(x11::Atom selection, x11::Time timestamp);
void OnPropertyNotify(const x11::PropertyNotifyEvent& event);
void OnSelectionNotify(const x11::SelectionNotifyEvent& event);
void OnSelectionRequest(const x11::SelectionRequestEvent& event);
@ -63,9 +63,11 @@ class XServerClipboard {
// clipboard content. This is done by changing the property |property| of the
// |requestor| window (these values come from the XSelectionRequestEvent).
// |target| must be a string type (STRING or UTF8_STRING).
void SendTargetsResponse(Window requestor, Atom property);
void SendTimestampResponse(Window requestor, Atom property);
void SendStringResponse(Window requestor, Atom property, Atom target);
void SendTargetsResponse(x11::Window requestor, x11::Atom property);
void SendTimestampResponse(x11::Window requestor, x11::Atom property);
void SendStringResponse(x11::Window requestor,
x11::Atom property,
x11::Atom target);
// Called by OnSelectionNotify() when the selection owner has replied to a
// request for information about a selection.
@ -73,10 +75,10 @@ class XServerClipboard {
// |type|, |format| etc are the results from XGetWindowProperty(), or 0 if
// there is no associated data.
void HandleSelectionNotify(const x11::SelectionNotifyEvent& event,
Atom type,
x11::Atom type,
int format,
int item_count,
void* data);
const void* data);
// These methods return true if selection processing is complete, false
// otherwise. They are called from HandleSelectionNotify(), and take the same
@ -84,42 +86,42 @@ class XServerClipboard {
bool HandleSelectionTargetsEvent(const x11::SelectionNotifyEvent& event,
int format,
int item_count,
void* data);
const void* data);
bool HandleSelectionStringEvent(const x11::SelectionNotifyEvent& event,
int format,
int item_count,
void* data);
const void* data);
// Notify the registered callback of new clipboard text.
void NotifyClipboardText(const std::string& text);
// These methods trigger the X server or selection owner to send back an
// event containing the requested information.
void RequestSelectionTargets(Atom selection);
void RequestSelectionString(Atom selection, Atom target);
void RequestSelectionTargets(x11::Atom selection);
void RequestSelectionString(x11::Atom selection, x11::Atom target);
// Assert ownership of the specified |selection|.
void AssertSelectionOwnership(Atom selection);
bool IsSelectionOwner(Atom selection);
void AssertSelectionOwnership(x11::Atom selection);
bool IsSelectionOwner(x11::Atom selection);
// Stores the connection supplied to Init().
x11::Connection* connection_ = nullptr;
// Window through which clipboard events are received, or BadValue if the
// window could not be created.
Window clipboard_window_;
x11::Window clipboard_window_ = x11::Window::None;
// Cached atoms for various strings, initialized during Init().
Atom clipboard_atom_;
Atom large_selection_atom_;
Atom selection_string_atom_;
Atom targets_atom_;
Atom timestamp_atom_;
Atom utf8_string_atom_;
x11::Atom clipboard_atom_ = x11::Atom::None;
x11::Atom large_selection_atom_ = x11::Atom::None;
x11::Atom selection_string_atom_ = x11::Atom::None;
x11::Atom targets_atom_ = x11::Atom::None;
x11::Atom timestamp_atom_ = x11::Atom::None;
x11::Atom utf8_string_atom_ = x11::Atom::None;
// The set of X selections owned by |clipboard_window_| (can be Primary or
// Clipboard or both).
std::set<Atom> selections_owned_;
std::set<x11::Atom> selections_owned_;
// Clipboard content to return to other applications when |clipboard_window_|
// owns a selection.
@ -127,7 +129,7 @@ class XServerClipboard {
// Stores the property to use for large transfers, or None if a large
// transfer is not currently in-progress.
Atom large_selection_property_;
x11::Atom large_selection_property_ = x11::Atom::None;
// Remembers the start time of selection processing, and is set to null when
// processing is complete. This is used to decide whether to begin processing

@ -672,7 +672,7 @@ void XDragDropClient::SendXdndLeave(x11::Window dest_window) {
void XDragDropClient::SendXdndDrop(x11::Window dest_window) {
auto xev = PrepareXdndClientMessage(kXdndDrop, dest_window);
xev.data.data32[2] = x11::CurrentTime;
xev.data.data32[2] = static_cast<uint32_t>(x11::Time::CurrentTime);
SendXClientEvent(dest_window, xev);
}

@ -28,7 +28,7 @@ TestCompositorHostX11::~TestCompositorHostX11() = default;
void TestCompositorHostX11::Show() {
XDisplay* display = gfx::GetXDisplay();
XSetWindowAttributes swa;
swa.override_redirect = x11::True;
swa.override_redirect = true;
window_ = static_cast<x11::Window>(XCreateWindow(
display, XDefaultRootWindow(display), // parent
bounds_.x(), bounds_.y(), bounds_.width(), bounds_.height(),
@ -42,7 +42,7 @@ void TestCompositorHostX11::Show() {
XMapWindow(display, static_cast<uint32_t>(window_));
// Since this window is override-redirect, syncing is sufficient
// to ensure the map is complete.
XSync(display, x11::False);
XSync(display, false);
allocator_.GenerateId();
compositor_.SetAcceleratedWidget(
static_cast<gfx::AcceleratedWidget>(window_));

@ -114,7 +114,7 @@ void KeyboardHookX11::CaptureKeyForDomCode(DomCode dom_code) {
// error handler for debugging purposes but are not used to judge success.
XGrabKey(x_display_, native_key_code, modifier,
static_cast<uint32_t>(x_window_),
/*owner_events=*/x11::False,
/*owner_events=*/false,
/*pointer_mode=*/GrabModeAsync,
/*keyboard_mode=*/GrabModeAsync);
}

@ -376,13 +376,4 @@ inline int XkbBuildCoreState(int m, int g) {
return ((g & 0x3) << 13) | (m & 0xff);
}
// Deprecated.
namespace x11 {
static constexpr unsigned long None = 0L;
static constexpr long CurrentTime = 0L;
static constexpr int False = 0;
static constexpr int True = 1;
static constexpr int Success = 0;
} // namespace x11
#endif // UI_GFX_X_X11_H_

@ -22,7 +22,7 @@ int X11ErrorHandler(Display* display, XErrorEvent* error) {
namespace gfx {
X11ErrorTracker::X11ErrorTracker() {
XSync(GetXDisplay(), x11::False);
XSync(GetXDisplay(), false);
old_handler_ = reinterpret_cast<void*>(XSetErrorHandler(X11ErrorHandler));
g_x11_error_code = 0;
}
@ -32,7 +32,7 @@ X11ErrorTracker::~X11ErrorTracker() {
}
bool X11ErrorTracker::FoundNewError() {
XSync(GetXDisplay(), x11::False);
XSync(GetXDisplay(), false);
unsigned char error = g_x11_error_code;
g_x11_error_code = 0;
return error != 0;

@ -57,10 +57,10 @@ GLXContext CreateContextAttribs(Display* display,
// errors can be generated. To prevent these errors from crashing our process,
// we simply ignore them and only look if the GLXContext was created.
// Sync to ensure any errors generated are processed.
XSync(display, x11::False);
XSync(display, false);
auto old_error_handler = XSetErrorHandler(IgnoreX11Errors);
GLXContext context = glXCreateContextAttribsARB(display, config, share,
x11::True, attribs.data());
GLXContext context =
glXCreateContextAttribsARB(display, config, share, true, attribs.data());
XSetErrorHandler(old_error_handler);
return context;
@ -182,7 +182,7 @@ bool GLContextGLX::Initialize(GLSurface* compatible_surface,
DVLOG(1) << "GLX_ARB_create_context not supported.";
context_ = glXCreateNewContext(
display_, static_cast<GLXFBConfig>(compatible_surface->GetConfig()),
GLX_RGBA_TYPE, share_handle, x11::True);
GLX_RGBA_TYPE, share_handle, true);
if (!context_) {
LOG(ERROR) << "Failed to create GL context with glXCreateNewContext.";
return false;

@ -34,7 +34,7 @@ TEST(GLContextGLXTest, MAYBE_DoNotDestroyOnFailedMakeCurrent) {
XSetWindowAttributes swa;
memset(&swa, 0, sizeof(swa));
swa.background_pixmap = 0;
swa.override_redirect = x11::True;
swa.override_redirect = true;
auto xwindow = static_cast<x11::Window>(XCreateWindow(
xdisplay, XDefaultRootWindow(xdisplay), 0, 0, 10,
10, // x, y, width, height
@ -47,7 +47,7 @@ TEST(GLContextGLXTest, MAYBE_DoNotDestroyOnFailedMakeCurrent) {
XMapWindow(xdisplay, static_cast<uint32_t>(xwindow));
// Since this window is override-redirect, syncing is sufficient
// to ensure the map is complete.
XSync(xdisplay, x11::False);
XSync(xdisplay, false);
GLImageTestSupport::InitializeGL(base::nullopt);
auto surface = gl::InitializeGLSurface(base::MakeRefCounted<GLSurfaceGLXX11>(
@ -64,7 +64,7 @@ TEST(GLContextGLXTest, MAYBE_DoNotDestroyOnFailedMakeCurrent) {
XDestroyWindow(xdisplay, static_cast<uint32_t>(xwindow));
// Since this window is override-redirect, syncing is sufficient
// to ensure the window is destroyed and unmapped.
XSync(xdisplay, x11::False);
XSync(xdisplay, false);
ASSERT_FALSE(error_tracker.FoundNewError());
if (context->MakeCurrent(surface.get())) {
@ -83,7 +83,7 @@ TEST(GLContextGLXTest, MAYBE_DoNotDestroyOnFailedMakeCurrent) {
// not destroyed.
ASSERT_TRUE(context->GetHandle());
surface = nullptr;
XSync(xdisplay, x11::True);
XSync(xdisplay, true);
}
} // namespace gl

@ -281,7 +281,7 @@ class SGIVideoSyncThread : public base::Thread,
DCHECK(task_runner()->BelongsToCurrentThread());
if (!context_) {
context_ = glXCreateNewContext(GetDisplay(), config, GLX_RGBA_TYPE,
nullptr, x11::True);
nullptr, true);
}
LOG_IF(ERROR, !context_) << "video_sync: glXCreateNewContext failed";
}
@ -337,7 +337,7 @@ class SGIVideoSyncProviderThreadShim {
vsync_lock_() {
// This ensures that creation of |parent_window_| has occured when this shim
// is executing in the same thread as the call to create |parent_window_|.
XSync(gfx::GetXDisplay(), x11::False);
XSync(gfx::GetXDisplay(), false);
}
~SGIVideoSyncProviderThreadShim() {

@ -202,11 +202,11 @@ class X11WindowTest : public testing::Test {
// Make X11 synchronous for our display connection. This does not force the
// window manager to behave synchronously.
XSynchronize(gfx::GetXDisplay(), x11::True);
XSynchronize(gfx::GetXDisplay(), true);
}
protected:
void TearDown() override { XSynchronize(gfx::GetXDisplay(), x11::False); }
void TearDown() override { XSynchronize(gfx::GetXDisplay(), false); }
std::unique_ptr<X11Window> CreateX11Window(
PlatformWindowDelegate* delegate,

@ -69,23 +69,18 @@ void DispatchMouseMotionEvent(DesktopWindowTreeHostLinux* desktop_host,
gfx::Rect bounds_in_screen = desktop_host->window()->GetBoundsInScreen();
auto* connection = x11::Connection::Get();
xcb_generic_event_t ge;
memset(&ge, 0, sizeof(ge));
auto* xev = reinterpret_cast<xcb_motion_notify_event_t*>(&ge);
xev->response_type = x11::MotionNotifyEvent::opcode;
xev->event = static_cast<uint32_t>(desktop_host->GetAcceleratedWidget());
xev->root = static_cast<uint32_t>(connection->default_screen().root);
xev->child = 0;
xev->time = x11::CurrentTime;
xev->event_x = point_in_screen.x() - bounds_in_screen.x();
xev->event_y = point_in_screen.y() - bounds_in_screen.y();
xev->root_x = point_in_screen.x();
xev->root_y = point_in_screen.y();
xev->state = 0;
xev->detail = NotifyNormal;
xev->same_screen = x11::True;
x11::MotionNotifyEvent xev{
.detail = x11::Motion::Normal,
.root = connection->default_root(),
.event = static_cast<x11::Window>(desktop_host->GetAcceleratedWidget()),
.root_x = point_in_screen.x(),
.root_y = point_in_screen.y(),
.event_x = point_in_screen.x() - bounds_in_screen.x(),
.event_y = point_in_screen.y() - bounds_in_screen.y(),
.same_screen = true,
};
x11::Event x11_event(&ge, connection);
x11::Event x11_event(xev);
ui::X11EventSource::GetInstance()->ProcessXEvent(&x11_event);
}

@ -117,13 +117,13 @@ class X11TopmostWindowFinderTest : public test::DesktopWidgetTestInteractive {
#endif
// Make X11 synchronous for our display connection. This does not force the
// window manager to behave synchronously.
XSynchronize(xdisplay(), x11::True);
XSynchronize(xdisplay(), true);
DesktopWidgetTestInteractive::SetUp();
}
void TearDown() override {
if (!IsSkipped())
XSynchronize(xdisplay(), x11::False);
XSynchronize(xdisplay(), false);
DesktopWidgetTestInteractive::TearDown();
}
@ -400,7 +400,7 @@ TEST_F(X11TopmostWindowFinderTest, DISABLED_Menu) {
x11::Window root = ui::GetX11RootWindow();
XSetWindowAttributes swa;
swa.override_redirect = x11::True;
swa.override_redirect = true;
x11::Window menu_window = static_cast<x11::Window>(XCreateWindow(
xdisplay(), static_cast<uint32_t>(root), 0, 0, 1, 1,
0, // border width