From 35adc02d428840befbaecb6c775c30ea62bd75a2 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 26 May 2018 10:05:19 +0200 Subject: [PATCH] wacom: Use GdkMonitor API on calibrator UI Replaces usage of deprecated GdkScreen API. We still have to pass monitor numbers around for gdk_window_fullscreen_on_monitor(), such is life. --- panels/wacom/calibrator/calibrator-gui.c | 8 +++++--- panels/wacom/cc-wacom-page.c | 19 ++++++++++++++----- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/panels/wacom/calibrator/calibrator-gui.c b/panels/wacom/calibrator/calibrator-gui.c index ed4a8ecc1..81a52cc56 100644 --- a/panels/wacom/calibrator/calibrator-gui.c +++ b/panels/wacom/calibrator/calibrator-gui.c @@ -665,7 +665,7 @@ set_up_stage (CalibArea *calib_area, ClutterActor *stage) */ CalibArea * calib_area_new (GdkScreen *screen, - int monitor, + int n_monitor, GdkDevice *device, FinishCallback callback, gpointer user_data, @@ -675,6 +675,7 @@ calib_area_new (GdkScreen *screen, CalibArea *calib_area; GdkRectangle rect; GdkVisual *visual; + GdkMonitor *monitor; #ifndef FAKE_AREA GdkWindow *window; GdkCursor *cursor; @@ -715,7 +716,8 @@ calib_area_new (GdkScreen *screen, /* Move to correct screen */ if (screen == NULL) screen = gdk_screen_get_default (); - gdk_screen_get_monitor_geometry (screen, monitor, &rect); + monitor = gdk_display_get_monitor (gdk_screen_get_display (screen), n_monitor); + gdk_monitor_get_geometry (monitor, &rect); calib_area->calibrator.geometry = rect; @@ -742,7 +744,7 @@ calib_area_new (GdkScreen *screen, G_CALLBACK (on_button_press_event), calib_area); - gtk_window_fullscreen_on_monitor (GTK_WINDOW (calib_area->window), screen, monitor); + gtk_window_fullscreen_on_monitor (GTK_WINDOW (calib_area->window), screen, n_monitor); visual = gdk_screen_get_rgba_visual (screen); if (visual != NULL) diff --git a/panels/wacom/cc-wacom-page.c b/panels/wacom/cc-wacom-page.c index bd4782604..ea3f5b70c 100644 --- a/panels/wacom/cc-wacom-page.c +++ b/panels/wacom/cc-wacom-page.c @@ -257,16 +257,25 @@ static gboolean run_calibration (CcWacomPage *page, GVariant *old_calibration, gdouble *cal, - gint monitor) + GdkMonitor *monitor) { + GdkDisplay *display = gdk_monitor_get_display (monitor); CcWacomPagePrivate *priv; + gint i, n_monitor = 0; g_assert (page->priv->area == NULL); priv = page->priv; + for (i = 0; i < gdk_display_get_n_monitors (display); i++) { + if (monitor == gdk_display_get_monitor (display, i)) { + n_monitor = i; + break; + } + } + priv->area = calib_area_new (NULL, - monitor, + n_monitor, cc_wacom_page_get_gdk_device (page), finish_calibration, page, @@ -289,7 +298,7 @@ calibrate (CcWacomPage *page) GVariant *old_calibration, **tmp, *array; gdouble *calibration; gsize ncal; - gint monitor; + GdkMonitor *monitor; GdkScreen *screen; GnomeRRScreen *rr_screen; GnomeRROutput *output; @@ -308,9 +317,9 @@ calibrate (CcWacomPage *page) output = cc_wacom_device_get_output (page->priv->stylus, rr_screen); gnome_rr_output_get_position (output, &x, &y); - monitor = gdk_screen_get_monitor_at_point (screen, x, y); + monitor = gdk_display_get_monitor_at_point (gdk_screen_get_display (screen), x, y); - if (monitor < 0) { + if (!monitor) { /* The display the tablet should be mapped to could not be located. * This shouldn't happen if the EDID data is good... */