Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Mon 22 Dec 2014, 05:18
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Windows with transparent backgrounds
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 1 Posts_count  
Author Message
ProgRob

Joined: 13 Feb 2013
Posts: 14

PostPosted: Mon 03 Mar 2014, 09:53    Post_subject:  Windows with transparent backgrounds  

For a project I am learning Genie. I want to create a window where the background is transparent but the widgets visible in it are opaque.

The problem I am having is that in Puppy Linux I cannot get a transparent background!

Here is my code:

Code:

uses
        Gtk
        Cairo

def on_expose (wid : Widget, event : Gdk.EventExpose) : bool
        // Get a cairo context for our window
        var ctx = Gdk.cairo_create (wid.window)
        // This should make the current color transparent (a = 0)
        ctx.set_source_rgba (1, 1, 1, 0)
        // Paint the entire window transparent to start with.
        ctx.set_operator (Cairo.Operator.SOURCE)
        ctx.paint ()
        // Draw circle
        var pat = new Cairo.Pattern.radial (75, 75, 20, 100,  100, 75)
        pat.add_color_stop_rgba (0, 1, 1, 1, 1)
        pat.add_color_stop_rgba (1, 0, 0, 0, 1)
        ctx.set_source (pat)
        ctx.arc (100, 100, 175, 0, 2 * 3.1416)
        ctx.fill ()
        return true

init
        Gtk.init (ref args)

        var window = new Gtk.Window
        window.title = "Demo window"
        window.set_default_size (200,200)
        window.app_paintable = true
        var cm = window.screen.get_rgba_colormap()
        window.set_colormap(cm)
        window.expose_event.connect(on_expose)
        window.destroy.connect (Gtk.main_quit)
        window.show_all ()
 
        Gtk.main ()


When I run this it shows a black background rather than a transparent one. I am running xcompmgr as well which makes non-active windows transparent so some kind of transparency is possible.

Can anyone guide me as to what I am doing wrong as I am pretty new to all this Cairo/GTK etc.?

Thanks,
Rob
Back to top
View user's profile Send_private_message 
musher0


Joined: 04 Jan 2009
Posts: 4465
Location: Gatineau (Qc), Canada

PostPosted: Mon 03 Mar 2014, 13:49    Post_subject:  

Hello, ProgRob.

I don't know anything about Genie. That said...

Your program may be showing the background, not the ROX backdrop, but the system
background, which is indeed black. Same thing happens in conky if you use the
"transparent", "own window" and "normal" settings. It is little known, but you can have
a "hierarchy" of backgrounds, which are used at different levels of the Linux system.

For example, if you try
Code:
urxvt -bg sienna4 -fg cornsilk -bd firebrick4 -b 4 -tr -tint white -sh 67 -cr white

the "-tr -tint white -sh 67" settings will allow the ROX background to seep through, with
a shade of white. Not so with conky, because conky, when its "own window" is set to
"normal", is looking at the system background, not at the ROX background.

In your case, I believe that you may need to introduce your same background earlier,
in the .initrc code, through a program such as qiv. See attached illustration. For your
transparency to work, my hunch is that the picture called by qiv (line 107) should be the
same as the one used by ROX. Also, please note that the addition needs to go just
below the xsetroot call.

Again, I don't know anything about Genie, but I hope this helps. Keep us posted?

BFN.

musher0
initrc-with-qiv-added.jpg
 Description   
 Filesize   40.8 KB
 Viewed   486 Time(s)

initrc-with-qiv-added.jpg


_________________
"Logical entities must not be multiplied needlessly." / "Il ne faut pas multiplier les êtres logiques inutilement." (Ockham)
Back to top
View user's profile Send_private_message Visit_website 
Ted Dog


Joined: 13 Sep 2005
Posts: 2534
Location: Heart of Texas

PostPosted: Mon 03 Mar 2014, 15:03    Post_subject:  

Thanks for clearing that up I wondered why a wallpaper mode for video playback has sound and no picture. video hidden behind rox background. Can we drop that or make it transparent¿
Back to top
View user's profile Send_private_message 
musher0


Joined: 04 Jan 2009
Posts: 4465
Location: Gatineau (Qc), Canada

PostPosted: Mon 03 Mar 2014, 16:06    Post_subject:  

Ted Dog wrote:
Thanks for clearing that up I wondered why a wallpaper mode for video playback has sound and no picture. video hidden behind rox background. Can we drop that or make it transparent¿


Hi, Ted.

That sounds like a logical explanation, but I can't help you there: I know zero in video stuff.
I wouldn't know which layer the video playback uses.

Stick around though, somebody's bound to answer! Smile

BFN.

musher0

_________________
"Logical entities must not be multiplied needlessly." / "Il ne faut pas multiplier les êtres logiques inutilement." (Ockham)
Back to top
View user's profile Send_private_message Visit_website 
Ted Dog


Joined: 13 Sep 2005
Posts: 2534
Location: Heart of Texas

PostPosted: Mon 03 Mar 2014, 16:35    Post_subject:  

root or base layer. Had it working on v4 series and forgot about that until I tried it a week or so ago when I saw the settings in VLC and hunted it down for mplayer. both did the same...
Back to top
View user's profile Send_private_message 
ProgRob

Joined: 13 Feb 2013
Posts: 14

PostPosted: Thu 06 Mar 2014, 11:37    Post_subject:  

Thanks Musher for the advice. I agree with you that this is not a Genie question. I think this is more about understanding how GTK+ works on Puppy.

So, here is the result of my investigations so far and they are weird. Firstly some corrected code, though, as there was an error in the original.

Code:

def on_expose (wid : Widget, event : Gdk.EventExpose) : bool
        var ctx = Gdk.cairo_create (wid.window)
        ctx.set_source_rgba(0, 0, 1, 0)
        ctx.set_operator (Cairo.Operator.SOURCE)
        ctx.paint ()
        var pat = new Cairo.Pattern.radial (75, 75, 20, 100,  100, 75)
        pat.add_color_stop_rgba (0, 1, 1, 0, 1)
        pat.add_color_stop_rgba (1, 1, 0, 0, 1)
        ctx.set_source (pat)
        ctx.arc (100, 100, 75, 0, 2 * 3.1416)
        ctx.fill ()
        return true

init
        Gtk.init (ref args)

        var window = new Gtk.Window()
        window.title = "Demo window"
        window.set_default_size (200,200)
        window.app_paintable = true
        var cm = window.screen.get_rgba_colormap()
        window.set_colormap(cm)
        window.expose_event.connect(on_expose)
        window.destroy.connect (Gtk.main_quit)
        window.show_all ()
 
        Gtk.main ()


So I have tried the following to see what is going on:

1. I modified the third line in the code above (set_source_rgba) so that the last parameter, the alpha value, was 1. This successfully painted the background a nice blue colour - this shows my code seems to be setting the background to something and that the alpha channel makes a difference.

2. I then set the alpha value on the same line to 0.5. The background became a darker blue - as if the black and blue were being merged. Exactly what you would expect if composition is taking place and the alpha channel was working but the background was black.

3. Next I switched off composition and switched off the Rox filer pinboard. This showed me a black background - exactly what Musher predicted

4. I then switched on xcompmgr and the background turned grey - this is really strange as this means that having composition switched on is affecting the black background beneath the Rox pinboard.

5. I then switched off xcompmgr and modified my .xinitrc file as suggested. Rebooting X gave me the same background as the Rox filer background (except without the icons). Again as expected.

6. I then switched on composition and the background turned grey (not a composited version of the background image but the same grey as in step 4). That I was not expecting.

7. Then I tried running my code - and it continued to give the same black background whether or not the pinboard was showing.

All of the above is very strange. Why does the image set with qiv disappear when composition is turned on? What is the black background being composited with to create the grey? And, why is my code still getting a black background even when I paint the background with an image?

One other oddity is that when I run xcompmgr and I have switched off the pinboard, if I move a window around I cannot see the outline of the window unless I move it over another window. The grey background seems to hide the outline.

Anyone got any further suggestions?

Thanks,
Rob
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0694s ][ Queries: 13 (0.0041s) ][ GZIP on ]