Commit 69bc5c76 authored by Shawn Gallea's avatar Shawn Gallea Committed by Commit Bot

EXO: Refactored cursor_shapes interface

Move cursor_shapes interface out of server.cc
This CL only moves code around.

Bug: 896710
Test: Built on ChromeOS
Change-Id: I43f93d25bf08f57d0f111ba99404a1fecb3723da
Reviewed-on: https://chromium-review.googlesource.com/c/1324139
Commit-Queue: Shawn Gallea <sagallea@google.com>
Reviewed-by: default avatarDaniele Castagna <dcastagna@chromium.org>
Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608970}
parent 4b8211d3
......@@ -47,6 +47,8 @@ source_set("wayland") {
"wl_seat.h",
"wl_shell.cc",
"wl_shell.h",
"zcr_cursor_shapes.cc",
"zcr_cursor_shapes.h",
"zcr_gaming_input.cc",
"zcr_gaming_input.h",
"zcr_keyboard_configuration.cc",
......
......@@ -101,6 +101,7 @@
#include "components/exo/wayland/wayland_touch_delegate.h"
#include "components/exo/wayland/wl_seat.h"
#include "components/exo/wayland/wl_shell.h"
#include "components/exo/wayland/zcr_cursor_shapes.h"
#include "components/exo/wayland/zcr_gaming_input.h"
#include "components/exo/wayland/zcr_keyboard_configuration.h"
#include "components/exo/wayland/zcr_keyboard_extension.h"
......@@ -2379,97 +2380,6 @@ void bind_stylus_tools(wl_client* client,
nullptr);
}
////////////////////////////////////////////////////////////////////////////////
// cursor_shapes interface:
static ui::CursorType GetCursorType(int32_t cursor_shape) {
switch (cursor_shape) {
#define ADD_CASE(wayland, chrome) \
case ZCR_CURSOR_SHAPES_V1_CURSOR_SHAPE_TYPE_##wayland: \
return ui::CursorType::chrome
ADD_CASE(POINTER, kPointer);
ADD_CASE(CROSS, kCross);
ADD_CASE(HAND, kHand);
ADD_CASE(IBEAM, kIBeam);
ADD_CASE(WAIT, kWait);
ADD_CASE(HELP, kHelp);
ADD_CASE(EAST_RESIZE, kEastResize);
ADD_CASE(NORTH_RESIZE, kNorthResize);
ADD_CASE(NORTH_EAST_RESIZE, kNorthEastResize);
ADD_CASE(NORTH_WEST_RESIZE, kNorthWestResize);
ADD_CASE(SOUTH_RESIZE, kSouthResize);
ADD_CASE(SOUTH_EAST_RESIZE, kSouthEastResize);
ADD_CASE(SOUTH_WEST_RESIZE, kSouthWestResize);
ADD_CASE(WEST_RESIZE, kWestResize);
ADD_CASE(NORTH_SOUTH_RESIZE, kNorthSouthResize);
ADD_CASE(EAST_WEST_RESIZE, kEastWestResize);
ADD_CASE(NORTH_EAST_SOUTH_WEST_RESIZE, kNorthEastSouthWestResize);
ADD_CASE(NORTH_WEST_SOUTH_EAST_RESIZE, kNorthWestSouthEastResize);
ADD_CASE(COLUMN_RESIZE, kColumnResize);
ADD_CASE(ROW_RESIZE, kRowResize);
ADD_CASE(MIDDLE_PANNING, kMiddlePanning);
ADD_CASE(EAST_PANNING, kEastPanning);
ADD_CASE(NORTH_PANNING, kNorthPanning);
ADD_CASE(NORTH_EAST_PANNING, kNorthEastPanning);
ADD_CASE(NORTH_WEST_PANNING, kNorthWestPanning);
ADD_CASE(SOUTH_PANNING, kSouthPanning);
ADD_CASE(SOUTH_EAST_PANNING, kSouthEastPanning);
ADD_CASE(SOUTH_WEST_PANNING, kSouthWestPanning);
ADD_CASE(WEST_PANNING, kWestPanning);
ADD_CASE(MOVE, kMove);
ADD_CASE(VERTICAL_TEXT, kVerticalText);
ADD_CASE(CELL, kCell);
ADD_CASE(CONTEXT_MENU, kContextMenu);
ADD_CASE(ALIAS, kAlias);
ADD_CASE(PROGRESS, kProgress);
ADD_CASE(NO_DROP, kNoDrop);
ADD_CASE(COPY, kCopy);
ADD_CASE(NONE, kNone);
ADD_CASE(NOT_ALLOWED, kNotAllowed);
ADD_CASE(ZOOM_IN, kZoomIn);
ADD_CASE(ZOOM_OUT, kZoomOut);
ADD_CASE(GRAB, kGrab);
ADD_CASE(GRABBING, kGrabbing);
ADD_CASE(DND_NONE, kDndNone);
ADD_CASE(DND_MOVE, kDndMove);
ADD_CASE(DND_COPY, kDndCopy);
ADD_CASE(DND_LINK, kDndLink);
#undef ADD_CASE
default:
return ui::CursorType::kNull;
}
}
void cursor_shapes_set_cursor_shape(wl_client* client,
wl_resource* resource,
wl_resource* pointer_resource,
int32_t shape) {
ui::CursorType cursor_type = GetCursorType(shape);
if (cursor_type == ui::CursorType::kNull) {
wl_resource_post_error(resource, ZCR_CURSOR_SHAPES_V1_ERROR_INVALID_SHAPE,
"Unrecognized shape %d", shape);
return;
}
Pointer* pointer = GetUserDataAs<Pointer>(pointer_resource);
pointer->SetCursorType(cursor_type);
}
const struct zcr_cursor_shapes_v1_interface cursor_shapes_implementation = {
cursor_shapes_set_cursor_shape};
void bind_cursor_shapes(wl_client* client,
void* data,
uint32_t version,
uint32_t id) {
wl_resource* resource =
wl_resource_create(client, &zcr_cursor_shapes_v1_interface, version, id);
wl_resource_set_implementation(resource, &cursor_shapes_implementation, data,
nullptr);
}
} // namespace
////////////////////////////////////////////////////////////////////////////////
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/exo/wayland/zcr_cursor_shapes.h"
#include <cursor-shapes-unstable-v1-server-protocol.h>
#include <wayland-server-core.h>
#include <wayland-server-protocol-core.h>
#include "components/exo/pointer.h"
#include "components/exo/wayland/server_util.h"
#include "ui/base/cursor/cursor_type.h"
namespace exo {
namespace wayland {
namespace {
////////////////////////////////////////////////////////////////////////////////
// cursor_shapes interface:
static ui::CursorType GetCursorType(int32_t cursor_shape) {
switch (cursor_shape) {
#define ADD_CASE(wayland, chrome) \
case ZCR_CURSOR_SHAPES_V1_CURSOR_SHAPE_TYPE_##wayland: \
return ui::CursorType::chrome
ADD_CASE(POINTER, kPointer);
ADD_CASE(CROSS, kCross);
ADD_CASE(HAND, kHand);
ADD_CASE(IBEAM, kIBeam);
ADD_CASE(WAIT, kWait);
ADD_CASE(HELP, kHelp);
ADD_CASE(EAST_RESIZE, kEastResize);
ADD_CASE(NORTH_RESIZE, kNorthResize);
ADD_CASE(NORTH_EAST_RESIZE, kNorthEastResize);
ADD_CASE(NORTH_WEST_RESIZE, kNorthWestResize);
ADD_CASE(SOUTH_RESIZE, kSouthResize);
ADD_CASE(SOUTH_EAST_RESIZE, kSouthEastResize);
ADD_CASE(SOUTH_WEST_RESIZE, kSouthWestResize);
ADD_CASE(WEST_RESIZE, kWestResize);
ADD_CASE(NORTH_SOUTH_RESIZE, kNorthSouthResize);
ADD_CASE(EAST_WEST_RESIZE, kEastWestResize);
ADD_CASE(NORTH_EAST_SOUTH_WEST_RESIZE, kNorthEastSouthWestResize);
ADD_CASE(NORTH_WEST_SOUTH_EAST_RESIZE, kNorthWestSouthEastResize);
ADD_CASE(COLUMN_RESIZE, kColumnResize);
ADD_CASE(ROW_RESIZE, kRowResize);
ADD_CASE(MIDDLE_PANNING, kMiddlePanning);
ADD_CASE(EAST_PANNING, kEastPanning);
ADD_CASE(NORTH_PANNING, kNorthPanning);
ADD_CASE(NORTH_EAST_PANNING, kNorthEastPanning);
ADD_CASE(NORTH_WEST_PANNING, kNorthWestPanning);
ADD_CASE(SOUTH_PANNING, kSouthPanning);
ADD_CASE(SOUTH_EAST_PANNING, kSouthEastPanning);
ADD_CASE(SOUTH_WEST_PANNING, kSouthWestPanning);
ADD_CASE(WEST_PANNING, kWestPanning);
ADD_CASE(MOVE, kMove);
ADD_CASE(VERTICAL_TEXT, kVerticalText);
ADD_CASE(CELL, kCell);
ADD_CASE(CONTEXT_MENU, kContextMenu);
ADD_CASE(ALIAS, kAlias);
ADD_CASE(PROGRESS, kProgress);
ADD_CASE(NO_DROP, kNoDrop);
ADD_CASE(COPY, kCopy);
ADD_CASE(NONE, kNone);
ADD_CASE(NOT_ALLOWED, kNotAllowed);
ADD_CASE(ZOOM_IN, kZoomIn);
ADD_CASE(ZOOM_OUT, kZoomOut);
ADD_CASE(GRAB, kGrab);
ADD_CASE(GRABBING, kGrabbing);
ADD_CASE(DND_NONE, kDndNone);
ADD_CASE(DND_MOVE, kDndMove);
ADD_CASE(DND_COPY, kDndCopy);
ADD_CASE(DND_LINK, kDndLink);
#undef ADD_CASE
default:
return ui::CursorType::kNull;
}
}
void cursor_shapes_set_cursor_shape(wl_client* client,
wl_resource* resource,
wl_resource* pointer_resource,
int32_t shape) {
ui::CursorType cursor_type = GetCursorType(shape);
if (cursor_type == ui::CursorType::kNull) {
wl_resource_post_error(resource, ZCR_CURSOR_SHAPES_V1_ERROR_INVALID_SHAPE,
"Unrecognized shape %d", shape);
return;
}
Pointer* pointer = GetUserDataAs<Pointer>(pointer_resource);
pointer->SetCursorType(cursor_type);
}
const struct zcr_cursor_shapes_v1_interface cursor_shapes_implementation = {
cursor_shapes_set_cursor_shape};
} // namespace
void bind_cursor_shapes(wl_client* client,
void* data,
uint32_t version,
uint32_t id) {
wl_resource* resource =
wl_resource_create(client, &zcr_cursor_shapes_v1_interface, version, id);
wl_resource_set_implementation(resource, &cursor_shapes_implementation, data,
nullptr);
}
} // namespace wayland
} // namespace exo
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_EXO_WAYLAND_ZCR_CURSOR_SHAPES_H_
#define COMPONENTS_EXO_WAYLAND_ZCR_CURSOR_SHAPES_H_
#include <stdint.h>
struct wl_client;
namespace exo {
namespace wayland {
void bind_cursor_shapes(wl_client* client,
void* data,
uint32_t version,
uint32_t id);
} // namespace wayland
} // namespace exo
#endif // COMPONENTS_EXO_WAYLAND_ZCR_CURSOR_SHAPES_H_
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