| 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/libgtkui/gtk_ui.h" | 5 #include "chrome/browser/ui/libgtkui/gtk_ui.h" |
| 6 | 6 |
| 7 #include <X11/Xcursor/Xcursor.h> |
| 8 #include <dlfcn.h> |
| 7 #include <math.h> | 9 #include <math.h> |
| 8 #include <pango/pango.h> | 10 #include <pango/pango.h> |
| 9 #include <X11/Xcursor/Xcursor.h> | |
| 10 | 11 |
| 11 #include <cmath> | 12 #include <cmath> |
| 12 #include <set> | 13 #include <set> |
| 13 #include <utility> | 14 #include <utility> |
| 14 | 15 |
| 15 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 16 #include "base/debug/leak_annotations.h" | 17 #include "base/debug/leak_annotations.h" |
| 17 #include "base/environment.h" | 18 #include "base/environment.h" |
| 18 #include "base/i18n/rtl.h" | 19 #include "base/i18n/rtl.h" |
| 19 #include "base/logging.h" | 20 #include "base/logging.h" |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 HSL border; | 370 HSL border; |
| 370 SkColorToHSL(default_color, &border); | 371 SkColorToHSL(default_color, &border); |
| 371 border.l = l; | 372 border.l = l; |
| 372 return HSLToSkColor(border, a * 0xff); | 373 return HSLToSkColor(border, a * 0xff); |
| 373 } | 374 } |
| 374 #endif | 375 #endif |
| 375 | 376 |
| 376 } // namespace | 377 } // namespace |
| 377 | 378 |
| 378 GtkUi::GtkUi() : middle_click_action_(GetDefaultMiddleClickAction()) { | 379 GtkUi::GtkUi() : middle_click_action_(GetDefaultMiddleClickAction()) { |
| 380 #if GTK_MAJOR_VERSION > 2 |
| 381 // Force Gtk to use Xwayland if it would have used wayland. libgtkui assumes |
| 382 // the use of X11 (eg. X11InputMethodContextImplGtk) and will crash under |
| 383 // other backends. |
| 384 // TODO(thomasanderson): Change this logic once Wayland support is added. |
| 385 static auto* _gdk_set_allowed_backends = |
| 386 reinterpret_cast<void (*)(const gchar*)>( |
| 387 dlsym(GetGdkSharedLibrary(), "gdk_set_allowed_backends")); |
| 388 if (GtkVersionCheck(3, 10)) |
| 389 DCHECK(_gdk_set_allowed_backends); |
| 390 if (_gdk_set_allowed_backends) |
| 391 _gdk_set_allowed_backends("x11"); |
| 392 #endif |
| 379 GtkInitFromCommandLine(*base::CommandLine::ForCurrentProcess()); | 393 GtkInitFromCommandLine(*base::CommandLine::ForCurrentProcess()); |
| 380 #if GTK_MAJOR_VERSION == 2 | 394 #if GTK_MAJOR_VERSION == 2 |
| 381 native_theme_ = NativeThemeGtk2::instance(); | 395 native_theme_ = NativeThemeGtk2::instance(); |
| 382 fake_window_ = chrome_gtk_frame_new(); | 396 fake_window_ = chrome_gtk_frame_new(); |
| 383 gtk_widget_realize(fake_window_); // Is this necessary? | 397 gtk_widget_realize(fake_window_); // Is this necessary? |
| 384 #elif GTK_MAJOR_VERSION == 3 | 398 #elif GTK_MAJOR_VERSION == 3 |
| 385 native_theme_ = NativeThemeGtk3::instance(); | 399 native_theme_ = NativeThemeGtk3::instance(); |
| 386 (void)fake_window_; // Silence the unused warning. | 400 (void)fake_window_; // Silence the unused warning. |
| 387 #else | 401 #else |
| 388 #error "Unsupported GTK version" | 402 #error "Unsupported GTK version" |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 | 1041 |
| 1028 float GtkUi::GetDeviceScaleFactor() const { | 1042 float GtkUi::GetDeviceScaleFactor() const { |
| 1029 return device_scale_factor_; | 1043 return device_scale_factor_; |
| 1030 } | 1044 } |
| 1031 | 1045 |
| 1032 } // namespace libgtkui | 1046 } // namespace libgtkui |
| 1033 | 1047 |
| 1034 views::LinuxUI* BuildGtkUi() { | 1048 views::LinuxUI* BuildGtkUi() { |
| 1035 return new libgtkui::GtkUi; | 1049 return new libgtkui::GtkUi; |
| 1036 } | 1050 } |
| OLD | NEW |