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
This commit is contained in:
parent
34fc234fd7
commit
94e6e55ef7
@ -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);
|
||||
|
||||
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_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);
|
||||
|
||||
popup->size_label = gtk_label_new ("");
|
||||
g_object_set (popup->size_label, "margin", 6, NULL);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user