Commit Graph

33852 Commits

Author SHA1 Message Date
Benjamin Otte
4c3363b8c2 icontheme: Remove NO_SVG and FORCE_SVG flags
If the icon theme loads SVGs or not is an implementation detail and
should not be exposed in public API.
2020-02-04 16:41:36 +01:00
Benjamin Otte
10023b5d6d icontheme: Remove GTK_ICON_LOOKUP_USE_BUILTIN
It's unused.
2020-02-04 16:41:36 +01:00
Benjamin Otte
bbbe39fb44 icontheme: Make text direction a lookup argument
Most users were just forgetting to set the proper flags.
And flags aren't the right way to set this anyway, it was just
acceptable as a workaround during GTK3 to not break API.
2020-02-04 16:41:36 +01:00
Benjamin Otte
b713b9f68d icontheme: Remove async APIs
Widgets would not use them properly. In fact, the only user was using
them wrong.

As icons are loaded async by default, this call isn't necessary.
2020-02-04 16:41:36 +01:00
Benjamin Otte
bfebc2b01a icontheme: Remove gtk_icon_theme_get_default()
The API encouraged wrong usage - most of the users were indeed wrong.

Use the correct version instead:
  gtk_icon_theme_get_for_display (gtk_widget_get_display ())
2020-02-04 16:41:36 +01:00
Matthias Clasen
b8ffe5b245 css: Fix the initial values optimization
Fix up the index computation. We have duplicate entries
in the type enum, so to go from one of the 'initial' types
to it corresponding type you subtract one, but to find
the size array entry for a type, you divide by 2.
2020-02-04 12:19:23 +01:00
Alexander Larsson
046de4ccbf icon-theme: Only have one copy of the icon flags enum
It turns out with the icon cache now using the virtual SYMBOLIC_PNG_SUFFIX
flag the two enums are now identical, so lets just use one of them, the
one GtkIconCache (so we move it to the header).
2020-02-04 09:35:20 +01:00
Alexander Larsson
308d434b57 GtkIconCache: Remove unused code
We're not really using the icon theme cache much anymore, as the
individual per-directory hashes are no longer used, so delete all the
unused code.
2020-02-03 12:49:32 +01:00
Alexander Larsson
e4170661b9 IconTheme: Make icon lookups faster
Traditionally the icon lookup for a theme has been:

lookup (icon_name, size):
  best_directory = NULL
  forearch theme
    foreach directory in theme
       if dir_size_matches (directory, size) && dir_has_icon (directory, icon-name)
         best_directory = chose_best_size_dir (best_directory, directory)

if best_directory
  return icon from best_directory

However, it turns out that there are a lot of subdirectories which have the same
size, as they differ only in the (essentially useless) "context" value. For example
the "16x16/apps" subdirectory is essentially the same as the "16x16/actions" one.

So, instead rathern than keeping all the directories as separate we store the
all the directories with the same size as a single entity (DirSize) and the
icon lookup in that DirSize looks up not only which suffix to use for that icon
but also which subdir it is in.

Additionally we keep a hashtable with all icon names that are
available in the entire theme (i.e. all DirSizes), which allows use
both to store each icon name only once, but also to do a quick
negative lookup and early exit in case we're looking up an icon that
doesn't exist. This is pretty common because we often look up sets of
icons like "image-png-symbolic", "image-png", "image", expecting some
to fail.

This brings down the time of the initial css validation from 20msec to 15msec for
me when running icon-factory.
2020-02-03 12:49:26 +01:00
Alexander Larsson
0a8d7603ea icon-cache: Add new function to list all the icons in a directory
This lists the icons in a particular director, with their flags in a
hashtable. We also convert from "icon.symbolic" + SUFFIX_PNG to
"icon" + SUFFIX_SYMBOLIC_PNG.
2020-02-03 12:49:26 +01:00
Rico Tzschichholz
4ab12ab755 Remove last GtkWidgetPath reference
See 49b47c9133
2020-02-03 10:51:50 +01:00
Matthias Clasen
621120d1d3 css: Fix an oversight in style change computation
Take the 'color == NULL means currentColor' trick into account
when computing the changes between two styles.
2020-02-02 16:41:14 +01:00
Matthias Clasen
27223f7956 Merge branch 'initial-style' into 'master'
Make it easy to recognize initial style values

See merge request GNOME/gtk!1375
2020-02-01 12:52:44 +00:00
Matthias Clasen
5faf977f66 border: Don't render initial borders
Add a fast exist for comon case that the border
values are unset.
2020-02-01 09:12:12 +01:00
Matthias Clasen
7fbb37a09f background: Don't render initial backgrounds
Add a fast exit for the common case that the background
values are unset.
2020-02-01 09:11:39 +01:00
Matthias Clasen
7027fc9ab6 Make it easy to recognize initial style values
Reuse the type field in GtkCssValues to make initial
style values easily recognizable.
2020-02-01 09:11:22 +01:00
Matthias Clasen
7479564972 modelbutton: Update a11y states
We took care to set the proper role on our accessible object,
but we forgot to update the state for check and radio button
roles.
2020-01-31 19:14:05 +01:00
Matthias Clasen
09612a1b3c filechooser: Remove debug spew 2020-01-31 16:55:01 +01:00
Matthias Clasen
6104c12392 Build fix for GtkCssValues 2020-01-31 11:40:06 +01:00
Matthias Clasen
f140b151e1 Merge branch 'meson-sassc-subproject' into 'master'
build: require sassc and drop generated .css files

See merge request GNOME/gtk!814
2020-01-31 07:26:48 +00:00
Matthias Clasen
a46f9af1c0 Remove primary monitor api
We only have implementations of this on X11 and Win32,
so make it available as backend api there.

Update all callers to use either the backend api, or
just monitor 0.
2020-01-30 21:33:37 +01:00
Christoph Reiter
4071e1e734 build: require sassc and drop generated .css files
Instead of requiring sassc to be installed add meson subprojects
which build libsass and sassc (currently both forks of mine, tested
under linux/mingw/msvc) when needed.

This allows us to drop the generated .css files and build scripts from git.

See #1502
2020-01-30 20:45:38 +01:00
Alexander Larsson
99c89d61e1 Merge branch 'icon-theme-rework' into 'master'
Rework icon themes

See merge request GNOME/gtk!1368
2020-01-30 17:30:10 +00:00
Alexander Larsson
09ef67afbc icon-theme: Add icon theme name in profiler mark 2020-01-30 18:22:11 +01:00
Alexander Larsson
d478ae1ef5 icon-theme: Avoid reentrancy issues while loading icon theme
In gtk_icon_theme_get_for_display() we were calling
gtk_icon_theme_set_display() which eventually (via the css machinery)
called back into gtk_icon_theme_get_for_display() which created a
second icon theme. We avoid this by setting the user-data earlier so
that the css machinery gets back the currently initializing theme
instead.
2020-01-30 18:19:56 +01:00
Alexander Larsson
b67d582230 GtkIconHelper: Preload icons for mapped widgets with higher priority
We look at whether a widget will be mapped (the actual state is not
yet set, so we can't rely on that at css validation time) and use
that to set the i/o priority of the async task.

This means that its likely that widgets that will be displayed soon
are loaded before those that are not yet going to be needed.
2020-01-30 15:41:24 +01:00
Alexander Larsson
498ab6ac6c IconHelper: Only preload icons once
This limits the amount of preloading we to, which can for instance
avoid trashing if the icon cache is full, and in general do less work
when its likely to be wasted such as when e.g. background-color for an
icon helper changes.
2020-01-30 15:17:59 +01:00
Alexander Larsson
c69327caa8 icon-theme: Show which icon loads are threaded in profile mark 2020-01-30 15:16:40 +01:00
Alexander Larsson
d1cd578d59 icon-theme: Add i/o priority to choose_icon_async()
This is set on the GTask and lower priority will be loaded before,
this can be used to prioritize some icons for preloading.
2020-01-30 15:15:08 +01:00
Alexander Larsson
5f8c2b52c6 indentation: fix various alignment issues
Most of these stem from the GtkIconInfo -> GtkIcon rename
2020-01-30 12:27:15 +01:00
Alexander Larsson
27799ba4f5 Remove final references to "icon info" with just "icon" 2020-01-30 10:53:43 +01:00
Alexander Larsson
2ec51b7010 icon-theme: Update the docs 2020-01-30 10:53:43 +01:00
Alexander Larsson
f7cd2a782b Fix warnings in gdk gir build
We now have graphene arguments in a gdk function, so add that to the
dependencies.
2020-01-30 10:53:43 +01:00
Alexander Larsson
ff0642bba6 icon-theme: Remove trailing whitespaces
Since everything is changing anyway lets just clean up all the
trailing whitespace issues in the whole file.
2020-01-30 10:53:43 +01:00
Alexander Larsson
b227a2f190 icon-theme: Use GtkSnapshot, not GdkSnapshot 2020-01-30 10:53:43 +01:00
Alexander Larsson
2b202129bb icon-theme: Fix indentation of matrix values 2020-01-30 10:53:43 +01:00
Alexander Larsson
d1c6d78ebb GtkImage: Preload icons during css validation
At the end of GtkImage css validation (during style-updated) when the
css properties (like the icon size) are valid we call _gtk_icon_helper_preload
which does an async icon theme lookup and load. This will happen on a thread
in parallel with the rest of the css machinery, and hopefully by the
time we need the icon it will be ready. If not we will block when we need
it, but during that blocking all the other icons will be loaded.

Testing widget-factory this changes the time of snapshot() from 31 to
25 msec, but on the other hand we also load a few more icons that we
didn't before causing the css validation phase to be about 8 msec slower.
This is because we're preloading all the images in the window, not only
the ones that are visible.

Unfortunately we still load a bunch of icons in snapshot(), from
GtkCssImageIconTheme, and ideally we should try to preload those also.
2020-01-30 10:53:43 +01:00
Alexander Larsson
6a8001fe7d icon-theme: Preload default icon themes in thread
This happens when we first get the theme for a display, or then the
icon theme setting changes.

This means we don't have to do this scan in the first snapshot
and can do the i/o it in parallel with other stuff. This moves
a 10msec block from the first snapshot cycle to early setup.
2020-01-30 10:53:43 +01:00
Alexander Larsson
ff3e022182 icon helper: Remove profiler mark
This was hitting every time we looked up an icon, and we already
log the actual load of the icon in the icon theme.
2020-01-30 10:53:43 +01:00
Alexander Larsson
d2f26b2f27 icon-theme: Improve profiler mark for icon loads
This adds the actual time it took to them as well as the icon size
and scale.
2020-01-30 10:53:43 +01:00
Alexander Larsson
55db9d07c5 icon-theme: Only add theme load profiler mark if we actually load theme 2020-01-30 10:53:43 +01:00
Alexander Larsson
1be932279c icon theme: Actually use scale in choose_icon_async() 2020-01-30 10:53:43 +01:00
Alexander Larsson
56ec748824 icon theme: Actually don't block in gtk_icon_theme_choose_icon_async()
If some other thread is lock the icon or icon theme locks they are likely
to do so for a long time, doing i/o. So, switch to trylock() for the
nonblocking part of _async(). This way we can return directly if the
result is available, but do a thread otherwise, never blocking the
calling (main) thread.
2020-01-30 10:53:43 +01:00
Alexander Larsson
1e6a82513b icon-theme: Clean up locking
Move the lru cache under the global cache lock to avoid some ABBA
style deadlocks when going from icon_theme->icon lock an icon->icon_theme.
We also move all the icon lock uses to a small part of code and make
sure that code never calls out or blocks with any locks held.

Rename the GtkIcon->cache_lock to texture_lock to avoid confusion withe
the global cache_lock.

Removed any mentions of threadsafety from the API docs, we don't
want apps to rely on this, but rather use it outselves internally.
2020-01-30 10:53:43 +01:00
Alexander Larsson
b087f9ca51 icon-theme: Drop the _for_scale() versions and always take scale 2020-01-30 10:53:43 +01:00
Alexander Larsson
e2f778602b icon-theme: Rename GtkIconInfo to GtkIcon 2020-01-30 10:53:43 +01:00
Alexander Larsson
6a15e9169d Rename GtkIcon widget to GtkBuiltinIcon
This is an internal widget whose name is not very important, and we
want to rename GtkIconInfo to GtkIcon, so lets rename this.
2020-01-30 10:53:33 +01:00
Matthias Clasen
cb60c1b83d builder: Add profiler marks for parsing
This is useful to understand what ui files take
long to load.
2020-01-30 10:04:38 +01:00
Matthias Clasen
ab69d43089 builder: Use a better name for templates
This name can show up in error messages or profiler
traces, so it is nice to provide some hint what
file we are dealing with.
<GtkFileChoser template> is a lot more helpful
than <input>.
2020-01-30 10:04:38 +01:00
Alexander Larsson
6af4b6a644 icon-theme: Drop all load() calls from GtkIconInfo
All users now either use it directly as a paintable or download
the texture to use the pixels.
2020-01-29 19:12:15 +01:00