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

Side by Side Diff: ui/aura/desktop.cc

Issue 8374005: aura: Try to make Linux host resize code more reliable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update a few other gfx::Rect calls Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « ui/aura/desktop.h ('k') | ui/aura/desktop_host.h » ('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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/aura/desktop.h" 5 #include "ui/aura/desktop.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 23 matching lines...) Expand all
34 namespace { 34 namespace {
35 35
36 // Default bounds for the host window. 36 // Default bounds for the host window.
37 static const int kDefaultHostWindowX = 200; 37 static const int kDefaultHostWindowX = 200;
38 static const int kDefaultHostWindowY = 200; 38 static const int kDefaultHostWindowY = 200;
39 static const int kDefaultHostWindowWidth = 1280; 39 static const int kDefaultHostWindowWidth = 1280;
40 static const int kDefaultHostWindowHeight = 1024; 40 static const int kDefaultHostWindowHeight = 1024;
41 41
42 } // namespace 42 } // namespace
43 43
44 // static
45 Desktop* Desktop::instance_ = NULL; 44 Desktop* Desktop::instance_ = NULL;
46
47 // static
48 ui::Compositor*(*Desktop::compositor_factory_)() = NULL; 45 ui::Compositor*(*Desktop::compositor_factory_)() = NULL;
46 bool Desktop::use_fullscreen_host_window_ = false;
49 47
50 Desktop::Desktop() 48 Desktop::Desktop()
51 : Window(NULL), 49 : Window(NULL),
52 host_(aura::DesktopHost::Create(GetInitialHostWindowBounds())), 50 host_(aura::DesktopHost::Create(GetInitialHostWindowBounds())),
53 ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)), 51 ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)),
54 active_window_(NULL), 52 active_window_(NULL),
55 in_destructor_(false), 53 in_destructor_(false),
56 screen_(new ScreenAura), 54 screen_(new ScreenAura),
57 capture_window_(NULL), 55 capture_window_(NULL),
58 mouse_pressed_handler_(NULL), 56 mouse_pressed_handler_(NULL),
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 Window* Desktop::GetFocusedWindow() { 402 Window* Desktop::GetFocusedWindow() {
405 return focused_window_; 403 return focused_window_;
406 } 404 }
407 405
408 bool Desktop::IsFocusedWindow(const Window* window) const { 406 bool Desktop::IsFocusedWindow(const Window* window) const {
409 return focused_window_ == window; 407 return focused_window_ == window;
410 } 408 }
411 409
412 void Desktop::Init() { 410 void Desktop::Init() {
413 Window::Init(); 411 Window::Init();
414 SetBounds(gfx::Rect(gfx::Point(), host_->GetSize())); 412 SetBounds(gfx::Rect(host_->GetSize()));
415 Show(); 413 Show();
416 compositor()->SetRootLayer(layer()); 414 compositor()->SetRootLayer(layer());
417 } 415 }
418 416
419 gfx::Rect Desktop::GetInitialHostWindowBounds() const { 417 gfx::Rect Desktop::GetInitialHostWindowBounds() const {
418 gfx::Rect bounds(kDefaultHostWindowX, kDefaultHostWindowY,
419 kDefaultHostWindowWidth, kDefaultHostWindowHeight);
420
420 const string size_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 421 const string size_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
421 switches::kAuraHostWindowSize); 422 switches::kAuraHostWindowSize);
422
423 int width = 0, height = 0;
424 vector<string> parts; 423 vector<string> parts;
425 base::SplitString(size_str, 'x', &parts); 424 base::SplitString(size_str, 'x', &parts);
426 if (parts.size() != 2 || 425 int parsed_width = 0, parsed_height = 0;
427 !base::StringToInt(parts[0], &width) || 426 if (parts.size() == 2 &&
428 !base::StringToInt(parts[1], &height) || 427 base::StringToInt(parts[0], &parsed_width) && parsed_width > 0 &&
429 width <= 0 || height <= 0) { 428 base::StringToInt(parts[1], &parsed_height) && parsed_height > 0) {
430 width = kDefaultHostWindowWidth; 429 bounds.set_size(gfx::Size(parsed_width, parsed_height));
431 height = kDefaultHostWindowHeight; 430 } else if (use_fullscreen_host_window_) {
431 bounds = gfx::Rect(DesktopHost::GetNativeDisplaySize());
432 } 432 }
433 return gfx::Rect(kDefaultHostWindowX, kDefaultHostWindowY, width, height); 433
434 return bounds;
434 } 435 }
435 436
436 } // namespace aura 437 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/desktop.h ('k') | ui/aura/desktop_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698