diff options
| author | Chong Yidong | 2008-08-26 17:09:53 +0000 |
|---|---|---|
| committer | Chong Yidong | 2008-08-26 17:09:53 +0000 |
| commit | 39d14c255d0f7df8d01c94aa913b531835c37614 (patch) | |
| tree | ed9b79e0e96eb402783d782c8108248837977ac3 /src | |
| parent | 7d31058f9cbc95c96b6da7473b1d0716e8a89bec (diff) | |
| download | emacs-39d14c255d0f7df8d01c94aa913b531835c37614.tar.gz emacs-39d14c255d0f7df8d01c94aa913b531835c37614.zip | |
Include character.h and font.h for XSETFONT.
(setup_frame_gcs): Compute X font id from font struct, just once.
Diffstat (limited to 'src')
| -rw-r--r-- | src/widget.c | 76 |
1 files changed, 23 insertions, 53 deletions
diff --git a/src/widget.c b/src/widget.c index d4d8d2e8460..f241ddf7d67 100644 --- a/src/widget.c +++ b/src/widget.c | |||
| @@ -53,6 +53,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 53 | #include <signal.h> | 53 | #include <signal.h> |
| 54 | #include "syssignal.h" | 54 | #include "syssignal.h" |
| 55 | 55 | ||
| 56 | #include "character.h" | ||
| 57 | #include "font.h" | ||
| 58 | |||
| 56 | /* This sucks: this is the first default that x-faces.el tries. This won't | 59 | /* This sucks: this is the first default that x-faces.el tries. This won't |
| 57 | be used unless neither the "Emacs.EmacsFrame" resource nor the | 60 | be used unless neither the "Emacs.EmacsFrame" resource nor the |
| 58 | "Emacs.EmacsFrame" resource is set; the frame | 61 | "Emacs.EmacsFrame" resource is set; the frame |
| @@ -104,7 +107,7 @@ static XtResource resources[] = { | |||
| 104 | offset (internal_border_width), XtRImmediate, (XtPointer)4}, | 107 | offset (internal_border_width), XtRImmediate, (XtPointer)4}, |
| 105 | {XtNinterline, XtCInterline, XtRInt, sizeof (int), | 108 | {XtNinterline, XtCInterline, XtRInt, sizeof (int), |
| 106 | offset (interline), XtRImmediate, (XtPointer)0}, | 109 | offset (interline), XtRImmediate, (XtPointer)0}, |
| 107 | {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *), | 110 | {XtNfont, XtCFont, XtRFontStruct, sizeof(struct font *), |
| 108 | offset(font),XtRString, DEFAULT_FACE_FONT}, | 111 | offset(font),XtRString, DEFAULT_FACE_FONT}, |
| 109 | {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), | 112 | {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), |
| 110 | offset(foreground_pixel), XtRString, "XtDefaultForeground"}, | 113 | offset(foreground_pixel), XtRString, "XtDefaultForeground"}, |
| @@ -572,6 +575,22 @@ setup_frame_gcs (ew) | |||
| 572 | XGCValues gc_values; | 575 | XGCValues gc_values; |
| 573 | struct frame* s = ew->emacs_frame.frame; | 576 | struct frame* s = ew->emacs_frame.frame; |
| 574 | Pixmap blank_stipple, blank_tile; | 577 | Pixmap blank_stipple, blank_tile; |
| 578 | unsigned long valuemask = (GCForeground | GCBackground | GCGraphicsExposures | ||
| 579 | | GCStipple | GCTile); | ||
| 580 | Lisp_Object font; | ||
| 581 | |||
| 582 | XSETFONT (font, ew->emacs_frame.font); | ||
| 583 | font = Ffont_xlfd_name (font, Qnil); | ||
| 584 | if (STRINGP (font)) | ||
| 585 | { | ||
| 586 | XFontStruct *xfont = XLoadQueryFont (FRAME_X_DISPLAY_INFO (s)->display, | ||
| 587 | SDATA (font)); | ||
| 588 | if (xfont) | ||
| 589 | { | ||
| 590 | gc_values.font = xfont->fid; | ||
| 591 | valuemask |= GCFont; | ||
| 592 | } | ||
| 593 | } | ||
| 575 | 594 | ||
| 576 | /* We have to initialize all of our GCs to have a stipple/tile, otherwise | 595 | /* We have to initialize all of our GCs to have a stipple/tile, otherwise |
| 577 | XGetGCValues returns uninitialized data when we query the stipple | 596 | XGetGCValues returns uninitialized data when we query the stipple |
| @@ -598,31 +617,24 @@ setup_frame_gcs (ew) | |||
| 598 | ew->core.depth); | 617 | ew->core.depth); |
| 599 | 618 | ||
| 600 | /* Normal video */ | 619 | /* Normal video */ |
| 601 | gc_values.font = ew->emacs_frame.font->fid; | ||
| 602 | gc_values.foreground = ew->emacs_frame.foreground_pixel; | 620 | gc_values.foreground = ew->emacs_frame.foreground_pixel; |
| 603 | gc_values.background = ew->core.background_pixel; | 621 | gc_values.background = ew->core.background_pixel; |
| 604 | gc_values.graphics_exposures = False; | 622 | gc_values.graphics_exposures = False; |
| 605 | gc_values.stipple = blank_stipple; | 623 | gc_values.stipple = blank_stipple; |
| 606 | gc_values.tile = blank_tile; | 624 | gc_values.tile = blank_tile; |
| 607 | XChangeGC (XtDisplay (ew), s->output_data.x->normal_gc, | 625 | XChangeGC (XtDisplay (ew), s->output_data.x->normal_gc, |
| 608 | (GCFont | GCForeground | GCBackground | GCGraphicsExposures | 626 | valuemask, &gc_values); |
| 609 | | GCStipple | GCTile), | ||
| 610 | &gc_values); | ||
| 611 | 627 | ||
| 612 | /* Reverse video style. */ | 628 | /* Reverse video style. */ |
| 613 | gc_values.font = ew->emacs_frame.font->fid; | ||
| 614 | gc_values.foreground = ew->core.background_pixel; | 629 | gc_values.foreground = ew->core.background_pixel; |
| 615 | gc_values.background = ew->emacs_frame.foreground_pixel; | 630 | gc_values.background = ew->emacs_frame.foreground_pixel; |
| 616 | gc_values.graphics_exposures = False; | 631 | gc_values.graphics_exposures = False; |
| 617 | gc_values.stipple = blank_stipple; | 632 | gc_values.stipple = blank_stipple; |
| 618 | gc_values.tile = blank_tile; | 633 | gc_values.tile = blank_tile; |
| 619 | XChangeGC (XtDisplay (ew), s->output_data.x->reverse_gc, | 634 | XChangeGC (XtDisplay (ew), s->output_data.x->reverse_gc, |
| 620 | (GCFont | GCForeground | GCBackground | GCGraphicsExposures | 635 | valuemask, &gc_values); |
| 621 | | GCStipple | GCTile), | ||
| 622 | &gc_values); | ||
| 623 | 636 | ||
| 624 | /* Cursor has to have an empty stipple. */ | 637 | /* Cursor has to have an empty stipple. */ |
| 625 | gc_values.font = ew->emacs_frame.font->fid; | ||
| 626 | gc_values.foreground = ew->core.background_pixel; | 638 | gc_values.foreground = ew->core.background_pixel; |
| 627 | gc_values.background = ew->emacs_frame.cursor_color; | 639 | gc_values.background = ew->emacs_frame.cursor_color; |
| 628 | gc_values.graphics_exposures = False; | 640 | gc_values.graphics_exposures = False; |
| @@ -632,9 +644,7 @@ setup_frame_gcs (ew) | |||
| 632 | RootWindowOfScreen (XtScreen (ew)), | 644 | RootWindowOfScreen (XtScreen (ew)), |
| 633 | setup_frame_cursor_bits, 16, 16); | 645 | setup_frame_cursor_bits, 16, 16); |
| 634 | XChangeGC (XtDisplay (ew), s->output_data.x->cursor_gc, | 646 | XChangeGC (XtDisplay (ew), s->output_data.x->cursor_gc, |
| 635 | (GCFont | GCForeground | GCBackground | GCGraphicsExposures | 647 | valuemask, &gc_values); |
| 636 | | GCStipple | GCTile), | ||
| 637 | &gc_values); | ||
| 638 | } | 648 | } |
| 639 | 649 | ||
| 640 | static void | 650 | static void |
| @@ -681,48 +691,8 @@ EmacsFrameInitialize (request, new, dum1, dum2) | |||
| 681 | exit (1); | 691 | exit (1); |
| 682 | } | 692 | } |
| 683 | 693 | ||
| 684 | #if 0 /* done in xfns.c */ | ||
| 685 | /* If the "Emacs.EmacsFrame.{default,Face}.{attributeFont,AttributeFont}" | ||
| 686 | resource is set, then it always overrides "Emacs.EmacsFrame.{font,Font}". | ||
| 687 | It's unfortunate that we have to do this, but we need to know the font | ||
| 688 | size for frame-sizing purposes before the faces get initialized. If | ||
| 689 | the "default.attributeFont" isn't set, then we use the font of this | ||
| 690 | EmacsFrame itself, defaulting to XtDefaultFont. Up in the lisp code, | ||
| 691 | the "default" face will use the frame's font if its own is not set, | ||
| 692 | so everything stays in sync -- it's not possible for the frame's font | ||
| 693 | and the default face's font to be different. | ||
| 694 | */ | ||
| 695 | { | ||
| 696 | XFontStruct *f = 0; | ||
| 697 | XtResource face_res; | ||
| 698 | face_res.resource_name = "attributeFont"; | ||
| 699 | face_res.resource_class = "AttributeFont"; | ||
| 700 | face_res.resource_type = XtRFontStruct; | ||
| 701 | face_res.resource_size = sizeof (XFontStruct *); | ||
| 702 | face_res.resource_offset = 0; | ||
| 703 | face_res.default_type = XtRImmediate; | ||
| 704 | face_res.default_addr = 0; | ||
| 705 | XtGetSubresources ((Widget) ew, (XtPointer) &f, "default", "Face", | ||
| 706 | &face_res, 1, NULL, 0); | ||
| 707 | |||
| 708 | if (f) | ||
| 709 | ew->emacs_frame.font = f; | ||
| 710 | else if (! ew->emacs_frame.font) | ||
| 711 | { | ||
| 712 | fprintf (stderr, "emacs frame widget could not load a font\n"); | ||
| 713 | exit (1); | ||
| 714 | } | ||
| 715 | } | ||
| 716 | |||
| 717 | /* Update the font field in frame */ | ||
| 718 | FRAME_FONT (ew->emacs_frame.frame) = ew->emacs_frame.font; | ||
| 719 | #endif | ||
| 720 | |||
| 721 | update_from_various_frame_slots (ew); | 694 | update_from_various_frame_slots (ew); |
| 722 | set_frame_size (ew); | 695 | set_frame_size (ew); |
| 723 | /*create_frame_gcs (ew); | ||
| 724 | setup_frame_gcs (ew); | ||
| 725 | update_various_frame_slots (ew); */ | ||
| 726 | } | 696 | } |
| 727 | 697 | ||
| 728 | 698 | ||