Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Other Community Discussions > Development & Programming > Programming Talk
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Programming Talk
This forum is for all programming questions.
The questions do not have to be directly related to Ubuntu and any programming language is allowed.

 
Thread Tools Display Modes
Old September 17th, 2007   #1
BuffaloX
Ubuntu Extra Shot
 
BuffaloX's Avatar
 
Join Date: May 2006
Location: Denmark
Beans: 396
How do I make shaped windows?

I've been searching several hours now (again),

But I haven't been able to find documentation for making shaped / non rectangular / free-form windows in Linux.

I'm looking for a solution for either of these languages.
C / C++
Python
Lazarus

Solution must be compatible with Gnome, and preferably also with Compiz fusion.

Any help would be much appreciated.
BuffaloX is offline   Reply With Quote
Old September 17th, 2007   #2
Wybiral
Tall Cafè Ubuntu
 
Wybiral's Avatar
 
Join Date: Oct 2006
Beans: 2,678
Ubuntu 7.10 Gutsy Gibbon
Re: How do I make shaped windows?

I remember theres a way to initialize a GTK window without a frame... Maybe using that with a transparent image or something. I haven't really seen it done in Gnome though (that I can think of).

EDIT:

I remember the command now: http://www.pygtk.org/docs/pygtk/clas...-set-decorated
__________________

Last edited by Wybiral; September 17th, 2007 at 02:01 PM..
Wybiral is offline   Reply With Quote
Old September 17th, 2007   #3
aks44
100% Pure Ubuntu
 
aks44's Avatar
 
Join Date: May 2007
Location: Paris, France
Beans: 927
Kubuntu 7.04 Feisty Fawn
Re: How do I make shaped windows?

What toolkit are you using?

With Qt, look at QWidget::setMask. (search term: "non rectangular" window qt)

With GTK, look at gtk_widget_shape_combine_mask. (search term: "non rectangular" window gtk)

Anyway, the results I found seem to detail the whole process quite correctly.
__________________
Not even tinfoil can save us now...
aks44 is offline   Reply With Quote
Old September 17th, 2007   #4
BuffaloX
Ubuntu Extra Shot
 
BuffaloX's Avatar
 
Join Date: May 2006
Location: Denmark
Beans: 396
Re: How do I make shaped windows?

Thanks for nice and quick responses.

I haven't decided on a toolkit or library yet, partly because I want this specific functionality, and hoped for some examples that could help me turbo charge into some Linux GUI programming.

I want compatibility with Gnome because that's what I use, and also compatibility with Compiz Fusion because I plan to use it, when functionality gets on par with Beryl. (It isn't yet IMO).

I think the alpha method for Python doesn't work so well, sometimes transparent areas show the wrong background, or the background with wrong opacity when placed on a semi transparent cube with Compiz.

The gtk_widget_shape_combine_mask sounds like what I want, but a google search has turned up only questions, and no examples....

Thanx for helping me on a clearly better track than where I came from.
BuffaloX is offline   Reply With Quote
Old September 17th, 2007   #5
moma
Quad Shot of Ubuntu
 
moma's Avatar
 
Join Date: Jan 2006
Location: Grønland,Oslo
Beans: 484
Re: How do I make shaped windows?

I have some shaped window (XLib XShape* + Cairo graphics on them) examples in C/C++. I just need to find them. It's late evening here so you'll get the sample(s) tomorrow.
__________________
// moma
http://www.futuredesktop.org

Last edited by moma; September 17th, 2007 at 03:22 PM..
moma is offline   Reply With Quote
Old September 17th, 2007   #6
BuffaloX
Ubuntu Extra Shot
 
BuffaloX's Avatar
 
Join Date: May 2006
Location: Denmark
Beans: 396
Re: How do I make shaped windows?

Quote:
Originally Posted by moma View Post
I have some shaped window (XLib XShape* + Cairo graphics on them) examples in C/C++. I just need to find them. It's late evening here so you'll get the sample(s) tomorrow.
WOW cool.

This Cairo thing sounds quite exciting...
Do I understand correctly, that it works directly on the X frame buffer and should work with all X11 compatible window managers?
If that is so, it is exactly what I want, but didn't think was possible.

I'm off to read about this Cairo thingy...
BuffaloX is offline   Reply With Quote
Old September 17th, 2007   #7
aks44
100% Pure Ubuntu
 
aks44's Avatar
 
Join Date: May 2007
Location: Paris, France
Beans: 927
Kubuntu 7.04 Feisty Fawn
Re: How do I make shaped windows?

Quote:
Originally Posted by BuffaloX View Post
The gtk_widget_shape_combine_mask sounds like what I want, but a google search has turned up only questions, and no examples....
http://www.advogato.org/proj/glock/ (search result)
http://www.brouhaha.com/~eric/software/glock/ (homepage)

Quote:
Glock is a simple analog clock program. It is written in C and uses the GTK+ toolkit, and optionally the Cairo graphics library.

The original purpose of glock was to have a simple demo of an undecorated non-rectangular window using gtk_widget_shape_combine_mask(), moveable with the mouse using gtk_window_begin_move_drag().
(first result for search term: "non rectangular" window gtk on clusty, looks like you better ditch google )
__________________
Not even tinfoil can save us now...

Last edited by aks44; September 17th, 2007 at 03:45 PM..
aks44 is offline   Reply With Quote
Old September 17th, 2007   #8
BuffaloX
Ubuntu Extra Shot
 
BuffaloX's Avatar
 
Join Date: May 2006
Location: Denmark
Beans: 396
Re: How do I make shaped windows?

Quote:
Originally Posted by aks44 View Post
http://www.advogato.org/proj/glock/ (search result)
http://www.brouhaha.com/~eric/software/glock/ (homepage)

(first result for search term: "non rectangular" window gtk on clusty, looks like you better ditch google )
glock is perfect, works perfectly with both gnome/metacity and gnome/compiz.
Seems like it uses Cairo, which is vector based. Which is even better for adjusting size.

It's quite late now here, so I'll have to wait till tomorrow to look at it again.
Can't wait till I get home tomorrow.

Oh btw, yes I probably should ditch google, I'll check out clusty for my next searches.
BuffaloX is offline   Reply With Quote
Old September 17th, 2007   #9
aks44
100% Pure Ubuntu
 
aks44's Avatar
 
Join Date: May 2007
Location: Paris, France
Beans: 927
Kubuntu 7.04 Feisty Fawn
Re: How do I make shaped windows?

Quote:
Originally Posted by BuffaloX View Post
glock is perfect [...] Can't wait till I get home tomorrow.
Glad I could help on a subject I don't know anything about.


Quote:
Originally Posted by BuffaloX View Post
Oh btw, yes I probably should ditch google, I'll check out clusty for my next searches.
FWIW, for me clusty gives way better results (the relevance is not even comparable) than google for most stuff (I'd say 90/95+ % of the searches). And whenever clusty doesn't yield any relevant result, it's quite rare that google does (although it happened). The only bad side of clusty is that it really doesn't deal well with *non-english* searches IMHO.
__________________
Not even tinfoil can save us now...

Last edited by aks44; September 17th, 2007 at 05:09 PM..
aks44 is offline   Reply With Quote
Old September 18th, 2007   #10
moma
Quad Shot of Ubuntu
 
moma's Avatar
 
Join Date: Jan 2006
Location: Grønland,Oslo
Beans: 484
Re: How do I make shaped windows?

Here is the sample 1.

// shape1.cpp
// This simple example shows how to create a shaped, borderless window.
// It uses only XLib and XShape* extension calls.

The shape of the window comes from "myshape.xbm" image.
myshape.xbm is readable. It also defines
#define myshape_width 200
#define myshape_height 200

The code has a draw() function which tries to draw a red, filled rectangle on the face, but only pixels that hits the mask (myshape.xbm) are visible.

Attached: shape1.tar

You will need the "libxext-dev" package to compile and run it.

Compile:
$ g++ -lX11 -lXext shape1.cpp -o shape1

Run:
$ ./shape1
---------

more to come.
Attached Files
File Type: tar shape1.tar (70.0 KB, 95 views)
__________________
// moma
http://www.futuredesktop.org

Last edited by moma; September 18th, 2007 at 08:19 AM..
moma is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:34 AM.


vBulletin ©2000 - 2010, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. bilberry