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

Side by Side Diff: services/ui/ws/window_tree.cc

Issue 2517853002: Fixes bug in handling restacking because of transients (Closed)
Patch Set: feedback Created 4 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "services/ui/ws/window_tree.h" 5 #include "services/ui/ws/window_tree.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 } 852 }
853 853
854 WindowId WindowTree::GenerateNewWindowId() { 854 WindowId WindowTree::GenerateNewWindowId() {
855 // TODO(sky): deal with wrapping and uniqueness. 855 // TODO(sky): deal with wrapping and uniqueness.
856 return WindowId(id_, next_window_id_++); 856 return WindowId(id_, next_window_id_++);
857 } 857 }
858 858
859 bool WindowTree::CanReorderWindow(const ServerWindow* window, 859 bool WindowTree::CanReorderWindow(const ServerWindow* window,
860 const ServerWindow* relative_window, 860 const ServerWindow* relative_window,
861 mojom::OrderDirection direction) const { 861 mojom::OrderDirection direction) const {
862 if (!window || !relative_window) 862 if (!window) {
863 DVLOG(1) << "reorder failing: invalid window";
863 return false; 864 return false;
865 }
866 if (!relative_window) {
867 DVLOG(1) << "reorder failing: invalid relative window";
868 return false;
869 }
864 870
865 if (!window->parent() || window->parent() != relative_window->parent()) 871 if (!window->parent()) {
872 DVLOG(1) << "reorder failing: no parent";
866 return false; 873 return false;
874 }
867 875
868 if (!access_policy_->CanReorderWindow(window, relative_window, direction)) 876 if (window->parent() != relative_window->parent()) {
877 DVLOG(1) << "reorder failing: parents differ";
869 return false; 878 return false;
879 }
880
881 if (!access_policy_->CanReorderWindow(window, relative_window, direction)) {
882 DVLOG(1) << "reorder failing: access policy denied";
883 return false;
884 }
870 885
871 const ServerWindow::Windows& children = window->parent()->children(); 886 const ServerWindow::Windows& children = window->parent()->children();
872 const size_t child_i = 887 const size_t child_i =
873 std::find(children.begin(), children.end(), window) - children.begin(); 888 std::find(children.begin(), children.end(), window) - children.begin();
874 const size_t target_i = 889 const size_t target_i =
875 std::find(children.begin(), children.end(), relative_window) - 890 std::find(children.begin(), children.end(), relative_window) -
876 children.begin(); 891 children.begin();
877 if ((direction == mojom::OrderDirection::ABOVE && child_i == target_i + 1) || 892 if ((direction == mojom::OrderDirection::ABOVE && child_i == target_i + 1) ||
878 (direction == mojom::OrderDirection::BELOW && child_i + 1 == target_i)) { 893 (direction == mojom::OrderDirection::BELOW && child_i + 1 == target_i)) {
894 DVLOG(1) << "reorder failing: already in position";
879 return false; 895 return false;
880 } 896 }
881 897
882 return true; 898 return true;
883 } 899 }
884 900
885 bool WindowTree::DeleteWindowImpl(WindowTree* source, ServerWindow* window) { 901 bool WindowTree::DeleteWindowImpl(WindowTree* source, ServerWindow* window) {
886 DCHECK(window); 902 DCHECK(window);
887 DCHECK_EQ(window->id().client_id, id_); 903 DCHECK_EQ(window->id().client_id, id_);
888 Operation op(source, window_server_, OperationType::DELETE_WINDOW); 904 Operation op(source, window_server_, OperationType::DELETE_WINDOW);
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 } 1261 }
1246 1262
1247 void WindowTree::ReorderWindow(uint32_t change_id, 1263 void WindowTree::ReorderWindow(uint32_t change_id,
1248 Id window_id, 1264 Id window_id,
1249 Id relative_window_id, 1265 Id relative_window_id,
1250 mojom::OrderDirection direction) { 1266 mojom::OrderDirection direction) {
1251 bool success = false; 1267 bool success = false;
1252 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); 1268 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id));
1253 ServerWindow* relative_window = 1269 ServerWindow* relative_window =
1254 GetWindowByClientId(ClientWindowId(relative_window_id)); 1270 GetWindowByClientId(ClientWindowId(relative_window_id));
1271 DVLOG(3) << "reorder client=" << id_ << " client window_id=" << window_id
1272 << " global window_id="
1273 << (window ? WindowIdToTransportId(window->id()) : 0)
1274 << " relative client window_id=" << relative_window_id
1275 << " relative global window_id="
1276 << (relative_window ? WindowIdToTransportId(relative_window->id())
1277 : 0);
1255 if (CanReorderWindow(window, relative_window, direction)) { 1278 if (CanReorderWindow(window, relative_window, direction)) {
1256 success = true; 1279 success = true;
1257 Operation op(this, window_server_, OperationType::REORDER_WINDOW); 1280 Operation op(this, window_server_, OperationType::REORDER_WINDOW);
1258 window->Reorder(relative_window, direction); 1281 window->Reorder(relative_window, direction);
1259 window_server_->ProcessWindowReorder(window, relative_window, direction); 1282 window_server_->ProcessWindowReorder(window, relative_window, direction);
1260 } 1283 }
1261 client()->OnChangeCompleted(change_id, success); 1284 client()->OnChangeCompleted(change_id, success);
1262 } 1285 }
1263 1286
1264 void WindowTree::GetWindowTree( 1287 void WindowTree::GetWindowTree(
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
1945 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, 1968 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset,
1946 effect_bitmask, callback); 1969 effect_bitmask, callback);
1947 } 1970 }
1948 1971
1949 void WindowTree::PerformOnDragDropDone() { 1972 void WindowTree::PerformOnDragDropDone() {
1950 client()->OnDragDropDone(); 1973 client()->OnDragDropDone();
1951 } 1974 }
1952 1975
1953 } // namespace ws 1976 } // namespace ws
1954 } // namespace ui 1977 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | ui/aura/client/transient_window_client_observer.h » ('j') | ui/aura/client/transient_window_client_observer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698