Commit 9c4e1d64 authored by Tom Anderson's avatar Tom Anderson Committed by Commit Bot

[XProto] Remove usage of all Xlib constants

R=sky
BUG=1066670

Change-Id: Ie60214eede9dc3d7f332d01918ffc9a618ec09b8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2431413
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811393}
parent 2fe1ae1f
...@@ -19,8 +19,9 @@ class VulkanSurfaceX11::ExposeEventForwarder : public ui::XEventDispatcher { ...@@ -19,8 +19,9 @@ class VulkanSurfaceX11::ExposeEventForwarder : public ui::XEventDispatcher {
public: public:
explicit ExposeEventForwarder(VulkanSurfaceX11* surface) : surface_(surface) { explicit ExposeEventForwarder(VulkanSurfaceX11* surface) : surface_(surface) {
if (auto* event_source = ui::X11EventSource::GetInstance()) { if (auto* event_source = ui::X11EventSource::GetInstance()) {
XSelectInput(gfx::GetXDisplay(), static_cast<uint32_t>(surface_->window_), x11::Connection::Get()->ChangeWindowAttributes(
ExposureMask); {.window = static_cast<x11::Window>(surface_->window_),
.event_mask = x11::EventMask::Exposure});
event_source->AddXEventDispatcher(this); event_source->AddXEventDispatcher(this);
} }
} }
......
...@@ -36,8 +36,8 @@ bool FindKeycodeForKeySym(Display* display, ...@@ -36,8 +36,8 @@ bool FindKeycodeForKeySym(Display* display,
for (auto i : kModifiersToTry) { for (auto i : kModifiersToTry) {
int mods = static_cast<int>(i); int mods = static_cast<int>(i);
unsigned long key_sym_with_mods; unsigned long key_sym_with_mods;
if (XkbLookupKeySym(display, found_keycode, mods, if (XkbLookupKeySym(display, found_keycode, mods, nullptr,
nullptr, &key_sym_with_mods) && &key_sym_with_mods) &&
key_sym_with_mods == key_sym) { key_sym_with_mods == key_sym) {
*modifiers = mods; *modifiers = mods;
*keycode = found_keycode; *keycode = found_keycode;
...@@ -105,17 +105,18 @@ bool X11KeyboardImpl::FindKeycode(uint32_t code_point, ...@@ -105,17 +105,18 @@ bool X11KeyboardImpl::FindKeycode(uint32_t code_point,
} }
bool X11KeyboardImpl::ChangeKeyMapping(uint32_t keycode, uint32_t code_point) { bool X11KeyboardImpl::ChangeKeyMapping(uint32_t keycode, uint32_t code_point) {
KeySym sym = NoSymbol; x11::KeySym sym{};
if (code_point > 0) { if (code_point > 0) {
std::string sym_hex = base::StringPrintf("U%x", code_point); std::string sym_hex = base::StringPrintf("U%x", code_point);
sym = XStringToKeysym(sym_hex.c_str()); sym = static_cast<x11::KeySym>(XStringToKeysym(sym_hex.c_str()));
if (sym == NoSymbol) { if (sym == x11::KeySym{}) {
// The server may not support Unicode-to-KeySym translation. // The server may not support Unicode-to-KeySym translation.
return false; return false;
} }
} }
KeySym syms[2]{sym, sym}; // {lower-case, upper-case} KeySym syms[2]{static_cast<KeySym>(sym) /* lower-case */,
static_cast<KeySym>(sym) /* upper-case */};
XChangeKeyboardMapping(display_, keycode, 2, syms, 1); XChangeKeyboardMapping(display_, keycode, 2, syms, 1);
return true; return true;
} }
......
...@@ -271,8 +271,8 @@ ClipboardX11::X11Details::X11Details() ...@@ -271,8 +271,8 @@ ClipboardX11::X11Details::X11Details()
primary_owner_(connection_, x_window_, x11::Atom::PRIMARY) { primary_owner_(connection_, x_window_, x11::Atom::PRIMARY) {
SetStringProperty(x_window_, x11::Atom::WM_NAME, x11::Atom::STRING, SetStringProperty(x_window_, x11::Atom::WM_NAME, x11::Atom::STRING,
"Chromium clipboard"); "Chromium clipboard");
x_window_events_ = x_window_events_ = std::make_unique<XScopedEventSelector>(
std::make_unique<XScopedEventSelector>(x_window_, PropertyChangeMask); x_window_, x11::EventMask::PropertyChange);
if (X11EventSource::GetInstance()) if (X11EventSource::GetInstance())
X11EventSource::GetInstance()->AddXEventDispatcher(this); X11EventSource::GetInstance()->AddXEventDispatcher(this);
......
...@@ -232,7 +232,8 @@ bool SelectionOwner::ProcessTarget(x11::Atom target, ...@@ -232,7 +232,8 @@ bool SelectionOwner::ProcessTarget(x11::Atom target,
base::TimeDelta::FromMilliseconds(kIncrementalTransferTimeoutMs); base::TimeDelta::FromMilliseconds(kIncrementalTransferTimeoutMs);
incremental_transfers_.emplace_back( incremental_transfers_.emplace_back(
requestor, target, property, requestor, target, property,
std::make_unique<XScopedEventSelector>(requestor, PropertyChangeMask), std::make_unique<XScopedEventSelector>(
requestor, x11::EventMask::PropertyChange),
it->second, 0, timeout); it->second, 0, timeout);
// Start a timer to abort the data transfer in case that the selection // Start a timer to abort the data transfer in case that the selection
......
...@@ -22,8 +22,8 @@ X11PropertyChangeWaiter::X11PropertyChangeWaiter(x11::Window window, ...@@ -22,8 +22,8 @@ X11PropertyChangeWaiter::X11PropertyChangeWaiter(x11::Window window,
: x_window_(window), property_(property), wait_(true) { : x_window_(window), property_(property), wait_(true) {
// Ensure that we are listening to PropertyNotify events for |window|. This // Ensure that we are listening to PropertyNotify events for |window|. This
// is not the case for windows which were not created by X11Window. // is not the case for windows which were not created by X11Window.
x_window_events_ = x_window_events_ = std::make_unique<XScopedEventSelector>(
std::make_unique<XScopedEventSelector>(x_window_, PropertyChangeMask); x_window_, x11::EventMask::PropertyChange);
// Override the dispatcher so that we get events before X11Window does. We // Override the dispatcher so that we get events before X11Window does. We
// must do this because X11Window stops propagation. // must do this because X11Window stops propagation.
......
...@@ -37,7 +37,8 @@ X11MenuRegistrar::X11MenuRegistrar() { ...@@ -37,7 +37,8 @@ X11MenuRegistrar::X11MenuRegistrar() {
ui::X11EventSource::GetInstance()->AddXEventDispatcher(this); ui::X11EventSource::GetInstance()->AddXEventDispatcher(this);
x_root_window_events_ = std::make_unique<ui::XScopedEventSelector>( x_root_window_events_ = std::make_unique<ui::XScopedEventSelector>(
ui::GetX11RootWindow(), StructureNotifyMask | SubstructureNotifyMask); ui::GetX11RootWindow(),
x11::EventMask::StructureNotify | x11::EventMask::SubstructureNotify);
} }
X11MenuRegistrar::~X11MenuRegistrar() { X11MenuRegistrar::~X11MenuRegistrar() {
......
...@@ -259,9 +259,10 @@ void X11WholeScreenMoveLoop::CreateDragInputWindow( ...@@ -259,9 +259,10 @@ void X11WholeScreenMoveLoop::CreateDragInputWindow(
.c_class = x11::WindowClass::InputOnly, .c_class = x11::WindowClass::InputOnly,
.override_redirect = x11::Bool32(true), .override_redirect = x11::Bool32(true),
}); });
uint32_t event_mask = ButtonPressMask | ButtonReleaseMask | auto event_mask =
PointerMotionMask | KeyPressMask | KeyReleaseMask | x11::EventMask::ButtonPress | x11::EventMask::ButtonRelease |
StructureNotifyMask; x11::EventMask::PointerMotion | x11::EventMask::KeyPress |
x11::EventMask::KeyRelease | x11::EventMask::StructureNotify;
grab_input_window_events_ = std::make_unique<ui::XScopedEventSelector>( grab_input_window_events_ = std::make_unique<ui::XScopedEventSelector>(
grab_input_window_, event_mask); grab_input_window_, event_mask);
connection->MapWindow({grab_input_window_}); connection->MapWindow({grab_input_window_});
......
...@@ -290,11 +290,13 @@ void XWindow::Init(const Configuration& config) { ...@@ -290,11 +290,13 @@ void XWindow::Init(const Configuration& config) {
// TODO(erg): Maybe need to set a ViewProp here like in RWHL::RWHL(). // TODO(erg): Maybe need to set a ViewProp here like in RWHL::RWHL().
long event_mask = ButtonPressMask | ButtonReleaseMask | FocusChangeMask | auto event_mask =
KeyPressMask | KeyReleaseMask | EnterWindowMask | x11::EventMask::ButtonPress | x11::EventMask::ButtonRelease |
LeaveWindowMask | ExposureMask | VisibilityChangeMask | x11::EventMask::FocusChange | x11::EventMask::KeyPress |
StructureNotifyMask | PropertyChangeMask | x11::EventMask::KeyRelease | x11::EventMask::EnterWindow |
PointerMotionMask; x11::EventMask::LeaveWindow | x11::EventMask::Exposure |
x11::EventMask::VisibilityChange | x11::EventMask::StructureNotify |
x11::EventMask::PropertyChange | x11::EventMask::PointerMotion;
xwindow_events_ = xwindow_events_ =
std::make_unique<XScopedEventSelector>(xwindow_, event_mask); std::make_unique<XScopedEventSelector>(xwindow_, event_mask);
connection_->Flush(); connection_->Flush();
......
...@@ -34,7 +34,7 @@ X11WorkspaceHandler::X11WorkspaceHandler(Delegate* delegate) ...@@ -34,7 +34,7 @@ X11WorkspaceHandler::X11WorkspaceHandler(Delegate* delegate)
ui::X11EventSource::GetInstance()->AddXEventDispatcher(this); ui::X11EventSource::GetInstance()->AddXEventDispatcher(this);
x_root_window_events_ = std::make_unique<ui::XScopedEventSelector>( x_root_window_events_ = std::make_unique<ui::XScopedEventSelector>(
x_root_window_, PropertyChangeMask); x_root_window_, x11::EventMask::PropertyChange);
} }
X11WorkspaceHandler::~X11WorkspaceHandler() { X11WorkspaceHandler::~X11WorkspaceHandler() {
......
...@@ -40,7 +40,7 @@ void TestCompositorHostX11::Show() { ...@@ -40,7 +40,7 @@ void TestCompositorHostX11::Show() {
.override_redirect = x11::Bool32(true), .override_redirect = x11::Bool32(true),
}); });
window_events_ = window_events_ =
std::make_unique<XScopedEventSelector>(window_, ExposureMask); std::make_unique<XScopedEventSelector>(window_, x11::EventMask::Exposure);
connection->MapWindow({window_}); connection->MapWindow({window_});
// Since this window is override-redirect, syncing is sufficient // Since this window is override-redirect, syncing is sufficient
// to ensure the map is complete. // to ensure the map is complete.
......
...@@ -658,7 +658,7 @@ KeyboardCode KeyboardCodeFromXKeyEvent(const x11::Event& xev) { ...@@ -658,7 +658,7 @@ KeyboardCode KeyboardCodeFromXKeyEvent(const x11::Event& xev) {
if (keycode != VKEY_UNKNOWN) if (keycode != VKEY_UNKNOWN)
return keycode; return keycode;
KeySym keysym_shift = NoSymbol; KeySym keysym_shift{};
modifiers |= static_cast<int>(x11::KeyButMask::Shift); modifiers |= static_cast<int>(x11::KeyButMask::Shift);
keysym_shift = TranslateKey(xkeycode, modifiers); keysym_shift = TranslateKey(xkeycode, modifiers);
MAP2 key2 = {keysym & 0xFFFF, xkeycode, keysym_shift & 0xFFFF, 0}; MAP2 key2 = {keysym & 0xFFFF, xkeycode, keysym_shift & 0xFFFF, 0};
...@@ -666,7 +666,7 @@ KeyboardCode KeyboardCodeFromXKeyEvent(const x11::Event& xev) { ...@@ -666,7 +666,7 @@ KeyboardCode KeyboardCodeFromXKeyEvent(const x11::Event& xev) {
if (keycode != VKEY_UNKNOWN) if (keycode != VKEY_UNKNOWN)
return keycode; return keycode;
KeySym keysym_altgr = NoSymbol; KeySym keysym_altgr{};
modifiers &= ~static_cast<int>(x11::KeyButMask::Shift); modifiers &= ~static_cast<int>(x11::KeyButMask::Shift);
modifiers |= static_cast<int>(x11::KeyButMask::Mod1); modifiers |= static_cast<int>(x11::KeyButMask::Mod1);
keysym_altgr = TranslateKey(xkeycode, modifiers); keysym_altgr = TranslateKey(xkeycode, modifiers);
......
...@@ -177,7 +177,7 @@ x11::Time X11EventSource::GetCurrentServerTime() { ...@@ -177,7 +177,7 @@ x11::Time X11EventSource::GetCurrentServerTime() {
}); });
dummy_atom_ = gfx::GetAtom("CHROMIUM_TIMESTAMP"); dummy_atom_ = gfx::GetAtom("CHROMIUM_TIMESTAMP");
dummy_window_events_ = std::make_unique<XScopedEventSelector>( dummy_window_events_ = std::make_unique<XScopedEventSelector>(
dummy_window_, PropertyChangeMask); dummy_window_, x11::EventMask::PropertyChange);
dummy_initialized_ = true; dummy_initialized_ = true;
} }
......
...@@ -14,7 +14,7 @@ namespace ui { ...@@ -14,7 +14,7 @@ namespace ui {
namespace { namespace {
// Asks the X server to set |window|'s event mask to |new_mask|. // Asks the X server to set |window|'s event mask to |new_mask|.
void SetEventMask(x11::Window window, uint32_t new_mask) { void SetEventMask(x11::Window window, x11::EventMask new_mask) {
auto* connection = x11::Connection::Get(); auto* connection = x11::Connection::Get();
// Window |window| may already be destroyed at this point, so the // Window |window| may already be destroyed at this point, so the
// change_attributes request may give a BadWindow error. In this case, just // change_attributes request may give a BadWindow error. In this case, just
...@@ -29,7 +29,7 @@ void SetEventMask(x11::Window window, uint32_t new_mask) { ...@@ -29,7 +29,7 @@ void SetEventMask(x11::Window window, uint32_t new_mask) {
} // anonymous namespace } // anonymous namespace
XScopedEventSelector::XScopedEventSelector(x11::Window window, XScopedEventSelector::XScopedEventSelector(x11::Window window,
uint32_t event_mask) x11::EventMask event_mask)
: window_(window), : window_(window),
event_mask_(event_mask), event_mask_(event_mask),
event_manager_( event_manager_(
...@@ -53,27 +53,27 @@ class XWindowEventManager::MultiMask { ...@@ -53,27 +53,27 @@ class XWindowEventManager::MultiMask {
~MultiMask() = default; ~MultiMask() = default;
void AddMask(uint32_t mask) { void AddMask(x11::EventMask mask) {
for (int i = 0; i < kMaskSize; i++) { for (int i = 0; i < kMaskSize; i++) {
if (mask & (1 << i)) if (static_cast<uint32_t>(mask) & (1 << i))
mask_bits_[i]++; mask_bits_[i]++;
} }
} }
void RemoveMask(uint32_t mask) { void RemoveMask(x11::EventMask mask) {
for (int i = 0; i < kMaskSize; i++) { for (int i = 0; i < kMaskSize; i++) {
if (mask & (1 << i)) { if (static_cast<uint32_t>(mask) & (1 << i)) {
DCHECK(mask_bits_[i]); DCHECK(mask_bits_[i]);
mask_bits_[i]--; mask_bits_[i]--;
} }
} }
} }
uint32_t ToMask() const { x11::EventMask ToMask() const {
uint32_t mask = NoEventMask; x11::EventMask mask = x11::EventMask::NoEvent;
for (int i = 0; i < kMaskSize; i++) { for (int i = 0; i < kMaskSize; i++) {
if (mask_bits_[i]) if (mask_bits_[i])
mask |= (1 << i); mask = mask | static_cast<x11::EventMask>(1 << i);
} }
return mask; return mask;
} }
...@@ -91,37 +91,37 @@ XWindowEventManager::XWindowEventManager() = default; ...@@ -91,37 +91,37 @@ XWindowEventManager::XWindowEventManager() = default;
XWindowEventManager::~XWindowEventManager() { XWindowEventManager::~XWindowEventManager() {
// Clear events still requested by not-yet-deleted XScopedEventSelectors. // Clear events still requested by not-yet-deleted XScopedEventSelectors.
for (const auto& mask_pair : mask_map_) for (const auto& mask_pair : mask_map_)
SetEventMask(mask_pair.first, NoEventMask); SetEventMask(mask_pair.first, x11::EventMask::NoEvent);
} }
void XWindowEventManager::SelectEvents(x11::Window window, void XWindowEventManager::SelectEvents(x11::Window window,
uint32_t event_mask) { x11::EventMask event_mask) {
std::unique_ptr<MultiMask>& mask = mask_map_[window]; std::unique_ptr<MultiMask>& mask = mask_map_[window];
if (!mask) if (!mask)
mask = std::make_unique<MultiMask>(); mask = std::make_unique<MultiMask>();
uint32_t old_mask = mask_map_[window]->ToMask(); x11::EventMask old_mask = mask_map_[window]->ToMask();
mask->AddMask(event_mask); mask->AddMask(event_mask);
AfterMaskChanged(window, old_mask); AfterMaskChanged(window, old_mask);
} }
void XWindowEventManager::DeselectEvents(x11::Window window, void XWindowEventManager::DeselectEvents(x11::Window window,
uint32_t event_mask) { x11::EventMask event_mask) {
DCHECK(mask_map_.find(window) != mask_map_.end()); DCHECK(mask_map_.find(window) != mask_map_.end());
std::unique_ptr<MultiMask>& mask = mask_map_[window]; std::unique_ptr<MultiMask>& mask = mask_map_[window];
uint32_t old_mask = mask->ToMask(); x11::EventMask old_mask = mask->ToMask();
mask->RemoveMask(event_mask); mask->RemoveMask(event_mask);
AfterMaskChanged(window, old_mask); AfterMaskChanged(window, old_mask);
} }
void XWindowEventManager::AfterMaskChanged(x11::Window window, void XWindowEventManager::AfterMaskChanged(x11::Window window,
uint32_t old_mask) { x11::EventMask old_mask) {
uint32_t new_mask = mask_map_[window]->ToMask(); x11::EventMask new_mask = mask_map_[window]->ToMask();
if (new_mask == old_mask) if (new_mask == old_mask)
return; return;
SetEventMask(window, new_mask); SetEventMask(window, new_mask);
if (new_mask == NoEventMask) if (new_mask == x11::EventMask::NoEvent)
mask_map_.erase(window); mask_map_.erase(window);
} }
......
...@@ -26,12 +26,12 @@ class XWindowEventManager; ...@@ -26,12 +26,12 @@ class XWindowEventManager;
// this object's lifetime. // this object's lifetime.
class EVENTS_X_EXPORT XScopedEventSelector { class EVENTS_X_EXPORT XScopedEventSelector {
public: public:
XScopedEventSelector(x11::Window window, uint32_t event_mask); XScopedEventSelector(x11::Window window, x11::EventMask event_mask);
~XScopedEventSelector(); ~XScopedEventSelector();
private: private:
x11::Window window_; x11::Window window_;
uint32_t event_mask_; x11::EventMask event_mask_;
base::WeakPtr<XWindowEventManager> event_manager_; base::WeakPtr<XWindowEventManager> event_manager_;
DISALLOW_COPY_AND_ASSIGN(XScopedEventSelector); DISALLOW_COPY_AND_ASSIGN(XScopedEventSelector);
...@@ -52,16 +52,16 @@ class XWindowEventManager { ...@@ -52,16 +52,16 @@ class XWindowEventManager {
~XWindowEventManager(); ~XWindowEventManager();
// Guarantees that events in |event_mask| will be reported to Chrome. // Guarantees that events in |event_mask| will be reported to Chrome.
void SelectEvents(x11::Window window, uint32_t event_mask); void SelectEvents(x11::Window window, x11::EventMask event_mask);
// Deselects events on |event_mask|. Chrome will stop receiving events for // Deselects events on |event_mask|. Chrome will stop receiving events for
// any set bit in |event_mask| only if no other client has selected that bit. // any set bit in |event_mask| only if no other client has selected that bit.
void DeselectEvents(x11::Window window, uint32_t event_mask); void DeselectEvents(x11::Window window, x11::EventMask event_mask);
// Helper method called by SelectEvents and DeselectEvents whenever the mask // Helper method called by SelectEvents and DeselectEvents whenever the mask
// corresponding to |window| might have changed. Calls SetEventMask if // corresponding to |window| might have changed. Calls SetEventMask if
// necessary. // necessary.
void AfterMaskChanged(x11::Window window, uint32_t old_mask); void AfterMaskChanged(x11::Window window, x11::EventMask old_mask);
std::map<x11::Window, std::unique_ptr<MultiMask>> mask_map_; std::map<x11::Window, std::unique_ptr<MultiMask>> mask_map_;
......
...@@ -648,7 +648,8 @@ KeySym Connection::TranslateKey(uint32_t key, unsigned int modifiers) const { ...@@ -648,7 +648,8 @@ KeySym Connection::TranslateKey(uint32_t key, unsigned int modifiers) const {
KeySym lower; KeySym lower;
KeySym upper; KeySym upper;
if (!(modifiers & kShiftMask) && if (!(modifiers & kShiftMask) &&
(!(modifiers & kLockMask) || (lock_meaning_ == NoSymbol))) { (!(modifiers & kLockMask) ||
(static_cast<x11::KeySym>(lock_meaning_) == kNoSymbol))) {
if ((n_keysyms == 1) || (syms[1] == kNoSymbol)) { if ((n_keysyms == 1) || (syms[1] == kNoSymbol)) {
ConvertCase(syms[0], &lower, &upper); ConvertCase(syms[0], &lower, &upper);
return lower; return lower;
......
...@@ -17,99 +17,6 @@ ...@@ -17,99 +17,6 @@
extern "C" { extern "C" {
static constexpr auto GrabModeAsync = 1;
static constexpr auto NoEventMask = 0L;
static constexpr auto KeyPressMask = 1L << 0;
static constexpr auto KeyReleaseMask = 1L << 1;
static constexpr auto ButtonPressMask = 1L << 2;
static constexpr auto ButtonReleaseMask = 1L << 3;
static constexpr auto EnterWindowMask = 1L << 4;
static constexpr auto LeaveWindowMask = 1L << 5;
static constexpr auto PointerMotionMask = 1L << 6;
static constexpr auto PointerMotionHintMask = 1L << 7;
static constexpr auto Button1MotionMask = 1L << 8;
static constexpr auto Button2MotionMask = 1L << 9;
static constexpr auto Button3MotionMask = 1L << 10;
static constexpr auto Button4MotionMask = 1L << 11;
static constexpr auto Button5MotionMask = 1L << 12;
static constexpr auto ButtonMotionMask = 1L << 13;
static constexpr auto KeymapStateMask = 1L << 14;
static constexpr auto ExposureMask = 1L << 15;
static constexpr auto VisibilityChangeMask = 1L << 16;
static constexpr auto StructureNotifyMask = 1L << 17;
static constexpr auto ResizeRedirectMask = 1L << 18;
static constexpr auto SubstructureNotifyMask = 1L << 19;
static constexpr auto SubstructureRedirectMask = 1L << 20;
static constexpr auto FocusChangeMask = 1L << 21;
static constexpr auto PropertyChangeMask = 1L << 22;
static constexpr auto ColormapChangeMask = 1L << 23;
static constexpr auto OwnerGrabButtonMask = 1L << 24;
static constexpr auto CWBackPixmap = 1L << 0;
static constexpr auto CWBackPixel = 1L << 1;
static constexpr auto CWBorderPixmap = 1L << 2;
static constexpr auto CWBorderPixel = 1L << 3;
static constexpr auto CWBitGravity = 1L << 4;
static constexpr auto CWWinGravity = 1L << 5;
static constexpr auto CWBackingStore = 1L << 6;
static constexpr auto CWBackingPlanes = 1L << 7;
static constexpr auto CWBackingPixel = 1L << 8;
static constexpr auto CWOverrideRedirect = 1L << 9;
static constexpr auto CWSaveUnder = 1L << 10;
static constexpr auto CWEventMask = 1L << 11;
static constexpr auto CWDontPropagate = 1L << 12;
static constexpr auto CWColormap = 1L << 13;
static constexpr auto CWCursor = 1L << 14;
static constexpr auto ForgetGravity = 0;
static constexpr auto NorthWestGravity = 1;
static constexpr auto NorthGravity = 2;
static constexpr auto NorthEastGravity = 3;
static constexpr auto WestGravity = 4;
static constexpr auto CenterGravity = 5;
static constexpr auto EastGravity = 6;
static constexpr auto SouthWestGravity = 7;
static constexpr auto SouthGravity = 8;
static constexpr auto SouthEastGravity = 9;
static constexpr auto StaticGravity = 10;
static constexpr auto Button1Mask = 1 << 8;
static constexpr auto Button2Mask = 1 << 9;
static constexpr auto Button3Mask = 1 << 10;
static constexpr auto Button4Mask = 1 << 11;
static constexpr auto Button5Mask = 1 << 12;
static constexpr auto CWX = 1 << 0;
static constexpr auto CWY = 1 << 1;
static constexpr auto CWWidth = 1 << 2;
static constexpr auto CWHeight = 1 << 3;
static constexpr auto CWBorderWidth = 1 << 4;
static constexpr auto CWSibling = 1 << 5;
static constexpr auto CWStackMode = 1 << 6;
static constexpr auto NotifyNormal = 0;
static constexpr auto NotifyGrab = 1;
static constexpr auto NotifyUngrab = 2;
static constexpr auto NotifyWhileGrabbed = 3;
static constexpr auto NotifyAncestor = 0;
static constexpr auto NotifyVirtual = 1;
static constexpr auto NotifyInferior = 2;
static constexpr auto NotifyNonlinear = 3;
static constexpr auto NotifyNonlinearVirtual = 4;
static constexpr auto NotifyPointer = 5;
static constexpr auto NotifyPointerRoot = 6;
static constexpr auto NotifyDetailNone = 7;
static constexpr auto PropModeReplace = 0;
static constexpr auto PropModePrepend = 1;
static constexpr auto PropModeAppend = 2;
static constexpr auto AnyPropertyType = 0L;
static constexpr auto NoSymbol = 0L;
using Status = int; using Status = int;
using Bool = int; using Bool = int;
using XID = unsigned long; using XID = unsigned long;
...@@ -163,15 +70,6 @@ using XSetWindowAttributes = struct { ...@@ -163,15 +70,6 @@ using XSetWindowAttributes = struct {
Cursor cursor; Cursor cursor;
}; };
using XWindowChanges = struct {
int x, y;
int width, height;
int border_width;
Window sibling;
int stack_mode;
};
using XModifierKeymap = struct { using XModifierKeymap = struct {
int max_keypermod; int max_keypermod;
KeyCode* modifiermap; KeyCode* modifiermap;
...@@ -216,7 +114,6 @@ int XUngrabServer(Display*); ...@@ -216,7 +114,6 @@ int XUngrabServer(Display*);
unsigned long XBlackPixel(Display*, int); unsigned long XBlackPixel(Display*, int);
int XStoreName(Display*, Window, const char*); int XStoreName(Display*, Window, const char*);
Status XIconifyWindow(Display*, Window, int); Status XIconifyWindow(Display*, Window, int);
int XConfigureWindow(Display*, Window, unsigned int, XWindowChanges*);
int XConvertSelection(Display*, Atom, Atom, Atom, Window, Time); int XConvertSelection(Display*, Atom, Atom, Atom, Window, Time);
Window XGetSelectionOwner(Display*, Atom); Window XGetSelectionOwner(Display*, Atom);
int XSetSelectionOwner(Display*, Atom, Window, Time); int XSetSelectionOwner(Display*, Atom, Window, Time);
......
...@@ -21,8 +21,9 @@ GLSurfaceGLXX11::~GLSurfaceGLXX11() { ...@@ -21,8 +21,9 @@ GLSurfaceGLXX11::~GLSurfaceGLXX11() {
void GLSurfaceGLXX11::RegisterEvents() { void GLSurfaceGLXX11::RegisterEvents() {
// Can be null in tests, when we don't care about Exposes. // Can be null in tests, when we don't care about Exposes.
if (X11EventSource::HasInstance()) { if (X11EventSource::HasInstance()) {
XSelectInput(gfx::GetXDisplay(), static_cast<uint32_t>(window()), x11::Connection::Get()->ChangeWindowAttributes(
ExposureMask); {.window = static_cast<x11::Window>(window()),
.event_mask = x11::EventMask::Exposure});
X11EventSource::GetInstance()->AddXEventDispatcher(this); X11EventSource::GetInstance()->AddXEventDispatcher(this);
} }
} }
......
...@@ -165,12 +165,10 @@ TEST(XEventTranslationTest, ChangedMouseButtonFlags) { ...@@ -165,12 +165,10 @@ TEST(XEventTranslationTest, ChangedMouseButtonFlags) {
EXPECT_EQ(0, mouseev2->changed_button_flags()); EXPECT_EQ(0, mouseev2->changed_button_flags());
// Taking in a EnterNotify XEvent // Taking in a EnterNotify XEvent
xcb_generic_event_t ge; x11::Event enter_event(x11::CrossingEvent{
memset(&ge, 0, sizeof(ge)); .opcode = x11::CrossingEvent::EnterNotify,
auto* enter = reinterpret_cast<xcb_enter_notify_event_t*>(&ge); .detail = x11::NotifyDetail::Virtual,
enter->response_type = x11::CrossingEvent::EnterNotify; });
enter->detail = NotifyVirtual;
x11::Event enter_event(&ge, x11::Connection::Get());
auto mouseev3 = ui::BuildMouseEventFromXEvent(enter_event); auto mouseev3 = ui::BuildMouseEventFromXEvent(enter_event);
EXPECT_TRUE(mouseev3); EXPECT_TRUE(mouseev3);
......
...@@ -364,7 +364,7 @@ TEST_F(X11WindowTest, WindowManagerTogglesFullscreen) { ...@@ -364,7 +364,7 @@ TEST_F(X11WindowTest, WindowManagerTogglesFullscreen) {
if (!WmSupportsHint(gfx::GetAtom("_NET_WM_STATE_FULLSCREEN"))) if (!WmSupportsHint(gfx::GetAtom("_NET_WM_STATE_FULLSCREEN")))
return; return;
Display* display = gfx::GetXDisplay(); auto* connection = x11::Connection::Get();
TestPlatformWindowDelegate delegate; TestPlatformWindowDelegate delegate;
ShapedX11ExtensionDelegate x11_extension_delegate; ShapedX11ExtensionDelegate x11_extension_delegate;
...@@ -407,11 +407,11 @@ TEST_F(X11WindowTest, WindowManagerTogglesFullscreen) { ...@@ -407,11 +407,11 @@ TEST_F(X11WindowTest, WindowManagerTogglesFullscreen) {
// fullscreen mode and ensure bounds are tracked correctly. // fullscreen mode and ensure bounds are tracked correctly.
initial_bounds.set_size({400, 400}); initial_bounds.set_size({400, 400});
{ {
XWindowChanges changes = {0}; connection->ConfigureWindow({
changes.width = initial_bounds.width(); .window = x11_window,
changes.height = initial_bounds.height(); .width = initial_bounds.width(),
XConfigureWindow(display, static_cast<uint32_t>(x11_window), .height = initial_bounds.height(),
CWHeight | CWWidth, &changes); });
// Ensure that the task which is posted when a window is resized is run. // Ensure that the task which is posted when a window is resized is run.
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
} }
......
...@@ -883,8 +883,8 @@ void X11Window::UpdateCursor( ...@@ -883,8 +883,8 @@ void X11Window::UpdateCursor(
} }
void X11Window::OnBeginForeignDrag(x11::Window window) { void X11Window::OnBeginForeignDrag(x11::Window window) {
source_window_events_ = source_window_events_ = std::make_unique<ui::XScopedEventSelector>(
std::make_unique<ui::XScopedEventSelector>(window, PropertyChangeMask); window, x11::EventMask::PropertyChange);
} }
void X11Window::OnEndForeignDrag() { void X11Window::OnEndForeignDrag() {
......
...@@ -162,13 +162,13 @@ class X11TopmostWindowFinderTest : public test::DesktopWidgetTestInteractive { ...@@ -162,13 +162,13 @@ class X11TopmostWindowFinderTest : public test::DesktopWidgetTestInteractive {
void ShowAndSetXWindowBounds(x11::Window window, const gfx::Rect& bounds) { void ShowAndSetXWindowBounds(x11::Window window, const gfx::Rect& bounds) {
XMapWindow(xdisplay(), static_cast<uint32_t>(window)); XMapWindow(xdisplay(), static_cast<uint32_t>(window));
XWindowChanges changes = {0}; connection()->ConfigureWindow({
changes.x = bounds.x(); .window = window,
changes.y = bounds.y(); .x = bounds.x(),
changes.width = bounds.width(); .y = bounds.y(),
changes.height = bounds.height(); .width = bounds.width(),
XConfigureWindow(xdisplay(), static_cast<uint32_t>(window), .height = bounds.height(),
CWX | CWY | CWWidth | CWHeight, &changes); });
} }
x11::Connection* connection() { return x11::Connection::Get(); } x11::Connection* connection() { return x11::Connection::Get(); }
......
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