Commit d0318315 authored by thomasanderson's avatar thomasanderson Committed by Commit bot

Linux: Add support for custom cursor themes

Use the cursor theme that GTK tells us is the default,
instead of always using the default white cursor theme.

BUG=377525

Review-Url: https://codereview.chromium.org/2135353002
Cr-Commit-Position: refs/heads/master@{#405261}
parent 2ea1df28
......@@ -6,6 +6,7 @@
#include <math.h>
#include <pango/pango.h>
#include <X11/Xcursor/Xcursor.h>
#include <set>
#include <utility>
......@@ -49,6 +50,7 @@
#include "ui/gfx/image/image_skia_source.h"
#include "ui/gfx/skbitmap_operations.h"
#include "ui/gfx/skia_util.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/native_theme/native_theme.h"
#include "ui/resources/grit/ui_resources.h"
#include "ui/views/controls/button/blue_button.h"
......@@ -508,9 +510,10 @@ void Gtk2UI::Initialize() {
G_CALLBACK(OnThemeChanged),
this);
LoadGtkValues();
LoadCursorTheme();
#if defined(ENABLE_BASIC_PRINTING)
printing::PrintingContextLinux::SetCreatePrintDialogFunction(
&PrintDialogGtk2::CreatePrintDialog);
......@@ -996,6 +999,24 @@ void Gtk2UI::LoadGtkValues() {
theme->GetSystemColor(ui::NativeTheme::kColorId_ThrobberWaitingColor);
}
void Gtk2UI::LoadCursorTheme() {
GtkSettings* settings = gtk_settings_get_default();
gchar* theme = nullptr;
gint size = 0;
g_object_get(settings,
"gtk-cursor-theme-name", &theme,
"gtk-cursor-theme-size", &size,
nullptr);
if (theme)
XcursorSetTheme(gfx::GetXDisplay(), theme);
if (size)
XcursorSetDefaultSize(gfx::GetXDisplay(), size);
g_free(theme);
}
void Gtk2UI::UpdateMaterialDesignColors() {
// TODO(varkha): This should be merged back into LoadGtkValues() once Material
// Design is on unconditionally.
......
......@@ -134,6 +134,9 @@ class Gtk2UI : public views::LinuxUI {
// ThemeService interface and the colors we send to webkit.
void LoadGtkValues();
// Initialize the Xcursor theme and size with the GTK theme and size.
void LoadCursorTheme();
// Updates colors if necessary after possible modification of command line.
// TODO(varkha): This should not be necessary once Material Design is on
// unconditionally.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment