Commit c0a7f167 authored by Maksim Sisov's avatar Maksim Sisov Committed by Commit Bot

Replace X11 includes in //ui/platform_window with ui/gfx/x/x11.h

X11 header files are infamous for creating macros with common
names such as None, True, False, Status, Bool, ...

Use a wrapper header ui/gfx/x/x11.h to make our life easier.

Bug: 782184
Change-Id: I88e1093b9e3a8195395a23f0fd8291613586972f
Reviewed-on: https://chromium-review.googlesource.com/809047Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Cr-Commit-Position: refs/heads/master@{#521759}
parent e62d46f6
...@@ -4,13 +4,11 @@ ...@@ -4,13 +4,11 @@
#include "ui/platform_window/x11/x11_cursor_ozone.h" #include "ui/platform_window/x11/x11_cursor_ozone.h"
#include <X11/Xcursor/Xcursor.h>
#include <X11/Xlib.h>
#include "base/logging.h" #include "base/logging.h"
#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/x/x11_util.h" #include "ui/base/x/x11_util.h"
#include "ui/gfx/geometry/point.h" #include "ui/gfx/geometry/point.h"
#include "ui/gfx/x/x11.h"
namespace ui { namespace ui {
......
...@@ -5,13 +5,12 @@ ...@@ -5,13 +5,12 @@
#ifndef UI_PLATFORM_WINDOW_X11_X11_CURSOR_OZONE_H_ #ifndef UI_PLATFORM_WINDOW_X11_X11_CURSOR_OZONE_H_
#define UI_PLATFORM_WINDOW_X11_X11_CURSOR_OZONE_H_ #define UI_PLATFORM_WINDOW_X11_X11_CURSOR_OZONE_H_
#include <X11/X.h>
#include <vector> #include <vector>
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "ui/base/cursor/cursor.h" #include "ui/base/cursor/cursor.h"
#include "ui/gfx/x/x11.h"
#include "ui/platform_window/x11/x11_window_export.h" #include "ui/platform_window/x11/x11_window_export.h"
class SkBitmap; class SkBitmap;
...@@ -43,7 +42,7 @@ class X11_WINDOW_EXPORT X11CursorOzone ...@@ -43,7 +42,7 @@ class X11_WINDOW_EXPORT X11CursorOzone
X11CursorOzone(); X11CursorOzone();
~X11CursorOzone(); ~X11CursorOzone();
::Cursor xcursor_ = None; ::Cursor xcursor_ = x11::None;
DISALLOW_COPY_AND_ASSIGN(X11CursorOzone); DISALLOW_COPY_AND_ASSIGN(X11CursorOzone);
}; };
......
...@@ -4,15 +4,12 @@ ...@@ -4,15 +4,12 @@
#include "ui/platform_window/x11/x11_window.h" #include "ui/platform_window/x11/x11_window.h"
#include <X11/extensions/XInput2.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "ui/events/devices/x11/touch_factory_x11.h" #include "ui/events/devices/x11/touch_factory_x11.h"
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/events/event_utils.h" #include "ui/events/event_utils.h"
#include "ui/events/platform/platform_event_source.h" #include "ui/events/platform/platform_event_source.h"
#include "ui/events/platform/x11/x11_event_source.h" #include "ui/events/platform/x11/x11_event_source.h"
#include "ui/gfx/x/x11.h"
#include "ui/platform_window/platform_window_delegate.h" #include "ui/platform_window/platform_window_delegate.h"
namespace ui { namespace ui {
......
...@@ -4,11 +4,6 @@ ...@@ -4,11 +4,6 @@
#include "ui/platform_window/x11/x11_window_base.h" #include "ui/platform_window/x11/x11_window_base.h"
#include <X11/extensions/XInput2.h>
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <string> #include <string>
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
...@@ -40,7 +35,7 @@ X11WindowBase::X11WindowBase(PlatformWindowDelegate* delegate, ...@@ -40,7 +35,7 @@ X11WindowBase::X11WindowBase(PlatformWindowDelegate* delegate,
const gfx::Rect& bounds) const gfx::Rect& bounds)
: delegate_(delegate), : delegate_(delegate),
xdisplay_(gfx::GetXDisplay()), xdisplay_(gfx::GetXDisplay()),
xwindow_(None), xwindow_(x11::None),
xroot_window_(DefaultRootWindow(xdisplay_)), xroot_window_(DefaultRootWindow(xdisplay_)),
bounds_(bounds) { bounds_(bounds) {
DCHECK(delegate_); DCHECK(delegate_);
...@@ -51,13 +46,13 @@ X11WindowBase::~X11WindowBase() { ...@@ -51,13 +46,13 @@ X11WindowBase::~X11WindowBase() {
} }
void X11WindowBase::Destroy() { void X11WindowBase::Destroy() {
if (xwindow_ == None) if (xwindow_ == x11::None)
return; return;
// Stop processing events. // Stop processing events.
XID xwindow = xwindow_; XID xwindow = xwindow_;
XDisplay* xdisplay = xdisplay_; XDisplay* xdisplay = xdisplay_;
xwindow_ = None; xwindow_ = x11::None;
delegate_->OnClosed(); delegate_->OnClosed();
// |this| might be deleted because of the above call. // |this| might be deleted because of the above call.
...@@ -69,7 +64,7 @@ void X11WindowBase::Create() { ...@@ -69,7 +64,7 @@ void X11WindowBase::Create() {
XSetWindowAttributes swa; XSetWindowAttributes swa;
memset(&swa, 0, sizeof(swa)); memset(&swa, 0, sizeof(swa));
swa.background_pixmap = None; swa.background_pixmap = x11::None;
swa.bit_gravity = NorthWestGravity; swa.bit_gravity = NorthWestGravity;
swa.override_redirect = UseTestConfigForPlatformWindows(); swa.override_redirect = UseTestConfigForPlatformWindows();
xwindow_ = xwindow_ =
...@@ -146,7 +141,7 @@ void X11WindowBase::Create() { ...@@ -146,7 +141,7 @@ void X11WindowBase::Create() {
void X11WindowBase::Show() { void X11WindowBase::Show() {
if (window_mapped_) if (window_mapped_)
return; return;
if (xwindow_ == None) if (xwindow_ == x11::None)
Create(); Create();
XMapWindow(xdisplay_, xwindow_); XMapWindow(xdisplay_, xwindow_);
...@@ -171,7 +166,7 @@ void X11WindowBase::Close() { ...@@ -171,7 +166,7 @@ void X11WindowBase::Close() {
} }
void X11WindowBase::SetBounds(const gfx::Rect& bounds) { void X11WindowBase::SetBounds(const gfx::Rect& bounds) {
if (xwindow_ != None) { if (xwindow_ != x11::None) {
XWindowChanges changes = {0}; XWindowChanges changes = {0};
unsigned value_mask = 0; unsigned value_mask = 0;
...@@ -220,7 +215,7 @@ void X11WindowBase::SetTitle(const base::string16& title) { ...@@ -220,7 +215,7 @@ void X11WindowBase::SetTitle(const base::string16& title) {
XTextProperty xtp; XTextProperty xtp;
char* c_utf8_str = const_cast<char*>(utf8str.c_str()); char* c_utf8_str = const_cast<char*>(utf8str.c_str());
if (Xutf8TextListToTextProperty(xdisplay_, &c_utf8_str, 1, XUTF8StringStyle, if (Xutf8TextListToTextProperty(xdisplay_, &c_utf8_str, 1, XUTF8StringStyle,
&xtp) == Success) { &xtp) == x11::Success) {
XSetWMName(xdisplay_, xwindow_, &xtp); XSetWMName(xdisplay_, xwindow_, &xtp);
XFree(xtp.value); XFree(xtp.value);
} }
...@@ -239,7 +234,7 @@ void X11WindowBase::Minimize() {} ...@@ -239,7 +234,7 @@ void X11WindowBase::Minimize() {}
void X11WindowBase::Restore() {} void X11WindowBase::Restore() {}
void X11WindowBase::MoveCursorTo(const gfx::Point& location) { void X11WindowBase::MoveCursorTo(const gfx::Point& location) {
XWarpPointer(xdisplay_, None, xroot_window_, 0, 0, 0, 0, XWarpPointer(xdisplay_, x11::None, xroot_window_, 0, 0, 0, 0,
bounds_.x() + location.x(), bounds_.y() + location.y()); bounds_.x() + location.x(), bounds_.y() + location.y());
} }
...@@ -250,7 +245,7 @@ PlatformImeController* X11WindowBase::GetPlatformImeController() { ...@@ -250,7 +245,7 @@ PlatformImeController* X11WindowBase::GetPlatformImeController() {
} }
bool X11WindowBase::IsEventForXWindow(const XEvent& xev) const { bool X11WindowBase::IsEventForXWindow(const XEvent& xev) const {
return xwindow_ != None && FindXEventTarget(xev) == xwindow_; return xwindow_ != x11::None && FindXEventTarget(xev) == xwindow_;
} }
void X11WindowBase::ProcessXWindowEvent(XEvent* xev) { void X11WindowBase::ProcessXWindowEvent(XEvent* xev) {
...@@ -298,7 +293,7 @@ void X11WindowBase::ProcessXWindowEvent(XEvent* xev) { ...@@ -298,7 +293,7 @@ void X11WindowBase::ProcessXWindowEvent(XEvent* xev) {
XEvent reply_event = *xev; XEvent reply_event = *xev;
reply_event.xclient.window = xroot_window_; reply_event.xclient.window = xroot_window_;
XSendEvent(xdisplay_, reply_event.xclient.window, False, XSendEvent(xdisplay_, reply_event.xclient.window, x11::False,
SubstructureRedirectMask | SubstructureNotifyMask, SubstructureRedirectMask | SubstructureNotifyMask,
&reply_event); &reply_event);
XFlush(xdisplay_); XFlush(xdisplay_);
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/macros.h" #include "base/macros.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
#include "ui/gfx/x/x11.h"
#include "ui/gfx/x/x11_types.h" #include "ui/gfx/x/x11_types.h"
#include "ui/platform_window/platform_window.h" #include "ui/platform_window/platform_window.h"
#include "ui/platform_window/platform_window_delegate.h" #include "ui/platform_window/platform_window_delegate.h"
......
...@@ -4,13 +4,12 @@ ...@@ -4,13 +4,12 @@
#include "ui/platform_window/x11/x11_window_ozone.h" #include "ui/platform_window/x11/x11_window_ozone.h"
#include <X11/Xlib.h>
#include "base/bind.h" #include "base/bind.h"
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/events/ozone/events_ozone.h" #include "ui/events/ozone/events_ozone.h"
#include "ui/events/platform/x11/x11_event_source.h" #include "ui/events/platform/x11/x11_event_source.h"
#include "ui/gfx/geometry/point.h" #include "ui/gfx/geometry/point.h"
#include "ui/gfx/x/x11.h"
#include "ui/platform_window/x11/x11_cursor_ozone.h" #include "ui/platform_window/x11/x11_cursor_ozone.h"
#include "ui/platform_window/x11/x11_window_manager_ozone.h" #include "ui/platform_window/x11/x11_window_manager_ozone.h"
...@@ -50,7 +49,7 @@ void X11WindowOzone::SetCursor(PlatformCursor cursor) { ...@@ -50,7 +49,7 @@ void X11WindowOzone::SetCursor(PlatformCursor cursor) {
} }
void X11WindowOzone::CheckCanDispatchNextPlatformEvent(XEvent* xev) { void X11WindowOzone::CheckCanDispatchNextPlatformEvent(XEvent* xev) {
handle_next_event_ = xwindow() == None ? false : IsEventForXWindow(*xev); handle_next_event_ = xwindow() == x11::None ? false : IsEventForXWindow(*xev);
} }
void X11WindowOzone::PlatformEventDispatchFinished() { void X11WindowOzone::PlatformEventDispatchFinished() {
......
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