-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compatibility with Fullscreen Avoider #707
base: develop
Are you sure you want to change the base?
Conversation
tiling.js
Outdated
|
||
// Patch monitor objects prototype to check our space for the inFullscreen | ||
// property. | ||
function patchMonitorInFullscreen() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Lythenas, that this type of patching needs to be done in patches.js and using the patterns there, otherwise this wouldn't pass EGO review) - see examples there for patching prototypes (which will then be automatically reverted on PaperWM disable).
But in principal I can see what you've done here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good though - we can do that after.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't know about the patches.js
file. Will move it there.
But I think we can't use the pattern there, since monitor.prototype
is undefined. Also I am not overwriting a normal function or property. I am setting a getter function for a property. And since that does not exist not sure how to restore it. I guess we would just safe the undefined.
Edit: I think the code in patches
works directly on classes, right? So I don't think we can use it since monitor
are just plain JS objects as far as I can tell.
The prototype seems to apply to all monitor objects but no other objects for some reason. I also don't know what happens when you plug in or unplag a monitor afterwards or change the monitor configuration. It is possible that the prototype will be lost when the objects change.
Maybe there is a better way to patch this but that is what I found works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also note that fullscreen avoider does some interesting stuff for patching by calling toString
on the function and string replacing some things: https://github.com/Noobsai/fullscreen-avoider/blob/master/src/extension.js#L91
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, given what we're doing in this case, we can add it into Utils.js
upgradeGnomeMonitors
:
https://github.com/paperwm/PaperWM/blob/release/utils.js#L526-L536
This is nice since it's a dbus service hook that will get called whenever monitors change (e.g. if we add new monitors and remove monitors). We use this to upgrade monitor objects to add connector information (e.g. HDMI-1, eDP-1 etc.).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anyway, can leave as is for the time being (since it's working fine) and can focus on the other issues (that you mentioned).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edit: I think the code in
patches
works directly on classes, right? So I don't think we can use it sincemonitor
are just plain JS objects as far as I can tell.
No, Monitor
is indeed a class - it's here:
https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/ui/layout.js?ref_type=heads#L158-L171
You're essentially overriding the prototype class getter get inFullscreen()
.
Interestingly, Gnome haven't exported this so that's the main reason why we can't use it directly in patches. You're approach of getting a concrete implementation of one and overriding the prototype (which effects the Monitor class) will work though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok. I thought is is not a class because it only shows up as an [object Object]
in looking glass. But .constructor.name
indeed returns Monitor
.
I'll try have a look at this tonight. Cheers. |
My code in We could also set the |
That would also work - for EGO the rule is "if you add or remove anything to a gnome object (prototype or not), then you must undo that when disabling your extension)". |
Since you pointed out it is indeed a class and not just an object, I think it fits better in |
It still needs some cleanup but I think this PR is ready for testing. See the open todos in the PR description for things to look out for.
when disconnecting the second monitor (where the topbar was moved to) and reconnecting it, the topbar stays on the primary monitor that has a fullscreen window. But that might be a limitation of Fullscreen Avoider, since it only does something on @jtaala should we also mention the compatibility with fullscreen avoider in the readme? |
Well, we could just list it in (with a few comments) in the end |
Cool, will start testing this tomorrow (my Saturday here in Australia). |
this is useful for introspection in looking glass
When running games (through Steam) I noticed the following:
|
Today I experienced a bug when having only one monitor. When I was changing workspaces, the workspace name stayed the same in the top bar. And also some windows didn't want to get tiled. I am not sure whether it's related to this branch or unrelated bug. I might try investigating, replicating during the weekend. Could also be an issue with one of the other extensions I use (or combination of the extensions) |
I learned some time ago to just disable fullscreen in the game video settings, make it windowed, and fullscreen manually with WM/DE. For most of the games I tried it worked better in general with tiling WMs. |
I also noticed these issues. I added them to the list in the description of the PR. I think I just need to trigger the update more often. I will try to fix this tomorrow. |
The case where the topbar is not on the same monitor as the space is handled by that function.
This should be fixed now. |
Sorry about this, I don't think that was right. They were getting tiled, it was just the spacing as you also noticed, and I reported again in the next reply.
Thank you for these new commits, seems like that fixed the issues I reported. I noticed one more issue, nothing critical. When I fullscreen something on any of the monitors, move cursor to another monitor, I get an animation on the primary like the panel was going away... Ie. the window gets immediately smaller, to make space for the bar, and then this space gradually disappears - like an animation |
@jtaala note about the changes in |
This fixes an issue with fullscreen avoider when the workspace on the secondary monitor has "Hide top bar" set.
Merging the develop branch seems to have broken some things. I will look into it later. |
I think I fixed the issues, but now there is some "jumping" of the windows on the secondary monitor when fullscreening on the primary. The reason for this is that we do multiple layouts but the first does not yet know that the topbar moved. I'm not sure how to fix that. Also I was only having this issue on my PC, I couldn't reproduce it in the VM. Also not after changing which monitor is the primary. |
Thanks @Lythenas, I've been working on that other PR (#741) and haven't looked at this yet. I've really been waiting for @Rutherther to test this PR since I don't use that extension and @Rutherther seems to have use cases to test against.
Happy to have a look. I've made some changes in #741 which fix some layout timing issues (mainly for window resizing though) so once I merge that in I'd be happy to have a look here (will install fullscreen avoider etc.). |
Hello, I know of one bug, but I cannot reproduce it reliably. Sometimes the bar stays on the other monitor, I have to fullscreen and defulscreen something on the primary monitor to get it back. But I don't know how it ended on the second monitor. I am also not sure if this is bug coming from Fullscreen Avoider, or from some change from PaperWM |
I commented out the line added in 4d829a8 for now. Without that, I got the blackscreen part bug on the first fullscreen on login, but not on the next ones. I will test like this for now and let you know of any bugs if I encounter any. Seems like "Queue layout after panelBox position changed" is supposed to fix hide top bar, I don't use that so I hope that commenting out the line shouldn't break anything else for me. |
I am also getting the half blackscreen bug, but not in anything I care about^^. And I think in some cases it is actually fixed by the queued layout (because it is briefly shows black and then fixes itself). To me this looks like the half blackscreen bug could be triggered by to many layout calls. And I think we can (and probably should) cut down on those. As said before I will wait for #741 and then try to improve this PR. But thank you for testing. It's good that it at least mostly works. I also noticed that it sometimes behaves a bit differently when running in an Ubuntu 23 VM and when running on my Arch desktop. |
Yeah, in my testing for #741, I've found something common between the apps that cause the half blackscreen bug - they all send multiple fullscreen change signals. For example, osu! sends 8-12 of these change singals during it's startup. Each of these signals triggers the Patch 3401 stops the blackscreen bug from occurring - but the changes in #741 will cut down on layout calls either way. |
For now I only merged |
The jumpiness is fixed now and I believe most things work fine now. But I need to test more for some edge cases. Feel free to also test if you have time. I think it should be fine to use. |
@Rutherther - could you run this through your various use cases and provide feedback here? Thanks all! |
Alright, I am trying to test the newest version now. I found out one problem. I am not sure if this was a problem even before, but I noticed it just now. When I fullscreen on my main monitor, and move the fullscreen window to the monitor with the topbar, the topbar doesn't move back to the main monitor. It gets hidden instead. Not even sure if this could be PaperWM issue (with fullscreen detect function patch I would suppose), or Fullscreen Avoider issue. |
I can reproduce that. I will look into it. I'm guessing this is a race condition. I.e. fullscreen-changed is fired when the fullscreen window moves but PaperWM state has not updated yet, so it still considers the old workspace fullscreen instead of the new one. I think something similar happens when you minimize a fullscreen window and then maximize it again. Probably mostly an issue with games. That happens with Into the Breach because it minimizes when you switch monitors. |
There are probably also other edge cases that cause problems. Probably swapping workspaces and things like that. I also need to properly test again if nothing broke when Fullscreen Avoider is disabled. |
Just an update for this: For many cases this PR works fine. However for some games I noticed edge cases that I can't figure out. Mostly there are two things:
I am unsure if this can be properly fixed with the current approach. I currently also do some trickery and resend the "in-fullscreen-changed" signal. This is kind of hacky and it might be better to just reimplement FullscreenAvoiders functionality in PaperWM. In any case for me I found it more useful to just set the primary monitor in gnome to my "secondary" monitor, since I only really use fullscreen windows (games) on one monitor. I'm converting this to a draft, since I probably won't finish this PR. If someone else wants to take over I would be happy to review it and test it out. |
Thanks for your work on this @Lythenas! |
Fixes #703
This adds support for the Fullscreen Avoider extension: https://github.com/Noobsai/fullscreen-avoider This extension moves the topbar to a secondary monitor (if avilable) if the primary monitor has a fullscreen window.
The main functionality is working so it is technically usable, but there are still some issues:
fixTopBar
is not effectively useless and could be removed