unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Po Lu <luangruo@yahoo.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Lucid menu faces
Date: Thu, 21 Jul 2022 09:21:26 +0800	[thread overview]
Message-ID: <87bktj9s6h.fsf@yahoo.com> (raw)
In-Reply-To: <83mtd3lqgv.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 20 Jul 2022 19:05:20 +0300")

Eli Zaretskii <eliz@gnu.org> writes:

> Isn't it true that the appearance of toolkit menus can be fully
> controlled only through X resources?  Toolkits are not part of Emacs,
> so they don't abide by our Lisp trickery.  We are all spoiled rotten
> by Emacs letting us control everything via Lisp objects and
> properties, but the truth is that it only works because Emacs has code
> to make it work.  Toolkits don't: they have no idea what is a 'face'
> in its Emacs interpretation.

Yes.  There is a hack in xfaces.c wrt the `menu' face:

static void
x_update_menu_appearance (struct frame *f)
{
  struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
  XrmDatabase rdb;

  if (dpyinfo
      && (rdb = XrmGetDatabase (FRAME_X_DISPLAY (f)),
	  rdb != NULL))
    {
      char line[512];
      char *buf = line;
      ptrdiff_t bufsize = sizeof line;
      Lisp_Object lface = lface_from_face_name (f, Qmenu, true);
      struct face *face = FACE_FROM_ID (f, MENU_FACE_ID);
      const char *myname = SSDATA (Vx_resource_name);
      bool changed_p = false;
#ifdef USE_MOTIF
      const char *popup_path = "popup_menu";
#else
      const char *popup_path = "menu.popup";
#endif

      if (STRINGP (LFACE_FOREGROUND (lface)))
	{
	  exprintf (&buf, &bufsize, line, -1, "%s.%s*foreground: %s",
		    myname, popup_path,
		    SDATA (LFACE_FOREGROUND (lface)));
	  XrmPutLineResource (&rdb, line);
	  exprintf (&buf, &bufsize, line, -1, "%s.pane.menubar*foreground: %s",
		    myname, SDATA (LFACE_FOREGROUND (lface)));
	  XrmPutLineResource (&rdb, line);
	  changed_p = true;
	}

      if (STRINGP (LFACE_BACKGROUND (lface)))
	{
	  exprintf (&buf, &bufsize, line, -1, "%s.%s*background: %s",
		    myname, popup_path,
		    SDATA (LFACE_BACKGROUND (lface)));
	  XrmPutLineResource (&rdb, line);

	  exprintf (&buf, &bufsize, line, -1, "%s.pane.menubar*background: %s",
		    myname, SDATA (LFACE_BACKGROUND (lface)));
	  XrmPutLineResource (&rdb, line);
	  changed_p = true;
	}

      if (face->font
	  /* On Solaris 5.8, it's been reported that the `menu' face
	     can be unspecified here, during startup.  Why this
	     happens remains unknown.  -- cyd  */
	  && FONTP (LFACE_FONT (lface))
	  && (!UNSPECIFIEDP (LFACE_FAMILY (lface))
	      || !UNSPECIFIEDP (LFACE_FOUNDRY (lface))
	      || !UNSPECIFIEDP (LFACE_SWIDTH (lface))
	      || !UNSPECIFIEDP (LFACE_WEIGHT (lface))
	      || !UNSPECIFIEDP (LFACE_SLANT (lface))
	      || !UNSPECIFIEDP (LFACE_HEIGHT (lface))))
	{
	  Lisp_Object xlfd = Ffont_xlfd_name (LFACE_FONT (lface), Qnil);
#ifdef USE_MOTIF
	  const char *suffix = "List";
	  bool motif = true;
#else
#if defined HAVE_X_I18N

	  const char *suffix = "Set";
#else
	  const char *suffix = "";
#endif
	  bool motif = false;
#endif

	  if (! NILP (xlfd))
	    {
#if defined HAVE_X_I18N
	      char *fontsetname = xic_create_fontsetname (SSDATA (xlfd), motif);
#else
	      char *fontsetname = SSDATA (xlfd);
#endif
	      exprintf (&buf, &bufsize, line, -1, "%s.pane.menubar*font%s: %s",
			myname, suffix, fontsetname);
	      XrmPutLineResource (&rdb, line);

	      exprintf (&buf, &bufsize, line, -1, "%s.%s*font%s: %s",
			myname, popup_path, suffix, fontsetname);
	      XrmPutLineResource (&rdb, line);
	      changed_p = true;
	      if (fontsetname != SSDATA (xlfd))
		xfree (fontsetname);
	    }
	}

      if (changed_p && f->output_data.x->menubar_widget)
	free_frame_menubar (f);

      if (buf != line)
	xfree (buf);
    }
}



  reply	other threads:[~2022-07-21  1:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-20 14:54 Lucid menu faces Manuel Giraud
2022-07-20 16:05 ` Eli Zaretskii
2022-07-21  1:21   ` Po Lu [this message]
2022-07-21 13:23   ` Manuel Giraud
2022-07-21 13:27     ` Po Lu
2022-07-21 16:15       ` Manuel Giraud
2022-07-22  1:04         ` Po Lu
2022-07-22  6:38           ` Manuel Giraud

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bktj9s6h.fsf@yahoo.com \
    --to=luangruo@yahoo.com \
    --cc=eliz@gnu.org \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).