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

Side by Side Diff: ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc

Issue 610263002: Prevent a frameless app from sizing itself to 0x0 on Desktop Linux (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" 5 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
6 6
7 #include <X11/extensions/shape.h> 7 #include <X11/extensions/shape.h>
8 #include <X11/extensions/XInput2.h> 8 #include <X11/extensions/XInput2.h>
9 #include <X11/Xatom.h> 9 #include <X11/Xatom.h>
10 #include <X11/Xregion.h> 10 #include <X11/Xregion.h>
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 884
885 void DesktopWindowTreeHostX11::SetBounds(const gfx::Rect& requested_bounds) { 885 void DesktopWindowTreeHostX11::SetBounds(const gfx::Rect& requested_bounds) {
886 gfx::Rect bounds(requested_bounds.origin(), 886 gfx::Rect bounds(requested_bounds.origin(),
887 AdjustSize(requested_bounds.size())); 887 AdjustSize(requested_bounds.size()));
888 bool origin_changed = bounds_.origin() != bounds.origin(); 888 bool origin_changed = bounds_.origin() != bounds.origin();
889 bool size_changed = bounds_.size() != bounds.size(); 889 bool size_changed = bounds_.size() != bounds.size();
890 XWindowChanges changes = {0}; 890 XWindowChanges changes = {0};
891 unsigned value_mask = 0; 891 unsigned value_mask = 0;
892 892
893 if (size_changed) { 893 if (size_changed) {
894 // X11 will send an XError at our process if have a 0 sized window.
895 DCHECK_GT(bounds.width(), 0);
896 DCHECK_GT(bounds.height(), 0);
897
898 if (bounds.width() < min_size_.width() || 894 if (bounds.width() < min_size_.width() ||
899 bounds.height() < min_size_.height() || 895 bounds.height() < min_size_.height() ||
900 (!max_size_.IsEmpty() && 896 (!max_size_.IsEmpty() &&
901 (bounds.width() > max_size_.width() || 897 (bounds.width() > max_size_.width() ||
902 bounds.height() > max_size_.height()))) { 898 bounds.height() > max_size_.height()))) {
903 // Update the minimum and maximum sizes in case they have changed. 899 // Update the minimum and maximum sizes in case they have changed.
904 UpdateMinAndMaxSize(); 900 UpdateMinAndMaxSize();
901
902 gfx::Size size = bounds.size();
903 size.SetToMin(max_size_);
904 size.SetToMax(min_size_);
905 bounds.set_size(size);
905 } 906 }
906 907
907 changes.width = bounds.width(); 908 changes.width = bounds.width();
908 changes.height = bounds.height(); 909 changes.height = bounds.height();
909 value_mask |= CWHeight | CWWidth; 910 value_mask |= CWHeight | CWWidth;
910 } 911 }
911 912
912 if (origin_changed) { 913 if (origin_changed) {
913 changes.x = bounds.x(); 914 changes.x = bounds.x();
914 changes.y = bounds.y(); 915 changes.y = bounds.y();
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 std::vector<gfx::Display> displays = 1225 std::vector<gfx::Display> displays =
1225 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE)->GetAllDisplays(); 1226 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE)->GetAllDisplays();
1226 // Compare against all monitor sizes. The window manager can move the window 1227 // Compare against all monitor sizes. The window manager can move the window
1227 // to whichever monitor it wants. 1228 // to whichever monitor it wants.
1228 for (size_t i = 0; i < displays.size(); ++i) { 1229 for (size_t i = 0; i < displays.size(); ++i) {
1229 if (requested_size == displays[i].size()) { 1230 if (requested_size == displays[i].size()) {
1230 return gfx::Size(requested_size.width() - 1, 1231 return gfx::Size(requested_size.width() - 1,
1231 requested_size.height() - 1); 1232 requested_size.height() - 1);
1232 } 1233 }
1233 } 1234 }
1234 return requested_size; 1235
1236 // Do not request a 0x0 window size. It causes an XError.
1237 gfx::Size size = requested_size;
1238 size.SetToMax(gfx::Size(1,1));
1239 return size;
1235 } 1240 }
1236 1241
1237 void DesktopWindowTreeHostX11::OnWMStateUpdated() { 1242 void DesktopWindowTreeHostX11::OnWMStateUpdated() {
1238 std::vector< ::Atom> atom_list; 1243 std::vector< ::Atom> atom_list;
1239 if (!ui::GetAtomArrayProperty(xwindow_, "_NET_WM_STATE", &atom_list)) 1244 if (!ui::GetAtomArrayProperty(xwindow_, "_NET_WM_STATE", &atom_list))
1240 return; 1245 return;
1241 1246
1242 bool was_minimized = IsMinimized(); 1247 bool was_minimized = IsMinimized();
1243 1248
1244 window_properties_.clear(); 1249 window_properties_.clear();
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
1938 if (linux_ui) { 1943 if (linux_ui) {
1939 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); 1944 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window);
1940 if (native_theme) 1945 if (native_theme)
1941 return native_theme; 1946 return native_theme;
1942 } 1947 }
1943 1948
1944 return ui::NativeTheme::instance(); 1949 return ui::NativeTheme::instance();
1945 } 1950 }
1946 1951
1947 } // namespace views 1952 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698