aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Stephani2017-08-27 13:15:34 +0200
committerPhilipp Stephani2017-08-27 14:05:40 +0200
commit2132629573472c74d0d42fc073fe62903c335f8b (patch)
tree642a02285d6bf114033c2499971e8569265d0b5d
parent7cb3d3bba149ec69fc03bf261556cfe92a9d2b40 (diff)
downloademacs-2132629573472c74d0d42fc073fe62903c335f8b.tar.gz
emacs-2132629573472c74d0d42fc073fe62903c335f8b.zip
Stop using deprecated GdkScreen monitor functions in newer GDK
* src/xfns.c (Fx_display_monitor_attributes_list): Use GdkMonitor objects instead of the deprecated GdkScreen functions in GDK 3.22+
-rw-r--r--src/xfns.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/xfns.c b/src/xfns.c
index 2f8c9c25416..40f06e2d9f3 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -4884,7 +4884,9 @@ Internal use only, use `display-monitor-attributes-list' instead. */)
4884#ifdef USE_GTK 4884#ifdef USE_GTK
4885 double mm_width_per_pixel, mm_height_per_pixel; 4885 double mm_width_per_pixel, mm_height_per_pixel;
4886 GdkDisplay *gdpy; 4886 GdkDisplay *gdpy;
4887#if ! GTK_CHECK_VERSION (3, 22, 0)
4887 GdkScreen *gscreen; 4888 GdkScreen *gscreen;
4889#endif
4888 gint primary_monitor = 0, n_monitors, i; 4890 gint primary_monitor = 0, n_monitors, i;
4889 Lisp_Object monitor_frames, rest, frame; 4891 Lisp_Object monitor_frames, rest, frame;
4890 static const char *source = "Gdk"; 4892 static const char *source = "Gdk";
@@ -4896,11 +4898,15 @@ Internal use only, use `display-monitor-attributes-list' instead. */)
4896 mm_height_per_pixel = ((double) HeightMMOfScreen (dpyinfo->screen) 4898 mm_height_per_pixel = ((double) HeightMMOfScreen (dpyinfo->screen)
4897 / x_display_pixel_height (dpyinfo)); 4899 / x_display_pixel_height (dpyinfo));
4898 gdpy = gdk_x11_lookup_xdisplay (dpyinfo->display); 4900 gdpy = gdk_x11_lookup_xdisplay (dpyinfo->display);
4901#if GTK_CHECK_VERSION (3, 22, 0)
4902 n_monitors = gdk_display_get_n_monitors (gdpy);
4903#else
4899 gscreen = gdk_display_get_default_screen (gdpy); 4904 gscreen = gdk_display_get_default_screen (gdpy);
4900#if GTK_CHECK_VERSION (2, 20, 0) 4905#if GTK_CHECK_VERSION (2, 20, 0)
4901 primary_monitor = gdk_screen_get_primary_monitor (gscreen); 4906 primary_monitor = gdk_screen_get_primary_monitor (gscreen);
4902#endif 4907#endif
4903 n_monitors = gdk_screen_get_n_monitors (gscreen); 4908 n_monitors = gdk_screen_get_n_monitors (gscreen);
4909#endif
4904 monitor_frames = Fmake_vector (make_number (n_monitors), Qnil); 4910 monitor_frames = Fmake_vector (make_number (n_monitors), Qnil);
4905 monitors = xzalloc (n_monitors * sizeof *monitors); 4911 monitors = xzalloc (n_monitors * sizeof *monitors);
4906 4912
@@ -4913,7 +4919,14 @@ Internal use only, use `display-monitor-attributes-list' instead. */)
4913 { 4919 {
4914 GdkWindow *gwin = gtk_widget_get_window (FRAME_GTK_WIDGET (f)); 4920 GdkWindow *gwin = gtk_widget_get_window (FRAME_GTK_WIDGET (f));
4915 4921
4922#if GTK_CHECK_VERSION (3, 22, 0)
4923 for (i = 0; i < n_monitors; i++)
4924 if (gdk_display_get_monitor_at_window (gdpy, gwin)
4925 == gdk_display_get_monitor (gdpy, i))
4926 break;
4927#else
4916 i = gdk_screen_get_monitor_at_window (gscreen, gwin); 4928 i = gdk_screen_get_monitor_at_window (gscreen, gwin);
4929#endif
4917 ASET (monitor_frames, i, Fcons (frame, AREF (monitor_frames, i))); 4930 ASET (monitor_frames, i, Fcons (frame, AREF (monitor_frames, i)));
4918 } 4931 }
4919 } 4932 }
@@ -4924,9 +4937,19 @@ Internal use only, use `display-monitor-attributes-list' instead. */)
4924 GdkRectangle rec, work; 4937 GdkRectangle rec, work;
4925 struct MonitorInfo *mi = &monitors[i]; 4938 struct MonitorInfo *mi = &monitors[i];
4926 4939
4940#if GTK_CHECK_VERSION (3, 22, 0)
4941 GdkMonitor *monitor = gdk_display_get_monitor (gdpy, i);
4942 if (gdk_monitor_is_primary (monitor))
4943 primary_monitor = i;
4944 gdk_monitor_get_geometry (monitor, &rec);
4945#else
4927 gdk_screen_get_monitor_geometry (gscreen, i, &rec); 4946 gdk_screen_get_monitor_geometry (gscreen, i, &rec);
4947#endif
4928 4948
4929#if GTK_CHECK_VERSION (2, 14, 0) 4949#if GTK_CHECK_VERSION (3, 22, 0)
4950 width_mm = gdk_monitor_get_width_mm (monitor);
4951 height_mm = gdk_monitor_get_height_mm (monitor);
4952#elif GTK_CHECK_VERSION (2, 14, 0)
4930 width_mm = gdk_screen_get_monitor_width_mm (gscreen, i); 4953 width_mm = gdk_screen_get_monitor_width_mm (gscreen, i);
4931 height_mm = gdk_screen_get_monitor_height_mm (gscreen, i); 4954 height_mm = gdk_screen_get_monitor_height_mm (gscreen, i);
4932#endif 4955#endif
@@ -4935,7 +4958,9 @@ Internal use only, use `display-monitor-attributes-list' instead. */)
4935 if (height_mm < 0) 4958 if (height_mm < 0)
4936 height_mm = rec.height * mm_height_per_pixel + 0.5; 4959 height_mm = rec.height * mm_height_per_pixel + 0.5;
4937 4960
4938#if GTK_CHECK_VERSION (3, 4, 0) 4961#if GTK_CHECK_VERSION (3, 22, 0)
4962 gdk_monitor_get_workarea (monitor, &work);
4963#elif GTK_CHECK_VERSION (3, 4, 0)
4939 gdk_screen_get_monitor_workarea (gscreen, i, &work); 4964 gdk_screen_get_monitor_workarea (gscreen, i, &work);
4940#else 4965#else
4941 /* Emulate the behavior of GTK+ 3.4. */ 4966 /* Emulate the behavior of GTK+ 3.4. */
@@ -4968,7 +4993,9 @@ Internal use only, use `display-monitor-attributes-list' instead. */)
4968 mi->mm_width = width_mm; 4993 mi->mm_width = width_mm;
4969 mi->mm_height = height_mm; 4994 mi->mm_height = height_mm;
4970 4995
4971#if GTK_CHECK_VERSION (2, 14, 0) 4996#if GTK_CHECK_VERSION (3, 22, 0)
4997 mi->name = g_strdup (gdk_monitor_get_model (monitor));
4998#elif GTK_CHECK_VERSION (2, 14, 0)
4972 mi->name = gdk_screen_get_monitor_plug_name (gscreen, i); 4999 mi->name = gdk_screen_get_monitor_plug_name (gscreen, i);
4973#endif 5000#endif
4974 } 5001 }