Commit 2a460cca authored by Tom Anderson's avatar Tom Anderson Committed by Commit Bot

[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: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807165}
parent faa1a22b
......@@ -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;
......
This diff is collapsed.
......@@ -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::Event x11_event(&ge, connection);
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(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
......
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