Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(370)

Side by Side Diff: chrome/browser/ui/libgtkui/gtk_ui.h

Issue 2963033002: Linux UI: Dynamically respond to changes in the scale factor (Closed)
Patch Set: LinuxUI may not exist in test scenarios Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/libgtkui/gtk_ui.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #ifndef CHROME_BROWSER_UI_LIBGTKUI_GTK_UI_H_ 5 #ifndef CHROME_BROWSER_UI_LIBGTKUI_GTK_UI_H_
6 #define CHROME_BROWSER_UI_LIBGTKUI_GTK_UI_H_ 6 #define CHROME_BROWSER_UI_LIBGTKUI_GTK_UI_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/observer_list.h" 14 #include "base/observer_list.h"
15 #include "chrome/browser/ui/libgtkui/gtk_signal.h" 15 #include "chrome/browser/ui/libgtkui/gtk_signal.h"
16 #include "chrome/browser/ui/libgtkui/libgtkui_export.h" 16 #include "chrome/browser/ui/libgtkui/libgtkui_export.h"
17 #include "ui/gfx/color_utils.h" 17 #include "ui/gfx/color_utils.h"
18 #include "ui/views/linux_ui/linux_ui.h" 18 #include "ui/views/linux_ui/linux_ui.h"
19 #include "ui/views/window/frame_buttons.h" 19 #include "ui/views/window/frame_buttons.h"
20 20
21 typedef struct _GParamSpec GParamSpec;
21 typedef struct _GtkStyle GtkStyle; 22 typedef struct _GtkStyle GtkStyle;
22 typedef struct _GtkWidget GtkWidget; 23 typedef struct _GtkWidget GtkWidget;
23 24
24 namespace libgtkui { 25 namespace libgtkui {
25 class Gtk2KeyBindingsHandler; 26 class Gtk2KeyBindingsHandler;
26 class GConfListener; 27 class GConfListener;
28 class DeviceScaleFactorObserver;
27 29
28 // Interface to GTK2 desktop features. 30 // Interface to GTK2 desktop features.
29 // 31 //
30 class GtkUi : public views::LinuxUI { 32 class GtkUi : public views::LinuxUI {
31 public: 33 public:
32 GtkUi(); 34 GtkUi();
33 ~GtkUi() override; 35 ~GtkUi() override;
34 36
35 typedef base::Callback<ui::NativeTheme*(aura::Window* window)> 37 typedef base::Callback<ui::NativeTheme*(aura::Window* window)>
36 NativeThemeGetter; 38 NativeThemeGetter;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 std::unique_ptr<views::Border> CreateNativeBorder( 92 std::unique_ptr<views::Border> CreateNativeBorder(
91 views::LabelButton* owning_button, 93 views::LabelButton* owning_button,
92 std::unique_ptr<views::LabelButtonBorder> border) override; 94 std::unique_ptr<views::LabelButtonBorder> border) override;
93 void AddWindowButtonOrderObserver( 95 void AddWindowButtonOrderObserver(
94 views::WindowButtonOrderObserver* observer) override; 96 views::WindowButtonOrderObserver* observer) override;
95 void RemoveWindowButtonOrderObserver( 97 void RemoveWindowButtonOrderObserver(
96 views::WindowButtonOrderObserver* observer) override; 98 views::WindowButtonOrderObserver* observer) override;
97 bool UnityIsRunning() override; 99 bool UnityIsRunning() override;
98 NonClientMiddleClickAction GetNonClientMiddleClickAction() override; 100 NonClientMiddleClickAction GetNonClientMiddleClickAction() override;
99 void NotifyWindowManagerStartupComplete() override; 101 void NotifyWindowManagerStartupComplete() override;
102 void AddDeviceScaleFactorObserver(
103 views::DeviceScaleFactorObserver* observer) override;
104 void RemoveDeviceScaleFactorObserver(
105 views::DeviceScaleFactorObserver* observer) override;
100 106
101 // ui::TextEditKeybindingDelegate: 107 // ui::TextEditKeybindingDelegate:
102 bool MatchEvent(const ui::Event& event, 108 bool MatchEvent(const ui::Event& event,
103 std::vector<ui::TextEditCommandAuraLinux>* commands) override; 109 std::vector<ui::TextEditCommandAuraLinux>* commands) override;
104 110
105 // ui::Views::LinuxUI: 111 // ui::Views::LinuxUI:
106 void UpdateDeviceScaleFactor() override; 112 void UpdateDeviceScaleFactor() override;
107 float GetDeviceScaleFactor() const override; 113 float GetDeviceScaleFactor() const override;
108 114
109 private: 115 private:
110 typedef std::map<int, SkColor> ColorMap; 116 typedef std::map<int, SkColor> ColorMap;
111 typedef std::map<int, color_utils::HSL> TintMap; 117 typedef std::map<int, color_utils::HSL> TintMap;
112 118
119 CHROMEG_CALLBACK_1(GtkUi,
120 void,
121 OnDeviceScaleFactorMaybeChanged,
122 void*,
123 GParamSpec*);
124
113 // This method returns the colors webkit will use for the scrollbars. When no 125 // This method returns the colors webkit will use for the scrollbars. When no
114 // colors are specified by the GTK+ theme, this function averages of the 126 // colors are specified by the GTK+ theme, this function averages of the
115 // thumb part and of the track colors. 127 // thumb part and of the track colors.
116 void SetScrollbarColors(); 128 void SetScrollbarColors();
117 129
118 // Extracts colors and tints from the GTK theme, both for the 130 // Extracts colors and tints from the GTK theme, both for the
119 // ThemeService interface and the colors we send to webkit. 131 // ThemeService interface and the colors we send to webkit.
120 void LoadGtkValues(); 132 void LoadGtkValues();
121 133
122 // Sets the Xcursor theme and size with the GTK theme and size. 134 // Sets the Xcursor theme and size with the GTK theme and size.
123 void UpdateCursorTheme(); 135 void UpdateCursorTheme();
124 136
125 // Updates |default_font_*|. 137 // Updates |default_font_*|.
126 void UpdateDefaultFont(); 138 void UpdateDefaultFont();
127 139
128 // Gets a ChromeGtkFrame theme color; returns true on success. No-op on gtk3. 140 // Gets a ChromeGtkFrame theme color; returns true on success. No-op on gtk3.
129 bool GetChromeStyleColor(const char* sytle_property, 141 bool GetChromeStyleColor(const char* sytle_property,
130 SkColor* ret_color) const; 142 SkColor* ret_color) const;
131 143
144 float GetRawDeviceScaleFactor();
145
132 ui::NativeTheme* native_theme_; 146 ui::NativeTheme* native_theme_;
133 147
134 // A GtkWindow object with the class "ChromeGtkFrame". 148 // On Gtk2, A GtkWindow object with the class "ChromeGtkFrame". On
149 // Gtk3, a regular GtkWindow.
135 GtkWidget* fake_window_; 150 GtkWidget* fake_window_;
136 151
137 // Colors calculated by LoadGtkValues() that are given to the 152 // Colors calculated by LoadGtkValues() that are given to the
138 // caller while |use_gtk_| is true. 153 // caller while |use_gtk_| is true.
139 ColorMap colors_; 154 ColorMap colors_;
140 155
141 // Colors that we pass to WebKit. These are generated each time the theme 156 // Colors that we pass to WebKit. These are generated each time the theme
142 // changes. 157 // changes.
143 SkColor focus_ring_color_; 158 SkColor focus_ring_color_;
144 SkColor thumb_active_color_; 159 SkColor thumb_active_color_;
(...skipping 19 matching lines...) Expand all
164 #endif // defined(USE_GCONF) 179 #endif // defined(USE_GCONF)
165 180
166 // If either of these vectors are non-empty, they represent the current 181 // If either of these vectors are non-empty, they represent the current
167 // window button configuration. 182 // window button configuration.
168 std::vector<views::FrameButton> leading_buttons_; 183 std::vector<views::FrameButton> leading_buttons_;
169 std::vector<views::FrameButton> trailing_buttons_; 184 std::vector<views::FrameButton> trailing_buttons_;
170 185
171 std::unique_ptr<Gtk2KeyBindingsHandler> key_bindings_handler_; 186 std::unique_ptr<Gtk2KeyBindingsHandler> key_bindings_handler_;
172 187
173 // Objects to notify when the window frame button order changes. 188 // Objects to notify when the window frame button order changes.
174 base::ObserverList<views::WindowButtonOrderObserver> observer_list_; 189 base::ObserverList<views::WindowButtonOrderObserver>
190 window_button_order_observer_list_;
191
192 // Objects to notify when the device scale factor changes.
193 base::ObserverList<views::DeviceScaleFactorObserver>
194 device_scale_factor_observer_list_;
175 195
176 // Whether we should lower the window on a middle click to the non client 196 // Whether we should lower the window on a middle click to the non client
177 // area. 197 // area.
178 NonClientMiddleClickAction middle_click_action_; 198 NonClientMiddleClickAction middle_click_action_;
179 199
180 // Used to override the native theme for a window. If no override is provided 200 // Used to override the native theme for a window. If no override is provided
181 // or the callback returns nullptr, GtkUi will default to a NativeThemeGtk2 201 // or the callback returns nullptr, GtkUi will default to a NativeThemeGtk2
182 // instance. 202 // instance.
183 NativeThemeGetter native_theme_overrider_; 203 NativeThemeGetter native_theme_overrider_;
184 204
185 float device_scale_factor_ = 1.0f; 205 float device_scale_factor_ = 1.0f;
186 206
187 DISALLOW_COPY_AND_ASSIGN(GtkUi); 207 DISALLOW_COPY_AND_ASSIGN(GtkUi);
188 }; 208 };
189 209
190 } // namespace libgtkui 210 } // namespace libgtkui
191 211
192 // Access point to the GTK2 desktop system. This should be the only symbol that 212 // Access point to the GTK2 desktop system. This should be the only symbol that
193 // is exported in the library; everything else should be used through the 213 // is exported in the library; everything else should be used through the
194 // interface, because eventually this .so will be loaded through dlopen at 214 // interface, because eventually this .so will be loaded through dlopen at
195 // runtime so our main binary can conditionally load GTK2 or GTK3 or EFL or 215 // runtime so our main binary can conditionally load GTK2 or GTK3 or EFL or
196 // QT or whatever. 216 // QT or whatever.
197 LIBGTKUI_EXPORT views::LinuxUI* BuildGtkUi(); 217 LIBGTKUI_EXPORT views::LinuxUI* BuildGtkUi();
198 218
199 #endif // CHROME_BROWSER_UI_LIBGTKUI_GTK_UI_H_ 219 #endif // CHROME_BROWSER_UI_LIBGTKUI_GTK_UI_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/libgtkui/gtk_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698