Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wnck-pager: update workspace switcher aspect ratio #1417

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions libmate-panel-applet/mate-panel-applet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
57 changes: 43 additions & 14 deletions mate-panel/panel-widget.c
Original file line number Diff line number Diff line change
Expand Up @@ -1401,6 +1401,45 @@ queue_resize_on_all_applets(PanelWidget *panel)
}
}

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);

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);

gtk_widget_get_preferred_height_for_width (ad->applet,
minimum_size->width,
&minimum_size->height,
NULL);
}
else
{
g_assert_not_reached ();
}
}

static void
panel_widget_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
{
Expand Down Expand Up @@ -1441,15 +1480,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;
Expand All @@ -1461,8 +1498,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;
Expand Down Expand Up @@ -1509,7 +1544,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)
Expand Down Expand Up @@ -1674,7 +1709,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;
Expand Down Expand Up @@ -1762,22 +1797,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;
}
Expand Down