Skip to content

Commit

Permalink
Fix harbour placement on the right edge
Browse files Browse the repository at this point in the history
Commit b780659 (Fix max line-length and too many space indents,
2022-07-16) factors out the code inside Harbour::placeDockApp() into
placeDockAppX and placeDockAppY but never calls the latter. Later on
placeDockAppY() is deleted in another cleanup commit.

I do not understand how I only noticed this now [1] but with default
harbor setting (on the right edge), all the dock apps are now moved to
the left edge. And this seems to fix this, but to be honest I don't
really know what I'm doing.

[1] well not now, a few months but I was too lazy to go check
  • Loading branch information
pclouds committed Nov 14, 2023
1 parent 8f3e4fe commit 29291ea
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
39 changes: 38 additions & 1 deletion src/Harbour.cc
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ Harbour::placeDockApp(DockApp *da)
if (x_place) {
placeDockAppX(da, head, x, y);
} else {
placeDockAppX(da, head, x, y);
placeDockAppY(da, head, x, y);
}

da->move(x, y);
Expand Down Expand Up @@ -440,6 +440,43 @@ Harbour::placeDockAppX(DockApp* da, const Geometry& head, int& x, const int y)
}
}

void
Harbour::placeDockAppY(DockApp *da, const Geometry& head, const int x, int &y)
{
int test;
bool placed = false, increase = false;
bool bottom = (_cfg->getHarbourOrientation() == BOTTOM_TO_TOP);
y = test = bottom ? head.y + head.height - da->getHeight() : head.y;

while (! placed
&& (bottom
? (test >= 0)
: ((test + da->getHeight()) < (head.y + head.height)))) {
placed = increase = true;

std::vector<DockApp*>::const_iterator it = _dapps.begin();
for (; placed && it != _dapps.end(); ++it) {
if ((*it) == da) {
continue; // exclude ourselves
}

int ty = static_cast<signed>(test + da->getHeight());
if (((*it)->getY() < ty) && ((*it)->getBY() > test)) {
placed = increase = false;
test = bottom
? (*it)->getY() - da->getHeight()
: (*it)->getBY();
}
}

if (placed) {
y = test;
} else if (increase) {
test += bottom ? -1 : 1;
}
}
}

//! @brief Inserts DockApp and places all dockapps in sorted order
//! @todo Screen boundary checking
void
Expand Down
2 changes: 2 additions & 0 deletions src/Harbour.hh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ private:
void placeDockApp(DockApp *da);
void placeDockAppX(DockApp *da, const Geometry& head,
int& x, const int y);
void placeDockAppY(DockApp *da, const Geometry& head,
const int x, int &y);
void placeDockAppsSorted(void);
void placeDockAppInsideScreen(DockApp *da);

Expand Down

0 comments on commit 29291ea

Please sign in to comment.