Commit 3f8afe15 authored by Benjamin Berg's avatar Benjamin Berg

display: Add function to run the snapping algorithm on a monitor

This is a function working only on a configuration which runs the
snapping with infinite snapping. This allows forcing a monitor that has
been modified to be adjacent to at least one monitor.

(cherry picked from commit adf7cb26)
parent 222bf954
......@@ -930,3 +930,31 @@ cc_display_arrangement_set_selected_output (CcDisplayArrangement *self,
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_SELECTED_OUTPUT]);
cc_display_config_snap_output (CcDisplayConfig *config,
CcDisplayMonitor *output)
struct SnapData snap_data;
gint x, y, w, h;
if (!cc_display_monitor_is_useful (output))
if (cc_display_config_count_useful_monitors (config) <= 1)
get_scaled_geometry (config, output, &x, &y, &w, &h);
snap_data.snapped = SNAP_DIR_NONE;
snap_data.mon_x = x;
snap_data.mon_y = y;
snap_data.dist_x = 0;
snap_data.dist_y = 0;
cairo_matrix_init_identity (&snap_data.to_widget);
snap_data.major_snap_distance = G_MAXUINT;
find_best_snapping (config, output, &snap_data);
cc_display_monitor_set_position (output, snap_data.mon_x, snap_data.mon_y);
......@@ -34,5 +34,10 @@ CcDisplayMonitor* cc_display_arrangement_get_selected_output (CcDisplayArran
void cc_display_arrangement_set_selected_output (CcDisplayArrangement *arr,
CcDisplayMonitor *output);
/* This is a bit of an odd-ball, but it currently makes sense to have it with
* the arrangement widget where the snapping code lives. */
void cc_display_config_snap_output (CcDisplayConfig *config,
CcDisplayMonitor *output);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment