[gtk+/wip/ebassi/gsk-renderer: 5/5] fixup! gtk: Port GtkWindow to render nodes



commit b368f727ee8892c4364210b452f07a02cd726d00
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Thu Jul 28 16:21:27 2016 +0100

    fixup! gtk: Port GtkWindow to render nodes

 gtk/gtkwindow.c |  109 ++++---------------------------------------------------
 1 files changed, 7 insertions(+), 102 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index ca79c2b..3d2e67a 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -719,7 +719,6 @@ gtk_window_class_init (GtkWindowClass *klass)
   widget_class->focus_out_event = gtk_window_focus_out_event;
   widget_class->focus = gtk_window_focus;
   widget_class->move_focus = gtk_window_move_focus;
-//  widget_class->draw = gtk_window_draw;
   widget_class->window_state_event = gtk_window_state_event;
   widget_class->get_preferred_width = gtk_window_get_preferred_width;
   widget_class->get_preferred_width_for_height = gtk_window_get_preferred_width_for_height;
@@ -7168,12 +7167,8 @@ gtk_window_realize (GtkWidget *widget)
 
   if (priv->renderer == NULL)
     {
-      graphene_rect_t viewport;
-
       priv->renderer = gsk_renderer_get_for_display (gtk_widget_get_display (widget));
-
-      graphene_rect_init (&viewport, 0, 0, allocation.width, allocation.height);
-      gsk_renderer_set_viewport (priv->renderer, &viewport);
+      gsk_renderer_set_scale_factor (priv->renderer, gtk_widget_get_scale_factor (widget));
     }
 
   if (gtk_widget_get_parent_window (widget))
@@ -7605,13 +7600,17 @@ _gtk_window_set_allocation (GtkWindow           *window,
       graphene_matrix_t projection;
       graphene_matrix_t modelview;
       graphene_point3d_t tmp;
+      int scale;
+
+      scale = gtk_widget_get_scale_factor (widget);
+      gsk_renderer_set_scale_factor (priv->renderer, scale);
 
       graphene_rect_init (&viewport, 0, 0, allocation->width, allocation->height);
       gsk_renderer_set_viewport (priv->renderer, &viewport);
 
       graphene_matrix_init_ortho (&projection,
-                                  0, allocation->width,
-                                  0, allocation->height,
+                                  0, allocation->width * scale,
+                                  0, allocation->height * scale,
                                   -1, 1);
       gsk_renderer_set_projection (priv->renderer, &projection);
 
@@ -10244,100 +10243,6 @@ gtk_window_get_render_node (GtkWidget   *widget,
   return node;
 }
 
-static gboolean
-gtk_window_draw (GtkWidget *widget,
-                cairo_t   *cr)
-{
-  GtkWindowPrivate *priv = GTK_WINDOW (widget)->priv;
-  GtkStyleContext *context;
-  gboolean ret = FALSE;
-  GtkAllocation allocation;
-  GtkBorder window_border;
-  gint title_height;
-
-  context = gtk_widget_get_style_context (widget);
-
-  get_shadow_width (GTK_WINDOW (widget), &window_border);
-  _gtk_widget_get_allocation (widget, &allocation);
-
-  if (gtk_cairo_should_draw_window (cr, _gtk_widget_get_window (widget)))
-    {
-      if (priv->client_decorated &&
-          priv->decorated &&
-          !priv->fullscreen &&
-          !priv->maximized)
-        {
-          gtk_style_context_save_to_node (context, priv->decoration_node);
-
-          if (priv->use_client_shadow)
-            {
-              GtkBorder padding, border;
-
-              gtk_style_context_get_padding (context, gtk_style_context_get_state (context), &padding);
-              gtk_style_context_get_border (context, gtk_style_context_get_state (context), &border);
-              sum_borders (&border, &padding);
-
-              gtk_render_background (context, cr,
-                                     window_border.left - border.left, window_border.top - border.top,
-                                     allocation.width -
-                                     (window_border.left + window_border.right - border.left - border.right),
-                                     allocation.height -
-                                     (window_border.top + window_border.bottom - border.top - 
border.bottom));
-              gtk_render_frame (context, cr,
-                                window_border.left - border.left, window_border.top - border.top,
-                                allocation.width -
-                                (window_border.left + window_border.right - border.left - border.right),
-                                allocation.height -
-                                (window_border.top + window_border.bottom - border.top - border.bottom));
-            }
-          else
-            {
-              gtk_render_background (context, cr, 0, 0,
-                                     allocation.width,
-                                     allocation.height);
-
-              gtk_render_frame (context, cr, 0, 0,
-                                allocation.width,
-                                allocation.height);
-            }
-
-          gtk_style_context_restore (context);
-        }
-
-      if (!gtk_widget_get_app_paintable (widget))
-        {
-           if (priv->title_box &&
-               gtk_widget_get_visible (priv->title_box) &&
-               gtk_widget_get_child_visible (priv->title_box))
-             title_height = priv->title_height;
-           else
-             title_height = 0;
-
-           gtk_render_background (context, cr,
-                                  window_border.left,
-                                  window_border.top + title_height,
-                                  allocation.width -
-                                  (window_border.left + window_border.right),
-                                  allocation.height -
-                                  (window_border.top + window_border.bottom +
-                                   title_height));
-           gtk_render_frame (context, cr,
-                             window_border.left,
-                             window_border.top + title_height,
-                             allocation.width -
-                             (window_border.left + window_border.right),
-                             allocation.height -
-                             (window_border.top + window_border.bottom +
-                              title_height));
-        }
-    }
-
-  if (GTK_WIDGET_CLASS (gtk_window_parent_class)->draw)
-    ret = GTK_WIDGET_CLASS (gtk_window_parent_class)->draw (widget, cr);
-
-  return ret;
-}
-
 /**
  * gtk_window_present:
  * @window: a #GtkWindow


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]