Chromium Code Reviews| Index: components/exo/wayland/server.cc |
| diff --git a/components/exo/wayland/server.cc b/components/exo/wayland/server.cc |
| index 877e56c3867e29db172c7a33917205ec2fd45c26..42f96311e0f33908722d7e86843c31f2112063bb 100644 |
| --- a/components/exo/wayland/server.cc |
| +++ b/components/exo/wayland/server.cc |
| @@ -13,13 +13,14 @@ |
| #include <wayland-server-protocol-core.h> |
| // Note: core wayland headers need to be included before protocol headers. |
| -#include <alpha-compositing-unstable-v1-server-protocol.h> // NOLINT |
| -#include <gaming-input-unstable-v1-server-protocol.h> // NOLINT |
| -#include <remote-shell-unstable-v1-server-protocol.h> // NOLINT |
| -#include <secure-output-unstable-v1-server-protocol.h> // NOLINT |
| -#include <stylus-unstable-v1-server-protocol.h> // NOLINT |
| -#include <vsync-feedback-unstable-v1-server-protocol.h> // NOLINT |
| -#include <xdg-shell-unstable-v5-server-protocol.h> // NOLINT |
| +#include <alpha-compositing-unstable-v1-server-protocol.h> // NOLINT |
| +#include <keyboard-configuration-unstable-v1-server-protocol.h> // NOLINT |
| +#include <gaming-input-unstable-v1-server-protocol.h> // NOLINT |
| +#include <remote-shell-unstable-v1-server-protocol.h> // NOLINT |
| +#include <secure-output-unstable-v1-server-protocol.h> // NOLINT |
| +#include <stylus-unstable-v1-server-protocol.h> // NOLINT |
| +#include <vsync-feedback-unstable-v1-server-protocol.h> // NOLINT |
| +#include <xdg-shell-unstable-v5-server-protocol.h> // NOLINT |
| #include <algorithm> |
| #include <cstdlib> |
| @@ -47,6 +48,7 @@ |
| #include "components/exo/gamepad_delegate.h" |
| #include "components/exo/keyboard.h" |
| #include "components/exo/keyboard_delegate.h" |
| +#include "components/exo/keyboard_device_configuration_delegate.h" |
| #include "components/exo/notification_surface.h" |
| #include "components/exo/notification_surface_manager.h" |
| #include "components/exo/pointer.h" |
| @@ -2998,6 +3000,79 @@ void bind_stylus(wl_client* client, void* data, uint32_t version, uint32_t id) { |
| nullptr); |
| } |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// keyboard_device_configuration interface: |
| + |
| +class WaylandKeyboardDeviceConfigurationDelegate |
| + : public KeyboardDeviceConfigurationDelegate { |
| + public: |
| + WaylandKeyboardDeviceConfigurationDelegate(wl_resource* resource, |
| + Keyboard* keyboard) |
| + : resource_(resource), keyboard_(keyboard) { |
| + keyboard_->SetKeyboardDeviceConfigurationDelegate(this); |
|
reveman
2016/12/09 00:18:37
what if the keyboard already has a device config d
yhanada
2016/12/09 14:54:04
I added a call of |OnKeyboardDestroying| in |Keybo
|
| + } |
| + ~WaylandKeyboardDeviceConfigurationDelegate() override { |
| + if (keyboard_ != nullptr) |
|
reveman
2016/12/09 00:18:37
s/keyboard_ != nullptr/keyboard/
but how can keyb
yhanada
2016/12/09 14:54:04
In order to avoid referencing a invalid pointer, I
|
| + keyboard_->SetKeyboardDeviceConfigurationDelegate(nullptr); |
| + } |
| + |
| + void OnKeyboardTypeChanged(bool is_physical) override { |
| + const uint32_t type = |
|
reveman
2016/12/09 00:18:37
nit: remove "const" or maybe even better, remove t
yhanada
2016/12/09 14:54:04
Done.
|
| + is_physical |
| + ? ZCR_KEYBOARD_DEVICE_CONFIGURATION_V1_KEYBOARD_TYPE_PHYSICAL |
| + : ZCR_KEYBOARD_DEVICE_CONFIGURATION_V1_KEYBOARD_TYPE_VIRTUAL; |
| + zcr_keyboard_device_configuration_v1_send_type_change(resource_, type); |
| + } |
| + |
| + private: |
| + wl_resource* resource_; |
| + Keyboard* keyboard_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(WaylandKeyboardDeviceConfigurationDelegate); |
| +}; |
| + |
| +void keyboard_device_configuration_destroy(wl_client* client, |
| + wl_resource* resource) { |
| + wl_resource_destroy(resource); |
| +} |
| + |
| +const struct zcr_keyboard_device_configuration_v1_interface |
| + keyboard_device_configuration_implementation = { |
| + keyboard_device_configuration_destroy}; |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// keyboard extension interface: |
|
reveman
2016/12/09 00:18:37
// keyboard configuration interface:
yhanada
2016/12/09 14:54:04
Done.
|
| + |
| +void keyboard_extension_get_keyboard_device_configuration( |
|
reveman
2016/12/09 00:18:37
keyboard_configuration_get_keyboard_device_configu
yhanada
2016/12/09 14:54:04
Done.
|
| + wl_client* client, |
| + wl_resource* resource, |
| + uint32_t id, |
| + wl_resource* keyboard_resource) { |
| + Keyboard* keyboard = GetUserDataAs<Keyboard>(keyboard_resource); |
|
reveman
2016/12/09 00:18:37
move this down to where it's first used. do you ne
yhanada
2016/12/09 14:54:04
Done.
|
| + wl_resource* keyboard_device_configuration_resource = wl_resource_create( |
| + client, &zcr_keyboard_device_configuration_v1_interface, 1, id); |
| + |
| + SetImplementation( |
| + keyboard_device_configuration_resource, |
| + &keyboard_device_configuration_implementation, |
| + base::MakeUnique<WaylandKeyboardDeviceConfigurationDelegate>( |
| + keyboard_device_configuration_resource, keyboard)); |
| +} |
| + |
| +const struct zcr_keyboard_configuration_v1_interface |
| + keyboard_configuration_implementation = { |
| + keyboard_extension_get_keyboard_device_configuration}; |
| + |
| +void bind_keyboard_configuration(wl_client* client, |
| + void* data, |
| + uint32_t version, |
| + uint32_t id) { |
| + wl_resource* resource = wl_resource_create( |
| + client, &zcr_keyboard_configuration_v1_interface, version, id); |
| + wl_resource_set_implementation( |
| + resource, &keyboard_configuration_implementation, data, nullptr); |
| +} |
| + |
| } // namespace |
| //////////////////////////////////////////////////////////////////////////////// |
| @@ -3040,6 +3115,8 @@ Server::Server(Display* display) |
| display_, bind_gaming_input); |
| wl_global_create(wl_display_.get(), &zcr_stylus_v1_interface, 1, display_, |
| bind_stylus); |
| + wl_global_create(wl_display_.get(), &zcr_keyboard_configuration_v1_interface, |
| + 1, display_, bind_keyboard_configuration); |
| } |
| Server::~Server() {} |