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

Switching screen does not work on Wayland #99

Closed
thomwiggers opened this issue Feb 18, 2019 · 10 comments
Closed

Switching screen does not work on Wayland #99

thomwiggers opened this issue Feb 18, 2019 · 10 comments

Comments

@thomwiggers
Copy link

thomwiggers commented Feb 18, 2019

Environment

  • Arch Linux
  • Python version 3.7

Pympress

  • version: 1.2.0-1
  • Installation method: AUR

Expected behaviour

  • Switch screens

Steps to reproduce

  • run Pympress
  • press s

Problem

Switching screens doesn't work. The following appears in the log, and also appears at pympress startup:

Traceback (most recent call last):                                                             
  File "/usr/lib/python3.7/site-packages/pympress/ui.py", line 1107, in on_window_state_event  
    util.set_screensaver(fullscreen, self.c_win.get_window())                                  
  File "/usr/lib/python3.7/site-packages/pympress/util.py", line 209, in set_screensaver       
    status = os.system("xdg-screensaver {} {}".format(cmd, window.get_xid()))                  
AttributeError: 'GdkWaylandWindow' object has no attribute 'get_xid'                           
@Cimbali
Copy link
Owner

Cimbali commented Feb 19, 2019

Hi @thomwiggers, and thanks for reporting this bug. First a couple of questions:

  • Can you be a bit more specific on your environment? It seems you're using Wayland, what are your desktop environment and window manager? The log of pympress should contain a lot more information on dependencies versions etc.
  • What do you mean by switching screens? Are you trying to switch full screen mode on/off or to maximise a window? Or do you want to swap the two windows to different displays?

We can fix the error that is reported in your log, but I'm not even sure that it is related to the bug you have. It is an error in the handling of the event after a window is (un)maximised, and should really have no impact except on disabling the screen saver. I suppose that playing videos does not work with Wayland either.

Is XWayland enabled? What happens if you launch GDK_BACKEND=x11 pympress, does that fix the bug?

The recommended way of installing on Linux is pip, as I have no control at all on AUR packages. In case the previous doesn't work, can you try installing from pip? In particular, the current version is 1.2.0 since February 7th so I'm not sure what the 1.2.0-1 version from AUR, updated on January 4th can be (I'm assuming the "1.20.0-1" is a typo and you meant "1.2.0-1").

@thomwiggers
Copy link
Author

thomwiggers commented Feb 20, 2019

1.20 was indeed a typo.

I'm running Gnome 3 on GDM on Wayland.

pip install pympress into an empty virtualenv is broken. It installs 1.3.1, but then fails with a ModuleNotFoundError: No module named 'gi'. Apparently pygobject is missing from the install_requires dependencies: installing that fixes the missing module.

Using GDB_BACKEND=x11 does indeed work, both with 1.3.1 and 1.2.0.

I'm not sure what you mean by "the current version is 1.2.0 since February 7th", because Github shows that 1.2.0 was available in September.

@thomwiggers thomwiggers changed the title Switching screen does not work Switching screen does not work on Wayland Feb 20, 2019
Cimbali added a commit that referenced this issue Feb 20, 2019
In Wayland, fail the the enabling/disabling of screensavers with a
simple warning.
@Cimbali
Copy link
Owner

Cimbali commented Feb 20, 2019

Thanks for the clarifications. Nevermind the dates, the github releases got me confused because I forgot to convert the latest tags to releases. (Still not sure what the -1).

  • gi is a module that is installed globally, as it stands for gobject introspections, meaning it depends on external libraries. If you want to use a virtualenv, you need to give it access to global modules, i.e. create the virtualenv using --system-site-packages
  • A number of things can't work on Wayland (meaning without XWayland), most notably screensavers and VLC videos
  • Can you specify what it is you are trying to achieve?
  • Using the current master (installed with e.g. pip install --force-reinstall git+https://github.com/Cimbali/pympress#egg=pympress from inside a virtualenv with global modules) should hide the AttributeError and replace it with a nicer warning in your pympress log.

@thomwiggers
Copy link
Author

thomwiggers commented Feb 21, 2019

The -1 is just the version of the packaging.

I disagree that you should necessarily specify --system-site-packages, the setup.py should be self-contained to allow development and testing in virtualenvs. Enabling --system-site-packages should not interfere with pygobject being part of setup.py: if it's part of the system packages then it will not be installed in the virtualenv. Similarly it should not influence people who try to install via pip install --user. The fact that you need extra dependencies to compile pygobject does not change this.

However, that is off topic for this issue.

As far as I could tell, the documentation does not mention that Wayland is poorly supported. With regards to what I was trying to do: just launching Pympress already starts popping up the traceback, probably as it is trying to set full screen and move the windows to specific displays (which doesn't work without XWayland). Pressing S to switch windows is another way to trigger the warnings (and it doesn't work).

I haven't tested it, but I think the warning could be more helpful, "unsupported OS" is extremely vague (especially since it's the WM, not the OS that's not supported).

@Cimbali
Copy link
Owner

Cimbali commented Feb 21, 2019

I'd rather we don't need to recompile gtk or gobject at every pympress install. This leads to bloat, out of date libraries, extends the install requirements to a compilation toolchain and the development headers of a bunch of other packages, etc etc. It's not worth it, and that's literally why there is the --system-site-packages on virtualenv. Alternately, if you need pygobject inside the virtualenv, then install it manually. Finally, the external dependencies of pympress are well documented here on github and on pypi, and can be included in the packages for every platform (as is done in the AUR package you installed).

Nevertheless, I started a discussion on that at #100 (we need at least to fail in a more graceful way than ModuleNotFoundError: No module named 'gi').

For wayland support:

  • I couldn't find any screensaver tool to suspend screensavers. Feel free to point to one if it's available, and I'll integrate it. This is really not a main feature of pympress though.
  • The reason videos don't work is that libvlc doesn't have support for embedding videos in a xwayland application. I'm working on a GstPlayer binding so that pympress can use gstreamer instead of VLC, whenever the latter doesn't work. However, this isn't stable for some reason.
  • You can always use Xwayland to restore those features.

Finally, on the bug. Is s for switching windows working, now that the error is caught and replaced with a warning? This only uses portable gtk methods, so wayland should not matter here.

@thomwiggers
Copy link
Author

thomwiggers commented Feb 21, 2019

No, S does not work, and this is all that is in the log:

INFO:pympress.__main__:Pympress: 1.3.1 ; Python: 3.7.2 ; OS: Linux 4.20.10-arch1-1-ARCH ; Gtk 3.24.5 ; GLib  2.58.2 ; Poppler 0.74.0 cairo ; Cairo 1.16.0 , pycairo 1.18.0 ; Media: GtkImage gif player, VLC 3.0.6 Vetinari
WARNING:pympress.util:Unsupported OS: can't enable/disable screensaver
WARNING:pympress.util:Unsupported OS: can't enable/disable screensaver
WARNING:pympress.util:Unsupported OS: can't enable/disable screensaver
WARNING:pympress.util:Unsupported OS: can't enable/disable screensaver
WARNING:pympress.util:Unsupported OS: can't enable/disable screensaver
WARNING:pympress.util:Unsupported OS: can't enable/disable screensaver
WARNING:pympress.util:Unsupported OS: can't enable/disable screensaver
WARNING:pympress.util:Unsupported OS: can't enable/disable screensaver
WARNING:pympress.util:Unsupported OS: can't enable/disable screensaver
WARNING:pympress.util:Unsupported OS: can't enable/disable screensaver
WARNING:pympress.util:Unsupported OS: can't enable/disable screensaver
WARNING:pympress.util:Unsupported OS: can't enable/disable screensaver
WARNING:pympress.util:Unsupported OS: can't enable/disable screensaver
WARNING:pympress.util:Unsupported OS: can't enable/disable screensaver
WARNING:pympress.util:Unsupported OS: can't enable/disable screensaver
WARNING:pympress.util:Unsupported OS: can't enable/disable screensaver
WARNING:pympress.util:Unsupported OS: can't enable/disable screensaver
WARNING:pympress.util:Unsupported OS: can't enable/disable screensaver
WARNING:pympress.util:Unsupported OS: can't enable/disable screensaver
WARNING:pympress.util:Unsupported OS: can't enable/disable screensaver
WARNING:pympress.util:Unsupported OS: can't enable/disable screensaver
WARNING:pympress.util:Unsupported OS: can't enable/disable screensaver
WARNING:pympress.util:Unsupported OS: can't enable/disable screensaver

@cgevans
Copy link
Contributor

cgevans commented Mar 22, 2023

The problem here is that, under Wayland, Gtk.Window.get_position does not actually return meaningful values. As pympress determines which display each window is on by using the window position, it thinks both content and presenter are on the same display, and doesn't swap them.

@Cimbali
Copy link
Owner

Cimbali commented Mar 22, 2023

I think Wayland support is (supposed to be) better in Gtk 4, but the list of breaking changes is very long (see #267) so it’s unlikely I have the time to port pympress any time soon. Also I’d have to figure out what the implications are for currently supported platforms (e.g. does Gtk 4 compile on Windows? Is there support for shipping the Gtk 4 dlls in an installer ? etc.)

So unfortunately we’re kind of stuck with sub-optimal Wayland support for now.

@Cimbali
Copy link
Owner

Cimbali commented Mar 23, 2023

From Gtk docs:

Some windowing systems, such as Wayland, do not support a global coordinate system, and thus the position of the window will always be (0, 0).

Does set_position do anything @cgevans? I.e. does current master, which includes your patch #284, start the 2 windows on different screens? I suppose not? Do you know if maybe Gtk.Window.fullscreen_on_monitor does anything?

@Cimbali
Copy link
Owner

Cimbali commented Mar 23, 2023

Actually my system now ships wayland as opposed to 4 years ago and I’ve been able to test things. Closing as Wayland does not support the concept of moving windows, so switching screens make no sense. I’ll add a best-effort auto-fullscreen for wayland.

@Cimbali Cimbali closed this as not planned Won't fix, can't repro, duplicate, stale Mar 23, 2023
Cimbali added a commit that referenced this issue Mar 23, 2023
Includes:
- Refactoring of ScreenArea with Monitor as a child class
- use fullscreen_at_monitor() to provide on-startup fullscreen
- disable swap-screens functionality as it can not be provided, see #99
smbct pushed a commit to smbct/pympress that referenced this issue Aug 4, 2023
In Wayland, fail the the enabling/disabling of screensavers with a
simple warning.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants