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

[WIP] a floating window widget for Variety #87

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

jlu5
Copy link
Member

@jlu5 jlu5 commented Oct 4, 2018

Would resolve #12 by creating a floating window for Variety (e.g. when the tray / indicator is not available).

TODO:

  • Draw a translucent window with the Variety icon
  • Disable window decorations and add custom code to handle dragging the widget
  • Widget should bring up Variety menu when right clicked
  • Options to show / hide the widget in the Variety menu (and/or preferences?). Afterwards, only an explicit run of variety --floating should bring it back up.
  • Option to set normal / always on top / always on bottom modes
  • Preferably make the floating widget remember its position
  • Intercept iconify (show desktop) events, as in Tray icon alternative on GNOME, etc. #12 (comment)
  • Once there's proper in-app management of the widget, remove it from the taskbar
  • Allow changing the wallpaper when scrolling on the icon
  • Maybe: allow the widget's opacity to be configured in preferences
  • Possibly make showing the floating icon the default instead of the preferences dialog?

These work equally fine in other DEs: Xfce, GNOME, etc.
On right click or any double click, the floating window will pop up the Variety menu.

It supports dragging to move the icon when LMB is held, but that means we can't use a single left click to popup the menu (since that would make the window itself lose focus).
@jlu5
Copy link
Member Author

jlu5 commented Oct 4, 2018

Here's what it looks like so far: https://www.dropbox.com/s/ytqcfdziuko7rew/variety-floating.mp4?dl=0

Client-initiated window movement doesn't seem to work there.
@jlu5
Copy link
Member Author

jlu5 commented Oct 4, 2018

In Wayland I can't turn off decorations and still allow movement, but at least we have menu access now.

screenshot_2018-10-04_12-15-45

@jlu5
Copy link
Member Author

jlu5 commented Oct 6, 2018

@peterlevi Any thoughts on this so far?

@peterlevi
Copy link
Member

@jlu5 Still haven't had a chance to look at the code, just ran the branch briefly, some initial thoughts:

  • I think showing this control widget should be an option, pretty much alongside the option to configure the tray icon, and it should be off by default - on systems where the tray icon works (I have tried on Ubuntu 16.04 and 18.04 and on both of their default setups it does), it is still a better option than putting anything on the desktop.
    However, once we have it, our response to all bugreports of the kind "tray icon does not work" should probably be "OK, this is not fully supported anymore, try the option for a floating control window".

  • I think "--preferences" is the proper default behavior, not "--floating". And in time we should make Variety controllable from its preferences window, so that the need for additional control means is not as important. Generally I think we should consider this control widget only as this - a simple control widget displayed on the wallpaper itself, and not make it an alternative "representation" of Variety. Therefore, I also think the proper mode for it is definitely below-all, and ideally it won't appear as a window in Alt-Tab and in the list of programs in the dash.

  • On my machine (16.04) if I run with --floating, it appears in the top-left corner with zero margin off the corner, which is not the best default location. Probably somewhere close to the tray icon (top-right), with some margin would be best default place.

  • Right-click fails to show the menu with
    Traceback (most recent call last):
    File "/home/peter/dev/variety/variety/FloatingWindow.py", line 82, in handle_click
    self.parent.ind.menu.popup_at_pointer(event)
    AttributeError: 'Menu' object has no attribute 'popup_at_pointer'

  • We may want to make it even smaller and more transparent than it currently is. Also, we may want to use the current less-obtrusive grayscale indicator icon instead of the app icon, so that we don't add additional colors to what the user sees on the desktop.

  • Using both left and right click for the menu probably makes sense (this is how tray indicators behave as well). It's a bit tricky to distinguish dragging from left-clicking, but it's doable.

Will try to find time in the next couple of days to take a look at the code. Thanks and regards, Peter.

@jlu5
Copy link
Member Author

jlu5 commented Oct 7, 2018

@jlu5 Still haven't had a chance to look at the code, just ran the branch briefly, some initial thoughts:

I think showing this control widget should be an option, pretty much alongside the option to configure the tray icon, and it should be off by default - on systems where the tray icon works (I have tried on Ubuntu 16.04 and 18.04 and on both of their default setups it does), it is still a better option than putting anything on the desktop.
However, once we have it, our response to all bugreports of the kind "tray icon does not work" should probably be "OK, this is not fully supported anymore, try the option for a floating control window".

Tray icon does not work for me on Ubuntu 18.04 GNOME out of the box. So, I think we definitely want the floating icon to be visible on GNOME desktops.

I think "--preferences" is the proper default behavior, not "--floating".

Fair enough.

And in time we should make Variety controllable from its preferences window, so that the need for additional control means is not as important.

OK, I agree. Should that be tracked as a different issue?

Generally I think we should consider this control widget only as this - a simple control widget displayed on the wallpaper itself, and not make it an alternative "representation" of Variety. Therefore, I also think the proper mode for it is definitely below-all, and ideally it won't appear as a window in Alt-Tab and in the list of programs in the dash.

My plan is to hide it from the window list once its display can be controlled in a more fine grained manner.

On my machine (16.04) if I run with --floating, it appears in the top-left corner with zero margin off the corner, which is not the best default location. Probably somewhere close to the tray icon (top-right), with some margin would be best default place.

It shows at the center of the screen for me on Xfce. Maybe that's a better place? There's no guarantee that the tray is at the bottom right as many DEs offer configurable panel placement.

Right-click fails to show the menu with
Traceback (most recent call last):
File "/home/peter/dev/variety/variety/FloatingWindow.py", line 82, in handle_click
self.parent.ind.menu.popup_at_pointer(event)
AttributeError: 'Menu' object has no attribute 'popup_at_pointer'

Oh right, that was added in GTK+ 3.22... I don't know what the equivalent is for older versions

We may want to make it even smaller and more transparent than it currently is. Also, we may want to
use the current less-obtrusive grayscale indicator icon instead of the app icon, so that we don't add
additional colors to what the user sees on the desktop.

This is very icon theme dependent. I actually like the Numix-Circle variant of the icon more than the stock one, since it has a more regular shape.

I think opacity should definitely be configurable, and maybe size. There are only a few default sizes to pick from (and they are the ones that probably scale best), https://valadoc.org/gtk+-3.0/Gtk.IconSize.html

Using both left and right click for the menu probably makes sense (this is how tray indicators behave as well). It's a bit tricky to distinguish dragging from left-clicking, but it's doable.

I couldn't get that working; raising the menu causes the widget to defocus, and we don't want any attempted drag action to pull up the menu. Maybe a delay would work here?

Will try to find time in the next couple of days to take a look at the code. Thanks and regards, Peter.

Cheers :)

@jlu5
Copy link
Member Author

jlu5 commented Oct 7, 2018

Some more thoughts on preferences integration:

  • I think if the floating icon is disabled in preferences, running variety --floating would re-enable that option and force the floating icon open.
  • Running variety --floating when the icon is already enabled should maybe force-focus it? But I don't know if that's possible if we use a below-all window.

I know it probably makes sense to make the controls available in the preferences dialog, but I feel that only doing that is still a clunky solution. The dialog fills up quite a lot of the screen if someone wants to scroll between wallpapers and see how they look.

@peterlevi
Copy link
Member

OK, I agree. Should that be tracked as a different issue?

Probably, though it's kind of a far-future wishlist one. There's multiple more important things than this.

On my machine (16.04) if I run with --floating, it appears in the top-left corner with zero margin off the corner, which is not the best default location. Probably somewhere close to the tray icon (top-right), with some margin would be best default place.

It shows at the center of the screen for me on Xfce. Maybe that's a better place? There's no guarantee that the tray is at the bottom right as many DEs offer configurable panel placement.

Center I would consider the worst possible place - it'll be like an eye-sore for most users in the center of their beautiful wallpaper :)
Left-top is pretty much the standard for icons like trash, mounts, shortcuts, in most DEs.
Right-hand side top or bottom are both OK, but I suppose the tray is at the top for a quite bigger proportion of users. Normally statistics should be driving such decisions, 2-3 years ago Ubuntu was so much more popular than anything else, that it was easy, right now I'm not sure how things are.

Right-click fails to show the menu with
Traceback (most recent call last):
File "/home/peter/dev/variety/variety/FloatingWindow.py", line 82, in handle_click
self.parent.ind.menu.popup_at_pointer(event)
AttributeError: 'Menu' object has no attribute 'popup_at_pointer'

Oh right, that was added in GTK+ 3.22... I don't know what the equivalent is for older versions

I think whatever we use now for the "Add..." button. We had bugfixes targeting this.

We may want to make it even smaller and more transparent than it currently is. Also, we may want to
use the current less-obtrusive grayscale indicator icon instead of the app icon, so that we don't add
additional colors to what the user sees on the desktop.

This is very icon theme dependent. I actually like the Numix-Circle variant of the icon more than the stock one, since it has a more regular shape.

Ok, no matter which icon variant we use, I'm pretty certain it should be a very toned down greyscale, flat-looking thing, and I think the default indicator icon fits this description better than the app icon. We may want to prepare a dedicated third one and so that it is also separately themeable.

I think opacity should definitely be configurable, and maybe size. There are only a few default sizes to pick from (and they are the ones that probably scale best), https://valadoc.org/gtk+-3.0/Gtk.IconSize.html

What could work to solve several of the mentioned issues (Wayland, dragging vs left-clicking, size configuration) is a right-click menu item "Configure widget placement...", which would make the widget window decorated and allow the user to move and scale it. Thus we won't have to rely on custom code for dragging and won't need dedicated GUI options for size.

@peterlevi
Copy link
Member

  • I think if the floating icon is disabled in preferences, running variety --floating would re-enable that option and force the floating icon open.
  • Running variety --floating when the icon is already enabled should maybe force-focus it? But I don't know if that's possible if we use a below-all window.

I'm trying to say that we should not consider this icon as having "open" and "non-open" or "focused"/ "non-focused" states. It should only have "enabled" (therefore always shown), and "disabled" (therefore not shown) states. So the --floating option could be used as a toggle for this and maybe should be more appropriately named --toggle-control-widget.

  • An option could be added to the right click menu to quickly disable/enable the floating icon - this should be synced with Preferences.

I wouldn't hurry with this, unless we add it only when triggered from the control widget itself (and if we group all control-widget related menuitems in a single submenu). The right-click menu is already quite overloaded.

I know it probably makes sense to make the controls available in the preferences dialog, but I feel that only doing that is still a clunky solution. The dialog fills up quite a lot of the screen if someone wants to scroll between wallpapers and see how they look.

True, that's why I think this is a far-future wishlist item that's not so important.

@jlu5
Copy link
Member Author

jlu5 commented Oct 7, 2018

Center I would consider the worst possible place - it'll be like an eye-sore for most users in the center of their beautiful wallpaper :)
Left-top is pretty much the standard for icons like trash, mounts, shortcuts, in most DEs.
Right-hand side top or bottom are both OK, but I suppose the tray is at the top for a quite bigger proportion of users. Normally statistics should be driving such decisions, 2-3 years ago Ubuntu was so much more popular than anything else, that it was easy, right now I'm not sure how things are.

I don't really know what makes sense as a default then.

Ok, no matter which icon variant we use, I'm pretty certain it should be a very toned down greyscale, flat-looking thing, and I think the default indicator icon fits this description better than the app icon. We may want to prepare a dedicated third one and so that it is also separately themeable.

The indicator icon would have to be made scalable then (It's currently a .png)
I think a separate icon name could also work here.

What could work to solve several of the mentioned issues (Wayland, dragging vs left-clicking, size configuration) is a right-click menu item "Configure widget placement...", which would make the widget window decorated and allow the user to move and scale it. Thus we won't have to rely on custom code for dragging and won't need dedicated GUI options for size.

That sounds fine, assuming that enabling / disabling decorations on runtime won't actually affect the window contents' position. (I do like the dragging ability on Xorg though - it just seems like an elegant, straightforward way to control it)


I'm trying to say that we should not consider this icon as having "open" and "non-open" or "focused"/ "non-focused" states. It should only have "enabled" (therefore always shown), and "disabled" (therefore not shown) states. So the --floating option could be used as a toggle for this and maybe should be more appropriately named --toggle-control-widget.

"focused" / "non-focused" wouldn't be a state per se, it would just be asking the WM to bring it to the top temporarily, if possible. Maybe this option can be removed once there's proper configuration, so far it's just been helpful for testing.

I guess we're also assuming that intercepting iconify actually works on Wayland. I haven't tried yet but I'm skeptical; a lot of client-side window controls don't seem to work at all. (If we can't stick to the desktop properly, we'll need some other way of displaying it consistently...)

I wouldn't hurry with this, unless we add it only when triggered from the control widget itself (and if we group all control-widget related menuitems in a single submenu). The right-click menu is already quite overloaded.

I just made the floating icon show the same menu as the indicator to reduce code duplication. edit: If we use a single option to show/hide the floating widget, would a subgroup still be needed?

if os.environ.get('XDG_SESSION_TYPE') != 'wayland': # Movement tracking doesn't work on Wayland :(
self.set_decorated(False)
self.set_accept_focus(True)
self.set_title('Variety')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we won't see the title anywhere, but probably still makes sense to use a descriptive one for this specific window - e.g. "Variety Control"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The title is always shown on GNOME/Wayland since it doesn't seem undecorated windows are able to move themselves.

@peterlevi
Copy link
Member

Checked the code, looks good to me so far.

@jlu5
Copy link
Member Author

jlu5 commented Feb 2, 2019

So, the status of this, several months later:

  • Widget placement: I'm assuming that the tray icon should by all means remember its last position. The issue is where the widget should start initially, since there is no "standard" layout for panels and whatnot on all Linux desktops
  • I have to figure out how the configuration system works in order to save whether the widget is enabled & its position
  • Need to implement a popup_at_pointer alternative for GTK+ < 3.22
  • Track a whitelist of desktops to turn on the widget by default (currently GNOME and Elementary OS Variety icon not visible in system tray, elementary OS [Juno] #103?)
    • When running Variety from the command line, it should throw up the widget again on these desktops if it has somehow been closed.. Maybe we should add an extra mode: off/on/auto?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tray icon alternative on GNOME, etc.
2 participants