Commit Graph

263 Commits

Author SHA1 Message Date
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
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
Daniel Hahler 25fca23772 doc: revisit gears.table 2019-01-03 17:13:40 +01:00
Emmanuel Lepage Vallee 6ca970395c doc: Merge gears.object and gears.object.properties
The `properties` submodule is almost for private use anyway. It is
not worth poluting the API index for it.
2018-12-31 17:50:37 -05:00
mergify[bot] bf50daf94e
Merge pull request #2182 from blueyed/doc-gtable-iterate
doc: improve gears.table.iterate
2018-11-12 16:40:53 +00:00
Uli Schlachter 4744a744f0 gears.table.join: Ignore nil arguments (#2440)
When calling join with e.g. arguments (nil, {"a"}), then everything past
the nil was ignored, because the code internally used ipairs() to
iterate over the arguments and this stops at the first nil it
encounters.

Fix this by using select() to iterate over the arguments.

This also adds a unit test for this problem.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-10-16 10:17:45 -04:00
Emmanuel Lepage Vallee da68b3cbaf table.join: Make deterministic.
`pairs` order isn't defined and `{...}` will always be ordered.
There is no reason to have random behavior where it can be
predicted at no additional cost.
2018-10-01 14:57:55 -04:00
Uli Schlachter 3927dbcf02 Fix incorrect @name annotation in gears.string
gears.string.xml_escape was annotated with "@name escape" and
gears.string.xml_unescape was annotated with "@name unescape".

Reference: https://github.com/awesomeWM/awesome/issues/2397#issuecomment-424630100
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-09-26 10:37:59 +02:00
Emmanuel Lepage Vallee 106fba6dd6 timer: Add a reminder to apply the existing naming conventions
Not now because changing things for the sake of changing things in
a point release is a bad idea, but eventually.
2018-08-06 19:03:25 -04:00
Emmanuel Lepage Vallée 25adaae594
Merge pull request #2266 from ZipFile/fix-no_overlap
Improve no_overlap placement
2018-06-26 10:05:49 -04:00
Emmanuel Lepage Vallee c6491e169c doc: Remove the signal name hack 2018-05-28 14:11:41 -04:00
Anatolii Aniskovych da418b56ab gears.geometry: Make area_intersect_area() public 2018-05-19 00:08:19 +03:00
Uli Schlachter 675900407a Deprecate gears.filesystem.get_dir
It is a useless thin wrapper around other functions. It's better to use
these other functions directly.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-03-11 16:08:07 +01:00
Emmanuel Lepage Vallée aabff6dac7
Merge pull request #1487 from Elv13/fix_1482
Add an awful.rules chain of responsibility
2018-03-04 16:42:05 -05:00
Emmanuel Lepage Vallee 4e0915674d gears: Add a new sort module
The first use case is a topological sort to handle dependency graphs

Closes #2159
2018-03-04 01:29:33 -05:00
Emmanuel Lepage Vallee 45135b28b1 shims: Use cairo PNG support instead of GDK
It is inferior, but at least doesn't print warnings on Travis due
to the lack of X server.
2018-02-25 18:01:08 -05:00
Uli Schlachter b2d1e8574f Merge branch 'gdkpixbuf' of https://github.com/psychon/awesome 2018-02-17 13:26:23 +01:00
Daniel Hahler c5f2aa8e83 doc: improve gears.table.iterate 2018-02-07 21:49:16 +01:00
Uli Schlachter 28e8894f05 Give the docs for gears.color some improvements
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-01-22 11:53:39 +01:00
Uli Schlachter 0864829c0a Add some introductionary documentation to gears.wallpaper
Related-to: https://github.com/awesomeWM/awesome/issues/1373
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-01-22 11:22:05 +01:00
Uli Schlachter ee944f4da8 gears.surface: Use GdkPixbuf
This now does directly what previously awesome.load_image() did. Also,
this commit removes the only caller of awesome.load_image(), so that
function could (in theory) be removed now.

Fixes: https://github.com/awesomeWM/awesome/issues/1235
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-01-18 18:19:07 +01:00
Uli Schlachter 8cc469322f ensure_pango_color: Support hex values with alpha
Reference: https://github.com/awesomeWM/awesome/pull/2129#discussion_r155397507
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-01-13 02:15:30 +01:00
necauqua aa64978c31
Add call_now argument to gears.timer 2017-10-31 18:24:53 +02:00
Daniel Hahler 03580db5bb Merge pull request #2015 from Elv13/doc_tests_and_notif_p1_5
object: Add support for signal forwarding
2017-10-21 19:20:41 +02:00
Emmanuel Lepage Vallee ce3be7ca1b object: Add support for signal forwarding
The CAPI signal system already has this mechanism.
2017-08-19 22:52:08 -04:00
Kevin Zander 5d0e9fd9e3 Add startswith and endswith function to gears.string, change awful.completion to use startswith over local function 2017-08-14 10:48:12 -05:00