diff options
author | Benjamin Berg <bberg@redhat.com> | 2018-10-23 23:15:24 +0200 |
---|---|---|
committer | Benjamin Berg <bberg@redhat.com> | 2018-10-24 10:36:13 +0200 |
commit | adf7cb26ea678a6c7c6e5ac7b27fe29604c92682 (patch) | |
tree | 62711cbde7cba6134ab67818b4a6e0a621d5e686 | |
parent | 1ad0eaba7c6dc70539fa85de4273a3836c0c81e1 (diff) | |
download | gnome-control-center-adf7cb26ea678a6c7c6e5ac7b27fe29604c92682.tar.gz |
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.
-rw-r--r-- | panels/display/cc-display-arrangement.c | 28 | ||||
-rw-r--r-- | panels/display/cc-display-arrangement.h | 5 |
2 files changed, 33 insertions, 0 deletions
diff --git a/panels/display/cc-display-arrangement.c b/panels/display/cc-display-arrangement.c index 936d05e4b..db72adca7 100644 --- a/panels/display/cc-display-arrangement.c +++ b/panels/display/cc-display-arrangement.c @@ -930,3 +930,31 @@ cc_display_arrangement_set_selected_output (CcDisplayArrangement *self, g_object_notify_by_pspec (G_OBJECT (self), props[PROP_SELECTED_OUTPUT]); } + +void +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)) + return; + + if (cc_display_config_count_useful_monitors (config) <= 1) + return; + + 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); +} diff --git a/panels/display/cc-display-arrangement.h b/panels/display/cc-display-arrangement.h index e7592c8b8..8d0e39bc0 100644 --- a/panels/display/cc-display-arrangement.h +++ b/panels/display/cc-display-arrangement.h @@ -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); + G_END_DECLS |