J-Lentz / iwgtk

Lightweight wireless networking GUI (front-end for iwd)
GNU General Public License v3.0
204 stars 14 forks source link

Fixes bug that causes multiple windows to open if the window is open but does not have focus when clicking taskbar icon #7

Closed Thulinma closed 4 years ago

Thulinma commented 4 years ago

As the title suggests!

To reproduce this bug:

I don't think this was intentional...? At least it's not what a user would expect I think. 😉 This pull request changes the behavior to simply close any open window(s) on click, and only opens a new one when none were closed.

J-Lentz commented 4 years ago

Hello Thulinma!

My assumption was that if there's an iwgtk window open in the background or in another workspace, and a user clicks the indicator, his intention is probably to open a window in the current workspace rather than to close the window in the background. But perhaps the more common scenario is that a user opens an iwgtk window, changes the focus to something else, and then wants to close it. There's no straightforward way to differentiate between the two cases, so this PR is an improvement over the original behavior, but I think it would be more intuitive if it only closed the most recently opened window (the first one in the global.windows list) rather than closing all of them. What are your thoughts on this?

Thulinma commented 4 years ago

Fair point, I can follow that logic, certainly.

Personally, I use a tiling window manager where window focus follow the mouse pointer. In this kind of environment it's very likely to "accidentally" focus another window before going back to the indicator icon, causing a second window to pop up when the intent was to close it.

I see no practical purpose to having more than one window open at any time, regardless of context. But perhaps my imagination is too limited...? I didn't think anyone would want to accidentally have multiple windows, so figured closing all of them when any are open made most sense. Most other applications with indicators that I'm aware of will simply toggle a single window on/off when clicked, some others will focus an already-open window when clicked, but I've never encountered any other application that would open multiple windows like this. 🙂

hhl commented 4 years ago

Well, I was wondering why there are more than one window open. Now I know why! I tried to close the window by clicking on the indicator-icon while another window had focus. I am with Thulinma, I see no real use case for more than one open instance of this little, great program, i wanna thank you for it! There are programs where it is really useful, but they have an extra menu point to open a new instance, not by clicking on the tray/indicator-icon.

J-Lentz commented 4 years ago

I agree that multiple windows probably aren't useful in practice. So if that's the consensus, perhaps it would simplify things to not allow multiple windows in the first place. The most intuitive approach, I think, would be to raise the existing window with gtk_window_present() if the user attempts to open a second window.

J-Lentz commented 4 years ago

Commit 097d5f793719ee3909fe0994e0f7a540ae81b450 removes support for multiple windows entirely. gtk_window_present() doesn't work on my desktop (Sway 1.5), so for now, if the user attempts to open the application while a window already exists, the old window is destroyed and a new one is created.