| Index: remoting/host/disconnect_window_linux.cc
|
| diff --git a/remoting/host/disconnect_window_linux.cc b/remoting/host/disconnect_window_linux.cc
|
| index f79bd30dd3f8d07544ba36249f2aaf83edd1b572..ef712da10cb74d3f70817720c3801c2eca8ee4b7 100644
|
| --- a/remoting/host/disconnect_window_linux.cc
|
| +++ b/remoting/host/disconnect_window_linux.cc
|
| @@ -31,13 +31,27 @@ class DisconnectWindowGtk : public HostWindow {
|
| override;
|
|
|
| private:
|
| - CHROMEG_CALLBACK_1(DisconnectWindowGtk, gboolean, OnDelete,
|
| - GtkWidget*, GdkEvent*);
|
| + CHROMEG_CALLBACK_1(DisconnectWindowGtk,
|
| + gboolean,
|
| + OnDelete,
|
| + GtkWidget*,
|
| + GdkEvent*);
|
| CHROMEG_CALLBACK_0(DisconnectWindowGtk, void, OnClicked, GtkButton*);
|
| - CHROMEG_CALLBACK_1(DisconnectWindowGtk, gboolean, OnConfigure,
|
| - GtkWidget*, GdkEventConfigure*);
|
| - CHROMEG_CALLBACK_1(DisconnectWindowGtk, gboolean, OnButtonPress,
|
| - GtkWidget*, GdkEventButton*);
|
| + CHROMEG_CALLBACK_1(DisconnectWindowGtk,
|
| + gboolean,
|
| + OnConfigure,
|
| + GtkWidget*,
|
| + GdkEventConfigure*);
|
| + CHROMEG_CALLBACK_1(DisconnectWindowGtk,
|
| + gboolean,
|
| + OnDraw,
|
| + GtkWidget*,
|
| + cairo_t*);
|
| + CHROMEG_CALLBACK_1(DisconnectWindowGtk,
|
| + gboolean,
|
| + OnButtonPress,
|
| + GtkWidget*,
|
| + GdkEventButton*);
|
|
|
| // Used to disconnect the client session.
|
| base::WeakPtr<ClientSessionControl> client_session_control_;
|
| @@ -67,6 +81,59 @@ void AddRoundRectPath(cairo_t* cairo_context, int width, int height,
|
| cairo_close_path(cairo_context);
|
| }
|
|
|
| +// Renders the disconnect window background.
|
| +void DrawBackground(cairo_t* cairo_context, int width, int height) {
|
| + // Set the arc radius for the corners.
|
| + const int kCornerRadius = 6;
|
| +
|
| + // Initialize the whole bitmap to be transparent.
|
| + cairo_save(cairo_context);
|
| + cairo_set_source_rgba(cairo_context, 0, 0, 0, 0);
|
| + cairo_set_operator(cairo_context, CAIRO_OPERATOR_SOURCE);
|
| + cairo_paint(cairo_context);
|
| + cairo_restore(cairo_context);
|
| +
|
| + AddRoundRectPath(cairo_context, width, height, kCornerRadius);
|
| + cairo_clip(cairo_context);
|
| +
|
| + // Paint the whole bitmap one color.
|
| + cairo_set_source_rgb(cairo_context, 0.91, 0.91, 0.91);
|
| + cairo_paint(cairo_context);
|
| +
|
| + // Paint the round-rectangle edge.
|
| + cairo_set_source_rgb(cairo_context, 0.13, 0.69, 0.11);
|
| + cairo_set_line_width(cairo_context, 6);
|
| + AddRoundRectPath(cairo_context, width, height, kCornerRadius);
|
| + cairo_stroke(cairo_context);
|
| +
|
| + // Render the window-gripper. In order for a straight line to light up
|
| + // single pixels, Cairo requires the coordinates to have fractional
|
| + // components of 0.5 (so the "/ 2" is a deliberate integer division).
|
| + double gripper_top = height / 2 - 10.5;
|
| + double gripper_bottom = height / 2 + 10.5;
|
| + cairo_set_line_width(cairo_context, 1);
|
| +
|
| + double x = 12.5;
|
| + cairo_set_source_rgb(cairo_context, 0.70, 0.70, 0.70);
|
| + cairo_move_to(cairo_context, x, gripper_top);
|
| + cairo_line_to(cairo_context, x, gripper_bottom);
|
| + cairo_stroke(cairo_context);
|
| + x += 3;
|
| + cairo_move_to(cairo_context, x, gripper_top);
|
| + cairo_line_to(cairo_context, x, gripper_bottom);
|
| + cairo_stroke(cairo_context);
|
| +
|
| + x -= 2;
|
| + cairo_set_source_rgb(cairo_context, 0.97, 0.97, 0.97);
|
| + cairo_move_to(cairo_context, x, gripper_top);
|
| + cairo_line_to(cairo_context, x, gripper_bottom);
|
| + cairo_stroke(cairo_context);
|
| + x += 3;
|
| + cairo_move_to(cairo_context, x, gripper_top);
|
| + cairo_line_to(cairo_context, x, gripper_bottom);
|
| + cairo_stroke(cairo_context);
|
| +}
|
| +
|
| DisconnectWindowGtk::DisconnectWindowGtk()
|
| : disconnect_window_(nullptr),
|
| current_width_(0),
|
| @@ -115,6 +182,7 @@ void DisconnectWindowGtk::Start(
|
|
|
| // Allow custom rendering of the background pixmap.
|
| gtk_widget_set_app_paintable(disconnect_window_, TRUE);
|
| + g_signal_connect(disconnect_window_, "draw", G_CALLBACK(OnDrawThunk), this);
|
|
|
| // Handle window resizing, to regenerate the background pixmap and window
|
| // shape bitmap. The stored width & height need to be initialized here
|
| @@ -138,7 +206,12 @@ void DisconnectWindowGtk::Start(
|
| gtk_alignment_set_padding(GTK_ALIGNMENT(align), 8, 8, 24, 12);
|
| gtk_container_add(GTK_CONTAINER(window), align);
|
|
|
| +#if GTK_MAJOR_VERSION == 2
|
| GtkWidget* button_row = gtk_hbox_new(FALSE, 12);
|
| +#else
|
| + GtkWidget* button_row = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
|
| + gtk_box_set_homogeneous(GTK_BOX(button_row), FALSE);
|
| +#endif
|
| gtk_container_add(GTK_CONTAINER(align), button_row);
|
|
|
| button_ = gtk_button_new_with_label(
|
| @@ -158,6 +231,14 @@ void DisconnectWindowGtk::Start(
|
| gtk_label_set_attributes(GTK_LABEL(message_), attributes);
|
| pango_attr_list_unref(attributes);
|
|
|
| +#if GTK_MAJOR_VERSION > 2
|
| + GdkScreen* screen = gtk_widget_get_screen(disconnect_window_);
|
| + GdkVisual* visual = gdk_screen_get_rgba_visual(screen);
|
| +
|
| + if (visual)
|
| + gtk_widget_set_visual(disconnect_window_, visual);
|
| +#endif
|
| +
|
| gtk_widget_show_all(disconnect_window_);
|
|
|
| // Extract the user name from the JID.
|
| @@ -197,6 +278,9 @@ gboolean DisconnectWindowGtk::OnConfigure(GtkWidget* widget,
|
| current_width_ = event->width;
|
| current_height_ = event->height;
|
|
|
| + // gdk_window_set_back_pixmap() is not supported in GDK3, and
|
| + // background drawing is handled in OnDraw().
|
| +#if GTK_MAJOR_VERSION == 2
|
| // Create the depth 1 pixmap for the window shape.
|
| GdkPixmap* shape_mask =
|
| gdk_pixmap_new(nullptr, current_width_, current_height_, 1);
|
| @@ -226,54 +310,27 @@ gboolean DisconnectWindowGtk::OnConfigure(GtkWidget* widget,
|
| GdkPixmap* background =
|
| gdk_pixmap_new(nullptr, current_width_, current_height_, 24);
|
| cairo_context = gdk_cairo_create(background);
|
| -
|
| - // Paint the whole bitmap one color.
|
| - cairo_set_source_rgb(cairo_context, 0.91, 0.91, 0.91);
|
| - cairo_paint(cairo_context);
|
| -
|
| - // Paint the round-rectangle edge.
|
| - cairo_set_source_rgb(cairo_context, 0.13, 0.69, 0.11);
|
| - cairo_set_line_width(cairo_context, 6);
|
| - AddRoundRectPath(cairo_context, current_width_, current_height_,
|
| - kCornerRadius);
|
| - cairo_stroke(cairo_context);
|
| -
|
| - // Render the window-gripper. In order for a straight line to light up
|
| - // single pixels, Cairo requires the coordinates to have fractional
|
| - // components of 0.5 (so the "/ 2" is a deliberate integer division).
|
| - double gripper_top = current_height_ / 2 - 10.5;
|
| - double gripper_bottom = current_height_ / 2 + 10.5;
|
| - cairo_set_line_width(cairo_context, 1);
|
| -
|
| - double x = 12.5;
|
| - cairo_set_source_rgb(cairo_context, 0.70, 0.70, 0.70);
|
| - cairo_move_to(cairo_context, x, gripper_top);
|
| - cairo_line_to(cairo_context, x, gripper_bottom);
|
| - cairo_stroke(cairo_context);
|
| - x += 3;
|
| - cairo_move_to(cairo_context, x, gripper_top);
|
| - cairo_line_to(cairo_context, x, gripper_bottom);
|
| - cairo_stroke(cairo_context);
|
| -
|
| - x -= 2;
|
| - cairo_set_source_rgb(cairo_context, 0.97, 0.97, 0.97);
|
| - cairo_move_to(cairo_context, x, gripper_top);
|
| - cairo_line_to(cairo_context, x, gripper_bottom);
|
| - cairo_stroke(cairo_context);
|
| - x += 3;
|
| - cairo_move_to(cairo_context, x, gripper_top);
|
| - cairo_line_to(cairo_context, x, gripper_bottom);
|
| - cairo_stroke(cairo_context);
|
| -
|
| + DrawBackground(cairo_context, current_width_, current_height_);
|
| cairo_destroy(cairo_context);
|
|
|
| gdk_window_set_back_pixmap(widget->window, background, FALSE);
|
| g_object_unref(background);
|
| gdk_window_invalidate_rect(widget->window, nullptr, TRUE);
|
| +#endif // GTK_MAJOR_VERSION == 2
|
|
|
| return FALSE;
|
| }
|
|
|
| +gboolean DisconnectWindowGtk::OnDraw(GtkWidget* widget, cairo_t* cr) {
|
| +#if GTK_MAJOR_VERSION == 2
|
| + NOTREACHED();
|
| +#endif
|
| + DCHECK(CalledOnValidThread());
|
| +
|
| + DrawBackground(cr, current_width_, current_height_);
|
| + return FALSE;
|
| +}
|
| +
|
| gboolean DisconnectWindowGtk::OnButtonPress(GtkWidget* widget,
|
| GdkEventButton* event) {
|
| DCHECK(CalledOnValidThread());
|
|
|