| 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 <alpha-compositing-unstable-v1-server-protocol.h> | 7 #include <alpha-compositing-unstable-v1-server-protocol.h> |
| 8 #include <gaming-input-unstable-v1-server-protocol.h> | 8 #include <gaming-input-unstable-v1-server-protocol.h> |
| 9 #include <gaming-input-unstable-v2-server-protocol.h> | 9 #include <gaming-input-unstable-v2-server-protocol.h> |
| 10 #include <grp.h> | 10 #include <grp.h> |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 152 |
| 153 // A property key containing a boolean set to true if a security object is | 153 // A property key containing a boolean set to true if a security object is |
| 154 // associated with window. | 154 // associated with window. |
| 155 DEFINE_UI_CLASS_PROPERTY_KEY(bool, kSurfaceHasSecurityKey, false); | 155 DEFINE_UI_CLASS_PROPERTY_KEY(bool, kSurfaceHasSecurityKey, false); |
| 156 | 156 |
| 157 // A property key containing a boolean set to true if a blending object is | 157 // A property key containing a boolean set to true if a blending object is |
| 158 // associated with window. | 158 // associated with window. |
| 159 DEFINE_UI_CLASS_PROPERTY_KEY(bool, kSurfaceHasBlendingKey, false); | 159 DEFINE_UI_CLASS_PROPERTY_KEY(bool, kSurfaceHasBlendingKey, false); |
| 160 | 160 |
| 161 // A property key containing a boolean set to true whether the current | 161 // A property key containing a boolean set to true whether the current |
| 162 // OnWindowActivated invocation should be ignored. | 162 // OnWindowActivated invocation should be ignored. The defualt is true |
| 163 DEFINE_UI_CLASS_PROPERTY_KEY(bool, kIgnoreWindowActivated, false); | 163 // to ignore the activation event originated by creation. |
| 164 DEFINE_UI_CLASS_PROPERTY_KEY(bool, kIgnoreWindowActivated, true); |
| 164 | 165 |
| 165 wl_resource* GetSurfaceResource(Surface* surface) { | 166 wl_resource* GetSurfaceResource(Surface* surface) { |
| 166 return surface->GetProperty(kSurfaceResourceKey); | 167 return surface->GetProperty(kSurfaceResourceKey); |
| 167 } | 168 } |
| 168 | 169 |
| 169 //////////////////////////////////////////////////////////////////////////////// | 170 //////////////////////////////////////////////////////////////////////////////// |
| 170 // wl_buffer_interface: | 171 // wl_buffer_interface: |
| 171 | 172 |
| 172 void buffer_destroy(wl_client* client, wl_resource* resource) { | 173 void buffer_destroy(wl_client* client, wl_resource* resource) { |
| 173 wl_resource_destroy(resource); | 174 wl_resource_destroy(resource); |
| (...skipping 1755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1929 | 1930 |
| 1930 void remote_surface_activate(wl_client* client, | 1931 void remote_surface_activate(wl_client* client, |
| 1931 wl_resource* resource, | 1932 wl_resource* resource, |
| 1932 uint32_t serial) { | 1933 uint32_t serial) { |
| 1933 ShellSurface* shell_surface = GetUserDataAs<ShellSurface>(resource); | 1934 ShellSurface* shell_surface = GetUserDataAs<ShellSurface>(resource); |
| 1934 aura::Window* window = shell_surface->GetWidget()->GetNativeWindow(); | 1935 aura::Window* window = shell_surface->GetWidget()->GetNativeWindow(); |
| 1935 | 1936 |
| 1936 // Activation on Aura is synchronous, so activation callbacks will be called | 1937 // Activation on Aura is synchronous, so activation callbacks will be called |
| 1937 // before the flag is reset. | 1938 // before the flag is reset. |
| 1938 window->SetProperty(kIgnoreWindowActivated, true); | 1939 window->SetProperty(kIgnoreWindowActivated, true); |
| 1939 GetUserDataAs<ShellSurface>(resource)->Activate(); | 1940 shell_surface->Activate(); |
| 1940 window->ClearProperty(kIgnoreWindowActivated); | 1941 window->SetProperty(kIgnoreWindowActivated, false); |
| 1941 } | 1942 } |
| 1942 | 1943 |
| 1943 void remote_surface_maximize(wl_client* client, wl_resource* resource) { | 1944 void remote_surface_maximize(wl_client* client, wl_resource* resource) { |
| 1944 GetUserDataAs<ShellSurface>(resource)->Maximize(); | 1945 GetUserDataAs<ShellSurface>(resource)->Maximize(); |
| 1945 } | 1946 } |
| 1946 | 1947 |
| 1947 void remote_surface_minimize(wl_client* client, wl_resource* resource) { | 1948 void remote_surface_minimize(wl_client* client, wl_resource* resource) { |
| 1948 GetUserDataAs<ShellSurface>(resource)->Minimize(); | 1949 GetUserDataAs<ShellSurface>(resource)->Minimize(); |
| 1949 } | 1950 } |
| 1950 | 1951 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2129 } | 2130 } |
| 2130 void OnMaximizeModeEnded() override {} | 2131 void OnMaximizeModeEnded() override {} |
| 2131 | 2132 |
| 2132 // Overridden from WMHelper::ActivationObserver: | 2133 // Overridden from WMHelper::ActivationObserver: |
| 2133 void OnWindowActivated(aura::Window* gained_active, | 2134 void OnWindowActivated(aura::Window* gained_active, |
| 2134 aura::Window* lost_active) override { | 2135 aura::Window* lost_active) override { |
| 2135 // If the origin of activation is Wayland client, then assume it's been | 2136 // If the origin of activation is Wayland client, then assume it's been |
| 2136 // already activated on the client side, so do not notify about the | 2137 // already activated on the client side, so do not notify about the |
| 2137 // activation. It means that zcr_remote_shell_v1_send_activated is used | 2138 // activation. It means that zcr_remote_shell_v1_send_activated is used |
| 2138 // only to notify about activations originating in Aura. | 2139 // only to notify about activations originating in Aura. |
| 2139 if (gained_active && gained_active->GetProperty(kIgnoreWindowActivated)) | 2140 if (gained_active && gained_active->GetProperty(kIgnoreWindowActivated)) { |
| 2141 gained_active->SetProperty(kIgnoreWindowActivated, false); |
| 2140 return; | 2142 return; |
| 2143 } |
| 2141 | 2144 |
| 2142 SendActivated(gained_active, lost_active); | 2145 SendActivated(gained_active, lost_active); |
| 2143 } | 2146 } |
| 2144 | 2147 |
| 2145 private: | 2148 private: |
| 2146 void ScheduleSendDisplayMetrics(int delay_ms) { | 2149 void ScheduleSendDisplayMetrics(int delay_ms) { |
| 2147 needs_send_display_metrics_ = true; | 2150 needs_send_display_metrics_ = true; |
| 2148 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 2151 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 2149 FROM_HERE, base::Bind(&WaylandRemoteShell::SendDisplayMetrics, | 2152 FROM_HERE, base::Bind(&WaylandRemoteShell::SendDisplayMetrics, |
| 2150 weak_ptr_factory_.GetWeakPtr()), | 2153 weak_ptr_factory_.GetWeakPtr()), |
| (...skipping 1793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3944 DCHECK(event_loop); | 3947 DCHECK(event_loop); |
| 3945 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); | 3948 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); |
| 3946 } | 3949 } |
| 3947 | 3950 |
| 3948 void Server::Flush() { | 3951 void Server::Flush() { |
| 3949 wl_display_flush_clients(wl_display_.get()); | 3952 wl_display_flush_clients(wl_display_.get()); |
| 3950 } | 3953 } |
| 3951 | 3954 |
| 3952 } // namespace wayland | 3955 } // namespace wayland |
| 3953 } // namespace exo | 3956 } // namespace exo |
| OLD | NEW |