[gnome-control-center/benzea/display-snap-after-changes: 2/3] display: Add function to run the snapping algorithm on a monitor
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/benzea/display-snap-after-changes: 2/3] display: Add function to run the snapping algorithm on a monitor
- Date: Tue, 23 Oct 2018 21:20:23 +0000 (UTC)
commit 2612f16f9854a68661d565669befda46f2ec7924
Author: Benjamin Berg <bberg redhat com>
Date: Tue Oct 23 23:15:24 2018 +0200
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.
panels/display/cc-display-arrangement.c | 28 ++++++++++++++++++++++++++++
panels/display/cc-display-arrangement.h | 5 +++++
2 files changed, 33 insertions(+)
---
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]