| 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> | 7 #include <X11/Xcursor/Xcursor.h> |
| 8 #include <dlfcn.h> | 8 #include <dlfcn.h> |
| 9 #include <math.h> | 9 #include <math.h> |
| 10 #include <pango/pango.h> | 10 #include <pango/pango.h> |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 is_blue_ ? "GtkButton#button.default.suggested-action" | 170 is_blue_ ? "GtkButton#button.default.suggested-action" |
| 171 : "GtkButton#button"); | 171 : "GtkButton#button"); |
| 172 GtkStateFlags state_flags = StateToStateFlags(state_); | 172 GtkStateFlags state_flags = StateToStateFlags(state_); |
| 173 if (focus_) { | 173 if (focus_) { |
| 174 state_flags = | 174 state_flags = |
| 175 static_cast<GtkStateFlags>(state_flags | GTK_STATE_FLAG_FOCUSED); | 175 static_cast<GtkStateFlags>(state_flags | GTK_STATE_FLAG_FOCUSED); |
| 176 } | 176 } |
| 177 gtk_style_context_set_state(context, state_flags); | 177 gtk_style_context_set_state(context, state_flags); |
| 178 gtk_render_background(context, cr, 0, 0, width, height); | 178 gtk_render_background(context, cr, 0, 0, width, height); |
| 179 gtk_render_frame(context, cr, 0, 0, width, height); | 179 gtk_render_frame(context, cr, 0, 0, width, height); |
| 180 if (focus_) | 180 if (focus_) { |
| 181 gtk_render_focus(context, cr, 0, 0, width, height); | 181 gfx::Rect focus_rect(width, height); |
| 182 |
| 183 if (!GtkVersionCheck(3, 14)) { |
| 184 gint focus_pad; |
| 185 gtk_style_context_get_style(context, "focus-padding", &focus_pad, |
| 186 nullptr); |
| 187 focus_rect.Inset(focus_pad, focus_pad); |
| 188 |
| 189 if (state_ == ui::NativeTheme::kPressed) { |
| 190 gint child_displacement_x, child_displacement_y; |
| 191 gboolean displace_focus; |
| 192 gtk_style_context_get_style( |
| 193 context, "child-displacement-x", &child_displacement_x, |
| 194 "child-displacement-y", &child_displacement_y, "displace-focus", |
| 195 &displace_focus, nullptr); |
| 196 if (displace_focus) |
| 197 focus_rect.Offset(child_displacement_x, child_displacement_y); |
| 198 } |
| 199 } |
| 200 |
| 201 if (!GtkVersionCheck(3, 20)) { |
| 202 GtkBorder border; |
| 203 gtk_style_context_get_border(context, state_flags, &border); |
| 204 focus_rect.Inset(border.left, border.top, border.right, border.bottom); |
| 205 } |
| 206 |
| 207 gtk_render_focus(context, cr, focus_rect.x(), focus_rect.y(), |
| 208 focus_rect.width(), focus_rect.height()); |
| 209 } |
| 182 #endif | 210 #endif |
| 183 | 211 |
| 184 cairo_destroy(cr); | 212 cairo_destroy(cr); |
| 185 cairo_surface_destroy(surface); | 213 cairo_surface_destroy(surface); |
| 186 | 214 |
| 187 return gfx::ImageSkiaRep(border, scale); | 215 return gfx::ImageSkiaRep(border, scale); |
| 188 } | 216 } |
| 189 | 217 |
| 190 private: | 218 private: |
| 191 bool is_blue_; | 219 bool is_blue_; |
| (...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 | 1069 |
| 1042 float GtkUi::GetDeviceScaleFactor() const { | 1070 float GtkUi::GetDeviceScaleFactor() const { |
| 1043 return device_scale_factor_; | 1071 return device_scale_factor_; |
| 1044 } | 1072 } |
| 1045 | 1073 |
| 1046 } // namespace libgtkui | 1074 } // namespace libgtkui |
| 1047 | 1075 |
| 1048 views::LinuxUI* BuildGtkUi() { | 1076 views::LinuxUI* BuildGtkUi() { |
| 1049 return new libgtkui::GtkUi; | 1077 return new libgtkui::GtkUi; |
| 1050 } | 1078 } |
| OLD | NEW |