all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Lucid menu faces
@ 2022-07-20 14:54 Manuel Giraud
  2022-07-20 16:05 ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Manuel Giraud @ 2022-07-20 14:54 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

The bug found by Colin earlier led me to the following question: how
hard would it be to have the Lucid menu rebuilt from elisp code?

As it is, if I do this:
--8<---------------cut here---------------start------------->8---
(let ((class '((class color) (min-colors 89))))
  (custom-theme-set-faces
   'user
   `(menu ((,class (:family "Iosevka" :foregroud "red" :background "blue"))))))
--8<---------------cut here---------------end--------------->8---

only the background color of the menu is changed.  Not the family font
nor the foreground color.

Best regards,
-- 
Manuel Giraud



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Lucid menu faces
  2022-07-20 14:54 Lucid menu faces Manuel Giraud
@ 2022-07-20 16:05 ` Eli Zaretskii
  2022-07-21  1:21   ` Po Lu
  2022-07-21 13:23   ` Manuel Giraud
  0 siblings, 2 replies; 8+ messages in thread
From: Eli Zaretskii @ 2022-07-20 16:05 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Manuel Giraud <manuel@ledu-giraud.fr>
> Date: Wed, 20 Jul 2022 16:54:52 +0200
> 
> Hi,
> 
> The bug found by Colin earlier led me to the following question: how
> hard would it be to have the Lucid menu rebuilt from elisp code?
> 
> As it is, if I do this:
> --8<---------------cut here---------------start------------->8---
> (let ((class '((class color) (min-colors 89))))
>   (custom-theme-set-faces
>    'user
>    `(menu ((,class (:family "Iosevka" :foregroud "red" :background "blue"))))))
> --8<---------------cut here---------------end--------------->8---
> 
> only the background color of the menu is changed.  Not the family font
> nor the foreground color.

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.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Lucid menu faces
  2022-07-20 16:05 ` Eli Zaretskii
@ 2022-07-21  1:21   ` Po Lu
  2022-07-21 13:23   ` Manuel Giraud
  1 sibling, 0 replies; 8+ messages in thread
From: Po Lu @ 2022-07-21  1:21 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

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);
    }
}



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Lucid menu faces
  2022-07-20 16:05 ` Eli Zaretskii
  2022-07-21  1:21   ` Po Lu
@ 2022-07-21 13:23   ` Manuel Giraud
  2022-07-21 13:27     ` Po Lu
  1 sibling, 1 reply; 8+ messages in thread
From: Manuel Giraud @ 2022-07-21 13:23 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

Eli Zaretskii <eliz@gnu.org> writes:

[...]

> Isn't it true that the appearance of toolkit menus can be fully
> controlled only through X resources?

Yes of course and so far this is what I'm doing.

> 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.

Ok.  I was just wondering as it partially work for the background of the
menu face.

As for my personal use case, I'd like to have that because I'm a exwm
user on a laptop (i.e. I do go from laptop screen to external ones back
and forth and so use differents resolutions).  So being able to modify
the menu aspect *without* restarting Emacs would be an improvement… but
it is not of life-and-death importance either.
-- 
Manuel Giraud



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Lucid menu faces
  2022-07-21 13:23   ` Manuel Giraud
@ 2022-07-21 13:27     ` Po Lu
  2022-07-21 16:15       ` Manuel Giraud
  0 siblings, 1 reply; 8+ messages in thread
From: Po Lu @ 2022-07-21 13:27 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: Eli Zaretskii, help-gnu-emacs

Manuel Giraud <manuel@ledu-giraud.fr> writes:

> As for my personal use case, I'd like to have that because I'm a exwm
> user on a laptop (i.e. I do go from laptop screen to external ones back
> and forth and so use differents resolutions).  So being able to modify
> the menu aspect *without* restarting Emacs would be an improvement… but
> it is not of life-and-death importance either.

Why not use the no-toolkit build?  There, the menu bar (but not the menu
itself) is drawn by redisplay itself.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Lucid menu faces
  2022-07-21 13:27     ` Po Lu
@ 2022-07-21 16:15       ` Manuel Giraud
  2022-07-22  1:04         ` Po Lu
  0 siblings, 1 reply; 8+ messages in thread
From: Manuel Giraud @ 2022-07-21 16:15 UTC (permalink / raw)
  To: Po Lu; +Cc: Eli Zaretskii, help-gnu-emacs

Po Lu <luangruo@yahoo.com> writes:

[...]

> Why not use the no-toolkit build?  There, the menu bar (but not the menu
> itself) is drawn by redisplay itself.

Yes why not but last time I check it was a bit ugly… but maybe
no-toolkit needs some tweaks (or love).
-- 
Manuel Giraud



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Lucid menu faces
  2022-07-21 16:15       ` Manuel Giraud
@ 2022-07-22  1:04         ` Po Lu
  2022-07-22  6:38           ` Manuel Giraud
  0 siblings, 1 reply; 8+ messages in thread
From: Po Lu @ 2022-07-22  1:04 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: Eli Zaretskii, help-gnu-emacs

Manuel Giraud <manuel@ledu-giraud.fr> writes:

> Yes why not but last time I check it was a bit ugly… but maybe
> no-toolkit needs some tweaks (or love).

The point is it can be made prettier by changing the `menu' face.
(Or at least until you actually open the menus.)



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Lucid menu faces
  2022-07-22  1:04         ` Po Lu
@ 2022-07-22  6:38           ` Manuel Giraud
  0 siblings, 0 replies; 8+ messages in thread
From: Manuel Giraud @ 2022-07-22  6:38 UTC (permalink / raw)
  To: Po Lu; +Cc: Eli Zaretskii, help-gnu-emacs

Po Lu <luangruo@yahoo.com> writes:

> Manuel Giraud <manuel@ledu-giraud.fr> writes:
>
>> Yes why not but last time I check it was a bit ugly… but maybe
>> no-toolkit needs some tweaks (or love).
>
> The point is it can be made prettier by changing the `menu' face.
> (Or at least until you actually open the menus.)

Yes I understood but there are some bugs/annoyances.  Just one example,
if I do:
--8<---------------cut here---------------start------------->8---
(custom-set-faces
 '(menu ((t (:family "Iosevka" :height 1.2))))
--8<---------------cut here---------------end--------------->8---

The height of the menu bar won't be correctly recalculated so menu-bar
entries will be truncated vertically.

I don't think that anybody really use the no-toolkit build nowadays.
And that why I said it might need some love to be usable again.
-- 
Manuel Giraud



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-07-22  6:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-20 14:54 Lucid menu faces Manuel Giraud
2022-07-20 16:05 ` Eli Zaretskii
2022-07-21  1:21   ` Po Lu
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

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.