diff options
| author | Gerd Moellmann | 1999-09-07 14:48:59 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 1999-09-07 14:48:59 +0000 |
| commit | 8bd201d6c4df994cc4f3a688caafad6ebed294a9 (patch) | |
| tree | 15a72d73f65bcd36d778e8218ed39cc0a4365984 | |
| parent | cfa2208264fdb06a8bb4882a57da315abfa86b6a (diff) | |
| download | emacs-8bd201d6c4df994cc4f3a688caafad6ebed294a9.tar.gz emacs-8bd201d6c4df994cc4f3a688caafad6ebed294a9.zip | |
(recompute_basic_faces): Clear face cache.
(Finternal_set_lisp_face_attribute): Modify frame parameters
if attributes of certain faces are changed.
(update_face_from_frame_parameter): New.
(realize_basic_faces): Realize new basic faces.
(Qscroll_bar, Qcursor, Qborder, Qmouse): New.
(syms_of_xfaces): Intialize new symbols.
(Qfringe): Replaces Qmargin.
| -rw-r--r-- | src/xfaces.c | 150 |
1 files changed, 134 insertions, 16 deletions
diff --git a/src/xfaces.c b/src/xfaces.c index 34d02ee84a0..e4f7d7f7244 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -280,8 +280,13 @@ Lisp_Object Qx_charset_registry; | |||
| 280 | 280 | ||
| 281 | /* Names of basic faces. */ | 281 | /* Names of basic faces. */ |
| 282 | 282 | ||
| 283 | Lisp_Object Qdefault, Qmodeline, Qtool_bar, Qregion, Qmargin; | 283 | Lisp_Object Qdefault, Qmodeline, Qtool_bar, Qregion, Qfringe; |
| 284 | Lisp_Object Qheader_line; | 284 | Lisp_Object Qheader_line, Qscroll_bar, Qcursor, Qborder, Qmouse;; |
| 285 | |||
| 286 | /* Names of frame parameters related to faces. */ | ||
| 287 | |||
| 288 | extern Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background; | ||
| 289 | extern Lisp_Object Qborder_color, Qcursor_color, Qmouse_color; | ||
| 285 | 290 | ||
| 286 | /* Default stipple pattern used on monochrome displays. This stipple | 291 | /* Default stipple pattern used on monochrome displays. This stipple |
| 287 | pattern is used on monochrome displays instead of shades of gray | 292 | pattern is used on monochrome displays instead of shades of gray |
| @@ -708,9 +713,10 @@ free_frame_faces (f) | |||
| 708 | } | 713 | } |
| 709 | 714 | ||
| 710 | 715 | ||
| 711 | /* Recompute basic faces for frame F. Call this after changing frame | 716 | /* Clear face caches, and recompute basic faces for frame F. Call |
| 712 | parameters on which those faces depend, or when realized faces have | 717 | this after changing frame parameters on which those faces depend, |
| 713 | been freed due to changing attributes of named faces. */ | 718 | or when realized faces have been freed due to changing attributes |
| 719 | of named faces. */ | ||
| 714 | 720 | ||
| 715 | void | 721 | void |
| 716 | recompute_basic_faces (f) | 722 | recompute_basic_faces (f) |
| @@ -718,7 +724,9 @@ recompute_basic_faces (f) | |||
| 718 | { | 724 | { |
| 719 | if (FRAME_FACE_CACHE (f)) | 725 | if (FRAME_FACE_CACHE (f)) |
| 720 | { | 726 | { |
| 721 | int realized_p = realize_basic_faces (f); | 727 | int realized_p; |
| 728 | clear_face_cache (0); | ||
| 729 | realized_p = realize_basic_faces (f); | ||
| 722 | xassert (realized_p); | 730 | xassert (realized_p); |
| 723 | } | 731 | } |
| 724 | } | 732 | } |
| @@ -3421,14 +3429,61 @@ frame.") | |||
| 3421 | } | 3429 | } |
| 3422 | 3430 | ||
| 3423 | #ifdef HAVE_X_WINDOWS | 3431 | #ifdef HAVE_X_WINDOWS |
| 3424 | /* Changed font-related attributes of the `default' face are | 3432 | |
| 3425 | reflected in changed `font' frame parameters. */ | 3433 | if (!EQ (frame, Qt) |
| 3426 | if (EQ (face, Qdefault) | 3434 | && !UNSPECIFIEDP (value) |
| 3427 | && !EQ (frame, Qt) | ||
| 3428 | && font_related_attr_p | ||
| 3429 | && lface_fully_specified_p (XVECTOR (lface)->contents) | ||
| 3430 | && NILP (Fequal (old_value, value))) | 3435 | && NILP (Fequal (old_value, value))) |
| 3431 | set_font_frame_param (frame, lface); | 3436 | { |
| 3437 | Lisp_Object param; | ||
| 3438 | |||
| 3439 | param = Qnil; | ||
| 3440 | |||
| 3441 | if (EQ (face, Qdefault)) | ||
| 3442 | { | ||
| 3443 | /* Changed font-related attributes of the `default' face are | ||
| 3444 | reflected in changed `font' frame parameters. */ | ||
| 3445 | if (font_related_attr_p | ||
| 3446 | && lface_fully_specified_p (XVECTOR (lface)->contents)) | ||
| 3447 | set_font_frame_param (frame, lface); | ||
| 3448 | else if (EQ (attr, QCforeground)) | ||
| 3449 | param = Qforeground_color; | ||
| 3450 | else if (EQ (attr, QCbackground)) | ||
| 3451 | param = Qbackground_color; | ||
| 3452 | } | ||
| 3453 | else if (EQ (face, Qscroll_bar)) | ||
| 3454 | { | ||
| 3455 | /* Changing the colors of `scroll-bar' sets frame parameters | ||
| 3456 | `scroll-bar-foreground' and `scroll-bar-background'. */ | ||
| 3457 | if (EQ (attr, QCforeground)) | ||
| 3458 | param = Qscroll_bar_foreground; | ||
| 3459 | else if (EQ (attr, QCbackground)) | ||
| 3460 | param = Qscroll_bar_background; | ||
| 3461 | } | ||
| 3462 | else if (EQ (face, Qborder)) | ||
| 3463 | { | ||
| 3464 | /* Changing background color of `border' sets frame parameter | ||
| 3465 | `border-color'. */ | ||
| 3466 | if (EQ (attr, QCbackground)) | ||
| 3467 | param = Qborder_color; | ||
| 3468 | } | ||
| 3469 | else if (EQ (face, Qcursor)) | ||
| 3470 | { | ||
| 3471 | /* Changing background color of `cursor' sets frame parameter | ||
| 3472 | `cursor-color'. */ | ||
| 3473 | if (EQ (attr, QCbackground)) | ||
| 3474 | param = Qcursor_color; | ||
| 3475 | } | ||
| 3476 | else if (EQ (face, Qmouse)) | ||
| 3477 | { | ||
| 3478 | /* Changing background color of `mouse' sets frame parameter | ||
| 3479 | `mouse-color'. */ | ||
| 3480 | if (EQ (attr, QCbackground)) | ||
| 3481 | param = Qmouse_color; | ||
| 3482 | } | ||
| 3483 | |||
| 3484 | if (SYMBOLP (param)) | ||
| 3485 | Fmodify_frame_parameters (frame, Fcons (Fcons (param, value), Qnil)); | ||
| 3486 | } | ||
| 3432 | 3487 | ||
| 3433 | #endif /* HAVE_X_WINDOWS */ | 3488 | #endif /* HAVE_X_WINDOWS */ |
| 3434 | 3489 | ||
| @@ -3490,6 +3545,57 @@ set_font_frame_param (frame, lface) | |||
| 3490 | } | 3545 | } |
| 3491 | 3546 | ||
| 3492 | 3547 | ||
| 3548 | /* Update the corresponding face when frame parameter PARAM on frame F | ||
| 3549 | has been assigned the value NEW_VALUE. */ | ||
| 3550 | |||
| 3551 | void | ||
| 3552 | update_face_from_frame_parameter (f, param, new_value) | ||
| 3553 | struct frame *f; | ||
| 3554 | Lisp_Object param, new_value; | ||
| 3555 | { | ||
| 3556 | Lisp_Object lface; | ||
| 3557 | |||
| 3558 | /* If there are no faces yet, give up. This is the case when called | ||
| 3559 | from Fx_create_frame, and we do the necessary things later in | ||
| 3560 | face-set-after-frame-defaults. */ | ||
| 3561 | if (NILP (f->face_alist)) | ||
| 3562 | return; | ||
| 3563 | |||
| 3564 | if (EQ (param, Qforeground_color)) | ||
| 3565 | { | ||
| 3566 | lface = lface_from_face_name (f, Qdefault, 1); | ||
| 3567 | LFACE_FOREGROUND (lface) = (STRINGP (new_value) | ||
| 3568 | ? new_value : Qunspecified); | ||
| 3569 | realize_basic_faces (f); | ||
| 3570 | } | ||
| 3571 | else if (EQ (param, Qbackground_color)) | ||
| 3572 | { | ||
| 3573 | lface = lface_from_face_name (f, Qdefault, 1); | ||
| 3574 | LFACE_BACKGROUND (lface) = (STRINGP (new_value) | ||
| 3575 | ? new_value : Qunspecified); | ||
| 3576 | realize_basic_faces (f); | ||
| 3577 | } | ||
| 3578 | if (EQ (param, Qborder_color)) | ||
| 3579 | { | ||
| 3580 | lface = lface_from_face_name (f, Qborder, 1); | ||
| 3581 | LFACE_BACKGROUND (lface) = (STRINGP (new_value) | ||
| 3582 | ? new_value : Qunspecified); | ||
| 3583 | } | ||
| 3584 | else if (EQ (param, Qcursor_color)) | ||
| 3585 | { | ||
| 3586 | lface = lface_from_face_name (f, Qcursor, 1); | ||
| 3587 | LFACE_BACKGROUND (lface) = (STRINGP (new_value) | ||
| 3588 | ? new_value : Qunspecified); | ||
| 3589 | } | ||
| 3590 | else if (EQ (param, Qmouse_color)) | ||
| 3591 | { | ||
| 3592 | lface = lface_from_face_name (f, Qmouse, 1); | ||
| 3593 | LFACE_BACKGROUND (lface) = (STRINGP (new_value) | ||
| 3594 | ? new_value : Qunspecified); | ||
| 3595 | } | ||
| 3596 | } | ||
| 3597 | |||
| 3598 | |||
| 3493 | /* Get the value of X resource RESOURCE, class CLASS for the display | 3599 | /* Get the value of X resource RESOURCE, class CLASS for the display |
| 3494 | of frame FRAME. This is here because ordinary `x-get-resource' | 3600 | of frame FRAME. This is here because ordinary `x-get-resource' |
| 3495 | doesn't take a frame argument. */ | 3601 | doesn't take a frame argument. */ |
| @@ -5131,8 +5237,12 @@ realize_basic_faces (f) | |||
| 5131 | { | 5237 | { |
| 5132 | realize_named_face (f, Qmodeline, MODE_LINE_FACE_ID); | 5238 | realize_named_face (f, Qmodeline, MODE_LINE_FACE_ID); |
| 5133 | realize_named_face (f, Qtool_bar, TOOL_BAR_FACE_ID); | 5239 | realize_named_face (f, Qtool_bar, TOOL_BAR_FACE_ID); |
| 5134 | realize_named_face (f, Qmargin, BITMAP_AREA_FACE_ID); | 5240 | realize_named_face (f, Qfringe, BITMAP_AREA_FACE_ID); |
| 5135 | realize_named_face (f, Qheader_line, HEADER_LINE_FACE_ID); | 5241 | realize_named_face (f, Qheader_line, HEADER_LINE_FACE_ID); |
| 5242 | realize_named_face (f, Qscroll_bar, SCROLL_BAR_FACE_ID); | ||
| 5243 | realize_named_face (f, Qborder, BORDER_FACE_ID); | ||
| 5244 | realize_named_face (f, Qcursor, CURSOR_FACE_ID); | ||
| 5245 | realize_named_face (f, Qmouse, MOUSE_FACE_ID); | ||
| 5136 | success_p = 1; | 5246 | success_p = 1; |
| 5137 | } | 5247 | } |
| 5138 | 5248 | ||
| @@ -6246,10 +6356,18 @@ syms_of_xfaces () | |||
| 6246 | staticpro (&Qtool_bar); | 6356 | staticpro (&Qtool_bar); |
| 6247 | Qregion = intern ("region"); | 6357 | Qregion = intern ("region"); |
| 6248 | staticpro (&Qregion); | 6358 | staticpro (&Qregion); |
| 6249 | Qmargin = intern ("margin"); | 6359 | Qfringe = intern ("fringe"); |
| 6250 | staticpro (&Qmargin); | 6360 | staticpro (&Qfringe); |
| 6251 | Qheader_line = intern ("header-line"); | 6361 | Qheader_line = intern ("header-line"); |
| 6252 | staticpro (&Qheader_line); | 6362 | staticpro (&Qheader_line); |
| 6363 | Qscroll_bar = intern ("scroll-bar"); | ||
| 6364 | staticpro (&Qscroll_bar); | ||
| 6365 | Qcursor = intern ("cursor"); | ||
| 6366 | staticpro (&Qcursor); | ||
| 6367 | Qborder = intern ("border"); | ||
| 6368 | staticpro (&Qborder); | ||
| 6369 | Qmouse = intern ("mouse"); | ||
| 6370 | staticpro (&Qmouse); | ||
| 6253 | 6371 | ||
| 6254 | defsubr (&Sinternal_make_lisp_face); | 6372 | defsubr (&Sinternal_make_lisp_face); |
| 6255 | defsubr (&Sinternal_lisp_face_p); | 6373 | defsubr (&Sinternal_lisp_face_p); |