| OLD | NEW |
| 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 "chrome/browser/ui/libgtk2ui/gtk2_ui.h" | 5 #include "chrome/browser/ui/libgtk2ui/gtk2_ui.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include <pango/pango.h> | 9 #include <pango/pango.h> |
| 10 | 10 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/debug/leak_annotations.h" | 12 #include "base/debug/leak_annotations.h" |
| 13 #include "base/environment.h" | 13 #include "base/environment.h" |
| 14 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/nix/mime_util_xdg.h" | 16 #include "base/nix/mime_util_xdg.h" |
| 17 #include "base/nix/xdg_util.h" |
| 17 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
| 18 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
| 19 #include "chrome/browser/themes/theme_properties.h" | 20 #include "chrome/browser/themes/theme_properties.h" |
| 20 #include "chrome/browser/ui/libgtk2ui/app_indicator_icon.h" | 21 #include "chrome/browser/ui/libgtk2ui/app_indicator_icon.h" |
| 21 #include "chrome/browser/ui/libgtk2ui/chrome_gtk_frame.h" | 22 #include "chrome/browser/ui/libgtk2ui/chrome_gtk_frame.h" |
| 22 #include "chrome/browser/ui/libgtk2ui/gtk2_border.h" | 23 #include "chrome/browser/ui/libgtk2ui/gtk2_border.h" |
| 23 #include "chrome/browser/ui/libgtk2ui/gtk2_event_loop.h" | 24 #include "chrome/browser/ui/libgtk2ui/gtk2_event_loop.h" |
| 24 #include "chrome/browser/ui/libgtk2ui/gtk2_key_bindings_handler.h" | 25 #include "chrome/browser/ui/libgtk2ui/gtk2_key_bindings_handler.h" |
| 25 #include "chrome/browser/ui/libgtk2ui/gtk2_signal_registrar.h" | 26 #include "chrome/browser/ui/libgtk2ui/gtk2_signal_registrar.h" |
| 26 #include "chrome/browser/ui/libgtk2ui/gtk2_status_icon.h" | 27 #include "chrome/browser/ui/libgtk2ui/gtk2_status_icon.h" |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 LOG(WARNING) << "Unexpected gtk-xft-rgba \"" << rgba << "\""; | 372 LOG(WARNING) << "Unexpected gtk-xft-rgba \"" << rgba << "\""; |
| 372 params.subpixel_rendering = gfx::FontRenderParams::SUBPIXEL_RENDERING_NONE; | 373 params.subpixel_rendering = gfx::FontRenderParams::SUBPIXEL_RENDERING_NONE; |
| 373 } | 374 } |
| 374 | 375 |
| 375 g_free(hint_style); | 376 g_free(hint_style); |
| 376 g_free(rgba); | 377 g_free(rgba); |
| 377 | 378 |
| 378 return params; | 379 return params; |
| 379 } | 380 } |
| 380 | 381 |
| 382 views::LinuxUI::NonClientMiddleClickAction GetDefaultMiddleClickAction() { |
| 383 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 384 switch (base::nix::GetDesktopEnvironment(env.get())) { |
| 385 case base::nix::DESKTOP_ENVIRONMENT_KDE4: |
| 386 // Starting with KDE 4.4, windows' titlebars can be dragged with the |
| 387 // middle mouse button to create tab groups. We don't support that in |
| 388 // Chrome, but at least avoid lowering windows in response to middle |
| 389 // clicks to avoid surprising users who expect the KDE behavior. |
| 390 return views::LinuxUI::MIDDLE_CLICK_ACTION_NONE; |
| 391 default: |
| 392 return views::LinuxUI::MIDDLE_CLICK_ACTION_LOWER; |
| 393 } |
| 394 } |
| 395 |
| 381 } // namespace | 396 } // namespace |
| 382 | 397 |
| 383 Gtk2UI::Gtk2UI() : middle_click_action_(MIDDLE_CLICK_ACTION_LOWER) { | 398 Gtk2UI::Gtk2UI() : middle_click_action_(GetDefaultMiddleClickAction()) { |
| 384 GtkInitFromCommandLine(*CommandLine::ForCurrentProcess()); | 399 GtkInitFromCommandLine(*CommandLine::ForCurrentProcess()); |
| 385 } | 400 } |
| 386 | 401 |
| 387 void Gtk2UI::Initialize() { | 402 void Gtk2UI::Initialize() { |
| 388 signals_.reset(new Gtk2SignalRegistrar); | 403 signals_.reset(new Gtk2SignalRegistrar); |
| 389 | 404 |
| 390 // Create our fake widgets. | 405 // Create our fake widgets. |
| 391 fake_window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL); | 406 fake_window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
| 392 fake_frame_ = chrome_gtk_frame_new(); | 407 fake_frame_ = chrome_gtk_frame_new(); |
| 393 fake_label_.Own(gtk_label_new("")); | 408 fake_label_.Own(gtk_label_new("")); |
| (...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1343 ClearAllThemeData(); | 1358 ClearAllThemeData(); |
| 1344 LoadGtkValues(); | 1359 LoadGtkValues(); |
| 1345 NativeThemeGtk2::instance()->NotifyObservers(); | 1360 NativeThemeGtk2::instance()->NotifyObservers(); |
| 1346 } | 1361 } |
| 1347 | 1362 |
| 1348 } // namespace libgtk2ui | 1363 } // namespace libgtk2ui |
| 1349 | 1364 |
| 1350 views::LinuxUI* BuildGtk2UI() { | 1365 views::LinuxUI* BuildGtk2UI() { |
| 1351 return new libgtk2ui::Gtk2UI; | 1366 return new libgtk2ui::Gtk2UI; |
| 1352 } | 1367 } |
| OLD | NEW |