From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#56538: 29.0.50; [PATCH] Colored highlight in Lucid backend Date: Thu, 14 Jul 2022 08:53:39 +0800 Message-ID: <87k08gtsz0.fsf@yahoo.com> References: <87wnch16as.fsf@elite.giraud> Reply-To: Po Lu Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13023"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.91 (gnu/linux) Cc: 56538@debbugs.gnu.org To: Manuel Giraud Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jul 14 02:55:47 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oBn8s-000399-Rr for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 14 Jul 2022 02:55:46 +0200 Original-Received: from localhost ([::1]:40946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBn8q-0004nJ-84 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 Jul 2022 20:55:44 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBn8B-0004ld-KY for bug-gnu-emacs@gnu.org; Wed, 13 Jul 2022 20:55:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54112) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oBn8B-0000f3-9H for bug-gnu-emacs@gnu.org; Wed, 13 Jul 2022 20:55:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oBn8B-0006TQ-8z for bug-gnu-emacs@gnu.org; Wed, 13 Jul 2022 20:55:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Po Lu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 14 Jul 2022 00:55:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56538 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 56538-submit@debbugs.gnu.org id=B56538.165776004824786 (code B ref 56538); Thu, 14 Jul 2022 00:55:03 +0000 Original-Received: (at 56538) by debbugs.gnu.org; 14 Jul 2022 00:54:08 +0000 Original-Received: from localhost ([127.0.0.1]:48004 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oBn7A-0006RC-13 for submit@debbugs.gnu.org; Wed, 13 Jul 2022 20:54:07 -0400 Original-Received: from sonic305-22.consmr.mail.ne1.yahoo.com ([66.163.185.148]:42634) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oBn77-0006Qr-PV for 56538@debbugs.gnu.org; Wed, 13 Jul 2022 20:53:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1657760031; bh=uS3rGGvANJxBwPLB57hcTHmSUE1hNjcdUKZwDovtpGQ=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=i/gqH49wCGmzmPOb1BCldpVQKzPRsj6YqEbZQkpHyBi+RWQn6VGtHWZke4/uo9QRw3DxtdvZSAI62CzrDBI0VooAsAAWrxg5I2I00SJU5600mm2C0WLvY4PolKAQatXruoTKTs9b87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NQQ T9B.t33rq_hYXr0D9Uyy5s0NikkO1v_NQRSOKjL6shq8ga9BTmxegV00bem1stVyNU3Px2EC1M7E U3OlNpW2n7XFUKnlzOiMoXX9n84hr9yKo1Ies7Nl31WWfYi8sv.V9WQNjwG.tVjMwYFA3BHjm2ZY rr72GMW.ARllnSI59aS5dvoNmQlLnYHVSjJQX2lHhrTrRHb9EkWBHLweKMNrIoUczSmZgvkOX1nN h63VYkJPceMsUBVJwMmtYLG.LJ4u4czgcbdT19Pa9bkQQdrBLCNHxachikTonzsDmUITho.MkIUU .yIKrXq2ttu66UPVB6BOTYKnqpB4i8i9bZky4VWftZupRx3hdlPw1NFwwyByQuwfSUHGs98glLXb xEwCzOYlyP6hbA3DClM5B9SjER3qs448pHWhzZrE.cz_L8kkKyHaXQkb3ljZjN3xLKwSBek0JsJp eXl4Ca1F.9EZwaszHe4XAYKMb97uMM8MsEYSzhggtW X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic305.consmr.mail.ne1.yahoo.com with HTTP; Thu, 14 Jul 2022 00:53:51 +0000 Original-Received: by hermes--canary-production-sg3-67975bbd4b-hh5lh (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 56b2da1c32d6a378a41d257583198b90; Thu, 14 Jul 2022 00:53:44 +0000 (UTC) In-Reply-To: <87wnch16as.fsf@elite.giraud> (Manuel Giraud's message of "Wed, 13 Jul 2022 15:38:35 +0200") X-Mailer: WebService/1.1.20407 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:236935 Archived-At: Manuel Giraud writes: > ++++ > +** New X resources: "highlightForeground" and "highlightBackground" > +This controls colors used for highlighted menu item. This should say which widget it applies to, and that it only applies under the Lucid build. > + {XmNtopHighlightShadowColor, XmCTopHighlightShadowColor, XtRPixel, > + sizeof (Pixel), offset (menu.top_highlight_shadow_color), > + XtRImmediate, (XtPointer)-1}, > + {XmNbottomHighlightShadowColor, XmCBottomHighlightShadowColor, XtRPixel, > + sizeof (Pixel), offset (menu.bottom_highlight_shadow_color), > + XtRImmediate, (XtPointer)-1}, > + {XmNtopHighlightShadowPixmap, XmCTopHighlightShadowPixmap, XtRPixmap, > + sizeof (Pixmap), offset (menu.top_highlight_shadow_pixmap),XtRImmediate, > + (XtPointer)None}, > + {XmNbottomHighlightShadowPixmap, XmCBottomHighlightShadowPixmap, XtRPixmap, > + sizeof (Pixmap), offset (menu.bottom_highlight_shadow_pixmap),XtRImmediate, > + (XtPointer)None}, Please fix the coding style here so that there is at least a space between casts and what is being casted. I know the rest of xlwmenu.c doesn't follow that coding style strictly, but there is no excuse to add even more incorrectly formatted code. > + /* XXX the following permutation is on purpose */ This comment seems redundant. > +/* > + * Generic draw shadow rectangle function. It is used to draw menus, menu items > + * and also toggle buttons. When ERASE_P is true, it clears shadows. DOWN_P is > + * true when a menu item is pushed or a button toggled. TOP_GC and BOTTOM_GC > + * are the graphic contexts used to draw the top and bottom shadow respectively. > + */ Please fix and re-fill the comment. We write comments like this: /* Take BAR and BAZ, and call foo_1 if appropriate. Otherwise, return false. */ > + xgcv.foreground = mw->menu.highlight_foreground; > + xgcv.background = (mw->menu.highlight_background == -1) ? > + mw->core.background_pixel : mw->menu.highlight_background; > + mw->menu.highlight_foreground_gc = XtGetGC ((Widget)mw, mask, &xgcv); > + > + xgcv.foreground = (mw->menu.highlight_background == -1) ? > + mw->core.background_pixel : mw->menu.highlight_background; > + xgcv.background = mw->menu.foreground; > + mw->menu.highlight_background_gc = XtGetGC ((Widget)mw, mask, &xgcv); What I said about coding style also applies here. Also, don't write: abc = foo_1_2 () ? mw->core.background_pixel : foo_1 (); but write: abc = (foo_1_2 () ? mw->core.background_pixel : foo_1 ()); > static void > @@ -1724,12 +1847,16 @@ release_drawing_gcs (XlwMenuWidget mw) > XtReleaseGC ((Widget) mw, mw->menu.disabled_gc); > XtReleaseGC ((Widget) mw, mw->menu.inactive_button_gc); > XtReleaseGC ((Widget) mw, mw->menu.background_gc); > + XtReleaseGC ((Widget) mw, mw->menu.highlight_foreground_gc); > + XtReleaseGC ((Widget) mw, mw->menu.highlight_background_gc); > /* let's get some segvs if we try to use these... */ > mw->menu.foreground_gc = (GC) -1; > mw->menu.button_gc = (GC) -1; > mw->menu.disabled_gc = (GC) -1; > mw->menu.inactive_button_gc = (GC) -1; > mw->menu.background_gc = (GC) -1; > + mw->menu.highlight_foreground_gc = (GC) -1; > + mw->menu.highlight_background_gc = (GC) -1; > } > > #ifndef emacs > @@ -1738,29 +1865,34 @@ #define MINL(x,y) ((((unsigned long) (x)) < ((unsigned long) (y))) \ > #endif > > static void > -make_shadow_gcs (XlwMenuWidget mw) > +compute_shadow_colors(XlwMenuWidget mw, > + Pixel *top_color, > + Pixel *bottom_color, > + Boolean *free_top_p, > + Boolean *free_bottom_p, > + Pixmap *top_pixmap, > + Pixmap *bottom_pixmap, > + Pixel fore_color, > + Pixel back_color) There should be a space after "compute_shadow_colors". > +static void > +make_shadow_gcs (XlwMenuWidget mw) > +{ > + XGCValues xgcv; > + unsigned long pm = 0; > + > + /* Normal shadows */ > + compute_shadow_colors(mw, > + &(mw->menu.top_shadow_color), > + &(mw->menu.bottom_shadow_color), > + &(mw->menu.free_top_shadow_color_p), > + &(mw->menu.free_bottom_shadow_color_p), > + &(mw->menu.top_shadow_pixmap), > + &(mw->menu.bottom_shadow_pixmap), > + mw->menu.foreground, > + mw->core.background_pixel); > + > + /* Highlight shadows */ > + compute_shadow_colors(mw, > + &(mw->menu.top_highlight_shadow_color), > + &(mw->menu.bottom_highlight_shadow_color), > + &(mw->menu.free_top_highlight_shadow_color_p), > + &(mw->menu.free_bottom_highlight_shadow_color_p), > + &(mw->menu.top_highlight_shadow_pixmap), > + &(mw->menu.bottom_highlight_shadow_pixmap), > + mw->menu.highlight_foreground, > + mw->menu.highlight_background); > > xgcv.fill_style = FillStippled; > xgcv.foreground = mw->menu.top_shadow_color; > @@ -1862,6 +2017,16 @@ make_shadow_gcs (XlwMenuWidget mw) > xgcv.stipple = mw->menu.bottom_shadow_pixmap; > pm = (xgcv.stipple ? GCStipple|GCFillStyle : 0); Please put spaces between "GCStipple", "|", and "GCFillStyle". Also, place a space after "compute_shadow_colors". > mw->menu.shadow_bottom_gc = XtGetGC ((Widget)mw, GCForeground | pm, &xgcv); > + > + xgcv.foreground = mw->menu.top_highlight_shadow_color; > + xgcv.stipple = mw->menu.top_highlight_shadow_pixmap; > + pm = (xgcv.stipple ? GCStipple|GCFillStyle : 0); > + mw->menu.highlight_shadow_top_gc = XtGetGC ((Widget)mw, GCForeground | pm, &xgcv); > + > + xgcv.foreground = mw->menu.bottom_highlight_shadow_color; > + xgcv.stipple = mw->menu.bottom_highlight_shadow_pixmap; > + pm = (xgcv.stipple ? GCStipple|GCFillStyle : 0); > + mw->menu.highlight_shadow_bottom_gc = XtGetGC ((Widget)mw, GCForeground | pm, &xgcv); > } What was said about casts also applies here. > @@ -2038,12 +2203,14 @@ XlwMenuRealize (Widget w, Mask *valueMask, XSetWindowAttributes *attributes) > #if defined USE_CAIRO || defined HAVE_XFT > if (mw->menu.xft_font) > { > - XColor colors[3]; > + XColor colors[4]; > colors[0].pixel = mw->menu.xft_fg.pixel = mw->menu.foreground; > colors[1].pixel = mw->menu.xft_bg.pixel = mw->core.background_pixel; > colors[2].pixel = mw->menu.xft_disabled_fg.pixel > = mw->menu.disabled_foreground; > - XQueryColors (XtDisplay (mw), mw->core.colormap, colors, 3); > + colors[3].pixel = mw->menu.xft_highlight_fg.pixel > + = mw->menu.highlight_foreground; > + XQueryColors (XtDisplay (mw), mw->core.colormap, colors, 4); > mw->menu.xft_fg.color.alpha = 0xFFFF; > mw->menu.xft_fg.color.red = colors[0].red; > mw->menu.xft_fg.color.green = colors[0].green; > @@ -2056,6 +2223,10 @@ XlwMenuRealize (Widget w, Mask *valueMask, XSetWindowAttributes *attributes) > mw->menu.xft_disabled_fg.color.red = colors[2].red; > mw->menu.xft_disabled_fg.color.green = colors[2].green; > mw->menu.xft_disabled_fg.color.blue = colors[2].blue; > + mw->menu.xft_highlight_fg.color.alpha = 0xFFFF; > + mw->menu.xft_highlight_fg.color.red = colors[3].red; > + mw->menu.xft_highlight_fg.color.green = colors[3].green; > + mw->menu.xft_highlight_fg.color.blue = colors[3].blue; > } > #endif > } > diff --git a/lwlib/xlwmenu.h b/lwlib/xlwmenu.h > index 7f4bf35939..f68d913b5a 100644 > --- a/lwlib/xlwmenu.h > +++ b/lwlib/xlwmenu.h > @@ -58,6 +58,10 @@ #define XtNallowResize "allowResize" > #define XtCAllowResize "AllowResize" > #define XtNborderThickness "borderThickness" > #define XtCBorderThickness "BorderThickness" > +#define XtNhighlightForeground "highlightForeground" > +#define XtCHighlightForeground "HighlightForeground" > +#define XtNhighlightBackground "highlightBackground" > +#define XtCHighlightBackground "HighlightBackground" > > /* Motif-compatible resource names */ > #define XmNshadowThickness "shadowThickness" > @@ -70,6 +74,16 @@ #define XmNtopShadowPixmap "topShadowPixmap" > #define XmCTopShadowPixmap "TopShadowPixmap" > #define XmNbottomShadowPixmap "bottomShadowPixmap" > #define XmCBottomShadowPixmap "BottomShadowPixmap" > +#define XmNtopHighlightShadowColor "topHighlightShadowColor" > +#define XmCTopHighlightShadowColor "TopHighlightShadowColor" > +#define XmNbottomHighlightShadowColor "bottomHighlightShadowColor" > +#define XmCBottomHighlightShadowColor "BottomHighlightShadowColor" > +#define XmNtopHighlightShadowPixmap "topHighlightShadowPixmap" > +#define XmCTopHighlightShadowPixmap "TopHighlightShadowPixmap" > +#define XmNbottomHighlightShadowPixmap "bottomHighlightShadowPixmap" > +#define XmCBottomHighlightShadowPixmap "BottomHighlightShadowPixmap" Motif doesn't have widget resources named topHighlightShadowColor, bottomHighlightShadowColor, topHighlightShadowPixmap or bottomHighlightShadowPixmap. So please delete these. > #define XmRHorizontalDimension "HorizontalDimension" > > typedef struct _XlwMenuRec *XlwMenuWidget; > diff --git a/lwlib/xlwmenuP.h b/lwlib/xlwmenuP.h > index 455ecdbce0..c314eb3e91 100644 > --- a/lwlib/xlwmenuP.h > +++ b/lwlib/xlwmenuP.h > @@ -63,13 +63,15 @@ #define _XlwMenuP_h > #if defined USE_CAIRO || defined HAVE_XFT > int default_face; > XftFont* xft_font; > - XftColor xft_fg, xft_bg, xft_disabled_fg; > + XftColor xft_fg, xft_bg, xft_disabled_fg, xft_highlight_fg; > #endif > String fontName; > XFontStruct* font; > Pixel foreground; > Pixel disabled_foreground; > Pixel button_foreground; > + Pixel highlight_foreground; > + Pixel highlight_background; > Dimension margin; > Dimension horizontal_spacing; > Dimension vertical_spacing; > @@ -80,6 +82,10 @@ #define _XlwMenuP_h > Pixel bottom_shadow_color; > Pixmap top_shadow_pixmap; > Pixmap bottom_shadow_pixmap; > + Pixel top_highlight_shadow_color; > + Pixel bottom_highlight_shadow_color; > + Pixmap top_highlight_shadow_pixmap; > + Pixmap bottom_highlight_shadow_pixmap; > Cursor cursor_shape; > XtCallbackList open; > XtCallbackList select, highlight; > @@ -88,8 +94,10 @@ #define _XlwMenuP_h > int horizontal; > > /* True means top_shadow_color and/or bottom_shadow_color must be freed. */ > - bool_bf free_top_shadow_color_p : 1; > - bool_bf free_bottom_shadow_color_p : 1; > + Boolean free_top_shadow_color_p; > + Boolean free_bottom_shadow_color_p; > + Boolean free_top_highlight_shadow_color_p; > + Boolean free_bottom_highlight_shadow_color_p; > > /* State of the XlwMenu */ > int top_depth; > @@ -112,9 +120,13 @@ #define _XlwMenuP_h > GC button_gc; > GC background_gc; > GC disabled_gc; > + GC highlight_foreground_gc; > + GC highlight_background_gc; > GC inactive_button_gc; > GC shadow_top_gc; > GC shadow_bottom_gc; > + GC highlight_shadow_top_gc; > + GC highlight_shadow_bottom_gc; > Cursor cursor; > Boolean popped_up; > Pixmap gray_pixmap; I haven't looked at the code here in much detail yet, but please verify that it builds and works correctly under Xft, Cairo, and without either of the two, and under a pseudo-color visual. (To get an X server with a pseudo color visual, run "Xephyr -screen 800x800x8".) Thanks.