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.
It's unused since commit 0aa4304bda. Before this was a stable sorting
algorithm since table.sort is allowed to be unstable. Apparently we don't need a
stable sorting algorithm anymore.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Any awful.titlebar.widget.button widget (e.g. floatingbutton or closebutton)
decides on the currently visible symbol based on several factors. One of them is
"is the client currently focused?" and thus the button has to be updated when
the client is focused/unfocused.
The way the code did this was to use client.connect_signal("focus", f) and
client.connect_signal("unfocus", f). However, these signals are never
disconnected and kept alive forever. The callback function had a strong
reference to the client (as an upvalue) and thus this also prevented the client
from being garbage collected.
Fix this by using c:connect_signal("focus/unfocis", f) instead. These kind of
signals are only kept alive by the client object and don't prevent it from being
garbage collected.
This fixes the new test that the previous commit added.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Until now, this layout was "append only". There was no official
APIs to remove, replace, insert and swap widgets. This is fine
for the usual wibox + sensors widget used by the majority of
users, but lack flexibility necessary to use the layout system
to place dynamic elements such as clients.
The methods introduced by this commit are also recursive. This
allow widgets to be decorated, wrapped and splitted without
having to add boilerplate code everywhere.
This remove duplicated code and will allow more "collection"
style layouts to be implemented without logic duplication.
This commit also do some small cleanup to remove duplicated
code now present in `awful.util`.
Fixes https://github.com/awesomeWM/awesome/issues/617
Go around a limitation of the lua language spec. The return value
of this method guaranteed `ipairs()` correctness.
Please note that both the official Lua and Luajit implementation
provide a sparse table compatible `ipairs()` and __len implementation
by default.
It is an internal API and is used by `gears.shape`, `gears.pattern`
and `gears.composition` only.
This commit also add `:rotate_at` and `:copy` methods.
It is necessary to have it beforehand when creating layout objects
for unselected layouts.
In the current layout system, there is no layout object, but to allow
tabs and dynamic tagging features like ion3, layouts cannot be stateless.
Before, it was the caller job to make sure the client wasn't floating.
This limitation is unecessary. awful.client.idx now return nil instead
of an error. awful.rules setting the master width factor are now
foolproof.
This code is imported from Elv13 config and make it very easy
to create shaped objects.
If accepted upstream, other shapes, such as arrow and powerline
will also be added. This commit introsuce the 2 most common
shapes, rounded rectangle and rounded bar.
This allow the most basic kind of stateful layouts to be created.
It is now possible to have layout instances instead of global
stateless layout arrange functions.
This allow layout "arrange" to be called less often and react on
the cause of the change itself rather than it's consequences
(usually, the "focus" signal).
Previously, the layout were re-arranged everytime the focus changed.
Now, with "raised" and "lowered", it require less "arrange".
"swapped" allow smarted layouts. Currently, swapped cause a full
re-arrange. It re-read the "index" list from scratch and create
a "new" layout. With "swapped", incremental layout changes are
possible.
Fixes https://github.com/awesomeWM/awesome/issues/616
gears.surface now returns a fallback image surface that is good enough for what
this code tries to do here.
Signed-off-by: Uli Schlachter <psychon@znc.in>
A nil-value is no longer simply passed through, so this has to do some "special
things" to work properly.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Before this, calling one of the loading functions with a nil argument always
made it return the default 0x0 surface. With this change, the passed-in default
value is now properly applied.
Signed-off-by: Uli Schlachter <psychon@znc.in>
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>
Oh hey, Pango exports an API that allows to query for named colors based on the
famous rgb.txt! Let's use that!
Signed-off-by: Uli Schlachter <psychon@znc.in>
This adds support to gears.color.parse_color to parse things like "#fff" (one
character per color component, without alpha) and "#ffff0000ffff0000" (four
characters per component, with alpha).
This makes sense on its own, but should also help with
https://github.com/awesomeWM/awesome/issues/585.
Signed-off-by: Uli Schlachter <psychon@znc.in>
*WARNING* This introduce a minor API break as awful.tag.setscreen
arguments are now swapped for consistency
This allow to introduce logic for each properties and improve
awful.tag.add and execute logic when setting properties.
The code here doesn't always work, so it's best to just don't mess with
awesome.version, but return it directly.
Fixes: https://github.com/awesomeWM/awesome/issues/569
Signed-off-by: Uli Schlachter <psychon@znc.in>
Since some commits, surface.load_uncached() handles errors itself and thus we
don't have to print an error message here any more.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Previously, a Lua error was thrown when loading a file failed. Most callers are
not prepared for this and the result is less than optimal.
This commit makes the functions print the errors and return nil instead. For
callers that want to handle errors themselves, "_silent" variants of the
functions are introduced which just return errors to the caller.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Having many arguments can easily get confusing and hard to understand. This
commit uses a table instead so that we have names that identify what each
callback does.
Signed-off-by: Uli Schlachter <psychon@znc.in>
This adds functions for getting directories according to the XDG base dir
specification. This might be useful in general.
This also adds a function for getting the cache dir, because I like an explicit
function call more than something which "switches" based on a string argument.
Better error messages if you mis-type something. :-)
Finally, this adds a function for getting the directory containing the rc.lua
file. Sadly, awful.util.getdir("config") did not actually do that. See #218.
Fixes: https://github.com/awesomeWM/awesome/issues/218
Signed-off-by: Uli Schlachter <psychon@znc.in>
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.
Lua will remove objects as values from a weak table before these objects are
finalized, but as values only in the next garbage collection cycle after the
object was finalized. Up to now, gears.object uses a table with weak keys so
that :disconnect_signal() works. This means that a signal can still call methods
which were already considered garbage by the garbage collector and thus can use
userdata from the C side which was already finalized. Crashes and other bugs
result.
This commit changes the code so that the function is also a value in the weak
table. Thus, the GC will remove the entry before the object is finalized.
Special magic is needed for Lua 5.1, because there only userdata has the
behavior that we want while we have a function. We do some magic with function
environments to make this work...
Closes https://github.com/awesomeWM/awesome/pull/567.
Signed-off-by: Uli Schlachter <psychon@znc.in>
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>
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>
This adds support for the callback that was added in the previous commit to this
function. We can just pass on the function that the caller gives us.
Fixes: https://github.com/awesomeWM/awesome/issues/185
Signed-off-by: Uli Schlachter <psychon@znc.in>
This allows scrolling a widget if there is too few space available. There are
several different modes available for how the scrolling "looks like".
Signed-off-by: Uli Schlachter <psychon@znc.in>
This is a weak table whose entries might be removed by the garbage collector.
I'm not sure if this will every cause problems, but it's better to be prepared
for tables having "nil holes" (which would mean ipairs ignores some entries).
Signed-off-by: Uli Schlachter <psychon@znc.in>
The code already tried to handle this correctly, but at some point it used the
wrong variable as the screen number...
Signed-off-by: Uli Schlachter <psychon@znc.in>
Example:
awful.prompt.run({ prompt = "Run: ", hooks = {
{{ },"Return",function(command)
local result = awful.util.spawn(command)
mypromptbox[mouse.screen].widget:set_text(type(result) == "string" and result or "")
return true
end},
{{"Mod1" },"Return",function(command)
local result = awful.util.spawn(command,{sticky=true})
mypromptbox[mouse.screen].widget:set_text(type(result) == "string" and result or "")
return true
end},
{{"Shift" },"Return",function(command)
local result = awful.util.spawn(command,{ontop=true,floating=true})
mypromptbox[mouse.screen].widget:set_text(type(result) == "string" and result or "")
return true
end}
}
},...)
Usually users want a wallpaper on all their screens. With the current code, this
resulted in a loop of upload-wallpaper, {download-wallpaper, add-new-part,
upload-wallpaper}*.
Fix this by being more intelligent: Instead of setting the wallpaper
immediately, this now uses gears.timer.delayed_call() to set the wallpaper. All
following modifications which come in before the delayed call runs will still be
part of the current update. This should mean that during startup, there is just
a single upload of a wallpaper.
(The above is what happens if there is no wallpaper yet. If there is already
one, we use :create_similar() and thus should only upload the part of the
wallpaper that changed, but this doesn't really make a difference.)
As a side-effect, the new code no longer draws to the old wallpaper to modify
it, but always creates a copy of it. This means that:
Fixes https://github.com/awesomeWM/awesome/issues/288.
Closes https://github.com/awesomeWM/awesome/pull/530.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Thanks to the way that X11 works, geometries consider the size of the client
without the border width, but the position of the top-left corner of the border.
This commit adds a new function get_area() which returns the area that is
actually covered by a client. Then, all the code is changed to use this new
function (even the part of the code which did get this border thing correct).
Closes https://github.com/awesomeWM/awesome/pull/541.
Signed-off-by: Uli Schlachter <psychon@znc.in>
None of this code wants to resize clients. Thus, it makes sense to only set the
position of a client and ignore its size.
Also, this sneaks in a fix for no_offscreen which is documented to return the
client's new position, but didn't actually do so.
Signed-off-by: Uli Schlachter <psychon@znc.in>
This makes the timer emit signals for when it is started and stopped. This does
not add a signal for :again(), because that function just calls the other two
functions and thus already emits start and stop.
Signed-off-by: Uli Schlachter <psychon@znc.in>
This changes the code in naughty so that it first decides on a width for the
notification and then uses the new function :get_height_for_width() to find a
suitable height.
This makes a difference in the following example where before this change the
text is cut off and afterwards it is shown completely:
naughty.notify({
text = string.rep("abcdefghijklmnopqrstuvwxyz\n", 4),
width = 75
})
Signed-off-by: Uli Schlachter <psychon@znc.in>
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>
We recently changed the C function screen_getbycoord() and this commit makes
awful.screen.getbycoord() use the same algorithm.
Signed-off-by: Uli Schlachter <psychon@znc.in>
My recent refactoring accidentally made the taglist only connect to the signal
for the first screen on which a taglist is created. This commit fixes the code
so that it connects for all screens.
Fixes https://github.com/awesomeWM/awesome/issues/500
Signed-off-by: Uli Schlachter <psychon@znc.in>
The mouse position is saved and restored when focusing another screen
If the target screen has no saved mouse position, the relative position
of the current screen is used
Signed-off-by: lesell_b <lesell_b@epitech.eu>
* This commit add a new module to avoid a (4 level) loop dependency
* It is now possible to call awful.spawn() with a table of properties
* awful.rules is used to execute the rules.
* Everything is public to allow alternative workflow modules such as
Tyrannical to use their own callback implementation.
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>
I have no idea why this needs collectgarbage() to be called twice.
On the other hand, I can explain the change in tooltip.lua. Lua 5.2 introduced
"ephermeron tables". This means that in the following sitation, lua 5.2 can
collect the entry from the table, while 5.1 keeps the entry alive, because the
table has a strong reference to the value and that in turn has a strong
reference to the key:
t = setmetatable({}, { __mode = "k"})
do
local k = {}
t[k] = function() print(k) end
end
collectgarbage("collect")
print(next(t, nil))
To handle this incompatibility, this commit just removes the whole indirection
through the module-level variable "data".
Signed-off-by: Uli Schlachter <psychon@znc.in>
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>
Again, instead of directly connecting to various signals for updating a
tasklist, this commit changes the code so that there is just a single, global
connections and based on this a weak table with all tasklist instances is used
do the updates.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Similar to what the previous commit does for layoutboxes, this changes the code
for the taglist so that there is only a single, global connection to the various
signals and these update all taglists via weak tables.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Instead of connecting to the needed tag-update-signal again for every layoutbox,
this now just creates a single connection and updates all layoutboxes from here.
A new weak table is used to find the layoutboxes from these callbacks.
Additionally, layoutboxes are now per-screen unique. So even if you try to
create three layoutboxes for screen 1, the code will now always return the same
instance.
This kind-of fixes the leak test for layoutboxes. The problem is that the
default config also creates a layoutbox and adds it to a wibox. Since this is
now the same layoutbox, the test still fails. Just removing the layoutbox-part
from the default config makes this problem go away.
Signed-off-by: Uli Schlachter <psychon@znc.in>
This fixes the textclock-specific part of the test that the previous commit
added.
To fix this, gears.timer.weak_start_new() is used. This function creates a timer
that is automatically stopped when its callback function is garbage collected.
The callback function is saved as a member of the texbox widget that is the
"widget behind the textclock". Thus, the timer can only be stopped after the
widget is garbage-collected, but the timer does not keep the widget alive.
Signed-off-by: Uli Schlachter <psychon@znc.in>
The way of icon path lookup for `menubar` is enhanced so that it is
based on a theme-oriented way as described in the specification:
Icon Theme Specification, Ver. 0.12
http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html
To accomplish this:
* Add the two new files `icon_theme.lua` and `index_theme.lua`.
The former implements an icon lookup algorithm suggested in the URL
above. The latter implements a helper object to parse the cache file
`index.theme` of which data is used by the former.
* Modify `menu_gen.lua` to use the new algorithm.
- The implementation of `lookup_category_icons` is changed
accordingly.
- The values of the field `all_categories.icon_name` are changed file
names to icon names, i.e., file extensions which are used to
indicate image file formats are removed.
* Add the new file `icon_theme_spec.lua` for a unit test for checking
if `icon_theme.lua` together with `index_theme.lua` works as
expected.
When a client is not visible, this would adjust its stacking order
still.
This also addresses https://github.com/awesomeWM/awesome/issues/472,
because it raises unminimized clients after they got focused.
This function updates a hierarchy if the layout of some widgets changed. It does
nothing on the parts that did not change. This should be more efficient than
recomputing the whole hierarchy whenever something changes.
Once again, this has some positive results on the "benchmark test":
Before:
create wibox: 0.083016 sec/iter ( 13 iters, 1.161 sec for benchmark)
update textclock: 0.00391091 sec/iter (271 iters, 3.219 sec for benchmark)
relayout textclock: 0.00273234 sec/iter (397 iters, 1.087 sec for benchmark)
redraw textclock: 0.0010191 sec/iter (989 iters, 1.745 sec for benchmark)
After:
create wibox: 0.083146 sec/iter ( 13 iters, 1.163 sec for benchmark)
update textclock: 0.00170519 sec/iter (647 iters, 2.201 sec for benchmark)
relayout textclock: 0.000581637 sec/iter (1880 iters, 1.094 sec for benchmark)
redraw textclock: 0.0010167 sec/iter (997 iters, 1.773 sec for benchmark)
So again no difference for creating wiboxes (100.16% compared to before). This
time we also have no real difference for creating wiboxes (99.76%). Update (44%)
and relayout (21%) are improved a lot.
Closes https://github.com/awesomeWM/awesome/pull/463.
Signed-off-by: Uli Schlachter <psychon@znc.in>
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>
This has some positive results on the "benchmark test". Each single number is
the best one out of three runs.
Before:
create wibox: 0.0826502 sec/iter ( 13 iters, 1.157 sec for benchmark)
update textclock: 0.0186952 sec/iter ( 57 iters, 2.473 sec for benchmark)
relayout textclock: 0.0158112 sec/iter ( 64 iters, 1.028 sec for benchmark)
redraw textclock: 0.0015197 sec/iter (662 iters, 1.861 sec for benchmark)
After:
create wibox: 0.0825672 sec/iter ( 13 iters, 1.154 sec for benchmark)
update textclock: 0.00378412 sec/iter (277 iters, 4.216 sec for benchmark)
relayout textclock: 0.00259056 sec/iter (420 iters, 1.09 sec for benchmark)
redraw textclock: 0.00105128 sec/iter (958 iters, 1.79 sec for benchmark)
We see no significant change in the creation of wiboxes (99.9% compared to
before). Update (20% of the previous run time), relayout (16%) and redraw (69%)
are all sped up by this change.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Instead of going through LGI to call cairo, this now implements the various
matrix operations directly in Lua. The plan is to avoid the overhead that we hit
due to LGI.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Before this, dependencies between widgets where implicitly discovered by
recursive calls to base.fit_widget() and base.layout_widget(). However, it is
too easy to get this wrong (just call one of these functions from outside of a
widget's :fit() / :layout() function) and the resulting mess would be hard to
debug.
Thus, this commit changes the API so that callers have to identify themselves
and we can explicitly record the dependency between the widgets involved.
This also fixes a bug where no dependencies were tracked for widgets after
:set_visible(false). Whoops...
Sorry for breaking the API for adding this.
Signed-off-by: Uli Schlachter <psychon@znc.in>
This is used by `tooltip.place` then to tie the tooltip to the screen of
the mouse. Without this, a tooltip from the tasklist might get moved to
the screen above the tasklist, if it gets considered to be on that
screen given its coordinates.
Closes https://github.com/awesomeWM/awesome/pull/437.
When a complete repaint is scheduled, also do a relayout, because this is also
the case that we go through when the underlying cairo surface is resized. For
example, resizing a client with a titlebar would trigger this.
Also, going through this code path is necessary since this is the only place
where the dirty area is updated so that it includes "everything". Before this
change, nothing was actually redrawn, because the dirty area was empty.
Fixes: https://github.com/awesomeWM/awesome/issues/449
Signed-off-by: Uli Schlachter <psychon@znc.in>
Extend the range of the 'group_names' patterns which is currently
restricted to typical ones like
pc+us+ru:2+de:3+ba:4+inet
to more general ones such as
macintosh_vndr/apple(alukbd)+macintosh_vndr/jp(usmac)+macintosh_vndr/jp(mac):2
so that the keyboardlayout widget can handles all possible patterns
returned by awesome.xkb_get_layout_group().