fthx / dock-from-dash

GNU General Public License v3.0
97 stars 20 forks source link

screen border not updated using dock #60

Closed MrReSc closed 1 year ago

MrReSc commented 2 years ago

When I use my laptop without external monitors and then connect it to my dock with two monitors and close the lid of the laptop, the dock no longer works. Only when I deactivate the extension and activate it again, the dock works again. I think the primary monitor is no longer correct.

OS: Fedora 36

fthx commented 2 years ago

Ok I'm starting to look at this. Do you have the JS error message in logs?

fthx commented 2 years ago

I do not have a dock until end of august ;-) ...

fthx commented 2 years ago

https://github.com/fthx/dock-from-dash/blob/06b7ce5b4caecc9b27967e39d3c7eaed9ab0a707/extension.js#L137

fthx commented 2 years ago

In a normal world, it should be updated since: https://github.com/fthx/dock-from-dash/blob/06b7ce5b4caecc9b27967e39d3c7eaed9ab0a707/extension.js#L290

MrReSc commented 2 years ago

I have found the following error:

remo@P14s ~ $ journalctl -n10000 | grep "JS ERROR"
Jul 28 14:55:17 P14s gnome-shell[2394]: JS ERROR: Invalid work id 3: Error: Invalid work id 3
Jul 28 14:55:17 P14s gnome-shell[2394]: JS ERROR: Invalid work id 4: Error: Invalid work id 4
Jul 28 14:55:17 P14s gnome-shell[2394]: JS ERROR: Invalid work id 3: Error: Invalid work id 3
Jul 28 14:55:17 P14s gnome-shell[2394]: JS ERROR: Invalid work id 4: Error: Invalid work id 4
Jul 28 14:55:17 P14s gnome-shell[2394]: JS ERROR: Invalid work id 3: Error: Invalid work id 3
Jul 28 14:55:17 P14s gnome-shell[2394]: JS ERROR: Invalid work id 4: Error: Invalid work id 4
Jul 28 14:55:17 P14s gnome-shell[2394]: JS ERROR: Invalid work id 3: Error: Invalid work id 3
Jul 28 14:55:17 P14s gnome-shell[2394]: JS ERROR: Invalid work id 4: Error: Invalid work id 4
Jul 28 14:55:17 P14s gnome-shell[2394]: JS ERROR: Invalid work id 3: Error: Invalid work id 3
Jul 28 14:55:17 P14s gnome-shell[2394]: JS ERROR: Invalid work id 4: Error: Invalid work id 4
Jul 28 14:56:07 P14s gnome-shell[2394]: JS ERROR: Invalid work id 3: Error: Invalid work id 3
Jul 28 14:56:07 P14s gnome-shell[2394]: JS ERROR: Invalid work id 4: Error: Invalid work id 4
...

I am not sure if this is really related.

The error is also reproducible in reverse. That is, if I disconnect the laptop from the docking station, then the dock is also not present on the laptop. Only after a switch on and off the extension.

MrReSc commented 2 years ago

Have you found out anything yet?

fthx commented 1 year ago

Is this issue still present ?

MrReSc commented 1 year ago

Yes

fthx commented 1 year ago

Does it happen only with a dock ?

fthx commented 1 year ago

Ok I let this one open. These workid errors happen after disabling/enabling extension. I'll try to disable it in a clean way, I guess that will do the trick.

fthx commented 1 year ago

workId starts with 3 then is increased each time extension is disabled/reenabled.

So a workid = 3 error after lid close or ... talks about the previous instance of the dock (that is a GS Dash object).

MrReSc commented 1 year ago

Does it happen only with a dock ?

Yes only with a dock.

MrReSc commented 1 year ago

Ok I let this one open. These workid errors happen after disabling/enabling extension. I'll try to disable it in a clean way, I guess that will do the trick.

That's what I've been looking for. Unfortunately, I am not familiar with the development for gnome and could not debug. I also think that it works then.

fthx commented 1 year ago

I found the good way to disable properly the dock, I get no more workids errors. I currently manage another (harmless) error for the screen border box that triggers the dock.

fthx commented 1 year ago

Hope it will fix the dock error (but I'll use my work dock from january).

fthx commented 1 year ago

Was more complicated than expected... GS links signals to the dock but does not store them in variables. These signals are called with a non existent previous dock instance. So avoid to make anything with the previous dock. https://github.com/fthx/dock-from-dash/commit/6ca0f76dfbe16a977950d66656fefd29c9cfb97e

fthx commented 1 year ago

Feel free to reopen if the usb dock issue is still here.

MrReSc commented 1 year ago

When I connect the laptop to the dock, the primary monitor changes to a monitor connected to the dock. To open the dock, I have to touch the bottom of the screen on the secondary monitor (formerly primary) and the dock opens on the primary monitor connected to the dock.

It looks like the dock now appears on the right monitor but the trigger remains on the wrong one.

Feel free to reopen if the usb dock issue is still here.

I can't reopen the issue myself, unfortunately.

fthx commented 1 year ago

Could you add (then logout/login of course):

this._screen_border_box_refresh();

just before the end of _dock_refresh function?

Like this:


_dock_refresh() {
        if (this.dock_refreshing) {
            return;
        }
        this.dock_refreshing = true;

        this.dock.work_area = Main.layoutManager.getWorkAreaForMonitor(Main.layoutManager.primaryIndex);
        if (!this.dock.work_area) {
            return;
        }

        this.dock.max_dock_height = Math.round(this.dock.work_area.height * DASH_MAX_HEIGHT_RATIO / 100);
        this.dock.set_width(this.dock.work_area.width);
        this.dock.set_height(Math.min(this.dock.get_preferred_height(this.dock.work_area.width), this.dock.max_dock_height));
        this.dock.setMaxSize(this.dock.width, this.dock.max_dock_height);

        if (settings.get_boolean('always-show') || this.dock.is_visible()) {
            this.dock.set_position(this.dock.work_area.x, this.dock.work_area.y + this.dock.work_area.height - this.dock.height);
        } else {
            this.dock.set_position(this.dock.work_area.x, this.dock.work_area.y + this.dock.work_area.height);
        }

        this.dock.show();
        if (!settings.get_boolean('always-show') && !this.dock._dashContainer.get_hover()) {
            this.dock._hide_dock();
        }

        this._screen_border_box_refresh();

        this.dock_refreshing = false;
    }
fthx commented 1 year ago

... and tell me if it does solve your problem.

I think in some edge cases like yours,

this.dock._box.connect('notify::position', this._screen_border_box_refresh.bind(this));
this.dock._box.connect('notify::size', this._screen_border_box_refresh.bind(this));

these signals were not triggered (monitor with same size, same relative position).

MrReSc commented 1 year ago

Could you add (then logout/login of course):

this._screen_border_box_refresh();

That solved the problem! Now everything seems to work. Thanks for the help and the extension itself.