Chromium Code Reviews| 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> |
| 11 #include <viewporter-server-protocol.h> | 11 #include <viewporter-server-protocol.h> |
| 12 #include <wayland-server-core.h> | 12 #include <wayland-server-core.h> |
| 13 #include <wayland-server-protocol-core.h> | 13 #include <wayland-server-protocol-core.h> |
| 14 | 14 |
| 15 // Note: core wayland headers need to be included before protocol headers. | 15 // Note: core wayland headers need to be included before protocol headers. |
| 16 #include <alpha-compositing-unstable-v1-server-protocol.h> // NOLINT | 16 #include <alpha-compositing-unstable-v1-server-protocol.h> // NOLINT |
| 17 #include <explicit-fencing-unstable-v1-server-protocol.h> // NOLINT | |
| 17 #include <gaming-input-unstable-v1-server-protocol.h> // NOLINT | 18 #include <gaming-input-unstable-v1-server-protocol.h> // NOLINT |
| 18 #include <remote-shell-unstable-v1-server-protocol.h> // NOLINT | 19 #include <remote-shell-unstable-v1-server-protocol.h> // NOLINT |
| 19 #include <secure-output-unstable-v1-server-protocol.h> // NOLINT | 20 #include <secure-output-unstable-v1-server-protocol.h> // NOLINT |
| 20 #include <stylus-unstable-v1-server-protocol.h> // NOLINT | 21 #include <stylus-unstable-v1-server-protocol.h> // NOLINT |
| 21 #include <xdg-shell-unstable-v5-server-protocol.h> // NOLINT | 22 #include <xdg-shell-unstable-v5-server-protocol.h> // NOLINT |
| 22 #include <vsync-feedback-unstable-v1-server-protocol.h> // NOLINT | 23 #include <vsync-feedback-unstable-v1-server-protocol.h> // NOLINT |
| 23 | 24 |
| 24 #include <algorithm> | 25 #include <algorithm> |
| 25 #include <cstdlib> | 26 #include <cstdlib> |
| 26 #include <iterator> | 27 #include <iterator> |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 53 #include "components/exo/pointer_delegate.h" | 54 #include "components/exo/pointer_delegate.h" |
| 54 #include "components/exo/pointer_stylus_delegate.h" | 55 #include "components/exo/pointer_stylus_delegate.h" |
| 55 #include "components/exo/shared_memory.h" | 56 #include "components/exo/shared_memory.h" |
| 56 #include "components/exo/shell_surface.h" | 57 #include "components/exo/shell_surface.h" |
| 57 #include "components/exo/sub_surface.h" | 58 #include "components/exo/sub_surface.h" |
| 58 #include "components/exo/surface.h" | 59 #include "components/exo/surface.h" |
| 59 #include "components/exo/surface_property.h" | 60 #include "components/exo/surface_property.h" |
| 60 #include "components/exo/touch.h" | 61 #include "components/exo/touch.h" |
| 61 #include "components/exo/touch_delegate.h" | 62 #include "components/exo/touch_delegate.h" |
| 62 #include "components/exo/wm_helper.h" | 63 #include "components/exo/wm_helper.h" |
| 64 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" | |
| 63 #include "ipc/unix_domain_socket_util.h" | 65 #include "ipc/unix_domain_socket_util.h" |
| 64 #include "third_party/skia/include/core/SkRegion.h" | 66 #include "third_party/skia/include/core/SkRegion.h" |
| 67 #include "ui/aura/env.h" | |
| 65 #include "ui/aura/window_property.h" | 68 #include "ui/aura/window_property.h" |
| 66 #include "ui/base/hit_test.h" | 69 #include "ui/base/hit_test.h" |
| 67 #include "ui/compositor/compositor_vsync_manager.h" | 70 #include "ui/compositor/compositor_vsync_manager.h" |
| 68 #include "ui/display/display_observer.h" | 71 #include "ui/display/display_observer.h" |
| 69 #include "ui/display/manager/managed_display_info.h" | 72 #include "ui/display/manager/managed_display_info.h" |
| 70 #include "ui/display/screen.h" | 73 #include "ui/display/screen.h" |
| 71 #include "ui/events/keycodes/dom/keycode_converter.h" | 74 #include "ui/events/keycodes/dom/keycode_converter.h" |
| 72 #include "ui/gfx/buffer_format_util.h" | 75 #include "ui/gfx/buffer_format_util.h" |
| 73 #include "ui/gfx/buffer_types.h" | 76 #include "ui/gfx/buffer_types.h" |
| 74 #include "ui/views/widget/widget.h" | 77 #include "ui/views/widget/widget.h" |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 90 | 93 |
| 91 namespace exo { | 94 namespace exo { |
| 92 namespace wayland { | 95 namespace wayland { |
| 93 namespace { | 96 namespace { |
| 94 | 97 |
| 95 // We don't send configure immediately after tablet mode switch | 98 // We don't send configure immediately after tablet mode switch |
| 96 // because layout can change due to orientation lock state or accelerometer. | 99 // because layout can change due to orientation lock state or accelerometer. |
| 97 const int kConfigureDelayAfterLayoutSwitchMs = 300; | 100 const int kConfigureDelayAfterLayoutSwitchMs = 300; |
| 98 | 101 |
| 99 // Default wayland socket name. | 102 // Default wayland socket name. |
| 100 const base::FilePath::CharType kSocketName[] = FILE_PATH_LITERAL("wayland-0"); | 103 const base::FilePath::CharType kSocketName[] = FILE_PATH_LITERAL("exosphere-0"); |
|
reveman
2016/10/09 19:03:17
We'll have to do this in a separate CL. Maybe try
fooishbar
2016/10/12 15:41:56
Yeah, this really shouldn't be in here; was a loca
| |
| 101 | 104 |
| 102 // Group used for wayland socket. | 105 // Group used for wayland socket. |
| 103 const char kWaylandSocketGroup[] = "wayland"; | 106 const char kWaylandSocketGroup[] = "wayland"; |
| 104 | 107 |
| 105 template <class T> | 108 template <class T> |
| 106 T* GetUserDataAs(wl_resource* resource) { | 109 T* GetUserDataAs(wl_resource* resource) { |
| 107 return static_cast<T*>(wl_resource_get_user_data(resource)); | 110 return static_cast<T*>(wl_resource_get_user_data(resource)); |
| 108 } | 111 } |
| 109 | 112 |
| 110 template <class T> | 113 template <class T> |
| (...skipping 2848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2959 const struct zcr_stylus_v1_interface stylus_implementation = { | 2962 const struct zcr_stylus_v1_interface stylus_implementation = { |
| 2960 stylus_get_pointer_stylus}; | 2963 stylus_get_pointer_stylus}; |
| 2961 | 2964 |
| 2962 void bind_stylus(wl_client* client, void* data, uint32_t version, uint32_t id) { | 2965 void bind_stylus(wl_client* client, void* data, uint32_t version, uint32_t id) { |
| 2963 wl_resource* resource = | 2966 wl_resource* resource = |
| 2964 wl_resource_create(client, &zcr_stylus_v1_interface, version, id); | 2967 wl_resource_create(client, &zcr_stylus_v1_interface, version, id); |
| 2965 wl_resource_set_implementation(resource, &stylus_implementation, data, | 2968 wl_resource_set_implementation(resource, &stylus_implementation, data, |
| 2966 nullptr); | 2969 nullptr); |
| 2967 } | 2970 } |
| 2968 | 2971 |
| 2972 //////////////////////////////////////////////////////////////////////////////// | |
| 2973 // per-surface explict-fencing interface: | |
|
reveman
2016/10/09 19:03:17
nit: for consistency "INTERFACENAME interface:"
fooishbar
2016/10/12 15:41:56
Done.
| |
| 2974 | |
| 2975 void fenced_surface_destroy(wl_client* client, wl_resource* resource) { | |
| 2976 wl_resource_destroy(resource); | |
| 2977 } | |
| 2978 | |
| 2979 void fenced_surface_set_acquire_fence(wl_client* client, | |
| 2980 wl_resource* resource, | |
| 2981 int fence_fd) | |
| 2982 { | |
| 2983 Surface* surface = GetUserDataAs<Surface>(resource); | |
| 2984 gfx::GpuFenceHandle handle; | |
| 2985 std::unique_ptr<gfx::GpuFence> fence; | |
| 2986 | |
| 2987 handle.fd.fd = fence_fd; | |
| 2988 | |
| 2989 fence = aura::Env::GetInstance() | |
|
reveman
2016/10/09 19:03:17
How about we move this to exo::Display by adding a
fooishbar
2016/10/12 15:41:56
Done.
| |
| 2990 ->context_factory() | |
| 2991 ->GetGpuMemoryBufferManager() | |
| 2992 ->CreateGpuFenceFromHandle(handle); | |
| 2993 | |
| 2994 if (!fence) { | |
| 2995 DLOG(WARNING) << "failed to create GpuFence!"; | |
| 2996 return; | |
| 2997 } | |
| 2998 | |
| 2999 surface->FenceAcquire(std::move(fence)); | |
| 3000 } | |
| 3001 | |
| 3002 const struct zcr_explicit_fenced_surface_v1_interface | |
| 3003 fenced_surface_implementation = { | |
| 3004 fenced_surface_destroy, | |
| 3005 fenced_surface_set_acquire_fence}; | |
| 3006 | |
| 3007 | |
| 3008 //////////////////////////////////////////////////////////////////////////////// | |
| 3009 // explict-fencing interface: | |
| 3010 | |
| 3011 void fencing_destroy(wl_client* client, wl_resource* resource) { | |
| 3012 wl_resource_destroy(resource); | |
| 3013 } | |
| 3014 | |
| 3015 void fencing_get_surface(wl_client* client, wl_resource* resource, uint32_t id, | |
|
reveman
2016/10/09 19:03:17
Can we make this consistent with the alpha_composi
fooishbar
2016/10/12 15:41:56
Yep, but let me do that in v3 so I can sort the re
fooishbar
2016/10/12 15:45:19
Done.
| |
| 3016 wl_resource* surface_resource) { | |
| 3017 Surface* surface = GetUserDataAs<Surface>(surface_resource); | |
| 3018 wl_resource* fenced_surface_resource = | |
| 3019 wl_resource_create(client, &zcr_explicit_fenced_surface_v1_interface, 1, | |
| 3020 id); | |
| 3021 | |
| 3022 wl_resource_set_implementation(fenced_surface_resource, | |
| 3023 &fenced_surface_implementation, | |
| 3024 surface, | |
| 3025 nullptr); | |
| 3026 } | |
| 3027 | |
| 3028 const struct zcr_linux_explicit_fencing_v1_interface | |
| 3029 fencing_implementation = { | |
| 3030 fencing_destroy, | |
| 3031 fencing_get_surface}; | |
| 3032 | |
| 3033 void bind_fencing(wl_client* client, void* data, uint32_t version, | |
| 3034 uint32_t id) { | |
| 3035 wl_resource* resource = | |
| 3036 wl_resource_create(client, &zcr_linux_explicit_fencing_v1_interface, 1, | |
| 3037 id); | |
| 3038 wl_resource_set_implementation(resource, &fencing_implementation, data, | |
| 3039 nullptr); | |
| 3040 } | |
| 3041 | |
| 2969 } // namespace | 3042 } // namespace |
| 2970 | 3043 |
| 2971 //////////////////////////////////////////////////////////////////////////////// | 3044 //////////////////////////////////////////////////////////////////////////////// |
| 2972 // Server, public: | 3045 // Server, public: |
| 2973 | 3046 |
| 2974 Server::Server(Display* display) | 3047 Server::Server(Display* display) |
| 2975 : display_(display), wl_display_(wl_display_create()) { | 3048 : display_(display), wl_display_(wl_display_create()) { |
| 2976 wl_global_create(wl_display_.get(), &wl_compositor_interface, | 3049 wl_global_create(wl_display_.get(), &wl_compositor_interface, |
| 2977 compositor_version, display_, bind_compositor); | 3050 compositor_version, display_, bind_compositor); |
| 2978 wl_global_create(wl_display_.get(), &wl_shm_interface, 1, display_, bind_shm); | 3051 wl_global_create(wl_display_.get(), &wl_shm_interface, 1, display_, bind_shm); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 3001 wl_global_create(wl_display_.get(), &zcr_secure_output_v1_interface, 1, | 3074 wl_global_create(wl_display_.get(), &zcr_secure_output_v1_interface, 1, |
| 3002 display_, bind_secure_output); | 3075 display_, bind_secure_output); |
| 3003 wl_global_create(wl_display_.get(), &zcr_alpha_compositing_v1_interface, 1, | 3076 wl_global_create(wl_display_.get(), &zcr_alpha_compositing_v1_interface, 1, |
| 3004 display_, bind_alpha_compositing); | 3077 display_, bind_alpha_compositing); |
| 3005 wl_global_create(wl_display_.get(), &zcr_remote_shell_v1_interface, | 3078 wl_global_create(wl_display_.get(), &zcr_remote_shell_v1_interface, |
| 3006 remote_shell_version, display_, bind_remote_shell); | 3079 remote_shell_version, display_, bind_remote_shell); |
| 3007 wl_global_create(wl_display_.get(), &zcr_gaming_input_v1_interface, 1, | 3080 wl_global_create(wl_display_.get(), &zcr_gaming_input_v1_interface, 1, |
| 3008 display_, bind_gaming_input); | 3081 display_, bind_gaming_input); |
| 3009 wl_global_create(wl_display_.get(), &zcr_stylus_v1_interface, 1, display_, | 3082 wl_global_create(wl_display_.get(), &zcr_stylus_v1_interface, 1, display_, |
| 3010 bind_stylus); | 3083 bind_stylus); |
| 3084 wl_global_create(wl_display_.get(), | |
|
reveman
2016/10/09 19:03:17
We currently don't make the assumption that all th
fooishbar
2016/10/12 15:41:56
Right, makes sense. Remembered that I'd only done
| |
| 3085 &zcr_linux_explicit_fencing_v1_interface, 1, display_, | |
| 3086 bind_fencing); | |
| 3011 } | 3087 } |
| 3012 | 3088 |
| 3013 Server::~Server() {} | 3089 Server::~Server() {} |
| 3014 | 3090 |
| 3015 // static | 3091 // static |
| 3016 std::unique_ptr<Server> Server::Create(Display* display) { | 3092 std::unique_ptr<Server> Server::Create(Display* display) { |
| 3017 std::unique_ptr<Server> server(new Server(display)); | 3093 std::unique_ptr<Server> server(new Server(display)); |
| 3018 | 3094 |
| 3019 char* runtime_dir = getenv("XDG_RUNTIME_DIR"); | 3095 char* runtime_dir = getenv("XDG_RUNTIME_DIR"); |
| 3020 if (!runtime_dir) { | 3096 if (!runtime_dir) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3072 DCHECK(event_loop); | 3148 DCHECK(event_loop); |
| 3073 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); | 3149 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); |
| 3074 } | 3150 } |
| 3075 | 3151 |
| 3076 void Server::Flush() { | 3152 void Server::Flush() { |
| 3077 wl_display_flush_clients(wl_display_.get()); | 3153 wl_display_flush_clients(wl_display_.get()); |
| 3078 } | 3154 } |
| 3079 | 3155 |
| 3080 } // namespace wayland | 3156 } // namespace wayland |
| 3081 } // namespace exo | 3157 } // namespace exo |
| OLD | NEW |