Closed ghabit closed 1 year ago
When I looked at this, that was quite a lot of work though...
https://github.com/micheleg/dash-to-dock/blob/ubuntu-dock/intellihide.js
is as long as the entire extension.js code here ;-)
Dash to dock have many other options there, I think wise deduction is to take only needed parts. However, I’m not able to code at all, but just started python tutorial. :)
I do not see options in this file.
I actually started working on this today and i've made a good bit of progress. I'll share more tomorrow when I'm less tired but so far I've gotten the dock to hide when windows pass over it (still needs work though) and I've gotten the dock to hide when windows are maximized. I used a lot of code from dash to dock but i'm also trying to make it as simple as possible because dash to dock is a really complex extension.
Dash to dock have many other options there, I think wise deduction is to take only needed parts. However, I’m not able to code at all, but just started python tutorial. :)
This is off topic, but I hope you have fun learning how to code :)
i'm also trying to make it as simple as possible
I believe this is perfect approach. Thank you for your work!
The key function is here. We have to keep it simple: hide if focused window does overlap the dock.
_doCheckOverlap() {
if (!this._isEnabled || (this._targetBox == null))
return;
let overlaps = OverlapStatus.FALSE;
let windows = global.get_window_actors();
if (windows.length > 0) {
/*
* Get the top window on the monitor where the dock is placed.
* The idea is that we dont want to overlap with the windows of the topmost application,
* event is it's not the focused app -- for instance because in multimonitor the user
* select a window in the secondary monitor.
*/
let topWindow = null;
for (let i = windows.length - 1; i >= 0; i--) {
let meta_win = windows[i].get_meta_window();
if (this._handledWindow(windows[i]) && (meta_win.get_monitor() == this._monitorIndex)) {
topWindow = meta_win;
break;
}
}
if (topWindow !== null) {
this._topApp = this._tracker.get_window_app(topWindow);
// If there isn't a focused app, use that of the window on top
this._focusApp = this._tracker.focus_app || this._topApp
windows = windows.filter(this._intellihideFilterInteresting, this);
for (let i = 0; i < windows.length; i++) {
let win = windows[i].get_meta_window();
if (win) {
let rect = win.get_frame_rect();
let test = (rect.x < this._targetBox.x2) &&
(rect.x + rect.width > this._targetBox.x1) &&
(rect.y < this._targetBox.y2) &&
(rect.y + rect.height > this._targetBox.y1);
if (test) {
overlaps = OverlapStatus.TRUE;
break;
}
}
}
}
}
if (this._status !== overlaps) {
this._status = overlaps;
this.emit('status-changed', this._status);
}
}
How to implement this for testing?
That's Ubuntu Dock function. Needs some work inside Dock from dash.
Unfortunately GJS doc is down since some weeks: https://gjs-docs.gnome.org/meta11~11_api/ so I cannot work on this atm.
@fthx don't worry about it, I already got it working.
I still need to clean up the code and make sure it's not negatively impacting performance, but it works pretty well.
@fthx There is a problem with this though, Dash to Dock is licensed under the GPL v2 license. Since I used code from Dash to Dock, I believe you would have to change the license of your extension to the GPL v2 license to include the code. Let me know what your thoughts on this are.
@fthx don't worry about it, I already got it working. Screencast.from.2023-01-07.18-03-18.webm
I still need to clean up the code and make sure it's not negatively impacting performance, but it works pretty well.
It looks amazing!
@fthx I apologize for mentioning you, but can I have your permission to change the license in my fork of this repo to GPLv2 so I can share the code on GitHub?
there's no problem keep v3 here
Oh thank you for letting me know, didn't notice that. I will open a pull request when I get home.
I see some commits, is it possible to install version with this functionality?
Soon. ATM I have a lot of work, should be much better in 2 weeks.
Do we have some way to enable this option for now?
I have to include this code in the new version. For now I do not have the time, I will be back in extensions around mid-november, except for bugs.
That's a heavy part of code. So I won't include that, let's keep it simple and bug free.
Thank you for your work! I'd like to extension work with it like a full functionality dock - is it possible to make intelligence hide option? Show the dock when it doesn't obstruct focused application windows. And we can call it by pressure when it is hidden (mentioned here https://github.com/fthx/dock-from-dash/issues/58) I think it will be enough to migrate from any others dash extensions, minimalistic yet functional.