Betterbird / thunderbird-patches

Betterbird is a fork of Mozilla Thunderbird. Here are the patches that provide all the goodness.
Other
468 stars 20 forks source link

Clicking the icon tray should not only restore, but also minimize it back #198

Closed dark-penguin closed 1 year ago

dark-penguin commented 1 year ago

Click the icon once - restore from tray (now works, even on MATE: #111 ) Click the icon once more - minimize it back (currently does nothing) - would be a huge improvement (at least for me), should be easy to implement, and I don't see any potential drawbacks since it currently does nothing!

It might be a usability improvement to also add a context menu on right-click with "New message" and most importantly "Exit", which would bring feature parity with FireTray. I don't use "New Message", but I do use "Exit".

Betterbird commented 1 year ago

I don't see any potential drawbacks since it currently does nothing!

You didn't look correctly. If you click now, it brings any BB windows to the front.

This is aligned with the established functionality on Windows. It's also technically quite challenging to find all open windows and mininise them. Currently minimising is triggered on the control of the respective window.

dark-penguin commented 1 year ago

You didn't look correctly. If you click now, it brings any BB windows to the front.

On MATE, it does not. %) But this is not a big deal.

I forgot you that can have multiple open windows. I can not, because I run it with --no-remote . Maybe I could keep it as a local patch, but anyway I don't suppose finding one window is any easier than finding all of them?

Betterbird commented 1 year ago

-no-remote doesn't stop you opening a folder in a new window. BTW, -no-remote is the biggest cannon you can drive at the sparrow, try -new-instance.

Hard to believe that the window doesn't come forward, the code is here and in the following lines: https://github.com/Betterbird/thunderbird-patches/blob/ae2d2bdd607e4c6089799045c9935fe012fd45c8/115/features/13-feature-linux-minimise-to-tray.patch#L299

dark-penguin commented 1 year ago

I also have Thunderbird 45.8.0 running as my "main" mail client, so I want the biggest cannon possible to prevent them from interfering with each other. :)

Hm, I have some experience with PyQt, but not with GTK or C. In PyQt documentation, it says right away: "Bringing a window to the foreground is not supported by almost any window manager. The only way to do it reliably is to display a message box as a child of your window, and then immediately hide it". That's what I do in PyQt. There is an "activate" or "focus" or something method too, but it does not work either.

dark-penguin commented 1 year ago

By the way... Seems like there is no problem finding a minimized window. But that's because you store them in an array when they are minimized (from the window's context), right?.. How about moving them to another array of "previously minimized windows" instead of just popping them out? Then you can minimize all windows that were minimized at least once before. And that's fine, because the only situation where this behaviour is really used is when I pop out a window to peek at it, and then immediately minimize it back. If I'm interacting with a window that has never been minimized yet, then it's no problem to reach for the taskbar to minimize it properly.

I understand that it's not the "desired behaviour" for you though, because of legacy compatibility. But that's what FireTray does, so I believe at least some people would be happy to have it - even in this mostly-working state. Could it be opt-in with a config option perhaps?

Betterbird commented 1 year ago

I've tried on Xfce again and when the window isn't minimised, a click on the system tray icon brings it to the front using the Mozilla code I pointed out. One could try gtk_window_present() as well here. (But at some stage, we need some sort of weekend.)

dark-penguin commented 1 year ago

But at some stage, we need some sort of weekend.

No urgency here, this is already a cherry on top of the heap of features we got working today! With this, my email setup is plenty comfortable already, it mimics almost all features I'm using with FireTray (which was the reason I couldn't upgrade since 45.8.0 !).

Regarding bringing a window to the front: this could be due to a window manager's attempt to discard "activate" calls to avoid raising windows "right under your mouse". And by the way, I've already encountered similar behaviour once in the past, with some corporate ERP that was being ported to Linux. %) So I believe a messagebox is the only way.

Unless you want to change this behaviour into minimizing the window instead! ;)

dark-penguin commented 1 year ago

You know what, I've got an idea! It's amazing what washing the dishes does to you!

    icon.clicked():  // icon context
window.toFront()

    window.toFront():  // window context
if this.alreadyAtFront -> this.minimize;  // window context, no problem!
else -> {
    modal_child.show();
    event_loop.schedule(in 10 msec, modal_child.close() )  // This is how you do it in Qt
}
Betterbird commented 1 year ago

It's amazing what washing the dishes does to you!

Come and wash mine 😉. We'll be looking at Issue #200 next, this one here is a WONTFIX, unless we want to improve bringing the window to the front better on Mate. As we said, works fine on Xfce. Another click won't minimise again, that will not be implemented, also for consistency with Windows.

Betterbird commented 1 year ago

@felixoi @Zahrun: On Gnome/KDE, when minimise to tray is enabled but you have no minimised window, instead to put other windows on top of the BB window, does a click (Gnome: double-click) onto the tray icon bring the BB to the top? Is does on Xfce but the reporter here claims that it doesn't work on Mate.

dark-penguin commented 1 year ago

I just clicked the icon (while having BB minimized), and it appeared... in the correct position... behind other windows. %)

Zahrun commented 1 year ago

I’m not sure to understand what is to be tested exactly. I have bb open, the window is not minimised, and I have other windows on top of it. If I click on the systray, the window calls for attention, its icon glows in the taskbar and latte dock unhides and shows bb icon bumping, although the bb window does not come on top of other window. Did I understand the test correctly?

Betterbird commented 1 year ago

I just clicked the icon (while having BB minimized), and it appeared... in the correct position... behind other windows. %)

Just shows that Mate is a hopeless case. gtk_windows_present() should "present" the window to the user.

Did I understand the test correctly?

Thanks for testing, yes, you understood correctly. That's KDE? So the window doesn't come to the top. Jolly bad, another difference in behaviour between desktops. This is really a mess. How can we cater to the behaviour of at least five different desktops? At a user ratio of 1%. I don't want to sound terrible, but dropping Linux altogether wouldn't cause any negative effect on the project.

dark-penguin commented 1 year ago

Would it be unreasonably difficult to create a child modal window for 10 msec and then hide it afterwards?

Betterbird commented 1 year ago

Anything is possible given time and $$$. Have you read the last paragraph of two comments up?

dark-penguin commented 1 year ago

I did, which is why I'm suggesting a fix that would work for any window manager. "present()" and the likes in any graphical library use a call that is typically ignored by all window managers - because unlike Windows, we have "focus steal prevention" which is now commonplace. The standard, always-working, recommended in the official documentation way is to create a child modal window and destroy it after a short delay (but not immediately!). This also works on Windows, so it does not require any platform-specific code.

Betterbird commented 1 year ago

This also works on Windows, so it does not require any platform-specific code.

You're kidding. Since when does Gtk programming have anything to do with MS Windows?

dark-penguin commented 1 year ago

I mean, this solution does not depend on the specific library you are using, be it GTK, Qt, or whatever Thunderbird uses for Windows (I don't know if it's also GTK or one of Windows-specific libraries directly). But nothing will break even if you do the same trick with other libraries even when it's not necessary.

Betterbird commented 1 year ago

FYI, Windows uses native Win32 calls. The code for the various platforms is completely separate. Besides, why should we touch it if it works.

The discussion is totally OT in this ticket/issue. If you want the activation behaviour to be improved, please file another issue.

felixoi commented 1 year ago

On Gnome/KDE, when minimise to tray is enabled but you have no minimised window, instead to put other windows on top of the BB window, does a click (Gnome: double-click) onto the tray icon bring the BB to the top? Is does on Xfce but the reporter here claims that it doesn't work on Mate.

Well the tray icon is only there if it's minimized or am i missing something?

dark-penguin commented 1 year ago

You are - there is an option to make it "always there", but changing into another icon when you have new mail.

Betterbird commented 1 year ago

Pref mail.biff.show_tray_icon_always

felixoi commented 1 year ago

Ok, thanks. I can confirm that on GNOME it does not bring BB to the top.

Betterbird commented 1 year ago

Thanks for testing. For Issue #200 we'll rework activation completely, so this is likely to improve. We'll ping you from the other ticket.