Commit Graph

130 Commits

Author SHA1 Message Date
Emmanuel Lepage Vallee c64c223ede tests: Improve wibox.widget.background documentation 2016-03-31 04:45:46 -04:00
Emmanuel Lepage Vallee e7652a053d tests: Add a new testing framework 2016-03-31 04:45:45 -04:00
Emmanuel Lepage Vallée b2fabfeea1 Merge pull request #770 from Elv13/background_clip
wibox.background: Add shape clip support
2016-03-26 01:51:17 -04:00
Emmanuel Lepage Vallee 2eb085c263 wibox.background: Add shape clip support 2016-03-21 03:30:14 -04:00
Emmanuel Lepage Vallee f1816474df wibox: Add widget and layout metatable for widget creation
Calling wibox.widget.base.make_widget_declarative{} is too long, so this
commit add wibox.widget{} and wibox.layout{} alias.
2016-03-19 17:37:33 -04:00
Uli Schlachter 2e2e3f07e2 systray: Emit layout_changed / redraw_needed where needed
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-03-05 16:53:38 +01:00
Uli Schlachter a1b20ef6bb Systray: Add settings for which screen to display on
This makes it possible to have the systray only visible on the primary screen,
which is the new default value. This also makes it possible to configure
directly on which screen the systray should be visible.

This breaks the API in the sense that people who use "the old method" to
configure the systray's screen possibly don't have a systray.

Fixes: https://github.com/awesomeWM/awesome/issues/724
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-03-05 16:49:49 +01:00
Uli Schlachter 1e5dd0c782 systray: Add API documentation
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-03-05 16:39:25 +01:00
Uli Schlachter ea95963726 systray: Turn this into a singleton
There's no point in having multiple instances of this, because there are no
per-instance settings and the systray can only be visible in a single place at a
time anyway.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-03-05 16:17:35 +01:00
Emmanuel Lepage Vallee 78ed3abe1a wibox.widget: Minor enhancements
* Better widget names when using the declarative syntax
 * Add ratio.get_ratio to avoid using the private API
 * Also support `set_widget` when swapping widgets
2016-03-04 04:16:53 -05:00
Emmanuel Lepage Vallée 3be5343e83 Merge pull request #709 from psychon/implement-set-children-sanely
Implement set children sanely
2016-03-03 02:06:58 -05:00
Daniel Hahler f874b0ad2e Merge pull request #712 from psychon/protected_calls
Protected calls (gears.protected_call)
2016-02-28 22:16:13 +01:00
Uli Schlachter 7bf2f17a8a Make gears.widget.{fit,layout}_widget more robust
This commit makes these methods invoke the method on a widget in a protected
context. Thanks to this, e.g. the wibox and other widgets are protected from
errors in a child widget.

Additionally, fit_widget() now assumes 0 if a widget's :fit() method didn't
provide a number.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-28 12:11:36 +01:00
Uli Schlachter a78f2359d1 Fix the test case that the previous commit added
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-28 11:10:46 +01:00
Uli Schlachter 1dd63b04de check_widget(): Also check .is_widget entry
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-27 14:01:31 +01:00
Uli Schlachter b1e7d3c22c Call check_widget() in :setup()
I just spent too much time tracking down a bug that happened while drawing a
widget. This is the reason why we should apply sanity checks while widgets are
constructed, so that we get a useful backtrace.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-27 13:58:48 +01:00
Uli Schlachter cf3c81fa9e Implement :set_children() sanely everywhere
This makes the code use the existing functions for setting widgets. That way,
all the sanity checks that the existing functions have are applied for this code
as well.

I just spent half an hour tracking down a bug where a boolean ended up as a
"widget" in a fixed layout. The symptom was that while drawing the widget, an
error happened. Via this change, the error would instead be flagged while
constructing the widget.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-27 13:55:34 +01:00
Uli Schlachter 65b403c34a wibox: Support screen objects
This commit documents that a textbox already accepts a screen object where a
screen index is expected. Also, this changes the widget API in that a widget's
context.screen is now a screen object instead of a screen index.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-26 18:42:57 +01:00
Uli Schlachter 15e72fb037 Fix luacheck warnings in lib/wibox
Warnings pointing out actual problems are left.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-12 09:15:55 +01:00
Emmanuel Lepage Vallee cb896ca87f wibox.widget: Add method to create declarative widgets directly 2016-02-11 03:58:54 -05:00
Emmanuel Lepage Vallée ff8f2aef27 Merge pull request #678 from Elv13/bgimage
Extend bgimage support
2016-02-10 03:59:06 -05:00
Emmanuel Lepage Vallee b1e69dba8c doc: Move the new widget documentation to a new file
This will help with discoverability
2016-02-10 01:25:41 -05:00
Emmanuel Lepage Vallee 6a68173ccb widget: Add a new container declaration syntax
This new syntax is inspired by the Awesome widget 3.2-3.4 API. It
allow cleaner widgets declaration. The produced code is usually much
shorted and easier to read than wibox.widget imperative syntax.
2016-02-10 01:09:50 -05:00
Emmanuel Lepage Vallee e36f23171b wibox.widget: Add `set_children` method
Provide a generic method to set the widget content
2016-02-10 01:09:50 -05:00
Emmanuel Lepage Vallee cbea82f1c8 widget.background: Allow function as background image
There is already a hack into `awful.widget.common`. This system aim
to make the hack obselete while preserving the useful part.

I think this is also necessary to properly support SVG (with DPI
and resize).

Finally, Qt handle this using the QBrush concept, where you can have
programmatic patterns. Cairo doesn't have this concept, so there is no
"clean" way to have programmatic brushes.
2016-02-10 00:15:00 -05:00
Emmanuel Lepage Vallee 33c943d9b8 widget.background: Add shape border support 2016-02-06 03:43:42 -05:00
Emmanuel Lepage Vallee b2d121aa18 widget.base: Add ':index(w, r)' method
This function is optionally recursive. This allow to manipulate
abstract layouts without really having to care about the exact
hierarchy.
2016-02-03 04:00:56 -05:00
Emmanuel Lepage Vallee 8da5c79bb8 wibox.widget: Add new `get_children(recursive)` method to all widgets 2016-02-03 04:00:42 -05:00
Emmanuel Lepage Vallee 1d1e487d19 wibox.imagebox: Add a `clip` method based on the `gears.shape` API 2016-02-02 00:21:42 -05:00
Emmanuel Lepage Vallee dc432eb7a6 widget.background: Fix error introduced in d01c1d2d6
Fix a copy/paste mistake.
2016-01-21 22:53:21 -05:00
Daniel Hahler cb267e56d5 Merge pull request #637 from psychon/set_markup
Make wibox.widget.textbox:set_markup() throw Lua errors less often
2016-01-20 00:01:09 +01:00
Emmanuel Lepage Vallee d01c1d2d6d widget.background: Allow background to have a shape 2016-01-18 17:22:49 -05:00
Uli Schlachter 178204449c Textbox:set_markup(): Print errors to stderr
Instead of throwing a Lua error, the code now just prints an error message to
stderr on invalid markup. For callers which want to handle this case specially,
we add :set_markup_silently() which returns error messages.

Fixes: https://github.com/awesomeWM/awesome/issues/546
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-01-17 16:47:27 +01:00
Uli Schlachter 76b1d348a1 imagebox: Remove dead code
Since some commits, surface.load() handles printing an error message for us.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-01-15 18:53:09 +01:00
Emmanuel Lepage Vallee bd8e2d2ca8 typo: replace 'wibox' with 'context' where relevant
Closes https://github.com/awesomeWM/awesome/pull/613.
2015-12-31 15:33:22 +01:00
Daniel Hahler 981987764e Merge pull request #586 from psychon/widget_funcs
Widgets: set_width / set_height
2015-12-12 19:13:28 +01:00
Daniel Hahler e39504a30f Make textbox widget respect the current theme
Without this fix `wibox.widget.textbox` ignores current theme font
setting and resets it to the initial one.
It becomes handy when the initial theme is tweaked during runtime, ie.
in `rc.lua`. Other AwesomeWM components like `awful` (taglist,
tasklist, menu) are aware and do respect the actual theme settings.

Closes https://github.com/awesomeWM/awesome/pull/89.
2015-12-11 00:55:33 +01:00
Uli Schlachter f4077def8e Add :set_{width,height} to widgets (#291)
This adds new functions to all widgets that allow to force a specific
width/height. These values override the result from :fit().

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-12-05 12:31:33 +01:00
Uli Schlachter c2be60fb54 wibox.widget.base: Factor out functions available on all widgets
Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-12-05 12:25:25 +01:00
Uli Schlachter c02969bb0e wibox.widget.systray: Also emit redraw_needed
When emitting layout_changed, the widget is relayouted. If this doesn't actually
change anything, nothing will be redrawn. Thus, this also emits redraw_needed to
force redraws.

This fixes a race condition with some weird tray icons. A new tray icon is
created and the systray is updated. Then this new icon is destroyed immediately
again and at the same time another icon is created. Then, the systray isn't
updated since the number of icons (=the layout) did not actually change.
However, it needs to be updated and so we ended up with broken/missing icons.

Fixes: https://github.com/awesomeWM/awesome/issues/487
Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-11-29 12:33:13 +01:00
Daniel Hahler 2bca03cb87 doc: fix format for wibox.widget.base.make_widget
Closes https://github.com/awesomeWM/awesome/pull/548.
2015-11-05 23:05:42 +01:00
Uli Schlachter cdd8d2ed5f Textbox: Add API for queriying preferred size (#466)
This adds :get_preferred_size() and :get_preferred_size_at_dpi() which return
the size (=width, height) that the textbox would need if unlimited space is
available.

This also adds :get_height_for_width() and :get_height_for_width_at_dpi() which
return the height that the textbox would need if the given width is available.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-10-17 19:13:26 +02:00
Daniel Hahler 4bffa7e47e doc: fix unintentional rendering as code due to indent 2015-10-14 00:22:26 +02:00
Uli Schlachter d03762c322 systray: Make sure the widget is only placed in a wibox
Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-10-10 20:30:08 +02:00
Uli Schlachter a3e690d191 imagebox: Redraw in :set_image()
If someone modifies a cairo surface and then sets the resulting object as the
image of an imagebox, the imagebox needs to redraw. Thus, since surfaces are
modifiable, we cannot assume that nothing changed when the same image is set
multiple times on an imagebox.

However, the dimensions of a surface cannot be changed and thus this does not
need to emit widget::layout_changed.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-09-29 00:28:26 +02:00
Uli Schlachter bd47edb4ef leak test: Make the layoutbox test pass
This commit does two things: It gets rid of the reference to the layoutbox that
the default config created and it changes the widget dependency cache to not
keep widgets alive unnecessarily.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-09-27 14:42:39 +02:00
Daniel Hahler 4e22cf02e6 Merge pull request #384 from blueyed/more-robust-errors
More robust errors: make sure errors are strings

Closes https://github.com/awesomeWM/awesome/pull/384.
2015-09-23 20:59:35 +02:00
Daniel Hahler 28ffdb050e Merge pull request #454 from psychon/remove_gears.debug.assert
Remove gears.debug.assert

Closes https://github.com/awesomeWM/awesome/pull/454.

Conflicts:
	lib/gears/matrix.lua
2015-09-21 21:16:36 +02:00
Uli Schlachter 8d6030819b textbox: Honor per-screen DPI
This makes the textbox' :draw() and :fit() callbacks use the DPI that is
specified in the given drawing context. With this, the textbox now scales
correctly if different screens have different DPI values.

Idea originally from Daniel.

Closes https://github.com/awesomeWM/awesome/pull/457.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-09-21 21:13:21 +02:00
Daniel Hahler b0d7e6bb6c Merge pull request #458 from psychon/explicit_widget_deps
Explicitly track dependencies between widgets

Closes https://github.com/awesomeWM/awesome/pull/458.
2015-09-21 21:12:39 +02:00