Skip to content

Commit

Permalink
Add Gnome 47 compatibility (paperwm#948)
Browse files Browse the repository at this point in the history
This PR adds Gnome 47 compatibility, including support for the merged
(from `Clutter.Color`) `Cogl.Color` methods.

This provides compatibility in our `release` branch for Gnome versions
45-47.
  • Loading branch information
jtaala authored Sep 14, 2024
2 parents cb7070b + 0df039f commit c568396
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Have questions or comments? Please ask on our [Github Discussions](https://gith

Clone the repo and check out the branch for the Gnome Shell version you're running:

- 45-46 (currently developed/supported): https://github.com/paperwm/PaperWM/tree/release
- 45-47 (currently developed/supported): https://github.com/paperwm/PaperWM/tree/release
- 42-44 ([EOL](https://release.gnome.org/calendar/#releases)): https://github.com/paperwm/PaperWM/tree/gnome-44
- 40-41 ([EOL](https://release.gnome.org/calendar/#releases)): https://github.com/paperwm/PaperWM/tree/gnome-40
- 3.28-3.38 ([EOL](https://release.gnome.org/calendar/#releases)): https://github.com/paperwm/PaperWM/tree/gnome-3.38
Expand Down
12 changes: 7 additions & 5 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
* This is a copy and modification of Gnome shell's background.js (keeping only the
* relevant parts).
*
* This was done since `Background` class isn't exported in Gnome 45, and we use the
* This was done since `Background` class isn't exported in Gnome 47, and we use the
* `Background` to add support for animated wallpapers in PaperWM spaces
* (we previously used Meta.Background but it doesn't support animated wallpapers).
*
* See https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/45.0/js/ui/background.js
* See https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/449a7a13034d507cd8b6776c8e1a021264c8bf41/js/ui/background.js
*/
import Clutter from 'gi://Clutter';
import Cogl from 'gi://Cogl';
import GDesktopEnums from 'gi://GDesktopEnums';
import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
Expand All @@ -23,6 +23,8 @@ import * as LoginManager from 'resource:///org/gnome/shell/misc/loginManager.js'
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
import * as Params from 'resource:///org/gnome/shell/misc/params.js';

import { Utils } from './imports.js';

const PRIMARY_COLOR_KEY = 'primary-color';
const SECONDARY_COLOR_KEY = 'secondary-color';
const COLOR_SHADING_TYPE_KEY = 'color-shading-type';
Expand Down Expand Up @@ -266,9 +268,9 @@ export const Background = GObject.registerClass({
let colorString, res_, color, secondColor;

colorString = this._settings.get_string(PRIMARY_COLOR_KEY);
[res_, color] = Clutter.Color.from_string(colorString);
[res_, color] = Utils.color_from_string(colorString);
colorString = this._settings.get_string(SECONDARY_COLOR_KEY);
[res_, secondColor] = Clutter.Color.from_string(colorString);
[res_, secondColor] = Utils.color_from_string(colorString);

let shadingType = this._settings.get_enum(COLOR_SHADING_TYPE_KEY);

Expand Down
17 changes: 17 additions & 0 deletions config/user.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,25 @@ DEFAULT STYLES ARE PROVIDED BELOW FOR REFERENCE:
background-color: transparent;
}
.open-position-icon {
icon-size: 22px;
padding: 0;
background-color: transparent;
}
.focus-button-tooltip {
background-color: rgba(0, 0, 0, 0.8);
padding: 8px;
border-radius: 8px;
font-weight: 600;
}
.take-window-hint {
background-color: rgba(0, 0, 0, 0.8);
padding: 8px;
border-radius: 8px;
}
.workspace-icon-button {
-st-icon-style: symbolic;
border: none;
Expand All @@ -55,6 +67,11 @@ DEFAULT STYLES ARE PROVIDED BELOW FOR REFERENCE:
border-radius: 8px;
}
.paperwm-clone-shade {
background-color: rgba(0, 0, 0, 0.7);
border-radius: 7px 7px 0px 0px;
}
.paperwm-window-position-bar-backdrop {
background-color: rgba(0, 0, 0, 0.35);
}
Expand Down
4 changes: 2 additions & 2 deletions liveAltTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import GObject from 'gi://GObject';
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
import * as AltTab from 'resource:///org/gnome/shell/ui/altTab.js';

import { Settings, Keybindings, Tiling, Scratch } from './imports.js';
import { Settings, Keybindings, Tiling, Scratch, Utils } from './imports.js';
import { Easer } from './utils.js';

let switcherSettings;
Expand Down Expand Up @@ -66,7 +66,7 @@ export const LiveAltTab = GObject.registerClass(
let fog = new Clutter.Actor({
x: workArea.x, y: workArea.y,
width: workArea.width, height: workArea.height,
opacity: 0, background_color: Clutter.color_from_string("black")[1],
opacity: 0, background_color: Utils.color_from_string("black")[1],
});

// this.blur = new Clutter.BlurEffect();
Expand Down
4 changes: 2 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"description": "Tiling window manager with a twist",
"url": "https://github.com/paperwm/PaperWM",
"settings-schema": "org.gnome.shell.extensions.paperwm",
"shell-version": [ "45", "46" ],
"version-name": "46.17.1",
"shell-version": [ "45", "46", "47" ],
"version-name": "47.0.0",
"donations": {
"buymeacoffee": "jaytaala",
"patreon": "valpackett"
Expand Down
4 changes: 2 additions & 2 deletions navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class ActionDispatcher {
console.debug("#dispatch", "created");
this.signals = new Utils.Signals();
this.actor = Tiling.spaces.spaceContainer;
this.actor.set_flags(Clutter.ActorFlags.REACTIVE);
this.actor.reactive = true;
this.navigator = getNavigator();

if (grab) {
Expand Down Expand Up @@ -279,7 +279,7 @@ class ActionDispatcher {
console.debug("Failed to release grab: ", e);
}

this.actor.unset_flags(Clutter.ActorFlags.REACTIVE);
this.actor.reactive = false;
this.signals.destroy();
this.signals = null;
// We have already destroyed the navigator
Expand Down
2 changes: 1 addition & 1 deletion stackoverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export class StackOverlay {
});

// Uncomment to debug the overlays
// overlay.background_color = Clutter.color_from_string('green')[1];
// overlay.background_color = Utils.color_from_string('green')[1];
// overlay.opacity = 100;

this.monitor = monitor;
Expand Down
2 changes: 1 addition & 1 deletion tiling.js
Original file line number Diff line number Diff line change
Expand Up @@ -1696,7 +1696,7 @@ border-radius: ${borderWidth}px;

// after creating new background apply this space's color
if (this.color) {
this.metaBackground.set_color(Clutter.color_from_string(this.color)[1]);
this.metaBackground.set_color(Utils.color_from_string(this.color)[1]);
}
}

Expand Down
17 changes: 16 additions & 1 deletion utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,21 @@ export function setBackgroundImage(actor, resource_path) {
actor.content_repeat = Clutter.ContentRepeat.BOTH;
}

/**
* Backwards compatible function. Attempts to use Cogl.Color with a fallback
* to Clutter.Color.
* @param {String} colorString
*/
export function color_from_string(colorString) {
try {
// Gnome 47+ merged Clutter.Color into Cogl.Color
return Cogl.Color.from_string(colorString);
} catch (error) {
// fallback for Gnome 45, 46
return Clutter.Color.from_string(colorString);
}
}


// // Debug and development utils

Expand Down Expand Up @@ -156,7 +171,7 @@ export function toggleCloneMarks() {
if (metaWindow.clone) {
metaWindow.clone.opacity = 190;
metaWindow.clone.__oldOpacity = 190;
metaWindow.clone.background_color = Clutter.color_from_string("red")[1];
metaWindow.clone.background_color = color_from_string("red")[1];
}
}
function unmarkCloneOf(metaWindow) {
Expand Down

0 comments on commit c568396

Please sign in to comment.