diff --git a/libmate-panel-applet/mate-panel-applet.c b/libmate-panel-applet/mate-panel-applet.c index 043155312..0830569f2 100644 --- a/libmate-panel-applet/mate-panel-applet.c +++ b/libmate-panel-applet/mate-panel-applet.c @@ -1132,15 +1132,21 @@ mate_panel_applet_get_preferred_height (GtkWidget *widget, static GtkSizeRequestMode mate_panel_applet_get_request_mode (GtkWidget *widget) { - /* Do not use GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH - * or GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT - * to avoid problems with in-process applets - * when the panel is not expanded - * See https://github.com/mate-desktop/mate-panel/issues/797 - * and https://github.com/mate-desktop/mate-panel/issues/799 - * Out of process applets already use GTK_SIZE_REQUEST_CONSTANT_SIZE - */ - return GTK_SIZE_REQUEST_CONSTANT_SIZE; + MatePanelApplet *applet = MATE_PANEL_APPLET (widget); + MatePanelAppletPrivate *priv; + MatePanelAppletOrient orientation; + + priv = mate_panel_applet_get_instance_private (applet); + + if (priv->out_of_process) + return GTK_SIZE_REQUEST_CONSTANT_SIZE; + + orientation = mate_panel_applet_get_orient (applet); + if (orientation == MATE_PANEL_APPLET_ORIENT_UP || + orientation == MATE_PANEL_APPLET_ORIENT_DOWN) + return GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH; + + return GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT; } static void diff --git a/mate-panel/panel-widget.c b/mate-panel/panel-widget.c index dd8f6d111..644c054d1 100644 --- a/mate-panel/panel-widget.c +++ b/mate-panel/panel-widget.c @@ -1401,6 +1401,91 @@ queue_resize_on_all_applets(PanelWidget *panel) } } +static const gchar *applet_debug_name (AppletData *ad) +{ + GtkWidget *widget = ad->applet; + static GString *gstring = NULL; + + if (!gstring) + gstring = g_string_new (NULL); + else + gstring = g_string_truncate (gstring, 0); + + do + { + if (gstring->len) + g_string_append (gstring, " / "); + g_string_append (gstring, gtk_widget_get_name (widget)); + + if (!GTK_IS_CONTAINER (widget)) + widget = NULL; + else + { + GList *children = gtk_container_get_children (GTK_CONTAINER (widget)); + + if (!children) + widget = NULL; + else + { + widget = children->data; + g_list_free (children); + } + } + } while (widget); + + return gstring->str; +} + +static void +get_preferred_size (PanelWidget *self, + AppletData *ad, + GtkRequisition *minimum_size) +{ + if (self->orient == GTK_ORIENTATION_HORIZONTAL) + { + if (ad->expand_minor) + minimum_size->height = self->sz; + else + gtk_widget_get_preferred_height (ad->applet, + &minimum_size->height, + NULL); + + g_print ("[%s] querying width for height %d\n", + applet_debug_name (ad), + minimum_size->height); + gtk_widget_get_preferred_width_for_height (ad->applet, + minimum_size->height, + &minimum_size->width, + NULL); + } + else if (self->orient == GTK_ORIENTATION_VERTICAL) + { + if (ad->expand_minor) + minimum_size->width = self->sz; + else + gtk_widget_get_preferred_width (ad->applet, + &minimum_size->width, + NULL); + + g_print ("[%s] querying height for width %d\n", + applet_debug_name (ad), + minimum_size->width); + gtk_widget_get_preferred_height_for_width (ad->applet, + minimum_size->width, + &minimum_size->height, + NULL); + } + else + { + g_assert_not_reached (); + } + + g_print ("[%s] height - %d, width - %d\n", + applet_debug_name (ad), + minimum_size->height, + minimum_size->width); +} + static void panel_widget_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { @@ -1441,15 +1526,13 @@ panel_widget_size_allocate(GtkWidget *widget, GtkAllocation *allocation) AppletData *ad = list->data; GtkAllocation challoc; GtkRequisition chreq; - gtk_widget_get_preferred_size (ad->applet, &chreq, NULL); + get_preferred_size (panel, ad, &chreq); ad->constrained = i; challoc.width = chreq.width; challoc.height = chreq.height; if(panel->orient == GTK_ORIENTATION_HORIZONTAL) { - if (ad->expand_minor) - challoc.height = allocation->height; if (ad->expand_major && ad->size_hints) { int width = panel->applets_using_hint[applet_using_hint_index].size; @@ -1461,8 +1544,6 @@ panel_widget_size_allocate(GtkWidget *widget, GtkAllocation *allocation) challoc.x = ltr ? ad->constrained : panel->size - ad->constrained - challoc.width; challoc.y = allocation->height / 2 - challoc.height / 2; } else { - if (ad->expand_minor) - challoc.width = allocation->width; if (ad->expand_major && ad->size_hints) { int height = panel->applets_using_hint[applet_using_hint_index].size; @@ -1509,7 +1590,7 @@ panel_widget_size_allocate(GtkWidget *widget, GtkAllocation *allocation) PanelObjectEdgeRelativity edge_relativity = PANEL_EDGE_START; gboolean right_stuck = FALSE; - gtk_widget_get_preferred_size (ad->applet, &chreq, NULL); + get_preferred_size (panel, ad, &chreq); if (!ad->expand_major || !ad->size_hints) { if(panel->orient == GTK_ORIENTATION_HORIZONTAL) @@ -1674,7 +1755,7 @@ panel_widget_size_allocate(GtkWidget *widget, GtkAllocation *allocation) const char *id; AppletInfo *info; PanelObjectEdgeRelativity edge_relativity = PANEL_EDGE_START; - gboolean right_stuck; + gboolean right_stuck = FALSE; AppletData *pad; int prior_space; int following_space; @@ -1762,22 +1843,16 @@ panel_widget_size_allocate(GtkWidget *widget, GtkAllocation *allocation) AppletData *ad = list->data; GtkAllocation challoc; GtkRequisition chreq; - gtk_widget_get_preferred_size (ad->applet, &chreq, NULL); + get_preferred_size (panel, ad, &chreq); challoc.width = chreq.width; challoc.height = chreq.height; if(panel->orient == GTK_ORIENTATION_HORIZONTAL) { challoc.width = ad->cells; - if (ad->expand_minor) { - challoc.height = allocation->height; - } challoc.x = ltr ? ad->constrained : panel->size - ad->constrained - challoc.width; challoc.y = allocation->height / 2 - challoc.height / 2; } else { challoc.height = ad->cells; - if (ad->expand_minor) { - challoc.width = allocation->width; - } challoc.x = allocation->width / 2 - challoc.width / 2; challoc.y = ad->constrained; }