Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(404)

Side by Side Diff: components/exo/wayland/server.cc

Issue 1750633002: components/exo: Extend pointer to use v5 protocol (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed unit tests Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/exo/wayland/server.h" 5 #include "components/exo/wayland/server.h"
6 6
7 #include <grp.h> 7 #include <grp.h>
8 #include <linux/input.h> 8 #include <linux/input.h>
9 #include <scaler-server-protocol.h> 9 #include <scaler-server-protocol.h>
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 void OnPointerEnter(Surface* surface, 1232 void OnPointerEnter(Surface* surface,
1233 const gfx::Point& location, 1233 const gfx::Point& location,
1234 int button_flags) override { 1234 int button_flags) override {
1235 wl_resource* surface_resource = surface->GetProperty(kSurfaceResourceKey); 1235 wl_resource* surface_resource = surface->GetProperty(kSurfaceResourceKey);
1236 DCHECK(surface_resource); 1236 DCHECK(surface_resource);
1237 // Should we be sending button events to the client before the enter event 1237 // Should we be sending button events to the client before the enter event
1238 // if client's pressed button state is different from |button_flags|? 1238 // if client's pressed button state is different from |button_flags|?
1239 wl_pointer_send_enter(pointer_resource_, next_serial(), surface_resource, 1239 wl_pointer_send_enter(pointer_resource_, next_serial(), surface_resource,
1240 wl_fixed_from_int(location.x()), 1240 wl_fixed_from_int(location.x()),
1241 wl_fixed_from_int(location.y())); 1241 wl_fixed_from_int(location.y()));
1242 wl_client_flush(client());
1243 } 1242 }
1244 void OnPointerLeave(Surface* surface) override { 1243 void OnPointerLeave(Surface* surface) override {
1245 wl_resource* surface_resource = surface->GetProperty(kSurfaceResourceKey); 1244 wl_resource* surface_resource = surface->GetProperty(kSurfaceResourceKey);
1246 DCHECK(surface_resource); 1245 DCHECK(surface_resource);
1247 wl_pointer_send_leave(pointer_resource_, next_serial(), surface_resource); 1246 wl_pointer_send_leave(pointer_resource_, next_serial(), surface_resource);
1248 wl_client_flush(client());
1249 } 1247 }
1250 void OnPointerMotion(base::TimeDelta time_stamp, 1248 void OnPointerMotion(base::TimeDelta time_stamp,
1251 const gfx::Point& location) override { 1249 const gfx::Point& location) override {
1252 wl_pointer_send_motion(pointer_resource_, time_stamp.InMilliseconds(), 1250 wl_pointer_send_motion(pointer_resource_, time_stamp.InMilliseconds(),
1253 wl_fixed_from_int(location.x()), 1251 wl_fixed_from_int(location.x()),
1254 wl_fixed_from_int(location.y())); 1252 wl_fixed_from_int(location.y()));
1255 wl_client_flush(client());
1256 } 1253 }
1257 void OnPointerButton(base::TimeDelta time_stamp, 1254 void OnPointerButton(base::TimeDelta time_stamp,
1258 int button_flags, 1255 int button_flags,
1259 bool pressed) override { 1256 bool pressed) override {
1260 struct { 1257 struct {
1261 ui::EventFlags flag; 1258 ui::EventFlags flag;
1262 uint32_t value; 1259 uint32_t value;
1263 } buttons[] = { 1260 } buttons[] = {
1264 {ui::EF_LEFT_MOUSE_BUTTON, BTN_LEFT}, 1261 {ui::EF_LEFT_MOUSE_BUTTON, BTN_LEFT},
1265 {ui::EF_RIGHT_MOUSE_BUTTON, BTN_RIGHT}, 1262 {ui::EF_RIGHT_MOUSE_BUTTON, BTN_RIGHT},
1266 {ui::EF_MIDDLE_MOUSE_BUTTON, BTN_MIDDLE}, 1263 {ui::EF_MIDDLE_MOUSE_BUTTON, BTN_MIDDLE},
1267 {ui::EF_FORWARD_MOUSE_BUTTON, BTN_FORWARD}, 1264 {ui::EF_FORWARD_MOUSE_BUTTON, BTN_FORWARD},
1268 {ui::EF_BACK_MOUSE_BUTTON, BTN_BACK}, 1265 {ui::EF_BACK_MOUSE_BUTTON, BTN_BACK},
1269 }; 1266 };
1270 uint32_t serial = next_serial(); 1267 uint32_t serial = next_serial();
1271 for (auto button : buttons) { 1268 for (auto button : buttons) {
1272 if (button_flags & button.flag) { 1269 if (button_flags & button.flag) {
1273 wl_pointer_send_button(pointer_resource_, serial, 1270 wl_pointer_send_button(pointer_resource_, serial,
1274 time_stamp.InMilliseconds(), button.value, 1271 time_stamp.InMilliseconds(), button.value,
1275 pressed ? WL_POINTER_BUTTON_STATE_PRESSED 1272 pressed ? WL_POINTER_BUTTON_STATE_PRESSED
1276 : WL_POINTER_BUTTON_STATE_RELEASED); 1273 : WL_POINTER_BUTTON_STATE_RELEASED);
1277 } 1274 }
1278 } 1275 }
1279 wl_client_flush(client());
1280 } 1276 }
1281 void OnPointerWheel(base::TimeDelta time_stamp, 1277
1282 const gfx::Vector2d& offset) override { 1278 void OnPointerScroll(base::TimeDelta time_stamp,
1279 const gfx::Vector2dF& offset,
1280 bool discrete) override {
1283 // Same as Weston, the reference compositor. 1281 // Same as Weston, the reference compositor.
1284 const double kAxisStepDistance = 10.0 / ui::MouseWheelEvent::kWheelDelta; 1282 const double kAxisStepDistance = 10.0 / ui::MouseWheelEvent::kWheelDelta;
1285 1283
1284 if (wl_resource_get_version(pointer_resource_) >=
1285 WL_POINTER_AXIS_SOURCE_SINCE_VERSION) {
1286 int32_t axis_source = discrete ? WL_POINTER_AXIS_SOURCE_WHEEL
1287 : WL_POINTER_AXIS_SOURCE_FINGER;
1288 wl_pointer_send_axis_source(pointer_resource_, axis_source);
1289 }
1290
1286 double x_value = offset.x() * kAxisStepDistance; 1291 double x_value = offset.x() * kAxisStepDistance;
1287 if (x_value) { 1292 wl_pointer_send_axis(pointer_resource_, time_stamp.InMilliseconds(),
1288 wl_pointer_send_axis(pointer_resource_, time_stamp.InMilliseconds(), 1293 WL_POINTER_AXIS_HORIZONTAL_SCROLL,
1289 WL_POINTER_AXIS_HORIZONTAL_SCROLL, 1294 wl_fixed_from_double(-x_value));
1290 wl_fixed_from_double(-x_value)); 1295
1296 double y_value = offset.y() * kAxisStepDistance;
1297 wl_pointer_send_axis(pointer_resource_, time_stamp.InMilliseconds(),
1298 WL_POINTER_AXIS_VERTICAL_SCROLL,
1299 wl_fixed_from_double(-y_value));
1300 }
1301
1302 void OnPointerScrollStop(base::TimeDelta time_stamp) override {
1303 if (wl_resource_get_version(pointer_resource_) >=
1304 WL_POINTER_AXIS_STOP_SINCE_VERSION) {
1305 wl_pointer_send_axis_stop(pointer_resource_, time_stamp.InMilliseconds(),
1306 WL_POINTER_AXIS_HORIZONTAL_SCROLL);
1307 wl_pointer_send_axis_stop(pointer_resource_, time_stamp.InMilliseconds(),
1308 WL_POINTER_AXIS_VERTICAL_SCROLL);
1291 } 1309 }
1292 double y_value = offset.y() * kAxisStepDistance; 1310 }
1293 if (y_value) { 1311
1294 wl_pointer_send_axis(pointer_resource_, time_stamp.InMilliseconds(), 1312 void OnPointerFrame() override {
1295 WL_POINTER_AXIS_VERTICAL_SCROLL, 1313 if (wl_resource_get_version(pointer_resource_) >=
1296 wl_fixed_from_double(-y_value)); 1314 WL_POINTER_FRAME_SINCE_VERSION) {
1315 wl_pointer_send_frame(pointer_resource_);
1297 } 1316 }
1298 wl_client_flush(client()); 1317 wl_client_flush(client());
1299 } 1318 }
1300 1319
1301 private: 1320 private:
1302 // The client who own this pointer instance. 1321 // The client who own this pointer instance.
1303 wl_client* client() const { 1322 wl_client* client() const {
1304 return wl_resource_get_client(pointer_resource_); 1323 return wl_resource_get_client(pointer_resource_);
1305 } 1324 }
1306 1325
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1587 1606
1588 void seat_get_touch(wl_client* client, wl_resource* resource, uint32_t id) { 1607 void seat_get_touch(wl_client* client, wl_resource* resource, uint32_t id) {
1589 wl_resource* touch_resource = wl_resource_create( 1608 wl_resource* touch_resource = wl_resource_create(
1590 client, &wl_touch_interface, wl_resource_get_version(resource), id); 1609 client, &wl_touch_interface, wl_resource_get_version(resource), id);
1591 1610
1592 SetImplementation( 1611 SetImplementation(
1593 touch_resource, &touch_implementation, 1612 touch_resource, &touch_implementation,
1594 make_scoped_ptr(new Touch(new WaylandTouchDelegate(touch_resource)))); 1613 make_scoped_ptr(new Touch(new WaylandTouchDelegate(touch_resource))));
1595 } 1614 }
1596 1615
1616 void seat_release(wl_client* client, wl_resource* resource) {
1617 wl_resource_destroy(resource);
1618 }
1619
1597 const struct wl_seat_interface seat_implementation = { 1620 const struct wl_seat_interface seat_implementation = {
1598 seat_get_pointer, seat_get_keyboard, seat_get_touch}; 1621 seat_get_pointer, seat_get_keyboard, seat_get_touch, seat_release};
1599 1622
1600 const uint32_t seat_version = 4; 1623 const uint32_t seat_version = 5;
1601 1624
1602 void bind_seat(wl_client* client, void* data, uint32_t version, uint32_t id) { 1625 void bind_seat(wl_client* client, void* data, uint32_t version, uint32_t id) {
1603 wl_resource* resource = wl_resource_create( 1626 wl_resource* resource = wl_resource_create(
1604 client, &wl_seat_interface, std::min(version, seat_version), id); 1627 client, &wl_seat_interface, std::min(version, seat_version), id);
1605 1628
1606 wl_resource_set_implementation(resource, &seat_implementation, data, nullptr); 1629 wl_resource_set_implementation(resource, &seat_implementation, data, nullptr);
1607 1630
1608 if (version >= WL_SEAT_NAME_SINCE_VERSION) 1631 if (version >= WL_SEAT_NAME_SINCE_VERSION)
1609 wl_seat_send_name(resource, "default"); 1632 wl_seat_send_name(resource, "default");
1610 1633
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1835 DCHECK(event_loop); 1858 DCHECK(event_loop);
1836 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); 1859 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds());
1837 } 1860 }
1838 1861
1839 void Server::Flush() { 1862 void Server::Flush() {
1840 wl_display_flush_clients(wl_display_.get()); 1863 wl_display_flush_clients(wl_display_.get());
1841 } 1864 }
1842 1865
1843 } // namespace wayland 1866 } // namespace wayland
1844 } // namespace exo 1867 } // namespace exo
OLDNEW
« components/exo/pointer_unittest.cc ('K') | « components/exo/pointer_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698