The usual "a or b"-trick to simulate C's ?:-operator does not work when
"false" is a valid value. Fix the code to handle this correctly and add
a short unit test which would have caught this problem.
Signed-off-by: Uli Schlachter <psychon@znc.in>
We already have a variant of this function for transforming an actual
matrix. This adds the corresponding static factory.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Instead of doing Linux-specific magic with error codes and trying to
read the first byte of a file, just use Gio to check if a file exists
and is readable.
Signed-off-by: Uli Schlachter <psychon@znc.in>
When adding callbacks as a `callback` entry in a property, the callback
is run by `awful.rules`, because it does `c.callback =
result_of_function`. This is obviously not intended. Also, this causes
the callbacks to run twice, because the code already handled this
`callback` property specially.
Fix this by just not merging callbacks with the normal rules at all.
Fixes: https://github.com/awesomeWM/awesome/issues/1159
Signed-off-by: Uli Schlachter <psychon@znc.in>
Instead of hardcoding the list of generated doc files as dependencies to
ldoc, we jump through some hoops to compute this dynamically.
Signed-off-by: Uli Schlachter <psychon@znc.in>
A while ago, we made errors from ldoc fatal by default. Then a new ldoc
release appeared and caused problems for all of our users, because
awesome failed to work.
This patch reverts the previous fix so that we ignore ldoc warnings by
default again. However, to catch ldoc warnings on Travis, another
ldoc-building-target is added that fails on warnings. This new target is
included in our "check" target.
This fixes the intend of issue #1098 ("Users with ldoc version X cannot
build awesome"), but it does not actually employ the solution proposed
there ("Blacklist those ldoc versions"). Still, since this fixes the
intend of the issue, I count it as fixed.
Fixes: https://github.com/awesomeWM/awesome/issues/1098
Signed-off-by: Uli Schlachter <psychon@znc.in>
At the beginning of every main loop iteration, we check for new events
from the X11 server. However, it's theoretically possible that during a
main loop iteration new events arrive and are read by libxcb into its
internal buffer. This would mean that the fd connected to the X11 server
is not readable and thus we do not wake up to handle these events.
Handle this by checking for pending events before calling poll(). If a
new events appears, we set the timeout for poll() to zero and will then
handle the new event in the following iteration of the main loop.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Add a single "do" to the beginning of the config. This causes a parsing
error ("'end' expected") and then another warning saying "something was
left on the Lua stack.
Fix this by popping the error message where we need to do so.
Signed-off-by: Uli Schlachter <psychon@znc.in>
For some reason, the code here tried to handle widget::redraw_needed
signals even though it should apparently/obviously only produce a
current snapshot of the widget's look.
Fix this by just removing the redraw code.
While here, also factor out the widget context table into a local
variable and re-use it for the initial layout and for the later draw.
Signed-off-by: Uli Schlachter <psychon@znc.in>
When awesome calls any Lua code, it does so with a protected call. This
means that any kind of Lua error should (there are exceptions) just
result in an error message being printed and everything continuing as
usual. When LGI calls Lua code, it uses a normal call. This means that
in an asynchronous context, that is, when there is no more call
generated by awesome's C code on the call stack, we must be careful,
since any error results in Awesome's unprotected error handler to be
called which restarts the WM.
menubar.utils.parse_dir() asynchronously parses a directory containing
.desktop files. This means that it is no longer in a protected call
context. Let's assume that the code itself is fine. However, the
callback that the caller provided for handling the results can be quite
arbitrary. Make sure that it is run in a protected context.
Helps-with: https://github.com/awesomeWM/awesome/issues/1173
Signed-off-by: Uli Schlachter <psychon@znc.in>
It does not provide much value. The version number is already known to
ldoc globally in the "description" variable.
Signed-off-by: Uli Schlachter <psychon@znc.in>
This is necessary when being run with a tty that has no width, which
happens when using https://github.com/metakirby5/codi.vim/ in Vim 8 (but
not Neovim), where rlwrap complains as follows:
> rlwrap: error: My terminal reports width=0 (is it emacs?) I can't
> handle this, sorry!
Daniel sees a short flicker of his wallpaper when he closes a client.
This happens because the window is destroyed immediately, but other
clients are re-arranged only shortly later. In the mean time, the X
server updates the display and repaints the root window (= wallpaper
becomes visible).
Work around this by delaying the destruction of frame windows to the end
of the current main loop iteration. This means that we first update the
position of all other windows and later destroy the window that was
actually closed.
Signed-off-by: Uli Schlachter <psychon@znc.in>
We are doing more and more things lazily in the C code. The newest
addition is lazily configuring clients, which means that geometry
changes are only applied later.
However, this caused a short flicker when a new client appears: We were
first making the client visible and then moving it to its "proper"
position.
Since unbanning is also done lazily, we just have to change the order in
which we apply these operations to fix this.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Instead of using magic with a weak table, the code now saves this data
as a property under the tag object. This avoids all kinds of leaks, for
example caused by t.foo = t.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Instead of using magic with a weak table, the code now saves this cache
as a property under the tag object.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Instead of using a weak table to save the last mouse position, this is
now saved directly as a property under the screen.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Instead of using a weak table with some magic to save properties of a
client, the code now uses the c.data table provided by the C code
instead.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Instead of having an extra weak table to save a boolean per client, this
now sets a property directly on the client.
Signed-off-by: Uli Schlachter <psychon@znc.in>
No idea what self referencing loops this refers to. Lua 5.1's and
LuaJIT's garbage collector both should handle cycles just fine. Things
only start getting complicated when you start using weak tables.
Unless someone comes up with an example where this patch causes a leak,
let's remove the weak table magic.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Matrix operations are hard. Apparently I always keep confusing the order
that transformations are applied in the matrix resulting from a matrix
multiplication.
This commit fixes things in wibox.hierarchy that were wrong due to the
wrong order and changes a unit test so that it would now catch the
breakage (and makes sure that it does not happen again).
Signed-off-by: Uli Schlachter <psychon@znc.in>
Instead of matrix_to_device and matrix_to_parent, this now provides the
full hierarchy instance managing the current widget.
In addition to x, y, width and height (which are an over-approximation
of the widget's extents on the drawable), this now also provides
widget_width and widget_height in the widget's local coordinate system.
These last two values are exact.
For example, the tooltip needs x/y/width/height while a widget that
wants to figure out which point on it was hit with a mouse press will
need widget_width and widget_height (together with the position argument
that is passed in with mouse::press).
I don't know how to document the return type of this function properly.
Hopefully just describing the structure of the resulting table is good
enough.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Previously, this mentioned non-existent arguments (widget) and
duplicated parts of the (not yet really existing) API documentation for
find_widgets().
Signed-off-by: Uli Schlachter <psychon@znc.in>
Just because they sound similar to mouse::press and mouse::release does
not mean that the arguments are the same. Perhaps they should be, but
that's another story.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Similar to the previous commit, this makes the drawable not apply a
pending relayout while it is not visible. When it becomes visible again,
the relayout is done.
The hope here is that less work is done while a drawable is not visible,
saving CPU time.
Signed-off-by: Uli Schlachter <psychon@znc.in>
LGI does not protect against use-after-free issues that can occur due to
using an object after finalisation. This manifests itself as occasional
crashes on Travis in cairo_region_union_rectangle() (AFAIK no one ran
into this issue in real-world usage).
Since visible drawables are always strongly reachable, the issue can
only occur with invisible drawables. The previous commit made sure that
those are fully repainted when they become visible, so we can just
ignore redraws for those and fix the crash issue.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Instead of tracking all drawables that are alive, the code now only
tracks visible drawables. When a drawable is made visible it is
completely repainted. This should not cause a difference when a wibox is
initially made visible, because it has to be redrawn anyway. However,
this introduces a full repaint when a wibox is hidden and then made
visible again.
Thanks to this change, we can stop using weak tables. Visible drawables
cannot be collected and so we can keep a strong reference to them. This
allows us to get rid of the weak tables which solves various problems
involving finalizers and using objects after finalisation.
Signed-off-by: Uli Schlachter <psychon@znc.in>