Commit 044395d1 authored by Tom Anderson's avatar Tom Anderson Committed by Commit Bot

[XProto] Remove usage of Shape extension

BUG=1066670
R=msisov
CC=sky,nickdiego

Change-Id: I31c3972ad51ccad320abd3554eec9cd8396aff1d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2262113
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: default avatarMaksim Sisov <msisov@igalia.com>
Cr-Commit-Position: refs/heads/master@{#782117}
parent 0347dc10
...@@ -717,10 +717,7 @@ void SetUseOSWindowFrame(x11::Window window, bool use_os_window_frame) { ...@@ -717,10 +717,7 @@ void SetUseOSWindowFrame(x11::Window window, bool use_os_window_frame) {
} }
bool IsShapeExtensionAvailable() { bool IsShapeExtensionAvailable() {
int dummy; return x11::Connection::Get()->shape().present();
static bool is_shape_available =
XShapeQueryExtension(gfx::GetXDisplay(), &dummy, &dummy);
return is_shape_available;
} }
x11::Window GetX11RootWindow() { x11::Window GetX11RootWindow() {
...@@ -855,23 +852,21 @@ bool WindowContainsPoint(x11::Window window, gfx::Point screen_loc) { ...@@ -855,23 +852,21 @@ bool WindowContainsPoint(x11::Window window, gfx::Point screen_loc) {
// client bounding region. Any portion of the client input region that is not // client bounding region. Any portion of the client input region that is not
// included in both the default input region and the client bounding region // included in both the default input region and the client bounding region
// will not be included in the effective input region on the screen. // will not be included in the effective input region on the screen.
int rectangle_kind[] = {ShapeInput, ShapeBounding}; x11::Shape::Sk rectangle_kind[] = {x11::Shape::Sk::Input,
for (int kind_index : rectangle_kind) { x11::Shape::Sk::Bounding};
int dummy; for (auto kind : rectangle_kind) {
int shape_rects_size = 0; auto shape =
gfx::XScopedPtr<XRectangle[]> shape_rects( x11::Connection::Get()->shape().GetRectangles({window, kind}).Sync();
XShapeGetRectangles(gfx::GetXDisplay(), static_cast<uint32_t>(window), if (!shape)
kind_index, &shape_rects_size, &dummy)); return true;
if (!shape_rects) { if (shape->rectangles.empty()) {
// The shape is empty. This can occur when |window| is minimized. // The shape can be empty when |window| is minimized.
DCHECK_EQ(0, shape_rects_size);
return false; return false;
} }
bool is_in_shape_rects = false; bool is_in_shape_rects = false;
for (int i = 0; i < shape_rects_size; ++i) { for (const auto& rect : shape->rectangles) {
// The ShapeInput and ShapeBounding rects are to be in window space, so we // The ShapeInput and ShapeBounding rects are to be in window space, so we
// have to translate by the window_rect's offset to map to screen space. // have to translate by the window_rect's offset to map to screen space.
const XRectangle& rect = shape_rects[i];
gfx::Rect shape_rect = gfx::Rect shape_rect =
gfx::Rect(rect.x + window_rect.x(), rect.y + window_rect.y(), gfx::Rect(rect.x + window_rect.x(), rect.y + window_rect.y(),
rect.width, rect.height); rect.width, rect.height);
......
...@@ -34,7 +34,6 @@ extern "C" { ...@@ -34,7 +34,6 @@ extern "C" {
#include <X11/extensions/Xrandr.h> #include <X11/extensions/Xrandr.h>
#include <X11/extensions/Xrender.h> #include <X11/extensions/Xrender.h>
#include <X11/extensions/record.h> #include <X11/extensions/record.h>
#include <X11/extensions/shape.h>
#include <X11/extensions/sync.h> #include <X11/extensions/sync.h>
// Define XK_xxx before the #include of <X11/keysym.h> so that <X11/keysym.h> // Define XK_xxx before the #include of <X11/keysym.h> so that <X11/keysym.h>
......
...@@ -152,16 +152,13 @@ class TestScreen : public display::ScreenBase { ...@@ -152,16 +152,13 @@ class TestScreen : public display::ScreenBase {
// Returns the list of rectangles which describe |window|'s bounding region via // Returns the list of rectangles which describe |window|'s bounding region via
// the X shape extension. // the X shape extension.
std::vector<gfx::Rect> GetShapeRects(x11::Window window) { std::vector<gfx::Rect> GetShapeRects(x11::Window window) {
int dummy;
int shape_rects_size;
gfx::XScopedPtr<XRectangle[]> shape_rects(
XShapeGetRectangles(gfx::GetXDisplay(), static_cast<uint32_t>(window),
ShapeBounding, &shape_rects_size, &dummy));
std::vector<gfx::Rect> shape_vector; std::vector<gfx::Rect> shape_vector;
for (int i = 0; i < shape_rects_size; ++i) { if (auto shape = x11::Connection::Get()
const XRectangle& rect = shape_rects[i]; ->shape()
shape_vector.emplace_back(rect.x, rect.y, rect.width, rect.height); .GetRectangles({window, x11::Shape::Sk::Bounding})
.Sync()) {
for (const auto& rect : shape->rectangles)
shape_vector.emplace_back(rect.x, rect.y, rect.width, rect.height);
} }
return shape_vector; return shape_vector;
} }
......
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