mirror of
https://github.com/brl/mutter.git
synced 2024-12-26 12:52:14 +00:00
backends: Refactor MetaScreenDirection guessing into separate function
Make it a helper MetaLogicalMonitor API, and use it on the MetaMonitorManager. https://bugzilla.gnome.org/show_bug.cgi?id=778119
This commit is contained in:
parent
e60dfd5b23
commit
efae039ad9
@ -180,3 +180,43 @@ static void
|
||||
meta_logical_monitor_class_init (MetaLogicalMonitorClass *klass)
|
||||
{
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_logical_monitor_has_neighbor (MetaLogicalMonitor *logical_monitor,
|
||||
MetaLogicalMonitor *neighbor,
|
||||
MetaScreenDirection neighbor_direction)
|
||||
{
|
||||
switch (neighbor_direction)
|
||||
{
|
||||
case META_SCREEN_RIGHT:
|
||||
if (neighbor->rect.x == (logical_monitor->rect.x +
|
||||
logical_monitor->rect.width) &&
|
||||
meta_rectangle_vert_overlap (&neighbor->rect,
|
||||
&logical_monitor->rect))
|
||||
return TRUE;
|
||||
break;
|
||||
case META_SCREEN_LEFT:
|
||||
if (logical_monitor->rect.x == (neighbor->rect.x +
|
||||
neighbor->rect.width) &&
|
||||
meta_rectangle_vert_overlap (&neighbor->rect,
|
||||
&logical_monitor->rect))
|
||||
return TRUE;
|
||||
break;
|
||||
case META_SCREEN_UP:
|
||||
if (logical_monitor->rect.y == (neighbor->rect.y +
|
||||
neighbor->rect.height) &&
|
||||
meta_rectangle_horiz_overlap (&neighbor->rect,
|
||||
&logical_monitor->rect))
|
||||
return TRUE;
|
||||
break;
|
||||
case META_SCREEN_DOWN:
|
||||
if (neighbor->rect.y == (logical_monitor->rect.y +
|
||||
logical_monitor->rect.height) &&
|
||||
meta_rectangle_horiz_overlap (&neighbor->rect,
|
||||
&logical_monitor->rect))
|
||||
return TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -80,4 +80,8 @@ int meta_logical_monitor_get_scale (MetaLogicalMonitor *logical_monitor);
|
||||
|
||||
GList * meta_logical_monitor_get_monitors (MetaLogicalMonitor *logical_monitor);
|
||||
|
||||
gboolean meta_logical_monitor_has_neighbor (MetaLogicalMonitor *logical_monitor,
|
||||
MetaLogicalMonitor *neighbor,
|
||||
MetaScreenDirection neighbor_dir);
|
||||
|
||||
#endif /* META_LOGICAL_MONITOR_H */
|
||||
|
@ -1572,37 +1572,8 @@ meta_monitor_manager_get_logical_monitor_neighbor (MetaMonitorManager *manager,
|
||||
{
|
||||
MetaLogicalMonitor *other = l->data;
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
case META_SCREEN_RIGHT:
|
||||
if (other->rect.x == (logical_monitor->rect.x +
|
||||
logical_monitor->rect.width) &&
|
||||
meta_rectangle_vert_overlap (&other->rect,
|
||||
&logical_monitor->rect))
|
||||
return other;
|
||||
break;
|
||||
case META_SCREEN_LEFT:
|
||||
if (logical_monitor->rect.x == (other->rect.x +
|
||||
other->rect.width) &&
|
||||
meta_rectangle_vert_overlap (&other->rect,
|
||||
&logical_monitor->rect))
|
||||
return other;
|
||||
break;
|
||||
case META_SCREEN_UP:
|
||||
if (logical_monitor->rect.y == (other->rect.y +
|
||||
other->rect.height) &&
|
||||
meta_rectangle_horiz_overlap (&other->rect,
|
||||
&logical_monitor->rect))
|
||||
return other;
|
||||
break;
|
||||
case META_SCREEN_DOWN:
|
||||
if (other->rect.y == (logical_monitor->rect.y +
|
||||
logical_monitor->rect.height) &&
|
||||
meta_rectangle_horiz_overlap (&other->rect,
|
||||
&logical_monitor->rect))
|
||||
return other;
|
||||
break;
|
||||
}
|
||||
if (meta_logical_monitor_has_neighbor (logical_monitor, other, direction))
|
||||
return other;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user