forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add fallback Linux UI for when GTK 3.20 isn't available
The minimum required version of GTK is 3.20 after [1] since all supported distros have it available. However, we still have some infra without GTK 3.20, so this CL adds a fallback codepath for when GTK 3.20 isn't available. This CL incidentally makes GTK an optional dependency in Chrome. For now, the manual dependency will be kept in the deb/rpm packages. [1] https://crrev.com/1104801 R=thestig,sky Change-Id: I6f30b7298a13a75602b98547bdfbf9dbc6bab99b Bug: b/270232634 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4295455 Reviewed-by: Scott Violet <sky@chromium.org> Commit-Queue: Thomas Anderson <thomasanderson@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Cr-Commit-Position: refs/heads/main@{#1111248}
- Loading branch information
1 parent
c8ecb5c
commit 38f7473
Showing
14 changed files
with
385 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "ui/linux/fallback_linux_ui.h" | ||
|
||
#include "base/time/time.h" | ||
#include "ui/events/keycodes/dom/dom_keyboard_layout_map.h" | ||
#include "ui/gfx/color_palette.h" | ||
#include "ui/gfx/geometry/size.h" | ||
#include "ui/gfx/image/image.h" | ||
#include "ui/gfx/platform_font.h" | ||
#include "ui/native_theme/native_theme.h" | ||
#include "ui/shell_dialogs/select_file_policy.h" | ||
#include "ui/views/controls/textfield/textfield.h" | ||
|
||
namespace ui { | ||
|
||
FallbackLinuxUi::FallbackLinuxUi() { | ||
gfx::FontRenderParamsQuery query; | ||
query.pixel_size = gfx::PlatformFont::kDefaultBaseFontSize; | ||
query.style = gfx::Font::NORMAL; | ||
query.weight = gfx::Font::Weight::NORMAL; | ||
query.device_scale_factor = GetDeviceScaleFactor(); | ||
default_font_render_params_ = | ||
gfx::GetFontRenderParams(query, &default_font_family_); | ||
} | ||
|
||
FallbackLinuxUi::~FallbackLinuxUi() = default; | ||
|
||
std::unique_ptr<ui::LinuxInputMethodContext> | ||
FallbackLinuxUi::CreateInputMethodContext( | ||
ui::LinuxInputMethodContextDelegate* delegate) const { | ||
// Fallback to FakeInputMethodContext. | ||
return nullptr; | ||
} | ||
|
||
gfx::FontRenderParams FallbackLinuxUi::GetDefaultFontRenderParams() const { | ||
return default_font_render_params_; | ||
} | ||
|
||
void FallbackLinuxUi::GetDefaultFontDescription( | ||
std::string* family_out, | ||
int* size_pixels_out, | ||
int* style_out, | ||
int* weight_out, | ||
gfx::FontRenderParams* params_out) const { | ||
*family_out = default_font_family_; | ||
*size_pixels_out = gfx::PlatformFont::kDefaultBaseFontSize; | ||
*style_out = gfx::Font::NORMAL; | ||
*weight_out = static_cast<int>(gfx::Font::Weight::NORMAL); | ||
*params_out = GetDefaultFontRenderParams(); | ||
} | ||
|
||
ui::SelectFileDialog* FallbackLinuxUi::CreateSelectFileDialog( | ||
void* listener, | ||
std::unique_ptr<ui::SelectFilePolicy> policy) const { | ||
// The toolkit select file dialog is a last choice used only when | ||
// the freedesktop portal interface isn't available and the desktop | ||
// isn't KDE. If neither condition is met, a dialog won't be created. | ||
NOTIMPLEMENTED(); | ||
return nullptr; | ||
} | ||
|
||
bool FallbackLinuxUi::Initialize() { | ||
return true; | ||
} | ||
|
||
bool FallbackLinuxUi::GetColor(int id, | ||
SkColor* color, | ||
bool use_custom_frame) const { | ||
return false; | ||
} | ||
|
||
bool FallbackLinuxUi::GetDisplayProperty(int id, int* result) const { | ||
return false; | ||
} | ||
|
||
void FallbackLinuxUi::GetFocusRingColor(SkColor* color) const {} | ||
|
||
void FallbackLinuxUi::GetActiveSelectionBgColor(SkColor* color) const {} | ||
|
||
void FallbackLinuxUi::GetActiveSelectionFgColor(SkColor* color) const {} | ||
|
||
void FallbackLinuxUi::GetInactiveSelectionBgColor(SkColor* color) const {} | ||
|
||
void FallbackLinuxUi::GetInactiveSelectionFgColor(SkColor* color) const {} | ||
|
||
base::TimeDelta FallbackLinuxUi::GetCursorBlinkInterval() const { | ||
return views::Textfield::GetCaretBlinkInterval(); | ||
} | ||
|
||
gfx::Image FallbackLinuxUi::GetIconForContentType( | ||
const std::string& content_type, | ||
int size, | ||
float scale) const { | ||
// Fallback to using generic icons. | ||
return gfx::Image(); | ||
} | ||
|
||
LinuxUi::WindowFrameAction FallbackLinuxUi::GetWindowFrameAction( | ||
WindowFrameActionSource source) { | ||
switch (source) { | ||
case WindowFrameActionSource::kDoubleClick: | ||
return WindowFrameAction::kToggleMaximize; | ||
case WindowFrameActionSource::kMiddleClick: | ||
return WindowFrameAction::kNone; | ||
case WindowFrameActionSource::kRightClick: | ||
return WindowFrameAction::kMenu; | ||
} | ||
} | ||
|
||
float FallbackLinuxUi::GetDeviceScaleFactor() const { | ||
return 1.0f; | ||
} | ||
|
||
bool FallbackLinuxUi::PreferDarkTheme() const { | ||
return false; | ||
} | ||
|
||
bool FallbackLinuxUi::AnimationsEnabled() const { | ||
return true; | ||
} | ||
|
||
void FallbackLinuxUi::AddWindowButtonOrderObserver( | ||
ui::WindowButtonOrderObserver* observer) {} | ||
|
||
void FallbackLinuxUi::RemoveWindowButtonOrderObserver( | ||
ui::WindowButtonOrderObserver* observer) {} | ||
|
||
std::unique_ptr<ui::NavButtonProvider> | ||
FallbackLinuxUi::CreateNavButtonProvider() { | ||
return nullptr; | ||
} | ||
|
||
ui::WindowFrameProvider* FallbackLinuxUi::GetWindowFrameProvider( | ||
bool solid_frame) { | ||
return nullptr; | ||
} | ||
|
||
base::flat_map<std::string, std::string> | ||
FallbackLinuxUi::GetKeyboardLayoutMap() { | ||
return ui::GenerateDomKeyboardLayoutMap(); | ||
} | ||
|
||
std::string FallbackLinuxUi::GetCursorThemeName() { | ||
// This is only used on X11 where QT obtains the cursor theme from XSettings. | ||
// However, ui/base/x/x11_cursor_loader.cc already handles this. | ||
return std::string(); | ||
} | ||
|
||
int FallbackLinuxUi::GetCursorThemeSize() { | ||
// This is only used on X11 where QT obtains the cursor size from XSettings. | ||
// However, ui/base/x/x11_cursor_loader.cc already handles this. | ||
return 0; | ||
} | ||
|
||
ui::NativeTheme* FallbackLinuxUi::GetNativeTheme() const { | ||
return ui::NativeTheme::GetInstanceForNativeUi(); | ||
} | ||
|
||
bool FallbackLinuxUi::GetTextEditCommandsForEvent( | ||
const ui::Event& event, | ||
std::vector<ui::TextEditCommandAuraLinux>* commands) { | ||
return false; | ||
} | ||
|
||
#if BUILDFLAG(ENABLE_PRINTING) | ||
printing::PrintDialogLinuxInterface* FallbackLinuxUi::CreatePrintDialog( | ||
printing::PrintingContextLinux* context) { | ||
// A print dialog won't be created. Chrome's print dialog (Ctrl-P) | ||
// should be used instead of the system (Ctrl-Shift-P) dialog. | ||
NOTIMPLEMENTED(); | ||
return nullptr; | ||
} | ||
|
||
gfx::Size FallbackLinuxUi::GetPdfPaperSize( | ||
printing::PrintingContextLinux* context) { | ||
return gfx::Size(); | ||
} | ||
#endif | ||
|
||
} // namespace ui |
Oops, something went wrong.