diff options
| author | Paul Eggert | 2013-05-06 22:34:01 -0700 |
|---|---|---|
| committer | Paul Eggert | 2013-05-06 22:34:01 -0700 |
| commit | e0c9d5650500f980701f1e0288db73ee32cbe7d0 (patch) | |
| tree | 6139a81ab72f9957884bfad1142b145fa26d7b6d /src | |
| parent | 150194c32f69feee7aae11d4ef21e8034d48b136 (diff) | |
| download | emacs-e0c9d5650500f980701f1e0288db73ee32cbe7d0.tar.gz emacs-e0c9d5650500f980701f1e0288db73ee32cbe7d0.zip | |
Static checking by GCC 4.8.0.
* xfns.c (x_get_net_workarea, struct MonitorInfo, free_monitors)
(x_get_monitor_for_frame, x_make_monitor_attribute_list)
(x_get_monitor_attributes_fallback)
(x_get_monitor_attributes_xinerama)
(x_get_monitor_attributes_xrandr, x_get_monitor_attributes):
Define only if USE_GTK.
(free_monitors): Define only if HAVE_XINERAMA || HAVE_XRANDR.
(x_get_monitor_attributes_fallback): Omit unused locals.
(x_get_monitor_attributes_xinerama, Fx_display_monitor_attributes_list):
Use double, not float, to avoid mixed-mode floating point arithmetic.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 14 | ||||
| -rw-r--r-- | src/xfns.c | 28 |
2 files changed, 31 insertions, 11 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 0d06f4e291d..e9629adf35a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,17 @@ | |||
| 1 | 2013-05-07 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Static checking by GCC 4.8.0. | ||
| 4 | * xfns.c (x_get_net_workarea, struct MonitorInfo, free_monitors) | ||
| 5 | (x_get_monitor_for_frame, x_make_monitor_attribute_list) | ||
| 6 | (x_get_monitor_attributes_fallback) | ||
| 7 | (x_get_monitor_attributes_xinerama) | ||
| 8 | (x_get_monitor_attributes_xrandr, x_get_monitor_attributes): | ||
| 9 | Define only if USE_GTK. | ||
| 10 | (free_monitors): Define only if HAVE_XINERAMA || HAVE_XRANDR. | ||
| 11 | (x_get_monitor_attributes_fallback): Omit unused locals. | ||
| 12 | (x_get_monitor_attributes_xinerama, Fx_display_monitor_attributes_list): | ||
| 13 | Use double, not float, to avoid mixed-mode floating point arithmetic. | ||
| 14 | |||
| 1 | 2013-05-07 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | 15 | 2013-05-07 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> |
| 2 | Jan Djärv <jan.h.d@swipnet.se> | 16 | Jan Djärv <jan.h.d@swipnet.se> |
| 3 | 17 | ||
diff --git a/src/xfns.c b/src/xfns.c index d3e3479be2d..d45d113a741 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -3804,6 +3804,8 @@ If omitted or nil, that stands for the selected frame's display. */) | |||
| 3804 | Return false if and only if the workarea information cannot be | 3804 | Return false if and only if the workarea information cannot be |
| 3805 | obtained via the _NET_WORKAREA root window property. */ | 3805 | obtained via the _NET_WORKAREA root window property. */ |
| 3806 | 3806 | ||
| 3807 | #ifndef USE_GTK | ||
| 3808 | |||
| 3807 | static bool | 3809 | static bool |
| 3808 | x_get_net_workarea (struct x_display_info *dpyinfo, XRectangle *rect) | 3810 | x_get_net_workarea (struct x_display_info *dpyinfo, XRectangle *rect) |
| 3809 | { | 3811 | { |
| @@ -3868,6 +3870,7 @@ struct MonitorInfo { | |||
| 3868 | char *name; | 3870 | char *name; |
| 3869 | }; | 3871 | }; |
| 3870 | 3872 | ||
| 3873 | #if defined HAVE_XINERAMA || defined HAVE_XRANDR | ||
| 3871 | static void | 3874 | static void |
| 3872 | free_monitors (struct MonitorInfo *monitors, int n_monitors) | 3875 | free_monitors (struct MonitorInfo *monitors, int n_monitors) |
| 3873 | { | 3876 | { |
| @@ -3876,6 +3879,7 @@ free_monitors (struct MonitorInfo *monitors, int n_monitors) | |||
| 3876 | xfree (monitors[i].name); | 3879 | xfree (monitors[i].name); |
| 3877 | xfree (monitors); | 3880 | xfree (monitors); |
| 3878 | } | 3881 | } |
| 3882 | #endif /* HAVE_XINERAMA || HAVE_XRANDR */ | ||
| 3879 | 3883 | ||
| 3880 | 3884 | ||
| 3881 | /* Return monitor number where F is "most" or closest to. */ | 3885 | /* Return monitor number where F is "most" or closest to. */ |
| @@ -3906,10 +3910,11 @@ x_get_monitor_for_frame (struct frame *f, | |||
| 3906 | if (x_intersect_rectangles (&mi->geom, &frect, &res)) | 3910 | if (x_intersect_rectangles (&mi->geom, &frect, &res)) |
| 3907 | { | 3911 | { |
| 3908 | a = res.width * res.height; | 3912 | a = res.width * res.height; |
| 3909 | if (a > area) { | 3913 | if (a > area) |
| 3910 | area = a; | 3914 | { |
| 3911 | best_area = i; | 3915 | area = a; |
| 3912 | } | 3916 | best_area = i; |
| 3917 | } | ||
| 3913 | } | 3918 | } |
| 3914 | 3919 | ||
| 3915 | if (a == 0 && area == 0) | 3920 | if (a == 0 && area == 0) |
| @@ -4005,7 +4010,6 @@ static Lisp_Object | |||
| 4005 | x_get_monitor_attributes_fallback (struct x_display_info *dpyinfo) | 4010 | x_get_monitor_attributes_fallback (struct x_display_info *dpyinfo) |
| 4006 | { | 4011 | { |
| 4007 | struct MonitorInfo monitor; | 4012 | struct MonitorInfo monitor; |
| 4008 | int width_mm, height_mm; | ||
| 4009 | XRectangle workarea_r; | 4013 | XRectangle workarea_r; |
| 4010 | 4014 | ||
| 4011 | /* Fallback: treat (possibly) multiple physical monitors as if they | 4015 | /* Fallback: treat (possibly) multiple physical monitors as if they |
| @@ -4035,7 +4039,7 @@ x_get_monitor_attributes_xinerama (struct x_display_info *dpyinfo) | |||
| 4035 | Display *dpy = dpyinfo->display; | 4039 | Display *dpy = dpyinfo->display; |
| 4036 | XineramaScreenInfo *info = XineramaQueryScreens (dpy, &n_monitors); | 4040 | XineramaScreenInfo *info = XineramaQueryScreens (dpy, &n_monitors); |
| 4037 | struct MonitorInfo *monitors; | 4041 | struct MonitorInfo *monitors; |
| 4038 | float mm_width_per_pixel, mm_height_per_pixel; | 4042 | double mm_width_per_pixel, mm_height_per_pixel; |
| 4039 | 4043 | ||
| 4040 | if (! info || n_monitors == 0) | 4044 | if (! info || n_monitors == 0) |
| 4041 | { | 4045 | { |
| @@ -4044,9 +4048,9 @@ x_get_monitor_attributes_xinerama (struct x_display_info *dpyinfo) | |||
| 4044 | return attributes_list; | 4048 | return attributes_list; |
| 4045 | } | 4049 | } |
| 4046 | 4050 | ||
| 4047 | mm_width_per_pixel = ((float) WidthMMOfScreen (dpyinfo->screen) | 4051 | mm_width_per_pixel = ((double) WidthMMOfScreen (dpyinfo->screen) |
| 4048 | / x_display_pixel_width (dpyinfo)); | 4052 | / x_display_pixel_width (dpyinfo)); |
| 4049 | mm_height_per_pixel = ((float) HeightMMOfScreen (dpyinfo->screen) | 4053 | mm_height_per_pixel = ((double) HeightMMOfScreen (dpyinfo->screen) |
| 4050 | / x_display_pixel_height (dpyinfo)); | 4054 | / x_display_pixel_height (dpyinfo)); |
| 4051 | monitors = (struct MonitorInfo *) xzalloc (n_monitors * sizeof (*monitors)); | 4055 | monitors = (struct MonitorInfo *) xzalloc (n_monitors * sizeof (*monitors)); |
| 4052 | for (i = 0; i < n_monitors; ++i) | 4056 | for (i = 0; i < n_monitors; ++i) |
| @@ -4218,6 +4222,8 @@ x_get_monitor_attributes (struct x_display_info *dpyinfo) | |||
| 4218 | return attributes_list; | 4222 | return attributes_list; |
| 4219 | } | 4223 | } |
| 4220 | 4224 | ||
| 4225 | #endif /* !USE_GTK */ | ||
| 4226 | |||
| 4221 | DEFUN ("x-display-monitor-attributes-list", Fx_display_monitor_attributes_list, | 4227 | DEFUN ("x-display-monitor-attributes-list", Fx_display_monitor_attributes_list, |
| 4222 | Sx_display_monitor_attributes_list, | 4228 | Sx_display_monitor_attributes_list, |
| 4223 | 0, 1, 0, | 4229 | 0, 1, 0, |
| @@ -4242,7 +4248,7 @@ Internal use only, use `display-monitor-attributes-list' instead. */) | |||
| 4242 | Lisp_Object attributes_list = Qnil; | 4248 | Lisp_Object attributes_list = Qnil; |
| 4243 | 4249 | ||
| 4244 | #ifdef USE_GTK | 4250 | #ifdef USE_GTK |
| 4245 | float mm_width_per_pixel, mm_height_per_pixel; | 4251 | double mm_width_per_pixel, mm_height_per_pixel; |
| 4246 | GdkDisplay *gdpy; | 4252 | GdkDisplay *gdpy; |
| 4247 | GdkScreen *gscreen; | 4253 | GdkScreen *gscreen; |
| 4248 | gint primary_monitor = 0, n_monitors, i; | 4254 | gint primary_monitor = 0, n_monitors, i; |
| @@ -4251,9 +4257,9 @@ Internal use only, use `display-monitor-attributes-list' instead. */) | |||
| 4251 | static const char *source = "Gdk"; | 4257 | static const char *source = "Gdk"; |
| 4252 | 4258 | ||
| 4253 | block_input (); | 4259 | block_input (); |
| 4254 | mm_width_per_pixel = ((float) WidthMMOfScreen (dpyinfo->screen) | 4260 | mm_width_per_pixel = ((double) WidthMMOfScreen (dpyinfo->screen) |
| 4255 | / x_display_pixel_width (dpyinfo)); | 4261 | / x_display_pixel_width (dpyinfo)); |
| 4256 | mm_height_per_pixel = ((float) HeightMMOfScreen (dpyinfo->screen) | 4262 | mm_height_per_pixel = ((double) HeightMMOfScreen (dpyinfo->screen) |
| 4257 | / x_display_pixel_height (dpyinfo)); | 4263 | / x_display_pixel_height (dpyinfo)); |
| 4258 | gdpy = gdk_x11_lookup_xdisplay (dpyinfo->display); | 4264 | gdpy = gdk_x11_lookup_xdisplay (dpyinfo->display); |
| 4259 | gscreen = gdk_display_get_default_screen (gdpy); | 4265 | gscreen = gdk_display_get_default_screen (gdpy); |