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

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

Issue 2524873002: Rename WindowTreeHost G|SetBounds to indicate they are in pixels. (Closed)
Patch Set: rebase 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 (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 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 gfx::Rect window_bounds_in_pixels( 658 gfx::Rect window_bounds_in_pixels(
659 parent_bounds_in_pixels.x() + 659 parent_bounds_in_pixels.x() +
660 (parent_bounds_in_pixels.width() - size_in_pixels.width()) / 2, 660 (parent_bounds_in_pixels.width() - size_in_pixels.width()) / 2,
661 parent_bounds_in_pixels.y() + 661 parent_bounds_in_pixels.y() +
662 (parent_bounds_in_pixels.height() - size_in_pixels.height()) / 2, 662 (parent_bounds_in_pixels.height() - size_in_pixels.height()) / 2,
663 size_in_pixels.width(), size_in_pixels.height()); 663 size_in_pixels.width(), size_in_pixels.height());
664 // Don't size the window bigger than the parent, otherwise the user may not be 664 // Don't size the window bigger than the parent, otherwise the user may not be
665 // able to close or move it. 665 // able to close or move it.
666 window_bounds_in_pixels.AdjustToFit(parent_bounds_in_pixels); 666 window_bounds_in_pixels.AdjustToFit(parent_bounds_in_pixels);
667 667
668 SetBounds(window_bounds_in_pixels); 668 SetBoundsInPixels(window_bounds_in_pixels);
669 } 669 }
670 670
671 void DesktopWindowTreeHostX11::GetWindowPlacement( 671 void DesktopWindowTreeHostX11::GetWindowPlacement(
672 gfx::Rect* bounds, 672 gfx::Rect* bounds,
673 ui::WindowShowState* show_state) const { 673 ui::WindowShowState* show_state) const {
674 *bounds = GetRestoredBounds(); 674 *bounds = GetRestoredBounds();
675 675
676 if (IsFullscreen()) { 676 if (IsFullscreen()) {
677 *show_state = ui::SHOW_STATE_FULLSCREEN; 677 *show_state = ui::SHOW_STATE_FULLSCREEN;
678 } else if (IsMinimized()) { 678 } else if (IsMinimized()) {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 SetWMSpecState(false, 843 SetWMSpecState(false,
844 atom_cache_.GetAtom("_NET_WM_STATE_FULLSCREEN"), 844 atom_cache_.GetAtom("_NET_WM_STATE_FULLSCREEN"),
845 None); 845 None);
846 846
847 // Resize the window so that it does not have the same size as a monitor. 847 // Resize the window so that it does not have the same size as a monitor.
848 // (Otherwise, some window managers immediately put the window back in 848 // (Otherwise, some window managers immediately put the window back in
849 // fullscreen mode). 849 // fullscreen mode).
850 gfx::Rect adjusted_bounds_in_pixels(bounds_in_pixels_.origin(), 850 gfx::Rect adjusted_bounds_in_pixels(bounds_in_pixels_.origin(),
851 AdjustSize(bounds_in_pixels_.size())); 851 AdjustSize(bounds_in_pixels_.size()));
852 if (adjusted_bounds_in_pixels != bounds_in_pixels_) 852 if (adjusted_bounds_in_pixels != bounds_in_pixels_)
853 SetBounds(adjusted_bounds_in_pixels); 853 SetBoundsInPixels(adjusted_bounds_in_pixels);
854 } 854 }
855 855
856 // Some WMs do not respect maximization hints on unmapped windows, so we 856 // Some WMs do not respect maximization hints on unmapped windows, so we
857 // save this one for later too. 857 // save this one for later too.
858 should_maximize_after_map_ = !IsVisible(); 858 should_maximize_after_map_ = !IsVisible();
859 859
860 // When we are in the process of requesting to maximize a window, we can 860 // When we are in the process of requesting to maximize a window, we can
861 // accurately keep track of our restored bounds instead of relying on the 861 // accurately keep track of our restored bounds instead of relying on the
862 // heuristics that are in the PropertyNotify and ConfigureNotify handlers. 862 // heuristics that are in the PropertyNotify and ConfigureNotify handlers.
863 restored_bounds_in_pixels_ = bounds_in_pixels_; 863 restored_bounds_in_pixels_ = bounds_in_pixels_;
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 } 1197 }
1198 1198
1199 void DesktopWindowTreeHostX11::HideImpl() { 1199 void DesktopWindowTreeHostX11::HideImpl() {
1200 if (IsVisible()) { 1200 if (IsVisible()) {
1201 XWithdrawWindow(xdisplay_, xwindow_, 0); 1201 XWithdrawWindow(xdisplay_, xwindow_, 0);
1202 wait_for_unmap_ = true; 1202 wait_for_unmap_ = true;
1203 } 1203 }
1204 native_widget_delegate_->OnNativeWidgetVisibilityChanged(false); 1204 native_widget_delegate_->OnNativeWidgetVisibilityChanged(false);
1205 } 1205 }
1206 1206
1207 gfx::Rect DesktopWindowTreeHostX11::GetBounds() const { 1207 gfx::Rect DesktopWindowTreeHostX11::GetBoundsInPixels() const {
1208 return bounds_in_pixels_; 1208 return bounds_in_pixels_;
1209 } 1209 }
1210 1210
1211 void DesktopWindowTreeHostX11::SetBounds( 1211 void DesktopWindowTreeHostX11::SetBoundsInPixels(
1212 const gfx::Rect& requested_bounds_in_pixel) { 1212 const gfx::Rect& requested_bounds_in_pixel) {
1213 gfx::Rect bounds_in_pixels(requested_bounds_in_pixel.origin(), 1213 gfx::Rect bounds_in_pixels(requested_bounds_in_pixel.origin(),
1214 AdjustSize(requested_bounds_in_pixel.size())); 1214 AdjustSize(requested_bounds_in_pixel.size()));
1215 bool origin_changed = bounds_in_pixels_.origin() != bounds_in_pixels.origin(); 1215 bool origin_changed = bounds_in_pixels_.origin() != bounds_in_pixels.origin();
1216 bool size_changed = bounds_in_pixels_.size() != bounds_in_pixels.size(); 1216 bool size_changed = bounds_in_pixels_.size() != bounds_in_pixels.size();
1217 XWindowChanges changes = {0}; 1217 XWindowChanges changes = {0};
1218 unsigned value_mask = 0; 1218 unsigned value_mask = 0;
1219 1219
1220 delayed_resize_task_.Cancel(); 1220 delayed_resize_task_.Cancel();
1221 1221
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1572 std::copy(atom_list.begin(), atom_list.end(), 1572 std::copy(atom_list.begin(), atom_list.end(),
1573 inserter(window_properties_, window_properties_.begin())); 1573 inserter(window_properties_, window_properties_.begin()));
1574 1574
1575 // Propagate the window minimization information to the content window, so 1575 // Propagate the window minimization information to the content window, so
1576 // the render side can update its visibility properly. OnWMStateUpdated() is 1576 // the render side can update its visibility properly. OnWMStateUpdated() is
1577 // called by PropertyNofify event from DispatchEvent() when the browser is 1577 // called by PropertyNofify event from DispatchEvent() when the browser is
1578 // minimized or shown from minimized state. On Windows, this is realized by 1578 // minimized or shown from minimized state. On Windows, this is realized by
1579 // calling OnHostResized() with an empty size. In particular, 1579 // calling OnHostResized() with an empty size. In particular,
1580 // HWNDMessageHandler::GetClientAreaBounds() returns an empty size when the 1580 // HWNDMessageHandler::GetClientAreaBounds() returns an empty size when the
1581 // window is minimized. On Linux, returning empty size in GetBounds() or 1581 // window is minimized. On Linux, returning empty size in GetBounds() or
1582 // SetBounds() does not work. 1582 // SetBoundsInPixels() does not work.
1583 // We also propagate the minimization to the compositor, to makes sure that we 1583 // We also propagate the minimization to the compositor, to makes sure that we
1584 // don't draw any 'blank' frames that could be noticed in applications such as 1584 // don't draw any 'blank' frames that could be noticed in applications such as
1585 // window manager previews, which show content even when a window is 1585 // window manager previews, which show content even when a window is
1586 // minimized. 1586 // minimized.
1587 bool is_minimized = IsMinimized(); 1587 bool is_minimized = IsMinimized();
1588 if (is_minimized != was_minimized) { 1588 if (is_minimized != was_minimized) {
1589 if (is_minimized) { 1589 if (is_minimized) {
1590 compositor()->SetVisible(false); 1590 compositor()->SetVisible(false);
1591 content_window_->Hide(); 1591 content_window_->Hide();
1592 } else { 1592 } else {
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
2345 if (linux_ui) { 2345 if (linux_ui) {
2346 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); 2346 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window);
2347 if (native_theme) 2347 if (native_theme)
2348 return native_theme; 2348 return native_theme;
2349 } 2349 }
2350 2350
2351 return ui::NativeThemeAura::instance(); 2351 return ui::NativeThemeAura::instance();
2352 } 2352 }
2353 2353
2354 } // namespace views 2354 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698