diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/browser.cc | 15 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_tabs_module.cc | 6 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.cc | 13 | ||||
-rw-r--r-- | chrome/browser/window_sizer_linux.cc | 85 |
4 files changed, 103 insertions, 16 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 618fb4a..cf30a20 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -37,6 +37,7 @@ #include "chrome/browser/tab_contents/site_instance.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_view.h" +#include "chrome/browser/window_sizer.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/notification_service.h" @@ -77,10 +78,6 @@ #include "chrome/common/child_process_host.h" #endif // OS_WIN -#if defined(OS_WIN) || defined(OS_MACOSX) -#include "chrome/browser/window_sizer.h" -#endif - #if defined(TOOLKIT_VIEWS) #include "chrome/browser/dock_info.h" #endif @@ -1802,7 +1799,8 @@ void Browser::AddNewContents(TabContents* source, // AddTabContents method does. if (type_ & TYPE_APP) transition = PageTransition::START_PAGE; - b->tabstrip_model()->AddTabContents(new_contents, -1, false, transition, true); + b->tabstrip_model()->AddTabContents(new_contents, -1, false, transition, + true); b->window()->Show(); return; } @@ -1815,7 +1813,8 @@ void Browser::AddNewContents(TabContents* source, initial_pos, user_gesture); browser->window()->Show(); } else if (disposition != SUPPRESS_OPEN) { - tabstrip_model_.AddTabContents(new_contents, -1, false, PageTransition::LINK, + tabstrip_model_.AddTabContents(new_contents, -1, false, + PageTransition::LINK, disposition == NEW_FOREGROUND_TAB); } } @@ -2364,8 +2363,10 @@ void Browser::ProcessPendingUIUpdates() { // Updating the URL happens synchronously in ScheduleUIUpdate. TabContents* selected_tab = GetSelectedTabContents(); - if (selected_tab && flags & TabContents::INVALIDATE_LOAD && GetStatusBubble()) + if (selected_tab && + flags & TabContents::INVALIDATE_LOAD && GetStatusBubble()) { GetStatusBubble()->SetStatus(selected_tab->GetStatusText()); + } if (flags & TabContents::INVALIDATE_TAB) { tabstrip_model_.UpdateTabContentsStateAt( diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc index cddafa5..322239a 100644 --- a/chrome/browser/extensions/extension_tabs_module.cc +++ b/chrome/browser/extensions/extension_tabs_module.cc @@ -13,13 +13,7 @@ #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/renderer_host/render_view_host_delegate.h" #include "chrome/browser/tab_contents/navigation_entry.h" - -// TODO(port): Port these files. -#if defined(OS_WIN) || defined(OS_MACOSX) #include "chrome/browser/window_sizer.h" -#else -#include "chrome/common/temp_scaffolding_stubs.h" -#endif namespace { // Error messages. diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index 34e42f0..5be3667 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -746,13 +746,21 @@ void BrowserWindowGtk::AddFindBar(FindBarGtk* findbar) { } void BrowserWindowGtk::SetGeometryHints() { - gtk_window_set_default_size(window_, 640, 480); - // Allow the user to resize us arbitrarily small. GdkGeometry geometry; geometry.min_width = 1; geometry.min_height = 1; gtk_window_set_geometry_hints(window_, NULL, &geometry, GDK_HINT_MIN_SIZE); + + if (browser_->GetSavedMaximizedState()) + gtk_window_maximize(window_); + else + gtk_window_unmaximize(window_); + + gfx::Rect rect = browser_->GetSavedWindowBounds(); + gtk_window_set_default_size(window_, + static_cast<gint>(rect.width()), + static_cast<gint>(rect.height())); } void BrowserWindowGtk::SetWindowIcon() { @@ -832,4 +840,3 @@ bool BrowserWindowGtk::IsToolbarSupported() { return browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) || browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR); } - diff --git a/chrome/browser/window_sizer_linux.cc b/chrome/browser/window_sizer_linux.cc new file mode 100644 index 0000000..524dfb4 --- /dev/null +++ b/chrome/browser/window_sizer_linux.cc @@ -0,0 +1,85 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/window_sizer.h" + +#include <gtk/gtk.h> + +#include "base/logging.h" +#include "chrome/browser/browser.h" + +// How much horizontal and vertical offset there is between newly +// opened windows. We don't care on Linux since the window manager generally +// does a good job of window placement. +const int WindowSizer::kWindowTilePixels = 0; + +// An implementation of WindowSizer::MonitorInfoProvider that gets the actual +// monitor information from X via GDK. +class DefaultMonitorInfoProvider : public WindowSizer::MonitorInfoProvider { + public: + DefaultMonitorInfoProvider() { } + + virtual gfx::Rect GetPrimaryMonitorWorkArea() const { + gfx::Rect rect = GetScreenWorkArea(); + return rect.Intersect(GetPrimaryMonitorBounds()); + } + + virtual gfx::Rect GetPrimaryMonitorBounds() const { + GdkScreen* screen = gdk_screen_get_default(); + GdkRectangle rect; + gdk_screen_get_monitor_geometry(screen, 0, &rect); + return gfx::Rect(rect); + } + + virtual gfx::Rect GetMonitorWorkAreaMatching( + const gfx::Rect& match_rect) const { + // TODO(thestig) Implement multi-monitor support. + return GetPrimaryMonitorWorkArea(); + } + + virtual gfx::Point GetBoundsOffsetMatching( + const gfx::Rect& match_rect) const { + // TODO(thestig) Implement multi-monitor support. + return GetPrimaryMonitorWorkArea().origin(); + } + + void UpdateWorkAreas() { + // TODO(thestig) Implement multi-monitor support. + work_areas_.clear(); + work_areas_.push_back(GetPrimaryMonitorBounds()); + } + + private: + gfx::Rect GetScreenWorkArea() const { + gboolean r; + glong *data; + gint data_len; + r = gdk_property_get(gdk_get_default_root_window(), // a gdk window + gdk_atom_intern("_NET_WORKAREA", FALSE), // property + gdk_atom_intern("CARDINAL", FALSE), // property type + 0, // byte offset into property + 0xff, // property length to retrieve + false, // delete property after retrieval? + NULL, // returned property type + NULL, // returned data format + &data_len, // returned data len + reinterpret_cast<guchar**>(&data)); // returned data + CHECK(r); + CHECK(data_len >= 16); + gint x = data[0]; + gint y = data[1]; + gint width = data[0] + data[2]; + gint height = data[1] + data[3]; + g_free(data); + return gfx::Rect(x, y, width, height); + } + + DISALLOW_COPY_AND_ASSIGN(DefaultMonitorInfoProvider); +}; + +// static +WindowSizer::MonitorInfoProvider* +WindowSizer::CreateDefaultMonitorInfoProvider() { + return new DefaultMonitorInfoProvider(); +} |