aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGerd Moellmann2001-03-22 18:33:28 +0000
committerGerd Moellmann2001-03-22 18:33:28 +0000
commita03ad4682c036c4cc94db45173c0ffde4e002ce1 (patch)
tree544d8261144c1276ae4867cfd7f8e28cbf049e5d /src
parent5143d8a4f145e6925c618b8d7421c2ddd36c80fa (diff)
downloademacs-a03ad4682c036c4cc94db45173c0ffde4e002ce1.tar.gz
emacs-a03ad4682c036c4cc94db45173c0ffde4e002ce1.zip
(x_set_menu_resources_from_menu_face) [USE_X_TOOLKIT]:
Removed, together with subroutines. (x_set_menu_face_resources) [USE_X_TOOLKIT]: New function. (realize_basic_faces) [USE_X_TOOLKIT]: Call x_set_menu_face_resources.
Diffstat (limited to 'src')
-rw-r--r--src/xfaces.c265
1 files changed, 65 insertions, 200 deletions
diff --git a/src/xfaces.c b/src/xfaces.c
index 4fd21fee093..b9a134ff719 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -4348,209 +4348,80 @@ DEFUN ("internal-set-lisp-face-attribute-from-resource",
4348 4348
4349#ifdef USE_X_TOOLKIT 4349#ifdef USE_X_TOOLKIT
4350 4350
4351#include "../lwlib/lwlib-utils.h" 4351void
4352 4352x_set_menu_face_resources (f)
4353/* Structure used to pass X resources to functions called via
4354 XtApplyToWidgets. */
4355
4356struct x_resources
4357{
4358 Arg *av;
4359 int ac;
4360};
4361
4362
4363#ifdef USE_MOTIF
4364
4365static void xm_apply_resources P_ ((Widget, XtPointer));
4366static void xm_set_menu_resources_from_menu_face P_ ((struct frame *, Widget));
4367
4368
4369/* Set widget W's X resources from P which points to an x_resources
4370 structure. If W is a cascade button, apply resources to W's
4371 submenu. */
4372
4373static void
4374xm_apply_resources (w, p)
4375 Widget w;
4376 XtPointer p;
4377{
4378 Widget submenu = 0;
4379 struct x_resources *res = (struct x_resources *) p;
4380
4381 XtSetValues (w, res->av, res->ac);
4382 XtVaGetValues (w, XmNsubMenuId, &submenu, NULL);
4383 if (submenu)
4384 {
4385 XtSetValues (submenu, res->av, res->ac);
4386 XtApplyToWidgets (submenu, xm_apply_resources, p);
4387 }
4388}
4389
4390
4391/* Set X resources of menu-widget WIDGET on frame F from face `menu'.
4392 This is the LessTif/Motif version.
4393
4394 As of 2001-03-13, setting the XmNfontList resource with LessTif
4395 leads to an infinite loop somewhere in LessTif. */
4396
4397static void
4398xm_set_menu_resources_from_menu_face (f, widget)
4399 struct frame *f; 4353 struct frame *f;
4400 Widget widget;
4401{ 4354{
4402 struct face *face; 4355 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
4403 Lisp_Object lface;
4404 Arg av[3];
4405 int ac = 0;
4406 XmFontList fl = 0;
4407
4408 lface = lface_from_face_name (f, Qmenu, 1);
4409 face = FACE_FROM_ID (f, MENU_FACE_ID);
4410
4411 if (!UNSPECIFIEDP (LFACE_FOREGROUND (lface)))
4412 {
4413 XtSetArg (av[ac], XmNforeground, face->foreground);
4414 ++ac;
4415 }
4416
4417 if (!UNSPECIFIEDP (LFACE_BACKGROUND (lface)))
4418 {
4419 XtSetArg (av[ac], XmNbackground, face->background);
4420 ++ac;
4421 }
4422
4423 /* If any font-related attribute of `menu' is set, set the font. */
4424 if (face->font
4425 && (!UNSPECIFIEDP (LFACE_FAMILY (lface))
4426 || !UNSPECIFIEDP (LFACE_SWIDTH (lface))
4427 || !UNSPECIFIEDP (LFACE_AVGWIDTH (lface))
4428 || !UNSPECIFIEDP (LFACE_WEIGHT (lface))
4429 || !UNSPECIFIEDP (LFACE_SLANT (lface))
4430 || !UNSPECIFIEDP (LFACE_HEIGHT (lface))))
4431 {
4432 XmFontListEntry fe;
4433 fe = XmFontListEntryCreate ("menu_font", XmFONT_IS_FONT, face->font);
4434 fl = XmFontListAppendEntry (NULL, fe);
4435 XtSetArg (av[ac], XmNfontList, fl);
4436 ++ac;
4437 }
4438
4439 xassert (ac <= sizeof av / sizeof *av);
4440 4356
4441 if (ac) 4357 if (dpyinfo)
4442 { 4358 {
4443 struct x_resources res; 4359 Display *dpy = FRAME_X_DISPLAY (f);
4360 XrmDatabase rdb = XrmGetDatabase (dpy);
4361 extern Lisp_Object Vx_resource_name;
4444 4362
4445 XtSetValues (widget, av, ac); 4363 if (rdb)
4446 res.av = av, res.ac = ac; 4364 {
4447 XtApplyToWidgets (widget, xm_apply_resources, &res); 4365 char line[512];
4366 Lisp_Object lface = lface_from_face_name (f, Qmenu, 1);
4367 struct face *face = FACE_FROM_ID (f, MENU_FACE_ID);
4368 char *myname = XSTRING (Vx_resource_name)->data;
4369 int changes = 0;
4448 4370
4449 if (fl) 4371 if (STRINGP (LFACE_FOREGROUND (lface)))
4450 XmFontListFree (fl); 4372 {
4451 } 4373 sprintf (line, "%s.menu*foreground: %s",
4452} 4374 myname, XSTRING (LFACE_FOREGROUND (lface))->data);
4453 4375 XrmPutLineResource (&rdb, line);
4454#endif /* USE_MOTIF */ 4376 sprintf (line, "%s.pane.menubar*foreground: %s",
4455 4377 myname, XSTRING (LFACE_FOREGROUND (lface))->data);
4456#ifdef USE_LUCID 4378 XrmPutLineResource (&rdb, line);
4457 4379 ++changes;
4458static void xl_apply_resources P_ ((Widget, XtPointer)); 4380 }
4459static void xl_set_menu_resources_from_menu_face P_ ((struct frame *, Widget));
4460
4461
4462/* Set widget W's resources from P which points to an x_resources
4463 structure. */
4464
4465static void
4466xl_apply_resources (widget, p)
4467 Widget widget;
4468 XtPointer p;
4469{
4470 struct x_resources *res = (struct x_resources *) p;
4471 XtSetValues (widget, res->av, res->ac);
4472}
4473
4474
4475/* On frame F, set X resources of menu-widget WIDGET from face `menu'.
4476 This is the Lucid version. */
4477
4478static void
4479xl_set_menu_resources_from_menu_face (f, widget)
4480 struct frame *f;
4481 Widget widget;
4482{
4483 struct face *face;
4484 Lisp_Object lface;
4485 Arg av[3];
4486 int ac = 0;
4487
4488 lface = lface_from_face_name (f, Qmenu, 1);
4489 face = FACE_FROM_ID (f, MENU_FACE_ID);
4490
4491 if (!UNSPECIFIEDP (LFACE_FOREGROUND (lface)))
4492 {
4493 XtSetArg (av[ac], XtNforeground, face->foreground);
4494 ++ac;
4495 }
4496
4497 if (!UNSPECIFIEDP (LFACE_BACKGROUND (lface)))
4498 {
4499 XtSetArg (av[ac], XtNbackground, face->background);
4500 ++ac;
4501 }
4502
4503 if (face->font
4504 && (!UNSPECIFIEDP (LFACE_FAMILY (lface))
4505 || !UNSPECIFIEDP (LFACE_SWIDTH (lface))
4506 || !UNSPECIFIEDP (LFACE_AVGWIDTH (lface))
4507 || !UNSPECIFIEDP (LFACE_WEIGHT (lface))
4508 || !UNSPECIFIEDP (LFACE_SLANT (lface))
4509 || !UNSPECIFIEDP (LFACE_HEIGHT (lface))))
4510 {
4511 XtSetArg (av[ac], XtNfont, face->font);
4512 ++ac;
4513 }
4514
4515 if (ac)
4516 {
4517 struct x_resources res;
4518 4381
4519 XtSetValues (widget, av, ac); 4382 if (STRINGP (LFACE_BACKGROUND (lface)))
4383 {
4384 sprintf (line, "%s*menu*background: %s",
4385 myname, XSTRING (LFACE_BACKGROUND (lface))->data);
4386 XrmPutLineResource (&rdb, line);
4387 sprintf (line, "%s.pane.menubar*background: %s",
4388 myname, XSTRING (LFACE_BACKGROUND (lface))->data);
4389 XrmPutLineResource (&rdb, line);
4390 ++changes;
4391 }
4392
4393 if (face->font_name
4394 && (!UNSPECIFIEDP (LFACE_FAMILY (lface))
4395 || !UNSPECIFIEDP (LFACE_SWIDTH (lface))
4396 || !UNSPECIFIEDP (LFACE_AVGWIDTH (lface))
4397 || !UNSPECIFIEDP (LFACE_WEIGHT (lface))
4398 || !UNSPECIFIEDP (LFACE_SLANT (lface))
4399 || !UNSPECIFIEDP (LFACE_HEIGHT (lface))))
4400 {
4401#ifdef USE_MOTIF
4402 char *format1 = "%s.pane.menubar*fontList: %s";
4403 char *format2 = "%s*menu*fontList: %s";
4404#else
4405 char *format1 = "%s.pane.menubar*font: %s";
4406 char *format2 = "%s*menu*font: %s";
4407#endif
4408 sprintf (line, format1, myname, face->font_name);
4409 XrmPutLineResource (&rdb, line);
4410 sprintf (line, format2, myname, face->font_name);
4411 XrmPutLineResource (&rdb, line);
4412 ++changes;
4413 }
4520 4414
4521 /* We must do children here in case we're handling a pop-up menu 4415 if (changes && f->output_data.x->menubar_widget)
4522 in which case WIDGET is a popup shell. XtApplyToWidgets 4416 {
4523 is a function from lwlib. */ 4417 free_frame_menubar (f);
4524 res.av = av, res.ac = ac; 4418 set_frame_menubar (f, 1, 1);
4525 XtApplyToWidgets (widget, xl_apply_resources, &res); 4419 XWINDOW (FRAME_SELECTED_WINDOW (f))->update_mode_line = Qt;
4420 }
4421 }
4526 } 4422 }
4527} 4423}
4528 4424
4529#endif /* USE_LUCID */
4530
4531
4532/* On frame F, set X resources of menu-widget WIDGET from face `menu'. */
4533
4534void
4535x_set_menu_resources_from_menu_face (f, widget)
4536 struct frame *f;
4537 Widget widget;
4538{
4539 /* Realized faces may have been removed on frame F, e.g. because of
4540 face attribute changes. Recompute them, if necessary, since we
4541 will need the `menu' face. */
4542 if (f->face_cache->used == 0)
4543 recompute_basic_faces (f);
4544
4545 BLOCK_INPUT;
4546#ifdef USE_LUCID
4547 xl_set_menu_resources_from_menu_face (f, widget);
4548#endif
4549#ifdef USE_MOTIF
4550 xm_set_menu_resources_from_menu_face (f, widget);
4551#endif
4552 UNBLOCK_INPUT;
4553}
4554 4425
4555#endif /* USE_X_TOOLKIT */ 4426#endif /* USE_X_TOOLKIT */
4556 4427
@@ -6100,15 +5971,9 @@ realize_basic_faces (f)
6100 if (menu_face_change_count) 5971 if (menu_face_change_count)
6101 { 5972 {
6102 menu_face_change_count = 0; 5973 menu_face_change_count = 0;
6103
6104#ifdef USE_X_TOOLKIT 5974#ifdef USE_X_TOOLKIT
6105 if (FRAME_X_P (f)) 5975 x_set_menu_face_resources (f);
6106 { 5976#endif
6107 Widget menu = f->output_data.x->menubar_widget;
6108 if (menu)
6109 x_set_menu_resources_from_menu_face (f, menu);
6110 }
6111#endif /* USE_X_TOOLKIT */
6112 } 5977 }
6113 5978
6114 success_p = 1; 5979 success_p = 1;