Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for Gnome Shell 46 #2146

Merged
merged 12 commits into from
Mar 20, 2024
18 changes: 16 additions & 2 deletions _stylesheet.scss
sergio-costas marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ $_dark_base_color: darken(desaturate(#241f31, 100%), 2%);
$base_color: if($variant =='light', #fff, $_dark_base_color);
$system_bg_color: $base_color;

$remark_color: rgba(238, 238, 238, 0.2);

// From https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/43.0/data/theme/gnome-shell-sass/widgets/_dash.scss
$dash_background_color: lighten($system_bg_color, 5%);
$dash_placeholder_size: 32px;
Expand Down Expand Up @@ -203,7 +205,8 @@ $dock_style_modes: [null, shrink, extended, extended-shrink];
0, $dock_icons_distance / 2);

.app-well-app,
.show-apps {
.show-apps,
.overview-tile {
@include set-internal-children-property($side, padding, $spacing);
padding-#{$side}: $padding + $side_margin;
padding-#{opposite($side)}: $padding;
Expand All @@ -214,7 +217,7 @@ $dock_style_modes: [null, shrink, extended, extended-shrink];
background-image: none;
}
&.focused .overview-icon {
background-color: rgba(238, 238, 236, 0.2);
background-color: $remark_color;
}

.app-well-app-running-dot {
Expand Down Expand Up @@ -247,6 +250,17 @@ $dock_style_modes: [null, shrink, extended, extended-shrink];
}
}

.dash-item-container .overview-tile .overview-icon,
.dash-item-container .show-apps .overview-icon {
background-color: rgba(255,255,255,0);
}

.dash-item-container .overview-tile:hover .overview-icon,
.dash-item-container .overview-tile.focused .overview-icon,
.dash-item-container .show-apps:hover .overview-icon {
background-color: $remark_color;
}

@each $side in $dock_sides {
@each $style_mode in $dock_style_modes {
$is_shrink: str-index(#{$style_mode}, shrink) !=null;
Expand Down
36 changes: 18 additions & 18 deletions appIconIndicators.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ class RunningIndicatorDots extends RunningIndicatorBase {
const n = this._number;

cr.setLineWidth(this._borderWidth);
Clutter.cairo_set_source_color(cr, this._borderColor);
Utils.cairoSetSourceColor(cr, this._borderColor);

// draw for the bottom case:
cr.translate(
Expand All @@ -422,7 +422,7 @@ class RunningIndicatorDots extends RunningIndicatorBase {
}

cr.strokePreserve();
Clutter.cairo_set_source_color(cr, this._bodyColor);
Utils.cairoSetSourceColor(cr, this._bodyColor);
cr.fill();
}

Expand All @@ -448,7 +448,7 @@ class RunningIndicatorCiliora extends RunningIndicatorDots {
const yOffset = this._height - padding - size;

cr.setLineWidth(this._borderWidth);
Clutter.cairo_set_source_color(cr, this._borderColor);
Utils.cairoSetSourceColor(cr, this._borderColor);

cr.translate(0, yOffset);
cr.newSubPath();
Expand All @@ -459,7 +459,7 @@ class RunningIndicatorCiliora extends RunningIndicatorDots {
}

cr.strokePreserve();
Clutter.cairo_set_source_color(cr, this._bodyColor);
Utils.cairoSetSourceColor(cr, this._bodyColor);
cr.fill();
}
}
Expand All @@ -481,7 +481,7 @@ class RunningIndicatorSegmented extends RunningIndicatorDots {
const yOffset = this._height - padding - size;

cr.setLineWidth(this._borderWidth);
Clutter.cairo_set_source_color(cr, this._borderColor);
Utils.cairoSetSourceColor(cr, this._borderColor);

cr.translate(0, yOffset);
for (let i = 0; i < this._number; i++) {
Expand All @@ -490,7 +490,7 @@ class RunningIndicatorSegmented extends RunningIndicatorDots {
}

cr.strokePreserve();
Clutter.cairo_set_source_color(cr, this._bodyColor);
Utils.cairoSetSourceColor(cr, this._bodyColor);
cr.fill();
}
}
Expand All @@ -510,14 +510,14 @@ class RunningIndicatorSolid extends RunningIndicatorDots {
const yOffset = this._height - padding - size;

cr.setLineWidth(this._borderWidth);
Clutter.cairo_set_source_color(cr, this._borderColor);
Utils.cairoSetSourceColor(cr, this._borderColor);

cr.translate(0, yOffset);
cr.newSubPath();
cr.rectangle(0, 0, this._width, size);

cr.strokePreserve();
Clutter.cairo_set_source_color(cr, this._bodyColor);
Utils.cairoSetSourceColor(cr, this._bodyColor);
cr.fill();
}
}
Expand All @@ -534,7 +534,7 @@ class RunningIndicatorSquares extends RunningIndicatorDots {
const yOffset = this._height - padding - size;

cr.setLineWidth(this._borderWidth);
Clutter.cairo_set_source_color(cr, this._borderColor);
Utils.cairoSetSourceColor(cr, this._borderColor);

cr.translate(
Math.floor((this._width - this._number * size - (this._number - 1) * spacing) / 2),
Expand All @@ -545,7 +545,7 @@ class RunningIndicatorSquares extends RunningIndicatorDots {
cr.rectangle(i * size + i * spacing, 0, size, size);
}
cr.strokePreserve();
Clutter.cairo_set_source_color(cr, this._bodyColor);
Utils.cairoSetSourceColor(cr, this._bodyColor);
cr.fill();
}
}
Expand All @@ -563,7 +563,7 @@ class RunningIndicatorDashes extends RunningIndicatorDots {
const yOffset = this._height - padding - size;

cr.setLineWidth(this._borderWidth);
Clutter.cairo_set_source_color(cr, this._borderColor);
Utils.cairoSetSourceColor(cr, this._borderColor);

cr.translate(
Math.floor((this._width - this._number * dashLength - (this._number - 1) * spacing) / 2),
Expand All @@ -575,7 +575,7 @@ class RunningIndicatorDashes extends RunningIndicatorDots {
}

cr.strokePreserve();
Clutter.cairo_set_source_color(cr, this._bodyColor);
Utils.cairoSetSourceColor(cr, this._bodyColor);
cr.fill();
}
}
Expand Down Expand Up @@ -607,7 +607,7 @@ class RunningIndicatorMetro extends RunningIndicatorDots {
const n = this._number;
if (n <= 1) {
cr.translate(0, yOffset);
Clutter.cairo_set_source_color(cr, this._bodyColor);
Utils.cairoSetSourceColor(cr, this._bodyColor);
cr.newSubPath();
cr.rectangle(0, 0, this._width, size);
cr.fill();
Expand All @@ -621,15 +621,15 @@ class RunningIndicatorMetro extends RunningIndicatorDots {

cr.translate(0, yOffset);

Clutter.cairo_set_source_color(cr, this._bodyColor);
Utils.cairoSetSourceColor(cr, this._bodyColor);
cr.newSubPath();
cr.rectangle(0, 0, this._width - darkenedLength - blackenedLength, size);
cr.fill();
Clutter.cairo_set_source_color(cr, blackenedColor);
Utils.cairoSetSourceColor(cr, blackenedColor);
cr.newSubPath();
cr.rectangle(this._width - darkenedLength - blackenedLength, 0, 1, size);
cr.fill();
Clutter.cairo_set_source_color(cr, darkenedColor);
Utils.cairoSetSourceColor(cr, darkenedColor);
cr.newSubPath();
cr.rectangle(this._width - darkenedLength, 0, darkenedLength, size);
cr.fill();
Expand All @@ -650,7 +650,7 @@ class RunningIndicatorBinary extends RunningIndicatorDots {
const binaryValue = String(`0000${(n >>> 0).toString(2)}`).slice(-4);

cr.setLineWidth(this._borderWidth);
Clutter.cairo_set_source_color(cr, this._borderColor);
Utils.cairoSetSourceColor(cr, this._borderColor);

cr.translate(Math.floor((this._width - 4 * size - (4 - 1) * spacing) / 2), yOffset);
for (let i = 0; i < binaryValue.length; i++) {
Expand All @@ -667,7 +667,7 @@ class RunningIndicatorBinary extends RunningIndicatorDots {
}
}
cr.strokePreserve();
Clutter.cairo_set_source_color(cr, this._bodyColor);
Utils.cairoSetSourceColor(cr, this._bodyColor);
cr.fill();
}
}
Expand Down
4 changes: 2 additions & 2 deletions appIcons.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ const DockAbstractAppIcon = GObject.registerClass({
}

/**
* Update taraget for minimization animation
* Update target for minimization animation
*/
updateIconGeometry() {
// If (for unknown reason) the actor is not on the stage the reported size
Expand Down Expand Up @@ -997,7 +997,7 @@ const DockAppIconMenu = class DockAppIconMenu extends PopupMenu.PopupMenu {
});
source.connect('destroy', () => this.destroy());

Main.uiGroup.add_actor(this.actor);
Main.uiGroup.add_child(this.actor);

const {remoteModel} = Docking.DockManager.getDefault();
const remoteModelApp = remoteModel?.lookupById(this._source?.app?.id);
Expand Down
11 changes: 8 additions & 3 deletions dash.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,12 @@ export const DockDash = GObject.registerClass({
this._scrollView.connect('scroll-event', this._onScrollEvent.bind(this));

this._boxContainer = new St.BoxLayout({
name: 'dashtodockBoxContainer',
x_align: Clutter.ActorAlign.FILL,
y_align: Clutter.ActorAlign.FILL,
vertical: !this._isHorizontal,
});
this._boxContainer.add_style_class_name(Theming.PositionStyleClass[this._position]);

const rtl = Clutter.get_default_text_direction() === Clutter.TextDirection.RTL;
this._box = new St.BoxLayout({
Expand All @@ -194,9 +196,12 @@ export const DockDash = GObject.registerClass({
x_expand: this._isHorizontal,
});
this._box._delegate = this;
this._dashContainer.add_actor(this._scrollView);
this._boxContainer.add_actor(this._box);
this._scrollView.add_actor(this._boxContainer);
this._boxContainer.add_child(this._box);
if (this._scrollView.add_actor)
this._scrollView.add_actor(this._boxContainer);
else
this._scrollView.add_child(this._boxContainer);
this._dashContainer.add_child(this._scrollView);

this._showAppsIcon = new AppIcons.DockShowAppsIcon(this._position);
this._showAppsIcon.show(false);
Expand Down
14 changes: 8 additions & 6 deletions docking.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ const DockedDash = GObject.registerClass({
// Add dash container actor and the container to the Chrome.
this.set_child(this._slider);
this._slider.set_child(this._box);
this._box.add_actor(this.dash);
this._box.add_child(this.dash);

// Add aligning container without tracking it for input region
this._trackDock();
Expand Down Expand Up @@ -866,7 +866,7 @@ const DockedDash = GObject.registerClass({
// If we don't have extended barrier features, then we need
// to support the old tray dwelling mechanism.
if (this._autohideIsEnabled &&
(!global.display.supports_extended_barriers() ||
(!Utils.supportsExtendedBarriers() ||
!DockManager.settings.requirePressureToShow)) {
const pointerWatcher = PointerWatcher.getPointerWatcher();
this._dockWatch = pointerWatcher.addWatch(
Expand Down Expand Up @@ -954,7 +954,7 @@ const DockedDash = GObject.registerClass({

_updatePressureBarrier() {
const {settings} = DockManager;
this._canUsePressure = global.display.supports_extended_barriers();
this._canUsePressure = Utils.supportsExtendedBarriers();
const {pressureThreshold} = settings;

// Remove existing pressure barrier
Expand Down Expand Up @@ -1115,7 +1115,7 @@ const DockedDash = GObject.registerClass({

if (this._pressureBarrier && this._dockState === State.HIDDEN) {
this._barrier = new Meta.Barrier({
display: global.display,
backend: global.backend,
x1,
x2,
y1,
Expand Down Expand Up @@ -2306,6 +2306,9 @@ export class DockManager {
});

const maybeAdjustBoxSize = (state, box, spacing) => {
// ensure that an undefined value will be converted into a valid one
spacing = spacing ?? 0;

if (state === OverviewControls.ControlsState.WINDOW_PICKER) {
const searchBox = this.overviewControls._searchEntry.get_allocation_box();
const {shouldShow: wsThumbnails} = this.overviewControls._thumbnailsBox;
Expand All @@ -2315,8 +2318,7 @@ export class DockManager {
box.y2 -= spacing;
}

box.y2 -= searchBox.get_height() + spacing;
box.y2 -= spacing;
box.y2 -= searchBox.get_height() + 2 * spacing;
}

return box;
Expand Down
3 changes: 2 additions & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"shell-version": [
"45"
"45",
"46"
],
"uuid": "dash-to-dock@micxgx.gmail.com",
"name": "Dash to Dock",
Expand Down
14 changes: 12 additions & 2 deletions theming.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import {
Clutter,
GObject,
Meta,
St,
} from './dependencies/gi.js';
Expand Down Expand Up @@ -353,13 +354,22 @@ class Transparency {
this._base_actor_style = '';


let addedSignal = 'child-added';
let removedSignal = 'child-removed';

// for compatibility with Gnome Shell 45
if (GObject.signal_lookup('actor-added', global.window_group)) {
addedSignal = 'actor-added';
removedSignal = 'actor-removed';
}

this._signalsHandler.addWithLabel(Labels.TRANSPARENCY, [
global.window_group,
'actor-added',
addedSignal,
this._onWindowActorAdded.bind(this),
], [
global.window_group,
'actor-removed',
removedSignal,
this._onWindowActorRemoved.bind(this),
], [
global.window_manager,
Expand Down
31 changes: 31 additions & 0 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -655,3 +655,34 @@ export function laterRemove(id) {
Meta.later_remove(id);
}

/**
* Up to Gnome Shell 45, the Cairo Context object didn't export the
* `setSourceColor()` method, so Clutter included a function call for
* that, written in C. In Gnome Shell 46, the method was finally exported,
* so that function was removed.
*
* This function is, thus, required for Gnome Shell 45 compatibility.
*
* @param {*} cr A cairo context
* @param {*} sourceColor The new color for source
*/
export function cairoSetSourceColor(cr, sourceColor) {
if (Clutter.cairo_set_source_color)
Clutter.cairo_set_source_color(cr, sourceColor);
else
cr.setSourceColor(sourceColor);
}

/**
* Specifies if the system supports extended barriers. This function
* is required for Gnome Shell 45 compatibility, which used
* `global.display.supports_extended_barriers`. Gnome Shell 46 moved
* that into global.backend.capabilities.
*
* @returns True if the system supports extended barriers.
*/
export function supportsExtendedBarriers() {
if (global.display.supports_extended_barriers)
return global.display.supports_extended_barriers();
return !!(global.backend.capabilities & Meta.BackendCapabilities.BARRIERS);
}
Loading
Loading