gnome/extensions/workspaces-to-dock@passingthru67.gmail.com/intellihide.js
// intellihide function to determine if dock overlaps a window
intellihide function to determine if dock overlaps a window
intellihide function to determine if dock overlaps a window
_updateDockVisibility() {
        if (this._disableIntellihide)
            return;
        if (this._inOverview) {
            return;
        }
        else {
            if (this._settings.get_boolean('intellihide') || this._settings.get_boolean('dock-fixed')) {
                let overlaps = false;
                let windows = global.get_window_actors();
                if (windows.length > 0) {
                    this._topWindow = windows[windows.length-1].get_meta_window();
                    for (let i = windows.length-1; i >= 0; i--) {
                        let win = windows[i].get_meta_window();
                        if (win.has_focus()) {
                            this._focusedWin = win;
                            break;
                        }
                    }
                    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 [dx, dy] = this._dock.actor.get_position();
                            let [dw, dh] = this._dock.actor.get_size();
                            let [dcx, dcy] = this._dock.actor.get_transformed_position();
                            let [dcw, dch] = this._dock.actor.get_size();
                            if (this._dock._isHorizontal) {
                                dx = dcx;
                                dw = dcw;
                                let intellihideAction = this._settings.get_enum('intellihide-action');
                                if (intellihideAction == IntellihideAction.SHOW_PARTIAL || intellihideAction == IntellihideAction.SHOW_PARTIAL_FIXED) {
                                    if (this._dock._slider.partialSlideoutSize)
                                        dh = this._dock._slider.partialSlideoutSize;
                                }
                            } else {
                                dy = dcy;
                                dh = dch;
                                let intellihideAction = this._settings.get_enum('intellihide-action');
                                if (intellihideAction == IntellihideAction.SHOW_PARTIAL || intellihideAction == IntellihideAction.SHOW_PARTIAL_FIXED) {
                                    if (this._dock._slider.partialSlideoutSize)
                                        dw = this._dock._slider.partialSlideoutSize;
                                }
                            }
                            let test;
                            if (this._dock._position == St.Side.LEFT || this._dock._position == St.Side.TOP) {
                                test = (rect.x < dx + dw) && (rect.x + rect.width > dx) && (rect.y < dy + dh) && (rect.y + rect.height > dy);
                            } else if (this._dock._position == St.Side.RIGHT) {
                                test = (rect.x < dx) && (rect.x + rect.width > dx - dw) && (rect.y < dy + dh) && (rect.y + rect.height > dy);
                            } else if (this._dock._position == St.Side.BOTTOM) {
                                test = (rect.x < dx + dw) && (rect.x + rect.width > dx) && (rect.y + rect.height > dy - dh) && (rect.y < dy);
                            }
                            if (test) {
                                overlaps = true;
                                break;
                            }
                        }
                    }
                }
                if (this._switchWorkspaceQuickShow && this._switchedWorkspace && this._quickShowTimeoutId == 0) {
                    this._show(true);
                    let timeout = this._settings.get_double('quick-show-timeout');
                    this._quickShowTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, timeout, this._quickShowExit.bind(this));
                } else {
                    if (this._quickShowTimeoutId == 0) {
                        if (overlaps) {
                            this._hide();
                        } else {
                            if (!this._settings.get_boolean('dock-fixed') && this._settings.get_boolean('intellihide') && (this._settings.get_enum('intellihide-action') == IntellihideAction.SHOW_PARTIAL || this._settings.get_enum('intellihide-action') == IntellihideAction.SHOW_PARTIAL_FIXED)) {
                                if (this._dock._dockState == DockState.SHOWING || this._dock._dockState == DockState.SHOWN) {
                                    this._hide(true);
                                } else {
                                    this._show();
                                }
                            } else {
                                if (this._settings.get_boolean('dock-fixed') && this._dock._monitor.inFullscreen) {
                                    this._hide();
                                } else {
                                    this._show();
                                }
                            }
                        }
                    }
                }
            } else {
                if (this._switchWorkspaceQuickShow && this._switchedWorkspace && this._quickShowTimeoutId == 0) {
                    this._show(true);
                    let timeout = this._settings.get_double('quick-show-timeout');
                    this._quickShowTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, timeout, this._quickShowExit.bind(this));
                } else {
                    if (this._quickShowTimeoutId == 0)
                        this._hide();
                }
            }
        }
    }
_updateDockVisibility ( ) { if ( this . _disableIntellihide ) return ; if ( this . _inOverview ) { return ; } else { if ( this . _settings . get_boolean ( 'intellihide' ) || this . _settings . get_boolean ( 'dock-fixed' ) ) { let overlaps = false ; let windows = global . get_window_actors ( ) ; if ( windows . length > 0 ) { this . _topWindow = windows [ windows . length - 1 ] . get_meta_window ( ) ; for ( let i = windows . length - 1 ; i >= 0 ; i -- ) { let win = windows [ i ] . get_meta_window ( ) ; if ( win . has_focus ( ) ) { this . _focusedWin = win ; break ; } } 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 [ dx , dy ] = this . _dock . actor . get_position ( ) ; let [ dw , dh ] = this . _dock . actor . get_size ( ) ; let [ dcx , dcy ] = this . _dock . actor . get_transformed_position ( ) ; let [ dcw , dch ] = this . _dock . actor . get_size ( ) ; if ( this . _dock . _isHorizontal ) { dx = dcx ; dw = dcw ; let intellihideAction = this . _settings . get_enum ( 'intellihide-action' ) ; if ( intellihideAction == IntellihideAction . SHOW_PARTIAL || intellihideAction == IntellihideAction . SHOW_PARTIAL_FIXED ) { if ( this . _dock . _slider . partialSlideoutSize ) dh = this . _dock . _slider . partialSlideoutSize ; } } else { dy = dcy ; dh = dch ; let intellihideAction = this . _settings . get_enum ( 'intellihide-action' ) ; if ( intellihideAction == IntellihideAction . SHOW_PARTIAL || intellihideAction == IntellihideAction . SHOW_PARTIAL_FIXED ) { if ( this . _dock . _slider . partialSlideoutSize ) dw = this . _dock . _slider . partialSlideoutSize ; } } let test ; if ( this . _dock . _position == St . Side . LEFT || this . _dock . _position == St . Side . TOP ) { test = ( rect . x < dx + dw ) && ( rect . x + rect . width > dx ) && ( rect . y < dy + dh ) && ( rect . y + rect . height > dy ) ; } else if ( this . _dock . _position == St . Side . RIGHT ) { test = ( rect . x < dx ) && ( rect . x + rect . width > dx - dw ) && ( rect . y < dy + dh ) && ( rect . y + rect . height > dy ) ; } else if ( this . _dock . _position == St . Side . BOTTOM ) { test = ( rect . x < dx + dw ) && ( rect . x + rect . width > dx ) && ( rect . y + rect . height > dy - dh ) && ( rect . y < dy ) ; } if ( test ) { overlaps = true ; break ; } } } } if ( this . _switchWorkspaceQuickShow && this . _switchedWorkspace && this . _quickShowTimeoutId == 0 ) { this . _show ( true ) ; let timeout = this . _settings . get_double ( 'quick-show-timeout' ) ; this . _quickShowTimeoutId = GLib . timeout_add ( GLib . PRIORITY_DEFAULT , timeout , this . _quickShowExit . bind ( this ) ) ; } else { if ( this . _quickShowTimeoutId == 0 ) { if ( overlaps ) { this . _hide ( ) ; } else { if ( ! this . _settings . get_boolean ( 'dock-fixed' ) && this . _settings . get_boolean ( 'intellihide' ) && ( this . _settings . get_enum ( 'intellihide-action' ) == IntellihideAction . SHOW_PARTIAL || this . _settings . get_enum ( 'intellihide-action' ) == IntellihideAction . SHOW_PARTIAL_FIXED ) ) { if ( this . _dock . _dockState == DockState . SHOWING || this . _dock . _dockState == DockState . SHOWN ) { this . _hide ( true ) ; } else { this . _show ( ) ; } } else { if ( this . _settings . get_boolean ( 'dock-fixed' ) && this . _dock . _monitor . inFullscreen ) { this . _hide ( ) ; } else { this . _show ( ) ; } } } } } } else { if ( this . _switchWorkspaceQuickShow && this . _switchedWorkspace && this . _quickShowTimeoutId == 0 ) { this . _show ( true ) ; let timeout = this . _settings . get_double ( 'quick-show-timeout' ) ; this . _quickShowTimeoutId = GLib . timeout_add ( GLib . PRIORITY_DEFAULT , timeout , this . _quickShowExit . bind ( this ) ) ; } else { if ( this . _quickShowTimeoutId == 0 ) this . _hide ( ) ; } } } }
intellihide function to determine if dock overlaps a window
intellihide function to determine if dock overlaps a window
// Return if we are in overview mode //else in normal mode: // SANITY CHECK //global.log("==============================================================="); //for (let i = windows.length-1; i >= 0; i--) { //let win = windows[i].get_meta_window(); //let wclass = win.get_wm_class(); //let wtype = win.get_window_type(); //let wfocus = win.has_focus(); //let wapp = this._tracker.get_window_app(win); //let msg = wclass + " [" + wtype + "] focused? " + wfocus + " wintype? " + wtype + " app? " + wapp; //global.log(msg); //} //global.log("---------------------------------------------------------------"); // This is the default window on top of all others // Find focused window (not always top window) // If there isn't a focused app, use that of the window on top //this._focusApp = this._tracker.focus_app || this._tracker.get_window_app(this._topWindow); // SANITY CHECK // global.log("dx="+dx+" dy="+dy+" || dcx="+Math.round(dcx)+" dcy="+dcy); // global.log("dw="+dw+" dh="+dh+" || dcw="+dcw+" dch="+dch);