Chromium Code Reviews| 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 <gtk/gtk.h> | 5 #include <gtk/gtk.h> |
| 6 #include <math.h> | 6 #include <math.h> |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 class DisconnectWindowGtk : public HostWindow { | 24 class DisconnectWindowGtk : public HostWindow { |
| 25 public: | 25 public: |
| 26 DisconnectWindowGtk(); | 26 DisconnectWindowGtk(); |
| 27 ~DisconnectWindowGtk() override; | 27 ~DisconnectWindowGtk() override; |
| 28 | 28 |
| 29 // HostWindow overrides. | 29 // HostWindow overrides. |
| 30 void Start(const base::WeakPtr<ClientSessionControl>& client_session_control) | 30 void Start(const base::WeakPtr<ClientSessionControl>& client_session_control) |
| 31 override; | 31 override; |
| 32 | 32 |
| 33 private: | 33 private: |
| 34 CHROMEG_CALLBACK_1(DisconnectWindowGtk, gboolean, OnDelete, | 34 CHROMEG_CALLBACK_1(DisconnectWindowGtk, |
| 35 GtkWidget*, GdkEvent*); | 35 gboolean, |
| 36 OnDelete, | |
| 37 GtkWidget*, | |
| 38 GdkEvent*); | |
| 36 CHROMEG_CALLBACK_0(DisconnectWindowGtk, void, OnClicked, GtkButton*); | 39 CHROMEG_CALLBACK_0(DisconnectWindowGtk, void, OnClicked, GtkButton*); |
| 37 CHROMEG_CALLBACK_1(DisconnectWindowGtk, gboolean, OnConfigure, | 40 CHROMEG_CALLBACK_1(DisconnectWindowGtk, |
| 38 GtkWidget*, GdkEventConfigure*); | 41 gboolean, |
| 39 CHROMEG_CALLBACK_1(DisconnectWindowGtk, gboolean, OnButtonPress, | 42 OnConfigure, |
| 40 GtkWidget*, GdkEventButton*); | 43 GtkWidget*, |
| 44 GdkEventConfigure*); | |
| 45 CHROMEG_CALLBACK_1(DisconnectWindowGtk, | |
| 46 gboolean, | |
| 47 OnDraw, | |
| 48 GtkWidget*, | |
| 49 cairo_t*); | |
| 50 CHROMEG_CALLBACK_1(DisconnectWindowGtk, | |
| 51 gboolean, | |
| 52 OnButtonPress, | |
| 53 GtkWidget*, | |
| 54 GdkEventButton*); | |
| 41 | 55 |
| 42 // Used to disconnect the client session. | 56 // Used to disconnect the client session. |
| 43 base::WeakPtr<ClientSessionControl> client_session_control_; | 57 base::WeakPtr<ClientSessionControl> client_session_control_; |
| 44 | 58 |
| 45 GtkWidget* disconnect_window_; | 59 GtkWidget* disconnect_window_; |
| 46 GtkWidget* message_; | 60 GtkWidget* message_; |
| 47 GtkWidget* button_; | 61 GtkWidget* button_; |
| 48 | 62 |
| 49 // Used to distinguish resize events from other types of "configure-event" | 63 // Used to distinguish resize events from other types of "configure-event" |
| 50 // notifications. | 64 // notifications. |
| 51 int current_width_; | 65 int current_width_; |
| 52 int current_height_; | 66 int current_height_; |
| 53 | 67 |
| 54 DISALLOW_COPY_AND_ASSIGN(DisconnectWindowGtk); | 68 DISALLOW_COPY_AND_ASSIGN(DisconnectWindowGtk); |
| 55 }; | 69 }; |
| 56 | 70 |
| 57 // Helper function for creating a rectangular path with rounded corners, as | 71 // Helper function for creating a rectangular path with rounded corners, as |
| 58 // Cairo doesn't have this facility. |radius| is the arc-radius of each | 72 // Cairo doesn't have this facility. |radius| is the arc-radius of each |
| 59 // corner. The bounding rectangle extends from (0, 0) to (width, height). | 73 // corner. The bounding rectangle extends from (0, 0) to (width, height). |
| 60 void AddRoundRectPath(cairo_t* cairo_context, int width, int height, | 74 void AddRoundRectPath(cairo_t* cairo_context, int width, int height, |
| 61 int radius) { | 75 int radius) { |
| 62 cairo_new_sub_path(cairo_context); | 76 cairo_new_sub_path(cairo_context); |
| 63 cairo_arc(cairo_context, width - radius, radius, radius, -M_PI_2, 0); | 77 cairo_arc(cairo_context, width - radius, radius, radius, -M_PI_2, 0); |
| 64 cairo_arc(cairo_context, width - radius, height - radius, radius, 0, M_PI_2); | 78 cairo_arc(cairo_context, width - radius, height - radius, radius, 0, M_PI_2); |
| 65 cairo_arc(cairo_context, radius, height - radius, radius, M_PI_2, 2 * M_PI_2); | 79 cairo_arc(cairo_context, radius, height - radius, radius, M_PI_2, 2 * M_PI_2); |
| 66 cairo_arc(cairo_context, radius, radius, radius, 2 * M_PI_2, 3 * M_PI_2); | 80 cairo_arc(cairo_context, radius, radius, radius, 2 * M_PI_2, 3 * M_PI_2); |
| 67 cairo_close_path(cairo_context); | 81 cairo_close_path(cairo_context); |
| 68 } | 82 } |
| 69 | 83 |
| 84 // Renders the disconnect window background. | |
| 85 void DrawBackground(cairo_t* cairo_context, int width, int height) { | |
| 86 // Set the arc radius for the corners. | |
| 87 const int kCornerRadius = 6; | |
| 88 | |
| 89 // Initialize the whole bitmap to be transparent. | |
| 90 cairo_save(cairo_context); | |
| 91 cairo_set_source_rgba(cairo_context, 0, 0, 0, 0); | |
| 92 cairo_set_operator(cairo_context, CAIRO_OPERATOR_SOURCE); | |
| 93 cairo_paint(cairo_context); | |
| 94 cairo_restore(cairo_context); | |
| 95 | |
| 96 AddRoundRectPath(cairo_context, width, height, kCornerRadius); | |
| 97 cairo_clip(cairo_context); | |
| 98 | |
| 99 // Paint the whole bitmap one color. | |
| 100 cairo_set_source_rgb(cairo_context, 0.91, 0.91, 0.91); | |
| 101 cairo_paint(cairo_context); | |
| 102 | |
| 103 // Paint the round-rectangle edge. | |
| 104 cairo_set_source_rgb(cairo_context, 0.13, 0.69, 0.11); | |
| 105 cairo_set_line_width(cairo_context, 6); | |
| 106 AddRoundRectPath(cairo_context, width, height, kCornerRadius); | |
| 107 cairo_stroke(cairo_context); | |
| 108 | |
| 109 // Render the window-gripper. In order for a straight line to light up | |
| 110 // single pixels, Cairo requires the coordinates to have fractional | |
| 111 // components of 0.5 (so the "/ 2" is a deliberate integer division). | |
| 112 double gripper_top = height / 2 - 10.5; | |
| 113 double gripper_bottom = height / 2 + 10.5; | |
| 114 cairo_set_line_width(cairo_context, 1); | |
| 115 | |
| 116 double x = 12.5; | |
| 117 cairo_set_source_rgb(cairo_context, 0.70, 0.70, 0.70); | |
| 118 cairo_move_to(cairo_context, x, gripper_top); | |
| 119 cairo_line_to(cairo_context, x, gripper_bottom); | |
| 120 cairo_stroke(cairo_context); | |
| 121 x += 3; | |
| 122 cairo_move_to(cairo_context, x, gripper_top); | |
| 123 cairo_line_to(cairo_context, x, gripper_bottom); | |
| 124 cairo_stroke(cairo_context); | |
| 125 | |
| 126 x -= 2; | |
| 127 cairo_set_source_rgb(cairo_context, 0.97, 0.97, 0.97); | |
| 128 cairo_move_to(cairo_context, x, gripper_top); | |
| 129 cairo_line_to(cairo_context, x, gripper_bottom); | |
| 130 cairo_stroke(cairo_context); | |
| 131 x += 3; | |
| 132 cairo_move_to(cairo_context, x, gripper_top); | |
| 133 cairo_line_to(cairo_context, x, gripper_bottom); | |
| 134 cairo_stroke(cairo_context); | |
| 135 } | |
| 136 | |
| 70 DisconnectWindowGtk::DisconnectWindowGtk() | 137 DisconnectWindowGtk::DisconnectWindowGtk() |
| 71 : disconnect_window_(nullptr), | 138 : disconnect_window_(nullptr), |
| 72 current_width_(0), | 139 current_width_(0), |
| 73 current_height_(0) { | 140 current_height_(0) { |
| 74 } | 141 } |
| 75 | 142 |
| 76 DisconnectWindowGtk::~DisconnectWindowGtk() { | 143 DisconnectWindowGtk::~DisconnectWindowGtk() { |
| 77 DCHECK(CalledOnValidThread()); | 144 DCHECK(CalledOnValidThread()); |
| 78 | 145 |
| 79 if (disconnect_window_) { | 146 if (disconnect_window_) { |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 108 // Remove window titlebar. | 175 // Remove window titlebar. |
| 109 gtk_window_set_decorated(window, FALSE); | 176 gtk_window_set_decorated(window, FALSE); |
| 110 | 177 |
| 111 // In case the titlebar is still there, try to remove some of the buttons. | 178 // In case the titlebar is still there, try to remove some of the buttons. |
| 112 // Utility windows have no minimize button or taskbar presence. | 179 // Utility windows have no minimize button or taskbar presence. |
| 113 gtk_window_set_type_hint(window, GDK_WINDOW_TYPE_HINT_UTILITY); | 180 gtk_window_set_type_hint(window, GDK_WINDOW_TYPE_HINT_UTILITY); |
| 114 gtk_window_set_deletable(window, FALSE); | 181 gtk_window_set_deletable(window, FALSE); |
| 115 | 182 |
| 116 // Allow custom rendering of the background pixmap. | 183 // Allow custom rendering of the background pixmap. |
| 117 gtk_widget_set_app_paintable(disconnect_window_, TRUE); | 184 gtk_widget_set_app_paintable(disconnect_window_, TRUE); |
| 185 g_signal_connect(disconnect_window_, "draw", G_CALLBACK(OnDrawThunk), this); | |
| 118 | 186 |
| 119 // Handle window resizing, to regenerate the background pixmap and window | 187 // Handle window resizing, to regenerate the background pixmap and window |
| 120 // shape bitmap. The stored width & height need to be initialized here | 188 // shape bitmap. The stored width & height need to be initialized here |
| 121 // in case the window is created a second time (the size of the previous | 189 // in case the window is created a second time (the size of the previous |
| 122 // window would be remembered, preventing the generation of bitmaps for the | 190 // window would be remembered, preventing the generation of bitmaps for the |
| 123 // new window). | 191 // new window). |
| 124 current_height_ = current_width_ = 0; | 192 current_height_ = current_width_ = 0; |
| 125 g_signal_connect(disconnect_window_, "configure-event", | 193 g_signal_connect(disconnect_window_, "configure-event", |
| 126 G_CALLBACK(OnConfigureThunk), this); | 194 G_CALLBACK(OnConfigureThunk), this); |
| 127 | 195 |
| 128 // Handle mouse events to allow the user to drag the window around. | 196 // Handle mouse events to allow the user to drag the window around. |
| 129 gtk_widget_set_events(disconnect_window_, GDK_BUTTON_PRESS_MASK); | 197 gtk_widget_set_events(disconnect_window_, GDK_BUTTON_PRESS_MASK); |
| 130 g_signal_connect(disconnect_window_, "button-press-event", | 198 g_signal_connect(disconnect_window_, "button-press-event", |
| 131 G_CALLBACK(OnButtonPressThunk), this); | 199 G_CALLBACK(OnButtonPressThunk), this); |
| 132 | 200 |
| 133 // All magic numbers taken from screen shots provided by UX. | 201 // All magic numbers taken from screen shots provided by UX. |
| 134 // The alignment sets narrow margins at the top and bottom, compared with | 202 // The alignment sets narrow margins at the top and bottom, compared with |
| 135 // left and right. The left margin is made larger to accommodate the | 203 // left and right. The left margin is made larger to accommodate the |
| 136 // window movement gripper. | 204 // window movement gripper. |
| 137 GtkWidget* align = gtk_alignment_new(0, 0, 1, 1); | 205 GtkWidget* align = gtk_alignment_new(0, 0, 1, 1); |
| 138 gtk_alignment_set_padding(GTK_ALIGNMENT(align), 8, 8, 24, 12); | 206 gtk_alignment_set_padding(GTK_ALIGNMENT(align), 8, 8, 24, 12); |
| 139 gtk_container_add(GTK_CONTAINER(window), align); | 207 gtk_container_add(GTK_CONTAINER(window), align); |
| 140 | 208 |
| 209 #if GTK_MAJOR_VERSION == 2 | |
| 141 GtkWidget* button_row = gtk_hbox_new(FALSE, 12); | 210 GtkWidget* button_row = gtk_hbox_new(FALSE, 12); |
| 211 #else | |
| 212 GtkWidget* button_row = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12); | |
| 213 gtk_box_set_homogeneous(GTK_BOX(button_row), FALSE); | |
| 214 #endif | |
| 142 gtk_container_add(GTK_CONTAINER(align), button_row); | 215 gtk_container_add(GTK_CONTAINER(align), button_row); |
| 143 | 216 |
| 144 button_ = gtk_button_new_with_label( | 217 button_ = gtk_button_new_with_label( |
| 145 l10n_util::GetStringUTF8(IDS_STOP_SHARING_BUTTON).c_str()); | 218 l10n_util::GetStringUTF8(IDS_STOP_SHARING_BUTTON).c_str()); |
| 146 gtk_box_pack_end(GTK_BOX(button_row), button_, FALSE, FALSE, 0); | 219 gtk_box_pack_end(GTK_BOX(button_row), button_, FALSE, FALSE, 0); |
| 147 | 220 |
| 148 g_signal_connect(button_, "clicked", G_CALLBACK(OnClickedThunk), this); | 221 g_signal_connect(button_, "clicked", G_CALLBACK(OnClickedThunk), this); |
| 149 | 222 |
| 150 message_ = gtk_label_new(nullptr); | 223 message_ = gtk_label_new(nullptr); |
| 151 gtk_box_pack_end(GTK_BOX(button_row), message_, FALSE, FALSE, 0); | 224 gtk_box_pack_end(GTK_BOX(button_row), message_, FALSE, FALSE, 0); |
| 152 | 225 |
| 153 // Override any theme setting for the text color, so that the text is | 226 // Override any theme setting for the text color, so that the text is |
| 154 // readable against the window's background pixmap. | 227 // readable against the window's background pixmap. |
| 155 PangoAttrList* attributes = pango_attr_list_new(); | 228 PangoAttrList* attributes = pango_attr_list_new(); |
| 156 PangoAttribute* text_color = pango_attr_foreground_new(0, 0, 0); | 229 PangoAttribute* text_color = pango_attr_foreground_new(0, 0, 0); |
| 157 pango_attr_list_insert(attributes, text_color); | 230 pango_attr_list_insert(attributes, text_color); |
| 158 gtk_label_set_attributes(GTK_LABEL(message_), attributes); | 231 gtk_label_set_attributes(GTK_LABEL(message_), attributes); |
| 159 pango_attr_list_unref(attributes); | 232 pango_attr_list_unref(attributes); |
| 160 | 233 |
| 234 #if GTK_MAJOR_VERSION > 2 | |
| 235 GdkScreen* screen = gtk_widget_get_screen(disconnect_window_); | |
| 236 GdkVisual* visual = gdk_screen_get_rgba_visual(screen); | |
| 237 | |
| 238 if (visual) | |
| 239 gtk_widget_set_visual(disconnect_window_, visual); | |
| 240 #endif | |
| 241 | |
| 161 gtk_widget_show_all(disconnect_window_); | 242 gtk_widget_show_all(disconnect_window_); |
| 162 | 243 |
| 163 // Extract the user name from the JID. | 244 // Extract the user name from the JID. |
| 164 std::string client_jid = client_session_control_->client_jid(); | 245 std::string client_jid = client_session_control_->client_jid(); |
| 165 base::string16 username = | 246 base::string16 username = |
| 166 base::UTF8ToUTF16(client_jid.substr(0, client_jid.find('/'))); | 247 base::UTF8ToUTF16(client_jid.substr(0, client_jid.find('/'))); |
| 167 gtk_label_set_text( | 248 gtk_label_set_text( |
| 168 GTK_LABEL(message_), | 249 GTK_LABEL(message_), |
| 169 l10n_util::GetStringFUTF8(IDS_MESSAGE_SHARED, username).c_str()); | 250 l10n_util::GetStringFUTF8(IDS_MESSAGE_SHARED, username).c_str()); |
| 170 gtk_window_present(window); | 251 gtk_window_present(window); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 190 GdkEventConfigure* event) { | 271 GdkEventConfigure* event) { |
| 191 DCHECK(CalledOnValidThread()); | 272 DCHECK(CalledOnValidThread()); |
| 192 | 273 |
| 193 // Only generate bitmaps if the size has actually changed. | 274 // Only generate bitmaps if the size has actually changed. |
| 194 if (event->width == current_width_ && event->height == current_height_) | 275 if (event->width == current_width_ && event->height == current_height_) |
| 195 return FALSE; | 276 return FALSE; |
| 196 | 277 |
| 197 current_width_ = event->width; | 278 current_width_ = event->width; |
| 198 current_height_ = event->height; | 279 current_height_ = event->height; |
| 199 | 280 |
| 281 #if GTK_MAJOR_VERSION == 2 | |
|
Sergey Ulanov
2017/02/06 17:40:41
Maybe add a comment that gdk_window_set_back_pixma
Tom (Use chromium acct)
2017/02/06 20:00:06
Done.
| |
| 200 // Create the depth 1 pixmap for the window shape. | 282 // Create the depth 1 pixmap for the window shape. |
| 201 GdkPixmap* shape_mask = | 283 GdkPixmap* shape_mask = |
| 202 gdk_pixmap_new(nullptr, current_width_, current_height_, 1); | 284 gdk_pixmap_new(nullptr, current_width_, current_height_, 1); |
| 203 cairo_t* cairo_context = gdk_cairo_create(shape_mask); | 285 cairo_t* cairo_context = gdk_cairo_create(shape_mask); |
| 204 | 286 |
| 205 // Set the arc radius for the corners. | 287 // Set the arc radius for the corners. |
| 206 const int kCornerRadius = 6; | 288 const int kCornerRadius = 6; |
| 207 | 289 |
| 208 // Initialize the whole bitmap to be transparent. | 290 // Initialize the whole bitmap to be transparent. |
| 209 cairo_set_source_rgba(cairo_context, 0, 0, 0, 0); | 291 cairo_set_source_rgba(cairo_context, 0, 0, 0, 0); |
| 210 cairo_set_operator(cairo_context, CAIRO_OPERATOR_SOURCE); | 292 cairo_set_operator(cairo_context, CAIRO_OPERATOR_SOURCE); |
| 211 cairo_paint(cairo_context); | 293 cairo_paint(cairo_context); |
| 212 | 294 |
| 213 // Paint an opaque round rect covering the whole area (leaving the extreme | 295 // Paint an opaque round rect covering the whole area (leaving the extreme |
| 214 // corners transparent). | 296 // corners transparent). |
| 215 cairo_set_source_rgba(cairo_context, 1, 1, 1, 1); | 297 cairo_set_source_rgba(cairo_context, 1, 1, 1, 1); |
| 216 cairo_set_operator(cairo_context, CAIRO_OPERATOR_SOURCE); | 298 cairo_set_operator(cairo_context, CAIRO_OPERATOR_SOURCE); |
| 217 AddRoundRectPath(cairo_context, current_width_, current_height_, | 299 AddRoundRectPath(cairo_context, current_width_, current_height_, |
| 218 kCornerRadius); | 300 kCornerRadius); |
| 219 cairo_fill(cairo_context); | 301 cairo_fill(cairo_context); |
| 220 | 302 |
| 221 cairo_destroy(cairo_context); | 303 cairo_destroy(cairo_context); |
| 222 gdk_window_shape_combine_mask(widget->window, shape_mask, 0, 0); | 304 gdk_window_shape_combine_mask(widget->window, shape_mask, 0, 0); |
| 223 g_object_unref(shape_mask); | 305 g_object_unref(shape_mask); |
| 224 | 306 |
| 225 // Create a full-color pixmap for the window background image. | 307 // Create a full-color pixmap for the window background image. |
| 226 GdkPixmap* background = | 308 GdkPixmap* background = |
| 227 gdk_pixmap_new(nullptr, current_width_, current_height_, 24); | 309 gdk_pixmap_new(nullptr, current_width_, current_height_, 24); |
| 228 cairo_context = gdk_cairo_create(background); | 310 cairo_context = gdk_cairo_create(background); |
| 229 | 311 DrawBackground(cairo_context, current_width_, current_height_); |
| 230 // Paint the whole bitmap one color. | |
| 231 cairo_set_source_rgb(cairo_context, 0.91, 0.91, 0.91); | |
| 232 cairo_paint(cairo_context); | |
| 233 | |
| 234 // Paint the round-rectangle edge. | |
| 235 cairo_set_source_rgb(cairo_context, 0.13, 0.69, 0.11); | |
| 236 cairo_set_line_width(cairo_context, 6); | |
| 237 AddRoundRectPath(cairo_context, current_width_, current_height_, | |
| 238 kCornerRadius); | |
| 239 cairo_stroke(cairo_context); | |
| 240 | |
| 241 // Render the window-gripper. In order for a straight line to light up | |
| 242 // single pixels, Cairo requires the coordinates to have fractional | |
| 243 // components of 0.5 (so the "/ 2" is a deliberate integer division). | |
| 244 double gripper_top = current_height_ / 2 - 10.5; | |
| 245 double gripper_bottom = current_height_ / 2 + 10.5; | |
| 246 cairo_set_line_width(cairo_context, 1); | |
| 247 | |
| 248 double x = 12.5; | |
| 249 cairo_set_source_rgb(cairo_context, 0.70, 0.70, 0.70); | |
| 250 cairo_move_to(cairo_context, x, gripper_top); | |
| 251 cairo_line_to(cairo_context, x, gripper_bottom); | |
| 252 cairo_stroke(cairo_context); | |
| 253 x += 3; | |
| 254 cairo_move_to(cairo_context, x, gripper_top); | |
| 255 cairo_line_to(cairo_context, x, gripper_bottom); | |
| 256 cairo_stroke(cairo_context); | |
| 257 | |
| 258 x -= 2; | |
| 259 cairo_set_source_rgb(cairo_context, 0.97, 0.97, 0.97); | |
| 260 cairo_move_to(cairo_context, x, gripper_top); | |
| 261 cairo_line_to(cairo_context, x, gripper_bottom); | |
| 262 cairo_stroke(cairo_context); | |
| 263 x += 3; | |
| 264 cairo_move_to(cairo_context, x, gripper_top); | |
| 265 cairo_line_to(cairo_context, x, gripper_bottom); | |
| 266 cairo_stroke(cairo_context); | |
| 267 | |
| 268 cairo_destroy(cairo_context); | 312 cairo_destroy(cairo_context); |
| 269 | 313 |
| 270 gdk_window_set_back_pixmap(widget->window, background, FALSE); | 314 gdk_window_set_back_pixmap(widget->window, background, FALSE); |
| 271 g_object_unref(background); | 315 g_object_unref(background); |
| 272 gdk_window_invalidate_rect(widget->window, nullptr, TRUE); | 316 gdk_window_invalidate_rect(widget->window, nullptr, TRUE); |
| 317 #endif | |
|
Sergey Ulanov
2017/02/06 17:40:41
// GTK_MAJOR_VERSION == 2
Tom (Use chromium acct)
2017/02/06 20:00:06
Done.
| |
| 273 | 318 |
| 274 return FALSE; | 319 return FALSE; |
| 275 } | 320 } |
| 276 | 321 |
| 322 gboolean DisconnectWindowGtk::OnDraw(GtkWidget* widget, cairo_t* cr) { | |
| 323 #if GTK_MAJOR_VERSION == 2 | |
| 324 NOTREACHED(); | |
| 325 #endif | |
| 326 DCHECK(CalledOnValidThread()); | |
| 327 | |
| 328 DrawBackground(cr, current_width_, current_height_); | |
| 329 return FALSE; | |
| 330 } | |
| 331 | |
| 277 gboolean DisconnectWindowGtk::OnButtonPress(GtkWidget* widget, | 332 gboolean DisconnectWindowGtk::OnButtonPress(GtkWidget* widget, |
| 278 GdkEventButton* event) { | 333 GdkEventButton* event) { |
| 279 DCHECK(CalledOnValidThread()); | 334 DCHECK(CalledOnValidThread()); |
| 280 | 335 |
| 281 gtk_window_begin_move_drag(GTK_WINDOW(disconnect_window_), | 336 gtk_window_begin_move_drag(GTK_WINDOW(disconnect_window_), |
| 282 event->button, | 337 event->button, |
| 283 event->x_root, | 338 event->x_root, |
| 284 event->y_root, | 339 event->y_root, |
| 285 event->time); | 340 event->time); |
| 286 return FALSE; | 341 return FALSE; |
| 287 } | 342 } |
| 288 | 343 |
| 289 } // namespace | 344 } // namespace |
| 290 | 345 |
| 291 // static | 346 // static |
| 292 std::unique_ptr<HostWindow> HostWindow::CreateDisconnectWindow() { | 347 std::unique_ptr<HostWindow> HostWindow::CreateDisconnectWindow() { |
| 293 return base::MakeUnique<DisconnectWindowGtk>(); | 348 return base::MakeUnique<DisconnectWindowGtk>(); |
| 294 } | 349 } |
| 295 | 350 |
| 296 } // namespace remoting | 351 } // namespace remoting |
| OLD | NEW |