Commit Graph

79 Commits

Author SHA1 Message Date
Uli Schlachter 4c3bac07ec wibox: Improve constructor functions for some layouts
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-03-10 13:46:28 +01:00
Lukáš Hrázký 5365dfdb79 wibox.layout.constraint: fix the min and max strategies
Fixes mixed up min/max strategies and other bugs in min and max. Also
removes enforcing the size in draw, adhering more to awesome's layout
concept.

Signed-off-by: Lukáš Hrázký <lukkash@email.cz>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-03-10 11:24:53 +01:00
Uli Schlachter 2e38c08569 wibox.wibox.systray: Allow multiple systrays
This has to be removed because it breaks the fallback to the default config if
the first config already managed to create a systray widget. This doesn't mean
that it is suddenly possible to have the systray visible in more than one place,
it just means that awesome will no longer complain about this.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-03-10 11:11:43 +01:00
Uli Schlachter 873d41bb5b wibox.drawable: Redraw when moved
Let's consider the following notification:

  naughty.notify({ text = "foo", bg = "#88888888", timeout=1 })
  naughty.notify({ text = "foo", bg = "#88888888", timeout=2 })

When the first notification disappears, the second one is moved and takes its
place. However, its content was not redrawn. This makes the pseudo-transparency
break and the wallpaper that is shown in the back of the notification doesn't
match the real wallpaper.

Fix this by redrawing drawables when they get moved.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-02-26 11:21:48 +01:00
Uli Schlachter 2de450dff9 wibox.drawable: Don't redraw drawables without surfaces (FS#1079)
Thanks to the previous commit, a drawable can no longer have a finished cairo
surface. Instead, it will now have a nil surface. This commit handles this new
possibility.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-02-20 14:19:31 +01:00
Lukáš Hrázký 470142acc3 wibox.widget.textbox: return 0, 0 from fit() if either w or h is 0
A hack around abusing the fact that width of a textbox is 0 when its
empty, while it's height is still set according to the font.

Signed-off-by: Lukáš Hrázký <lukkash@email.cz>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-02-20 13:08:27 +01:00
Lukáš Hrázký 1881ceb9d3 wibox.layout.flex: add set_max_widget_size() function
The function can be used to set the maximum size the widget in the
flex layout should take.

Signed-off-by: Lukáš Hrázký <lukkash@email.cz>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-02-20 13:08:27 +01:00
Uli Schlachter f859131bf3 wibox.widget.systray: Properly work when rotated (FS#1115)
The systray widget's fit() function worked in the (rotated) user coordinate
space while the draw() function used device coordinates (unrotated). This meant
that width and height were swapped up in the calculations and the systray ended
up being way too small.

Fix this by making the draw() function use user coordinates, too. This means
that it needs some new magic to detect a rotated coordinate space. This, in
turn, means that the systray is now automatically rotated when you put it into a
rotate layout.

This might cause some minor breakage because people no longer need to call
:set_horizontal() on the widgets.

Thanks a lot to Alexander Gehrke for his help!

Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-02-16 22:14:08 +01:00
Uli Schlachter 6608b0aa1c wibox.layout.align: Give middle widget full height
I amended some change to commit 8560de597c which made the align layout's
middle widget really centered instead of being way too wide. However, this also
shrunk the widget on the "other" axis, too. This commit fixes that up.

A big "sorry" to Lukáš for breaking his patch.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-01-08 22:06:25 +01:00
Lukáš Hrázký 66e52229f7 wibox.layout: add a new constraint layout
This layout can be used to constraint the size of the widget it holds.
Depending on the strategy passed to it, the widget will have a minimum,
maximum or exact size that was set through this layout.

Signed-off-by: Lukáš Hrázký <lukkash@email.cz>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-01-05 23:05:30 +01:00
Lukáš Hrázký 8560de597c wibox.layout.align: make the middle widget really centered
Centers the middle widget in the align layout in the remaining space
left by the widgets on the sides.

Signed-off-by: Lukáš Hrázký <lukkash@email.cz>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-01-05 23:05:30 +01:00
Lukáš Hrázký e38651bafb wibox.layout.align: don't take up all space in the other axis
This adds a fit function to the align layout that makes sure that
the layout will not take up all the available space in the other
axis than it's direction. Eg. for horizontal align layout, it will
only take up the maximum of its widgets' heights in the vertical axis.

Signed-off-by: Lukáš Hrázký <lukkash@email.cz>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-01-05 21:05:45 +01:00
Lukáš Hrázký f6d9443c5d wibox.layout.flex: fix the fit function
The fit function of the flex layout is different from the fixed.fit one.

Signed-off-by: Lukáš Hrázký <lukkash@email.cz>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-01-05 21:04:48 +01:00
Lukáš Hrázký 9d333113dd wibox.layout: remove unnecessary wrapping of draw and fit functions
Signed-off-by: Lukáš Hrázký <lukkash@email.cz>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-01-05 20:59:42 +01:00
Uli Schlachter 3a25e78224 wibox.layout.rotate: Add some good constructor arguments
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-01-05 20:52:00 +01:00
Uli Schlachter ae69b2db03 wibox.layout.base: Use math.min/max
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-01-05 20:50:17 +01:00
Uli Schlachter f6b43a1f1d Fix wibox.layout.rotate
This got broken in commit 90f7f55348.

Thanks to crazedpsyc for reporting this.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-12-05 17:35:08 +01:00
Uli Schlachter e24c09e828 Update titlebar color when focus changes (FS#1056)
The current code relied on some widget to cause a redraw when the focus changes.
Obviously, this assumption is wrong.

Instead, the code now uses the proper "focus" and "unfocus" signals for setting
titlebar colors, but it also needs to set these colors when a new titlebar is
created (v1 of this patch forgot that). For this reason, update_colors has to be
saved for when a titlebar's colors are updated.

This commit also reverts the ugly redraw_hook hack from commit a1918b8306.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-11-29 16:52:19 +01:00
Uli Schlachter c50d62749b Fix errors from missing themes
This patch gets rid of lots of errors that happen when beautiful.init() is not
called in the config. Most of them were missing default values.

Thanks to panthar for reporting this.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-11-27 22:55:42 +01:00
Uli Schlachter b7eb233aee imagebox: Use a different entry for saving the image
In 3.4, an imagebox' image is set via "box.image = foo". Since widgets are just
ordinary tables in 3.5, this will actually mess with the imagebox' image without
setting it correctly.

Fix this by renaming the entry to "_image".

A similar patch was applied to the textbox widget ages ago.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-11-27 17:24:54 +01:00
Uli Schlachter fa6d996c41 widgets: Add some constructor arguments
This saves space when constructing widgets, because some common cases can now be
done in a single line of code.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-11-25 19:16:31 +01:00
Uli Schlachter d13b825c36 Fix warnings from LDoc
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-11-19 15:35:32 +01:00
Uli Schlachter 96e03cb45d Lots of random documentation fixes
This is mostly about mis-named parameters, but also other small things.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-11-19 14:09:10 +01:00
Uli Schlachter 90f7f55348 wibox: Make the functions a little more object-y
This replaces lots of function foo.bar(this, ...) with function foo:bar(...).
There should be no other changes in this commit.

The point is to make it easier for api documentation tools to figure out that
these are methods on objects.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-11-18 20:44:03 +01:00
Uli Schlachter 14fa66c63f wibox.drawables: Fix a memleak
Drawables could never be garbage-collected, because of the "wallpaper_changed"
signal. The callback function for this signal kept a strong reference to the
drawable.

Fix this by putting all drawable's draw() methods into a weakly keyed tabled so
that the strong reference to them disappears.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-11-03 19:52:39 +01:00
Uli Schlachter 77fedaeee8 Remove unused signal property::widgets
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-10-31 22:24:23 +01:00
Uli Schlachter fa86fbeb52 lib/wibox: Make signals from drawables available
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-10-31 22:12:30 +01:00
Uli Schlachter a1918b8306 awful.titlebars: Implement
This commits adds the necessary lua code so that we finally can have titlebars.
As the baseline for the needed functionality, the titlebar code in awesome 3.4
and a quick poll on the mailing list were used.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-10-23 20:37:50 +02:00
Uli Schlachter 1e418cbe3b drawable: Add property::surface
This new property is used for fixing some missing redraws that the old code had.
Those could be seen via awful.menu. Open and close a submenu repeatedly and the
submenu will appear black.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-10-20 22:51:52 +02:00
Uli Schlachter 41ef107b88 Add titlebars on the C side
This commit makes it possible to add titlebars to a client. These titlebars are
drawables.

The drawin's input handling is moved to the drawable. This allows it to use the
same code for drawin and titlebar input handling, although there are lots of
differences between the two on the C side.

On the lua side, a new wibox.drawable module is created which handles all the
drawable-specific magic and which can also be used for titlebars.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-10-14 17:30:59 +02:00
Uli Schlachter f0512eeaab Introduce drawables
A drawable is something that you can draw to, just like a drawin. However, a
drawable isn't necessarily its own windows. This will later on be used to
implement titlebars where the titlebars are drawables.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-10-14 17:30:54 +02:00
Uli Schlachter 21d821a8dd rotate: Use the draw_widget() function
Without this, input handling is broken (draw_widget() registers each widget with
its position for input handling).

This also removes some unnecessary save()/restore() calls. Our caller (again
draw_widget()) already does that for us.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-07-06 13:09:13 +02:00
Uli Schlachter ce9932f17f Fix various minor errors after the lua 5.2 conversion
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-06-16 21:12:26 +02:00
Arvydas Sidorenko 61ff9ce2b7 Ported awful to lua 5.2
Tested with lua 5.1: all good

Signed-off-by: Arvydas Sidorenko <asido4@gmail.com>
2012-06-16 17:37:30 +02:00
Arvydas Sidorenko f73e0b44c0 Ported wibox.widget to lua 5.2
Tested with 5.1: all good

Signed-off-by: Arvydas Sidorenko <asido4@gmail.com>
2012-06-16 17:37:30 +02:00
Arvydas Sidorenko 4e67027a97 Ported wibox.layout to lua 5.2
Tested with lua 5.1: all good

Signed-off-by: Arvydas Sidorenko <asido4@gmail.com>
2012-06-16 17:37:30 +02:00
Arvydas Sidorenko 3f5eaf9c1b Ported wibox to lua 5.2
Tested with lua 5.1: all good

Signed-off-by: Arvydas Sidorenko <asido4@gmail.com>
2012-06-16 17:37:30 +02:00
Arvydas Sidorenko 9623b8e42f Changed unpack in portable way
Signed-off-by: Arvydas Sidorenko <asido4@gmail.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-06-16 13:00:13 +02:00
Uli Schlachter 68d630c32a Remove a pango hack
Instead of creating unused cairo image surfaces, we create our temporary layouts
now via the (PangoCairo) font map. Way less ugly.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-05-27 20:17:14 +02:00
Uli Schlachter 4f30dfd198 Switch from oocairo to lgi.cairo
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-05-27 19:20:34 +02:00
dodo 634d54298e new wibox.layout.mirror
this allows to mirror a widget vertical and/or horizontal.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-05-18 12:09:32 +02:00
Felix Bier bd0c9f75ae Return condition value instead of conditional true/false
Signed-off-by: Felix Bier <flx.bier@googlemail.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-05-13 10:49:10 +02:00
Anurag Priyam 9dfe4fe84b wibox.set_bg: remove historical cruft
Should ideally have been removed in commit 'drawin: Remove bg_color property'.

Signed-off-by: Anurag Priyam <anurag08priyam@gmail.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-05-06 18:53:04 +02:00
Anurag Priyam ceb6eb311d wibox: assume a default background and foreground color if none passed
Signed-off-by: Anurag Priyam <anurag08priyam@gmail.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-05-06 18:53:04 +02:00
Uli Schlachter 5c7a3501d0 wibox: Add pseudo-transparency support
If you now set a wibox' background to e.g. "#00000080", the wibox will do fake
transparency and draw the wallpaper as its background.

This should cover 90% of uses of wibox transparency. For the remaining 10% I'll
wait for bug reports. :-)

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-04-07 21:54:51 +02:00
Uli Schlachter efee293dd2 wibox: Allow tables as color specification
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-02-17 17:50:31 +01:00
Arvydas Sidorenko e052bd99b0 oocairo.image_surface_create_from_png TO awesome.load_image
Replaced all references to image_surface_create_from_png to
awesome.load_image

Signed-off-by: Arvydas Sidorenko <asido4@gmail.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-01-29 16:18:18 +01:00
Uli Schlachter 6f61bde6f2 wibox.widget.base.make_widget: Remove outdated cruft
This never should have ended up in git. AFAIR :size() was replaced by :fit()
long, long ago.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-01-04 17:11:06 +01:00
Uli Schlachter 20cafb4851 drawin: Remove bg_color property
The default background color (None) means that the server will leave the
window's content untouched when an exposure happens. This should get rid of all
cases of "flashing window".

The real background will later be drawn while awesome is handling the expose
event.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-12-23 16:54:55 +01:00
Uli Schlachter d8f0bd13bf textbox: Actually tell pango which space we have (FS#933)
In the textbox' draw() callback we forgot to set the pango layout's width and
height. Whoops.

This was tested with the following code which makes it visible when the textbox
draws outside of its assigned space:

local w = wibox({ screen = 1 })
w.y = 10
w.x = 10
w.width = 150
w.height = 150
w.visible = true

local wi = wibox.widget.base.make_widget()
local t = wibox.widget.textbox()
t:set_markup("Foo <b>bar</b> <i>Foobar</i> und so weiter")

wi.draw = function(d, wibox, cr, width, height)
	cr:move_to(24.5, 0)
	cr:line_to(24.5, 150)
	cr:move_to(0, 24.5)
	cr:line_to(150, 24.5)
	cr:move_to(124.5, 0)
	cr:line_to(124.5, 150)
	cr:move_to(0, 124.5)
	cr:line_to(150, 124.5)
	cr:set_line_width(1)
	cr:stroke()

	cr:translate(25, 25)
	t.draw(t, wibox, cr, 100, 100)
end
w:set_widget(wi)

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-10-19 19:05:25 +02:00