Compare commits

..

1 Commits

Author SHA1 Message Date
Simon McVittie
5a83f003c7 blur: Always allocate at least one pixel
This works around a crash when we try to blur a background that hasn't
yet had any space allocated for it, in particular when locking the screen
with mutter 3.36.1 and the Native Window Placement extension.

Workaround for <https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2538>.

Signed-off-by: Simon McVittie <smcv@debian.org>
2020-04-03 10:04:26 +01:00
14 changed files with 41 additions and 90 deletions

View File

@@ -1,7 +1,7 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
/* exported ExtensionState, ExtensionType, getCurrentExtension,
getSettings, initTranslations, openPrefs, isOutOfDate,
installImporter, serializeExtension, deserializeExtension */
getSettings, initTranslations, isOutOfDate, installImporter,
serializeExtension, deserializeExtension */
// Common utils for the extension system and the extension
// preferences tool
@@ -153,27 +153,6 @@ 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++) {
const style = 'width: %dpx; height: %dpx;'.format(subSize, subSize);
let bin = new St.Bin({ style });
let bin = new St.Bin({ width: subSize * scale, height: subSize * scale });
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,24 +215,6 @@ 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,11 +114,8 @@ 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 / scaleFactor : ICON_SIZE;
size = found ? len : ICON_SIZE;
}
if (this.iconSize == size && this._iconBin.child)

View File

@@ -498,8 +498,6 @@ 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
@@ -521,9 +519,6 @@ var ScreenShield = class {
this._isModal = false;
}
this._longLightbox.lightOff();
this._shortLightbox.lightOff();
this._lockDialogGroup.ease({
translation_y: -global.screen_height,
duration: Overview.ANIMATION_TIME,
@@ -538,6 +533,8 @@ var ScreenShield = class {
this._dialog = null;
}
this._longLightbox.lightOff();
this._shortLightbox.lightOff();
this.actor.hide();
if (this._becameActiveId != 0) {

View File

@@ -316,7 +316,16 @@ var GnomeShellExtensions = class {
}
OpenExtensionPrefs(uuid, parentWindow, options) {
Main.extensionManager.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);
}
ReloadExtensionAsync(params, invocation) {

View File

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

View File

@@ -360,6 +360,18 @@ update_fbo (FramebufferData *data,
float new_width = floorf (width / downscale_factor);
float new_height = floorf (height / downscale_factor);
if (G_UNLIKELY (new_width < 1.0f))
{
g_warning ("%s: Correcting width from %f to 1", G_STRLOC, new_width);
new_width = 1.0f;
}
if (G_UNLIKELY (new_height < 1.0f))
{
g_warning ("%s: Correcting height from %f to 1", G_STRLOC, new_height);
new_height = 1.0f;
}
data->texture = cogl_texture_2d_new_with_size (ctx, new_width, new_height);
if (!data->texture)
return FALSE;

View File

@@ -418,9 +418,6 @@ 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,18 +1619,3 @@ 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,6 +115,4 @@ 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,11 +176,7 @@ 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,8 +117,6 @@ struct _StThemeNode {
CoglPipeline *color_pipeline;
StThemeNodePaintState cached_state;
int scale_factor;
};
void _st_theme_node_ensure_background (StThemeNode *node);

View File

@@ -219,8 +219,6 @@ 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);
@@ -347,7 +345,6 @@ 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;
@@ -399,7 +396,6 @@ 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);
@@ -979,7 +975,9 @@ 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)
{
@@ -994,7 +992,7 @@ get_length_from_term (StThemeNode *node,
{
case NUM_LENGTH_PX:
type = ABSOLUTE;
multiplier = 1 * node->scale_factor;
multiplier = 1 * scale_factor;
break;
case NUM_LENGTH_PT:
type = POINTS;
@@ -1125,10 +1123,14 @@ 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)
*length = (int) ((value / node->scale_factor) + 0.5) * node->scale_factor;
{
g_object_get (node->context, "scale-factor", &scale_factor, NULL);
*length = (int) ((value / scale_factor) + 0.5) * scale_factor;
}
return result;
}
@@ -3010,6 +3012,7 @@ StBorderImage *
st_theme_node_get_border_image (StThemeNode *node)
{
int i;
int scale_factor;
if (node->border_image_computed)
return node->border_image;
@@ -3018,6 +3021,7 @@ 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--)
{
@@ -3122,7 +3126,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,
node->scale_factor);
scale_factor);
g_object_unref (file);
@@ -3963,9 +3967,6 @@ 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);