emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: customize-face: inverse-video does not work when customizing the men


From: Eli Zaretskii
Subject: Re: customize-face: inverse-video does not work when customizing the menu face
Date: Thu, 29 Nov 2001 19:08:17 +0200 (IST)

On Sat, 24 Nov 2001, Richard Stallman wrote:

>     I like better what Gerd seemed to be suggesting: add to xrdb.c code
>     that defines X resources for the default colors.  We already do that
>     for the background colors; all I need to add is similar code for the
>     foreground colors.  Then we will always be able to get the default
>     colors from x_get_resource.  Does that sound reasonable?
> 
> It is certainly possible to do this.  I see a possible reason it might
> be the wrong thing to do.  A user might want menus to appear in the
> system default colors and might find it strange that Emacs alone
> uses different colors for its menus.

We are doing this for the menu background already; all I added is code to 
do the same for the foreground.

Below is what I came up with.  These changes handle the inverse attribute 
of the menu face correctly in the toolkit versions, both when the menu 
colors are specified by the user and when they are left unspecified.

If no one objects, I will install these changes.

Btw, while working on this, I found a curious problem (it is also present 
in the current code, before my changes): sometimes, XrmPutLineResource 
has no effect whatsoever!  I mean, Emacs calls XrmPutLineResource that 
was supposed to change the "emacs.pane.menubar.foreground" resource, but 
the menu-bar's appearance does not change, and x-get-resource tells me 
that the new foreground is not in the resource data base.  The curious 
thing is that this happens in a seemingly random fashion, and I couldn't 
find any pattern in that randomness.  Does someone have an idea what 
could be the problem here?  Is there some X call I'm missing?


2001-11-29  Eli Zaretskii  <address@hidden>

        * xrdb.c (x_load_resources) [USE_MOTIF]: Put menu foreground color
        into the X resources, not only background.
        [USE_X_TOOLKIT]: Put menu foreground and background colors into
        the X resources.

        * xfaces.c (x_update_menu_appearance): Handle the inverse_p
        attribute of the menu face correctly, even if the menu colors are
        the default colors.  In case of the default colors, use those
        loaded into the X resources by x_load_resources.


*** src/xrdb.c~0        Thu Aug 16 14:55:19 2001
--- src/xrdb.c  Wed Nov 28 13:54:31 2001
***************
*** 551,558 ****
--- 551,562 ----
    XrmPutLineResource (&rdb, line);
    sprintf (line, "%s*menu*background: grey75", myclass);
    XrmPutLineResource (&rdb, line);
+   /* xfaces.c:x_update_menu_appearance depends on the following two
+      resources being present.  */
    sprintf (line, "%s*menubar*background: grey75", myclass);
    XrmPutLineResource (&rdb, line);
+   sprintf (line, "%s.pane.menubar.foreground: black", myclass);
+   XrmPutLineResource (&rdb, line);
    sprintf (line, "%s*verticalScrollBar.background: grey75", myclass);
    XrmPutLineResource (&rdb, line);
    sprintf (line, "%s*verticalScrollBar.troughColor: grey75", myclass);
***************
*** 603,608 ****
--- 607,623 ----
    sprintf (line, "Emacs*verticalScrollBar.background: grey75");
    XrmPutLineResource (&rdb, line);
  
+ #ifdef USE_X_TOOLKIT
+ 
+   /* xfaces.c:x_update_menu_appearance depends on the following two
+      resources being present.  */
+   sprintf (line, "%s.pane.menubar.background: grey75", myclass);
+   XrmPutLineResource (&rdb, line);
+   sprintf (line, "%s.pane.menubar.foreground: black", myclass);
+   XrmPutLineResource (&rdb, line);
+ 
+ #endif /* USE_X_TOOLKIT */
+ 
  #endif /* not USE_MOTIF */
  
    user_database = get_user_db (display);



*** src/xfaces.c        Wed Aug 22 12:04:54 2001
--- ./xfaces.c  Thu Nov 29 18:53:42 2001
***************
*** 4435,4465 ****
  #else
        const char *popup_path = "menu.popup";
  #endif
!       
        if (STRINGP (LFACE_FOREGROUND (lface)))
        {
!         sprintf (line, "%s.%s*foreground: %s",
!                  myname, popup_path,
!                  XSTRING (LFACE_FOREGROUND (lface))->data);
          XrmPutLineResource (&rdb, line);
!         sprintf (line, "%s.pane.menubar*foreground: %s",
!                  myname, XSTRING (LFACE_FOREGROUND (lface))->data);
          XrmPutLineResource (&rdb, line);
          changed_p = 1;
        }
  
!       if (STRINGP (LFACE_BACKGROUND (lface)))
        {
!         sprintf (line, "%s.%s*background: %s",
!                  myname, popup_path,
!                  XSTRING (LFACE_BACKGROUND (lface))->data);
          XrmPutLineResource (&rdb, line);
!         sprintf (line, "%s.pane.menubar*background: %s",
!                  myname, XSTRING (LFACE_BACKGROUND (lface))->data);
          XrmPutLineResource (&rdb, line);
          changed_p = 1;
        }
!         
        if (face->font_name
          && (!UNSPECIFIEDP (LFACE_FAMILY (lface))
              || !UNSPECIFIEDP (LFACE_SWIDTH (lface))
--- 4435,4512 ----
  #else
        const char *popup_path = "menu.popup";
  #endif
!       char *face_fg = NULL, *face_bg = NULL;
!       static int default_fg_inverted = 0, default_bg_inverted = 0;
!       int should_invert = EQ (LFACE_INVERSE (lface), Qt);
!       int really_invert;
!       int bg_defaulted = 0, fg_defaulted = 0;
!       extern char *x_get_resource_string P_((char *, char *));
! 
!       /* If the menu face colors are unspecified, get them from the X
!        resources.  This allows us to handle the inverse-video-p
!        attribute even with unspecified colors.  We defined backup
!        resources in xrdb.c:x_load_resources, precisely for this
!        case.  */
        if (STRINGP (LFACE_FOREGROUND (lface)))
+       face_fg = XSTRING (LFACE_FOREGROUND (lface))->data;
+       else
        {
!         fg_defaulted = 1;
!         face_fg = x_get_resource_string ("pane.menubar.foreground",
!                                          "Foreground");
!       }
!       if (STRINGP (LFACE_BACKGROUND (lface)))
!       face_bg = XSTRING (LFACE_BACKGROUND (lface))->data;
!       else
!       {
!         bg_defaulted = 1;
!         face_bg = x_get_resource_string ("pane.menubar.background",
!                                          "Background");
!       }
! 
!       if (face_fg)
!       {
!         really_invert = should_invert;
!         /* If we use the default color (from the X resources), and
!            we already inverted them once, don't invert again.  This
!            is because the first time we invert the default colors,
!            they stay inverted in the resources, and we should simply
!            use them.  */
!         if (really_invert && fg_defaulted)
!           {
!             if (default_fg_inverted)
!               really_invert = 0;
!             else
!               default_fg_inverted = 1;
!           }
!         sprintf (line, "%s.%s*%sground: %s", myname, popup_path,
!                  really_invert ? "back" : "fore", face_fg);
          XrmPutLineResource (&rdb, line);
!         sprintf (line, "%s.pane.menubar*%sground: %s", myname,
!                  really_invert ? "back" : "fore", face_fg);
          XrmPutLineResource (&rdb, line);
          changed_p = 1;
        }
  
!       if (face_bg)
        {
!         really_invert = should_invert;
!         if (really_invert && bg_defaulted)
!           {
!             if (default_bg_inverted)
!               really_invert = 0;
!             else
!               default_bg_inverted = 1;
!           }
!         sprintf (line, "%s.%s*%sground: %s", myname, popup_path,
!                  really_invert ? "fore" : "back", face_bg);
          XrmPutLineResource (&rdb, line);
!         sprintf (line, "%s.pane.menubar*%sground: %s", myname,
!                  really_invert ? "fore" : "back", face_bg);
          XrmPutLineResource (&rdb, line);
          changed_p = 1;
        }
! 
        if (face->font_name
          && (!UNSPECIFIEDP (LFACE_FAMILY (lface))
              || !UNSPECIFIEDP (LFACE_SWIDTH (lface))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]