OLD | NEW |
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 <stddef.h> | 9 #include <stddef.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 // linux_dmabuf_interface: | 727 // linux_dmabuf_interface: |
728 | 728 |
729 void linux_dmabuf_destroy(wl_client* client, wl_resource* resource) { | 729 void linux_dmabuf_destroy(wl_client* client, wl_resource* resource) { |
730 wl_resource_destroy(resource); | 730 wl_resource_destroy(resource); |
731 } | 731 } |
732 | 732 |
733 void linux_dmabuf_create_params(wl_client* client, | 733 void linux_dmabuf_create_params(wl_client* client, |
734 wl_resource* resource, | 734 wl_resource* resource, |
735 uint32_t id) { | 735 uint32_t id) { |
736 std::unique_ptr<LinuxBufferParams> linux_buffer_params = | 736 std::unique_ptr<LinuxBufferParams> linux_buffer_params = |
737 base::WrapUnique(new LinuxBufferParams(GetUserDataAs<Display>(resource))); | 737 base::MakeUnique<LinuxBufferParams>(GetUserDataAs<Display>(resource)); |
738 | 738 |
739 wl_resource* linux_buffer_params_resource = | 739 wl_resource* linux_buffer_params_resource = |
740 wl_resource_create(client, &zwp_linux_buffer_params_v1_interface, 1, id); | 740 wl_resource_create(client, &zwp_linux_buffer_params_v1_interface, 1, id); |
741 | 741 |
742 SetImplementation(linux_buffer_params_resource, | 742 SetImplementation(linux_buffer_params_resource, |
743 &linux_buffer_params_implementation, | 743 &linux_buffer_params_implementation, |
744 std::move(linux_buffer_params)); | 744 std::move(linux_buffer_params)); |
745 } | 745 } |
746 | 746 |
747 const struct zwp_linux_dmabuf_v1_interface linux_dmabuf_implementation = { | 747 const struct zwp_linux_dmabuf_v1_interface linux_dmabuf_implementation = { |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 | 1110 |
1111 DISALLOW_COPY_AND_ASSIGN(WaylandPrimaryDisplayObserver); | 1111 DISALLOW_COPY_AND_ASSIGN(WaylandPrimaryDisplayObserver); |
1112 }; | 1112 }; |
1113 | 1113 |
1114 const uint32_t output_version = 2; | 1114 const uint32_t output_version = 2; |
1115 | 1115 |
1116 void bind_output(wl_client* client, void* data, uint32_t version, uint32_t id) { | 1116 void bind_output(wl_client* client, void* data, uint32_t version, uint32_t id) { |
1117 wl_resource* resource = wl_resource_create( | 1117 wl_resource* resource = wl_resource_create( |
1118 client, &wl_output_interface, std::min(version, output_version), id); | 1118 client, &wl_output_interface, std::min(version, output_version), id); |
1119 | 1119 |
1120 SetImplementation( | 1120 SetImplementation(resource, nullptr, |
1121 resource, nullptr, | 1121 base::MakeUnique<WaylandPrimaryDisplayObserver>(resource)); |
1122 base::WrapUnique(new WaylandPrimaryDisplayObserver(resource))); | |
1123 } | 1122 } |
1124 | 1123 |
1125 //////////////////////////////////////////////////////////////////////////////// | 1124 //////////////////////////////////////////////////////////////////////////////// |
1126 // xdg_surface_interface: | 1125 // xdg_surface_interface: |
1127 | 1126 |
1128 int XdgResizeComponent(uint32_t edges) { | 1127 int XdgResizeComponent(uint32_t edges) { |
1129 switch (edges) { | 1128 switch (edges) { |
1130 case XDG_SURFACE_RESIZE_EDGE_TOP: | 1129 case XDG_SURFACE_RESIZE_EDGE_TOP: |
1131 return HTTOP; | 1130 return HTTOP; |
1132 case XDG_SURFACE_RESIZE_EDGE_BOTTOM: | 1131 case XDG_SURFACE_RESIZE_EDGE_BOTTOM: |
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1900 | 1899 |
1901 void bind_remote_shell(wl_client* client, | 1900 void bind_remote_shell(wl_client* client, |
1902 void* data, | 1901 void* data, |
1903 uint32_t version, | 1902 uint32_t version, |
1904 uint32_t id) { | 1903 uint32_t id) { |
1905 wl_resource* resource = | 1904 wl_resource* resource = |
1906 wl_resource_create(client, &zwp_remote_shell_v1_interface, | 1905 wl_resource_create(client, &zwp_remote_shell_v1_interface, |
1907 std::min(version, remote_shell_version), id); | 1906 std::min(version, remote_shell_version), id); |
1908 | 1907 |
1909 SetImplementation(resource, &remote_shell_implementation, | 1908 SetImplementation(resource, &remote_shell_implementation, |
1910 base::WrapUnique(new WaylandRemoteShell( | 1909 base::MakeUnique<WaylandRemoteShell>( |
1911 static_cast<Display*>(data), resource))); | 1910 static_cast<Display*>(data), resource)); |
1912 } | 1911 } |
1913 | 1912 |
1914 //////////////////////////////////////////////////////////////////////////////// | 1913 //////////////////////////////////////////////////////////////////////////////// |
1915 // zwp_vsync_timing_v1_interface: | 1914 // zwp_vsync_timing_v1_interface: |
1916 | 1915 |
1917 // Implements VSync timing interface by monitoring a compositor for updates | 1916 // Implements VSync timing interface by monitoring a compositor for updates |
1918 // to VSync parameters. | 1917 // to VSync parameters. |
1919 class VSyncTiming : public ui::CompositorVSyncManager::Observer { | 1918 class VSyncTiming : public ui::CompositorVSyncManager::Observer { |
1920 public: | 1919 public: |
1921 ~VSyncTiming() { vsync_manager_->RemoveObserver(this); } | 1920 ~VSyncTiming() { vsync_manager_->RemoveObserver(this); } |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2450 | 2449 |
2451 const struct wl_touch_interface touch_implementation = {touch_release}; | 2450 const struct wl_touch_interface touch_implementation = {touch_release}; |
2452 | 2451 |
2453 //////////////////////////////////////////////////////////////////////////////// | 2452 //////////////////////////////////////////////////////////////////////////////// |
2454 // wl_seat_interface: | 2453 // wl_seat_interface: |
2455 | 2454 |
2456 void seat_get_pointer(wl_client* client, wl_resource* resource, uint32_t id) { | 2455 void seat_get_pointer(wl_client* client, wl_resource* resource, uint32_t id) { |
2457 wl_resource* pointer_resource = wl_resource_create( | 2456 wl_resource* pointer_resource = wl_resource_create( |
2458 client, &wl_pointer_interface, wl_resource_get_version(resource), id); | 2457 client, &wl_pointer_interface, wl_resource_get_version(resource), id); |
2459 | 2458 |
2460 SetImplementation(pointer_resource, &pointer_implementation, | 2459 SetImplementation( |
2461 base::WrapUnique(new Pointer( | 2460 pointer_resource, &pointer_implementation, |
2462 new WaylandPointerDelegate(pointer_resource)))); | 2461 base::MakeUnique<Pointer>(new WaylandPointerDelegate(pointer_resource))); |
2463 } | 2462 } |
2464 | 2463 |
2465 void seat_get_keyboard(wl_client* client, wl_resource* resource, uint32_t id) { | 2464 void seat_get_keyboard(wl_client* client, wl_resource* resource, uint32_t id) { |
2466 #if defined(USE_XKBCOMMON) | 2465 #if defined(USE_XKBCOMMON) |
2467 uint32_t version = wl_resource_get_version(resource); | 2466 uint32_t version = wl_resource_get_version(resource); |
2468 wl_resource* keyboard_resource = | 2467 wl_resource* keyboard_resource = |
2469 wl_resource_create(client, &wl_keyboard_interface, version, id); | 2468 wl_resource_create(client, &wl_keyboard_interface, version, id); |
2470 | 2469 |
2471 SetImplementation(keyboard_resource, &keyboard_implementation, | 2470 SetImplementation(keyboard_resource, &keyboard_implementation, |
2472 base::WrapUnique(new Keyboard( | 2471 base::MakeUnique<Keyboard>( |
2473 new WaylandKeyboardDelegate(keyboard_resource)))); | 2472 new WaylandKeyboardDelegate(keyboard_resource))); |
2474 | 2473 |
2475 // TODO(reveman): Keep repeat info synchronized with chromium and the host OS. | 2474 // TODO(reveman): Keep repeat info synchronized with chromium and the host OS. |
2476 if (version >= WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION) | 2475 if (version >= WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION) |
2477 wl_keyboard_send_repeat_info(keyboard_resource, 40, 500); | 2476 wl_keyboard_send_repeat_info(keyboard_resource, 40, 500); |
2478 #else | 2477 #else |
2479 NOTIMPLEMENTED(); | 2478 NOTIMPLEMENTED(); |
2480 #endif | 2479 #endif |
2481 } | 2480 } |
2482 | 2481 |
2483 void seat_get_touch(wl_client* client, wl_resource* resource, uint32_t id) { | 2482 void seat_get_touch(wl_client* client, wl_resource* resource, uint32_t id) { |
2484 wl_resource* touch_resource = wl_resource_create( | 2483 wl_resource* touch_resource = wl_resource_create( |
2485 client, &wl_touch_interface, wl_resource_get_version(resource), id); | 2484 client, &wl_touch_interface, wl_resource_get_version(resource), id); |
2486 | 2485 |
2487 SetImplementation( | 2486 SetImplementation( |
2488 touch_resource, &touch_implementation, | 2487 touch_resource, &touch_implementation, |
2489 base::WrapUnique(new Touch(new WaylandTouchDelegate(touch_resource)))); | 2488 base::MakeUnique<Touch>(new WaylandTouchDelegate(touch_resource))); |
2490 } | 2489 } |
2491 | 2490 |
2492 void seat_release(wl_client* client, wl_resource* resource) { | 2491 void seat_release(wl_client* client, wl_resource* resource) { |
2493 wl_resource_destroy(resource); | 2492 wl_resource_destroy(resource); |
2494 } | 2493 } |
2495 | 2494 |
2496 const struct wl_seat_interface seat_implementation = { | 2495 const struct wl_seat_interface seat_implementation = { |
2497 seat_get_pointer, seat_get_keyboard, seat_get_touch, seat_release}; | 2496 seat_get_pointer, seat_get_keyboard, seat_get_touch, seat_release}; |
2498 | 2497 |
2499 const uint32_t seat_version = 5; | 2498 const uint32_t seat_version = 5; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2624 if (surface->GetProperty(kSurfaceHasViewportKey)) { | 2623 if (surface->GetProperty(kSurfaceHasViewportKey)) { |
2625 wl_resource_post_error(resource, WP_VIEWPORTER_ERROR_VIEWPORT_EXISTS, | 2624 wl_resource_post_error(resource, WP_VIEWPORTER_ERROR_VIEWPORT_EXISTS, |
2626 "a viewport for that surface already exists"); | 2625 "a viewport for that surface already exists"); |
2627 return; | 2626 return; |
2628 } | 2627 } |
2629 | 2628 |
2630 wl_resource* viewport_resource = wl_resource_create( | 2629 wl_resource* viewport_resource = wl_resource_create( |
2631 client, &wp_viewport_interface, wl_resource_get_version(resource), id); | 2630 client, &wp_viewport_interface, wl_resource_get_version(resource), id); |
2632 | 2631 |
2633 SetImplementation(viewport_resource, &viewport_implementation, | 2632 SetImplementation(viewport_resource, &viewport_implementation, |
2634 base::WrapUnique(new Viewport(surface))); | 2633 base::MakeUnique<Viewport>(surface)); |
2635 } | 2634 } |
2636 | 2635 |
2637 const struct wp_viewporter_interface viewporter_implementation = { | 2636 const struct wp_viewporter_interface viewporter_implementation = { |
2638 viewporter_destroy, viewporter_get_viewport}; | 2637 viewporter_destroy, viewporter_get_viewport}; |
2639 | 2638 |
2640 void bind_viewporter(wl_client* client, | 2639 void bind_viewporter(wl_client* client, |
2641 void* data, | 2640 void* data, |
2642 uint32_t version, | 2641 uint32_t version, |
2643 uint32_t id) { | 2642 uint32_t id) { |
2644 wl_resource* resource = | 2643 wl_resource* resource = |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2713 if (surface->GetProperty(kSurfaceHasSecurityKey)) { | 2712 if (surface->GetProperty(kSurfaceHasSecurityKey)) { |
2714 wl_resource_post_error(resource, ZWP_SECURE_OUTPUT_V1_ERROR_SECURITY_EXISTS, | 2713 wl_resource_post_error(resource, ZWP_SECURE_OUTPUT_V1_ERROR_SECURITY_EXISTS, |
2715 "a security object for that surface already exists"); | 2714 "a security object for that surface already exists"); |
2716 return; | 2715 return; |
2717 } | 2716 } |
2718 | 2717 |
2719 wl_resource* security_resource = | 2718 wl_resource* security_resource = |
2720 wl_resource_create(client, &zwp_security_v1_interface, 1, id); | 2719 wl_resource_create(client, &zwp_security_v1_interface, 1, id); |
2721 | 2720 |
2722 SetImplementation(security_resource, &security_implementation, | 2721 SetImplementation(security_resource, &security_implementation, |
2723 base::WrapUnique(new Security(surface))); | 2722 base::MakeUnique<Security>(surface)); |
2724 } | 2723 } |
2725 | 2724 |
2726 const struct zwp_secure_output_v1_interface secure_output_implementation = { | 2725 const struct zwp_secure_output_v1_interface secure_output_implementation = { |
2727 secure_output_destroy, secure_output_get_security}; | 2726 secure_output_destroy, secure_output_get_security}; |
2728 | 2727 |
2729 void bind_secure_output(wl_client* client, | 2728 void bind_secure_output(wl_client* client, |
2730 void* data, | 2729 void* data, |
2731 uint32_t version, | 2730 uint32_t version, |
2732 uint32_t id) { | 2731 uint32_t id) { |
2733 wl_resource* resource = | 2732 wl_resource* resource = |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2830 wl_resource_post_error(resource, | 2829 wl_resource_post_error(resource, |
2831 ZWP_ALPHA_COMPOSITING_V1_ERROR_BLENDING_EXISTS, | 2830 ZWP_ALPHA_COMPOSITING_V1_ERROR_BLENDING_EXISTS, |
2832 "a blending object for that surface already exists"); | 2831 "a blending object for that surface already exists"); |
2833 return; | 2832 return; |
2834 } | 2833 } |
2835 | 2834 |
2836 wl_resource* blending_resource = | 2835 wl_resource* blending_resource = |
2837 wl_resource_create(client, &zwp_blending_v1_interface, 1, id); | 2836 wl_resource_create(client, &zwp_blending_v1_interface, 1, id); |
2838 | 2837 |
2839 SetImplementation(blending_resource, &blending_implementation, | 2838 SetImplementation(blending_resource, &blending_implementation, |
2840 base::WrapUnique(new Blending(surface))); | 2839 base::MakeUnique<Blending>(surface)); |
2841 } | 2840 } |
2842 | 2841 |
2843 const struct zwp_alpha_compositing_v1_interface | 2842 const struct zwp_alpha_compositing_v1_interface |
2844 alpha_compositing_implementation = {alpha_compositing_destroy, | 2843 alpha_compositing_implementation = {alpha_compositing_destroy, |
2845 alpha_compositing_get_blending}; | 2844 alpha_compositing_get_blending}; |
2846 | 2845 |
2847 void bind_alpha_compositing(wl_client* client, | 2846 void bind_alpha_compositing(wl_client* client, |
2848 void* data, | 2847 void* data, |
2849 uint32_t version, | 2848 uint32_t version, |
2850 uint32_t id) { | 2849 uint32_t id) { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2915 wl_resource* resource, | 2914 wl_resource* resource, |
2916 uint32_t id, | 2915 uint32_t id, |
2917 wl_resource* seat) { | 2916 wl_resource* seat) { |
2918 wl_resource* gamepad_resource = wl_resource_create( | 2917 wl_resource* gamepad_resource = wl_resource_create( |
2919 client, &zwp_gamepad_v1_interface, wl_resource_get_version(resource), id); | 2918 client, &zwp_gamepad_v1_interface, wl_resource_get_version(resource), id); |
2920 | 2919 |
2921 base::Thread* gaming_input_thread = GetUserDataAs<base::Thread>(resource); | 2920 base::Thread* gaming_input_thread = GetUserDataAs<base::Thread>(resource); |
2922 | 2921 |
2923 SetImplementation( | 2922 SetImplementation( |
2924 gamepad_resource, &gamepad_implementation, | 2923 gamepad_resource, &gamepad_implementation, |
2925 base::WrapUnique(new Gamepad(new WaylandGamepadDelegate(gamepad_resource), | 2924 base::MakeUnique<Gamepad>(new WaylandGamepadDelegate(gamepad_resource), |
2926 gaming_input_thread->task_runner().get()))); | 2925 gaming_input_thread->task_runner().get())); |
2927 } | 2926 } |
2928 | 2927 |
2929 const struct zwp_gaming_input_v1_interface gaming_input_implementation = { | 2928 const struct zwp_gaming_input_v1_interface gaming_input_implementation = { |
2930 gaming_input_get_gamepad}; | 2929 gaming_input_get_gamepad}; |
2931 | 2930 |
2932 void bind_gaming_input(wl_client* client, | 2931 void bind_gaming_input(wl_client* client, |
2933 void* data, | 2932 void* data, |
2934 uint32_t version, | 2933 uint32_t version, |
2935 uint32_t id) { | 2934 uint32_t id) { |
2936 wl_resource* resource = | 2935 wl_resource* resource = |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3000 | 2999 |
3001 void stylus_get_pointer_stylus(wl_client* client, | 3000 void stylus_get_pointer_stylus(wl_client* client, |
3002 wl_resource* resource, | 3001 wl_resource* resource, |
3003 uint32_t id, | 3002 uint32_t id, |
3004 wl_resource* pointer_resource) { | 3003 wl_resource* pointer_resource) { |
3005 Pointer* pointer = GetUserDataAs<Pointer>(pointer_resource); | 3004 Pointer* pointer = GetUserDataAs<Pointer>(pointer_resource); |
3006 | 3005 |
3007 wl_resource* stylus_resource = | 3006 wl_resource* stylus_resource = |
3008 wl_resource_create(client, &zwp_pointer_stylus_v1_interface, 1, id); | 3007 wl_resource_create(client, &zwp_pointer_stylus_v1_interface, 1, id); |
3009 | 3008 |
3010 SetImplementation(stylus_resource, &pointer_stylus_implementation, | 3009 SetImplementation( |
3011 base::WrapUnique(new WaylandPointerStylusDelegate( | 3010 stylus_resource, &pointer_stylus_implementation, |
3012 stylus_resource, pointer))); | 3011 base::MakeUnique<WaylandPointerStylusDelegate>(stylus_resource, pointer)); |
3013 } | 3012 } |
3014 | 3013 |
3015 const struct zwp_stylus_v1_interface stylus_implementation = { | 3014 const struct zwp_stylus_v1_interface stylus_implementation = { |
3016 stylus_get_pointer_stylus}; | 3015 stylus_get_pointer_stylus}; |
3017 | 3016 |
3018 void bind_stylus(wl_client* client, void* data, uint32_t version, uint32_t id) { | 3017 void bind_stylus(wl_client* client, void* data, uint32_t version, uint32_t id) { |
3019 wl_resource* resource = | 3018 wl_resource* resource = |
3020 wl_resource_create(client, &zwp_stylus_v1_interface, version, id); | 3019 wl_resource_create(client, &zwp_stylus_v1_interface, version, id); |
3021 wl_resource_set_implementation(resource, &stylus_implementation, data, | 3020 wl_resource_set_implementation(resource, &stylus_implementation, data, |
3022 nullptr); | 3021 nullptr); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3128 DCHECK(event_loop); | 3127 DCHECK(event_loop); |
3129 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); | 3128 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); |
3130 } | 3129 } |
3131 | 3130 |
3132 void Server::Flush() { | 3131 void Server::Flush() { |
3133 wl_display_flush_clients(wl_display_.get()); | 3132 wl_display_flush_clients(wl_display_.get()); |
3134 } | 3133 } |
3135 | 3134 |
3136 } // namespace wayland | 3135 } // namespace wayland |
3137 } // namespace exo | 3136 } // namespace exo |
OLD | NEW |