Compare commits

...

11 Commits

Author SHA1 Message Date
966d4b164c st/theme-context: Invalidate texture cache when scaling changes 2020-04-03 19:01:08 -03:00
a3cf41734a appDisplay: Set the folder icon geometry through CSS
The CSS engine is scale-aware, whereas simply setting the
width and height properties directly isn't.

Use CSS to set the folder icon.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1176
2020-04-03 18:20:57 -03:00
76811b4ebc st/theme-node: Use the node's scale factor
Each node stores the scale factor in place when it was created.
Creating nodes with the same style, but with different scale
factors, yields different nodes.

Use the node's scale factor instead of retrieving the context's
one.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1176
2020-04-03 18:20:57 -03:00
2721c306af st/theme-node: Consider scale factor when comparing
The CSS engine of St is scale-aware, which means every length
and size it produces is multiplied by the current scale factor.

However, the individual nodes aren't aware of the scale factor
when they compare to each other.

Store and compare the scale factors in the nodes themselves.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/1635

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1176
2020-04-03 18:20:57 -03:00
402fd8ec29 iconGrid: Downscale icon size when comparing to defaults
The return value of st_theme_node_lookup_length() is scaled according
to the scale factor. IconGrid.ICON_SIZE is not. However, when BaseIcon
tries to fetch the CSS value for "icon-size" (which returns a scaled
value), it uses it as-is, mixing the two coordinate systems.

Use a single coordinate system (unscaled sizes) in IconGrid.BaseIcon.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1175
2020-04-03 16:04:40 -03:00
fbe2e30f38 screenShield: Wake up on deactivate()
Usually the screen is woken up before the shield is deactivated, but
it is also possible to unlock the session programmatically via the
org.gnome.ScreenSaver D-Bus API.

The intention is very likely not to unlock a turned off screen in
that case. Nor does it seem like a good idea to change the lock
state without any indication.

Waking up the screen is more likely to meet expectations and is
more reasonable too, so do that.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1158
2020-04-03 14:44:50 +00:00
fb6ead2881 screenShield: Switch lightboxes off before unlock transition
There is no point in animating a transition with fullscreen black
rectangles stacked on top, so switch them off before rather than
after the transition.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1158
2020-04-03 14:44:50 +00:00
7ff7fb5d3b st/icon: Only load default fallback icon if an icon was set and failed to load
Commit c89d6a633 introduced a default fallback icon that would be displayed in
case the main gicon or the fallback gicon wasn't set or failed to load.

This broke the use case where a StIcon is created but no main icon or
fallback icon are set on purpose, for example the appindicator extension
which always creates a StIcon to represent icons in menu items but the
actual icons are only set if the application provides one, leaving the
menu showing the default fallback ("image-missing") icon for all menu
entries that don't actually have an icon provided by the application.

Fix that by only using the default fallback icon if the provided one
failed to load.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1173
2020-04-03 14:28:24 +00:00
8030d9ad32 extensionUtils: Add openPrefs() convenience method
Opening their own preferences is a reasonable desire for extensions,
so make up for breaking it by adding a convenience method for that
action.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1163
2020-04-03 15:27:37 +02:00
45bc850715 extensionSystem: Add method for opening extension prefs
Extension that want to expose their own preferences (for example as menu
items) do that by passing their UUID to gnome-shell-extension-prefs.

But since 3.36.1 the app is optional and no longer accepts arguments on
the command line. To adjust, extensions now need to make a D-Bus call
the extensions portal, just like the app and gnome-shell.

We will add a convenience method for that purpose, so it makes
sense to share the existing code. As it's extension-related, the
extension manager looks like the right place ...

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1163
2020-04-03 15:23:26 +02:00
51a913730e workspace: Fix chaining up
Gah, accidentally dropped the 'vfunc' prefix :-(

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1172
2020-04-03 12:57:01 +00:00
13 changed files with 90 additions and 29 deletions

View File

@ -1,7 +1,7 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
/* exported ExtensionState, ExtensionType, getCurrentExtension,
getSettings, initTranslations, isOutOfDate, installImporter,
serializeExtension, deserializeExtension */
getSettings, initTranslations, openPrefs, isOutOfDate,
installImporter, serializeExtension, deserializeExtension */
// Common utils for the extension system and the extension
// preferences tool
@ -153,6 +153,27 @@ function getSettings(schema) {
return new Gio.Settings({ settings_schema: schemaObj });
}
/**
* openPrefs:
*
* Open the preference dialog of the current extension
*/
function openPrefs() {
const extension = getCurrentExtension();
if (!extension)
throw new Error('openPrefs() can only be called from extensions');
try {
const extensionManager = imports.ui.main.extensionManager;
extensionManager.openExtensionPrefs(extension.uuid, '', {});
} catch (e) {
if (e.name === 'ImportError')
throw new Error('openPrefs() cannot be called from preferences');
logError(e, 'Failed to open extension preferences');
}
}
/**
* versionCheck:
* @param {string[]} required - an array of versions we're compatible with

View File

@ -1376,12 +1376,12 @@ class FolderView extends BaseAppView {
});
layout.hookup_style(icon);
let subSize = Math.floor(FOLDER_SUBICON_FRACTION * size);
let scale = St.ThemeContext.get_for_stage(global.stage).scale_factor;
let numItems = this._orderedItems.length;
let rtl = icon.get_text_direction() == Clutter.TextDirection.RTL;
for (let i = 0; i < 4; i++) {
let bin = new St.Bin({ width: subSize * scale, height: subSize * scale });
const style = 'width: %dpx; height: %dpx;'.format(subSize, subSize);
let bin = new St.Bin({ style });
if (i < numItems)
bin.child = this._orderedItems[i].app.create_icon_texture(subSize);
layout.attach(bin, rtl ? (i + 1) % 2 : i % 2, Math.floor(i / 2), 1, 1);

View File

@ -215,6 +215,24 @@ var ExtensionManager = class {
return true;
}
openExtensionPrefs(uuid, parentWindow, options) {
const extension = this.lookup(uuid);
if (!extension || !extension.hasPrefs)
return false;
Gio.DBus.session.call(
'org.gnome.Shell.Extensions',
'/org/gnome/Shell/Extensions',
'org.gnome.Shell.Extensions',
'OpenExtensionPrefs',
new GLib.Variant('(ssa{sv})', [uuid, parentWindow, options]),
null,
Gio.DBusCallFlags.NONE,
-1,
null);
return true;
}
notifyExtensionUpdate(uuid) {
let extension = this.lookup(uuid);
if (!extension)

View File

@ -114,8 +114,11 @@ class BaseIcon extends St.Bin {
if (this._setSizeManually) {
size = this.iconSize;
} else {
const { scaleFactor } =
St.ThemeContext.get_for_stage(global.stage);
let [found, len] = node.lookup_length('icon-size', false);
size = found ? len : ICON_SIZE;
size = found ? len / scaleFactor : ICON_SIZE;
}
if (this.iconSize == size && this._iconBin.child)

View File

@ -498,6 +498,8 @@ var ScreenShield = class {
if (Main.sessionMode.currentMode == 'unlock-dialog')
Main.sessionMode.popMode('unlock-dialog');
this.emit('wake-up-screen');
if (this._isGreeter) {
// We don't want to "deactivate" any more than
// this. In particular, we don't want to drop
@ -519,6 +521,9 @@ var ScreenShield = class {
this._isModal = false;
}
this._longLightbox.lightOff();
this._shortLightbox.lightOff();
this._lockDialogGroup.ease({
translation_y: -global.screen_height,
duration: Overview.ANIMATION_TIME,
@ -533,8 +538,6 @@ var ScreenShield = class {
this._dialog = null;
}
this._longLightbox.lightOff();
this._shortLightbox.lightOff();
this.actor.hide();
if (this._becameActiveId != 0) {

View File

@ -316,16 +316,7 @@ var GnomeShellExtensions = class {
}
OpenExtensionPrefs(uuid, parentWindow, options) {
Gio.DBus.session.call(
'org.gnome.Shell.Extensions',
'/org/gnome/Shell/Extensions',
'org.gnome.Shell.Extensions',
'OpenExtensionPrefs',
new GLib.Variant('(ssa{sv})', [uuid, parentWindow, options]),
null,
Gio.DBusCallFlags.NONE,
-1,
null);
Main.extensionManager.openExtensionPrefs(uuid, parentWindow, options);
}
ReloadExtensionAsync(params, invocation) {

View File

@ -404,7 +404,7 @@ var WindowClone = GObject.registerClass({
return true;
}
return super.key_press_event(keyEvent);
return super.vfunc_key_press_event(keyEvent);
}
_onClicked() {

View File

@ -418,6 +418,9 @@ st_icon_update (StIcon *icon)
priv->opacity_handler_id = 0;
}
if (priv->gicon == NULL && priv->fallback_gicon == NULL)
return;
if (!st_widget_get_resource_scale (ST_WIDGET (icon), &resource_scale))
return;

View File

@ -1619,3 +1619,18 @@ st_texture_cache_rescan_icon_theme (StTextureCache *cache)
return gtk_icon_theme_rescan_if_needed (priv->icon_theme);
}
/**
* st_texture_cache_invalidate:
* @cache: a #StTextureCache
*
* Invalidates the texture cache, and evicts all icons.
*/
void
st_texture_cache_invalidate (StTextureCache *cache)
{
g_return_if_fail (ST_IS_TEXTURE_CACHE (cache));
st_texture_cache_evict_icons (cache);
}

View File

@ -115,4 +115,6 @@ CoglTexture * st_texture_cache_load (StTextureCache *cache,
gboolean st_texture_cache_rescan_icon_theme (StTextureCache *cache);
void st_texture_cache_invalidate (StTextureCache *cache);
#endif /* __ST_TEXTURE_CACHE_H__ */

View File

@ -176,7 +176,11 @@ st_theme_context_set_property (GObject *object,
int scale_factor = g_value_get_int (value);
if (scale_factor != context->scale_factor)
{
StTextureCache *cache = st_texture_cache_get_default ();
context->scale_factor = scale_factor;
st_texture_cache_invalidate (cache);
st_theme_context_changed (context);
}

View File

@ -117,6 +117,8 @@ struct _StThemeNode {
CoglPipeline *color_pipeline;
StThemeNodePaintState cached_state;
int scale_factor;
};
void _st_theme_node_ensure_background (StThemeNode *node);

View File

@ -219,6 +219,8 @@ st_theme_node_new (StThemeContext *context,
if (theme == NULL && parent_node != NULL)
theme = parent_node->theme;
g_object_get (context, "scale-factor", &node->scale_factor, NULL);
g_set_object (&node->theme, theme);
node->element_type = element_type;
node->element_id = g_strdup (element_id);
@ -345,6 +347,7 @@ st_theme_node_equal (StThemeNode *node_a, StThemeNode *node_b)
node_a->context != node_b->context ||
node_a->theme != node_b->theme ||
node_a->element_type != node_b->element_type ||
node_a->scale_factor != node_b->scale_factor ||
g_strcmp0 (node_a->element_id, node_b->element_id) ||
g_strcmp0 (node_a->inline_style, node_b->inline_style))
return FALSE;
@ -396,6 +399,7 @@ st_theme_node_hash (StThemeNode *node)
hash = hash * 33 + GPOINTER_TO_UINT (node->context);
hash = hash * 33 + GPOINTER_TO_UINT (node->theme);
hash = hash * 33 + ((guint) node->element_type);
hash = hash * 33 + ((guint) node->scale_factor);
if (node->element_id != NULL)
hash = hash * 33 + g_str_hash (node->element_id);
@ -975,9 +979,7 @@ get_length_from_term (StThemeNode *node,
} type = ABSOLUTE;
double multiplier = 1.0;
int scale_factor;
g_object_get (node->context, "scale-factor", &scale_factor, NULL);
if (term->type != TERM_NUMBER)
{
@ -992,7 +994,7 @@ get_length_from_term (StThemeNode *node,
{
case NUM_LENGTH_PX:
type = ABSOLUTE;
multiplier = 1 * scale_factor;
multiplier = 1 * node->scale_factor;
break;
case NUM_LENGTH_PT:
type = POINTS;
@ -1123,14 +1125,10 @@ get_length_from_term_int (StThemeNode *node,
{
double value;
GetFromTermResult result;
int scale_factor;
result = get_length_from_term (node, term, use_parent_font, &value);
if (result == VALUE_FOUND)
{
g_object_get (node->context, "scale-factor", &scale_factor, NULL);
*length = (int) ((value / scale_factor) + 0.5) * scale_factor;
}
*length = (int) ((value / node->scale_factor) + 0.5) * node->scale_factor;
return result;
}
@ -3012,7 +3010,6 @@ StBorderImage *
st_theme_node_get_border_image (StThemeNode *node)
{
int i;
int scale_factor;
if (node->border_image_computed)
return node->border_image;
@ -3021,7 +3018,6 @@ st_theme_node_get_border_image (StThemeNode *node)
node->border_image_computed = TRUE;
ensure_properties (node);
g_object_get (node->context, "scale-factor", &scale_factor, NULL);
for (i = node->n_properties - 1; i >= 0; i--)
{
@ -3126,7 +3122,7 @@ st_theme_node_get_border_image (StThemeNode *node)
node->border_image = st_border_image_new (file,
border_top, border_right, border_bottom, border_left,
scale_factor);
node->scale_factor);
g_object_unref (file);
@ -3967,6 +3963,9 @@ st_theme_node_geometry_equal (StThemeNode *node,
g_return_val_if_fail (ST_IS_THEME_NODE (other), FALSE);
if (node->scale_factor != other->scale_factor)
return FALSE;
_st_theme_node_ensure_geometry (node);
_st_theme_node_ensure_geometry (other);