aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan Djärv2014-08-09 11:06:25 +0200
committerJan Djärv2014-08-09 11:06:25 +0200
commit5742859f273b82e7dbadf7e9f581fd5d364dc05a (patch)
treeb2deba0e81343a41d07cd33f5f84554dba6b1ad3 /src
parentfea30ac1c84d0c3d2fff34a309980c53e3db2fe8 (diff)
downloademacs-5742859f273b82e7dbadf7e9f581fd5d364dc05a.tar.gz
emacs-5742859f273b82e7dbadf7e9f581fd5d364dc05a.zip
* widget.c (DEFAULT_FACE_FONT, EmacsFrameSetValues, setup_frame_gcs)
(resources, setup_frame_cursor_bits): Remove unused variables and functions, esp. wrt. font. * widgetprv.h (EmacsFramePart): Remove font. Fixes: debbugs:18227
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog8
-rw-r--r--src/widget.c186
-rw-r--r--src/widgetprv.h1
3 files changed, 12 insertions, 183 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 2c5001e9a5a..b5831d811d5 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
12014-08-09 Jan Djärv <jan.h.d@swipnet.se>
2
3 * widgetprv.h (EmacsFramePart): Remove font.
4
5 * widget.c (DEFAULT_FACE_FONT, EmacsFrameSetValues, setup_frame_gcs)
6 (resources, setup_frame_cursor_bits): Remove unused variables and
7 functions, esp. wrt. font (Bug#18227).
8
12014-08-07 Paul Eggert <eggert@cs.ucla.edu> 92014-08-07 Paul Eggert <eggert@cs.ucla.edu>
2 10
3 * xterm.c (x_delete_terminal): Plug file descriptor leak (Bug#17691). 11 * xterm.c (x_delete_terminal): Plug file descriptor leak (Bug#17691).
diff --git a/src/widget.c b/src/widget.c
index 45118a88730..b5b76bb306b 100644
--- a/src/widget.c
+++ b/src/widget.c
@@ -53,30 +53,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
53#include "character.h" 53#include "character.h"
54#include "font.h" 54#include "font.h"
55 55
56/* 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
58 "Emacs.EmacsFrame" resource is set; the frame
59 may have the wrong default size if this font doesn't exist, but some other
60 font that x-faces.el does. The workaround is to specify some font in the
61 resource database; I don't know a solution other than duplicating the font-
62 searching code from x-faces.el in this file.
63
64 This also means that if "Emacs.EmacsFrame" is specified as a non-
65 existent font, then Xt is going to substitute "XtDefaultFont" for it,
66 which is a different size than this one. The solution for this is to
67 make x-faces.el try to use XtDefaultFont. The problem with that is that
68 XtDefaultFont is almost certainly variable-width.
69
70 #### Perhaps we could have this code explicitly set XtDefaultFont to this?
71 */
72#define DEFAULT_FACE_FONT "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-*"
73
74 56
75static void EmacsFrameInitialize (Widget request, Widget new, ArgList dum1, Cardinal *dum2); 57static void EmacsFrameInitialize (Widget request, Widget new, ArgList dum1, Cardinal *dum2);
76static void EmacsFrameDestroy (Widget widget); 58static void EmacsFrameDestroy (Widget widget);
77static void EmacsFrameRealize (Widget widget, XtValueMask *mask, XSetWindowAttributes *attrs); 59static void EmacsFrameRealize (Widget widget, XtValueMask *mask, XSetWindowAttributes *attrs);
78static void EmacsFrameResize (Widget widget); 60static void EmacsFrameResize (Widget widget);
79static Boolean EmacsFrameSetValues (Widget cur_widget, Widget req_widget, Widget new_widget, ArgList dum1, Cardinal *dum2);
80static XtGeometryResult EmacsFrameQueryGeometry (Widget widget, XtWidgetGeometry *request, XtWidgetGeometry *result); 61static XtGeometryResult EmacsFrameQueryGeometry (Widget widget, XtWidgetGeometry *request, XtWidgetGeometry *result);
81 62
82 63
@@ -102,8 +83,6 @@ static XtResource resources[] = {
102 offset (internal_border_width), XtRImmediate, (XtPointer)4}, 83 offset (internal_border_width), XtRImmediate, (XtPointer)4},
103 {XtNinterline, XtCInterline, XtRInt, sizeof (int), 84 {XtNinterline, XtCInterline, XtRInt, sizeof (int),
104 offset (interline), XtRImmediate, (XtPointer)0}, 85 offset (interline), XtRImmediate, (XtPointer)0},
105 {XtNfont, XtCFont, XtRFontStruct, sizeof (struct font *),
106 offset (font),XtRString, DEFAULT_FACE_FONT},
107 {XtNforeground, XtCForeground, XtRPixel, sizeof (Pixel), 86 {XtNforeground, XtCForeground, XtRPixel, sizeof (Pixel),
108 offset (foreground_pixel), XtRString, "XtDefaultForeground"}, 87 offset (foreground_pixel), XtRString, "XtDefaultForeground"},
109 {XtNcursorColor, XtCForeground, XtRPixel, sizeof (Pixel), 88 {XtNcursorColor, XtCForeground, XtRPixel, sizeof (Pixel),
@@ -157,7 +136,10 @@ static EmacsFrameClassRec emacsFrameClassRec = {
157 /* destroy */ EmacsFrameDestroy, 136 /* destroy */ EmacsFrameDestroy,
158 /* resize */ EmacsFrameResize, 137 /* resize */ EmacsFrameResize,
159 /* expose */ XtInheritExpose, 138 /* expose */ XtInheritExpose,
160 /* set_values */ EmacsFrameSetValues, 139
140 /* Emacs never does XtSetvalues on this widget, so we have no code
141 for it. */
142 /* set_values */ 0, /* Not supported */
161 /* set_values_hook */ 0, 143 /* set_values_hook */ 0,
162 /* set_values_almost */ XtInheritSetValuesAlmost, 144 /* set_values_almost */ XtInheritSetValuesAlmost,
163 /* get_values_hook */ 0, 145 /* get_values_hook */ 0,
@@ -502,91 +484,6 @@ widget_update_wm_size_hints (Widget widget)
502 update_wm_hints (ew); 484 update_wm_hints (ew);
503} 485}
504 486
505static char setup_frame_cursor_bits[] =
506{
507 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
508 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
509 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
510 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
511};
512
513static void
514setup_frame_gcs (EmacsFrame ew)
515{
516 XGCValues gc_values;
517 struct frame* s = ew->emacs_frame.frame;
518 Pixmap blank_stipple, blank_tile;
519 unsigned long valuemask = (GCForeground | GCBackground | GCGraphicsExposures
520 | GCStipple | GCTile);
521 Lisp_Object font;
522
523 XSETFONT (font, ew->emacs_frame.font);
524 font = Ffont_xlfd_name (font, Qnil);
525 if (STRINGP (font))
526 {
527 XFontStruct *xfont = XLoadQueryFont (FRAME_DISPLAY_INFO (s)->display,
528 SSDATA (font));
529 if (xfont)
530 {
531 gc_values.font = xfont->fid;
532 valuemask |= GCFont;
533 }
534 }
535
536 /* We have to initialize all of our GCs to have a stipple/tile, otherwise
537 XGetGCValues returns uninitialized data when we query the stipple
538 (instead of None or something sensible) and it makes things hard.
539
540 This should be fixed for real by not querying the GCs but instead having
541 some GC-based cache instead of the current face-based cache which doesn't
542 effectively cache all of the GC settings we need to use.
543 */
544
545 blank_stipple
546 = XCreateBitmapFromData (XtDisplay (ew),
547 RootWindowOfScreen (XtScreen (ew)),
548 setup_frame_cursor_bits, 2, 2);
549
550 /* use fg = 0, bg = 1 below, but it's irrelevant since this pixmap should
551 never actually get used as a background tile!
552 */
553 blank_tile
554 = XCreatePixmapFromBitmapData (XtDisplay (ew),
555 RootWindowOfScreen (XtScreen (ew)),
556 setup_frame_cursor_bits, 2, 2,
557 0, 1, ew->core.depth);
558
559 /* Normal video */
560 gc_values.foreground = ew->emacs_frame.foreground_pixel;
561 gc_values.background = ew->core.background_pixel;
562 gc_values.graphics_exposures = False;
563 gc_values.stipple = blank_stipple;
564 gc_values.tile = blank_tile;
565 XChangeGC (XtDisplay (ew), s->output_data.x->normal_gc,
566 valuemask, &gc_values);
567
568 /* Reverse video style. */
569 gc_values.foreground = ew->core.background_pixel;
570 gc_values.background = ew->emacs_frame.foreground_pixel;
571 gc_values.graphics_exposures = False;
572 gc_values.stipple = blank_stipple;
573 gc_values.tile = blank_tile;
574 XChangeGC (XtDisplay (ew), s->output_data.x->reverse_gc,
575 valuemask, &gc_values);
576
577 /* Cursor has to have an empty stipple. */
578 gc_values.foreground = ew->core.background_pixel;
579 gc_values.background = ew->emacs_frame.cursor_color;
580 gc_values.graphics_exposures = False;
581 gc_values.tile = blank_tile;
582 gc_values.stipple
583 = XCreateBitmapFromData (XtDisplay (ew),
584 RootWindowOfScreen (XtScreen (ew)),
585 setup_frame_cursor_bits, 16, 16);
586 XChangeGC (XtDisplay (ew), s->output_data.x->cursor_gc,
587 valuemask, &gc_values);
588}
589
590static void 487static void
591update_various_frame_slots (EmacsFrame ew) 488update_various_frame_slots (EmacsFrame ew)
592{ 489{
@@ -614,7 +511,6 @@ update_from_various_frame_slots (EmacsFrame ew)
614 ew->core.width = FRAME_PIXEL_WIDTH (f); 511 ew->core.width = FRAME_PIXEL_WIDTH (f);
615 ew->core.background_pixel = FRAME_BACKGROUND_PIXEL (f); 512 ew->core.background_pixel = FRAME_BACKGROUND_PIXEL (f);
616 ew->emacs_frame.internal_border_width = f->internal_border_width; 513 ew->emacs_frame.internal_border_width = f->internal_border_width;
617 ew->emacs_frame.font = x->font;
618 ew->emacs_frame.foreground_pixel = FRAME_FOREGROUND_PIXEL (f); 514 ew->emacs_frame.foreground_pixel = FRAME_FOREGROUND_PIXEL (f);
619 ew->emacs_frame.cursor_color = x->cursor_pixel; 515 ew->emacs_frame.cursor_color = x->cursor_pixel;
620 ew->core.border_pixel = x->border_pixel; 516 ew->core.border_pixel = x->border_pixel;
@@ -721,80 +617,6 @@ EmacsFrameResize (Widget widget)
721 } 617 }
722} 618}
723 619
724static Boolean
725EmacsFrameSetValues (Widget cur_widget, Widget req_widget, Widget new_widget, ArgList dum1, Cardinal *dum2)
726{
727 EmacsFrame cur = (EmacsFrame)cur_widget;
728 EmacsFrame new = (EmacsFrame)new_widget;
729
730 Boolean needs_a_refresh = False;
731 Boolean has_to_recompute_size;
732 Boolean has_to_recompute_gcs;
733 Boolean has_to_update_hints;
734
735 int char_width, char_height;
736 Dimension pixel_width;
737 Dimension pixel_height;
738
739 /* AFAIK, this function is never called. -- Jan D, Oct 2009. */
740 has_to_recompute_gcs = (cur->emacs_frame.font != new->emacs_frame.font
741 || (cur->emacs_frame.foreground_pixel
742 != new->emacs_frame.foreground_pixel)
743 || (cur->core.background_pixel
744 != new->core.background_pixel)
745 );
746
747 has_to_recompute_size = (cur->emacs_frame.font != new->emacs_frame.font
748 && cur->core.width == new->core.width
749 && cur->core.height == new->core.height);
750
751 has_to_update_hints = (cur->emacs_frame.font != new->emacs_frame.font);
752
753 if (has_to_recompute_gcs)
754 {
755 setup_frame_gcs (new);
756 needs_a_refresh = True;
757 }
758
759 if (has_to_recompute_size)
760 {
761 /* Don't do this pixelwise, hopefully. */
762 pixel_width = new->core.width;
763 pixel_height = new->core.height;
764 pixel_to_char_size (new, pixel_width, pixel_height, &char_width,
765 &char_height);
766 char_to_pixel_size (new, char_width, char_height, &pixel_width,
767 &pixel_height);
768 new->core.width = pixel_width;
769 new->core.height = pixel_height;
770
771 change_frame_size (new->emacs_frame.frame, char_width, char_height,
772 1, 0, 0, 0);
773 needs_a_refresh = True;
774 }
775
776 if (has_to_update_hints)
777 update_wm_hints (new);
778
779 update_various_frame_slots (new);
780
781 /* #### This doesn't work, I haven't been able to find ANY kludge that
782 will let (x-create-frame '((iconic . t))) work. It seems that changes
783 to wm_shell's iconic slot have no effect after it has been realized,
784 and calling XIconifyWindow doesn't work either (even though the window
785 has been created.) Perhaps there is some property we could smash
786 directly, but I'm sick of this for now.
787 */
788 if (cur->emacs_frame.iconic != new->emacs_frame.iconic)
789 {
790 Widget wmshell = get_wm_shell ((Widget) cur);
791 XtVaSetValues (wmshell, XtNiconic,
792 (XtArgVal) new->emacs_frame.iconic, NULL);
793 }
794
795 return needs_a_refresh;
796}
797
798static XtGeometryResult 620static XtGeometryResult
799EmacsFrameQueryGeometry (Widget widget, XtWidgetGeometry *request, XtWidgetGeometry *result) 621EmacsFrameQueryGeometry (Widget widget, XtWidgetGeometry *request, XtWidgetGeometry *result)
800{ 622{
diff --git a/src/widgetprv.h b/src/widgetprv.h
index c0a5238743e..f5e2eb549a1 100644
--- a/src/widgetprv.h
+++ b/src/widgetprv.h
@@ -43,7 +43,6 @@ typedef struct {
43 int internal_border_width; /* internal borders */ 43 int internal_border_width; /* internal borders */
44 int interline; /* skips between lines */ 44 int interline; /* skips between lines */
45 45
46 struct font* font; /* font */
47 Pixel foreground_pixel; /* foreground */ 46 Pixel foreground_pixel; /* foreground */
48 47
49 Pixel cursor_color; /* text cursor color */ 48 Pixel cursor_color; /* text cursor color */