unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Help writing a patch to allow transparent backgrounds?
@ 2016-02-09 15:22 Clément Pit--Claudel
  2016-02-10 18:35 ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Clément Pit--Claudel @ 2016-02-09 15:22 UTC (permalink / raw)
  To: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 2023 bytes --]

Hi all,

The only way to get transparency at the moment seems to be with the 'alpha frame parameter. Unfortunately this makes the whole frame transparent, instead of just the background. I'd like to make Emacs only draw text to the screen, without painting a background. I'm on Linux with Gtk3.

I expect that this would require changing the way the background is painted, and changing the way faces are drawn to not add a solid background.

There are examples online:
  * Two StackOverflow questions:
    * https://stackoverflow.com/questions/16832581/how-to-make-a-gtkwindow-background-transparent-on-linux
    * https://stackoverflow.com/questions/22940588/how-do-i-really-make-a-gtk-3-gtklayout-transparent-draw-theme-background
  * A patch to implement this feature in Nemo:
    * https://lists.fedoraproject.org/pipermail/scm-commits/Week-of-Mon-20131230/1165217.html
  * Another patch:
    * https://github.com/IgnorantGuru/spacefm/commit/5e4e148a2e1cf962fdf7dbc776d8d09ad110dbd7
    * https://github.com/IgnorantGuru/spacefm/issues/269

It's not clear to me how to apply the ideas from these pages. I tried two sets of modifications:

* In gtkutil.c (xg_set_widget_bg (struct frame *f, GtkWidget *w, unsigned long pixel)), changing
    bg.alpha = 1.0;
  to
    bg.alpha = 0.0;
* In xterm.c (x_set_cr_source_with_gc_background (struct frame *f, GC gc)), changing
    cairo_set_source_rgb (FRAME_CR_CONTEXT (f), color.red / 65535.0,
                          color.green / 65535.0, color.blue / 65535.0);
  to
    cairo_set_source_rgba (FRAME_CR_CONTEXT (f), color.red / 65535.0,
                           color.green / 65535.0, color.blue / 65535.0, 0.0);
  and compiling with --with-cairo

Both of these changes had the same effect: the background isn't redrawn anymore. The contents of the desktop (behind the Emacs frame) are captured when the frame is created, but never updated after that; instead, whatever gets painted there remains there.

Thanks for the help!
Clément.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: Help writing a patch to allow transparent backgrounds?
  2016-02-09 15:22 Help writing a patch to allow transparent backgrounds? Clément Pit--Claudel
@ 2016-02-10 18:35 ` Eli Zaretskii
  2016-02-10 18:46   ` Clément Pit--Claudel
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2016-02-10 18:35 UTC (permalink / raw)
  To: Clément Pit--Claudel; +Cc: emacs-devel

> From: Clément Pit--Claudel <clement.pit@gmail.com>
> Date: Tue, 9 Feb 2016 10:22:38 -0500
> 
> The only way to get transparency at the moment seems to be with the 'alpha frame parameter. Unfortunately this makes the whole frame transparent, instead of just the background. I'd like to make Emacs only draw text to the screen, without painting a background. I'm on Linux with Gtk3.
> 
> I expect that this would require changing the way the background is painted, and changing the way faces are drawn to not add a solid background.

I can try helping you with doing that in a non-Cairo build.  I'm not
familiar enough with the way Cairo drawing works (and I'm not sure we
have here anyone who does).

Let me know if doing that in a build without Cairo is useful enough
for you to work on that.

Thanks.



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

* Re: Help writing a patch to allow transparent backgrounds?
  2016-02-10 18:35 ` Eli Zaretskii
@ 2016-02-10 18:46   ` Clément Pit--Claudel
  2016-02-10 19:23     ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Clément Pit--Claudel @ 2016-02-10 18:46 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1097 bytes --]

On 02/10/2016 01:35 PM, Eli Zaretskii wrote:
>> From: Clément Pit--Claudel <clement.pit@gmail.com>
>> Date: Tue, 9 Feb 2016 10:22:38 -0500
>>
>> The only way to get transparency at the moment seems to be with the 'alpha frame parameter. Unfortunately this makes the whole frame transparent, instead of just the background. I'd like to make Emacs only draw text to the screen, without painting a background. I'm on Linux with Gtk3.
>>
>> I expect that this would require changing the way the background is painted, and changing the way faces are drawn to not add a solid background.
> 
> I can try helping you with doing that in a non-Cairo build.  I'm not
> familiar enough with the way Cairo drawing works (and I'm not sure we
> have here anyone who does).

Thanks!
 
> Let me know if doing that in a build without Cairo is useful enough
> for you to work on that.

Yes, I think so :) Am I correct in thinking that the default build does not use Cairo? That is, the final result would work with the default build on Linux, but not with ./configure --with-cairo?

Clément.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: Help writing a patch to allow transparent backgrounds?
  2016-02-10 18:46   ` Clément Pit--Claudel
@ 2016-02-10 19:23     ` Eli Zaretskii
  2016-02-10 19:36       ` Clément Pit--Claudel
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2016-02-10 19:23 UTC (permalink / raw)
  To: Clément Pit--Claudel; +Cc: emacs-devel

> Cc: emacs-devel@gnu.org
> From: Clément Pit--Claudel <clement.pit@gmail.com>
> Date: Wed, 10 Feb 2016 13:46:08 -0500
> 
> > Let me know if doing that in a build without Cairo is useful enough
> > for you to work on that.
> 
> Yes, I think so :) Am I correct in thinking that the default build does not use Cairo? That is, the final result would work with the default build on Linux, but not with ./configure --with-cairo?

Yes, that's correct.  Cairo is opt-in at this stage.



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

* Re: Help writing a patch to allow transparent backgrounds?
  2016-02-10 19:23     ` Eli Zaretskii
@ 2016-02-10 19:36       ` Clément Pit--Claudel
  2016-02-13 13:51         ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Clément Pit--Claudel @ 2016-02-10 19:36 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 678 bytes --]

On 02/10/2016 02:23 PM, Eli Zaretskii wrote:
>> Cc: emacs-devel@gnu.org From: Clément Pit--Claudel
>> <clement.pit@gmail.com> Date: Wed, 10 Feb 2016 13:46:08 -0500
>> 
>>> Let me know if doing that in a build without Cairo is useful
>>> enough for you to work on that.
>> 
>> Yes, I think so :) Am I correct in thinking that the default build
>> does not use Cairo? That is, the final result would work with the
>> default build on Linux, but not with ./configure --with-cairo?
> 
> Yes, that's correct.  Cairo is opt-in at this stage.

Thanks! I'll be happy to try to implement this feature, with some help to navigate my way around the C source.

Clément.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: Help writing a patch to allow transparent backgrounds?
  2016-02-10 19:36       ` Clément Pit--Claudel
@ 2016-02-13 13:51         ` Eli Zaretskii
  0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2016-02-13 13:51 UTC (permalink / raw)
  To: Clément Pit--Claudel; +Cc: emacs-devel

> Cc: emacs-devel@gnu.org
> From: Clément Pit--Claudel <clement.pit@gmail.com>
> Date: Wed, 10 Feb 2016 14:36:28 -0500
> 
> Thanks! I'll be happy to try to implement this feature, with some help to navigate my way around the C source.

Look at xterm.c:x_draw_glyph_string_background.  This is the function
that draws the background of text before that text is drawn in the
foreground color.  The other function to look at is
x_draw_glyph_string_bg_rect in the same file -- this one is used to
draw the background of display elements that are not text: images and
stretches of white space.

A word about "glyph strings": these are structures built by the Emacs
display engine in preparation for actually redrawing portions of the
display which need that.  Each glyph string is the longest possible
collection of glyphs that are to be drawn in the same face, so the
terminal-specific back-end (such as xterm.c) could set up the
necessary settings once, and then draw all of the glyphs of the glyph
string in one go.  For displaying text, the glyph string includes a
run of characters in the same face (font, colors, etc.) specified by
their glyph indices in the font.

HTH



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

end of thread, other threads:[~2016-02-13 13:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-09 15:22 Help writing a patch to allow transparent backgrounds? Clément Pit--Claudel
2016-02-10 18:35 ` Eli Zaretskii
2016-02-10 18:46   ` Clément Pit--Claudel
2016-02-10 19:23     ` Eli Zaretskii
2016-02-10 19:36       ` Clément Pit--Claudel
2016-02-13 13:51         ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

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

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