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

Side by Side Diff: components/exo/shell_surface.cc

Issue 2360533002: exo: Implement minimal support for version 6 of XDG shell. (Closed)
Patch Set: fix bad rebase and unit tests Created 3 years, 10 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
« no previous file with comments | « no previous file | components/exo/shell_surface_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/shell_surface.h" 5 #include "components/exo/shell_surface.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/common/frame/custom_frame_view_ash.h" 9 #include "ash/common/frame/custom_frame_view_ash.h"
10 #include "ash/common/shelf/wm_shelf.h" 10 #include "ash/common/shelf/wm_shelf.h"
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 return value; 677 return value;
678 } 678 }
679 679
680 //////////////////////////////////////////////////////////////////////////////// 680 ////////////////////////////////////////////////////////////////////////////////
681 // SurfaceDelegate overrides: 681 // SurfaceDelegate overrides:
682 682
683 void ShellSurface::OnSurfaceCommit() { 683 void ShellSurface::OnSurfaceCommit() {
684 surface_->CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces(); 684 surface_->CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces();
685 surface_->CommitSurfaceHierarchy(); 685 surface_->CommitSurfaceHierarchy();
686 686
687 if (enabled() && !widget_) 687 if (enabled() && !widget_) {
688 CreateShellSurfaceWidget(ui::SHOW_STATE_NORMAL); 688 // Defer widget creation until surface contains some contents.
689 if (surface_->content_size().IsEmpty())
690 Configure();
691 else
692 CreateShellSurfaceWidget(ui::SHOW_STATE_NORMAL);
693 }
689 694
690 // Apply the accumulated pending origin offset to reflect acknowledged 695 // Apply the accumulated pending origin offset to reflect acknowledged
691 // configure requests. 696 // configure requests.
692 origin_ += pending_origin_offset_; 697 origin_ += pending_origin_offset_;
693 pending_origin_offset_ = gfx::Vector2d(); 698 pending_origin_offset_ = gfx::Vector2d();
694 699
695 // Update resize direction to reflect acknowledged configure requests. 700 // Update resize direction to reflect acknowledged configure requests.
696 resize_component_ = pending_resize_component_; 701 resize_component_ = pending_resize_component_;
697 702
698 if (widget_) { 703 if (widget_) {
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 } 1146 }
1142 1147
1143 // Receive accessibility changes to update shadow underlay. 1148 // Receive accessibility changes to update shadow underlay.
1144 WMHelper::GetInstance()->AddAccessibilityObserver(this); 1149 WMHelper::GetInstance()->AddAccessibilityObserver(this);
1145 1150
1146 // Show widget next time Commit() is called. 1151 // Show widget next time Commit() is called.
1147 pending_show_widget_ = true; 1152 pending_show_widget_ = true;
1148 } 1153 }
1149 1154
1150 void ShellSurface::Configure() { 1155 void ShellSurface::Configure() {
1151 DCHECK(widget_);
1152
1153 // Delay configure callback if |scoped_configure_| is set. 1156 // Delay configure callback if |scoped_configure_| is set.
1154 if (scoped_configure_) { 1157 if (scoped_configure_) {
1155 scoped_configure_->set_needs_configure(); 1158 scoped_configure_->set_needs_configure();
1156 return; 1159 return;
1157 } 1160 }
1158 1161
1159 gfx::Vector2d origin_offset = pending_origin_config_offset_; 1162 gfx::Vector2d origin_offset = pending_origin_config_offset_;
1160 pending_origin_config_offset_ = gfx::Vector2d(); 1163 pending_origin_config_offset_ = gfx::Vector2d();
1161 1164
1162 ash::wm::WindowState* window_state = 1165 int resize_component = HTCAPTION;
1163 ash::wm::GetWindowState(widget_->GetNativeWindow()); 1166 if (widget_) {
1167 ash::wm::WindowState* window_state =
1168 ash::wm::GetWindowState(widget_->GetNativeWindow());
1164 1169
1165 // If surface is being resized, save the resize direction. 1170 // If surface is being resized, save the resize direction.
1166 int resize_component = window_state->is_dragged() 1171 if (window_state->is_dragged())
1167 ? window_state->drag_details()->window_component 1172 resize_component = window_state->drag_details()->window_component;
1168 : HTCAPTION; 1173 }
1169 1174
1170 uint32_t serial = 0; 1175 uint32_t serial = 0;
1171 if (!configure_callback_.is_null()) { 1176 if (!configure_callback_.is_null()) {
1172 const views::NonClientView* non_client_view = widget_->non_client_view(); 1177 if (widget_) {
1173 serial = configure_callback_.Run( 1178 const views::NonClientView* non_client_view = widget_->non_client_view();
1174 non_client_view->frame_view()->GetBoundsForClientView().size(), 1179 serial = configure_callback_.Run(
1175 ash::wm::GetWindowState(widget_->GetNativeWindow())->GetStateType(), 1180 non_client_view->frame_view()->GetBoundsForClientView().size(),
1176 IsResizing(), widget_->IsActive()); 1181 ash::wm::GetWindowState(widget_->GetNativeWindow())->GetStateType(),
1182 IsResizing(), widget_->IsActive());
1183 } else {
1184 serial = configure_callback_.Run(
1185 gfx::Size(), ash::wm::WINDOW_STATE_TYPE_NORMAL, false, false);
1186 }
1177 } 1187 }
1178 1188
1179 if (!serial) { 1189 if (!serial) {
1180 pending_origin_offset_ += origin_offset; 1190 pending_origin_offset_ += origin_offset;
1181 pending_resize_component_ = resize_component; 1191 pending_resize_component_ = resize_component;
1182 return; 1192 return;
1183 } 1193 }
1184 1194
1185 // Apply origin offset and resize component at the first Commit() after this 1195 // Apply origin offset and resize component at the first Commit() after this
1186 // configure request has been acknowledged. 1196 // configure request has been acknowledged.
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 // small style shadow for them. 1517 // small style shadow for them.
1508 if (!activatable_) 1518 if (!activatable_)
1509 shadow->SetElevation(wm::ShadowElevation::SMALL); 1519 shadow->SetElevation(wm::ShadowElevation::SMALL);
1510 // We don't have rounded corners unless frame is enabled. 1520 // We don't have rounded corners unless frame is enabled.
1511 if (!frame_enabled_) 1521 if (!frame_enabled_)
1512 shadow->SetRoundedCornerRadius(0); 1522 shadow->SetRoundedCornerRadius(0);
1513 } 1523 }
1514 } 1524 }
1515 1525
1516 } // namespace exo 1526 } // namespace exo
OLDNEW
« no previous file with comments | « no previous file | components/exo/shell_surface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698