[mutter] resize-popup: use a tooltip style for the resize popup window



commit 94e6e55ef7021af56507515111af66f102b43ad7
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Jan 28 16:47:47 2013 -0500

    resize-popup: use a tooltip style for the resize popup window
    
    - set GTK_STYLE_CLASS_TOOLTIP on the window, and use the same code of
      GtkTooltip to paint it
    - set GDK_WINDOW_TYPE_HINT_TOOLTIP and make the window non-resizable, so
      it doesn't get an incorrect shadow from the WM
    
    https://bugzilla.gnome.org/show_bug.cgi?id=692741

 src/ui/resizepopup.c |   48 +++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 39 insertions(+), 9 deletions(-)
---
diff --git a/src/ui/resizepopup.c b/src/ui/resizepopup.c
index 63d0e5a..a4ae00b 100644
--- a/src/ui/resizepopup.c
+++ b/src/ui/resizepopup.c
@@ -67,22 +67,52 @@ meta_ui_resize_popup_free (MetaResizePopup *popup)
   g_free (popup);
 }
 
+static gboolean
+size_window_draw (GtkWidget *widget,
+                  cairo_t *cr,
+                  MetaResizePopup *popup)
+{
+  GtkStyleContext *context;
+  gint width, height;
+
+  context = gtk_widget_get_style_context (widget);
+  width = gtk_widget_get_allocated_width (widget);
+  height = gtk_widget_get_allocated_height (widget);
+
+  gtk_render_background (context, cr, 0, 0, width, height);
+  gtk_render_frame (context, cr, 0, 0, width, height);
+
+  return FALSE;
+}
+
 static void
 ensure_size_window (MetaResizePopup *popup)
 {
+  GdkVisual *visual;
+  GdkScreen *screen;
+
   if (popup->size_window)
     return;
-  
+
   popup->size_window = gtk_window_new (GTK_WINDOW_POPUP);
+  screen = gdk_display_get_screen (gdk_x11_lookup_xdisplay (popup->display),
+                                   popup->screen_number);
+  visual = gdk_screen_get_rgba_visual (screen);
+
+  gtk_window_set_screen (GTK_WINDOW (popup->size_window), screen);
+  if (visual != NULL)
+    gtk_widget_set_visual (popup->size_window, visual);
+
+  gtk_window_set_type_hint (GTK_WINDOW (popup->size_window),
+                            GDK_WINDOW_TYPE_HINT_TOOLTIP);
+  gtk_window_set_resizable (GTK_WINDOW (popup->size_window), FALSE);
+
+  gtk_widget_set_app_paintable (popup->size_window, TRUE);
+  gtk_style_context_add_class (gtk_widget_get_style_context (popup->size_window),
+                               GTK_STYLE_CLASS_TOOLTIP);
+  g_signal_connect (popup->size_window, "draw",
+                    G_CALLBACK (size_window_draw), popup);
 
-  gtk_window_set_screen (GTK_WINDOW (popup->size_window),
-			 gdk_display_get_screen (gdk_x11_lookup_xdisplay (popup->display),
-						 popup->screen_number));
-  
-  /* never shrink the size window */
-  gtk_window_set_resizable (GTK_WINDOW (popup->size_window),
-                            TRUE);
-  
   popup->size_label = gtk_label_new ("");
   g_object_set (popup->size_label, "margin", 6, NULL);
 


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