workspace: Extend builtin struts to screen edge when possible

Struts are defined in terms of screen edges, so expand the rectangles
we get via set_builtin_struts() accordingly. However we do want to
allow chrome on edges between monitors, in which case the expansion
would render an entire monitor unusable - don't expand the rectangles
in that case, which means we will only use them for constraining
windows but ignore them for the client-visible _NET_WORKAREA property.

https://bugzilla.gnome.org/show_bug.cgi?id=730527
This commit is contained in:
Florian Müllner 2014-06-11 02:16:13 +02:00
parent f3d7c9cff9
commit a7350475e8

View File

@ -1040,6 +1040,45 @@ void
meta_workspace_set_builtin_struts (MetaWorkspace *workspace, meta_workspace_set_builtin_struts (MetaWorkspace *workspace,
GSList *struts) GSList *struts)
{ {
MetaScreen *screen = workspace->screen;
GSList *l;
for (l = struts; l; l = l->next)
{
MetaStrut *strut = l->data;
int idx = meta_screen_get_monitor_index_for_rect (screen, &strut->rect);
switch (strut->side)
{
case META_SIDE_TOP:
if (meta_screen_get_monitor_neighbor (screen, idx, META_SCREEN_UP))
continue;
strut->rect.height += strut->rect.y;
strut->rect.y = 0;
break;
case META_SIDE_BOTTOM:
if (meta_screen_get_monitor_neighbor (screen, idx, META_SCREEN_DOWN))
continue;
strut->rect.height = screen->rect.height - strut->rect.y;
break;
case META_SIDE_LEFT:
if (meta_screen_get_monitor_neighbor (screen, idx, META_SCREEN_LEFT))
continue;
strut->rect.width += strut->rect.x;
strut->rect.x = 0;
break;
case META_SIDE_RIGHT:
if (meta_screen_get_monitor_neighbor (screen, idx, META_SCREEN_RIGHT))
continue;
strut->rect.width = screen->rect.width - strut->rect.x;
break;
}
}
/* Reordering doesn't actually matter, so we don't catch all /* Reordering doesn't actually matter, so we don't catch all
* no-impact changes, but this is just a (possibly unnecessary * no-impact changes, but this is just a (possibly unnecessary
* anyways) optimization */ * anyways) optimization */