OLD | NEW |
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 "chrome/browser/ui/gtk/browser_window_gtk.h" | 5 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
6 | 6 |
7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
8 | 8 |
9 #include <dlfcn.h> | 9 #include <dlfcn.h> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/base_paths.h" | 12 #include "base/base_paths.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/environment.h" |
14 #include "base/i18n/file_util_icu.h" | 15 #include "base/i18n/file_util_icu.h" |
15 #include "base/logging.h" | 16 #include "base/logging.h" |
16 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
17 #include "base/memory/singleton.h" | 18 #include "base/memory/singleton.h" |
18 #include "base/message_loop.h" | 19 #include "base/message_loop.h" |
| 20 #include "base/nix/xdg_util.h" |
19 #include "base/path_service.h" | 21 #include "base/path_service.h" |
20 #include "base/string_util.h" | 22 #include "base/string_util.h" |
21 #include "base/time.h" | 23 #include "base/time.h" |
22 #include "base/utf_string_conversions.h" | 24 #include "base/utf_string_conversions.h" |
23 #include "chrome/app/chrome_command_ids.h" | 25 #include "chrome/app/chrome_command_ids.h" |
24 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" | 26 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" |
25 #include "chrome/browser/bookmarks/bookmark_utils.h" | 27 #include "chrome/browser/bookmarks/bookmark_utils.h" |
26 #include "chrome/browser/browser_process.h" | 28 #include "chrome/browser/browser_process.h" |
27 #include "chrome/browser/debugger/devtools_window.h" | 29 #include "chrome/browser/debugger/devtools_window.h" |
28 #include "chrome/browser/download/download_item_model.h" | 30 #include "chrome/browser/download/download_item_model.h" |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 | 319 |
318 // Add this window to its own unique window group to allow for | 320 // Add this window to its own unique window group to allow for |
319 // window-to-parent modality. | 321 // window-to-parent modality. |
320 gtk_window_group_add_window(gtk_window_group_new(), window_); | 322 gtk_window_group_add_window(gtk_window_group_new(), window_); |
321 g_object_unref(gtk_window_get_group(window_)); | 323 g_object_unref(gtk_window_get_group(window_)); |
322 | 324 |
323 if (browser_->type() & Browser::TYPE_APP) { | 325 if (browser_->type() & Browser::TYPE_APP) { |
324 std::string app_name = browser_->app_name(); | 326 std::string app_name = browser_->app_name(); |
325 if (app_name != DevToolsWindow::kDevToolsApp) { | 327 if (app_name != DevToolsWindow::kDevToolsApp) { |
326 std::string wmclassname = web_app::GetWMClassFromAppName(app_name); | 328 std::string wmclassname = web_app::GetWMClassFromAppName(app_name); |
327 gtk_window_set_wmclass(window_, | 329 |
328 wmclassname.c_str(), | 330 scoped_ptr<base::Environment> env(base::Environment::Create()); |
329 gdk_get_program_class()); | 331 if (base::nix::GetDesktopEnvironment(env.get()) == |
| 332 base::nix::DESKTOP_ENVIRONMENT_XFCE) { |
| 333 // Workaround for XFCE. XFCE seems to treat the class as a user |
| 334 // displayed title, which our app name certainly isn't. They don't have |
| 335 // a dock or application based behaviour so do what looks good. |
| 336 gtk_window_set_wmclass(window_, |
| 337 wmclassname.c_str(), |
| 338 gdk_get_program_class()); |
| 339 } else { |
| 340 // Most everything else uses the wmclass_class to group windows |
| 341 // together (docks, per application stuff, etc). Hopefully they won't |
| 342 // display wmclassname to the user. |
| 343 gtk_window_set_wmclass(window_, |
| 344 window_->wmclass_name, |
| 345 wmclassname.c_str()); |
| 346 } |
| 347 |
| 348 gtk_window_set_role(window_, wmclassname.c_str()); |
330 } | 349 } |
331 } | 350 } |
332 | 351 |
333 // For popups, we initialize widgets then set the window geometry, because | 352 // For popups, we initialize widgets then set the window geometry, because |
334 // popups need the widgets inited before they can set the window size | 353 // popups need the widgets inited before they can set the window size |
335 // properly. For other windows, we set the geometry first to prevent resize | 354 // properly. For other windows, we set the geometry first to prevent resize |
336 // flicker. | 355 // flicker. |
337 if (browser_->type() & Browser::TYPE_POPUP) { | 356 if (browser_->type() & Browser::TYPE_POPUP) { |
338 InitWidgets(); | 357 InitWidgets(); |
339 SetGeometryHints(); | 358 SetGeometryHints(); |
(...skipping 1988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2328 // special-case the ones where the custom frame should be used. These names | 2347 // special-case the ones where the custom frame should be used. These names |
2329 // are taken from the WMs' source code. | 2348 // are taken from the WMs' source code. |
2330 return (wm_name == "Blackbox" || | 2349 return (wm_name == "Blackbox" || |
2331 wm_name == "compiz" || | 2350 wm_name == "compiz" || |
2332 wm_name == "e16" || // Enlightenment DR16 | 2351 wm_name == "e16" || // Enlightenment DR16 |
2333 wm_name == "Metacity" || | 2352 wm_name == "Metacity" || |
2334 wm_name == "Mutter" || | 2353 wm_name == "Mutter" || |
2335 wm_name == "Openbox" || | 2354 wm_name == "Openbox" || |
2336 wm_name == "Xfwm4"); | 2355 wm_name == "Xfwm4"); |
2337 } | 2356 } |
OLD | NEW |