#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "ui/gtk/gtk_ui.h"
#include <cairo.h>
#include <pango/pango.h>
#include <cmath>
#include <memory>
#include <optional>
#include <set>
#include <unordered_set>
#include <utility>
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/containers/flat_map.h"
#include "base/debug/leak_annotations.h"
#include "base/environment.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/nix/mime_util_xdg.h"
#include "base/nix/xdg_util.h"
#include "base/numerics/safe_conversions.h"
#include "base/observer_list.h"
#include "base/strings/string_split.h"
#include "chrome/browser/themes/theme_properties.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkShader.h"
#include "ui/base/glib/glib_cast.h"
#include "ui/base/ime/input_method.h"
#include "ui/base/ime/linux/fake_input_method_context.h"
#include "ui/base/ime/linux/linux_input_method_context.h"
#include "ui/base/ime/text_input_flags.h"
#include "ui/base/ozone_buildflags.h"
#include "ui/base/ui_base_switches.h"
#include "ui/color/color_id.h"
#include "ui/color/color_provider.h"
#include "ui/color/color_provider_key.h"
#include "ui/color/color_provider_manager.h"
#include "ui/display/display.h"
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/keycodes/dom/dom_keyboard_layout_manager.h"
#include "ui/events/keycodes/dom/keycode_converter.h"
#include "ui/gfx/animation/animation.h"
#include "ui/gfx/font_render_params.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/skia_conversions.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia_rep.h"
#include "ui/gfx/image/image_skia_source.h"
#include "ui/gfx/skbitmap_operations.h"
#include "ui/gtk/gtk_color_mixers.h"
#include "ui/gtk/gtk_compat.h"
#include "ui/gtk/gtk_key_bindings_handler.h"
#include "ui/gtk/gtk_ui_platform.h"
#include "ui/gtk/gtk_ui_platform_stub.h"
#include "ui/gtk/gtk_util.h"
#include "ui/gtk/input_method_context_impl_gtk.h"
#include "ui/gtk/native_theme_gtk.h"
#include "ui/gtk/nav_button_provider_gtk.h"
#include "ui/gtk/printing/print_dialog_gtk.h"
#include "ui/gtk/printing/printing_gtk_util.h"
#include "ui/gtk/select_file_dialog_linux_gtk.h"
#include "ui/gtk/settings_provider_gtk.h"
#include "ui/gtk/window_frame_provider_gtk.h"
#include "ui/linux/cursor_theme_manager_observer.h"
#include "ui/linux/device_scale_factor_observer.h"
#include "ui/linux/linux_ui.h"
#include "ui/linux/linux_ui_delegate.h"
#include "ui/linux/nav_button_provider.h"
#include "ui/linux/window_button_order_observer.h"
#include "ui/native_theme/native_theme.h"
#include "ui/ozone/public/ozone_platform.h"
#include "ui/shell_dialogs/select_file_dialog.h"
#include "ui/shell_dialogs/select_file_policy.h"
#include "ui/views/window/window_button_order_provider.h"
#if BUILDFLAG(IS_OZONE_WAYLAND)
#include "ui/gtk/wayland/gtk_ui_platform_wayland.h"
#endif
#if BUILDFLAG(IS_OZONE_X11)
#include "ui/gtk/x/gtk_ui_platform_x11.h"
#endif
namespace gtk {
namespace {
const GtkUi* g_gtk_ui = …;
const double kDefaultDPI = …;
int indicators_count;
const char kUnknownContentType[] = …;
gfx::FontRenderParams GetGtkFontRenderParams() { … }
std::unique_ptr<GtkUiPlatform> CreateGtkUiPlatform(ui::LinuxUiBackend backend) { … }
double FontScale() { … }
}
GtkUi::GtkUi() : … { … }
GtkUi::~GtkUi() { … }
GtkUiPlatform* GtkUi::GetPlatform() { … }
bool GtkUi::Initialize() { … }
void GtkUi::InitializeFontSettings() { … }
ui::NativeTheme* GtkUi::GetNativeTheme() const { … }
bool GtkUi::GetColor(int id, SkColor* color, bool use_custom_frame) const { … }
bool GtkUi::GetDisplayProperty(int id, int* result) const { … }
void GtkUi::GetFocusRingColor(SkColor* color) const { … }
void GtkUi::GetActiveSelectionBgColor(SkColor* color) const { … }
void GtkUi::GetActiveSelectionFgColor(SkColor* color) const { … }
void GtkUi::GetInactiveSelectionBgColor(SkColor* color) const { … }
void GtkUi::GetInactiveSelectionFgColor(SkColor* color) const { … }
base::TimeDelta GtkUi::GetCursorBlinkInterval() const { … }
gfx::Image GtkUi::GetIconForContentType(const std::string& content_type,
int dip_size,
float scale) const { … }
void GtkUi::SetWindowButtonOrdering(
const std::vector<views::FrameButton>& leading_buttons,
const std::vector<views::FrameButton>& trailing_buttons) { … }
void GtkUi::SetWindowFrameAction(WindowFrameActionSource source,
WindowFrameAction action) { … }
std::unique_ptr<ui::LinuxInputMethodContext> GtkUi::CreateInputMethodContext(
ui::LinuxInputMethodContextDelegate* delegate) const { … }
gfx::FontRenderParams GtkUi::GetDefaultFontRenderParams() { … }
ui::SelectFileDialog* GtkUi::CreateSelectFileDialog(
void* listener,
std::unique_ptr<ui::SelectFilePolicy> policy) const { … }
ui::LinuxUi::WindowFrameAction GtkUi::GetWindowFrameAction(
WindowFrameActionSource source) { … }
bool GtkUi::PreferDarkTheme() const { … }
void GtkUi::SetDarkTheme(bool dark) { … }
void GtkUi::SetAccentColor(std::optional<SkColor> accent_color) { … }
bool GtkUi::AnimationsEnabled() const { … }
void GtkUi::AddWindowButtonOrderObserver(
ui::WindowButtonOrderObserver* observer) { … }
void GtkUi::RemoveWindowButtonOrderObserver(
ui::WindowButtonOrderObserver* observer) { … }
std::unique_ptr<ui::NavButtonProvider> GtkUi::CreateNavButtonProvider() { … }
ui::WindowFrameProvider* GtkUi::GetWindowFrameProvider(bool solid_frame,
bool tiled) { … }
static struct { … } kDeadKeyMapping[] = …;
base::flat_map<std::string, std::string> GtkUi::GetKeyboardLayoutMap() { … }
std::string GtkUi::GetCursorThemeName() { … }
int GtkUi::GetCursorThemeSize() { … }
bool GtkUi::GetTextEditCommandsForEvent(
const ui::Event& event,
int text_flags,
std::vector<ui::TextEditCommandAuraLinux>* commands) { … }
#if BUILDFLAG(ENABLE_PRINTING)
printing::PrintDialogLinuxInterface* GtkUi::CreatePrintDialog(
printing::PrintingContextLinux* context) { … }
gfx::Size GtkUi::GetPdfPaperSize(printing::PrintingContextLinux* context) { … }
#endif
void GtkUi::OnThemeChanged(GtkSettings* settings, GtkParamSpec* param) { … }
void GtkUi::OnCursorThemeNameChanged(GtkSettings* settings,
GtkParamSpec* param) { … }
void GtkUi::OnCursorThemeSizeChanged(GtkSettings* settings,
GtkParamSpec* param) { … }
void GtkUi::OnEnableAnimationsChanged(GtkSettings* settings,
GtkParamSpec* param) { … }
void GtkUi::OnGtkXftDpiChanged(GtkSettings* settings, GParamSpec* param) { … }
void GtkUi::OnScreenResolutionChanged(GdkScreen* screen, GParamSpec* param) { … }
void GtkUi::OnMonitorChanged(GdkMonitor* monitor, GParamSpec* param) { … }
void GtkUi::OnMonitorAdded(GdkDisplay* display, GdkMonitor* monitor) { … }
void GtkUi::OnMonitorRemoved(GdkDisplay* display, GdkMonitor* monitor) { … }
void GtkUi::OnMonitorsChanged(GListModel* list,
guint position,
guint removed,
guint added) { … }
void GtkUi::LoadGtkValues() { … }
void GtkUi::UpdateColors() { … }
void GtkUi::TrackMonitor(GdkMonitor* monitor) { … }
display::DisplayConfig GtkUi::GetDisplayConfig() const { … }
void GtkUi::AddGtkNativeColorMixer(ui::ColorProvider* provider,
const ui::ColorProviderKey& key) { … }
void GtkUi::UpdateDeviceScaleFactor() { … }
}