Skip to content
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

override_redirect protection breaks context menus on ultrawide #6518

Open
n0madK opened this issue Apr 10, 2021 · 36 comments · Fixed by QubesOS/qubes-gui-daemon#71 or QubesOS/qubes-gui-daemon#82
Labels
affects-4.1 This issue affects Qubes OS 4.1. C: gui-virtualization diagnosed Technical diagnosis has been performed (see issue comments). P: default Priority: default. Default priority for new issues, to be replaced given sufficient information. r4.1-bullseye-stable r4.1-buster-stable r4.1-centos-stream8-cur-test r4.1-dom0-stable r4.1-fc31-stable r4.1-fc32-stable r4.1-fc33-stable r4.1-fc34-cur-test T: bug Type: bug report. A problem or defect resulting in unintended behavior in something that exists.

Comments

@n0madK
Copy link

n0madK commented Apr 10, 2021

Qubes OS version

Qubes 4.1

Brief summary

When I connect an ultrawide monitor to a laptop, then open a context menu in an application on the far right side of the screen, the overridde_redirect protection triggers and the context menu does not open.

To Reproduce

Steps to reproduce the behavior:

  1. Boot laptop
  2. Start Thunderbird
  3. Connect ultrawide monitor
  4. Q->System Tools->Display, disable laptop screen
  5. Drag Thunderbird to the right-side
  6. Right-click on an email

Expected behavior

Context menu opens.

Actual behavior

Context menu flickers and closes. The override_redirect protection popup shows.

Solutions you've tried

Restarting the VM after the screen settings have been changed allows the context menu to behave as expected

Additional context

When opening the context menu, a window opens that extends from the left edge of the screen to the place where the context menu should open, then immediately closes. I wonder if:

  1. the application (Thunderbird) is first opening a window the full width of the current screen before resizing
  2. the xside.c retains the original screen geometry at VM boot time (ie changing the screen size does not propagated to running VMs) - https://github.com/QubesOS/qubes-gui-daemon/pull/41/files#diff-7897f6116dd3815ad17499205f816d770805aca6ce63e96ff55be4fe2d95a3d6R1147

I'm not sure how to debug this, but I also don't see how else this bug would trigger.

Related, non-duplicate issues

QubesOS/qubes-gui-daemon#41
#4705

@n0madK n0madK added P: default Priority: default. Default priority for new issues, to be replaced given sufficient information. T: bug Type: bug report. A problem or defect resulting in unintended behavior in something that exists. labels Apr 10, 2021
@andrewdavidwong andrewdavidwong added C: gui-virtualization needs diagnosis Requires technical diagnosis from developer. Replace with "diagnosed" or remove if otherwise closed. labels Apr 10, 2021
@andrewdavidwong andrewdavidwong added this to the Release 4.1 milestone Apr 10, 2021
@SaswatPadhi
Copy link

After a dom0 update this bug appears on my system too. It's super annoying! Basic apps that used to work fine (like Firefox) now crash quite often.

  • First a popup shows up regarding override_redirect
  • At some point the window closes and GUI for the AppVM crashes
  • Only solution is to restart the AppVM and hope that I don't hit the bug again

Here's what I see in the guid.<appvm>.log:

invalid PMaxSize for 0x54001d2 (32766/32766)
invalid PMaxSize for 0x54001e3 (32766/32766)
invalid PMaxSize for 0x54001e6 (32766/32766)
This VM has attempted to create a very large window in a manner that would have prevented you from closing it and regaining the control of Qubes OS's graphical user interface.

As a protection measure, the "override_redirect" flag of the window in question has been unset. If this creates unexpected issues in the handling of this VM's windows, please set "override_redirect_protection" to "false" for this VM in /etc/qubes/guid.conf to disable this protection measure and restart the VM.

This message will only appear once per VM per session. Please click on this notification to close it.
ErrorHandler: BadAccess (attempt to access private resource denied)
                 Major opcode: 130 (MIT-SHM)
                 Minor opcode: 1 (X_ShmAttach)
                 ResourceID:   0x54001e7
                 Failed serial number:  2170
                 Current serial number: 2171
XShmAttach failed for window 0x54001e6(remote 0x800048)
ErrorHandler: BadAccess (attempt to access private resource denied)
                 Major opcode: 130 (MIT-SHM)
                 Minor opcode: 1 (X_ShmAttach)
                 ResourceID:   0x54001e0
                 Failed serial number:  2191
                 Current serial number: 2192
XShmAttach failed for window 0x54001e6(remote 0x800048)

@SaswatPadhi
Copy link

Also note that, the warning states:

please set "override_redirect_protection" to "false" for this VM in /etc/qubes/guid.conf to disable this protection measure

But at the top of /etc/qubes/guid.conf we see:

# EDITING THIS FILE WILL NOT HAVE ANY EFFECT! It is not read by GUI daemon
# anymore, and is left here for reference only. To configure the GUI daemon,
# use qvm-features (see 'man qvm-features' for details).

Can we:

  1. update warning so it states the qvm-features commandline to be used?
  2. provide a UI to flip this Qube Manager? at least globally in dom0, because we do so for allow_fullscreen etc.

@andrewdavidwong
Copy link
Member

  1. provide a UI to flip this Qube Manager? at least globally in dom0, because we do so for allow_fullscreen etc.

This should be filed as a separate issue, as it would be a separate enhancement.

@na--
Copy link

na-- commented Jun 9, 2021

This bug regularly occurs for me and messes up the NetworkManager's sys-net system tray icon, despite the fact that I should have disabled the override_redirect protection (I'm on 4.1) through qvm-features 😕

$ qvm-features sys-net gui-override-redirect-protection
false

@SaswatPadhi
Copy link

Same for me. This issue is making it impossible for me to use most apps, like Firefox, which show context menus / popups.

Could someone please state the exact steps to disable this?

@marmarek
Copy link
Member

$ qvm-features sys-net gui-override-redirect-protection
false

String "false" actually is not a boolean negative value... An empty string is (see man qvm-features). So, it should be:

qvm-features sys-net gui-override-redirect-protection ""

But also, it should not trigger on normal usage, and I never got it for NetworkManager, Firefox or any other similar common applications. Can anyone who is affected set debug property on an affected qube to "1" (or true or similar) and then send a guid log when the issue happens?

@SaswatPadhi
Copy link

Yes sure, I can try to post a debug log in a bit.

Thanks a lot for the instructions as well, @marmarek!

@n0madK
Copy link
Author

n0madK commented Jul 1, 2021

I can reproduce this 100% of the time with the steps in my first post.
guid.email.log

After disabling gui-override-redirect-protection and triggering the issue, the top right menu completely breaks in Thunderbird:

  1. Start email vm
  2. Plug in ultrawide monitor
  3. Drag Thunderbird off the laptop screen to the right
  4. Open the menu (nothing happens)
  5. Drag Thunderbird back onto the laptop screen
  6. Open the menu (nothing happens)

I have to close and re-open the Thunderbird to recover.
guid.email.log

@marmarek
Copy link
Member

marmarek commented Jul 1, 2021

Thanks, that's exactly the log I needed!

handle_configure_from_vm, local 0x5e00232 remote 0x140013e, 338/605, was 200/200, ovr=1, xy 2693/146, was 0/0
force_on_screen(from handle_configure_from_vm) returns 1 (reason 3): window 0x5e00232, xy 2693 146, wh 338 605, work area 1920 1080 borderwidth 0
XMoveResizeWindow local 0x5e00232 remote 0x140013e, xy 2693 146 (vm_window is 2693 146) wh -773 605
MSG_WINDOW_DUMP for 0x5e00232(0x140013e): 338x605, type = 0
process_xevent_configure(synth 0) local 0x5e00232 remote 0x140013e, 64763/605, was -773/605, xy 2693/146 was 2693/146

Negative size! It wrapped around into absurdly large window. I guess something went wrong in QubesOS/qubes-gui-daemon#56

@marmarek
Copy link
Member

marmarek commented Jul 1, 2021

work area 1920 1080

Is this accurate for your (combined) screen size? if you have external monitor connected, then likely not...
Can you check xprop -root _NET_WORKAREA in dom0?

DemiMarie added a commit to DemiMarie/qubes-gui-daemon that referenced this issue Jul 1, 2021
Instead of trying to check for offscreen windows while sanitizing window
positions, return early in the case of offscreen windows, and then
sanitize x, y, width, height, x + width, and y + height separately.
This takes more code, but the new code is much, *much* simpler and
easier to understand.

Fixes QubesOS/qubes-issues#6518.
DemiMarie added a commit to DemiMarie/qubes-gui-daemon that referenced this issue Jul 1, 2021
Instead of trying to check for offscreen windows while sanitizing window
positions, return early in the case of offscreen windows, and then
sanitize x, y, width, height, x + width, and y + height separately.
This takes more code, but the new code is much, *much* simpler and
easier to understand.

Fixes QubesOS/qubes-issues#6518.
@n0madK
Copy link
Author

n0madK commented Jul 1, 2021

Laptop only

$ xprop -root _NET_WORKAREA
_NET_WORKAREA(CARDINAL) = 0, 39, 1920, 1041, 0, 39, 1920, 1041, 0, 39, 1920, 1041

Monitor only

$ xprop -root _NET_WORKAREA
_NET_WORKAREA(CARDINAL) = 0, 39, 5120, 1401, 0, 39, 5120, 1401, 0, 39, 5120, 1401

Laptop+monitor mirrored

$ xprop -root _NET_WORKAREA
_NET_WORKAREA(CARDINAL) = 0, 39, 5120, 1401, 0, 39, 5120, 1401, 0, 39, 5120, 1401

DemiMarie added a commit to DemiMarie/qubes-gui-daemon that referenced this issue Jul 1, 2021
Instead of trying to check for offscreen windows while sanitizing window
positions, return early in the case of offscreen windows, and then
sanitize x, y, width, height, x + width, and y + height separately.
This takes more code, but the new code is much, *much* simpler and
easier to understand.

Fixes QubesOS/qubes-issues#6518.
DemiMarie added a commit to DemiMarie/qubes-gui-daemon that referenced this issue Jul 1, 2021
Instead of trying to check for offscreen windows while sanitizing window
positions, return early in the case of offscreen windows, and then
sanitize x, y, width, height, x + width, and y + height separately.
This takes more code, but the new code is much, *much* simpler and
easier to understand.

Fixes QubesOS/qubes-issues#6518.
DemiMarie added a commit to DemiMarie/qubes-gui-daemon that referenced this issue Jul 1, 2021
Instead of trying to check for offscreen windows while sanitizing window
positions, return early in the case of offscreen windows, and then
sanitize x, y, width, height, x + width, and y + height separately.
This takes more code, but the new code is much, *much* simpler and
easier to understand.

Fixes QubesOS/qubes-issues#6518.
DemiMarie added a commit to DemiMarie/qubes-gui-daemon that referenced this issue Jul 1, 2021
Instead of trying to check for offscreen windows while sanitizing window
positions, return early in the case of offscreen windows, and then
sanitize x, y, width, height, x + width, and y + height separately.
This takes more code, but the new code is much, *much* simpler and
easier to understand.

Fixes QubesOS/qubes-issues#6518.
DemiMarie added a commit to DemiMarie/qubes-gui-daemon that referenced this issue Jul 1, 2021
Instead of trying to check for offscreen windows while sanitizing window
positions, return early in the case of offscreen windows, and then
sanitize x, y, width, height, x + width, and y + height separately.
This takes more code, but the new code is much, *much* simpler and
easier to understand.

Fixes QubesOS/qubes-issues#6518.
DemiMarie added a commit to DemiMarie/qubes-gui-daemon that referenced this issue Jul 1, 2021
Instead of trying to check for offscreen windows while sanitizing window
positions, return early in the case of offscreen windows, and then
sanitize x, y, width, height, x + width, and y + height separately.
This takes more code, but the new code is much, *much* simpler and
easier to understand.

Fixes QubesOS/qubes-issues#6518.
DemiMarie added a commit to DemiMarie/qubes-gui-daemon that referenced this issue Jul 1, 2021
Instead of trying to check for offscreen windows while sanitizing window
positions, return early in the case of offscreen windows, and then
sanitize x, y, width, height, x + width, and y + height separately.
This takes more code, but the new code is much, *much* simpler and
easier to understand.

Fixes QubesOS/qubes-issues#6518.
marmarek added a commit to marmarek/qubes-gui-daemon that referenced this issue Jul 3, 2021
It is _NET_CURRENT_DESKTOP, not _NET_WM_CURRENT_DESKTOP. Adjust variable
name too.

QubesOS/qubes-issues#6518
marmarek added a commit to marmarek/qubes-gui-daemon that referenced this issue Jul 3, 2021
Subscribe to root window's property change events, otherwise gui-daemon
won't receive _NET_WORKAREA change events.
Update it also after re-reading root window size.

QubesOS/qubes-issues#6518
DemiMarie added a commit to DemiMarie/qubes-gui-daemon that referenced this issue Jul 4, 2021
Instead of trying to check for offscreen windows while sanitizing window
positions, return early in the case of offscreen windows, and then
sanitize x, y, width, height, x + width, and y + height separately.
This takes more code, but the new code is much, *much* simpler and
easier to understand.

Fixes QubesOS/qubes-issues#6518.
@marmarek
Copy link
Member

marmarek commented Aug 26, 2021

Ok, so I'm afraid(?) this is exactly what Xfce requested to do:

_NET_WORKAREA(CARDINAL) = 0, 1229, 1920, 1051, ...

This means Xfce requested to not use area outside of 1920x1051 rectangle at (0, 1229). I'm not sure how a panel between monitors should be represented, but the way it currently is, should result in windows appearing only on the bottom screen...

@SaswatPadhi
Copy link

SaswatPadhi commented Aug 26, 2021

Thanks @marmarek.
I agree that this looks like an Xfce issue at this point. I could set this panel to auto hide and that works well for now.

One remaining question I have is, how does normal window placement work? As in, why are we able to place Firefox in the top monitor (either by dragging it there, or the default placement when mouse is in the monitor), but we can't place context menus there?

@SaswatPadhi
Copy link

Also, dom0 context menus work correctly in both monitors, it's just AppVM context menus that have this issue.

@marmarek
Copy link
Member

marmarek commented Aug 26, 2021

We try to be a bit stricter how VM can place its windows, to prevent it obscuring critical UI elements. With dom0 windows, it's directly responsibility of the window manager only, and apparently it knows more accurate definition of allowed areas.
The context menus are outside of window manager control completely, and that's why we need to enforce placement rules on our own.

@DemiMarie
Copy link

What does xprop -root show? Is there another property that provides more information? _NET_WORKAREA doesn’t provide enough information for the GUI daemon to properly handle this situation.

@qubesos-bot
Copy link

Automated announcement from builder-github

The package qubes-gui-daemon_4.1.15-1+deb10u1 has been pushed to the r4.1 stable repository for the Debian template.
To install this update, please use the standard update command:

sudo apt-get update && sudo apt-get dist-upgrade

Changes included in this update

@qubesos-bot
Copy link

Automated announcement from builder-github

The component gui-daemon (including package qubes-audio-daemon-4.1.15-1.fc32) has been pushed to the r4.1 stable repository for dom0.
To install this update, please use the standard update command:

sudo qubes-dom0-update

Or update dom0 via Qubes Manager.

Changes included in this update

@qubesos-bot
Copy link

Automated announcement from builder-github

The component gui-daemon (including package qubes-audio-daemon-4.1.15-1.fc32) has been pushed to the r4.1 stable repository for the Fedora template.
To install this update, please use the standard update command:

sudo dnf update

Changes included in this update

@andrewdavidwong andrewdavidwong added diagnosed Technical diagnosis has been performed (see issue comments). and removed needs diagnosis Requires technical diagnosis from developer. Replace with "diagnosed" or remove if otherwise closed. labels Sep 9, 2021
DemiMarie added a commit to DemiMarie/qubes-gui-daemon that referenced this issue Aug 2, 2022
Marking as draft because I am not sure if the call to abort() is
justified.

Fixes QubesOS/qubes-issues#6518.
DemiMarie added a commit to DemiMarie/qubes-gui-daemon that referenced this issue Oct 3, 2022
Marking as draft because I am not sure if the call to abort() is
justified.

Fixes QubesOS/qubes-issues#6518.
@andrewdavidwong andrewdavidwong added the affects-4.1 This issue affects Qubes OS 4.1. label Aug 8, 2023
@andrewdavidwong andrewdavidwong removed this from the Release 4.1 updates milestone Aug 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-4.1 This issue affects Qubes OS 4.1. C: gui-virtualization diagnosed Technical diagnosis has been performed (see issue comments). P: default Priority: default. Default priority for new issues, to be replaced given sufficient information. r4.1-bullseye-stable r4.1-buster-stable r4.1-centos-stream8-cur-test r4.1-dom0-stable r4.1-fc31-stable r4.1-fc32-stable r4.1-fc33-stable r4.1-fc34-cur-test T: bug Type: bug report. A problem or defect resulting in unintended behavior in something that exists.
Projects
None yet
7 participants