✨ Tweak clang-format style

This commit is contained in:
Simon Schneegans
2022-03-04 20:39:12 +01:00
parent 28c1cb6d72
commit 77310f9e65
7 changed files with 109 additions and 114 deletions
+2
View File
@@ -1,4 +1,6 @@
BasedOnStyle: Google BasedOnStyle: Google
AlignConsecutiveAssignments: true AlignConsecutiveAssignments: true
AlignAfterOpenBracket: Align
ContinuationIndentWidth: 2
KeepEmptyLinesAtTheStartOfBlocks: true KeepEmptyLinesAtTheStartOfBlocks: true
ColumnLimit: 90 ColumnLimit: 90
+25 -25
View File
@@ -101,26 +101,26 @@ class Extension {
// anyways, we override the actors ease() method once - the next time it will be // anyways, we override the actors ease() method once - the next time it will be
// called by the _mapWindow(), we will intercept it! // called by the _mapWindow(), we will intercept it!
this._windowCreatedConnection = this._windowCreatedConnection =
global.display.connect('window-created', (d, metaWin) => { global.display.connect('window-created', (d, metaWin) => {
let actor = metaWin.get_compositor_private(); let actor = metaWin.get_compositor_private();
const orig = actor.ease; const orig = actor.ease;
actor.ease = function(...params) { actor.ease = function(...params) {
orig.apply(actor, params); orig.apply(actor, params);
actor.ease = orig; actor.ease = orig;
// There are cases where the ease() is called prior to mapping the actor. If // There are cases where the ease() is called prior to mapping the actor. If
// the actor is not yet mapped, we defer the effect creation. // the actor is not yet mapped, we defer the effect creation.
if (actor.mapped) { if (actor.mapped) {
extensionThis._setupEffect(actor, true);
} else {
const connectionID = actor.connect('notify::mapped', () => {
extensionThis._setupEffect(actor, true); extensionThis._setupEffect(actor, true);
} else { actor.disconnect(connectionID);
const connectionID = actor.connect('notify::mapped', () => { });
extensionThis._setupEffect(actor, true); }
actor.disconnect(connectionID); };
}); });
}
};
});
// Some of the effects require that the window's actor is enlarged to provide a bigger // Some of the effects require that the window's actor is enlarged to provide a bigger
// canvas to draw the effects. Outside the overview we can simply increase the scale // canvas to draw the effects. Outside the overview we can simply increase the scale
@@ -324,8 +324,8 @@ class Extension {
// Only add effects to normal windows and dialog windows. // Only add effects to normal windows and dialog windows.
const isNormalWindow = actor.meta_window.window_type == Meta.WindowType.NORMAL; const isNormalWindow = actor.meta_window.window_type == Meta.WindowType.NORMAL;
const isDialogWindow = const isDialogWindow =
actor.meta_window.window_type == Meta.WindowType.MODAL_DIALOG || actor.meta_window.window_type == Meta.WindowType.MODAL_DIALOG ||
actor.meta_window.window_type == Meta.WindowType.DIALOG; actor.meta_window.window_type == Meta.WindowType.DIALOG;
if (!isNormalWindow && !isDialogWindow) { if (!isNormalWindow && !isDialogWindow) {
return; return;
@@ -390,8 +390,8 @@ class Extension {
// modifications to this behavior by the effects. // modifications to this behavior by the effects.
const config = this._currentEffect.tweakTransition(actor, this._settings, forOpening); const config = this._currentEffect.tweakTransition(actor, this._settings, forOpening);
const duration = testMode ? const duration = testMode ?
5000 : 5000 :
this._settings.get_int(this._currentEffect.getNick() + '-animation-time'); this._settings.get_int(this._currentEffect.getNick() + '-animation-time');
// All animations are relative to the window's center. // All animations are relative to the window's center.
actor.set_pivot_point(0.5, 0.5); actor.set_pivot_point(0.5, 0.5);
@@ -461,8 +461,8 @@ class Extension {
// Update uniforms at each frame. // Update uniforms at each frame.
transition.connect('new-frame', (t) => { transition.connect('new-frame', (t) => {
shader.set_uniform_value('uProgress', testMode ? 0.5 : t.get_progress()); shader.set_uniform_value('uProgress', testMode ? 0.5 : t.get_progress());
shader.set_uniform_value( shader.set_uniform_value('uTime',
'uTime', testMode ? duration / 2 : 0.001 * t.get_elapsed_time()); testMode ? duration / 2 : 0.001 * t.get_elapsed_time());
shader.set_uniform_value('uSizeX', actor.width); shader.set_uniform_value('uSizeX', actor.width);
shader.set_uniform_value('uSizeY', actor.height); shader.set_uniform_value('uSizeY', actor.height);
}); });
@@ -491,10 +491,10 @@ class Extension {
if (!forOpening) { if (!forOpening) {
if (isDialogWindow) { if (isDialogWindow) {
imports.ui.windowManager.DIALOG_DESTROY_WINDOW_ANIMATION_TIME = imports.ui.windowManager.DIALOG_DESTROY_WINDOW_ANIMATION_TIME =
duration != null ? duration : this._origDialogTime; duration != null ? duration : this._origDialogTime;
} else { } else {
imports.ui.windowManager.DESTROY_WINDOW_ANIMATION_TIME = imports.ui.windowManager.DESTROY_WINDOW_ANIMATION_TIME =
duration != null ? duration : this._origWindowTime; duration != null ? duration : this._origWindowTime;
} }
} }
} }
+68 -73
View File
@@ -64,13 +64,11 @@ var PreferencesDialog = class PreferencesDialog {
const styleProvider = Gtk.CssProvider.new(); const styleProvider = Gtk.CssProvider.new();
styleProvider.load_from_resource('/css/gtk.css'); styleProvider.load_from_resource('/css/gtk.css');
if (utils.isGTK4()) { if (utils.isGTK4()) {
Gtk.StyleContext.add_provider_for_display( Gtk.StyleContext.add_provider_for_display(Gdk.Display.get_default(), styleProvider,
Gdk.Display.get_default(), styleProvider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
} else { } else {
Gtk.StyleContext.add_provider_for_screen( Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), styleProvider,
Gdk.Screen.get_default(), styleProvider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
} }
// Make sure custom icons are found. // Make sure custom icons are found.
@@ -481,80 +479,77 @@ var PreferencesDialog = class PreferencesDialog {
// Each effect page is based on a template widget. This template contains the title // Each effect page is based on a template widget. This template contains the title
// and the preview button. // and the preview button.
// clang-format off
if (GObject.type_from_name('BurnMyWindowsEffectPage') == null) { if (GObject.type_from_name('BurnMyWindowsEffectPage') == null) {
BurnMyWindowsEffectPage = BurnMyWindowsEffectPage = GObject.registerClass(
GObject.registerClass({ {
GTypeName: 'BurnMyWindowsEffectPage', GTypeName: 'BurnMyWindowsEffectPage',
Template: `resource:///ui/${utils.getGTKString()}/effectPage.ui`, Template: `resource:///ui/${utils.getGTKString()}/effectPage.ui`,
InternalChildren: ['label', 'button'], InternalChildren: ['label', 'button'],
}, },
class BurnMyWindowsEffectPage extends Gtk.Box { class BurnMyWindowsEffectPage extends Gtk.Box { // ------------------------------
_init(Effect, dialog) { _init(Effect, dialog) {
super._init(); super._init();
// Set the effect's name as label. // Set the effect's name as label.
this._label.label = Effect.getLabel(); this._label.label = Effect.getLabel();
// Open the preview window once the preview button is clicked. // Open the preview window once the preview button is clicked.
this._button.connect('clicked', () => { this._button.connect('clicked', () => {
// Set the to-be-previewed effect.
dialog.getSettings().set_string('open-preview-effect', Effect.getNick());
dialog.getSettings().set_string('close-preview-effect', Effect.getNick());
// Set the to-be-previewed effect. // Make sure that the window.show() firther below "sees" this change.
dialog.getSettings().set_string('open-preview-effect', Effect.getNick()); Gio.Settings.sync();
dialog.getSettings().set_string('close-preview-effect', Effect.getNick());
// Make sure that the window.show() firther below "sees" this change. // Create the preview-window.
Gio.Settings.sync(); const window = new Gtk.Window({
// Translators: %s will be replaced by the effect's name.
title: _('Preview for %s').replace('%s', Effect.getLabel()),
default_width: 800,
default_height: 450,
modal: true,
transient_for: utils.isGTK4() ? this._button.get_root() :
this._button.get_toplevel()
});
// Create the preview-window. // Add a header bar to the window.
const window = new Gtk.Window({ if (utils.isGTK4()) {
// Translators: %s will be replaced by the effect's name. const header = Gtk.HeaderBar.new();
title: _('Preview for %s').replace("%s", Effect.getLabel()), window.set_titlebar(header);
default_width: 800, }
default_height: 450,
modal: true, const box = new Gtk.Box({
transient_for: utils.isGTK4() ? this._button.get_root() : orientation: Gtk.Orientation.VERTICAL,
this._button.get_toplevel() valign: Gtk.Align.CENTER,
spacing: 10,
margin_start: 50,
margin_end: 50
});
const label = Gtk.Label.new(_('Close this Window to Preview the Effect!'));
label.wrap = true;
label.justify = Gtk.Justification.CENTER;
label.get_style_context().add_class('large-title');
const image = new Gtk.Image({
icon_name: 'burn-my-windows-symbolic',
pixel_size: 128,
});
dialog.gtkBoxAppend(box, image);
dialog.gtkBoxAppend(box, label);
if (utils.isGTK4()) {
window.set_child(box);
window.show();
} else {
window.add(box);
window.show_all();
}
}); });
}
// Add a header bar to the window. });
if (utils.isGTK4()) {
const header = Gtk.HeaderBar.new();
window.set_titlebar(header);
}
const box = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
valign: Gtk.Align.CENTER,
spacing: 10,
margin_start:50,
margin_end:50
});
const label = Gtk.Label.new(_('Close this Window to Preview the Effect!'));
label.wrap = true;
label.justify = Gtk.Justification.CENTER;
label.get_style_context().add_class('large-title');
const image = new Gtk.Image({
icon_name: 'burn-my-windows-symbolic',
pixel_size: 128,
});
dialog.gtkBoxAppend(box, image);
dialog.gtkBoxAppend(box, label);
if (utils.isGTK4()) {
window.set_child(box);
window.show();
} else {
window.add(box);
window.show_all();
}
});
}
});
// clang-format on
} }
} }
} }
+4 -5
View File
@@ -134,9 +134,8 @@ if (utils.isInShellProcess()) {
// this texture is also re-created each time. This could be improved in the future! // this texture is also re-created each time. This could be improved in the future!
const shardData = GdkPixbuf.Pixbuf.new_from_resource('/img/shards.png'); const shardData = GdkPixbuf.Pixbuf.new_from_resource('/img/shards.png');
this._shardTexture = new Clutter.Image(); this._shardTexture = new Clutter.Image();
this._shardTexture.set_data( this._shardTexture.set_data(shardData.get_pixels(), Cogl.PixelFormat.RGB_888,
shardData.get_pixels(), Cogl.PixelFormat.RGB_888, shardData.width, shardData.width, shardData.height, shardData.rowstride);
shardData.height, shardData.rowstride);
// Usually, the shards fly away from the center of the window. // Usually, the shards fly away from the center of the window.
let epicenterX = 0.5; let epicenterX = 0.5;
@@ -232,8 +231,8 @@ if (utils.isInShellProcess()) {
const pipeline = this.get_pipeline(); const pipeline = this.get_pipeline();
// Use linear filtering for the window texture. // Use linear filtering for the window texture.
pipeline.set_layer_filters( pipeline.set_layer_filters(0, Cogl.PipelineFilter.LINEAR,
0, Cogl.PipelineFilter.LINEAR, Cogl.PipelineFilter.LINEAR); Cogl.PipelineFilter.LINEAR);
// Bind the shard texture. // Bind the shard texture.
pipeline.set_layer_texture(1, this._shardTexture.get_texture()); pipeline.set_layer_texture(1, this._shardTexture.get_texture());
+2 -2
View File
@@ -233,9 +233,9 @@ if (utils.isInShellProcess()) {
const gradient = []; const gradient = [];
for (let i = 1; i <= 5; i++) { for (let i = 1; i <= 5; i++) {
const color = const color =
Clutter.Color.from_string(settings.get_string('fire-color-' + i))[1]; Clutter.Color.from_string(settings.get_string('fire-color-' + i))[1];
gradient.push(`vec4(${color.red / 255}, ${color.green / 255}, ${ gradient.push(`vec4(${color.red / 255}, ${color.green / 255}, ${
color.blue / 255}, ${color.alpha / 255})`); color.blue / 255}, ${color.alpha / 255})`);
} }
this.set_shader_source(` this.set_shader_source(`
+5 -5
View File
@@ -129,14 +129,14 @@ if (utils.isInShellProcess()) {
const fontData = GdkPixbuf.Pixbuf.new_from_resource('/img/matrixFont.png'); const fontData = GdkPixbuf.Pixbuf.new_from_resource('/img/matrixFont.png');
this._fontTexture = new Clutter.Image(); this._fontTexture = new Clutter.Image();
this._fontTexture.set_data( this._fontTexture.set_data(
fontData.get_pixels(), fontData.get_pixels(),
fontData.has_alpha ? Cogl.PixelFormat.RGBA_8888 : Cogl.PixelFormat.RGB_888, fontData.has_alpha ? Cogl.PixelFormat.RGBA_8888 : Cogl.PixelFormat.RGB_888,
fontData.width, fontData.height, fontData.rowstride); fontData.width, fontData.height, fontData.rowstride);
const trailColor = const trailColor =
Clutter.Color.from_string(settings.get_string('matrix-trail-color'))[1]; Clutter.Color.from_string(settings.get_string('matrix-trail-color'))[1];
const tipColor = const tipColor =
Clutter.Color.from_string(settings.get_string('matrix-tip-color'))[1]; Clutter.Color.from_string(settings.get_string('matrix-tip-color'))[1];
// The technique for this effect was inspired by // The technique for this effect was inspired by
// https://www.shadertoy.com/view/ldccW4, however the implementation is quite // https://www.shadertoy.com/view/ldccW4, however the implementation is quite
+3 -4
View File
@@ -125,12 +125,11 @@ if (utils.isInShellProcess()) {
// See assets/README.md for how this texture was created. // See assets/README.md for how this texture was created.
const clawData = GdkPixbuf.Pixbuf.new_from_resource('/img/claws.png'); const clawData = GdkPixbuf.Pixbuf.new_from_resource('/img/claws.png');
this._clawTexture = new Clutter.Image(); this._clawTexture = new Clutter.Image();
this._clawTexture.set_data( this._clawTexture.set_data(clawData.get_pixels(), Cogl.PixelFormat.RGB_888,
clawData.get_pixels(), Cogl.PixelFormat.RGB_888, clawData.width, clawData.width, clawData.height, clawData.rowstride);
clawData.height, clawData.rowstride);
const color = const color =
Clutter.Color.from_string(settings.get_string('claw-scratch-color'))[1]; Clutter.Color.from_string(settings.get_string('claw-scratch-color'))[1];
// If we are currently performing integration test, the animation uses a fixed seed. // If we are currently performing integration test, the animation uses a fixed seed.
const testMode = settings.get_boolean('test-mode'); const testMode = settings.get_boolean('test-mode');