From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?H=C3=A5kon?= Flatval Newsgroups: gmane.emacs.devel Subject: Re: Sv: Sv: Sv: Support for background transparency Date: Wed, 26 Jan 2022 19:16:27 +0100 Message-ID: References: <87wnlnptf2.fsf@gnus.org> <83h7bwybeg.fsf@gnu.org> <87y24t1ed1.fsf@gnus.org> <87wniv2pp8.fsf@yahoo.com> <874k5x29be.fsf@yahoo.com> <87czkhph4s.fsf@yahoo.com> <87r18vhaj0.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24860"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.6.10; emacs 27.2 Cc: Po Lu , "emacs-devel@gnu.org" To: Robert Pluim Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jan 26 19:14:30 2022 Return-path: Envelope-to: ged-emacs-devel@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 1nCmoM-0006H0-TU for ged-emacs-devel@m.gmane-mx.org; Wed, 26 Jan 2022 19:14:27 +0100 Original-Received: from localhost ([::1]:45106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCmoL-00013p-VR for ged-emacs-devel@m.gmane-mx.org; Wed, 26 Jan 2022 13:14:25 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:44860) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCm7c-0001JZ-Re for emacs-devel@gnu.org; Wed, 26 Jan 2022 12:30:22 -0500 Original-Received: from [2a01:111:f400:fe0a::81a] (port=28638 helo=EUR03-DB5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCm7V-0004Ki-UR for emacs-devel@gnu.org; Wed, 26 Jan 2022 12:30:14 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZoY1uL/q4k+J+EZYkNqk17Sy39qwplUlGecC7VCmd9kvTHOK6yElLA7P1DIA2WxBdVCJnmLaIINJc19sZEY/hPwSz19MvLMnEsX5+lbs/lD9WrL0f6ABp2XWKy1XJO9h6dxexZ4Fy9YKQACX5rfoC+At+1dcL7wMrx9H1z5p7kFR+/eMvwIYs9E4v80cydnLywu5w4l4/kx2zNHYlh2DpqN+wKK1hrKiXJLq5XZb3cNu/kwTHM6iZEhb6WAHTrgV9hYZdW1J9fc0A8kKrYvAxldTy1rBobb2my5orEV7PeF+pl+m/cUST4DXfdnGp33CgD1OUEcYDsIaDeKnvA8ipw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=npqQ+6HROSdc6OrofRF7pv9uc1k/551aliEe13FzTQA=; b=JRK8FR9XEFxfz6b87deTeZj28NgCKMu2MyzJo4M9+q9a+HYRZhLS+7boi5jPMdpP/WKFFhtgFXBp8vy8a+aEa1ZW5btWseQgVOgAUAkJMmseTGzgJlmk4T4pjYvcPrdUmX6IBQQjYBIgl4/1XxXv9VVd5nKycMua0aFS+O0fEaAb1FKlwbHto94j5E5QlrXBR0036zGPobfNkG5GXRd2dHGWimK5EJgV0YSkFbu+ZgF0tXf6RabK3CtIZl1HTR6CSiYRhuYf4s0yFuPfYK9402qEdEsPIHevJ3yiBWdI2LlZ9+fX6LKm9nccQfFaFwEjCBc9uFzdUVPW86ZtbFJEIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=npqQ+6HROSdc6OrofRF7pv9uc1k/551aliEe13FzTQA=; b=CnMfK6ReUKCFf+/PnnbvPbP7hg6y0UWsINiNADXjIL0oyRTjfVgCb6AFPeTQZRdL4FSidhUsXmSPgyOnbYpICaSlMM5UbubEISmD5Y+NNd/WD1DroBaEpv4xjVOyovrQ9vtAgV+7l2bF1sTJQ9nKXivm+VoXNAVSVwmvVT5Iq0JkQq5PScDDWyBqQxbs88FGdbajcQ/hfYiI6IeBxGhCBGuRnHfINk1FQsfawtpo8A8o7YMx0GgFRUKjPpzjDJe0yw/QBxz7ZKXTwpAwaNivy0ys3Qh4rtGBVRpqp1JVgBHDKFkZs5J64DiD/T+UixTQ1BC3Xddsj/6EXoPCBNRcwA== Original-Received: from PRAP251MB0688.EURP251.PROD.OUTLOOK.COM (2603:10a6:102:293::21) by DU0P251MB0436.EURP251.PROD.OUTLOOK.COM (2603:10a6:10:348::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.17; Wed, 26 Jan 2022 17:25:06 +0000 Original-Received: from PRAP251MB0688.EURP251.PROD.OUTLOOK.COM ([fe80::15ff:34d8:e4d9:a23f]) by PRAP251MB0688.EURP251.PROD.OUTLOOK.COM ([fe80::15ff:34d8:e4d9:a23f%5]) with mapi id 15.20.4909.007; Wed, 26 Jan 2022 17:25:05 +0000 In-reply-to: <87r18vhaj0.fsf@gmail.com> X-TMN: [aXUGpDycQijDcjVRsWTzJQ5+1wXFfBzJwlE5QLy7/yPWQMZb/tUY2UbdmTqLxdn+] X-ClientProxiedBy: OL1P279CA0048.NORP279.PROD.OUTLOOK.COM (2603:10a6:e10:14::17) To PRAP251MB0688.EURP251.PROD.OUTLOOK.COM (2603:10a6:102:293::21) X-Microsoft-Original-Message-ID: <87wnim1hj8.fsf@hotmail.com> X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 79ce4d05-239a-468d-c6ea-08d9e0f0cb32 X-MS-TrafficTypeDiagnostic: DU0P251MB0436:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: I/jwOMakxhIWrgsfausLgqFMho+FYxnt+IWqb7zZfanjkH8JdpmtE/p+qt3SwG65mhpJeXSyODDdpeMNmnlbUjOVeEbaaXa4j53xCbn9EQnIfvQ/UhluoZ1fNQX+9RJ51s6b3BmGsXO7np6fGV05pg5556lqni5W69WPn/R447rTBswPn6VY12weuumbKXRMBSVffuXibO4JSfXE7rFUPpi6uSSHBPJ3uTDUk6UXX4CNEkFnXRakN/9d/ywbIdhVoX0f6vizPffOftZvYSw4QhDVscnubam9DtLQIuUbtEftbi+wbDGhZ1HKXUDeMja5BgDiF2z4LVOEqHnaDAGxKaSkzM0rWC/A4Vhuf6WGB910gcvrOInf6RiwQrknVlaUypyqpbqSPKt4Wb5DwK6F0syzW3mILUjQv0kxFdDNNaTxRy7rKovdGvFfnxG3TtyheT6nV7uF08RAIKoVPui1Bk/FfFCXfncEoA3VSCjWTavHXmTyNQ3/i408bEsgJFw4/Z8IM6Vo+EGBjEcI1gwPIrY8HcvFOs1yxN3NGW9cy09ycUJntujzjrCCc6l7f/FlY2O/cMG7ALmaujvUA0eMKw== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?RXByV2YzYXUyK0ttK3lIRDNvK01JMFpwVklpTlNSaXdvRmtoREZEVFJyREdN?= =?utf-8?B?UFh5czE1ZXVlRmpkWmp5dUNPNlArNFlFcHpHbEhtT3BjWDdvTUhrcnk3ZWVY?= =?utf-8?B?UUloWWpKcUhFTkcrQ2VMc3Q0YzRvQUVDYi93WU0rR2tlYVl0N0NKWGVtWitS?= =?utf-8?B?SFVhQkpabzdOaTdNd05LTnh2dTVMQUhQRFFEMGVlODUwdk9jdFJ5VGF2dk1C?= =?utf-8?B?VUpFcUJGcDhLSlp3SmZlRTdUanp3dk9ZSEtzaUZuVkJMekRJS2NqVStxSEdp?= =?utf-8?B?eVVleVJ6VDhVcitXemFVcUZJaXNYS3oxLzZuRTlJSStqSnFQdWxoM2RxY0xT?= =?utf-8?B?UndFRCt0azBsdTFSd3VxYkJwTHdrL2RyUXpBa2xGdjRnRE1CdHpJRGhTNW1y?= =?utf-8?B?MEtnY1hKSmwxSWNrd00xeFJmTWhFNXlvT1UwNVcxdGtpQzJCRU1ScnNFdG5r?= =?utf-8?B?VHJDVjY0djhuTDkvUGpNUE1JOEx2dS9uc3FOSG1yczB6aW1Gc0ZseThsOHRW?= =?utf-8?B?MkNzZWQ0QWxzK1ZWT3pubzhIVEFCR2ZoZmFWMndWMlFlS1JNU1NtSHVVYlJN?= =?utf-8?B?VjJXcW45VkhrcHYrSXkvamEzK1NycGlBMjRDcE1YdXRlaW5tR05ucXNTbzJn?= =?utf-8?B?b2FBNlFEK3JqRWFPZTJMTmR6L0JOYWVKZCtlZ0 X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-00b75.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 79ce4d05-239a-468d-c6ea-08d9e0f0cb32 X-MS-Exchange-CrossTenant-AuthSource: PRAP251MB0688.EURP251.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2022 17:25:05.7854 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0P251MB0436 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:fe0a::81a (failed) Received-SPF: pass client-ip=2a01:111:f400:fe0a::81a; envelope-from=hkon20@hotmail.com; helo=EUR03-DB5-obe.outbound.protection.outlook.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:285443 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > You mean link from the Emacs user manual to the lispref? Something > like this will work: > > (@pxref{Frame Parameters,,, elisp, The Emacs Lisp Reference Manual}) I have added the links in this patch. I also updated the changelog with the improvements you suggested. - H=C3=A5kon --=-=-= Content-Type: application/octet-stream Content-Disposition: attachment; filename=alpha-background-changelog Content-Transfer-Encoding: base64 MjAyMi0wMS0yNSAgSMOla29uIEZsYXR2YWwgIDxoa29uMjBAaG90bWFpbC5jb20+CgoJKiBzcmMv eHRlcm0uYyAoeF9zZXRfY3Jfc291cmNlX3dpdGhfZ2NfYmFja2dyb3VuZCk6CiAgICAgICAgQWRk IHN1cHBvcnQgZm9yIHRyYW5zcGFyZW50IGRyYXdpbmcuCiAgICAgICAgKHhfY2xlYXJfcmVjdGFu Z2xlKToKICAgICAgICBOZXcgZnVuY3Rpb24gZm9yIGRyYXdpbmcgd2l0aCBiYWNrZ3JvdW5kIGNv bG9ycy4KCSh4X2RyYXdfcmVjdGFuZ2xlKToKICAgICAgICBVc2UgeF9jbGVhcl9yZWN0YW5nbGUg ZnVuY3Rpb24gZm9yIGRyYXdpbmcgYmFja2dyb3VuZC4KCgoJKiBzcmMveGZucy5jIChGeF9jcmVh dGVfZnJhbWUsIHhfY3JlYXRlX3RpcF9mcmFtZSk6CglBZGQgYWxwaGEtYmFja2dyb3VuZCBkZWZh dWx0cy4KCSh4X2ZyYW1lX3Bhcm1faGFuZGxlcnMpOiBBZGQgYWxwaGEtYmFja2dyb3VuZCBoYW5k bGVyLgoKCSogc3JjL3czMmZucy5jIChGeF9jcmVhdGVfZnJhbWUsIHczMl9jcmVhdGVfdGlwX2Zy YW1lKToKCUFkZCBhbHBoYS1iYWNrZ3JvdW5kIGRlZmF1bHRzLgoJKHczMl9mcmFtZV9wYXJtX2hh bmRsZXJzKTogQWRkIGFscGhhLWJhY2tncm91bmQgaGFuZGxlci4KCgkqIHNyYy9wZ3RrZm5zLmMg KHBndGtfZnJhbWVfcGFybV9oYW5kbGVycyk6CiAgICAgICAgQWRkIGFscGhhLWJhY2tncm91bmQg aGFuZGxlci4KCShGeF9jcmVhdGVfZnJhbWUsIHhfY3JlYXRlX3RpcF9mcmFtZSk6IEFkZCBhbHBo YS1iYWNrZ3JvdW5kIGRlZmF1bHRzLgoKCSogc3JjL25zZm5zLm0gKG5zX2ZyYW1lX3Bhcm1faGFu ZGxlcnMpOiBBZGQgYWxwaGEtYmFja2dyb3VuZCBoYW5kbGVyLgoJKEZ4X2NyZWF0ZV9mcmFtZSk6 IEFkZCBhbHBoYS1iYWNrZ3JvdW5kIGRlZmF1bHRzLgoKCSogc3JjL2hhaWt1Zm5zLmMgKGhhaWt1 X2NyZWF0ZV9mcmFtZSwgaGFpa3VfY3JlYXRlX3RpcF9mcmFtZSk6CglBZGQgYWxwaGEtYmFja2dy b3VuZCBkZWZhdWx0cy4KICAgICAgICAoaGFpa3VfZnJhbWVfcGFybV9oYW5kbGVycyk6IEFkZCBh bHBoYS1iYWNrZ3JvdW5kIGhhbmRsZXIuCgoKCSogc3JjL2d0a3V0aWwuYyAoeGdfY3JlYXRlX2Zy YW1lX3dpZGdldHMpOgogICAgICAgIFByZXZlbnQgR1RLIGZyb20gZmlsbGluZyBpbiBiYWNrZ3Jv dW5kLgoJKHhnX2NyZWF0ZV9mcmFtZV93aWRnZXRzKTogQWRkIHN1cHBvcnQgZm9yIDMyLWJpdCB2 aXN1YWwuCgoKCSogc3JjL2ZyYW1lLmggKEdDQUxJR05FRF9TVFJVQ1QpOiBBZGQgYWxwaGFfYmFj a2dyb3VuZCBmaWVsZC4KCgoJKiBzcmMvZnJhbWUuYyAoZnJhbWVfcGFybXMpOiBBZGQgYWxwaGEt YmFja2dyb3VuZCBmcmFtZSBwYXJhbWV0ZXIuCgkoZ3VpX3NldF9hbHBoYV9iYWNrZ3JvdW5kKToK ICAgICAgICBBZGQgZ3VpIGZ1bmN0aW9uIGZvciBzZXR0aW5nIGFscGhhLWJhY2tncm91bmQuCgko c3ltc19vZl9mcmFtZSk6IEFkZCBzeW1ib2wgZm9yIGFscGhhLWJhY2tncm91bmQuCgoJKiBkb2Mv bGlzcHJlZi9mcmFtZXMudGV4aSAoRm9udCBhbmQgQ29sb3IgUGFyYW1ldGVycyk6CiAgICAgICAg QWRkIGRvY3VtZW50YXRpb24gb24gYWxwaGEtYmFja2dyb3VuZC4KCgkqIGRvYy9lbWFjcy94cmVz b3VyY2VzLnRleGkgKFRhYmxlIG9mIFJlc291cmNlcyk6CglMaXN0IGFscGhhIGFuZCBhbHBoYS1i YWNrZ3JvdW5kIGFzIFggcmVzb3VyY2VzLgo= --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=gdk-cairo-background-transparency-009.patch diff --git a/doc/emacs/xresources.texi b/doc/emacs/xresources.texi index ccf7e35eee..bb362ca3ea 100644 --- a/doc/emacs/xresources.texi +++ b/doc/emacs/xresources.texi @@ -149,6 +149,15 @@ Table of Resources is the case. @table @asis +@item @code{alpha} (class @code{Alpha}) +Sets the @samp{alpha} frame parameter, determining frame transparency +(@pxref{Frame Parameters,,, elisp, The Emacs Lisp Reference Manual}). + +@item @code{alphaBackground} (class @code{AlphaBackground}) +Sets the @samp{alpha-background} frame parameter, determining background +transparency +(@pxref{Frame Parameters,,, elisp, The Emacs Lisp Reference Manual}). + @item @code{background} (class @code{Background}) Background color (@pxref{Colors}). diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi index 2eeb8b7ed7..16748ac922 100644 --- a/doc/lispref/frames.texi +++ b/doc/lispref/frames.texi @@ -2433,6 +2433,16 @@ Font and Color Parameters Some window systems do not support the @code{alpha} parameter for child frames (@pxref{Child Frames}). + +@vindex alpha-background@r{, a frame parameter} +@item alpha-background +@cindex opacity, frame +@cindex transparency, frame +Sets the background transparency of the frame. Unlike the @code{alpha} +frame parameter, this only controls the transparency of the background +while keeping foreground elements such as text fully opaque. It +should be an integer between 0 and 100, where 0 means +completely transparent and 100 means completely opaque (default). @end table The following frame parameters are semi-obsolete in that they are diff --git a/src/frame.c b/src/frame.c index 8aaff949ba..c331cff32b 100644 --- a/src/frame.c +++ b/src/frame.c @@ -3907,6 +3907,7 @@ DEFUN ("frame-scale-factor", Fframe_scale_factor, Sframe_scale_factor, {"z-group", SYMBOL_INDEX (Qz_group)}, {"override-redirect", SYMBOL_INDEX (Qoverride_redirect)}, {"no-special-glyphs", SYMBOL_INDEX (Qno_special_glyphs)}, + {"alpha-background", SYMBOL_INDEX (Qalpha_background)}, #ifdef NS_IMPL_COCOA {"ns-appearance", SYMBOL_INDEX (Qns_appearance)}, {"ns-transparent-titlebar", SYMBOL_INDEX (Qns_transparent_titlebar)}, @@ -5024,6 +5025,33 @@ gui_set_alpha (struct frame *f, Lisp_Object arg, Lisp_Object oldval) } } +void +gui_set_alpha_background (struct frame *f, Lisp_Object arg, Lisp_Object oldval) +{ + double alpha = 1.0; + + if (NILP (arg)) + alpha = 1.0; + else if (FLOATP (arg)) + { + alpha = XFLOAT_DATA (arg); + if (! (0 <= alpha && alpha <= 1.0)) + args_out_of_range (make_float (0.0), make_float (1.0)); + } + else if (FIXNUMP (arg)) + { + EMACS_INT ialpha = XFIXNUM (arg); + if (! (0 <= ialpha && ialpha <= 100)) + args_out_of_range (make_fixnum (0), make_fixnum (100)); + alpha = ialpha / 100.0; + } + else + wrong_type_argument (Qnumberp, arg); + + f->alpha_background = alpha; + + SET_FRAME_GARBAGED (f); +} /** * gui_set_no_special_glyphs: @@ -6100,6 +6128,7 @@ syms_of_frame (void) #endif DEFSYM (Qalpha, "alpha"); + DEFSYM (Qalpha_background, "alpha-background"); DEFSYM (Qauto_lower, "auto-lower"); DEFSYM (Qauto_raise, "auto-raise"); DEFSYM (Qborder_color, "border-color"); diff --git a/src/frame.h b/src/frame.h index cb2f58e261..5d5f2122fb 100644 --- a/src/frame.h +++ b/src/frame.h @@ -637,6 +637,9 @@ #define EMACS_FRAME_H Negative values mean not to change alpha. */ double alpha[2]; + /* Background opacity */ + double alpha_background; + /* Exponent for gamma correction of colors. 1/(VIEWING_GAMMA * SCREEN_GAMMA) where viewing_gamma is 0.4545 and SCREEN_GAMMA is a frame parameter. 0 means don't do gamma correction. */ @@ -1669,6 +1672,7 @@ #define EMACS_CLASS "Emacs" extern long gui_figure_window_size (struct frame *, Lisp_Object, bool, bool); extern void gui_set_alpha (struct frame *, Lisp_Object, Lisp_Object); +extern void gui_set_alpha_background (struct frame *, Lisp_Object, Lisp_Object); extern void gui_set_no_special_glyphs (struct frame *, Lisp_Object, Lisp_Object); extern void validate_x_resource_name (void); diff --git a/src/gtkutil.c b/src/gtkutil.c index 98907bf022..8b8123c807 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -1467,6 +1467,10 @@ xg_create_frame_widgets (struct frame *f) } wtop = gtk_window_new (type); gtk_widget_add_events (wtop, GDK_ALL_EVENTS_MASK); + + /* This prevents GTK from painting the window's background, which + would interfere with transparent background in some environments */ + gtk_widget_set_app_paintable (wtop, TRUE); #endif /* gtk_window_set_has_resize_grip is a Gtk+ 3.0 function but Ubuntu @@ -1587,6 +1591,15 @@ xg_create_frame_widgets (struct frame *f) #endif | GDK_VISIBILITY_NOTIFY_MASK); + GdkScreen *screen = gtk_widget_get_screen (wtop); + + if (FRAME_DISPLAY_INFO (f)->n_planes == 32) + { + GdkVisual *visual = gdk_screen_get_rgba_visual (screen); + gtk_widget_set_visual (wtop, visual); + gtk_widget_set_visual (wfixed, visual); + } + #ifndef HAVE_PGTK /* Must realize the windows so the X window gets created. It is used by callers of this function. */ @@ -1651,7 +1664,6 @@ xg_create_frame_widgets (struct frame *f) #endif { - GdkScreen *screen = gtk_widget_get_screen (wtop); GtkSettings *gs = gtk_settings_get_for_screen (screen); /* Only connect this signal once per screen. */ if (! g_signal_handler_find (G_OBJECT (gs), diff --git a/src/haikufns.c b/src/haikufns.c index 58a2e1d464..0e0cffea72 100644 --- a/src/haikufns.c +++ b/src/haikufns.c @@ -830,6 +830,8 @@ #define ASSIGN_CURSOR(cursor, be_cursor) \ RES_TYPE_NUMBER); gui_default_parameter (f, parms, Qalpha, Qnil, "alpha", "Alpha", RES_TYPE_NUMBER); + gui_default_parameter (f, parms, Qalpha_background, Qnil, + "alphaBackground", "AlphaBackground", RES_TYPE_NUMBER); gui_default_parameter (f, parms, Qfullscreen, Qnil, "fullscreen", "Fullscreen", RES_TYPE_SYMBOL); @@ -1043,6 +1045,8 @@ haiku_create_tip_frame (Lisp_Object parms) "cursorType", "CursorType", RES_TYPE_SYMBOL); gui_default_parameter (f, parms, Qalpha, Qnil, "alpha", "Alpha", RES_TYPE_NUMBER); + gui_default_parameter (f, parms, Qalpha_background, Qnil, + "alphaBackground", "AlphaBackground", RES_TYPE_NUMBER); initial_setup_back_buffer (f); @@ -2609,7 +2613,8 @@ DEFUN ("haiku-frame-restack", Fhaiku_frame_restack, Shaiku_frame_restack, 2, 3, haiku_set_no_accept_focus, NULL, /* set z group */ haiku_set_override_redirect, - gui_set_no_special_glyphs + gui_set_no_special_glyphs, + gui_set_alpha_background, }; void diff --git a/src/nsfns.m b/src/nsfns.m index 11132a294a..467e56ece4 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -1004,6 +1004,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side. ns_set_z_group, 0, /* x_set_override_redirect */ gui_set_no_special_glyphs, + gui_set_alpha_background, #ifdef NS_IMPL_COCOA ns_set_appearance, ns_set_transparent_titlebar, @@ -1436,6 +1437,8 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side. RES_TYPE_NUMBER); gui_default_parameter (f, parms, Qalpha, Qnil, "alpha", "Alpha", RES_TYPE_NUMBER); + gui_default_parameter (f, parms, Qalpha_background, Qnil, + "alphaBackground", "AlphaBackground", RES_TYPE_NUMBER); gui_default_parameter (f, parms, Qfullscreen, Qnil, "fullscreen", "Fullscreen", RES_TYPE_SYMBOL); diff --git a/src/pgtkfns.c b/src/pgtkfns.c index 9c37c04810..5980b31d6e 100644 --- a/src/pgtkfns.c +++ b/src/pgtkfns.c @@ -1043,6 +1043,7 @@ frames (each of which corresponds to one page). Each frame should be x_set_z_group, x_set_override_redirect, gui_set_no_special_glyphs, + gui_set_alpha_background, }; @@ -1667,6 +1668,8 @@ #define INSTALL_CURSOR(FIELD, NAME) \ RES_TYPE_NUMBER); gui_default_parameter (f, parms, Qalpha, Qnil, "alpha", "Alpha", RES_TYPE_NUMBER); + gui_default_parameter (f, parms, Qalpha, Qnil, + "alphaBackground", "AlphaBackground", RES_TYPE_NUMBER); if (!NILP (parent_frame)) { @@ -2936,6 +2939,8 @@ x_create_tip_frame (struct pgtk_display_info *dpyinfo, Lisp_Object parms, struct "cursorType", "CursorType", RES_TYPE_SYMBOL); gui_default_parameter (f, parms, Qalpha, Qnil, "alpha", "Alpha", RES_TYPE_NUMBER); + gui_default_parameter (f, parms, Qalpha_background, Qnil, + "alphaBackground", "AlphaBackground", RES_TYPE_NUMBER); /* Add `tooltip' frame parameter's default value. */ if (NILP (Fframe_parameter (frame, Qtooltip))) diff --git a/src/w32fns.c b/src/w32fns.c index 1ea685d194..009855602e 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -6018,6 +6018,8 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, NULL, NULL, RES_TYPE_BOOLEAN); gui_default_parameter (f, parameters, Qno_special_glyphs, Qnil, NULL, NULL, RES_TYPE_BOOLEAN); + gui_default_parameter (f, parameters, Qalpha_background, Qnil, + "alphaBackground", "AlphaBackground", RES_TYPE_NUMBER); /* Process alpha here (Bug#16619). On XP this fails with child frames. For `no-focus-on-map' frames delay processing of alpha @@ -6155,6 +6157,9 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, gui_default_parameter (f, parameters, Qz_group, Qnil, NULL, NULL, RES_TYPE_SYMBOL); + gui_default_parameter (f, parameters, Qalpha_background, Qnil, + "alphaBackground", "AlphaBackground", RES_TYPE_NUMBER); + /* Make the window appear on the frame and enable display, unless the caller says not to. However, with explicit parent, Emacs cannot control visibility, so don't try. */ @@ -7089,6 +7094,8 @@ w32_create_tip_frame (struct w32_display_info *dpyinfo, Lisp_Object parms) /* Process alpha here (Bug#17344). */ gui_default_parameter (f, parms, Qalpha, Qnil, "alpha", "Alpha", RES_TYPE_NUMBER); + gui_default_parameter (f, parms, Qalpha_background, Qnil, + "alphaBackground", "AlphaBackground", RES_TYPE_NUMBER); /* Add `tooltip' frame parameter's default value. */ if (NILP (Fframe_parameter (frame, Qtooltip))) @@ -10436,6 +10443,7 @@ w32_get_resource (const char *key, const char *name, LPDWORD lpdwtype) w32_set_z_group, 0, /* x_set_override_redirect */ gui_set_no_special_glyphs, + gui_set_alpha_background, }; void diff --git a/src/xfns.c b/src/xfns.c index faab1b1158..dea21ed142 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -4598,6 +4598,8 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, RES_TYPE_NUMBER); gui_default_parameter (f, parms, Qalpha, Qnil, "alpha", "Alpha", RES_TYPE_NUMBER); + gui_default_parameter (f, parms, Qalpha_background, Qnil, + "alphaBackground", "AlphaBackground", RES_TYPE_NUMBER); if (!NILP (parent_frame)) { @@ -6371,10 +6373,29 @@ select_visual (struct x_display_info *dpyinfo) int n_visuals; XVisualInfo *vinfo, vinfo_template; - dpyinfo->visual = DefaultVisualOfScreen (screen); + vinfo_template.screen = XScreenNumberOfScreen (screen); + +#if defined (USE_GTK) && defined (USE_CAIRO) + /* First attempt to use 32-bit visual if available */ + + vinfo_template.depth = 32; + + vinfo = XGetVisualInfo (dpy, VisualScreenMask | VisualDepthMask, + &vinfo_template, &n_visuals); + if (n_visuals > 0) + { + dpyinfo->n_planes = vinfo->depth; + dpyinfo->visual = vinfo->visual; + XFree (vinfo); + return; + } + +#endif /* defined (USE_GTK) && defined (USE_CAIRO) */ + + /* 32-bit visual not available, fallback to default visual */ + dpyinfo->visual = DefaultVisualOfScreen (screen); vinfo_template.visualid = XVisualIDFromVisual (dpyinfo->visual); - vinfo_template.screen = XScreenNumberOfScreen (screen); vinfo = XGetVisualInfo (dpy, VisualIDMask | VisualScreenMask, &vinfo_template, &n_visuals); if (n_visuals <= 0) @@ -7232,6 +7253,8 @@ x_create_tip_frame (struct x_display_info *dpyinfo, Lisp_Object parms) "cursorType", "CursorType", RES_TYPE_SYMBOL); gui_default_parameter (f, parms, Qalpha, Qnil, "alpha", "Alpha", RES_TYPE_NUMBER); + gui_default_parameter (f, parms, Qalpha_background, Qnil, + "alphaBackground", "AlphaBackground", RES_TYPE_NUMBER); /* Add `tooltip' frame parameter's default value. */ if (NILP (Fframe_parameter (frame, Qtooltip))) @@ -8560,6 +8583,7 @@ DEFUN ("x-gtk-debug", Fx_gtk_debug, Sx_gtk_debug, 1, 1, 0, x_set_z_group, x_set_override_redirect, gui_set_no_special_glyphs, + gui_set_alpha_background, }; void diff --git a/src/xterm.c b/src/xterm.c index 1684048ea4..541fc0abaf 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -874,12 +874,27 @@ x_set_cr_source_with_gc_background (struct frame *f, GC gc) { XGCValues xgcv; XColor color; + unsigned int depth; XGetGCValues (FRAME_X_DISPLAY (f), gc, GCBackground, &xgcv); color.pixel = xgcv.background; + x_query_colors (f, &color, 1); - cairo_set_source_rgb (FRAME_CR_CONTEXT (f), color.red / 65535.0, - color.green / 65535.0, color.blue / 65535.0); + + depth = FRAME_DISPLAY_INFO (f)->n_planes; + + if (f->alpha_background < 1.0 && depth == 32) + { + cairo_set_source_rgba (FRAME_CR_CONTEXT (f), color.red / 65535.0, + color.green / 65535.0, color.blue / 65535.0, + f->alpha_background); + + cairo_set_operator (FRAME_CR_CONTEXT (f), CAIRO_OPERATOR_SOURCE); + } + else + cairo_set_source_rgb (FRAME_CR_CONTEXT (f), color.red / 65535.0, + color.green / 65535.0, color.blue / 65535.0); + } static const cairo_user_data_key_t xlib_surface_key, saved_drawable_key; @@ -1318,6 +1333,29 @@ x_fill_rectangle (struct frame *f, GC gc, int x, int y, int width, int height) #endif } + +static void +x_clear_rectangle (struct frame *f, GC gc, int x, int y, int width, int height) +{ +#ifdef USE_CAIRO + cairo_t *cr; + + cr = x_begin_cr_clip (f, gc); + x_set_cr_source_with_gc_background (f, gc); + cairo_rectangle (cr, x, y, width, height); + cairo_fill (cr); + x_end_cr_clip (f); +#else + XGCValues xgcv; + Display *dpy = FRAME_X_DISPLAY (f); + XGetGCValues (dpy, gc, GCBackground | GCForeground, &xgcv); + XSetForeground (dpy, gc, xgcv.background); + XFillRectangle (dpy, FRAME_X_DRAWABLE (f), + gc, x, y, width, height); + XSetForeground (dpy, gc, xgcv.foreground); +#endif +} + static void x_draw_rectangle (struct frame *f, GC gc, int x, int y, int width, int height) { @@ -1898,9 +1936,9 @@ x_draw_fringe_bitmap (struct window *w, struct glyph_row *row, struct draw_fring if (face->stipple) XSetFillStyle (display, face->gc, FillOpaqueStippled); else - XSetForeground (display, face->gc, face->background); + XSetBackground (display, face->gc, face->background); - x_fill_rectangle (f, face->gc, p->bx, p->by, p->nx, p->ny); + x_clear_rectangle (f, face->gc, p->bx, p->by, p->nx, p->ny); if (!face->stipple) XSetForeground (display, face->gc, face->foreground); @@ -2201,12 +2239,7 @@ x_compute_glyph_string_overhangs (struct glyph_string *s) static void x_clear_glyph_string_rect (struct glyph_string *s, int x, int y, int w, int h) { - Display *display = FRAME_X_DISPLAY (s->f); - XGCValues xgcv; - XGetGCValues (display, s->gc, GCForeground | GCBackground, &xgcv); - XSetForeground (display, s->gc, xgcv.background); - x_fill_rectangle (s->f, s->gc, x, y, w, h); - XSetForeground (display, s->gc, xgcv.foreground); + x_clear_rectangle (s->f, s->gc, x, y, w, h); } --=-=-=--