Skip to content

Capturing window is broken in screenshot view caused by a js error #811

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

Closed
lost-melody opened this issue Apr 1, 2024 · 9 comments · Fixed by #812
Closed

Capturing window is broken in screenshot view caused by a js error #811

lost-melody opened this issue Apr 1, 2024 · 9 comments · Fixed by #812
Labels
bug Undesirable behavior WIP Already working on it, bear with us!

Comments

@lost-melody
Copy link
Collaborator

Describe the bug
As a GNOME feature, we can press PrtSc to take a screenshot, and in the "screenshot view" we can then press w to preview and select a window to capture.
Now when I try to capture a window, there's no preview displayed and no window to select. Plus an error is observed in logs. (see addition context)

To Reproduce
Steps to reproduce the behavior:

  1. Press PrtSc (or whatever keybinding for Take a screenshot interactively in GNOME keyboard shortcuts settings).
  2. Press w if not in window selection view.
  3. Result: no window is listed here.

Expected behavior
Previews of windows should be listed to select and capture.

Screenshots

Nothing displayed

capture-window-nothing

Expected

capture-window-expected

System information:

System information
Distribution: Arch Linux
GNOME Shell 46.0
Display server: Wayland
PaperWM branch/tag: develop
PaperWM commit: 8f80d09f1cd5c32a36f4acdfd2e8af959ea1d35c
Enabled extensions:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- AlphabeticalAppGrid@stuarthayhurst
- [email protected]
- [email protected]
- blur-my-shell@aunetx
- [email protected]
- [email protected]

Additional context

Error logs
gnome-shell[619105]: JS ERROR: TypeError: meta_window is undefined
    spaceOfWindow@file:///home/lost-melody/.local/share/gnome-shell/extensions/[email protected]/tiling.js:2919:9
    sortWindows@file:///home/lost-melody/.local/share/gnome-shell/extensions/[email protected]/overviewlayout.js:263:32
    computeLayout@file:///home/lost-melody/.local/share/gnome-shell/extensions/[email protected]/overviewlayout.js:101:23
    setupOverrides/<@file:///home/lost-melody/.local/share/gnome-shell/extensions/[email protected]/patches.js:244:49
    vfunc_allocate@resource:///org/gnome/shell/ui/screenshot.js:729:33
    @resource:///org/gnome/shell/ui/init.js:21:20

A workaround is to add those codes in function sortWindows:

export function sortWindows(a, b) {
    if (!a || !b || !a.metaWindow || !b.metaWindow) {
        return 0;
    }
    // ...
}

This is not a fix, but I cannot proceed any further.

@lost-melody lost-melody added the bug Undesirable behavior label Apr 1, 2024
@Lythenas
Copy link
Collaborator

Lythenas commented Apr 1, 2024

I can confirm this issue on Gnome 46. I think on Gnome 45 it still worked some time ago (but not 100% sure).

The behavior is also a bit inconsistent. From very limited testing:

  • I have two monitors, monitor 1 with multiple firefox windows, discord and thunderbird
  • taking a screenshot on monitor 2 with only a single firefox window works fine
  • taking a screenshot on monitor 2 with steam main, friends and chat windows only shows the chat window. But it shows on monitor 1 and only the part that was visible on monitor 2.
  • taking a screenshot on monitor 1 shows only the discord window, which was out of screen. But it shows on monitor 2.
  • somehow it works fine if all windows on the workspace take up the entire screen (e.g. Super+f).

It seems like sortWindows is called with arguments that don't have a metaWindow field.

@jtaala does this have something to do with what you implemented for the gnome overview? If so can you take a look here? Otherwise I will try to look into it.

@jtaala
Copy link
Collaborator

jtaala commented Apr 1, 2024

Sure, just pushed up a fix for that comparator.

Can you please test branch fix-gnome-window-screenshot?

@lost-melody
Copy link
Collaborator Author

Yes it fixes the problem.

@jtaala
Copy link
Collaborator

jtaala commented Apr 1, 2024

Well, it's fixed in that the windows show, but it's also showing PaperWM's clipping for partially shown windows:

image

A workaround this by going into Gnome overview (which Gnome window screenshot works correctly). We could override the window screenshot to either go into Gnome overview first or disable PaperWM's clipping for the screenshot...

Both of those options are some work, I'll push up this fix first anyways and keep this issue open.

@jtaala
Copy link
Collaborator

jtaala commented Apr 1, 2024

Just a heads-up that I'm going to try fix the clipping issue tonight (will experiment with hiding the clip actor while in screenshot view). If that doesn't go well, I'll just merge this branch for a partial fix.

@jtaala
Copy link
Collaborator

jtaala commented Apr 2, 2024

Morning all,

I believe I've now fixed the clipping windows issue. @lost-melody, could you please pull the latest on fix-gnome-window-screenshot and test?

I've added a patch to remove window clipping (which clips windows to the monitor boundaries in PaperWM) when the ScreenshotUI opens, and then re-apply them when it closes).

@jtaala jtaala added the WIP Already working on it, bear with us! label Apr 2, 2024
@lost-melody
Copy link
Collaborator Author

@jtaala, I've tried your fix and it works, but a side effect is introduced. If I return to Overview from ScreenshotUI (by pressing Super, PrtSc, then Esc), windows are clipped.

@jtaala
Copy link
Collaborator

jtaala commented Apr 3, 2024

@jtaala, I've tried your fix and it works, but a side effect is introduced. If I return to Overview from ScreenshotUI (by pressing Super, PrtSc, then Esc), windows are clipped.

Nice pickup @lost-melody. Fixed.

@jtaala jtaala linked a pull request Apr 3, 2024 that will close this issue
@jtaala
Copy link
Collaborator

jtaala commented Apr 3, 2024

  • I have two monitors, monitor 1 with multiple firefox windows, discord and thunderbird
  • taking a screenshot on monitor 2 with only a single firefox window works fine
  • taking a screenshot on monitor 2 with steam main, friends and chat windows only shows the chat window. But it shows on monitor 1 and only the part that was visible on monitor 2.
  • taking a screenshot on monitor 1 shows only the discord window, which was out of screen. But it shows on monitor 2.
  • somehow it works fine if all windows on the workspace take up the entire screen (e.g. Super+f).

Most of these issues are due to the gnome paradigm of "one workspace across all monitors" (i.e. see #389 (comment)). Even with multiple monitors, on vanilla gnome it's actually one workspace. That's what's happening here, for screenshots, gnome is pulling the windows on that "workspace" (which conflicts with PaperWM approach of having one workspace per monitor).

Anyways, what it means is that for screenshotting windows with PaperWM (and multiple monitors), is that pressing printscreen will show the windows on that PaperWM space... which may be spread out across multiple monitors (in the case where some windows are to the left/right in scrolling space.

It's workable, but may be confusing.

@jtaala jtaala closed this as completed in 7db476d Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Undesirable behavior WIP Already working on it, bear with us!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants