Julien Danjou | 2 Jun 11:01 2009

Re: Writing a layout - where does the p parameter come from?

Hi Nathan,

At 1243891357 time_t, Nathan Huesken wrote:
> So I am looking at the tile layout as reference.
> It seems, that its parameters are stored in the current tag ...
> 
> No I wonder, what would I have to do to get my parameters in.
> And I also wonder how I could remember which client belongs to which
> tile. Can I store information in clients as well?

As you can see all information are passed to layouts via on_arrange()
function in awful/layout/init.lua.

Clients and tags have properties internal to awesome core, but since
some people or libs wants to store information, we usually use a
property thingie inside awful.tag and awful.client.

You have a set of awful.tag.setproperty() or something like that, which
can be used to store more properties. This properties are automatically
collected upon objects destructution so you do not have to worry about
this.

Just store what you need and retrieve it when needed.

Cheers,
--

-- 
Julien Danjou
// ᐰ <julien <at> danjou.info>   http://julien.danjou.info
// 9A0D 5FD9 EB42 22F6 8974  C95C A462 B51E C2FE E5CD
// Trust me.
(Continue reading)

Nathan Huesken | 2 Jun 22:48 2009

Re: Writing a layout - where does the p parameter come from?

Hello,

Thanks for you answer Julien, now I feel like I am almost there.
2 Questions:

- What is the difference between workarea and geometry?

- OK, I can set simple properties of a tag and a client using
"setproperty". But I need something more complex. I need to store a tree
structure telling me how the area has been divided.
So I need a "root-node" object, stored in the tag. And this root node
has 2 of the same kind (until a leave node is reached).
Can this also be archived with setproperty? I do not see how but I am
completly new to lua!

Thanks!
Nathan

On Tue, Jun 02, 2009 at 11:01:48AM +0200, Julien Danjou wrote:
> Hi Nathan,
> 
> At 1243891357 time_t, Nathan Huesken wrote:
> > So I am looking at the tile layout as reference.
> > It seems, that its parameters are stored in the current tag ...
> > 
> > No I wonder, what would I have to do to get my parameters in.
> > And I also wonder how I could remember which client belongs to which
> > tile. Can I store information in clients as well?
> 
> As you can see all information are passed to layouts via on_arrange()
(Continue reading)

Gregor Best | 2 Jun 23:01 2009

Re: Writing a layout - where does the p parameter come from?

On Tue, Jun 02, 2009 at 10:48:13PM +0200, Nathan Huesken wrote:
> [...]
> - OK, I can set simple properties of a tag and a client using
> "setproperty". But I need something more complex. I need to store a tree
> structure telling me how the area has been divided.
> So I need a "root-node" object, stored in the tag. And this root node
> has 2 of the same kind (until a leave node is reached).
> Can this also be archived with setproperty? I do not see how but I am
> completly new to lua!
> 
> [...]

You can easily store tables inside the tag properties. With some
handling functions, tables can be modelled like trees (bintree, octree,
k-tree, whatever you want), which should be what you want. You'd do
something like this:

    local tree   = { }
    tree.left    = { }
    tree.right   = { }
    tree.content = foobar
    tree.left.left    = { }
    tree.left.right   = { }
    tree.left.content = gna
    awful.tag.setproperty(t, "divisions", tree)

--

-- 
GCS/IT/M d- s+:- a--- C++ UL+++ US UB++ P+++ L+++ E--- W+ N+ o--
K- w--- O M-- V PS+ PE- Y+ PGP+++ t+ 5 X+ R tv+ b++ DI+++ D+++ G+
e- h! r y+
(Continue reading)

Nathan Huesken | 3 Jun 13:40 2009

Re: Writing a layout - where does the p parameter come from?

Hi,

Unfortantly I have little success with this.
So I have this function in tag.lua:

--- Return the division tree of the tag
function getdivisiontree(t)
   local t = t or selected()
   local tree
   tree = getproperty(t, "division_tree") or {}
   if #tree==0 then
	  tree={}
	  tree.division="none"
	  tree.ratio=0.5
	  setproperty(t, "division_tree", tree)
   end
   return tree
end

See Idea is, that when no decision tree exists yet, one is created.
But I get an error:
tag.lua:304: table index is nil

On Tue, Jun 02, 2009 at 11:01:23PM +0200, Gregor Best wrote:
> On Tue, Jun 02, 2009 at 10:48:13PM +0200, Nathan Huesken wrote:
> > [...]
> > - OK, I can set simple properties of a tag and a client using
> > "setproperty". But I need something more complex. I need to store a tree
> > structure telling me how the area has been divided.
> > So I need a "root-node" object, stored in the tag. And this root node
(Continue reading)

Julien Danjou | 3 Jun 13:50 2009

Re: Writing a layout - where does the p parameter come from?

At 1244029212 time_t, Nathan Huesken wrote:
> tag.lua:304: table index is nil

What's line 304 ?

--

-- 
Julien Danjou
// ᐰ <julien <at> danjou.info>   http://julien.danjou.info
// 9A0D 5FD9 EB42 22F6 8974  C95C A462 B51E C2FE E5CD
// Tomorrow I was nothing, yesterday I'll be.
Nathan Huesken | 3 Jun 13:59 2009

Re: Writing a layout - where does the p parameter come from?

from tag.lua

function setproperty(tag, prop, value)
         if not data.tags[tag] then
            data.tags[tag] = {}   <-- this is line 304
         end
         data.tags[tag][prop] = value
end

The getdivisiontree is called from on_arrange.
Could it be, that it is called at a time there are not tags jet, so that
the "t" parameter is nil and selected also returns nil?

Does that make sense?
Thanks!
Nathan

On Wed, Jun 03, 2009 at 01:50:10PM +0200, Julien Danjou wrote:
> At 1244029212 time_t, Nathan Huesken wrote:
> > tag.lua:304: table index is nil
> 
> What's line 304 ?
> 
> -- 
> Julien Danjou
> // ᐰ <julien <at> danjou.info>   http://julien.danjou.info
> // 9A0D 5FD9 EB42 22F6 8974  C95C A462 B51E C2FE E5CD
> // Tomorrow I was nothing, yesterday I'll be.

--

-- 
(Continue reading)

Julien Danjou | 3 Jun 14:05 2009

Re: Writing a layout - where does the p parameter come from?

At 1244030374 time_t, Nathan Huesken wrote:
> Does that make sense?

It does. Adding a couple of print() might help. ;-)

--

-- 
Julien Danjou
// ᐰ <julien <at> danjou.info>   http://julien.danjou.info
// 9A0D 5FD9 EB42 22F6 8974  C95C A462 B51E C2FE E5CD
// When I get sad, I stop being sad and be awesome instead. True story.
Nathan Huesken | 3 Jun 14:09 2009

Re: Writing a layout - where does the p parameter come from?

OK, I solved the problem by stoping the function when the tag is nil and
the selected also returns nil.

Byt why is on_arrange called when there are no tags yet? It does not
make sense to me!

On Wed, Jun 03, 2009 at 02:05:21PM +0200, Julien Danjou wrote:
> At 1244030374 time_t, Nathan Huesken wrote:
> > Does that make sense?
> 
> It does. Adding a couple of print() might help. ;-)
> 
> -- 
> Julien Danjou
> // ᐰ <julien <at> danjou.info>   http://julien.danjou.info
> // 9A0D 5FD9 EB42 22F6 8974  C95C A462 B51E C2FE E5CD
> // When I get sad, I stop being sad and be awesome instead. True story.

--

-- 
To unsubscribe, send mail to awesome-devel-unsubscribe <at> naquadah.org.

Julien Danjou | 3 Jun 14:14 2009

Re: Writing a layout - where does the p parameter come from?

At 1244030991 time_t, Nathan Huesken wrote:
> OK, I solved the problem by stoping the function when the tag is nil and
> the selected also returns nil.
> 
> Byt why is on_arrange called when there are no tags yet? It does not
> make sense to me!

Because on every tag selection change it is called. Even if no tag is
selected. That might sound useless, and it is probably right now, but
you never know. ;-)

--

-- 
Julien Danjou
// ᐰ <julien <at> danjou.info>   http://julien.danjou.info
// 9A0D 5FD9 EB42 22F6 8974  C95C A462 B51E C2FE E5CD
// Ferns will rule the world.
Julien Danjou | 3 Jun 09:42 2009

Re: Writing a layout - where does the p parameter come from?

At 1243975693 time_t, Nathan Huesken wrote:
> - What is the difference between workarea and geometry?

Geometry is the screen geometry, i.e., the number of pixels available
from left to right.
Workarea is the same thing, but minus the wibox and the client that have
struts (i.e. panel like gnome-panel or gkrellm in dock mode). That's the
space you should use to put your windows, unless you want to put your
windows above the panels and wiboxes, which I don't think you want in a
layout IMHO. :-)

> - OK, I can set simple properties of a tag and a client using

Gregor answered to that. ;)

--

-- 
Julien Danjou
// ᐰ <julien <at> danjou.info>   http://julien.danjou.info
// 9A0D 5FD9 EB42 22F6 8974  C95C A462 B51E C2FE E5CD
// I'm no superman.

Gmane