Skip to content

Commit

Permalink
Fix ability to select a workspace that is not in the first row.
Browse files Browse the repository at this point in the history
This fix adjusts the ThumbnailsBox's allocation in vfunc_allocate. A better fix
would correctly specify the preferred width and height, but I couldn't figure
out how to get that to work.

This patch finally fully fixes mzur#177.
  • Loading branch information
mainland committed Sep 25, 2024
1 parent 5c6027f commit f63cf90
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions [email protected]/overview/thumbnailsBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ const vfunc_get_preferred_width = function (_forHeight) {
return themeNode.adjust_preferred_width(totalSpacing, naturalWidth);
}

const vfunc_allocate = function(box) {
this.set_allocation(box);

const vfunc_allocate = function(orig_box) {
const workspaceManager = global.workspace_manager;
const rows = workspaceManager.layout_rows;
const columns = workspaceManager.layout_columns;
Expand All @@ -112,7 +110,7 @@ const vfunc_allocate = function(box) {
return;

let themeNode = this.get_theme_node();
box = themeNode.get_content_box(box);
let box = themeNode.get_content_box(orig_box);

const portholeWidth = this._porthole.width;
const portholeHeight = this._porthole.height;
Expand Down Expand Up @@ -149,6 +147,17 @@ const vfunc_allocate = function(box) {
const thumbnailHeight = thumbnailFullHeight * this._expandFraction;
const roundedVScale = thumbnailHeight / portholeHeight;

// Fix up allocation for ThumbnailsBox
const orig_width = orig_box.x2 - orig_box.x1;
const desired_width = thumbnailWidth * columns + spacing * (columns + 1);
const extra = orig_width - desired_width;

orig_box.x1 += extra/2;
orig_box.x2 -= extra/2;
orig_box.y2 = orig_box.y1 + thumbnailHeight*rows + 2*spacing;

this.set_allocation(orig_box);

// We always request size for maxThumbnailScale, distribute
// space evently if we use smaller thumbnails

Expand Down Expand Up @@ -178,7 +187,7 @@ const vfunc_allocate = function(box) {
let indicatorLeftFullBorder = indicatorThemeNode.get_padding(St.Side.LEFT) + indicatorThemeNode.get_border_width(St.Side.LEFT);
let indicatorRightFullBorder = indicatorThemeNode.get_padding(St.Side.RIGHT) + indicatorThemeNode.get_border_width(St.Side.RIGHT);

let x = box.x1;
let x = 0;
let y = box.y1;

if (this._dropPlaceholderPos == -1) {
Expand All @@ -198,7 +207,7 @@ const vfunc_allocate = function(box) {
if (i % columns > 0) {
x += spacing - Math.round(thumbnail.collapse_fraction * spacing);
} else {
x = Math.round(box.x1 + (box.get_width() - Math.round(spacing - thumbnail.collapse_fraction * spacing + thumbnailWidth) * columns) / 2);
x = 0;
}

const y1 = y;
Expand Down

0 comments on commit f63cf90

Please sign in to comment.