Window can be both Maximized and Minimized‽
I tried this on Ubuntu X64. But there is a nonsensical way to get a window to be minimized and maximized at the same time. I think I am understanding this correctly, but perhaps I just need an explanation because the Docs said this could happen, I just thought it would make sense when it did.
Steps to reproduce and explanation:
When I launch an application, create a Robot::Window that finds it, when I first query Robot::Window::IsMinimized() and Robot::Window::IsMaximized() they return false, this seems correct. Then I call Robot::Window::SetMaximized(true) and the window is visibly maximized and Robot::Window::IsMinimized() false while Robot::Window::IsMaximized() it returns true. Ok, so far so good.
Here is where it gets weird. If I then call Robot::Window::SetMinimized(true) both Robot::Window::IsMinimized() and Robot::Window::IsMaximized() return true. This does not seem normal X11/GTK these states ought to be mutually exclusive.
I can workaround this by calling data->window.SetMinimized(false) before maximizing and data->window.SetMaximized(false) before every minimization, but that step does not seem required and seems to be an unneeded wart for newcomers on this library's API.
Possible explanation and fix:
Is there some reason for this I am unaware of? I have no explanation, perhaps on some obscure window manager (that uses GTK still) it makes sense for a window to be maximized and minimized, there are some crazy UIs out there.
I looked at the implementation of both Window::SetMinimized (bool state) and void Window::SetMaximized (bool state) I noticed maximized had an extra line at 1028 that appears to missing from the corresponding location in the minimize implementation.
When I add SetState (mData->XWin, STATE_MAXIMIZE, false); all my tests now pass and my code appears to correctly detect minimization and maximization using Robot. Is that a good idea to do? I really don't know what is going on with X11 code here or in general really.
Hey, so why can't a maximized window be minimized? or am I misunderstanding the question? You can minimize a maximized window to the taskbar and then restore it and it'll still be maximized. Therefore, it's maximized when it's minimized, if that makes any sense.
The obscure window manager you're talking about is probably Windows because the line you're referring to is specifically to make the function behave the same on Linux as it does on Windows. On Windows, when you change the maximize settings, the window becomes unminimized if it was minimized. That line is to ensure that Linux does the same thing.
Both these functions went through multiple transformations before being implemented the way they are, it's probably not the ideal situation but it's also not an oversight.
Is my code in particular confusing or just X11 itself? I've looked a dozens of different X11 applications and it's usually very difficult to understand what's going on until you've dissected the application. I did my best to make everything as clean as possible but there's only so much I could do.
P.S. Sorry for the lateness of this reply, I only noticed the issue today.
It is probably just X11. This appears to be a Linux only issue.
If minimized after maximized the both of the functions Robot::Window::IsMinimized() and Robot::Window::IsMaximized() return true. Should a minimized window return true for IsMaximized()?
It is not really a priority I am just notifying you selfishly. If I contribute fixes I don't need to maintain them. ;)
Linux was... difficult, just as Mac was and when I did test these particular functions I only really tested them on Ubuntu 14 and later Ubuntu 12. I'm aware that other distributions have their own problems but I'm not sure that it's something I'm able to fix.
As far as I know, a minimized window should only be maximized if it was maximized prior to being minimized. That's how it works on Windows at least. But I digress, I'm not even sure it's a problem. I will happily review this functionality again prior to the next release though.
If you think that is an appropriate behavior then I will not argue. I think I understand why you say it should be there. When brought out of a minimized state does the the window become restored or minimized? This extra bit could be used to answer that question.
If you choose to patch this to remove this functionality then you can use this line to do so: https://github.com/Sqeaky/robot/commit/60a11701a5560d1d70d43f415028a44480a7946c?diff=split
If you choose to keep functionality as is, either remove that line when merging or let me know and I will remove from my repo prior to the merge.
So the behaviour should actually be identical to the test cases. Anytime setMaximize gets used it'll unminimize the window if it gets minimized. Anytime setMinimize gets used, it won't (or shouldn't) affect the maximize state.
But I'll take a look at your change either way, just to make sure!
I removed the changed from my fork in commit dec636ba79 so when you integrate it will be easier for you.
I agree that we should do what we can to maximize cross-platform compatibility. Even though this is one minor point I can see how this can minimize effort for library users.
I think we can close this issue, but I am reluctant to close issues on projects that I do not run.
Hey there, yes I've actually started looking at your changes and so far so good. I'm just currently reading up on new reverse engineering techniques. I think I learned more in the past two months than I did in the past two years. Yeah, lets leave this open for now cause I want to remember to review this functionality later.