juliusHuelsmann / st

Repatch repository of developed 'Vim Browse' and 'Alpha Focus Highlight' patches for simple terminal (st).
https://st.suckless.org/patches/alpha_focus_highlight/
MIT License
28 stars 11 forks source link

windows have no transparency when spawned. #35

Open Apep-the-snek opened 11 months ago

Apep-the-snek commented 11 months ago

they only gain transparency when the focus is moved away from them, i used unmodified st other than scrollback support added, and no compilation errors when building. this is from the latest version found on the suckless.org website on st 0.9. image image

sorry if there is something obvious i'm missing.

juliusHuelsmann commented 11 months ago

hey :) If the focus patch is applied (which is the case in this repository), the transparency values are configured via the following two variables (which you can find in the config.h):

/* bg opacity */
float alpha = 0.8, alphaUnfocused = 0.6;

By default the transparency for the unfocused window is higher than the one for the focused window, but you can change that by finding a lower value for float alpha.

If I temporarily change my configuration to the following:

float alpha = 0.1, alphaUnfocused = 1.0;

and rebuild, I receive a terminal with high transparency if focused, and no transparency otherwise.

The process for changing the values is as follows:

  1. change config.h (not config.def.h, that is just used for generating a new config.h from scratch
  2. make
  3. ./st
Apep-the-snek commented 11 months ago

Well that is not my issue. my issue is that whenever i spawn a st terminal with this patch, it will have no transparency at all on that window until i change the focus. the right transparency will be applied if i for example switch focus. picture 0 shows two ST terminals, the rightmost being just spawned and therefore has no transparency at all (the bug that i'm facing), picture 1 shows the same two windows, only i switched the focus twice and therefore it works as intended. I just tested this on stock ST (which i should have done from the beginning) and the same problem occurs there.

i only edit config.def.h because i add patches sometimes, and yes i always remember to remove config.h

juliusHuelsmann commented 11 months ago

ok weird, I am currently using an older version of the terminal, but ran the patch on v 0.9 of st:

Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Tue Oct 4 19:40:30 2022 +0200

    bump version to 0.9

with this patch, which should be the same one you're using: Build process:

image

New terminal without switching focus: image

So that seems to work for me.

Tests you can perform to track down the problem

1. Add debug info

I inserted two lines (the ones with the unusual indentation) into the xloadalpha function to debug this temporarily (without the leading '+', I just copied from the diff):

+xloadalpha(void)
+{
+       xloadcolor(focused ?bg :bgUnfocused, NULL, &dc.col[defaultbg]);
+       float const usedAlpha = focused ? alpha : alphaUnfocused;
+  fprintf(stdout, "x load alpha: %f\n", usedAlpha);
+  fflush(stdout);
+       if (opt_alpha) alpha = strtof(opt_alpha, NULL);
+       dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * usedAlpha);
+       dc.col[defaultbg].pixel &= 0x00FFFFFF;
+       dc.col[defaultbg].pixel |= (unsigned char)(0xff * usedAlpha) << 24;
+}

try doing the same and post the output here. My output on start is the following:

x load alpha: 0.600000
x load alpha: 0.500000

(apparently it spawns unfocus and then gains focus; current settings for the test is focus 0.5, no focus 0.6) and when I switch focus from the terminal a new line appears, which reflects what I am seeing on my system.

2. Compare with behavior of the alpha patch

If you're investigating this issue on your machine if you are facing the same problem with the OG alpha patch (the one that does not react to focus changes).

3. Diff to 68d1ad9b54e952e3079356aeab8ab37e44c56c2c

Attach the diff of your code after applying only st-focus to the commit 68d1ad9b54e952e3079356aeab8ab37e44c56c2c of st, so I can compare that to the diff I receive after patching.

Which compositor & WM are you using?

I am not sure if I can help you with the problem as I cannot replicate this; if you find a solution contributions are welcome!

Apep-the-snek commented 11 months ago

1: image by default, the function does not look exactly as you showed image here's how i changed it image 3rd image is after patching the debugging st focus diff patch in a stock st

retrying but with the added top line: image this time it did patch as expected image when i run st i get these errors, i'm a bit of a newb so i don't know how to fix them, i did look up the errors and found: https://www.reddit.com/r/suckless/comments/msy0sp/question_erresc_on_st/ but i don't know if that was even helpful (maybe i'm missing something?). and yes, my issue still stands, only that i found if i spawn specifically 4 shells in a row, quite quickly but not too quickly, the last spawned window will be transparent as it should be (weird, lol).

note: i always use make clean install as when i did make, it did not overwrite my existing st patch (i'm using all stock to be as scientific and thorough as possible) and also because i'm a newb when it comes to make so i just use what has worked in the past lol, and make clean install never has any problems with me.

2: I patched the alpha patch. compiling went smoothly. meanwhile i found that both nano (ik ik, i should learn vim or emacs at this point lol) and links (browser) on the st terminals using my main config that i haven't closed yet, have this bronze looking transparency for some reason, idk, just thought i'd share it. might have something to do with pywal: image first compiling with the alpha patch had no transparency, does not change with focus or anything, let's see if there is something in the config file for transparency: image nope, it is at 0.8, which means that windows by default does not spawn with transparency. also spawning 4 windows in quick succession like i did did not give the last window transparency.

3: i don't know what that means, sorry i'm using xcompmgr, i can change that, i might test that after sending this, as i don't want to lose all of what i have written here (including the images, maybe the links persist, not gonna gamble on that). and i'm using DWM with no major modifications, only fullgaps patch. some other potentially useful stuff (probably not), i use artix openrc (changed it from dinit with a script after install) and here is the fastfetch: image it is in the same window that i had nano open in and it still has that bronze tint, whatever lol.

(don't worry about the ram, it's just my browser lol, i have too many tabs open)

EDIT: i did killall xcompmgr, i thought it would have killed the xinit thing as it usually does whenever i kill anything in .xinitrc, so i just ran picom and the same issue applies there. please say if you want me to test any other compositor.