Recent

Author Topic: 2020 year and transparent form in linux (gtk2/qt/something else). Is posible ?  (Read 5878 times)

Anton Shevtsov

  • New Member
  • *
  • Posts: 15
I've seen many similar topics over the years, but maybe there is a solution now? I want to create a transparent form, is it possible?

p.s.
linux, fpc 3.3.1, lazarus 2.0.2

MarkMLl

  • Hero Member
  • *****
  • Posts: 8572
It's 2020, and like most foramina there's a search box. Have you read through the results and is there anything useful in there?

I'm not trying to be rude, but it's an ongoing topic of discussion.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

balazsszekely

  • Guest
This works fine on my Linux Mint 19.2 Cinnamon(64 bit) machine:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   Form1.AlphaBlend := True;
  4.   Form1.AlphaBlendValue := 155; //0..255
  5. end;

PS: Lazarus 2.1.0, FPC: 3.3.1, Gtk2

Handoko

  • Hero Member
  • *****
  • Posts: 5546
  • My goal: build my own game engine using Lazarus
@Anton Shevtsov

If you're looking for non-rectangular form and you're a Windows user, try this:
https://forum.lazarus.freepascal.org/index.php/topic,26639.msg164057.html#msg164057

@GetMem

Your suggestion does not work on Ubuntu Mate, which uses a fork of GNOME 2 desktop environment. Linux Mint Cinnamon uses GNOME 3 desktop environment.

I found an interesting C code to make transparent form. Can anyone convert it to work in Lazarus?
https://gist.github.com/mertyildiran/7708a3764ebd16ee2a5d4f3801207bfd

tetrastes

  • Hero Member
  • *****
  • Posts: 766

@GetMem

Your suggestion does not work on Ubuntu Mate, which uses a fork of GNOME 2 desktop environment. Linux Mint Cinnamon uses GNOME 3 desktop environment.


Strange, it works on Debian 10 Xfce 4.12, which is still based on GTK-2. May be Lazarus trunc is the matter? (I also have Lazarus 2.1.0, as GetMem.)

lucamar

  • Hero Member
  • *****
  • Posts: 4217
Strange, it works on Debian 10 Xfce 4.12, which is still based on GTK-2. May be Lazarus trunc is the matter? (I also have Lazarus 2.1.0, as GetMem.)

It works also in Xubuntu 18.04 (Xfce 4.12) with Laz/fpc 2.0.10/3.2.0 ...
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Fred vS

  • Hero Member
  • *****
  • Posts: 3946
    • StrumPract is the musicians best friend
I've seen many similar topics over the years, but maybe there is a solution now? I want to create a transparent form, is it possible?

p.s.
linux, fpc 3.3.1, lazarus 2.0.2

It is perfectly possible using the MSEgui widgetset.
On Linux and FreeBSD (and Windows, of course).
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

dbannon

  • Hero Member
  • *****
  • Posts: 3826
    • tomboy-ng, a rewrite of the classic Tomboy
....
Your suggestion does not work on Ubuntu Mate, which uses a fork of GNOME 2 desktop environment.

Yep, I can confirm that GetMem's suggestion does not work on Ubuntu Mate U18.04. Strange ...

I am not sure its a GTK2/GTK3 thing, compiling for GTK3 fails at transparent too. (Obviously, while Mate is based on GTK2, it has the GTK3 libraries installed too.)

EDIT: interestingly enough, the C based demo Handoko found does not display any transparency on U18.04 Mate either.

Davo
« Last Edit: November 08, 2020, 07:08:47 am by dbannon »
Lazarus 4, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Fred vS

  • Hero Member
  • *****
  • Posts: 3946
    • StrumPract is the musicians best friend
I've seen many similar topics over the years, but maybe there is a solution now? I want to create a transparent form, is it possible?

p.s.
linux, fpc 3.3.1, lazarus 2.0.2

It is perfectly possible using the MSEgui widgetset.
On Linux and FreeBSD (and Windows, of course).

Here the binary of the example for Linux 64 bit, maybe you may test it to see if it works on your system.
MSEgui deals directly with X11.

https://github.com/fredvs/attach/files/5506224/transparentform.zip
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

AmatCoder

  • Jr. Member
  • **
  • Posts: 79
    • My site
Note that transparents windows from GTK has effect only on X11 screens with a compositing manager running.

If it does not work with MATE must be because you are running Marco (the MATE Window Manager) without compositing effects.

Handoko

  • Hero Member
  • *****
  • Posts: 5546
  • My goal: build my own game engine using Lazarus
Thanks Fred vS for providing the binary. I tested it, unfortunately still got no transparency.

So far, it is not GTK2 vs GTK3 issue, not Linux issue but only happens on Ubuntu Mate. Maybe what AmatCoder said is true. I checked my Ubuntu Mate 20.04, it's really using Marco as its window manager.

Is anyone here also a member of Ubuntu Mate forum's user? Hope someone can submit a bug report there.
« Last Edit: November 08, 2020, 05:09:08 pm by Handoko »

Fred vS

  • Hero Member
  • *****
  • Posts: 3946
    • StrumPract is the musicians best friend
Thanks Fred vS for providing the binary. I tested it, unfortunately still got no transparency.

Ha, then, imho, the verdict is like AmatCoder suspected: you dont have a Compositor installed.

You may install Compton, it is a very good Compositor:

Code: Bash  [Select][+][-]
  1. § sudo apt install compton compton-conf

There are few things to tune after this, take a look at explanation here:
https://www.addictivetips.com/ubuntu-linux-tips/window-compositing-lightweight-linux-desktops-compton/

And take a look at "Enabling Compton On MATE" chapter.

Fre;D
« Last Edit: November 08, 2020, 06:59:29 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

dbannon

  • Hero Member
  • *****
  • Posts: 3826
    • tomboy-ng, a rewrite of the classic Tomboy
Yep, that appears to be the case. By default (my) U18.04 Mate uses, as Windows Manager, Marco (Adaptive compositor).  Changing that to either Marco (Compton GPU compositor) or Compiz (Advanced GPU accelerated desktop effects) does show transparency for Lazarus Apps that have the appropriate AlphaBlend settings.

Interesting, that C code example Handoko found still does not work, good thing we use Lazarus :-)

On (my) U18.04, you do not need to install or configure anything, just fire up Mate Tweek (from Control Center), click Windows and select one. I may use Marco with Crompton for a bit, Compiz is just a bit too busy for me.

Interesting discussion.

Davo

Lazarus 4, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Handoko

  • Hero Member
  • *****
  • Posts: 5546
  • My goal: build my own game engine using Lazarus
Thank you for informing what you found.

I cannot test Compiz because my graphics card has problem and I do not wish to install Compton just because of the transparency problem.

dbannon

  • Hero Member
  • *****
  • Posts: 3826
    • tomboy-ng, a rewrite of the classic Tomboy
I cannot test Compiz because my graphics card has problem and I do not wish to install Compton just because of the transparency problem.

I suspect (but may be very wrong) that you don't need to install, Compton, its already there, you just need to select it in Mate Tweek. I have not installed any special graphics card drivers (I never do) but the mention of "GPU" in the two fancy compositors did worry me a bit.  I would expect you would not be offered the option in Mate Tweek if your hardware does not support it. 

Also worth noting that those fancy tricks compositors do come at a CPU cost. And its generally just eye candy.

Davo
Lazarus 4, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

 

TinyPortal © 2005-2018