diff options
| author | Gerd Moellmann | 1999-09-03 18:49:56 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 1999-09-03 18:49:56 +0000 |
| commit | d62c8769252960dcc14554e7eb33cbf2af9aee5a (patch) | |
| tree | 9c69ce0b740347f3b193ed14f76a6ea993da0295 /src | |
| parent | b61cbba3c14949390100577dbf0592b23a7e0def (diff) | |
| download | emacs-d62c8769252960dcc14554e7eb33cbf2af9aee5a.tar.gz emacs-d62c8769252960dcc14554e7eb33cbf2af9aee5a.zip | |
Include math.h. Add extern declaration for atof in case
we don't see one.
(Qscreen_gamma): New.
(struct x_frame_parm_table): Add prototypes, add
x_set_screen_gamma.
(gamma_correct): New function.
(defined_color): Call it.
(x_set_screen_gamma): New.
(x_set_title): Add parameter old_value.
(RES_TYPE_FLOAT): New.
(x_get_arg): Handle RES_TYPE_FLOAT.
(Fx_create_frame): Call x_default_parameter for `screen-gamma'.
(lookup_pixel_color): Change call to x_alloc_nearest_color to
new prototype.
(lookup_rgb_color): Ditto.
(syms_of_xfns): Initialize Qscreen_gamma.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xfns.c | 108 |
1 files changed, 81 insertions, 27 deletions
diff --git a/src/xfns.c b/src/xfns.c index dbb7dae53b6..edc538f3e3e 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -30,6 +30,7 @@ Boston, MA 02111-1307, USA. */ | |||
| 30 | #include <signal.h> | 30 | #include <signal.h> |
| 31 | #include <config.h> | 31 | #include <config.h> |
| 32 | #include <stdio.h> | 32 | #include <stdio.h> |
| 33 | #include <math.h> | ||
| 33 | 34 | ||
| 34 | /* This makes the fields of a Display accessible, in Xlib header files. */ | 35 | /* This makes the fields of a Display accessible, in Xlib header files. */ |
| 35 | 36 | ||
| @@ -120,6 +121,7 @@ extern XFontStruct *xlwmenu_default_font; | |||
| 120 | #endif | 121 | #endif |
| 121 | 122 | ||
| 122 | extern void free_frame_menubar (); | 123 | extern void free_frame_menubar (); |
| 124 | extern double atof (); | ||
| 123 | 125 | ||
| 124 | #endif /* USE_X_TOOLKIT */ | 126 | #endif /* USE_X_TOOLKIT */ |
| 125 | 127 | ||
| @@ -251,6 +253,7 @@ Lisp_Object Quser_position; | |||
| 251 | Lisp_Object Quser_size; | 253 | Lisp_Object Quser_size; |
| 252 | Lisp_Object Qdisplay; | 254 | Lisp_Object Qdisplay; |
| 253 | Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background; | 255 | Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background; |
| 256 | Lisp_Object Qscreen_gamma; | ||
| 254 | 257 | ||
| 255 | /* The below are defined in frame.c. */ | 258 | /* The below are defined in frame.c. */ |
| 256 | 259 | ||
| @@ -741,29 +744,31 @@ x_destroy_all_bitmaps (dpyinfo) | |||
| 741 | struct x_frame_parm_table | 744 | struct x_frame_parm_table |
| 742 | { | 745 | { |
| 743 | char *name; | 746 | char *name; |
| 744 | void (*setter)( /* struct frame *frame, Lisp_Object val, oldval */ ); | 747 | void (*setter) P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 745 | }; | 748 | }; |
| 746 | 749 | ||
| 747 | void x_set_foreground_color (); | 750 | void x_set_foreground_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 748 | void x_set_background_color (); | 751 | void x_set_background_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 749 | void x_set_mouse_color (); | 752 | void x_set_mouse_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 750 | void x_set_cursor_color (); | 753 | void x_set_cursor_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 751 | void x_set_border_color (); | 754 | void x_set_border_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 752 | void x_set_cursor_type (); | 755 | void x_set_cursor_type P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 753 | void x_set_icon_type (); | 756 | void x_set_icon_type P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 754 | void x_set_icon_name (); | 757 | void x_set_icon_name P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 755 | void x_set_font (); | 758 | void x_set_font P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 756 | void x_set_border_width (); | 759 | void x_set_border_width P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 757 | void x_set_internal_border_width (); | 760 | void x_set_internal_border_width P_ ((struct frame *, Lisp_Object, |
| 758 | void x_explicitly_set_name (); | 761 | Lisp_Object)); |
| 759 | void x_set_autoraise (); | 762 | void x_explicitly_set_name P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 760 | void x_set_autolower (); | 763 | void x_set_autoraise P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 761 | void x_set_vertical_scroll_bars (); | 764 | void x_set_autolower P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 762 | void x_set_visibility (); | 765 | void x_set_vertical_scroll_bars P_ ((struct frame *, Lisp_Object, |
| 763 | void x_set_menu_bar_lines (); | 766 | Lisp_Object)); |
| 764 | void x_set_scroll_bar_width (); | 767 | void x_set_visibility P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 765 | void x_set_title (); | 768 | void x_set_menu_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 766 | void x_set_unsplittable (); | 769 | void x_set_scroll_bar_width P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 770 | void x_set_title P_ ((struct frame *, Lisp_Object, Lisp_Object)); | ||
| 771 | void x_set_unsplittable P_ ((struct frame *, Lisp_Object, Lisp_Object)); | ||
| 767 | void x_set_toolbar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object)); | 772 | void x_set_toolbar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object)); |
| 768 | void x_set_scroll_bar_foreground P_ ((struct frame *, Lisp_Object, | 773 | void x_set_scroll_bar_foreground P_ ((struct frame *, Lisp_Object, |
| 769 | Lisp_Object)); | 774 | Lisp_Object)); |
| @@ -774,6 +779,7 @@ static Lisp_Object x_default_scroll_bar_color_parameter P_ ((struct frame *, | |||
| 774 | Lisp_Object, | 779 | Lisp_Object, |
| 775 | char *, char *, | 780 | char *, char *, |
| 776 | int)); | 781 | int)); |
| 782 | static void x_set_screen_gamma P_ ((struct frame *, Lisp_Object, Lisp_Object)); | ||
| 777 | 783 | ||
| 778 | static struct x_frame_parm_table x_frame_parms[] = | 784 | static struct x_frame_parm_table x_frame_parms[] = |
| 779 | { | 785 | { |
| @@ -800,6 +806,7 @@ static struct x_frame_parm_table x_frame_parms[] = | |||
| 800 | "toolbar-lines", x_set_toolbar_lines, | 806 | "toolbar-lines", x_set_toolbar_lines, |
| 801 | "scroll-bar-foreground", x_set_scroll_bar_foreground, | 807 | "scroll-bar-foreground", x_set_scroll_bar_foreground, |
| 802 | "scroll-bar-background", x_set_scroll_bar_background, | 808 | "scroll-bar-background", x_set_scroll_bar_background, |
| 809 | "screen-gamma", x_set_screen_gamma | ||
| 803 | }; | 810 | }; |
| 804 | 811 | ||
| 805 | /* Attach the `x-frame-parameter' properties to | 812 | /* Attach the `x-frame-parameter' properties to |
| @@ -1208,6 +1215,23 @@ x_report_frame_params (f, alistptr) | |||
| 1208 | } | 1215 | } |
| 1209 | 1216 | ||
| 1210 | 1217 | ||
| 1218 | |||
| 1219 | /* Gamma-correct COLOR on frame F. */ | ||
| 1220 | |||
| 1221 | void | ||
| 1222 | gamma_correct (f, color) | ||
| 1223 | struct frame *f; | ||
| 1224 | XColor *color; | ||
| 1225 | { | ||
| 1226 | if (f->gamma) | ||
| 1227 | { | ||
| 1228 | color->red = pow (color->red / 65535.0, f->gamma) * 65535.0 + 0.5; | ||
| 1229 | color->green = pow (color->green / 65535.0, f->gamma) * 65535.0 + 0.5; | ||
| 1230 | color->blue = pow (color->blue / 65535.0, f->gamma) * 65535.0 + 0.5; | ||
| 1231 | } | ||
| 1232 | } | ||
| 1233 | |||
| 1234 | |||
| 1211 | /* Decide if color named COLOR is valid for the display associated with | 1235 | /* Decide if color named COLOR is valid for the display associated with |
| 1212 | the selected frame; if so, return the rgb values in COLOR_DEF. | 1236 | the selected frame; if so, return the rgb values in COLOR_DEF. |
| 1213 | If ALLOC is nonzero, allocate a new colormap cell. */ | 1237 | If ALLOC is nonzero, allocate a new colormap cell. */ |
| @@ -1229,6 +1253,9 @@ defined_color (f, color, color_def, alloc) | |||
| 1229 | status = XParseColor (display, screen_colormap, color, color_def); | 1253 | status = XParseColor (display, screen_colormap, color, color_def); |
| 1230 | if (status && alloc) | 1254 | if (status && alloc) |
| 1231 | { | 1255 | { |
| 1256 | /* Apply gamma correction. */ | ||
| 1257 | gamma_correct (f, color_def); | ||
| 1258 | |||
| 1232 | status = XAllocColor (display, screen_colormap, color_def); | 1259 | status = XAllocColor (display, screen_colormap, color_def); |
| 1233 | if (!status) | 1260 | if (!status) |
| 1234 | { | 1261 | { |
| @@ -1330,6 +1357,27 @@ x_decode_color (f, arg, def) | |||
| 1330 | Fcons (arg, Qnil))); | 1357 | Fcons (arg, Qnil))); |
| 1331 | } | 1358 | } |
| 1332 | 1359 | ||
| 1360 | /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is | ||
| 1361 | the previous value of that parameter, NEW_VALUE is the new value. */ | ||
| 1362 | |||
| 1363 | static void | ||
| 1364 | x_set_screen_gamma (f, new_value, old_value) | ||
| 1365 | struct frame *f; | ||
| 1366 | Lisp_Object new_value, old_value; | ||
| 1367 | { | ||
| 1368 | if (NILP (new_value)) | ||
| 1369 | f->gamma = 0; | ||
| 1370 | else if (NUMBERP (new_value) && XFLOATINT (new_value) > 0) | ||
| 1371 | /* The value 0.4545 is the normal viewing gamma. */ | ||
| 1372 | f->gamma = 1.0 / (0.4545 * XFLOATINT (new_value)); | ||
| 1373 | else | ||
| 1374 | Fsignal (Qerror, Fcons (build_string ("Illegal screen-gamma"), | ||
| 1375 | Fcons (new_value, Qnil))); | ||
| 1376 | |||
| 1377 | clear_face_cache (0); | ||
| 1378 | } | ||
| 1379 | |||
| 1380 | |||
| 1333 | /* Functions called only from `x_set_frame_param' | 1381 | /* Functions called only from `x_set_frame_param' |
| 1334 | to set individual parameters. | 1382 | to set individual parameters. |
| 1335 | 1383 | ||
| @@ -2154,9 +2202,9 @@ x_implicitly_set_name (f, arg, oldval) | |||
| 2154 | F->explicit_name is set, ignore the new name; otherwise, set it. */ | 2202 | F->explicit_name is set, ignore the new name; otherwise, set it. */ |
| 2155 | 2203 | ||
| 2156 | void | 2204 | void |
| 2157 | x_set_title (f, name) | 2205 | x_set_title (f, name, old_name) |
| 2158 | struct frame *f; | 2206 | struct frame *f; |
| 2159 | Lisp_Object name; | 2207 | Lisp_Object name, old_name; |
| 2160 | { | 2208 | { |
| 2161 | /* Don't change the title if it's already NAME. */ | 2209 | /* Don't change the title if it's already NAME. */ |
| 2162 | if (EQ (name, f->title)) | 2210 | if (EQ (name, f->title)) |
| @@ -2553,6 +2601,7 @@ x_get_resource_string (attribute, class) | |||
| 2553 | enum resource_types | 2601 | enum resource_types |
| 2554 | { | 2602 | { |
| 2555 | RES_TYPE_NUMBER, | 2603 | RES_TYPE_NUMBER, |
| 2604 | RES_TYPE_FLOAT, | ||
| 2556 | RES_TYPE_BOOLEAN, | 2605 | RES_TYPE_BOOLEAN, |
| 2557 | RES_TYPE_STRING, | 2606 | RES_TYPE_STRING, |
| 2558 | RES_TYPE_SYMBOL | 2607 | RES_TYPE_SYMBOL |
| @@ -2600,6 +2649,9 @@ x_get_arg (dpyinfo, alist, param, attribute, class, type) | |||
| 2600 | case RES_TYPE_NUMBER: | 2649 | case RES_TYPE_NUMBER: |
| 2601 | return make_number (atoi (XSTRING (tem)->data)); | 2650 | return make_number (atoi (XSTRING (tem)->data)); |
| 2602 | 2651 | ||
| 2652 | case RES_TYPE_FLOAT: | ||
| 2653 | return make_float (atof (XSTRING (tem)->data)); | ||
| 2654 | |||
| 2603 | case RES_TYPE_BOOLEAN: | 2655 | case RES_TYPE_BOOLEAN: |
| 2604 | tem = Fdowncase (tem); | 2656 | tem = Fdowncase (tem); |
| 2605 | if (!strcmp (XSTRING (tem)->data, "on") | 2657 | if (!strcmp (XSTRING (tem)->data, "on") |
| @@ -3701,6 +3753,8 @@ This function is an internal primitive--use `make-frame' instead.") | |||
| 3701 | "cursorColor", "Foreground", RES_TYPE_STRING); | 3753 | "cursorColor", "Foreground", RES_TYPE_STRING); |
| 3702 | x_default_parameter (f, parms, Qborder_color, build_string ("black"), | 3754 | x_default_parameter (f, parms, Qborder_color, build_string ("black"), |
| 3703 | "borderColor", "BorderColor", RES_TYPE_STRING); | 3755 | "borderColor", "BorderColor", RES_TYPE_STRING); |
| 3756 | x_default_parameter (f, parms, Qscreen_gamma, Qnil, | ||
| 3757 | "screenGamma", "ScreenGamma", RES_TYPE_FLOAT); | ||
| 3704 | 3758 | ||
| 3705 | x_default_scroll_bar_color_parameter (f, parms, Qscroll_bar_foreground, | 3759 | x_default_scroll_bar_color_parameter (f, parms, Qscroll_bar_foreground, |
| 3706 | "scrollBarForeground", | 3760 | "scrollBarForeground", |
| @@ -7213,8 +7267,7 @@ lookup_rgb_color (f, r, g, b) | |||
| 7213 | 7267 | ||
| 7214 | BLOCK_INPUT; | 7268 | BLOCK_INPUT; |
| 7215 | cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f)); | 7269 | cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f)); |
| 7216 | rc = x_alloc_nearest_color (FRAME_X_DISPLAY (f), FRAME_X_SCREEN (f), | 7270 | rc = x_alloc_nearest_color (f, cmap, &color); |
| 7217 | cmap, &color); | ||
| 7218 | UNBLOCK_INPUT; | 7271 | UNBLOCK_INPUT; |
| 7219 | 7272 | ||
| 7220 | if (rc) | 7273 | if (rc) |
| @@ -7263,8 +7316,7 @@ lookup_pixel_color (f, pixel) | |||
| 7263 | cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f)); | 7316 | cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f)); |
| 7264 | color.pixel = pixel; | 7317 | color.pixel = pixel; |
| 7265 | XQueryColor (FRAME_X_DISPLAY (f), cmap, &color); | 7318 | XQueryColor (FRAME_X_DISPLAY (f), cmap, &color); |
| 7266 | rc = x_alloc_nearest_color (FRAME_X_DISPLAY (f), FRAME_X_SCREEN (f), | 7319 | rc = x_alloc_nearest_color (f, cmap, &color); |
| 7267 | cmap, &color); | ||
| 7268 | UNBLOCK_INPUT; | 7320 | UNBLOCK_INPUT; |
| 7269 | 7321 | ||
| 7270 | if (rc) | 7322 | if (rc) |
| @@ -10127,6 +10179,8 @@ syms_of_xfns () | |||
| 10127 | staticpro (&Qscroll_bar_foreground); | 10179 | staticpro (&Qscroll_bar_foreground); |
| 10128 | Qscroll_bar_background = intern ("scroll-bar-background"); | 10180 | Qscroll_bar_background = intern ("scroll-bar-background"); |
| 10129 | staticpro (&Qscroll_bar_background); | 10181 | staticpro (&Qscroll_bar_background); |
| 10182 | Qscreen_gamma = intern ("screen-gamma"); | ||
| 10183 | staticpro (&Qscreen_gamma); | ||
| 10130 | /* This is the end of symbol initialization. */ | 10184 | /* This is the end of symbol initialization. */ |
| 10131 | 10185 | ||
| 10132 | Qlaplace = intern ("laplace"); | 10186 | Qlaplace = intern ("laplace"); |