diff options
author | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-31 21:52:44 +0000 |
---|---|---|
committer | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-31 21:52:44 +0000 |
commit | fc7611b38ad901cc9babc4defc7214ca601883e2 (patch) | |
tree | 14e572b2aee6c487c13962b9386f8d629ca46590 /chrome/browser | |
parent | 0170caac6453b9d0a946fea8e22d3e48a82119f1 (diff) | |
download | chromium_src-fc7611b38ad901cc9babc4defc7214ca601883e2.zip chromium_src-fc7611b38ad901cc9babc4defc7214ca601883e2.tar.gz chromium_src-fc7611b38ad901cc9babc4defc7214ca601883e2.tar.bz2 |
Linux: Autodetect whether the custom frame should be used.
Listing a bunch of strings from WMs' source sucks,
but I can't think of any way to detect tiling WMs that
don't support the EWMH (see the bug and the comment in
this CL), so this seems safer.
Tested with the following:
- wiped out related prefs and started chrome under ion3;
custom frame not used
- quit and started under metacity; custom frame *was* used
- toggled custom frame pref off and restarted under
metacity again; custom frame not used
- toggled it back on and restarted under ion3; custom frame
was used
BUG=15861
TEST=see above
Review URL: http://codereview.chromium.org/160374
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22193 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/browser.cc | 1 | ||||
-rw-r--r-- | chrome/browser/browser_prefs.cc | 11 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.cc | 41 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.h | 6 |
4 files changed, 56 insertions, 3 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index a23d2ae..35a57d6 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -1245,7 +1245,6 @@ void Browser::RegisterUserPrefs(PrefService* prefs) { prefs->RegisterBooleanPref(prefs::kDeleteFormData, true); prefs->RegisterIntegerPref(prefs::kDeleteTimePeriod, 0); prefs->RegisterBooleanPref(prefs::kCheckDefaultBrowser, true); - prefs->RegisterBooleanPref(prefs::kUseCustomChromeFrame, false); prefs->RegisterBooleanPref(prefs::kShowOmniboxSearchHint, true); } diff --git a/chrome/browser/browser_prefs.cc b/chrome/browser/browser_prefs.cc index 57175d6..74e9b65 100644 --- a/chrome/browser/browser_prefs.cc +++ b/chrome/browser/browser_prefs.cc @@ -30,7 +30,7 @@ #include "chrome/browser/views/frame/browser_view.h" #endif -#if defined(TOOLKIT_VIEWS) || defined(OS_LINUX) +#if defined(OS_WIN) || defined(OS_LINUX) #include "chrome/browser/task_manager.h" #endif @@ -38,6 +38,10 @@ #include "chrome/browser/views/keyword_editor_view.h" #endif +#if defined(TOOLKIT_GTK) +#include "chrome/browser/gtk/browser_window_gtk.h" +#endif + namespace browser { void RegisterAllPrefs(PrefService* user_prefs, PrefService* local_state) { @@ -56,7 +60,7 @@ void RegisterAllPrefs(PrefService* user_prefs, PrefService* local_state) { #if defined(TOOLKIT_VIEWS) // TODO(port): whittle this down as we port BrowserView::RegisterBrowserViewPrefs(local_state); #endif -#if defined(TOOLKIT_VIEWS) || defined(OS_LINUX) +#if defined(OS_WIN) || defined(OS_LINUX) TaskManager::RegisterPrefs(local_state); #endif @@ -74,6 +78,9 @@ void RegisterAllPrefs(PrefService* user_prefs, PrefService* local_state) { NewTabUI::RegisterUserPrefs(user_prefs); BlockedPopupContainer::RegisterUserPrefs(user_prefs); DevToolsManager::RegisterUserPrefs(user_prefs); +#if defined(TOOLKIT_GTK) + BrowserWindowGtk::RegisterUserPrefs(user_prefs); +#endif } } // namespace browser diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index 1ffc57c..aef73ad 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -392,6 +392,7 @@ BrowserWindowGtk::BrowserWindowGtk(Browser* browser) is_active_(true) { use_custom_frame_.Init(prefs::kUseCustomChromeFrame, browser_->profile()->GetPrefs(), this); + window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); g_object_set_data(G_OBJECT(window_), kBrowserWindowKey, this); gtk_widget_add_events(GTK_WIDGET(window_), GDK_BUTTON_PRESS_MASK | @@ -1190,6 +1191,15 @@ GtkWindow* BrowserWindowGtk::GetBrowserWindowForXID(XID xid) { return BrowserWindowGtk::xid_map_.find(xid)->second; } +// static +void BrowserWindowGtk::RegisterUserPrefs(PrefService* prefs) { + bool custom_frame_default = false; + if (!prefs->HasPrefPath(prefs::kUseCustomChromeFrame)) + custom_frame_default = GetCustomFramePrefDefault(); + prefs->RegisterBooleanPref( + prefs::kUseCustomChromeFrame, custom_frame_default); +} + void BrowserWindowGtk::SetGeometryHints() { // Allow the user to resize us arbitrarily small. GdkGeometry geometry; @@ -1725,3 +1735,34 @@ bool BrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) { } NOTREACHED(); } + +// static +bool BrowserWindowGtk::GetCustomFramePrefDefault() { + XID wm_window; + if (!x11_util::GetIntProperty(x11_util::GetX11RootWindow(), + "_NET_SUPPORTING_WM_CHECK", + reinterpret_cast<int*>(&wm_window))) { + return false; + } + + std::string wm_name; + if (!x11_util::GetStringProperty(wm_window, "_NET_WM_NAME", &wm_name)) + return false; + + // Ideally, we'd use the custom frame by default and just fall back on using + // system decorations for the few (?) tiling window managers where it doesn't + // make sense (e.g. awesome, ion3, ratpoison, xmonad, etc.). The EWMH + // _NET_SUPPORTING_WM property makes it easy to look up a name for the current + // WM, but at least some of the WMs in the latter group don't set it. + // Instead, we default to using system decorations for all WMs and + // special-case the ones where the custom frame should be used. These names + // are taken from the WMs' source code. + return (wm_name == "Blackbox" || + wm_name == "compiz" || + wm_name == "e16" || // Enlightenment DR16 + wm_name == "Fluxbox" || + wm_name == "KWin" || + wm_name == "Metacity" || + wm_name == "Openbox" || + wm_name == "Xfwm4"); +} diff --git a/chrome/browser/gtk/browser_window_gtk.h b/chrome/browser/gtk/browser_window_gtk.h index d2e3f2d..acb1d66 100644 --- a/chrome/browser/gtk/browser_window_gtk.h +++ b/chrome/browser/gtk/browser_window_gtk.h @@ -164,6 +164,8 @@ class BrowserWindowGtk : public BrowserWindow, GtkWindow* window() { return window_; } + static void RegisterUserPrefs(PrefService* prefs); + protected: virtual void DestroyBrowser(); // Top level window. @@ -277,6 +279,10 @@ class BrowserWindowGtk : public BrowserWindow, // it should and sets |edge|. bool GetWindowEdge(int x, int y, GdkWindowEdge* edge); + // Determine whether we use should default to native decorations or the custom + // frame based on the currently-running window manager. + static bool GetCustomFramePrefDefault(); + NotificationRegistrar registrar_; // The position and size of the current window. |