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

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

Issue 618413002: Check for NULL NativeView in linux/mac Screen::GetDisplayNearestWindow(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comment to screen.h 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
« ui/gfx/screen.h ('K') | « ui/gfx/screen_mac.mm ('k') | 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_screen_x11.h" 5 #include "ui/views/widget/desktop_aura/desktop_screen_x11.h"
6 6
7 #include <X11/extensions/Xrandr.h> 7 #include <X11/extensions/Xrandr.h>
8 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
9 9
10 // It clashes with out RootWindow. 10 // It clashes with out RootWindow.
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 int DesktopScreenX11::GetNumDisplays() const { 150 int DesktopScreenX11::GetNumDisplays() const {
151 return displays_.size(); 151 return displays_.size();
152 } 152 }
153 153
154 std::vector<gfx::Display> DesktopScreenX11::GetAllDisplays() const { 154 std::vector<gfx::Display> DesktopScreenX11::GetAllDisplays() const {
155 return displays_; 155 return displays_;
156 } 156 }
157 157
158 gfx::Display DesktopScreenX11::GetDisplayNearestWindow( 158 gfx::Display DesktopScreenX11::GetDisplayNearestWindow(
159 gfx::NativeView window) const { 159 gfx::NativeView window) const {
160 if (!window)
161 return GetPrimaryDisplay();
162
160 // Getting screen bounds here safely is hard. 163 // Getting screen bounds here safely is hard.
161 // 164 //
162 // You'd think we'd be able to just call window->GetBoundsInScreen(), but we 165 // You'd think we'd be able to just call window->GetBoundsInScreen(), but we
163 // can't because |window| (and the associated WindowEventDispatcher*) can be 166 // can't because |window| (and the associated WindowEventDispatcher*) can be
164 // partially initialized at this point; WindowEventDispatcher initializations 167 // partially initialized at this point; WindowEventDispatcher initializations
165 // call through into GetDisplayNearestWindow(). But the X11 resources are 168 // call through into GetDisplayNearestWindow(). But the X11 resources are
166 // created before we create the aura::WindowEventDispatcher. So we ask what 169 // created before we create the aura::WindowEventDispatcher. So we ask what
167 // the DRWHX11 believes the window bounds are instead of going through the 170 // the DRWHX11 believes the window bounds are instead of going through the
168 // aura::Window's screen bounds. 171 // aura::Window's screen bounds.
169 aura::WindowTreeHost* host = window->GetHost(); 172 aura::WindowTreeHost* host = window->GetHost();
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 change_notifier_.NotifyDisplaysChanged(old_displays, displays_); 362 change_notifier_.NotifyDisplaysChanged(old_displays, displays_);
360 } 363 }
361 364
362 //////////////////////////////////////////////////////////////////////////////// 365 ////////////////////////////////////////////////////////////////////////////////
363 366
364 gfx::Screen* CreateDesktopScreen() { 367 gfx::Screen* CreateDesktopScreen() {
365 return new DesktopScreenX11; 368 return new DesktopScreenX11;
366 } 369 }
367 370
368 } // namespace views 371 } // namespace views
OLDNEW
« ui/gfx/screen.h ('K') | « ui/gfx/screen_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698