Commit Graph

287 Commits

Author SHA1 Message Date
Seth Barberee b9bb9cbe69 add docs for gears.cache 2020-01-05 20:58:36 -06:00
Emmanuel Lepage-Vallee 9f42f57a76 doc: Upgrade the gears.timer documentation to the new standards. 2019-12-21 21:35:12 -08:00
Seth Barberee d05b7d80f1 gears.string doc revamp 2019-12-19 09:52:03 -06:00
Seth Barberee 9e3c418a03 add gears.table.cycle_value (#2942) 2019-12-12 22:10:10 -08:00
Emmanuel Lepage Vallée a6e52a8c42
doc: Fix an incorrect signal name. (#2943)
Reported by @unai-ndz

See #1373
2019-12-11 10:01:54 -08:00
Emmanuel Lepage Vallee c96487515f object: Make the legacy accessor code more robust.
* Using `= one and two or three` is a bad idea on boolean.
* Using # to check if a table has content doesn't work on named keys
2019-12-04 02:05:09 -05:00
Emmanuel Lepage Vallee 42dceb1db8 object: Add a standard implementation for append and remove.
This is for legacy accessors only, but it will be expanded later.
2019-12-04 01:40:32 -05:00
Emmanuel Lepage Vallee fbe2b34af4 properties: Allow to delay some operations.
This will be useful for the append/remove support.
2019-12-04 01:40:32 -05:00
Aire-One 82a2769e04 Fix ldoc modules summaries missing the final `.`. 2019-11-28 13:53:59 +01:00
Emmanuel Lepage Vallee 10fd4e8883 object: Try harder to auto-undeprecate the keys and buttons.
Having the new object layout will be important soon when the
append/remove methods start to get added to the client and the
reborn `awful.keyboard` module.
2019-11-09 16:43:12 -05:00
Emmanuel Lepage Vallee 35a4b4edbf object: Allow old `gears.table.join` accessors to be set to `false`.
This worked before, so it has to work again.

Fixes #2915
2019-11-09 16:43:12 -05:00
Emmanuel Lepage Vallee 45823f230a capi: Move from `.data` to `._private` for the property data.
This will bring the CAPI classes closer to the gears.object ones.

Fixes #2897
2019-11-09 16:43:12 -05:00
Emmanuel Lepage Vallee 50eb7d5599 Revert "legacy: Temporary workaround for #2897. (#2898)"
This reverts commit e888d983ef.
2019-11-09 16:43:12 -05:00
Emmanuel Lepage Vallée e888d983ef
legacy: Temporary workaround for #2897. (#2898)
The `:keys()` and `:buttons()` APIs moved from get/set single methods
to properties. It works fine if you use the new or old API, but has
limitations when mixing them. `awful.rules` calls properties in a loop
after checking if it is a function. Thus it triggers the secondary
codepath to try to handle this case.

This codepath was tested with gears.objects based components
(ie. widgets). It was not tested with clients and tags, and it
didn't work because they use `awful.tag.getproperty` and
`awful.client.property.get` instead of `._private` like all
newer components. Those old functions are officially deprecated,
but used by tons of configs and modules ported from v3.5 and thus
still the default way to access Lua properties in our implementation.

This commit adds a `_private` to anything that doesn't have one to
at least make the error stop. It will "mostly" work until a more
complete solution is added. Reverting the 2 PRs that changed this
would delay getting more feedbacks.
2019-10-09 13:35:05 -04:00
Emmanuel Lepage Vallee 78c3496770 object: Add support for the legacy accessors as r/w methods.
Many legacy Awesome APIs such as `client:tags()`, `root.buttons()`,
`client:keys()`, `drawin:geometry()`, etc used functions for both the getter
and setter. This contrast with just about everything else that came after
it and is an artifact of an earlier time before we had "good" Lua object
support.

Because both consistency and backward compatibility are important, this
table wrapper allows to support both the legacy method based accessors
and key/value based accessors.

It isn't part of the public API, has a sledgehammer function prototype
and is intended for internal use only.

It's ugly, but backward compatibility is more important than anything
else.
2019-10-05 18:06:51 -04:00
Emmanuel Lepage Vallee 9920fdd3f1 gears.table: Add a new way to merge 2 tables.
This function allows to update the content of a table using the
content of a second table. It helps to keep the original reference
and to know what has been added and removed.
2019-09-29 18:20:15 -04:00
Uli Schlachter 1adeef18a2 Fix some typos (#2880)
Signed-off-by: Uli Schlachter <psychon@znc.in>
2019-09-23 18:39:12 +02:00
Emmanuel Lepage Vallee f60abed1d0 gears.geometry: Add a function to compare 2 rectangles.
The next step will be to find all the places where this is duplicated.
2019-09-04 13:11:47 -04:00
Emmanuel Lepage Vallée 1e59fc7fd2
Merge pull request #2828 from Elv13/matcher_v2
Improve `gears.matcher` to be more flexible.
2019-08-11 22:29:35 -07:00
Emmanuel Lepage Vallee 67e5dd3091 matcher: Match all sources when none is provided.
Nobody wants to set this parameter. It is necessary because the old
API allowed `awful.rules` to be used with random for random matching.

This stopped "really" working between the 3.4 and 3.5 release because
the code started to accumulate "corner case" fixes aligned with the
client properties. v4.0 added more ordering and v4.3 added external
sources. After this, it is unusable with external objects, but
`gears.matcher` handle this use case very well.
2019-08-06 02:20:01 -04:00
Emmanuel Lepage Vallee 91ca922671 tests: Test the gears.matcher greater and lesser sections. 2019-08-03 18:26:06 -04:00
Emmanuel Lepage Vallee 64bef57013 matcher: Add a `greater` and `lesser` matching sections.
In a perfect world we would have pure expression matching, but
that's problematic with all the "metaness" of the code. For now,
this adds an imperfect way to match the minimum and maximum of
number properties.

It will be used by the screen rules for the DPI and size properties.
2019-08-03 18:26:06 -04:00
Emmanuel Lepage Vallee b40083780e matcher: Add a "every" and "every_any" sections to the rules.
So far the "any" rules had a "OR" and "NOT" logic "gates", but not
an "AND".
2019-08-03 18:26:06 -04:00
Emmanuel Lepage Vallee 3e4f292906 matcher: Fix the doc.
It was developed in parallel to the new doc format and wasn't updated.
2019-08-03 18:26:06 -04:00
Emmanuel Lepage Vallee 801ae69f23 matcher: Add a custom setter for "fake" object properties.
This is hardcoded in `awful.rules`, but cannot be shared due to the
priority corner cases. Given in the long run any "standard" priority
should use the topological sort API, better not try to share *that*
code.
2019-08-03 18:26:06 -04:00
Emmanuel Lepage Vallee 9a16ee62e6 matcher: Add a way to match properties beside == and patterns.
It is useful for objects and avoid the mess that it Lua == overload.

The primary use case will be to match tags by name or object.
2019-08-03 18:26:06 -04:00
Emmanuel Lepage Vallee f3f9e4a4b5 matcher: Allow rules to be addressed using an identifier. 2019-08-03 18:26:06 -04:00
Emmanuel Lepage Vallee 886f8ea4e3 matcher: Use gears.object.
This way there's some signals. It can be useful if the module using the
matcher needs to act when something happens.
2019-08-03 18:26:05 -04:00
Emmanuel Lepage Vallee d8b53dac5d matcher: Add methods to add new rules.
It is now possible to add and remove rules. This is superior to how
`awful.rules` originally handled rules because modules can now
assume adding and removing rules works.

The reason for the methods rather than `table.insert` is partially
because future commits will add signals. In turn, this will allow
`gears.matcher` to be extended by module using it using the extra
"introspection" made possible by the signals.
2019-08-03 18:26:01 -04:00
Emmanuel Lepage Vallee c0ef0c8802 tests: Expose the previously private gears.protect_call error handlers.
This will allow the test suits to intercept them instead of adding more
and more exceptions to `run.sh`.
2019-08-03 01:45:22 -04:00
Emmanuel Lepage Vallee 41149ed335 class: Share the module level signal system implementation.
Avoid adding another copy.
2019-08-03 01:45:22 -04:00
Uli Schlachter ccaa75f4b4 Make shapes more robust w.r.t pre-existing paths (#2806)
A call to cairo_close_path() adds a straight line to the beginning of
the current sub-path. This is used in some of the shapes to, well, close
the shapes.

Sub-paths can be created explicitly via cairo_new_sub_path(), but also
implicitly via cairo_move_to(). When a new sub-path is started, there is
no current point on the path. This means that e.g. cairo_line_to() is in
this start equivalent to cairo_move_to() (= no line is created) and that
cairo_curve_to() first does a cairo_move_to() to the beginning of the
curve. Similarly, cairo_arc() and cairo_arc_negative() first do a
line_to() to the beginning of the arc, and this line_to() can be
implicitly turned into a curve_to().

The problem with the code in gears.shape is that parts of the code
(implicitly) assume that there is not yet any path when the shape
function is called.  If this assumption is broken, the call to
close_path() could go to the wrong point, because the path did not start
at the expected position.

Most of the functions in gears.shape already implicitly start a new
sub-path via a call to cairo_move_to(). Those that do not (necessarily)
begin with a call to cairo_move_to() are handled in this commit: They
get an explicit call to cairo_new_sub_path().

This change fixes the issue reported at
https://github.com/awesomeWM/awesome/pull/2804, because the shapes will
no longer be influenced by the pre-existing path. The move_to() that was
left around and caused that issue turns into a degenerate part (it only
has a move_to(), so nothing can be drawn) and is then discarded by
cairo.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2019-07-03 16:56:08 -04:00
Emmanuel Lepage Vallee 90a29f92eb doc: Fix all the property, theme and field types. 2019-06-08 18:14:14 -04:00
Emmanuel Lepage Vallee b4ece0f053 doc: Use an explicit tag for all static functions.
This way their name doesn't get mangle by the broken magic. It will also
eventually allow to `error()` in the template when the implicit
`@function` is used.

This commit also fixes a large number of issues found while
proof-reading everything.
2019-06-08 18:14:13 -04:00
Emmanuel Lepage Vallee 11d7a614d9 doc: Add a constructor stereotype for everything.
This forces the constructor functions to be at the top of the API
documentation rather than in a random position.
2019-06-08 18:13:42 -04:00
Emmanuel Lepage Vallee 63ca0f0d8f doc: Use an explicit @method stereotype for all methods.
ldoc has a magical `@classmod` module type which tries to detect
what is a method and what is a static function. It fails about as
often as it works. This commit makes everything explicit to remove
such issues.

Fixes #2640
Ref #1373
2019-06-08 18:13:42 -04:00
Emmanuel Lepage Vallee cdeafeff94 doc: Add a section for theme related libraries 2019-06-08 18:13:42 -04:00
Emmanuel Lepage Vallee ded35502d5 doc: Add a section for utility libraries
Dedicated for the modules extensions developers will need, but that the
general "I only edit rc.lua" user wont.
2019-06-08 18:13:42 -04:00
Emmanuel Lepage Vallee 9d0c2200b2 doc: Add a section for the important classes.
The choice is very subjective, but at least they stand out.
2019-06-08 18:13:28 -04:00
Emmanuel Lepage Vallee 74c2e7382e gears: Extract the logic code from awful.rules into gears.matcher.
The use case for this is to reuse the matching logic for other objects
such as tags or notification.
2019-04-05 20:40:53 -04:00
mergify[bot] 710278c4b9
Merge pull request #2654 from psychon/luajit-xpcall
gears.protected_call: Automatically detect xpcall features
2019-02-18 01:42:40 +00:00
mergify[bot] 8563895284
Merge pull request #2663 from psychon/rng_init
Initialise Lua's pseudo-RNG from C from a good source
2019-02-18 01:34:35 +00:00
mergify[bot] fd38e2fb5c
Merge pull request #2658 from psychon/delayed_call_run_now
Add and use gears.timer.run_delayed_calls_now()
2019-02-17 19:25:04 +00:00
Uli Schlachter 3a4bf103b3 Initialise Lua's pseudo-RNG from C from a good source
GLib has an internal pseudo-RNG that it initialises from /dev/urandom.
This commit adds code that uses this RNG to initialise various random
number generators that can be used by Lua.

This also removes some Lua code that initialises the random number
generator badly.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2019-02-17 10:17:47 +01:00
Sorky 4831a46590 Add get_random_file_from_dir to gears.filesystem
Ref #2596
2019-02-16 13:58:24 -05:00
Uli Schlachter 8fdc89ff09 Add and use gears.timer.run_delayed_calls_now()
Signed-off-by: Uli Schlachter <psychon@znc.in>
2019-02-15 17:04:19 +01:00
Uli Schlachter e50fa84f61 gears.protected_call: Automatically detect xpcall features
In Lua 5.1, xpcall() has exactly two arguments: The function to call and
the error handler. Everywhere else, xpcall() passes extra arguments on
to the function to call. This includes LuaJIT, however since LuaJIT sets
_VERSION to "Lua 5.1", so far gears.protected_call used the workaround
for Lua 5.1 here.

This commit switches gears.protected_call to actually test for this
feature instead of just guessing based on _VERSION. Thus, this now also
uses the better code with LuaJIT.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2019-02-15 09:25:06 +01:00
Uli Schlachter 7cb9ec4798 gears.timer: Use gears.debug.print_error (#2647)
Signed-off-by: Uli Schlachter <psychon@znc.in>
2019-02-14 10:21:55 -05:00
Emmanuel Lepage Vallee 9efcf9df87 shape.arc: Prevent an angle underflow when rounded edges are enabled.
Fixes #2604
2019-01-26 12:13:13 -05:00
Emmanuel Lepage Vallee 8757e15d30 gears: Add `find_keys` and `find_first_key` to `gears.table`.
Fills a small gap between keys_filters and hasitem.
2019-01-24 06:31:57 -05:00