Commit Graph

2481 Commits

Author SHA1 Message Date
Andre Moreira Magalhaes
343b3351f1 app-cache: Fix cache for folder translations
The app-cache code currently stores the folder translations in a hash
that can be accessed via shell_util_get_translated_folder_name().
This hash uses the filename (inc. extension) for the "desktop-directory"
as key which causes an issue when trying to find the translation
on AppDisplay._findBestFolderName() which gets categories (folder names)
from the app info which doesn't contain the ".directory" extension.

Fix that by storing the filename without extension as the hash key for
the cached folder translations.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1168
2020-04-02 20:37:20 +00:00
Florian Müllner
6d3c740b37 st/entry: Unset key focus when made unreactive
It seems reasonable that an entry shouldn't allow entering text when not
reactive. The same could be achieved by changing the text's :editable
property, however that will disable scrolling if the text doesn't fit,
which may result in an unwanted size change.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/2423
2020-03-29 22:12:57 +02:00
Florian Müllner
34c4627db9 st/entry: Bind ClutterText reactivity to entry
The text is part of the entry, so it is surprising that it can
still be edited when the entry itself isn't reactive. Address
this by setting up a binding instead of expecting all consumers
to handle the case themselves.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/2423
2020-03-29 22:12:57 +02:00
Florian Müllner
b08b125df6 st/entry: Remove unused macro
https://gitlab.gnome.org/GNOME/gnome-shell/issues/2423
2020-03-29 22:12:57 +02:00
Carlos Garnacho
656168543f st: Honor alpha range specified by pango_attr_foreground_alpha_new()
This is documented as a value between 1 and 65536. However we were passing
a 0 value for 100% transparent colors, which is interpreted as "system
inherited" in pango_renderer_get_alpha() docs.

Ensure we respect this range by specifying the minimum allowed alpha (1)
if the color is fully transparent. If someone notices this 1/65535th change
I'll ask him how many pleiades can he count.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2504

(yes, again).
2020-03-28 16:58:30 +00:00
Carlos Garnacho
73472ba6a7 st: Forward CSS foreground alpha as a PangoAttribute to text
Let the PangoRenderer handle this.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2504
2020-03-27 22:47:48 +00:00
Jonas Dreßler
91748aedb7 blur-effect: Handle failure of background blitting gracefully
`paint_background` already provides a return value in case the blitting
of the framebuffer fails, handle that and fall back to only drawing the
actor in case something goes wrong.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/1000
2020-03-27 22:31:57 +00:00
Jonas Dreßler
4783d767d6 blur-effect: Properly clear background framebuffer
We want to completely clear the background framebuffer when switching
back to ACTOR mode to make sure the `background_fb.framebuffer` check
will fail in `update_background_fbo` when switching to BACKGROUND mode
again. Otherwise the checks in `update_background_fbo` will return TRUE
and we will keep using the background framebuffer that was created
before switchig to ACTOR mode.

While at it, also clear the background framebuffer completely when
changing the actor to avoid the same issue here.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/1000
2020-03-27 22:31:57 +00:00
Jonas Dreßler
dedbf0cb09 blur-effect: Fix framebuffer sizes when stage-view scaling is used
When blurring only the actor (ACTOR mode), we don't want to apply any
scale, it looks fine without using the resource scale and it also seems
like `clutter_actor_continue_paint` in `paint_actor_offscreen` only
draws an unscaled texture anyway (ie. if the resource scale is 2, only a
quarter of the framebuffer is being drawn to).

In BACKGROUND mode though, we need to scale the framebuffer using the
scale factor of the stage view (ie. the final scale factor for the
monitor) because the content of the framebuffer we blit is scaled using
that factor. Also, since the framebuffer we blit belongs to a stage view
and only includes the contents of this view, we need to adjust the
stage-coordinates of the actor to be relative to the stage-view.

To make sure we don't have to get the transformed actor size or position
multiple times during one paint-run and don't have to carefully floor()
or ceil() widths and positions, store the size of the actor (which is
also the size of the framebuffer) and its position relative to the stage
view inside a ClutterActorBox.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/1000
2020-03-27 22:31:56 +00:00
Jonas Dreßler
e5b7462b94 blur-effect: Don't check whether effect is enabled when painting
A ClutterEffect is being painted as part of the paint cycle of
ClutterActor, where _clutter_effect_paint() is called before painting
the actual actor. With that, it's impossible that an effect gets painted
while it's disabled, so remove the check whether the ClutterActorMeta is
enabled before painting.

Also if everything works fine in Clutter, the ClutterActorMeta should
have an actor set and we've been notified about that actor in
shell_blur_effect_set_actor(), so assert that our cached actor is set
when painting the effect.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/1000
2020-03-27 22:31:56 +00:00
Jonas Dreßler
48b0a91385 blur-effect: Fix alignment of function arguments
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/1000
2020-03-27 22:31:56 +00:00
Florian Müllner
c89d6a633a st/icon: Add a default fallback icon
The idea behind commit 3dd8ffc2bb to try harder to avoid empty
icon actors because of missing icons was sound, so implement that
behavior in StIcon itself:

If the main gicon was not found, and the fallback gicon isn't set or
wasn't found either, fall back to the standard 'missing-image' icon.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1127
2020-03-26 18:36:02 +00:00
Florian Müllner
fecc0c06ac Revert "texture-cache: Use image-missing image when no other icon was loaded"
The commit broke StIcon's :fallback-gicon property, as it relies on failure to load
an icon to determine that the fallback should be shown.

Luckily StIcon is the only user of st_texture_cache_load_gicon() (at least in
regular shell code), so we'll be able to implement the 'image-missing' fallback
there.

This reverts commit 3dd8ffc2bb.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1127
2020-03-26 18:36:02 +00:00
Florian Müllner
f52574bd28 shell/util: Add touch_file_async() helper
Add a small helper method to asynchronously "touch" a file and return
whether the file was created or not.

As g_file_make_directory_with_parents() doesn't have an async variant,
we need a C helper to make the entire operation non-blocking.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/2432
2020-03-25 20:03:01 +00:00
Carlos Garnacho
66c4b1a8b6 st: Apply css foreground color to text as a PangoAttribute
Rely on the Pango renderer handling this properly, instead of tinting
the full ClutterText in the color specified through css.

Also set the caret color explicitly, since it used to be set as a side
effect of clutter_text_set_color(), but no longer is.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/issues/850
2020-03-25 11:18:30 +00:00
Florian Müllner
35484151ce shell/screenshot: Throw error on failure
Commit da537cda43 moved the Shell.Screenshot API to GIO's async pattern,
but we never set the GError passed to the *_finish() functions and only
indicate failure by returning FALSE.

The expected behavior is to throw an error in that situation, so make sure
we do that.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1123
2020-03-24 11:29:53 +00:00
Florian Müllner
1bccbe7f11 shell/screenshot: Remove unnecessary NULL check
Since commit be5f5ec9d4, the output stream is created externally and
expected to be non-NULL, so the check is now pointless (in particular
*after* calling g_object_ref() on the stream).

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1123
2020-03-24 11:29:53 +00:00
Florian Müllner
b4162afa65 shell/screenshot: Check preconditions of public API
It's good practice to guard public API against programmer errors,
so add the usual g_return*_if_fail() calls.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1123
2020-03-24 11:29:53 +00:00
Mario Sanchez Prada
3dd8ffc2bb texture-cache: Use image-missing image when no other icon was loaded
If a given icon is not available for neither the current theme nor any
of the fallback options (default theme -"Adwaita", "gnome"...), the
call to gtk_icon_theme_lookup_by_gicon() will return a NULL value, which
returned by the Shell Toolkit as is, causing trouble in the Shell's JS
code when calling shell_app_create_icon_texture() to create an icon.

To at least mitigate the chances of this having this issue happening, we
should at least try to load the standad 'image-missing' icon from the
Icon Naming Specification spec when we receive a NULL here, so that
at least we try to show something to the user, even if it's ugly.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/1121
2020-03-23 13:50:06 -03:00
Jan Tojnar
7cd37a4017 build: Add missing dependency to run-js-test
run-js-test requires girepository.h header file which is provided
by gobject-introspection. gobject-introspection is required by gjs,
another of our dependencies, so, usually, the header gets included
by inheriting the cflags from there but some distros interpret
pkg-config fields more strictly[1] so that will not be the case there.

Listing direct dependencies explicitly is a good practice any way
so let’s do that.

[1]: https://bugs.freedesktop.org/show_bug.cgi?id=105572

https://bugzilla.gnome.org/show_bug.cgi?id=787864
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1114
2020-03-21 02:58:17 +00:00
Florian Müllner
e572d5d08c extensionPrefs: Use imports.package.start()
We want to make the extensions app code more self-contained to make it
easier to build separately, and ultimately make it available on flathub.

One complication we are facing is that it is currently all over the source
tree:
 - js/extensionPrefs for the main code
 - src for the launcher process
 - data for .desktop file and icons

Switching from a C launcher to the imports.package module allows us to
consolidate the first two, and will also take care of the annoying
setup bits (defining JS search path, extending GI lookup, loading
resources).

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1081
2020-03-19 14:27:35 +00:00
Florian Müllner
ea1adea24d shell/network-agent: Wrap nm_plugin_info_new_search_file()
While we can use the libnm API directly from JS, the call will
synchronously load the VPN service descriptions from disk.
Previously we were lowering the impact by caching the result,
but as we stopped doing that, it becomes more important to address
the issue properly and move it off to a thread.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/2386
2020-03-17 14:07:15 +00:00
Florian Müllner
1aff64a38b main: Stop owning the public org.freedesktop.Notifications name
For sandboxed apps, permission to talk to org.freedesktop.Notifications
looks innocent enough. However as all exported services share the same
connection to the session bus, that permission actually grants an app
access to *any* shell D-Bus API.

While we want apps to use the notification portal, it is still common
for apps to use libnotify, raw D-Bus calls or even notify-send.

We don't want to give those apps a way to circumvent most of the sandbox
restrictions, so stop owning the org.freedesktop.Notifications name.

In a next step we will implement a separate notification-daemon that
exposes the API on the well-known address and proxies any requests to
the real implementation in gnome-shell.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/547
2020-03-12 16:09:27 +00:00
Christian Hergert
f8db5aa106 app-cache: add ShellAppCache for GAppInfo caching
This caches GAppInfo so that the compositor thread does not have to perform
costly disk access to load them. Instead, they are loaded from a worker
thread and the ShellAppCache notifies of changes.

To simplify maintenance, ShellAppCache manages this directly and the
existing ShellAppSystem wraps the cache. We may want to graft these
together in the future, but now it provides the easiest way to backport
changes to older Shell releases.

Another source of compositor thread disk access was in determining the
name for an application directory. Translations are provided via GKeyFile
installed in "desktop-directories". Each time we would build the name
for a label (or update it) we would have to load all of these files.

Instead, the ShellAppCache caches that information and updates the cache
in bulk when those change. We can reduce this in the future to do less
work, but chances are these will come together anyway so that is probably
worth fixing if we ever come across it.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/2282
2020-03-11 18:06:15 -07:00
Carlos Garnacho
b18469427e St: Ensure to update entry hint visibility with IM preedit
Commit 88ac339774 changed StEntry behavior so the text hint would
stay visible while focused, as long as the text buffer is empty.
However, IMs that use preedit still should count as "started typing",
while the text buffer is still officially empty.

To fix this, check on st_entry_update_hint_visibility() that there's
indeed no preedit buffer before showing the hint. We can't directly
listen to internal preedit buffer changes in ClutterText, so handle
preedit buffer updates through the ::cursor-changed signal that will
be indirectly emitted.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1084
2020-03-11 14:07:07 +01:00
Sebastian Keller
1b872c1195 st/texture-cache: Fix invalid memory write related to X11 window icons
st_texture_cache_bind_weak_notify calls g_clear_signal_handler which
then calls st_texture_cache_free_bind. st_texture_cache_free_bind frees
the bind structure, so by the time g_clear_signal_handler tries to write
bind->notify_signal_id, bind has already been freed.

Fix this by using g_signal_handler_disconnect instead.

This partially reverts 135d178d08

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/issues/2334
2020-03-09 17:34:56 +00:00
Sebastian Keller
c05098cd12 st/password-entry: Fix peek icon leak
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1078
2020-03-08 23:51:55 +01:00
Florian Müllner
bf367daaba build: Fix some harmless compiler warnings
Some (newer?) GCC versions complain when a g_auto variable isn't
initialized when declared, even when the initialization is guaranteed
to happen before the variable is used or goes out of scope.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/2298
2020-03-08 00:34:36 +00:00
Florian Müllner
4ff94f80a0 shell/tray-manager: Delay managing screen if necessary
Now that Xwayland startup is asynchronous, the function may be called
before X11 is available, resulting in a crash.

Fix this by only managing the tray immediately if we already have an
X11 display, and wait for it to be set up otherwise.

Likewise, unmanage the screen when X11 becomes unavailable.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/2308
2020-03-06 18:45:21 +00:00
Florian Müllner
e6d4581959 shell/tray-manager: Allow to unmanage screen
Since support for legacy status icons is implemented by extensions
nowadays, they need to undo the call to manage_screen() when they
are disabled.

Right now that means bypassing garbage collection with an explicit
call to run_dispose() on the Shell.TrayManager. That works, but is
rather ugly.

An explicit unmanage_screen() method is a nicer option, and will be
useful to us as well to deal with X11 going away (once Xwayland
crashes don't bring down the entire session).

https://gitlab.gnome.org/GNOME/gnome-shell/issues/2308
2020-03-06 18:45:21 +00:00
Florian Müllner
07bbcb1b48 shell/tray-manager: Only create resources when needed
NaTrayManager in particular is deeply tied to X11. We currently assume
that X11 support is always available, but that is already not true
anymore - Xwayland startup is now asynchronous.

It will be even less true once we handle Xwayland crashes gracefully.

Start addressing that by not creating the corresponding resources once
and assume they exist for the lifetime of Shell.TrayManager, but make
sure they exist when actually needed.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/2308
2020-03-06 18:45:21 +00:00
Christian Hergert
d0226c7897 shell: fix typo in comment
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/1050
2020-02-26 19:00:05 -08:00
Christian Hergert
19e084036a global: force fsync() to worker thread when saving state
The g_file_replace_contents_async() API can potentially call fsync() from
the thread calling into it upon completion. This can have disasterous
effects when run from the compositor main thread such as complete stalls.

This is a followup to 86a00b6872 which
assumed (like the rest of us) that the fsync() would be performed on the
thread that was doing the I/O operations.

You can verify this with an strace -e fsync and cause terminal to display
a command completed notification (eg: from a backdrop window).

This also fixes a lifecycle bug for the variant, as
g_file_replace_contents_async() does not copy the data during the operation
as that is the responsibility of the caller. Instead, we just use a GBytes
variant and reference the variant there.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/1050
2020-02-26 15:33:30 -08:00
Florian Müllner
cc3f439323 calendar-server: Remove unused defines
The file doesn't contain any translatable strings, so the i18n
macros are unused.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/1016
2020-02-26 22:53:00 +00:00
Christian Hergert
24a3fd4c4d st: implement ClutterActorClass.has_accessible()
Implement ClutterActorClass.has_accessible() to ensure that CallyActor does not
recreate accessibles during the removal/destruction of an actor.  This relies
on GNOME/mutter!1083 for the ClutterActorClass.has_accessible virtual function.

Running GNOME Shell for about 30 seconds results in a difference between
the two runs.

Before:

    ALLOCATED      TOTAL    FUNCTION
[   52.2 KiB] [   0.05%]    cally_actor_real_remove_actor
[   36.3 KiB] [   0.04%]      st_widget_get_accessible
[    9.8 KiB] [   0.01%]      atk_gobject_accessible_for_object
[    3.2 KiB] [   0.00%]      g_signal_emit_by_name
[    2.9 KiB] [   0.00%]      clutter_actor_get_children

After:

    ALLOCATED      TOTAL    FUNCTION
[    1.8 KiB] [   0.00%]    cally_actor_real_remove_actor
[    1.1 KiB] [   0.00%]      clutter_actor_get_children
[  659 bytes] [   0.00%]      g_signal_emit_by_name

Obviously 50KiB isn't a huge savings.

Although fixing things to avoid re-entrancy on destruction can be very useful
from a correctness standpoint.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/issues/2263
2020-02-24 22:20:26 +00:00
Florian Müllner
120b907c33 shell/stack: Ignore hidden children for focus navigation
ShellStack implements custom focus navigation, and will only ever
navigate into its top-most child. That kind of makes sense as long
as that child is actually visible, but not when it is hidden.

Descend into the stack to look for a focusable child instead.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/2210
2020-02-24 12:29:44 +00:00
Florian Müllner
574ab04e9f st/texture-cache: Heap-allocate saved scales
Otherwise we end up reading random junk later, with the result that
we fail to evict textures with scaled keys.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/2244
2020-02-20 23:06:58 +01:00
Jonas Ådahl
f4f8982825 st/settings: Add API to inhibit animations
There may be situations where we shouldn't enable animations. Make it
possible for the Shell to decide when there are such situations and in
when needed inhibit animations.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/757
2020-02-20 11:14:55 +00:00
Jonas Ådahl
7220f6d25b shell-util: Add API to check for X11 extensions
Will be used to disable animations when running inside Xvnc. This was
done in gsd-xsettings before.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/757
2020-02-20 11:14:55 +00:00
Jonas Dreßler
7c8ed95330 blur-effect: Remove modify_paint_volume vfunc override
If we modify the paint volume to make it larger and include the blur
radius, we should also use the gained size and draw something there.
Since the framebuffers are only the size of the actor to blur, we're not
doing that right now anyway, so remove the vfunc override.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/991
2020-02-12 11:11:02 -03:00
Jonas Dreßler
f351cfa2f7 blur-effect: Use sigma value instead of blur radius
Almost all implementations, including CSS [1] of gaussian blurs use the
sigma/standard deviation value as the input parameter, even if they call
that value "radius". Since using sigma is more correct mathematically
and avoids confusion for people used to other blur implementations, use
that parameter here, too.

[1] https://www.w3.org/TR/filter-effects-1/#funcdef-filter-blur

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/991
2020-02-12 11:10:38 -03:00
Jonas Dreßler
d26bb38be9 blur-effect: Implement incremental calculation of gauss coefficient
Use the shader for linear sampling and incremental calculation of the
gaussian kernel values as it was implemented by Patrick Walton in
webrender.

The sigma value for the blur (the standard deviation) is calculated by
taking the blur radius and dividing it by 3, this value is used by most
implementations of gaussian blurs since it covers a high percentage of
the gaussian shape.

The linear sampling optimization is implemented by skipping every second
texel (i += 2) in the for-loop that's sampling adjacent texels.

https://github.com/servo/webrender/blob/master/webrender/res/cs_blur.glsl
38ec7db6f1

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/991
2020-02-12 11:07:55 -03:00
Jonas Dreßler
b75e61d5c8 blur-effect: Only apply paint opacity once when blurring actor
We don't want to apply the opacity multiple times, because this would
also multiply the opacity we're applying.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/991
2020-02-12 14:02:28 +00:00
Jonas Dreßler
ca35ae4364 blur-effect: Only apply paint opacity to actor blur
We don't want to apply the opacity of the actor when blurring the
background.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/991
2020-02-12 14:02:28 +00:00
Jonas Dreßler
f6fa08fa75 blur-effect: Don't paint background using actor opacity
The background should always be painted fully opaque, the opacity of the
actor does not change the one of the background.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/991
2020-02-12 14:02:28 +00:00
Jonas Dreßler
46f94241eb blur-effect: Use int for opacity override
The opacity override can be -1 if no override is set, so use the
appropriate datatype here.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/991
2020-02-12 14:02:28 +00:00
Jonas Dreßler
ea2ddaa9dd blur-effect: Floor downscaled frambuffer sizes
Floor the downscaled size of the new framebuffer to make sure we don't
initialize a framebuffer with a floating point value that might be
interpreted wrong by `cogl_texture_2d_new_with_size` and end up with a
slightly wrong aspect ratio of the framebuffer.

This fixes situations where the widths or heights of downscaled
framebuffers sometimes miss some pixels at the border.

While at it, remove the `downscale_factor` argument from
`setup_projection_matrix` since that function doesn't need the initial
size of the actor anyway.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/991
2020-02-12 14:02:28 +00:00
Jonas Dreßler
b4d491a4d2 blur-effect: Add some more documentation about performance
Explicitly mention that this effect works best for large blur radii and
can be slow if the blurred actor/image is large and not being scaled.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/991
2020-02-12 14:02:28 +00:00
Jonas Dreßler
463dcc6b93 blur-effect: Fix crash when switching to ACTOR mode
The `clear_framebuffer()` function takes a CoglFramebuffer, not a
FramebufferData object.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/991
2020-02-12 14:02:28 +00:00
Sebastian Keller
7287ee3651 texture-cache: Fix invalid reads when storing used resource scales
The used_scales hash table uses g_double_hash and g_double_equal which
try to read a double from the passed pointers. The pointers however were
pointing to a float, leading to an invalid read.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/974
2020-02-06 19:47:24 +00:00